akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

int dp[10010];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, n; cin >> h >> n;
	VE a(n), b(n); rep(i, n)cin >> a[i] >> b[i];
	
	for (int i = 1; i <= h; i++) {
		int now = INF;
		rep(j, n) {
			now = min(dp[max(0LL, i - a[j])] + b[j], now);
		}
		dp[i] = now;
	}
	cout << dp[h] << endl;
	return 0;
}

Measured memory_bytes: 384
(h,w),*a=[map(int,o.split())for o in open(0)]
B=[];l=[]
for y in range(h):
 *A,=a[y];x=0
 for x in range(1,w):c=A[x-1]%2;l+=[(y+1,x,y+1,x+1)]*c;A[x]+=c
 B+=A[x],
 if y and B[-2]%2:l+=(y,w,y+1,w),;B[y]+=1
print(len(l))
for a in l:print(*a)

Measured memory_bytes: 26004
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int N=2005;
int n,m,a[N],b[N];
ll dp[N][N],sum[N][N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	FOR(i,1,n) cin>>a[i];
	FOR(i,1,m) cin>>b[i];
	dp[0][0]=0;
	sum[0][0]=0;
	FOR(i,1,n)
		FOR(j,1,m){
			if(a[i]==b[j]) dp[i][j]=sum[i-1][j-1]+1;
			else dp[i][j]=0;
			dp[i][j]%=MOD;
			sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j]+MOD)%MOD;
		}
	(sum[n][m]+=1)%=MOD;
	cout<<sum[n][m]<<'\n';
}



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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if ((100*a + 10*b + c)%4 == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
#include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	int num;
	vector<int> vec;
	cin >> num;
	for (int i = 0; i < num; i++) {
		int tmp;
		cin >> tmp;
		vec.push_back(tmp);
	}
	sort(vec.begin(), vec.end());
	long sum = 0;
	for (int i = 0; i < num; i++) {
		if (i == 0) {
			cout << vec[i] << " ";
		}
		if (i == num - 1) {
			cout << vec[i] << " ";
		}
		sum += vec[i];
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}

vll G[N];
ll 	dp[N][2];

ll dfs(ll node,ll parent,ll k)
{
	if(sz(G[node])==1 && node!=parent)
	{
		dp[node][k]=1;
		return 1;
	}
	if(dp[node][k]!=-1)
	{
		return dp[node][k];
	}
	ll i,ans=1;
	for(i=0;i<sz(G[node]);i++)
	{
		if(parent!=G[node][i])
		{
			if(k==0)
			{
				ans=(ans*(dfs(G[node][i],node,0)+dfs(G[node][i],node,1)))%mod;
			}
			else
			{
				ans=(ans*dfs(G[node][i],node,0))%mod;
			}
		}
	}
	dp[node][k]=ans;
	return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,u,v,ans,k1,k2;
    cin>>n;
    for(i=1;i<n;i++)
    {
    	cin>>u>>v;
    	G[u].pb(v);
    	G[v].pb(u);
    }
    memset(dp,-1,sizeof(dp));
    k1=dfs(1,1,0);
    k2=dfs(1,1,1);
    ans=(k1+k2)%mod;
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 52616
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int N; cin >> N;
    string res(2*N, '?');
    cout << "?";
    for(int i=1;i<=N;i++) cout << " " << i;
    cout << endl;
    string query0; cin >> query0;
    int L = 0, R = N;
    while(R - L > 1){
        cout << "?";
        int mid = (L+R)/2;
        for(int i=1;i<=N;i++) cout << " " << i+mid;
        cout << endl;
        string q; cin >> q;
        if(query0 == q) L = mid;
        else R = mid;
    }
    res[L] = query0[0];
    res[L+N] = (res[L] == 'B' ? 'R' : 'B');
    auto calcIdx = [&](int idx){
        while(idx > 2*N) idx -= 2*N;
        return idx;
    };
    for(int i=L;i<=L+N;i+=N){
        for(int j=2;j<=N;j++){ 
            cout << "? " << calcIdx(i+j);
            for(int k=2;k<=N;k++){
                cout << " " << calcIdx(i+k+N);
            }
            cout << endl;
            string q; cin >> q;
            res[(i+j-1)%(2*N)] = q[0];
        }
    }
    cout << "! " << res << endl;
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

int main(void) {
    ll a,b,x; cin >>a>>b>>x;

	if (a+b-x>-1&&x-a>-1) cout <<"YES"<<endl;
	else cout <<"NO"<<endl;
	
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a*a + b*b <=c*c){
    cout << (a*b)/2 << endl;
  }else{
    cout << (a*c)/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
int h, w, s;
int U[33][33];
pair<int,int> DP[33][33][33][33];
const pair<int,int> zero(0,0);
int rect_sum(int t, int l, int b, int r){
  return U[b][r] - U[t][r] - U[b][l] + U[t][l];
}

pair<int,int> dfs(int t, int l, int b, int r){
  if(DP[t][l][b][r] != zero) return DP[t][l][b][r];
  pair<int,int> ret(1,s-(U[h][w]-rect_sum(t,l,b,r)));
  for(int i = t+1; i < b; ++i){
    if(U[h][w] - min(rect_sum(t,l,i,r),rect_sum(i,l,b,r)) > s) continue;
    pair<int,int> ret_l = dfs(t,l,i,r), ret_r = dfs(i,l,b,r);
    pair<int,int> ret_(ret_l.first+ret_r.first, min(ret_l.second, ret_r.second));
    ret = max(ret, ret_);
  }
  for(int i = l+1; i < r; ++i){
    if(U[h][w] - min(rect_sum(t,l,b,i),rect_sum(t,i,b,r)) > s) continue;
    pair<int,int> ret_l = dfs(t,l,b,i), ret_r = dfs(t,i,b,r);
    pair<int,int> ret_(ret_l.first+ret_r.first, min(ret_l.second, ret_r.second));
    ret = max(ret, ret_);
  }
  //cerr << "t, l, b, r = " << t << " " << l << " " << b << " " << r << ", ret = " << ret.first << ", " << ret.second << endl;
  DP[t][l][b][r] = ret;
  return ret;
}

int main(){
  while(cin >> h >> w >> s, h){
    for(int i = 0; i <= h; ++i) U[i][0] = 0;
    for(int j = 0; j <= w; ++j) U[0][j] = 0;
    for(int i = 0; i <= h; ++i)
      for(int j = 0; j <= w; ++j)
        for(int k = 0; k <= h; ++k)
          for(int l = 0; l <= w; ++l)
            DP[i][j][k][l] = zero;
    for(int i = 0; i < h; ++i)
      for(int j = 0; j < w; ++j)
        cin >> U[i+1][j+1];
    for(int i = 1; i <= h; ++i){
      for(int j = 1; j <= w; ++j)
        U[i][j] += U[i][j-1];
      for(int j = 1; j <= w; ++j)
        U[i][j] += U[i-1][j];
    }
    pair<int,int> ans = dfs(0,0,h,w);
    cout << ans.first << " " << ans.second << endl;
  }
  return 0;
}



Measured memory_bytes: 12344
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
//constexpr long long MOD = 1000000007;

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

int main()
{
  std::string S;
  std::cin >> S;
  std::deque<char> deq(S.begin(), S.end());
  int Q;
  std::cin >> Q;
  bool head = true;
  while(Q--)
  {
    int T, F;
    char C;
    std::cin >> T;
    if(T == 1)
    {
      head = !head;
    }
    else
    {
      std::cin >> F >> C;
      if(head)
      {
        if(F == 1)
          deq.push_front(C);
        else
          deq.push_back(C);
      }
      else
      {
        if(F == 1)
          deq.push_back(C);
        else
          deq.push_front(C);
      }
    }
  }
  if(head)
  {
    for(auto c: deq)
      std::cout << c;
  }
  else
  {
    for(auto it = deq.rbegin(); it != deq.rend(); ++it)
      std::cout << *it;
  }
  std::cout << std::endl;
  return 0;
}



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

using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  string ans;
  
  if ((A == B & B != C) || (A == C & B != C) || (C == B & A != C)){
    ans = "Yes";
  }
  else{
    ans = "No";
  }
  cout<< ans << endl;
  return 0;
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint modpow(lint a,lint n,lint p){if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**/int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};



int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	int a,b,c,n;
	string s,t;
	in(n);
	int ans=0;
	int hoge=(n+1000-1)/1000;
	int ar=hoge*1000;
	out(ar-n);
	return 0;
}


Measured memory_bytes: 3648
import collections

n=int(input())
a= list(map(int, input().split()))
aa=list(set(a))
sortaa=sorted(aa,reverse=True)
c = collections.Counter(a)
comf=[]
for i in range(len(aa)):
    if i == 0:
        comf.extend([sortaa[i] for ii in range(2*c[sortaa[i]]-1)])
    else:
        comf.extend([sortaa[i] for ii in range(2*c[sortaa[i]])])

print(sum(comf[:n-1]))

Measured memory_bytes: 41156
// #include <iostream>
#include <stdio.h>

int main(){
    
    int A[3];
    int sum = 0;
    for (int i = 0; i < 3; i++){
        // scanf("%lf",&a[i]);
        scanf("%d",&A[i]);
        sum += A[i];
    }
    
    printf("%s",(sum >= 22 ) ? "bust":"win");
    // if(sum > 22){
    //     printf("bust");
    // }else{

    // }
    
    // for (int i = 0; i < 3; i++){
    
    // }
    
    
    
}

Measured memory_bytes: 128
use std::io;
 
fn abs(a:i32, b:i32) -> (String) {
    if a % 2 == 0 {
        return "Even".to_string();
    }
    if b % 2 == 0 {
        return "Even".to_string();
    }
    else {
        return "Odd".to_string();
    }
}
 
fn main() {
    /*
    assert_eq!(abs(3, 4), "Even".to_string());
    assert_eq!(abs(1, 21), "Odd".to_string());
    */
    
	let stdin = io::stdin();
    let mut line = String::new();
    stdin.read_line(&mut line).ok();
    let txt:Vec<_> = line.trim().split(' ').collect();
    let a:i32 = txt[0].parse().unwrap();
    let b:i32 = txt[1].parse().unwrap();
 
    let result = abs(a, b);
    println!("{}", result)
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; i<n; i++)
#define REP2(i, a, b) for(int i=a; i<b; i++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int N;
vector<vector<int>> G;
vector<int> nodes;
long long ans = 0;
vector<long long> pow2;

long long bipow(long long n, long long m){
    if(m==0) return 1;
    if(m%2==0){
        long long tmp = bipow(n, m/2);
        return (tmp*tmp) % MOD;
    }else{
        return (n*bipow(n, m-1)) % MOD;
    }
}

void add(long long &x, long long y){
    x = (x + y) % MOD;
}
void sub(long long &x, long long y){
    x = (x - y + MOD) % MOD;
}

void dfs(int cur, int prv){
    int cnt = 1;
    for(int nxt : G[cur]){
        if(nxt == prv) continue;
        dfs(nxt, cur);
        cnt += nodes[nxt];
    }
    nodes[cur] = cnt;
}

void efs(int cur, int prv){
    add(ans, pow2[N-1]);
    add(ans, G[cur].size()-1);
    for(int nxt : G[cur])
        sub(ans, pow2[nodes[nxt]]);

    for(int nxt : G[cur]){
        if(nxt == prv) continue;
        nodes[cur] -= nodes[nxt];
        nodes[nxt] = N;
        efs(nxt, cur);
        nodes[cur] = N;
    }
}

int main(){
    cin >> N;
    G.resize(N);
    nodes.resize(N);
    pow2.resize(N+1);
    pow2[0] = 1;
    REP(i, N) pow2[i+1] = (pow2[i] * 2) % MOD;

    REP(i, N-1){
        int A, B;
        cin >> A >> B;
        A--; B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    dfs(0, -1);
    efs(0, -1);
    long long inv = bipow(2, (1LL*N*(MOD-2)));
    ans = (ans * inv) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 24704
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n,m;
   
   cin >> n >> m;
  
   int nn = n-1;
   int mm = m-1;
  
   int a = mm/nn;
  
   int b = mm%nn;
  
   if(m!=1){
     
     
   if(b>0){
     cout << a+1 << endl;
   }else{
      cout << a << endl;
   }
  
   }else{
      cout << 0 << endl;
   }
  
   
  return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

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

  int32_t a, b;
  cin >> a >> b;
  int32_t n;
  if (b < 10) {
    n = 10;
  } else if (b < 100) {
    n = 100;
  } else {
    n = 1000;
  }
  int32_t x = a * n + b;
  int32_t c = static_cast<int32_t>(sqrt(static_cast<double>(x)));
  if ((x == c * c) || (x == (c + 1) * (c + 1))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int plan1, plan2;
  plan1 = A * N;
  plan2 = B;
  
  if (plan1 > plan2) {
    cout << plan2 << endl;
  }
  else {
    cout << plan1 << endl;
  }
}


Measured memory_bytes: 256
import numpy as np

N, M = list(map(int, input().split(" ")))
A_list = np.sort(np.asarray(list(map(int, input().split(" ")))))[::-1]
B_list = np.sort(np.asarray(list(map(int, input().split(" ")))))[::-1]

out = 1
a_next_i = 0
b_next_i = 0
for x in range(N*M, 1, -1):
    #if x in A_list and x in B_list:
    if a_next_i < N and x == A_list[a_next_i] and b_next_i < M and x == B_list[b_next_i]:
        kosuu = 1
        a_next_i += 1
        b_next_i += 1
    #elif x in A_list:
    elif a_next_i < N and x == A_list[a_next_i]:
        #kosuu = np.sum(B_list >= x)
        kosuu = b_next_i
        a_next_i += 1
    #elif x in B_list:
    elif b_next_i < M and x == B_list[b_next_i]:
        #kosuu = np.sum(A_list >= x)
        kosuu = a_next_i
        b_next_i += 1
    else:
        #kosuu = np.sum(A_list >= x) * np.sum(B_list >= x) - (N * M - x)
        kosuu = a_next_i * b_next_i - (N * M - x)
    out *= kosuu
    out = out % 1000000007
   
print(out)

#print(A_list)
#print(B_list)

Measured memory_bytes: 14408
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

template <class Type>
class SegmentTree {
    public:
    
    SegmentTree(Type *a, int n, Type Default = 1e9) : DEFAULT(Default) {
        for (size = 1; size < n; ) size <<= 1;
        
        data = (Type *)malloc(sizeof(Type) * size * 2);
        for (int i = 0; i < size * 2; i++) data[i] = DEFAULT;
        for (int i = 0; i < n; i++) data[i + size] = a[i];
        for (int i = size - 1; i > 0; i--) data[i] = min(data[i * 2], data[i * 2 + 1]);
    }
    
    ~SegmentTree() {
        free(data);
    }
    
    void update(int index, Type value) {
        index += size;
        data[index] = value;
        
        while (index > 1) {
            index >>= 1;
            data[index] = min(data[index * 2], data[index * 2 + 1]);
        }
    }
    
    //[x,y)
    Type query(int x, int y) {
        Type value = DEFAULT;
        
        while (0 < x && x + (x & -x) <= y) {
            value = min(value, data[(size + x) / (x & -x)]);
            x += x & -x;
        }
        
        while (x < y) {
            value = min(value, data[(size + y) / (y & -y) - 1]);
            y -= y & -y;
        }
        
        return value;
    }
    
    private:
    
    int size;
    Type DEFAULT;
    Type *data;
};

int a[200000];
int b[200001];

long long dfs(int x, int y, SegmentTree <int> &s) {
    int z, p;
    long long ans = 0;
    
    if (x >= y) return 0;
    if (x + 1 == y) return a[x];
    
    z = s.query(x, y);
    p = b[z];
    
    ans += (long long)(p - x + 1) * (y - p) * z;
    ans += dfs(x, p, s);
    ans += dfs(p + 1, y, s);
    
    return ans;
}

int main() {
    int n, i;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = 0; i < n; i++) b[a[i]] = i;
    
    SegmentTree <int> s(a, n);
    
    printf("%lld\n", dfs(0, n, s));
    
    return 0;
}


Measured memory_bytes: 19456
#include <iostream>
using namespace std;
int main(void){
    
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    
    if(A1 + A2 + A3 >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    
    
}


Measured memory_bytes: 256
import bisect





def main():
    a, b, c = map(int, input().split())
    ans = 0
    data = [a, b, c]
    data.sort()
    while 1:
        if data[0] == data[1] and data[0] == data[2]:
            break
        if data[2] > data[1] and data[2] > data[0]:
            data[1] += 1
            data[0] += 1
        else:
            data[0] += 2
        ans += 1
        data.sort()

    print(ans)







if __name__ == '__main__':
    main()



Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

int main(void){
  char b;
  cin >> b;
  map<char,char> m;
  m['A'] = 'T';
  m['T'] = 'A';
  m['C'] = 'G';
  m['G'] = 'C';
  cout << m[b] << endl;
  return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc129/tasks/abc129_c
# 典型的なDP

MOD = 10**9 + 7
import numpy as np
# dp[i]をi段目までの通りの数とする。
N, M = list(map(int, input().split()))
to_zero = np.full((N + 1), False, dtype=bool)
for _ in range(M):
    to_zero[int(input())] = True  # 床が抜けているところ

# dpテーブルの用意
dp = np.full((N + 1), -1, dtype='int64')
dp[0] = 1
dp[1] = 0 if to_zero[1] else 1
for i in range(2, N + 1):
    dp[i] = 0 if to_zero[i] else dp[i - 2] + dp[i - 1]
    if dp[i] > MOD:
        dp[i] %= MOD

print(dp[-1])


Measured memory_bytes: 17820
#include<cstdio>
using namespace std;
int main(void)
{
	int n,i,j,flg,cnt,x,y;
	int a[15][15];
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		for(i=0;i<n;i++)	
			for(j=0;j<n;j++)	a[i][j]=0;
		y=n/2+1;	x=n/2;
		a[y][x]=1;
		for(i=2;i<=n*n;i++)	{
			y++;	x++;
			flg=0;
			while(flg==0)	{
				if(x>=n)	{
					x=0;
				}
				else if(y>=n)	{
					y=0;
				}
				else if(x<0)	{
					x=n-1;
				}
				else if(a[y][x]!=0)	{
					y++;	x--;
				}
				else {
					flg=1;
				}
			}
			a[y][x]=i;
		}
		for(i=0;i<n;i++)	{
			for(j=0;j<n;j++)	{
				printf("%4d",a[i][j]);
			}
			printf("\n");
		}
	}	
	return 0;
}


Measured memory_bytes: 1044
s = input()
q = int(input())
jun = 1
f = "";t = ""
for _ in range(q):
  
  tmp = input()
  if len(tmp)==1:
    jun = 1 if jun==0 else 0 
  else:
    _,ff,c = tmp.split()
    if jun+int(ff) ==2:
      f = c+f
    else:
      t += c
if jun==1:
  print(f+s+t)
else:
  print((f+s+t)[::-1])
      

Measured memory_bytes: 4500
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n>>k;
  int l[n];
  for(int i = 0; i < n; i++)
    cin >> l[i];
  std::sort(l, l + n);
  std::reverse(l, (l + n));
  int sum = 0;
  for(int i = 0; i < k ; i++)
  	sum += l[i];
  std::cout << sum << std::endl;
  return 0;
}


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

int main(void){
    string x;
    cin>>x;
    stack<char> st;
    rep(i, x.size()){
        if(x[i] == 'S'){
            st.push('S');
        }
        else {
            if(st.size() == 0){
                st.push('T');
            }
            else{
                if(st.top() == 'S') st.pop();
                else st.push('T');
            }
        }
    }
    cout<<st.size()<<endl;
    return 0;
}

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

#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 

#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

const int N =1e3;

int mod= 1e9+7;
int dx[4]={0,0,+1,-1};
int dy[4]={+1,-1,0,0};



void solve(){
 int n;
 cin>>n;
 vi v(n,0);

 rep(i,0,n)
	  cin>>v[i];
 vi dp(n,0);
 
 dp[0]=0;
 

 rep(i,1,n){
  
   if(i==1)
	 dp[i]=dp[i-1]+abs(v[i]-v[i-1]);  
   else if(i-2>=0)
    dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]) );

 }

 cout<<dp[n-1]<<endl;

}



int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
		solve();


	return 0;	   
}


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

using namespace std;

typedef long long ll;
typedef long long unsigned int llui;
typedef long long int lli;
typedef long double float64;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define tr(container, it) \
    for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 


// #define sz(a) int((a).size())
// #define pb push_back
// #define fill(a,v) memset(a,v,sizeof a)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;

#define trace3(x,y,z) cout<< '>' << #x << ':' << x \
        << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;

#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x \
    << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;



inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

#define LSOne(S) (S&(-S))

const double pi = acos(-1);


template<class T> inline T gcd(T a,T b) //NOTES:__gcd(0,0) gives exception
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}

int cmp(double x, double y = 0, double tol = EPS) {
    return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

/////////////////////////////////////////////////////////////////////

/*bool sortby(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.first < b.first);
}*/

const int MAX_N = 4123;

int arr[MAX_N];
 
int main() {
	string s;
	cin>>s;
	s[3]='8';
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
A=0

for i in range(n-2):
    if p[i]<p[i+1]:
        if p[i+1]<p[i+2]:
            A=A+1
    else:
        if p[i+1]>p[i+2]:
            A=A+1

print(A)


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

using namespace std;

typedef long long ll;

const int N=(int)1e5+7;
int n;
int dir[N];
int cnt[N];
int cnt2[N];

void mv()
{
        for(int i=1;i<=n;i++)
                cnt2[i]=0;
        for(int i=1;i<=n;i++)
                cnt2[i+dir[i]]+=cnt[i];
        for(int i=1;i<=n;i++)
                cnt[i]=cnt2[i];
}

void print()
{
        for(int i=1;i<=n;i++)
                cout<<cnt[i]<<" ";
        cout<<"\n";
}
int cnt_r[N];
int cnt_l[N];

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

        //freopen("input","r",stdin);

        string s;
        cin>>s;
        n=(int)s.size();
        for(int i=1;i<=n;i++)
                cnt[i]=1;
        for(int i=1;i<=n;i++)
                if(s[i-1]=='L')
                        dir[i]=-1;
                else
                        dir[i]=+1;

        for(int i=1;i<=n;i++)
                if(s[i-1]=='R')
                        cnt_r[i]=1+cnt_r[i-1];
        for(int i=n;i>=1;i--)
                if(s[i-1]=='L')
                        cnt_l[i]=1+cnt_l[i+1];
        for(int i=1;i<=n;i++)
                if(cnt_r[i] && cnt_l[i+1])
                {
                        int sum=(cnt_r[i]+cnt_l[i+1]);
                        int a=sum/2,b=sum/2;
                        if(sum%2)
                        {
                                if(cnt_r[i]%2)
                                        a++;
                                else
                                        b++;
                        }
                        cout<<a<<" "<<b<<" ";
                        i++;
                }
                else
                        cout<<"0 ";
        cout<<"\n";
        return 0;
        for(int i=1;i<=100;i++)
                print(), mv();



        return 0;
}



Measured memory_bytes: 2256
from collections import deque

input = input()

stack = deque()
area = deque()

for i, v in enumerate(input):
    if v == "\\":
        stack.append(i)
    elif v == "/" and stack:
        j = stack.pop()
        ans = i - j
        while area and j<area[-1][0]:
            ans += area.pop()[1]
        area.append([j, ans])

B = [len(area)]
A = [i[1] for i in area]
print(sum(A))
B.extend(A)
print(*B)


Measured memory_bytes: 6796
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    ll n, sum = 0, ans1 = 0, ans2 = 0;
    int x[101];
    cin >> n;
    for (int i = 0; i < n;i++)
    {
        cin >> x[i];
        sum += x[i];
    }
    int mid1,mid2;
    mid1 = sum / n;
    mid2 = mid1 + 1;
    for (int i = 0; i < n;i++)
    {
        ans1 += (x[i] - mid1) * (x[i] - mid1);
        ans2 += (x[i] - mid2) * (x[i] - mid2);
    }
    cout << min(ans1, ans2);

    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = (i - 3600*h)/60;
   s = i - 3600*h - 60*m;
   cout << h << ":" << m << ":" << s << endl; 
   
   return 0;
}


Measured memory_bytes: 3088
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n,l = map(int,input().split())
    words=[]
    words=[input().rstrip() for _ in range(n)]
    s_words=sorted(words,key=lambda x:x[0:])
    ans=""

    for s_word in s_words:
        ans+=s_word
    print(ans)
if __name__=="__main__":
    main()

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

long long GCD(long long x, long long y) {
	if (y == 0) return x;
	else return GCD(y, x % y);
}

int main()
{

	int K;

	cin >> K;

	int a, b, c;

	long long s = 0;

	for (a = 1; a <= K; ++a) {
		for (b = 1; b <= K; ++b) {
			for (c = 1; c <= K; ++c) {
				s += GCD(a, GCD(b, c));
			}
		}
	}

	cout << s << endl;

}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
	cin>>a;
	if(a<2)  cout<<1;
	else if(a<4) cout<<2;
	else if(a<8) cout<<4;
	else if(a<16) cout<<8;
	else if(a<32) cout<<16;
	else if(a<64) cout<<32;
	else if(a<=100) cout<<64;
    return 0;
}

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

int main(int argc, char *argv[]) {
  int A, B, m;
  std::cin >> A >> B >> m;
  std::vector<int> a(A), b(B);
  int minA = INT_MAX, minB = INT_MAX;
  for (int i = 0; i < A; ++i) {
    std::cin >> a.at(i);
    minA = std::min(minA, a.at(i));
  }
  for (int i = 0; i < B; ++i) {
    std::cin >> b.at(i);
    minB = std::min(minB, b.at(i));
  }

  int min = minA + minB;
  for (int i = 0; i < m; ++i) {
    int x, y, c;
    std::cin >> x >> y >> c;
    min = std::min(min, a.at(x - 1) + b.at(y - 1) - c);
  }
  std::cout << min << std::endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>

using namespace std;

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

	string V;

	for (int j = 0; j < N; j++) {
		for (int i = 0; i < S.size(); i++) {
			V += S[i];
			if (S[i] == S[i + 1]) {
				i++;
			}
			
		}
		if (S.size() == V.size()) {
			break;
		}
		S = V;
		V = "";
	}


	size_t size = S.size();
	cout << size << endl;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine(Console.ReadLine().Split().Aggregate("T", (x, y) => x == "T" && y == "F" ? "F" : "T"));
    }
}



Measured memory_bytes: 20176
# B
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
T = int(input())
res_list = []

for _ in range(T):
    A, B, C, D = map(int, input().split())
    E = gcd(B, D)
    res = "Yes"
    if A < B:
        res = "No"
    if D < B:
        res = "No"
    if C < B - E:
        res = "No"
    F = A - ((A - C - 1) // B) * B - B
    if F < 0:
        res = "No"
    res_list.append(res)
for i in range(T):
    print(res_list[i])

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
 

    class Program
    {
        static void Main(string[] args)
        {
            int[] WHxyr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int W = WHxyr[0];
            int H = WHxyr[1];
            int x = WHxyr[2];
            int y = WHxyr[3];
            int r = WHxyr[4];
            bool isCan = false;

            if ((x - r >= 0)&&(x+r<=W)&&(y+r<=H)&&(y-r>=0))
            {
                isCan = true;
            }
            if (isCan == true)
            {
                Console.WriteLine("Yes");
            }else
            {
                Console.WriteLine("No");
            }
            
        }
        
    }
}

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

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	string res[] = { "First", "Second" };
	string s;
	cin >> s;
	int n = s.size();
	if (s[0] == s[n - 1]) {
		cout << (n % 2 ? res[1] : res[0]) << endl;
	}
	else {
		cout << (n % 2 ? res[0] : res[1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 512
A=10000
B=5000
C=1000
ans_A=-1
ans_B=-1
ans_C=-1
x,y=map(int,input().split())
for a in range(x+1):
  for b in range(x-a+1):
    c=x-a-b
    if a*A+b*B+c*C==y:
      ans_A=a
      ans_B=b
      ans_C=c
print(ans_A,ans_B,ans_C)
      

Measured memory_bytes: 8972
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void)
{
    int i,j=0,ara[15],min=99999,num;
    char s[15];
    gets(s);
 
    for(i=0;i<strlen(s)-2;i++)
    {
        num=((s[i]-'0')*100)+((s[i+1]-'0')*10)+(s[i+2]-'0');
        ara[j]=abs(753-num);
        j++;
    }
    for(i=0;i<j;i++)
    {
        if(ara[i]<=min)min=ara[i];
    }
    printf("%d",min);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define pb push_back
#define mp make_pair
///////

int const N = 1e5 + 41;
int const K = 27;

int n, q;
vector<string> vs;

struct Node{
	Node *to[27];
	int cnt;
	Node(){
		cnt = 0;
		fi(0, 27){
			to[i] = NULL;
		}
	};
};

Node *root = new Node();

void push(Node *v, string &s, int p){
	++v->cnt;
	if(p == sz(s)) return;
	if(v->to[s[p]] == NULL){
		v->to[s[p]] = new Node();
	}
	push(v->to[s[p]], s, p+1);
}

int cnt[N][K][K];

void dfs(Node *v, int id, int p){
	if(p == sz(vs[id])) return;
	dfs(v->to[vs[id][p]], id, p+1);
	fi(0, 27){
		if(i == vs[id][p]) continue;
		if(v->to[i] == NULL) continue;
		cnt[id][vs[id][p]][i] += v->to[i]->cnt;
	}
}

void solve(){
	cin >> n;
	fi(0, n){
		string s;
		cin >> s;
		fj(0, sz(s)) s[j] -= ('a' - 1);
		s += (char)(0);
		push(root, s, 0);
		vs.pb(s);
	}
	fi(0, n){
		dfs(root, i, 0);
	}



	cin >> q;
	fi(0, q){
		string alpha;
		int id;
		cin >> id;
		--id;
		cin >> alpha;
		fj(0, sz(alpha)) alpha[j] -= ('a' - 1);
		alpha = "0" + alpha;
		alpha[0] -= '0';

		int ans = 1;
		fj(0, 27){
			fk(j+1, 27){
				ans += cnt[id][alpha[k]][alpha[j]];
			}
		}
		cout << ans << endl;
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 342260
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed main(){
	int N, i, now, ans = 0;
	char *S = (char *)malloc(sizeof(char) * 200001);
	scanf("%s", S);
	for(N = 0; S[N] != '\0'; N++);
	for(i = 0, now = 0; i < N; i++){
		if(S[i] == 'W'){
			ans += i - now;
			now++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

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


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  ll n,k,s;
  cin>>n>>k>>s;
  vector<ll> a(n,s==(1e9)?(1e9-1):1e9);
  rep(i,k)a[i]=s;
  for(auto x:a)cout<<x<<" ";cout<<endl;

}

Measured memory_bytes: 2048
/*  ex9_1
    L40S38  */
#include<stdio.h>
#include<stdlib.h>

typedef struct stack{
    char row[11];
    //入力される文字列は最大10文字+ヌル文字
    int letter_num;
    //文字列の長さ
}stack;

void push(stack *stack_p,char *letter){
    //stackの文字列の最後にletterを加える
    stack_p->row[stack_p->letter_num]=*letter;
    stack_p->letter_num++;
    return;
}

void pop(stack *stack_p){
    //stackの文字列の最後の文字を削除
    if(stack_p->letter_num!=0){
        stack_p->letter_num--;
        stack_p->row[stack_p->letter_num]='\0';
    }
    return;
}

int main(void){
    stack *Stack;
    Stack=(stack*)calloc(1,sizeof(stack));
    if(Stack==NULL){
        printf("ERROR");
        return -1;
    }
    char input[11];
    //input:入力された'0','1','B'のみでできた文字列

    int i=0;

    //入力された文字列をinputに格納
    scanf("%s",input);

    //input[i]ごとにStack中の文字列における処理を変更
    while(input[i]){
        if(input[i]=='B'){
            //バックスペースキーの時はpop操作
            pop(Stack);
        }
        else{
            //それ以外の時はpush操作
            push(Stack,&input[i]);
        }
        i++;
    }

    //結果の出力
    for(i=0;i<Stack->letter_num;i++){
        printf("%c",Stack->row[i]);
    }
    putchar('\n');
    free(Stack);
    return 0;

}

Measured memory_bytes: 1656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		
		int k = scan.nextInt();
		String s = scan.next();
		scan.close();
		
		if(s.length() <= k) {
			System.out.println(s);
		}else {
			System.out.println(s.substring(0, k) + "...");
		}
	}

}


Measured memory_bytes: 27096
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
//#define s second

using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    int l = s.length();
    int lt = t.length();
    int ans = INT32_MAX;
    for(int i=0;i<=(l-lt);i++){
        int count = 0;
        for(int j=0;j<lt;j++){
            if(s[i+j] != t[j]){
                count ++;
            }
        }
        if(ans > count){
            ans = count;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define PI 3.1415926535897932384626
#define mod 1000000007
using namespace std;

int main(){
	int n, m, sum = 0;
  	cin >> n>> m;
  	int arr[m];
  	for(int i = 0; i<m; i++){
    	cin >> arr[i];
      	sum += arr[i];
    }
  	if(sum > n)
      cout << -1 <<endl;
  	else if(sum == n)
      cout << 0<<endl;
  	else
      cout << n - sum<<endl;
  	
}


Measured memory_bytes: 3616
//Author - Soumik Roy
//Date & Time - September 19, 2020 6:17 PM
//Problem name - C - A x B + C
//Problem url - https://atcoder.jp/contests/abc179/tasks/abc179_c
//Time limit - 2000 ms
//Memory Limit - 1024 MB    
//Parsed with ai-virtual-assistant https://github.com/Saurav-Paul/AI-virtual-assistant-python
#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define bug(x)				  cout<<"  [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int dir[]={0,1,0,-1,1,0,-1,0};
void solve()
{
	ll n;
	cin>>n;
	ll total=0;
	for(int i=1;i<=n;i++)
	{
		ll div=(n-1)/i;
		// if(div<=i)
		// 	continue;
		//cout<<div<<endl;
		total=(total+(div));
	}
	cout<<total<<endl;
}
int main()
{
    KAMEHAMEHA
	int t=1;
	//cin>>t;
	for(int cn=1;cn<=t;cn++)
	{
		solve();
	}
    return 0;
}



Measured memory_bytes: 3604