akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, ans = 0;
   cin >> n;
   vector<int> a(n, 0);
   for (int i = 0; i < n; i++)
   {
      cin >> a[i];
      ans += a[i];
   }
   ans -= n;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
///17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

#define n_l '\n'
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define debug(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

void IO() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void constructXOR(int A[], int n) 
{ 
    int XOR = 0; 
    for (int i = 0; i < n; i++) 
        XOR ^= A[i]; 
 
    for (int i = 0; i < n; i++) 
        A[i] = XOR ^ A[i]; 
} 
int32_t main() {
    //IO();
    fastio;
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n; cin >> n;
    int ar[n];
    for (int i = 0; i < n; i++) cin >> ar[i];
    constructXOR(ar, n);
	for (int i = 0; i < n; i++) cout << ar[i] << " ";
	cout << endl;

    

    return 0;
}


Measured memory_bytes: 5136
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

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

	int a,b;
	cin>>a>>b;
	if(a+b>=10) cout<<"error"<<endl;
	else cout<<a+b<<endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx")
 
#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define mp make_pair
#define f first
#define s second
#define y1 asafsaf
#define kz ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
using namespace std;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
 
const int N = 300, inf = 1e9, mod = 1e9 + 7;
const ll linf = 1e18;
const double pi = acos(-1.0);
 
ll n, b[N][N], a[N], m, r, mx;
ll ans;
 
int main(){
    cin >> n >> m >> r;
    for(int i = 1; i <= r; ++i)
        cin >> a[i];
    sort(a + 1, a + r + 1);
    for(int i = 1; i <= n; ++i)
    for(int j = 1; j <= n; ++j)
        b[i][j] = inf;
    for(int i = 1; i <= n; ++i)
        b[i][i] = 0;
    for(int i = 1; i <= m; ++i){
        int x, y, cost;
        cin >> x >> y >> cost;
        b[x][y] = cost;
        b[y][x] = cost;
    }
    for(int k = 1; k <= n; ++k)
    for(int i = 1; i <= n; ++i)
    for(int j = 1; j <= n; ++j){
        b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
    }
    ll res = 1e18;
    do{
        ans = 0;
        for(int i = 2; i <= r; ++i){
            ans += b[a[i]][a[i - 1]];
            mx = max(mx, b[a[i]][a[i - 1]]);
        }
        res = min(res, ans);
    }while(next_permutation(a + 1, a + r + 1));
    cout << res;
    return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void) {
	char str1[11], str2[11],str[11];
	int ball1, ball2;

	scanf("%s %s", str1, str2);
	scanf("%d %d", &ball1, &ball2);
	scanf("%s", str);
	if (strcmp(str1, str) == 0)ball1--;
	else ball2--;
	printf("%d %d", ball1, ball2);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define nl '\n'
typedef long long ll;
//////////////////////////////////////////////////////////////////////



int main(){
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  
  int h,w;cin>>h>>w;
  int s[1+h][1+w];
  int n;cin>>n;
  int a[1+n];
  for(int i=1;i<=n;i++)cin>>a[i];
  
  for(int i=1,j=1;i<=h;i++){
    for(int k=(i%2?1:w);k>=1 and k<=w;(i%2?k++:k--)){
      for(;j<=n and a[j]==0;j++);
      s[i][k]=j;
      a[j]--;
    }
  }
  
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++)
      cout<<s[i][j]<<" \n"[j==w];
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(ll i = 0; i < (ll)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 998244353ll;
const dou pi=3.141592653589793*2;
int main(){
    itn n,p;
    std::cin >> n>>p;
    VEC(int,a,n);
    vvector(dp,ll,n+1,6000,0);
    dp[0][0]=1;
    rep(i,n){
        rep(j,5050){
            dp[i+1][j+a[i]]+=dp[i][j];
            dp[i+1][j]+=dp[i][j];
        }
    }
    ll ans=0;
    rep(i,5050){
        if(i%2==p)ans+=dp[n][i] ;}       
    
    //std::cout << dp[3][2] << std::endl;
    //if(p==0)ans++;
    std::cout << ans << std::endl;
}

Measured memory_bytes: 2688
mod = 10**9 + 7


n = int(input())

is_prime = [True] * 1001
is_prime[0] = is_prime[1] = False
for i in range(1001):
    if is_prime[i]:
        j = 2
        while i * j <= 1000:
            is_prime[i * j] = False
            j += 1
P = [i for i in range(1001) if is_prime[i]]

A = {p:1 for p in P}
for i in range(2, n + 1):
    for p in P:
        while i % p == 0:
            i //= p
            A[p] += 1
        if i == 1:
            break

ans = 1
for a in A.values():
    ans *= a
    ans %= mod

print(ans)


Measured memory_bytes: 3064
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=998244353;//1000000007;




int main(){
    string s;
    cin>>s;
    vector<ll> cnt0,cnt1;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0'){cnt0.push_back(i); cnt0.push_back(i);}
        else if(s[i]=='1'){cnt0.push_back(i); cnt1.push_back(i);}
        else{cnt1.push_back(i); cnt1.push_back(i);}
    }
    vector<vector<ll>> dp(2*s.size()+1,vector<ll>(2*s.size()+1,0));
    dp[0][0]=1;
    for(int i=0;i<2*s.size();i++){
        for(int t=0;t<2*s.size();t++){
            if(cnt1.size()>=t+1 && cnt1[t]<=i){
                dp[i+1][t+1]+=dp[i][t];
                dp[i+1][t+1]%=MOD;
            }
            if(cnt0.size()>=i-t+1 && i-t>=0 && cnt0[i-t]<=i){
                dp[i+1][t]+=dp[i][t];
                dp[i+1][t]%=MOD;
            }
        }
    }
    ll sum=0;
    for(int i=0;i<=2*s.size();i++){
        sum+=dp[2*s.size()][i];
    }
    cout<<sum%MOD<<endl;
    
    
    return 0;
}


Measured memory_bytes: 125696
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  loop 1 n
loop :: Int -> Int -> IO ()
loop count lim = do
  if count > lim
    then return ()
    else do
      ls <- getLine
      let ans = randList' ls
      putStrLn $ "Case " ++ (show count) ++ ":"
      mapM_  putStrLn ans
      loop (count + 1) lim

strToInt :: String -> Int
strToInt str = read str

format :: Int -> String
format i = (replicate (8 - (length str)) '0') ++ str
  where str = show i

takeRange :: Int -> Int -> [a] -> [a]
takeRange 0 j ss = take j ss
takeRange i j (s:ss)
  |(i >= 0 && j >= 0 && i <= j) = takeRange (i-1) (j-1) ss
  | otherwise = []

randNex :: String -> String
randNex s = show (strToInt (takeRange 2 6 (format (i*i))))
  where i = strToInt s

randList :: String -> [String] -> [String]
randList s ss
  | length ss == 10 = ss
  | otherwise = randList (randNex s) (ss ++ [randNex s])
randList' :: String -> [String]
randList' s = randList s []

Measured memory_bytes: 4116
var A,B,C,D,N:int64;
begin
read(A,B,C,D,N);
if B>2*A then B:=2*A;
if C>2*B then C:=2*B;
if D>2*C then D:=2*C;
writeln(N div 2*D+N mod 2*C);
end.

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n;
vl u, v, w;
Graph G;
map<ll, ll> m;
/******* define variable end *******/
// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v.to]) continue; // next_v が探索済だったらスルー
		if (next_v.cost % 2 == 0){
			m[next_v.to] = m[v];
		}else{
			m[next_v.to] = (m[v]+1)%2;
		}
        dfs(G, next_v.to); // 再帰的に探索
    }
}
int solve() {
	cin >> n;
	seen.resize(n);
	G.resize(n);
	u.resize(n-1);
	v.resize(n-1);
	w.resize(n-1);
	REP(i, n-1){
		cin >> u[i] >> v[i] >> w[i];
		Edge e = {v[i]-1, w[i]};
		G[u[i]-1].push_back(e);
		Edge e2 = {u[i]-1, w[i]};
		G[v[i]-1].push_back(e2);
	}
	m[0] = 0;
	dfs(G, 0);
	for(auto& [key, value] : m){
		cout << value << endl;
	}
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
  	cout.precision(10);
	double pi = 2.0 * asin(1.0); 
	double unit_r = 180.0 / pi;
	double a,b,x,ans;	cin>>a>>b>>x;
  	if(a*a*b/2<x)	ans=2*(a*a*b-x)/(a*a*a);
  	else ans=a*b*b/(2*x);
    cout.precision(10);
	cout<<atan(ans) * unit_r<<endl;
    return 0;
}




Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
int getgcd(int x,int y){return !x?y:getgcd(y%x,x);}
const int maxn=5e2+5,mod=1e9+7;
int n,m,k,ind,ans=1,top;
int e[maxn][maxn],C[maxn][maxn];
int phi[maxn],pw[maxn],f[maxn];
int dfn[maxn],low[maxn],st[maxn],inst[maxn];
void dfs(int x,int fa){
	dfn[x]=low[x]=++ind;
	st[++top]=x;inst[x]=1;
	rep(i,1,n)if(e[x][i]&&i!=fa){
		if(!dfn[i]){
			dfs(i,x);
			low[x]=min(low[x],low[i]);
			if(low[i]>=dfn[x]){
				vector<int>a;
				while(1){
					int now=st[top--];
					a.pb(now);inst[now]=0;
					if(now==i)break;
				}
				a.pb(x);
				int E=0,V=SZ(a);
				rep2(i,0,V)rep2(j,0,i)E+=e[a[i]][a[j]];
				if(E==V)ans=1ll*ans*f[E]%mod;
				else if(E==V-1){
					ans=1ll*ans*k%mod;
					if(V!=2)assert(0);
				}else ans=1ll*ans*C[k+E-1][k-1]%mod;
			}
		}else if(inst[i])low[x]=min(low[x],dfn[i]);
	}
}
int main(){
	read(n);read(m);read(k);
	rep(i,0,500)rep(j,0,i)C[i][j]=!j?1:(C[i-1][j-1]+C[i-1][j])%mod;
	pw[0]=1;rep(i,1,m)pw[i]=1ll*pw[i-1]*k%mod;
	rep(i,1,m)rep(j,1,i)if(getgcd(i,j)==1)phi[i]++;
	rep(i,1,m)rep(d,1,i)if(i%d==0)f[i]=(f[i]+1ll*pw[d]*phi[i/d])%mod;
	rep(i,1,m)f[i]=1ll*f[i]*power(i,mod-2,mod)%mod;
	rep(i,1,m){
		int x,y;read(x);read(y);
		e[x][y]=e[y][x]=1;
	}
	rep(i,1,n)if(!dfn[i])dfs(i,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
N = int(input())
A = list(map(int, input().split()))

chk = 0
for i in range(0,N):
    if A[i]%2 == 0:
        if A[i]%3 == 0 or A[i]%5 == 0:
            continue
        else:
            chk += 1

if chk == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll PS(ll y) {
  ll axe=1;
  repl(i,1,y+1) {
    axe*=i;
  }
  return axe;
}
int main() {
  
  int N;
  cin>>N;
  vector<int>P(N);
  vector<int> Q(N);
  rep(i,N) {
    cin >>P.at(i);
  }
  rep(i,N) {
    cin >>Q.at(i);
  }
  
ll a[109]; 
  ll b[PS(N)][N];
for (ll i = 0; i < N; i++) {
 a[i]=i+1;
}
  ll count=0;

  
do {
    for (ll i = 0; i < N; i++) {
        if (i+1) 
        
         
     b[count][i]=a[i];
    }
  

  count++;
} while(next_permutation(a, a + N));
  
  ll c[PS(N)][N+1];
  rep(i,PS(N)) {
    rep(j,N) {
      c[i][j]=b[i][j];
    }
  }
  
  rep(k,PS(N)) {
    c[k][N]=k+1;
  }
  
  
  ll A=0;
  ll B=0;
  ll counting1=0;
  rep(i,PS(N)) {
       
    rep(j,N) {
 
  if(P.at(j)==c[i][j]) {
    counting1++;
  }
    }
    if(counting1==N) {
      A=i;
      break;
    }
    else if(counting1!=N) {
      counting1=0;
    }
  }
  
   ll counting2=0;
  rep(i,PS(N)) {
       
    rep(j,N) {
 
  if(Q.at(j)==c[i][j]) {
    counting2++;
  }
    }
    if(counting2==N) {
      B=i;
      break;
    }
    else if(counting2!=N) {
      counting2=0;
    }
  }
    
    
  //cout<<A<<" "<<B<<endl;
    ll finale=abs(B-A);
  cout<< finale <<endl;
}
  
 
  
  
  

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

int main(){
  int t,n;

  for(int i=0;i<4;++i){
    cin >> t >> n;

    if(t == 1){
      cout << 6000 * n << endl;
    }else if(t == 2){
      cout << 4000 * n << endl;
    }else if(t == 3){
      cout << 3000 * n << endl;
    }else if(t == 4){
      cout << 2000 * n << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3104
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 2
ans = a[0]-1
for i in range(1,n):
  if a[i] == cnt:
    cnt += 1
  else:
    ans += (a[i]-1)//cnt
print(ans)

Measured memory_bytes: 44124
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a<=c&&c<=b){
        put("Yes");
    }else{
        put("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

int main(int argc, char const *argv[])
{
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i=0;i<m;++i)cin >>x[i];
    if ((m==1) || (n>=m)){
        cout << 0;
    }
    else{
        vector<int> y(m-1);
        sort(x.begin(),x.end());
        for (int i=0;i<m-1;++i){
            y[i]=x[i+1]-x[i];
        }
        sort(y.begin(),y.end());
        long long ans = accumulate(y.begin(),y.end()-n+1,0);
        cout << ans;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	char suit[4] = {'S', 'H', 'C', 'D'};
	int card[4][13];
	for(int i = 0; i < 4; i++){
		for (int j = 0; j < 13; j++){
			card[i][j] = 1;
		}
	}
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		char s;
		int c;
		cin >> s >> c;
		int snumber;
		for(int j = 0; j < 4; j++){
			if(s == suit[j]){
				snumber = j;
			}
		}
		card[snumber][c-1] = 0;
	}
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 13; j++){
			if(card[i][j]==1){
				cout << suit[i] << " " << j+1 << "\n";
			}
		}
	}
}


Measured memory_bytes: 3084
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  int a_, b_, x_;
  std::cin >> a_ >> b_ >> x_;

  double a = a_;
  double b = b_;
  double x = x_;
  double s = x / a;
  double pi = 3.1415926535897932;

  double res;
  if (s > a * b / 2) {
    // std::cout << "1" << std::endl;
    res = std::atan2(b - x / (a * a), a / 2);

  } else {
    // std::cout << "2" << std::endl;
    // std::cout << "s = " << s << std::endl;
    // std::cout << "2 * s / b = " << 2 * s / b << std::endl;
    res = std::atan2(b, 2 * s / b);
  }
  res *= 360 / (2 * (pi));
  std::printf("%.10f\n", res);

  // std::cout << std::atan2(1, 1) << std::endl;

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int n,A[50];
int solve(int i,int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  int res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}
int main(){
  int q,M,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
while(true){
string op;
int A, B;
cin >> A >> op >> B;
if(op == "?"){
break;
}
if(op == "+"){
cout << A+B << endl;
}
if(op == "-"){
cout << A-B << endl;
}
if(op == "/"){
cout << A/B << endl;
}
if(op == "*"){
cout << A*B << endl;
}









}

}


Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int K = cin.nextint;
        int S = cin.nextint;
        int ans = 0;
        for (int i = 0; i <= K; i++)
        {
            for (int j = 0; j <= K; j++)
            {
                int p = S - i - j;
                if (0 <= p && p <= K)
                {
                    ans++;
                }
            }
        }
        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    int par = n/2;
    double impar = n - par;
    cout << ((double) ((impar) / (par+impar))) << endl;
}


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

int main()
{
int n;
char t;
string s,s1="";
cin>>n>>s;
t=s[0];
int p=s.length();
for(int i=0;i<p;i++)
{
 t=s[i];
 if(t!=s[i+1])s1+=t; 
}
cout<<s1.length();
return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF (1LL<<60)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, K; cin >> N >> K;
	vector<ll> x(N, 0LL);
	rep (i, N){
		cin >> x[i];
	} // end rep

	ll res = INF;
	rep (i, N - K + 1){
		ll xl = x[i];
		ll xr = x[i + K - 1];
		res = min(res, abs(xl) + abs(xr - xl));
		res = min(res, abs(xr) + abs(xr - xl));
	} // end rep

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define INF 9223372036854775807

int64_t rf(vector<vector<int64_t> > &dp, vector<vector<int64_t> > &w, int i, int j) {
    if (dp.at(i).at(j) != INF) {
        return dp.at(i).at(j);
    }
    if (j == i) {
        return 0;
    }
    for (int k = 0; k < j-i; k++) {
        dp.at(i).at(j) = min(dp.at(i).at(j), rf(dp, w, i, i+k) + rf(dp, w, i+1+k, j) + w.at(i).at(j));
    }
    return dp.at(i).at(j);
}

int main() {
    int n; cin >> n;
    vector<vector<int64_t> > dp(n, vector<int64_t>(n, INF));
    vector<vector<int64_t> > w(n, vector<int64_t>(n));
    for (int i = 0; i < n; i++) {
        cin >> w.at(i).at(i);
    }
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            w.at(i).at(j) = w.at(i).at(j-1) + w.at(j).at(j);
        }
    }
    cout << rf(dp, w, 0, n-1) << endl;
}

Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	string s[3];
	rep(i,3)cin>>s[i];
	rep(i,2){
		if(s[i].back()!=s[i+1][0]){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

using ll = long long;
const int mod = 1e9 + 7;
const int nax = 1e5 + 5;

int main()
{
	fast();
	int n, k, c;
	string s;
	cin >> n >> k >> c;
	cin >> s;
	vector<int> l(n + 2, -1), r(n + 2, -1);
	int days = 0;
	for(int i = 0; i < n; ++i){
		if(s[i] == 'o') {
			l[++days] = i, i += c;
			if(days == k + 1)
				return 0;
		}
	}
	days = k;
	for(int i = n - 1; i >= 0; --i){
		if(s[i] == 'o'){
			r[days--] = i;
			i -= c;
		}
	}
	for(int i = 1; i <= k; ++i){
		if(l[i] == r[i] && l[i] != -1)
			cout << l[i]  + 1 <<"\n";
	}
}			

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

#define ll long long
#define ld long double
#define pi 3.14159265359

int main() {
    int N; cin >> N;
    string S; cin >> S;
    ll r = 0, g = 0, b = 0;
    for (ll i = 0; i < S.size(); i++) {
        if (S.at(i) == 'R') {
            r++;
        }
        else if (S.at(i) == 'G') {
            g++;
        }
        else {
            b++;
        }
    }
    ll sum = r * g * b;
    ll cnt = 0;
    for (ll i = 0; i < N - 2; i++) {
        for (ll j = i + 1; j < N - 1; j++) {
            if (S.at(i) != S.at(j)) {
                ll k = 2 * j - i;
                if (k <= N - 1) {
                    if (S.at(k) != S.at(i) && S.at(k) != S.at(j)) {
                        cnt++;
                    }
                }
            }
        }
    }
    ll ans = sum - cnt;
    cout << ans << endl;
}

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

int main(){
  int a,b,c,d,x,y;
  cin >> a >> b >> c >> d;
  x = (a+d-1)/d;
  y = (b+c-1)/b;
  if(x>=y){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  return 0;
  
    
}


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

int main()
{
	int a[4] ;
	
	cin>>a[0]>>a[1]>>a[2]>>a[3];
	
	if( a[0]+a[1] > a[2]+a[3] )
		cout<<"Left\n";
	else if( a[0]+a[1] < a[2]+a[3] )
		cout<<"Right\n";
	else
		cout<<"Balanced\n";
	return 0;
}


Measured memory_bytes: 256
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
lint lcm(lint a, lint b) { return a * b / my::gcd(a, b); }
}  // namespace my
/*                    */

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c;
  vector<vector<int>> a(n);
  for (int i = 0; i < n; i++) {
    int tmpc;
    cin >> tmpc;
    c.push_back(tmpc);
    for (int j = 0; j < m; j++) {
      int tmpa;
      cin >> tmpa;
      a.at(i).push_back(tmpa);
    }
  }

  const int B = 12;
  lint ans = 0;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<B> bs(tmp);
    lint ans_ = 0;
    vector<lint> rikai(m, 0);
    for (int i = 0; i < n; i++) {
      if (!bs.test(i)) continue;
      for (int j = 0; j < m; j++) {
        rikai.at(j) += a.at(i).at(j);
      }
      ans_ += c.at(i);
    }

    bool flag = true;
    for (int j = 0; j < m; j++) {
      if (rikai.at(j) < x) {
        flag = false;
        break;
      }
    }
    if (flag) {
      if (ans == 0)
        ans = ans_;
      else if (ans_ < ans)
        ans = ans_;
    }
  }

  if (ans == 0)
    cout << -1 << endl;
  else
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
long long inversion_number(vector<int> &A){
	int N = A.size();
	vector<int> B = A;
	sort(B.begin(), B.end());
	map<int, int> mp;
	for (int i = 0; i < N; i++){
		mp[B[i]] = i + 1;
	}
	for (int i = 0; i < N; i++){
		A[i] = mp[A[i]];
	}
	long long ans = 0;
	vector<int> BIT(N + 1, 0);
	for (int i = 0; i < N; i++){
		ans += i;
		int j = A[i];
		while (j > 0){
			ans -= BIT[j];
			j -= j & -j;
		}
		j = A[i];
		while (j <= N){
			BIT[j]++;
			j += j & -j;
		}
	}
	return ans;
}
int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++){
    cin >> A[i];
  }
  cout << inversion_number(A) << endl;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  void solve() {
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);

  Problem::Solver sol;
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
int N,K;
cin>>N>>K;
int a=0,answer;
for(int i=0;i<N;i++){
    int A;
    cin>>A;
}
for(int i=1;a<=N;i++){
    a+=K;
    if(a>=N){
        answer=i;
        cout<<answer<<endl;
        return 0;
    }
    else{
        a-=1;
    }
}
    return 0;
}


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


#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  string s ;
  cin >> n >> s ;
  
  vector<int> r ;
  vector<int> g ;
  vector<int> b ;
  rep(m,s.size()){
    if( s.at(m) == 'R')
      r.push_back(m+1);
     if( s.at(m) == 'B')
      b.push_back(m+1);
     if( s.at(m) == 'G')
      g.push_back(m+1);
  }
  
  intll ans = r.size() * b.size() * g.size();
  for(int i=0;i<s.size()-2;i++){
    for(int j=i+1;2*j-i < s.size();j++){
      int k = 2*j-i ;
     
      if(s.at(i) != s.at(j)){
       if(s.at(j) !=s.at(k)){
        if(s.at(i) != s.at(k)){
        ans--;
        }
       }
      }
    }
  }
  
  cout <<ans ;
  
}


Measured memory_bytes: 3636
#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 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

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % 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 long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long

int cnt[26]; vector<char>v;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl; return 0;
	}
	if (s.size() != 26) {
		rep(i, s.size())cnt[s[i] - 'a']++;
		rep(i, 26) {
			if (cnt[i] != 1) {
				cout << s << (char)('a' + i) << endl; return 0;
			}
		}
	}
	v.push_back(s[25]);
	for (int i = 24; i >= 0; i--) {
		sort(ALL(v));
		if (s[i] < s[i + 1]) {
			if (i == 0) {
				cout << (char)(s[0] + 1) << endl; return 0;
			}
			cout << s.substr(0, i);
			rep(j, v.size()) {
				if (s[i] < v[j]) {
					cout << v[j] << endl; return 0;
				}
			}
		}
		v.push_back(s[i]);
	}
	return 0;
}

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


public class Main {

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

	    if (s.lastIndexOf("s") == s.length() - 1) {
	    	System.out.println(s + "es");
	    } else {
	    	System.out.println(s + "s");
	    }
	}

}

Measured memory_bytes: 38620
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
const int INF = 1e9+7;

int main(int argc, char **argv)
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if (r <= x && x <= W - r && r <= y && y <= H - r) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x;
        int i = 0;
        while(true){
            x = sc.nextInt();
            if ( x == 0 ) break;
            i = i + 1;
            System.out.println("Case " + i + ": " + x );
            
        }
	}

}


Measured memory_bytes: 41548
#include<bits/stdc++.h>
using namespace std;
int a, b, c;

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

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin >> a >> b >> c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if (s.size() == 2) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main() {
	int N;

	for (int i = 0; i < 1000; i++) {
		cin >> N;
		if (N == 0) { break; }

		int a = 0;
		int count = 0;
		for (int s = 1; s < N; s++) {
			for (int j = s; j < 1000; j++) {
				a += j;
				if (a == N) {
					count += 1;
				}if (a > N) {
					a = 0;
					break;
				}
			}
		}
			cout << count << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3080
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = new StringBuilder(sc.next()).reverse().toString().toCharArray();
        int N = S.length;
        //System.out.println(S);

        boolean ok = false;
        for (int i = 1; i < N; i++) {
            int len = N - i;
            if (len % 2 == 0) {
                ok = true;
                for (int j = i; j < i + len / 2; j++) {
                    //System.out.println(String.format("S[%d] = %s, S[%d] = %s", j, S[j], j + len / 2, S[j+len/2]));
                    if (S[j] != S[j + len / 2]) {
                        ok = false;
                        break;
                    }
                }

                if (ok) {
                    System.out.println(len);
                    return;
                }
            }
        }
        return;
    }

}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

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

#define S second
#define F first
#define int long long  

//////////

signed main()
{
    fastio;
    int h,w;
    cin>>h>>w;
    int mo=1000000007;
    string s[h+1];
    for(int i=1;i<=h;++i)
    {
        cin>>s[i];
        s[i]=" "+s[i];
    }
    for(int i=0;i<=w;++i)
        s[0].append("W");
    int ans[h+1][w+1]={};
    ans[1][1]=1;
    for(int i=1;i<=h;++i)
    {
        for(int j=1;j<=w;++j)
        {
            if(s[i-1][j]=='.')
                ans[i][j]+=ans[i-1][j];
            if(s[i][j-1]=='.')
                ans[i][j]+=ans[i][j-1];
            ans[i][j]%=mo;
        }
    }
    cout<<ans[h][w];
}

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

int main() {
    int A, B;
    cin >> A >> B;
    int ans = -1;
    for (int i = 1; i <= 1000; ++i) {
      if (i*8/100 == A && i/10 == B) {
        ans = i;
        break;
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.to_s
b = gets.chomp.to_s
c = gets.chomp.to_s
aa = []
bb = []
cc = []
a.each_byte { |x| aa << x }
b.each_byte { |x| bb << x }
c.each_byte { |x| cc << x }
result = 0
for m in 0..n - 1
  x = []
  x << aa[m]
  x << bb[m]
  x << cc[m]
  x.uniq!
  result = result + x.length - 1
end
puts result


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

bool is_prime(int n) {
  for(int i=2; i*i <= n; i++) {
    if(n%i == 0)return false;
  }
  return n != 1;
}

int main(void) {
  int N;
  cin >> N;

  vector<int> ps;
  for (int i = 2; i <= 55555; i++) {
    if (is_prime(i) && i % 10 == 7) {
      ps.push_back(i);
    }
  }
  for (int i = 0; i < N; i++) {
    cout << ps[i];
    if (i != N - 1) cout << " ";
  }
  cout << endl;
  // cout << ps.size() << endl;
  // for (int i = 0; i < ps.size(); i++) {
  //   cout << ps[i] << " ";
  // }cout << endl;

  return 0;
}

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

int main() {
    int n; scanf("%d", &n);
    int ans = 0;
    for (int i =  1; i <= n; i+=2) {
        int cnt = 0;
        for (int j = 1; j <= n; j++) {
            if (i % j == 0) cnt++;
        }
        if (cnt == 8) ans++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;



int main(){
	ll N; cin>>N;
	string s; cin>>s;
	vector<ll> r(N+1,0);
	vector<ll> g(N+1,0);
    vector<ll> b(N+1,0);
	for(int i = N-1;i>=0;--i){
        if(s[i] == 'R'){
          r[i] = r[i+1] + 1;
          g[i] = g[i+1];
          b[i] = b[i+1];
        }else if(s[i] == 'G'){
          r[i] = r[i+1];
          g[i] = g[i+1] + 1;
          b[i] = b[i+1];
        }else{
          r[i] = r[i+1];
          g[i] = g[i+1];
          b[i] = b[i+1] + 1;
        }
    }
    ll red = 0, blue = 0, green = 0;
    for(int i = N-1;i>=0;--i){
        if(s[i] == 'R'){
          red++;
        }else if(s[i] == 'G'){
          green++;
        }else{
          blue++;
        }
    }
 	ll ans = red*green*blue;
    REP(i,N-2)for(int j = i+1;j<=N-2;j++){
          ll k = 2*j - i;
          if(k >= N) continue;
    	  if(s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ans--;
    }
    cout << ans;
  	return 0;
}


Measured memory_bytes: 3684
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] a = new int[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		sc.close();

		List<String> list = new ArrayList<>();
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i][j] % 2 == 1) {
					if (j == w - 1) {
						if (i != h - 1) {
							a[i][j]--;
							a[i + 1][j]++;
							list.add((i + 1) + " " + (j + 1) + " " + (i + 2) + " " + (j + 1));
						}
					} else {
						a[i][j]--;
						a[i][j + 1]++;
						list.add((i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2));
					}
				}
			}
		}
		PrintWriter pw = new PrintWriter(System.out);
		pw.println(list.size());
		for (String str : list) {
			pw.println(str);
		}
		pw.flush();
	}
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,char>> a(m);
  for(int i=0;i<m;i++)
    cin >> a.at(i).first >> a.at(i).second;
  int ans = -1;
  for(int i=0;i<pow(10,n+1);i++){
    bool ok=false;
    string s = to_string(i);
    if(s.size()==n){
      ok=true;
      for(int j=0;j<m;j++){
        if(a.at(j).first>s.size()||s.at(a.at(j).first-1)!=a.at(j).second){
          ok=false;
          break;
        }
      }
    }
    if(ok){
      ans=i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3996