akhauriyash/Code-Regression huggingface dataset:
mod = 998244353
n = int(input())
d = list(map(int,input().split()))
if d[0]!=0 or d[1:].count(0)!=0:
  print(0)
  exit()
l = [0 for i in range(n)]
for i in d:
  l[i] += 1
cou = 1
if 0 in l:
  a = l.index(0)
  if sum(l[a:])!=0:
    print(0)
    exit()
for i in range(n-2):
  if l[i+1]!=0:
    a = l[i]
    b = l[i+1]
    cou *= (a**b)%mod
print(cou%mod)

Measured memory_bytes: 14020
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 
#define nint int
using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> p;
typedef pair<double,double> dop;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;


signed main()
{
int n,p;
std::cin >> n >> p;
if(n == 1){
    std::cout << p << std::endl;
} else {
    int ro = pow(p,1.0/n + 0.1);
    for(int i = ro; i >= 1; i--){
        if(p % (int)pow(i,n * 1.0) == 0){
            std::cout << i << std::endl;
            break;
        }
    }
}
return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>

int nPr(int n, int r);

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> P(N), Q(N);
  int a = 0, b = 0;
  for (int i = 0; i < N; i++)
  {
    std::cin >> P.at(i);
    int num = P.at(i) - 1;
    for (int j = 0; j < i; j++)
    {
      if (P.at(j) < P.at(i)) num--;
    }
    a += num * nPr(N-i-1, N-i-1);
  }
  for (int i = 0; i < N; i++)
  {
    std::cin >> Q.at(i);
    int num = Q.at(i) - 1;
    for (int j = 0; j < i; j++)
    {
      if (Q.at(j) < Q.at(i)) num--;
    }
    b += num * nPr(N-i-1, N-i-1);
  }
  std::cout << std::abs(a - b) << std::endl;
}

/* ++++++++++ function ++++++++++ */
int nPr(int n, int r)
{
  int ans = 1;
  for (int i = n; i > n - r; i--) ans *= i;
  return ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#define in(x) scanf("%d", &x)
#define out(x) printf("%d", x)


int main(void) {
	int n, m, ans = 0, sum  = 0; 
	in(n); in(m);
	int a[n];
	for(int it = 0; it < n; ++it) {
		in(a[it]); 
		sum += a[it]; 
	}
	for(int it = 0; it < n; ++it) {
		if((float)a[it] >= (float) sum / (4 * m))
			++ans;
	}
	if(ans >= m) 
		printf("Yes\n");
	else 
		printf("No\n"); 	
	return 0;	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
   long long int n,i,j,k,t=0;
   map<long long int,long long int>m;
   vector<long long int>v;
   set<long long int>s;
   cin>>n;
   for(i=0;i<n;i++)
   {
       cin>>k;
       m[k]++;
       v.push_back(k);
       s.insert(k);
   }
//   cout<<m[1]<<endl;
//   cout<<m[2]<<endl;
//   cout<<m[4]<<endl;
   for(auto x:s)
   {
       j=m[x];
       t+=(j*(j-1))/2;
       //cout<<j<<endl;

   }
   //cout<<t<<endl;
   for(i=0;i<v.size();i++)
   {
       cout<<t-m[v[i]]+1<<endl;
   }



    return 0;
}


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

#define all(a) a.begin(),a.end()
#define pb(x) push_back(x)
#define vec vector<long long>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define fi first
#define se second
#define print(a) for(auto i:a)cout<<i<< " ";cout<<endl
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define MP(a,b) make_pair(a,b)
#define hii cout<<"hi\n"
#define printpair(x) for(auto i: x)cout<<i.fi<<" "<<i.se<<endl
#define D(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using namespace std;

const ll N = 1e9 + 5;
bool col2(pair<ll,ll> p1, pair<ll, ll> p2){
  if(p1.fi == p2.fi)return p2.se<p1.se;
  else return p1.fi< p2.fi;
}
struct comp{
  bool operator() (ll const &x, ll const &y){
    return x>y;
  }
};


int main()
{
  fast;
  ll a;cin>>a;
  cout<<a + a*a + a*a*a<<endl;
}




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

int main()
{
    int N;
    int M = (1e+6) + 1;
    cin >> N;
    vector<bool> A(M, false);
    set<int> duplicate;
    int Ai;
    for(int i=0;i<N;i++){
        cin >> Ai;
        if(A[Ai]) duplicate.insert(Ai);
        A[Ai] = true;
    }

    set<int> res;
    for(int i=1;i<=M;i++){
        if(!A[i]) continue;
        res.insert(i);
        for(int j=1; i*j<=M; j++){
            if(A[i*j]) A[i*j] = false;
        }
    }
    for(auto e : duplicate){
        if(res.count(e)){
            res.erase(e);
        }
    }
    cout << res.size() << endl;

    return 0;
}

Measured memory_bytes: 13080
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cstdio>
      
#define f first
#define s second
      
using namespace std;
      
typedef pair<int,int> P;
      
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
      
int main(void){
      
int n,id=0;
string idx="ABCDEFGHI";
char s,t,d;
map<char,P>mp;
      
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
mp[idx[id++]]=P(j,i);
}
}
      
while(cin >> n,n){
cin >> s >> t >> d;
   
P S=mp[s],T=mp[t],D=mp[d];
   
double dp[16][3][3];
      
for(int k=0;k<16;k++)
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)dp[k][i][j]=0;
      
dp[0][S.s][S.f]=1;
      
for(int k=0;k<n;k++){
for(int y=0;y<3;y++){
for(int x=0;x<3;x++){
for(int l=0;l<4;l++){
int nx=x+dx[l],ny=y+dy[l];
if(nx<0 || ny<0 || 2<nx || 2<ny || 
(nx==D.f&&ny==D.s))nx=x,ny=y;
dp[k+1][ny][nx]+=dp[k][y][x]/4;
}
}
}
}
printf("%.8f",dp[n][T.s][T.f]);
cout << endl;
}
      
return 0;
}

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int maxP, maxD = 0;
        for (int i = 0; i < n; i++) {
            int p, d1, d2;
            cin >> p >> d1 >> d2;
            if (maxD < d1 + d2) {
                maxP = p;
                maxD = d1 + d2;
            }
        }
        cout << maxP << " " << maxD << endl;
    }
}

Measured memory_bytes: 868
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twol pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define mk make_pair
#define y1 y1922
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int rin(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
inline int bin(){
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
}
int n,m,ans;
two x[200004];
multiset<int>s;
multiset<int>::IT it;
int main(){FAST;xRand;
cin>>n>>m;
for(int i=0;i<n;i++){
	cin>>x[i].f>>x[i].s;
}
sort(x,x+n);
int j=0;
for(int i=1;i<=m;i++){
	while(j<n&&x[j].f<=i){
		s.insert(x[j].s);
		j++;
	}
	if(sz(s)){
		it=s.end();
		it--;
		ans+=(*it);
//		cout<<(*it)<<endl;
		s.erase(it);
	}
}
cout<<ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/



Measured memory_bytes: 5632
#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar(), c-'0'>9&c!='-');
	for(a=(b=c=='-')?0:c-'0'; (c=getchar()-'0')<=9; a=a*10+c);
	return b?-a:a;
}
int main() {
	int (*rd)()=read<int>, h=rd(), w=rd(), a=rd(), b=rd();
	for(int i=0; i<h; ++i) {
		for(int j=0; j<w; ++j) printf("%d", (i<b)^(j<a));
		puts("");
	}
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

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

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

		vector<vector<int> > v(n);
		REP(i, m) {
			int a, b;
			cin >> a >> b;
			v[a-1].push_back(b-1);
			v[b-1].push_back(a-1);
		}

		set<int> u;
		REP(i, v[0].size()) {
			u.insert(v[0][i]);
			REP(j, v[v[0][i] ].size()) {
				u.insert(v[v[0][i] ][j]);
			}
		}

		cout << u.size()-1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1372
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)

int red;

signed main(){
	int n;cin>>n;
	string s;cin>>s;
	for(int i=0;i<n;i++)if(s[i]=='R')red++;
	if(2*red>n)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

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

    return 0;
}

Measured memory_bytes: 256
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0; char f[7];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003];
int h1[100003], h2[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.emplace(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1.emplace(i);
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) h1[a[i]]++;
		if (dist[b[i]] > dist[a[i]]) h1[b[i]]++;
	}
	for (int i = 1; i <= n; i++)z[i].resize(h1[i]);
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) { z[a[i]][h2[a[i]]] = make_pair(b[i], d[i]); h2[a[i]]++; }
		if (dist[b[i]] > dist[a[i]]) { z[b[i]][h2[b[i]]] = make_pair(a[i], d[i]); h2[b[i]]++; }
	}
	for (int i = 1; i <= n; i++) D[dist[i]].push_back(i);
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 24324
n=gets.to_i
c=[]
s=[]
f=[]
(0..n-2).each{|i| c[i], s[i], f[i]=gets.split.map &:to_i}

res=[0]*n
for i in 0...n-1
    t=s[i]+c[i]
    for j in i+1...n-1
        if t<s[j]
            t=s[j]
        else
            t=s[j]+(t-s[j]+f[j]-1)/f[j]*f[j]
        end
        t+=c[j]
    end
    res[i]=t
end
puts res


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
typedef struct p point;
ll MOD = (1e9)+7;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
ll DP[101010];
int input[101010];
int main(){
	fastIO();
	for(int i=0;i<100100;i++){
		DP[i]=1e10;
	}
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>input[i];
	}
	DP[1]=abs(input[0]-input[1]);
	DP[0]=0;
	for(int i=2;i<n;i++){
		for(int j=1;j<=k;j++){
			if(i-j>=0){
				DP[i]=min(DP[i],DP[i-j]+abs(input[i]-input[i-j]));
			}
		}
	}
	cout<<DP[n-1]<<endl;
}
// - VERIFICAR LONG VS INT -


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

using namespace std;

typedef long long ll;
typedef long double ld;

ll n;
ll p;
ll ans=1;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>p;
    for(ll d=2;d*d<=p;d++)
    {
        int cnt=0;
        while(p%d==0)
        {
            p/=d;
            cnt++;
        }
        if(cnt)
        {
            ll ori=cnt/n;
            for(int i=1;i<=ori;i++)
            {
                ans*=d;
            }
        }
    }
    if(p>1)
    {
        int cnt=1;
        ll ori=cnt/n;
        for(int i=1;i<=ori;i++)
        {
            ans*=p;
        }
    }
    cout<<ans<<"\n";
    return 0;
}
/**

**/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];
//平方根　= sqrt



int main() {

  int x,y;
  cin >> x >> y;
  if (y%2==0) {
    if (x*2<=y && y<=x*4){
      cout << "Yes" << endl;
      return 0;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "No" <<endl;

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    int d[N];
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }
    sort(d, d+N);

    if(N % 2 != 0){
        cout << 0 << endl;
        return 0;
    }

    if(d[N / 2 - 1] == d[N / 2]){
        cout << 0 << endl;
        return 0;
    }

    int ans = d[N / 2] - d[N / 2 - 1];
    cout << ans << endl;

}

Measured memory_bytes: 640
/*
	Roll no : 18EC10057
	PC No.:   70
*/


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define size 100000
#define ll long long int
int arr[size];
ll arr1[size];


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


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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int o=0,e=0;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x&1)
			o++;
		else
			e++;
	}
	e+=o/2;
	o&=1;
	if(e>=1)
		e=1;
	if(o+e==1)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  map<char,string> enc;
  map<string,char> dec;

  enc['A'] = "00000";
  enc['B'] = "00001";
  enc['C'] = "00010";
  enc['D'] = "00011";
  enc['E'] = "00100";
  enc['F'] = "00101";
  enc['G'] = "00110";
  enc['H'] = "00111";
  enc['I'] = "01000";
  enc['J'] = "01001";
  enc['K'] = "01010";
  enc['L'] = "01011";
  enc['M'] = "01100";
  enc['N'] = "01101";
  enc['O'] = "01110";
  enc['P'] = "01111";
  enc['Q'] = "10000";
  enc['R'] = "10001";
  enc['S'] = "10010";
  enc['T'] = "10011";
  enc['U'] = "10100";
  enc['V'] = "10101";
  enc['W'] = "10110";
  enc['X'] = "10111";
  enc['Y'] = "11000";
  enc['Z'] = "11001";
  enc[' '] = "11010";
  enc['.'] = "11011";
  enc[','] = "11100";
  enc['-'] = "11101";
  enc['\'']= "11110";
  enc['?'] = "11111";

  dec["101"] = ' ';
  dec["000000"] = '\'';
  dec["000011"] = ',';
  dec["10010001"] = '-';
  dec["010001"] = '.';
  dec["000001"] = '?';
  dec["100101"] = 'A';
  dec["10011010"] = 'B';
  dec["0101"] = 'C';
  dec["0001"] = 'D';
  dec["110"] = 'E';
  dec["01001"] = 'F';
  dec["10011011"] = 'G';
  dec["010000"] = 'H';
  dec["0111"] = 'I';
  dec["10011000"] = 'J';
  dec["0110"] = 'K';
  dec["00100"] = 'L';
  dec["10011001"] = 'M';
  dec["10011110"] = 'N';
  dec["00101"] = 'O';
  dec["111"] = 'P';
  dec["10011111"] = 'Q';
  dec["1000"] = 'R';
  dec["00110"] = 'S';
  dec["00111"] = 'T';
  dec["10011100"] = 'U';
  dec["10011101"] = 'V';
  dec["000010"] = 'W';
  dec["10010010"] = 'X';
  dec["10010011"] = 'Y';
  dec["10010000"] = 'Z';

  string input;
  while(getline(cin, input)){
    string buff = "";
    REP(i,input.size())
      buff += enc[input[i]];

    string ans,tmp;
    for(int i=0; i<buff.size(); i++){
      tmp += buff[i];
      if(dec.find(tmp) != dec.end()){
        ans += dec[tmp];
        tmp = "";
      }
    }

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 123456789012



template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash(const string &s, unsigned base = 29297) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RH = RollingHash< 1000000007 >;
using RH2 = RollingHash< 998244353 >;

int main() {
    int i,j;
    int n;
    string s;
    cin>>n>>s;
    RH rh(s);
    RH2 rh2(s,20394);

    int l=0,r=n;
    while(r-l>1){
        int m=(r+l)/2;
        map<int,int> ma;
        set<int> se;
        bool ok=0;
        for(i=0;i<n-m+1;i++){
            int u=rh.get(i,i+m);
            if(se.find(u)!=se.end()){
                if(ma[u]<=i-m){
                    if(rh2.get(i,i+m)==rh2.get(ma[u],ma[u]+m)) ok=1;
                }
            }
            else{
                se.insert(u);
                ma[u]=i;
            }
        }

        if(ok) l=m;
        else r=m;
    }
    cout<<l<<endl;
    
}

//RollingHash(s,base);文字列のハッシュテーブルを構築する。
//get(l,r) 区間[l,r)のハッシュ
//connect(h1,h2,h2len) "h1"+"h2"のハッシュ
//LCP(b,l1,r1,l2,r2) 区間[l1,r1)とハッシュテーブルbの区間[l2,r2)のLCAの長さ

Measured memory_bytes: 768
#include <iostream>

using namespace std;
int gcdr(int n1, int n2){

   while(1){
    if(n1 > n2){
    	if(n1%n2 == 0) return n2;
    	else n1 = n1%n2;
    }
  else{
    if(n2%n1 == 0) return n1;
    else n2 = n2%n1;
  }
   }
}
int main(){
	int n;
    cin >> n;
  int sayi1, sayi2, gcd;
  cin >> sayi1 >> sayi2;
  gcd = gcdr(sayi1, sayi2);
  for(int i= 0; i < n-2; i++){
  	int sayi;
    cin >> sayi;
    gcd = gcdr(gcd, sayi);
  }
  cout << gcd;
  	

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int S = sc.nextInt();
        int W = sc.nextInt();

        System.out.println(solve(S, W));
    }

    private static String solve(int S, int W) {
        return S <= W ? "unsafe" : "safe";
    }
}

Measured memory_bytes: 35600
#include <stdio.h>
#define NUM 100

int main()
{
  int n,i,u,k,j,v;
  int Adj[NUM][NUM];

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      Adj[i][j] = 0;
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    u--;
    for(j = 1;j <= k;j++){
      scanf("%d",&v);
      v--;
      Adj[u][v] = 1;
    }
  }

  for(i = 0;i < n;i++){
    printf("%d",Adj[i][0]);
    for(j = 1;j < n;j++){
      printf(" %d",Adj[i][j]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2068
fun main(args: Array<String>) {
    val (N, X) = readLine()!!.split(" ").map(String::toInt)
    val L = readLine()!!.split(" ").map(String::toInt)
    var d = 0
    var ans = 1
    for (l in L) {
        d += l
        if (d > X) break
        ans++
    }
    println(ans)
}

Measured memory_bytes: 37996
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
const bool DEBUG = 1;
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <stdio.h>
#include <sys/time.h>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef pair<int, PP> IPP;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define LREP(i,n) LFOR(i,0,n)
#define LRFOR(i,a,b) for(ll i=(b)-1;i>=(a);--i)
#define LRREP(i,b,a) LRFOR(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define REACH(i,c) RREP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define BR cout << "\n"

#define dump(x) if(DEBUG)cerr<<"[" << __LINE__ << "] "<<#x<<"="<<(x)<<"\n"
#define dump2(x,y) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
			<<" , "<<#y<<"="<<(y)<<"\n"
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
			<<" , "<<#y<<"="<<(y)<<"\n"\
			<<" , "<<#z<<"="<<(z)<<"\n"

#define SAY(x) if(DEBUG) cerr << "[" << __LINE__ << "] " << (x) << "\n"

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

ll ans;

int f[100][5][2];
int p[100][11];

int main() {
	omajinai;
	int n;
	cin>>n;
	REP(i,n){
		REP(j,5)REP(k,2){
			cin>>f[i][j][k];
		}
	}
	REP(i,n)REP(j, 11){
		cin>>p[i][j];
	}

	ll ans = -LINF;
	FOR(i, 1, 1<<10){
		ll re=0;
		REP(s, n){
			int c=0;
			REP(j, 5)REP(k,2){
				int val = j*2 + k;
				if((i & (1<<val)) && (f[s][j][k])){
					c++;
				}
			}
			re += p[s][c];
		}
		ans = max(ans, re);
	}

	cout << ans << endl;

//	if(n%s==0){
//		cout << "Yes" << endl;
//	}else{
//		cout << "No" << endl;
//	}
}


Measured memory_bytes: 256
#include<stdio.h> 
int main() 
{ 
int a,b,c,d,l,r; 
scanf("%d%d%d%d",&a,&b,&c,&d); 
if((a+b)>(c+d))printf("Left\n"); 
else if((a+b)==(c+d))printf("Balanced\n"); 
else printf("Right\n"); 

return 0;}

Measured memory_bytes: 2024
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int lv,n;
    while(1){
        scanf("%d",&lv);
        if(lv == 0) break;
        scanf("%d",&n);
        getchar();
        char now = 0;
        int level=0,ans=0;
        int i = 0,o = 0;
        bool flg = 0;
        while(n--){
            char a;
            scanf("%c",&a);
            if(a == 'I' && !flg){
                flg = 1;
            }
            else if(a == 'I'){
                if(flg){
                    if(a != now){
                        i++;
                        if(i == o){
                            level = i;
                        }
                        if(lv <= level)ans++;
                    }
                    else{
                        i = o = level = 0;
                    }
                }
            }
            else if(a == 'O'){
                if(flg){
                    if(a != now) o++;
                    else{
                        flg = 0;
                        i = o = level = 0;
                    }
                }
            }
            now = a;
        }
        cout << ans << endl;
    }
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main() {
 
	int n, k;
	cin >> n >> k;
	vector<int> d;
	d.resize(k);
	for (int i = 0; i < k; i++) {
		cin >> d[i];
	}
	int temp = n;
	int flag = 0;
	string money;
	while (flag==0) {
		money = to_string(temp);
		flag = 1;
		for (int i = 0; i < k; i++) {
			if(money.find(to_string(d[i]))!=-1){
				flag = 0;
			}
		}
		temp += 1;
	}
	cout << temp - 1 << endl;
 
 
//	cin >> n;
 
 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, A, B;
    cin>>N>>A>>B;
    ll full=N/(A+B);
    ll count=full*A;
    ll mo=N%(A+B);
    count+=min(mo, A);
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
    int i;
    cin>>s;
    for(i=0;i<s.size();i++) if(s[i]=='C') break;
    for(int j=i+1;j<s.size();j++)
        if(s[j]=='F')
        {
            cout<<"Yes";
            return 0;
        }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, T: "List[int]"):
    from functools import reduce

    def lcm_base(a: int, b:int):
        return a*b // gcd(a,b)

    def lcm(*numbers):
        return reduce(lcm_base, numbers, 1)

    def gcd_base(a: int, b: int):
        while b:
            a, b = b, a%b

        return a

    def gcd(*numbers):
        return reduce(gcd_base, numbers)

    print(lcm(*T))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, T)

if __name__ == '__main__':
    main()


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

vector<int> next_comb(int n, int k, vector<int> v){
    if (n < k) cout << "error" << endl;
    for (int i = 0; i < v.size()-1; ++i) {
        if (v[i] >= v[i+1]) cout << "error" << endl;
    }

    for(int i = k-1; i >= 0; --i){
        if (v[i] != i+n-k){
            int t = ++v[i];
            for (int j = i+1; j < k; ++j){
                v[j] = ++t;
            }
            return v;
        }
    }

    for (int i = 0; i < k; ++i){
        v[i] = i;
    }
    return v;
}

int comb(int n, int k){
    if ( n < 0 || k < 0 || k > n) return 0;
    k = min(k, n-k);
    int p = 1, q = 1;
    while ( k > 0 ) {
        p *= n--;
        q *= k--;
    }
    return p / q;
}

int main(){
    const int INF = 2e9+10;
    int N, M, X, C[20], A[20][20];
    cin >> N >> M >> X;
    for (int i = 0; i < N; ++i){
        cin >> C[i];
        for (int j = 0; j < M; ++j){
            cin >> A[i][j];
        }
    }

    int res = INF; 
    for (int i = 1; i <= N; ++i){

        vector<int> v;    
        for (int j = 0; j < i; ++j){
            v.push_back(j);
        }

        for (int p = 0; p < comb(N, i); ++p){

            int c = 0;
            int a[M];
            for (int k = 0; k < M; ++k) a[k] = 0;

            for (int j : v){
                c += C[j];
                for (int k = 0; k < M; ++k){
                    a[k] += A[j][k];
                }
            }

            bool check = true;
            for (int k = 0; k < M; ++k){
                check &= a[k] >= X;
            }

            if (check) {
                res = min(res, c);
            }

            v = next_comb(N, i, v);
        }
    }

    if (res != INF){
        cout << res << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
n=int(input())
a=list(map(int,input().split()))
flag = 1
k = 0
swap_count = 0
while flag == 1:
    flag = 0
    for i in range(n-1,k,-1):
        if a[i-1] > a[i]:
            a[i],a[i-1] = a[i-1],a[i]
            flag = 1
            swap_count += 1
    k += 1
print(" ".join(map(str,a)))
print(swap_count)


Measured memory_bytes: 5600
import sys
import os
#import math

N=int(input())
p=[0]*5
for i in range(5):
    p[i]=int(input())

pmin=min(p)
#g=math.ceil(N/pmin)
g=int(N/pmin)
if (N%pmin)==0:
    print(5+g-1)
else:
    print(5+g)

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


int N;
int A[10];

int main(){
    cin>>N;
    int all=1,bad=1;
    for(int i=0;i<N;i++){
        cin>>A[i];
        all*=3;
        if(A[i]%2==0) bad*=2;
    }
    cout<<all-bad<<endl;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n, l, p[205], m = 1000, s = 0;
	cin >> n >> l;
	for(int i = 1; i <= n; ++i){
		p[i - 1] = l + i - 1;
		m = min(abs(m), abs(p[i - 1]));
		if(p[i - 1] < 0) m *= -1;
		s += p[i - 1];
//		cout << p[i - 1] << endl;
	}
	cout << s - m;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string w;
  cin >> w;
  vector<int>W(w.size());
  vector<int>count(26,0);
  for (int i = 0; i < w.size(); i++) {
    W.at(i) = w.at(i) - '0';
    W.at(i) -= 49;
    count.at(W.at(i))++;
  }
  for (int i = 0; i < 26; i++) {
    if (count.at(i) % 2 == 1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
  

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

int main(void) {
	// string namae;
	// cin>>namae;
	// cout<<namae<<endl;
	// // int a,b,c,d;
	// a=1;
	// b=5;
	// c=3;
	// d=10;
	// a=a+3;
	// a++;
	// b=b*c;
	// c=b/a;
	// d=a%c;
	// cout<<a<<endl;
	// cout<<b<<endl;
	// cout<<c<<endl;
	// cout<<d<<endl;
	int X,A;
	cin>>X>>A;
	if(X<A){
		cout<<"0"<<endl;
	}
	else{
		cout<<"10"<<endl;
	}	
	
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}



template< typename T>
T power(T x,int k){
    T ret=1;
    while(k>0){
        if(k&1) (ret*=x);
        (x*=x); 
        k >>= 1;
    }
    return ret;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int h;
    cin>>h;

    int i=power<int>(2,60);

    int ans=0;
    int t=1;
    int c=61;

    while(i>1){
        if(h&i){
            ans+=t;
            t*=2;
            h=h/2;
            //cout<<h<<endl;
            //cout<<t<<endl;
            continue;
        }

        i>>=1;
    }


    cout<<ans+t<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s,r;
  cin>>s>>r;
  sort(r.begin(),r.end());
  reverse(r.begin(),r.end());
  sort(s.begin(),s.end());
  if(s<r)cout<<"Yes";
  else cout<<"No";
  return 0;
}

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

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int N = cin.nextInt();
		long t = cin.nextInt();
		long a = cin.nextInt();
		for (int i = 0; i < N - 1; i++)
		{
			long T = cin.nextInt();
			long A = cin.nextInt();
			if(T >= t && A >= a)
			{
				t = T;
				a = A;
			}
			else
			{
				long num = Math.Max((t + T - 1) / T, (a + A - 1) / A);
				t = num * T;
				a = num * A;
			}
		}
		Console.WriteLine(t + a);
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

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

using namespace std;

constexpr int N = 1e6 + 10;
constexpr int MOD = 1e9 + 7;

long long n, a[3][N], b[N], fen[2][3 * N];

void add (int x, int val, int p) {
    for (; x < 3 * N; x += x & (-x))
        fen[p][x] += val;
}

int get (int x, int p) {
    int ret = 0;
    for (; x; x -= x & (-x))
        ret += fen[p][x];
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < 3; i++)
        for (int j = 1; j <= n; j++)
            cin >> a[i][j];
    for (int i = 1; i <= n; i++) {
        if ((a[1][i] % 3) == 2 && (a[1][i] + i) & 1) {
            if ((abs (a[1][i] - a[0][i]) != 1) || (abs (a[1][i] - a[2][i]) != 1)) {
                cout << "No" << '\n';
                return 0;
            }
            b[i] = a[1][i];
            if (a[0][i] > a[1][i])
                b[i] = -b[i];
        }
        else {
            cout << "No" << '\n';
            return 0;
        }
    }
    long long invo = 0, inve = 0, cnto = 0, cnte = 0;
    for (int i = 1; i <= n; i++) {
        if (i & 1) {
            if (b[i] < 0)
                cnto++, b[i] = -b[i];
            add (b[i], 1, 1);
            invo += ((i + 1) / 2) - get (b[i], 1);
        }
        else {
            if (b[i] < 0)
                cnte++, b[i] = -b[i];
            add (b[i], 1, 0);
            inve += (i / 2) - get (b[i], 0);
        }
    }
    if ((cnto + inve) & 1)
        cout << "No" << '\n';
    else if ((cnte + invo) & 1)
        cout << "No" << '\n';
    else
        cout << "Yes" << '\n';
    return 0;
}


Measured memory_bytes: 33024
import Foundation

let a = readLine()!
let b = readLine()!
var ans = ""
if a == b {
  ans = "EQUAL"
} else if a.count < b.count {
  ans = "LESS"
} else if a.count > b.count {
  ans = "GREATER"
} else {
  for (i, j) in zip(a, b) {
    if i > j {
      ans = "GREATER"
      break
    } else if i < j {
      ans = "LESS"
      break
    }
  }
}
print(ans)

Measured memory_bytes: 12992
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define mod 1000000007
#define inf 10010010010
using namespace std;

//O(logB)
ll mpow(ll a, ll b, ll m){
	if (!b) return 1 % m;
	if (b == 1) return a % m;
	if (b % 2) return (a*mpow(a, b - 1, m)) % m;
	else return mpow((a*a) % m, b / 2, m) % m;
}

//O(N)
ll mfact(ll a, ll m){
	ll ret = 1;
	for (ll i = 1; i <= a; ++i) ret = (i*ret) % m;
	return ret;
}

ll fact[100001], factinv[100001];

//O(N+logN)
//前処理しとけばO(1)
//前処理はO(N+logN)
ll mcomb(ll n, ll k, ll m){
	if (!n && !k) return 1;
	if (n < k || n < 0) return 0;
	
	//前処理用
	return ((((fact[n] % m) * (factinv[k] % m)) % m) * (factinv[n - k] % m)) % m;
	
	//return (((mfact(n, m)*mpow(mfact(k, m), m - 2, m)) % m)*mpow(mfact(n - k, m), m - 2, m)) % m;
}

int main(){
	fact[0] = 1;
	for (ll i = 1; i <= 100000; ++i) fact[i] = (fact[i - 1] * i) % mod;
	for (ll i = 0; i <= 100000; ++i) factinv[i] = mpow(fact[i], mod - 2, mod);
	ll n, k; cin >> n >> k;
	vl a(n); rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	ll ans = 0;
	rep(i, n){
		ll c = mcomb(n - i - 1, k - 1, mod);
		ans = (ans + (a[n - i - 1] - a[i])*c) % mod;
		if (ans < 0) ans += mod;
	}cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
a, b, c, x = [int(input()) for i in range(4)]
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if x == 500 * i + 100 * j + 50 * k:
                ans += 1

print(ans)

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


int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	a+=b;
	c+=d;
	
	if(a==c) cout << "Balanced" << endl;
	else if(a>c) cout << "Left" << endl;
	else cout << "Right" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
int a,b;
signed main(){
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}


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

bool betemp(string sleft, string sright, int left, int right) {
    if (sleft == sright) return (right - left) % 2 == 1;
    else return (right - left) % 2 == 0;
}

void solve(int N) {
    string vac = "Vacant";
    string sleft, sright, str;
    int left = 0, right = N/2;
    cout << left << endl;
    cin >> sleft;
    if (sleft == vac) return;
    cout << right << endl;
    cin >> sright;
    if (sright == vac) return;

    if (!betemp(sleft, sright, left, right)) {
        swap(sleft, sright), left = right, right = N;
    }
    while (right - left > 1) {
        int mid = (left + right) / 2;
        cout << mid << endl;
        cin >> str;
        if (str == vac) return;
        if (betemp(sleft, str, left, mid)) sright = str, right = mid;
        else sleft = str, left = mid;
    }
}

int main() {
    int N;
  cin >> N;
    solve(N);
}


Measured memory_bytes: 852
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double pi = 3.14159265359;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------


int h, w;
string s;

int main()
{
	cin >> h >> w;
	for (int i = 0;i < w + 2;i++) cout << "#";cout << endl;
	for (int i = 0;i < h;i++) {
		cin >> s;
		cout << "#" + s + "#" << endl;
	}
	for (int i = 0;i < w + 2;i++) cout << "#";cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	char a;
	cin>>a;
	
	if(a<='Z'&&a>='A')cout<<'A'<<endl;
	else cout<<'a'<<endl;
	
	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

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

		String n = scan.next();
		int length = n.length();
		char[] n_list = n.toCharArray();
		long sum = 0;

		for(int i = 0; i < length;i++) {
			sum += (int)n_list[i] - (int)'0';
		}

		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 40624
#include<bits/stdc++.h>
#include <string> 
using namespace std;
bool check(int M,int sum,int A){
  if(A<(double)sum/(4*M)){
    return false;
  }else{
    return true;
  }
}
int main()
{
  int N,M;
  int A[1000],sum;
  int count=0;
  cin>>N>>M;
  for(int i=0;i<N;i++){
    cin>>A[i];
    sum+=A[i];
  }
  for(int i=0;i<N;i++){
    int b=A[i];
    if(check(M,sum,b)){
      count++;
      cout<<"";
    }
  }
  if(count>=M){
    cout<<"Yes";
  }else{
    cout<<"No";
  } 
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O999")
//示例：#define ll long long
//unsigned long long ;
const int INF=0x3f3f3f3f;
const int maxn=50000005;
using namespace std;

int main(){
	//freopen(".in", "r",stdin );
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	if(n%2==0)
		cout<<n/2<<endl;
	else
		cout<<n/2+1<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;
int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int>a(N);
	vector<pair<int, int>>b;
	priority_queue<pair<int,int>>que,que_m,que2;
	vector<pair<int, int>>ans;
	int cnt = 0;
	int min_a = INF, max_a = 0;
	rep(i, N) {
		cin >> a[i];
		min_a = min(min_a, a[i]);
		max_a = max(max_a, a[i]);
		if (a[i] != 0) {
			que.push({ a[i],i });
			que_m.push({ -a[i],i });
		}
	}
	bool f = true;
	rep(i, N - 1) {
		if (a[i] > a[i + 1])f = false;
	}
	if (f) {
		cout << 0 << endl;
		return 0;
	}

	bool flag = (min_a + max_a >= 0 ? true : false);
	if (flag) {
		cnt += N;
		rep(i, N) {
			a[i] += que.top().first;
			ans.push_back({ que.top().second, i });
			if(a[i]!=0)que2.push({ a[i],i });
		}
		cnt += N;
		int x = que2.top().second;
		max_a = que2.top().first;
		rep(i, N) {
			a[i] += max_a;
			ans.push_back({ x,i });
			x = i;
			max_a = a[i];
		}
	}
	else {
		cnt += N;
		rep(i, N) {
			a[i] += -que_m.top().first;
			ans.push_back({ que_m.top().second, i });
			if(a[i]!=0)que2.push({ -a[i],i });
		}
		cnt += N;
		int x = que2.top().second;
		min_a = -que2.top().first;
		for(int i=N-1;i>=0;i--) {
			a[i] += min_a;
			ans.push_back({ x,i });
			x = i;
			min_a = a[i];
		}
	}
	cout << cnt << endl;
	rep(i, ans.size())cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;

std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    }
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

void solve(long long X){
  sieve(X*10LL);
  long long idx = X;
  while(!IsPrime[idx]) {
    idx++;
  }
  std::cout << idx << std::endl;
}

int main(){
  long long X;
  scanf("%lld",&X);
  solve(X);
  return 0;
}


Measured memory_bytes: 888