akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        String anc = "No";
        if((A*2) <= B && B <= (A*4) &&(B%2) == 0){
            anc = "Yes";
        }
        System.out.println(anc);
        }
    }

Measured memory_bytes: 35772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

ll dp[51][51][2501];

void solve(long long N, long long A, vector<long long> x){
	dp[0][0][0] = 1;
	rep(i, N) {
		rep(j, N+1) {
			rep(k, N*50+1) {
				if (i+1<j) continue;
				if (j-1 >= 0 && k-x[i]>= 0) dp[i+1][j][k] = dp[i][j][k] + dp[i][j-1][k-x[i]];
				else dp[i+1][j][k] = dp[i][j][k];
			}
		}
	}
	ll res = 0;
	rep(i, N+1) {
		rep(j, N*50+1) {
			if (i*A == j) res += dp[N][i][j];
		}
	}
	cout << res-1 << endl;
}

int main(){	
	long long A;
	long long N;
	scanf("%lld",&N);
	vector<long long> x(N-1+1);
	scanf("%lld",&A);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&x[i]);
	}
	solve(N, A, x);
	return 0;
}



Measured memory_bytes: 49152
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
struct node{ 
	int c;
	int a[15];
}book[15];
int b[15];
int main(){
	int n,m,x;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>book[i].c;
		for(int j=0;j<m;j++) cin>>book[i].a[j];
	}
	int ans=2e9;
	for(int i=0;i<(1<<n);i++){
		memset(b,0,sizeof b);
		int sum=0;
		for(int j=0;j<n;j++)
		if(i>>j&1){
			sum+=book[j].c;
			for(int k=0;k<m;k++) b[k]+=book[j].a[k];
		}
		bool flag=1;
		for(int j=0;j<m;j++) if(b[j]<x) flag=0;
		if(flag) ans=min(ans,sum);
	}
	if(ans==2e9) cout<<"-1";
	else cout<<ans;
	return 0;
}

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

int n, i = 1, p = 3;
int a[10000];

int main()
{
	a[0] = 2;

	while (i < 10000) {
		int j = 3;

		while (j * j <= p) {
			if (p % j == 0)
				break;

			j += 2;
		}

		if (j * j > p) {
			a[i] = a[i - 1] + p;
			i++;
		}

		p += 2;
	}

	cin >> n;

	while (n > 0) {
		cout << a[n - 1] << endl;

		cin >> n;
	}

	return 0;
}


Measured memory_bytes: 3028
// 全然わからないので、解説を読んで実装
// 兎と亀の例はそこから

#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

void limit_add(long long& target, long long add) {
  target = (target + add) % 1000000007;
}

void dump(vector<vector<unordered_map<int, long long>>>& dp) {
  int n = dp.size();
  for (int i = 0; i < n; i++) {
    int j_size = dp[i].size();
    for (long long j = 0; j < j_size; j++) {
      for (auto ks : dp[i][j]) {
        int current_k = ks.first;
        long long count = ks.second;

        cout << i << " " << j << " " << current_k << " " << count << endl;
      }
    }
  }
}

int main() {
  int n,k;
  cin >> n;
  cin >> k;
  
  vector<vector<unordered_map<int, long long>>> dp;
  dp.assign(n+1, vector<unordered_map<int, long long>>()); //TODO: dpを2個交互に使うようにしたい
  int dp_size = dp.size();
  for (int i = 0; i < dp_size; i++) {
    dp[i].assign(i+1, unordered_map<int, long long>());
  }
  dp[0][0][0] = 1;
  
  for (int i = 0; i < n; i++) {
    int j_size = dp[i].size();
    for (long long j = 0; j < j_size; j++) {
      for (auto ks : dp[i][j]) {
        int current_k = ks.first;
        long long count = ks.second;
        // 1追加されて、i+1,j+1の状態になった時
        //TODO: 結果に不要な場合は枝切りしたい
        
        // 追加された兎、亀はこれまでとマッチしない場合
        // kはj+1個残るので、その2倍(交換すると2増えるため、以下同じ)
        // 増えるcountは、これが起こる場合の数なので、1通り
        limit_add(dp[i+1][j+1][current_k + 2 * (j+1)], count);
        
        // 追加された兎、亀とこれまでが1組のみマッチした場合 (j+1同士も含む)
        // 起こる場合は 兎がj+1,亀がjまでのどれかでj通り
        // その反対でj通り
        // 兎、亀ともj+1を選んで1通り
        limit_add(dp[i+1][j]  [current_k + 2 * j], count * (j+j+1));
        
        // 追加された兎、亀とこれまでが2組ともマッチした場合
        // 起こる場合は、兎がj+1,亀がjまでのどれかでj通り
        // その反対でj通り
        // 同時に発生するので、j*j
        if (j>0) {
          limit_add(dp[i+1][j-1][current_k + 2 * (j-1)], count * (j*j));
        }
      }
    }
  }
  
  cout << dp[n][0][k] << endl;;
  //TODO: debug dump(dp);
  
  return 0;
}


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


template <typename T> struct BIT {
  std::vector<T> tree;
  long long int size;

  BIT(long long int n) : tree(n + 1, T()), size(n) {}

  T sum(long long k) {
    T s = 0;
    for (long long int i = k + 1; i > 0; i -= i & -i) {
      s = s + tree[i];
    }
    return s;
  }

  T range(long long int start, long long int end) {
    return sum(end) - sum(start - 1);
  }

  void add(long long int k, T v) {
    for (long long int i = k + 1; i <= size; i += i & -i) {
      tree[i] = tree[i] + v;
    }
  }

  void debug() {
    for (long long int i = 0; i <= size; i++) {
      std::cout << tree[i] << " ";
    }
    std::cout << std::endl;
  }
};

using namespace std;
using ll = long long int;

int main() {
  ll N;
  string S;
  ll Q;

  cin >> N >> S >> Q;
  vector<BIT<ll>> bit(26, BIT<ll>(N));

  for (ll i = 0; i < N; i++) {
    bit[S[i] - 'a'].add(i, 1);
  }

  for (ll t = 0; t < Q; t++) {
    ll typ; cin >> typ;

    if (typ == 1) {
      ll i;
      char c;
      cin >> i >> c;
      bit[S[i-1] - 'a'].add(i-1, -1);
      bit[c - 'a'].add(i-1, 1);
      S[i-1] = c;
    } else {
      ll l, r; cin >> l >> r;
      ll cnt = 0;
      for (ll i = 0; i < 26; i++) {
        if (bit[i].range(l-1, r-1) > 0) {
          cnt++;
        }
      }

      cout << cnt << endl;
    }
  }
}

Measured memory_bytes: 109344
#include<bits/stdc++.h>
#include<vector>
using namespace std;
long long euclid(long a , long b){
    if(b == 0) return a;
    return euclid(b , a % b);
}

int main(void){

    int N; cin >> N;
    vector<long long> A(N);  for(int i = 0 ; i < N ; i++) cin >> A[i];
    long long ans = 0;
    for(int i = 0 ; i < N ; i++) ans = euclid(ans , A[i]);
    printf("%d\n", ans);

    return 0;
}

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

using ll = long long;

signed main() {
  string s;
  ll k;
  cin >> s >> k;
  ll n = s.size();
  ll ans = 0;

  ll top = 0;   // 元の文字列で先頭で同じ文字が連続している数
  ll back = 0;  // 元の文字列で末尾で同じ文字が連続している数

  ll same_char_cnt;
  for (ll i = 0; i < n; i += same_char_cnt) {
    same_char_cnt = 1;
    for (ll j = i + 1; j < n; j++) {
      if (s[i] == s[j])
        same_char_cnt++;
      else
        break;
    }

    if (i == 0) {
      top = same_char_cnt;
      continue;
    }

    if (i + same_char_cnt >= n) {
      back = same_char_cnt;
      continue;
    }

    ans += same_char_cnt / 2;
  }

  ans *= k;

  if (top == n) {
    ans = (n * k) / 2;
  } else {
    if (s[0] == s[n - 1])
      ans += (top + back) / 2 * (k - 1) + top / 2 + back / 2;
    else
      ans += k * (top / 2 + back / 2);
  }

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a[3];
  int d=0,e=0;
  
  for(int i=0;i<3;i++){
    cin>>a[i];
    if(a[i]==5)
      d++;
    else
      e++;
  }
  if(d==2&&e==1)
    cout<<"YES";
  else
    cout<<"NO";
  
  return 0;
}


Measured memory_bytes: 3012
def solve(A, n, b):
    for x in b:
        for i in range(3):
            for j in range(3):
                if A[i][j] == x:
                    A[i][j] = -1
    for i in range(3):
        ok = True
        for j in range(3):
            if A[i][j] != -1:
                ok = False
                break
        if ok:
            return "Yes"
    for j in range(3):
        ok = True
        for i in range(3):
            if A[i][j] != -1:
                ok = False
                break
        if ok:
            return "Yes"
    ok = True
    for i in range(3):
        if A[i][i] != -1:
            ok = False
    if ok:
        return "Yes"
    ok = True
    for i in range(3):
        if A[2-i][i] != -1:
            ok = False
    if ok:
        return "Yes"
    return "No"

A = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
print(solve(A, n, b))

Measured memory_bytes: 3064
#include <climits>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

inline double calc(int a, int b) {
	return static_cast<double>(abs(a - b)) / a;
}

inline vector<int> divisor(int n) {
	vector<int> res;
	for(int i = 1; i * i <= n; ++i) {
		if(n % i == 0) {
			res.emplace_back(i);
			if(i != n / i) res.emplace_back(n / i);
		}
	}
	return res;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	constexpr int MAX_A = 100000;
	constexpr int MAX = 2 * MAX_A;

	int n;
	cin >> n;

	vector<int> a(n);
	for(auto &e : a) cin >> e;

	vector<vector<int>> d(1);
	for(int i = 1; i <= MAX; ++i) {
		d.emplace_back(divisor(i));
	}

	vector<vector<double>> dp(n, vector<double>(MAX + 1, INT_MAX));
	for(int i = 1; i <= MAX; ++i) {
		dp[0][i] = calc(a.front(), i);
	}

	for(int i = 1; i < n; ++i) {
		for(int j = 1; j <= MAX; ++j) {
			for(const auto &e : d[j]) {
				chmin(dp[i][j], dp[i - 1][e]);
			}
			chmax(dp[i][j], calc(a[i], j));
		}
	}

	double ans = INT_MAX;
	for(const auto &e : dp.back()) {
		chmin(ans, e);
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

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

int main()
{
  int N, M;
  string s = "No";

  cin >> N;
  M = N / 7;
  for (int i = 0; i <= M; i++)
  {
    if ((N - i * 7) % 4 == 0)
    {
      s = "Yes";
      break;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  ll ans=n*(n-1)/2+m*(m-1)/2;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll n,now;
queue<ll> s;
int main() {
	cin >> n;
	REP(i, 1 << n) {
		ll a; cin >> a;
		s.push(a);
	}
	REP(k, INF) {
		now = s.size();
		if (now == 1) {
			cout << s.front() << endl;
			return 0;
		}
		REP(i, now / 2) {
			ll a = s.front();
			s.pop();
			ll b = s.front();
			s.pop();
			if (a == b)s.push(a);
			else s.push(abs(a - b));
		}
	}
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
vector<int>v;
int main()
{
    long long t,n,c,x,p,s,f,ans,mm=INT_MAX;
    cin>>t>>p;
    for(int i=1;i<=t;i++){
        cin>>n;
        v.push_back(n);


    }
    for(int i=0; i<t-p+1; i++)
    {
        ans=0;

        s=v[i];
        f=v[i+p-1];

        if(s<0 && f<0)
        {
            ans=abs(s);
        }
        else if(s<0 && f==0)
        {
            ans=abs(s);

        }
        else if(s<0 && f>0)
        {

            if(abs(s)<abs(f))
            {
                ans+=abs(s);
                ans+=(f-s);
            }
            else
            {
                ans+=abs(f);
                ans+=(f-s);

            }
        }
        else if(s==0 && f>0)
        {
            ans=0;
        }
        else if(s>0 && f>0)
        {
            ans=f;
        }
        //cout<<s<<" "<<f<<" "<<ans<<endl;
        mm=min(mm,ans);
    }


    cout<<mm;

}




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

using namespace std;

int main()
{
	string s;
	int x;
	cin>>x; cin>>s;
	for (auto a: s)
	{
		a+=x;
		if (a>90)
			a-=26;
		cout<<a;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3620
N,x=map(int,input().split())
if x==1 or x==2*N-1:
  print("No")
else:
  print("Yes")
  k=2
  c=0
  while c<=N-3:
    if k!=x:
      print(k)
      c+=1
    k+=1
  print(1)
  print(x)
  print(2*N-1)
  while c<=2*N-5:
    if k!=x:
      print(k)
      c+=1
    k+=1
    

Measured memory_bytes: 53208
#include<iostream>
using namespace std;
#define MAX 108
#define black 2
#define gray 1
#define white 0
#define INFTY 1<<21
int mark[MAX][MAX];
int color[MAX];
int d[MAX];
int p[MAX];
int n;
inline void display(){
	cout<<endl;
	for(int i = 0;i<n;++i){
		for(int j = 0;j<n;++j)
			cout<<mark[i][j]<<' ';
	cout<<endl;
	}
	cout<<endl;
} 
void dijkstra( int begin ){
	for(int i = 0;i<n;++i){
		d[i] = INFTY;
		p[i] = -1;
		color[i] = white;
	}
	int mincost,u;
	d[0] = 0;
	
	while( true ){
		mincost = INFTY;
		for(int i= 0;i<n;++i)
			if(black!=color[i]&&d[i]<mincost){
				u = i;
				mincost = d[i];
			}
		if(INFTY==mincost)break;
		color[u] = black;
		for(int i =0;i<n;++i)
			if(black!=color[i]&&mark[u][i]!=-1&&d[i]>mincost+mark[u][i]){
				d[i] = mincost+mark[u][i];
				p[i] = u;
				color[i] = gray;
			}
	}
	for(int i = 0;i<n;++i)
		cout<<i<<' '<<d[i]<<endl;
} 

int main(){
	int u,k,vx,c;
	cin>>n;
	for(int i = 0;i<n;++i)
		for(int j=0;j<n;++j)
			mark[i][j] = -1;
	for(int i =0;i<n;++i){
		cin>>u>>k;
		for(int j = 0;j<k;++j){
			cin>>vx>>c;
			mark[u][vx] = c;
		}
	}
	
//	display();
	dijkstra(0);
	return 0;
}
/*
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3


*/


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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL 10000000000000000LL
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>


int main() {
  int n;
  cin >> n;
  ll a[3*n];
  REP(i, 3*n) cin >> a[i];
  priority_queue<ll, vector<ll>, greater<ll>> que;
  ll sum = 0;
  ll r[n+1], l[n+1];
  REP(i, n){
    que.push(a[i]);
    sum += a[i];
  }
  r[0] = sum;
  REP(i, n){
    que.push(a[i+n]);
    ll x = que.top();
    que.pop();
    sum += (a[n+i]-x);
    r[i+1] = sum;
  }
  priority_queue<ll> que2;
  ll sum2 = 0;
  REP(i, n){
    que2.push(a[3*n-1-i]);
    sum2 += a[3*n-1-i];
  }
  l[n] = sum2;
  REP(i, n){
    que2.push(a[2*n-1-i]);
    ll y = que2.top();
    que2.pop();
    sum2 += (a[2*n-1-i]-y);
    l[n-1-i] = sum2;
  }
  ll ans = -INFL;
  REP(i, n+1){
    if(ans < r[i]-l[i]) ans = r[i]-l[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5876
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
vector<bool> prime;
int main(){
    int num;
    num=100100;
    int sqt_num=(int)sqrt((double)num)+1000;
    prime.resize(num,true);
    prime.at(0)=false;
    for(int i=0;i<sqt_num;i++){
        if(prime.at(i)){
            for(int j=2;(i+1)*j<=num;j++){
                prime.at((i+1)*j-1)=false;
            }
        }
    }
    vector<int> sum(100050,0);
    for(int i=3;i<=100010;i++){
        if(prime[i-1]&&prime[(i+1)/2-1])sum.at(i)=1;
    }
    for(int i=0;i<=100010;i++){
        sum.at(i+1)+=sum.at(i);
    }
    int q;
    cin>>q;
    while(q--){
        int l,r;
        cin>>l>>r;
        cout<<sum.at(r)-sum.at(l-1)<<endl;
    }
}


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

#define PI 3.141592

using namespace std;

int main (void){
    int n,m;
    int ans=0;
    cin>>n>>m;
    vector <int> A(m,0);
    for(int i=0;i<m;i++){
        cin>>A[i];
    }
    for(int k=0;k<A.size();k++){
        n-=A[k];
    }
    if(n>=0){
        ans=n;
    }
    else{
        ans=-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(j, ini));
    return move(vec);
}
template <typename T>
vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() {
    int N = In<int>();
    int K = In<int>();
    int Q = In<int>();
    vector<int> avec(N, K - Q);
    for(int q = 0; q < Q; q++) {
        int a = In<int>();
        avec[a - 1]++;
    }
    for(int n = 0; n < N; n++) {
        cout << (avec[n] > 0 ? "Yes" : "No") << endl;
    }
}

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

int main() {
  int N, A;
  cin >> N;
  cin >> A;

  if ((N % 500) <= A) {
    cout << "Yes" << endl;
  }
  
  else if((N % 500) > A) {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<c;++a)
#define repeq(a,b,c) for(int a=b;a<=c;++a)
#define debug(x) cerr<<(#x)<<": "<<x<<endl
typedef long long ll;
const int SZ=300;
int a[SZ][SZ];
bool verified[SZ][SZ];
vector<tuple<int,int,int> > es;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	rep(i,0,n) rep(j,0,n)
	{
		cin >> a[i][j];
		if(i<j)
			es.emplace_back(a[i][j],i,j);
	}
	rep(i,0,n)
		verified[i][i] = true;
	bool bad= false;
	ll tot = 0;
	sort(es.begin(),es.end());
	for(auto e:es)
	{
		int w = get<0>(e), i=get<1>(e), j=get<2>(e);
		int best = -1;
		rep(k,0,n)
			if(verified[i][k] && verified[k][j] && (best==-1 || a[i][k]+a[k][j]<best))
			   best = a[i][k]+a[k][j];
		if(best!=-1 && best<w)
			bad = true;
		else if(best==-1 || best>w)
		{
			tot+=w;
		}
		verified[i][j] = true;
		verified[j][i] = true;
		if(bad)
			break;
	}
	if(bad)
		cout << "-1\n";
	else
		cout << tot << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

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


Measured memory_bytes: 3584
import java.math.BigInteger;
import java.util.*;

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

        BigInteger C = A.gcd(B);
        boolean f = true;
        long cnt = 1;

        long D = C.longValue();
        while (true) {
            if (D%2==0) {
                D /= 2;
                if (f)
                    cnt++;
                f = false;
            } else {
                break;
            }
        }
        for (long i=3; i<=Math.sqrt(C.longValue()); i+=2) {
            if (D%i==0) {
                cnt++;
                while (D%i==0) {
                    D /= i;
                }
            }
        }
        if (D!=1)
            cnt++;
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define sll set<ll>
#define str string
#define rev reverse
#define mp make_pair
#define pb push_back
#define acc accumulate
#define vll vector<ll>
#define eb emplace_back
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define dq deque<ll>
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back

void solve()
{
    ll n,m,i,j;
    cin >> n >> m;
    ll a[n][m];
    char b[n][m];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
            cin >> b[i][j];
    }
    ll mo=1000000007;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(b[i][j]=='#')
                a[i][j]=0;   
            else if(i==0 && j==0)
                a[i][j]=1;
            else if(i==0)
                a[i][j]=a[i][j-1]%mo;
            else if(j==0)
                a[i][j]=a[i-1][j]%mo;
            else
                a[i][j]=(a[i-1][j]%mo+a[i][j-1]%mo)%mo;

        }
    }
    cout << a[n-1][m-1] << endl;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll cases;
    //cin >> cases;
    cases=1;
    for(ll i=0;i<cases;i++)
        solve();

    return 0;
}

Measured memory_bytes: 9088
import sys
bbn=1000000007
	
#+++++
		
def main():
	n = int(input())
	al = list(map(int, input().split()))
	
	b4=0
	odd=0
	b2=0
	for v in al:
		if v % 4 == 0:
			b4+=1
		elif v % 2 == 1:
			odd+=1
		else:
			b2+=1
	ret = 'Yes' if (b4 + (b2==0))>= odd else 'No'
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 62576
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<vector>
using namespace std;
priority_queue<string,vector<string>,greater<string> >q;
int main(){
	int n,l;
	cin>>n>>l;
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		q.push(s);
	}
	while(q.size()>0){
		cout<<q.top();
		q.pop();
	}
	cout<<endl;
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n;
string s;
cin >> n >> s;
ll all=n*(n-1)*(n-2)/6;
for(ll i=1;i<n+1;i++){
    for(ll j=1;j<n+1;j++){
        if(i>=j)continue;
        if(2*j-i-1>=n)continue;
        if(s[i-1]==s[j-1]||s[j-1]==s[2*j-i-1]||s[i-1]==s[2*j-i-1])all++;
        }
    }
for(ll j=1;j<=n;j++){
    all-=min(n-j,j-1);
}
ll cntr=0;
ll cntg=0;
ll cntb=0;
for(ll i=0;i<n;i++){
    if(s[i]=='R')cntr++;
    else if(s[i]=='G')cntg++;
    else cntb++;
}
all-=3*cntr*(cntr-1)*(n-2)/6;
all-=3*cntg*(cntg-1)*(n-2)/6;
all-=3*cntb*(cntb-1)*(n-2)/6;
all+=2*((cntr*(cntr-1)*(cntr-2)/6)+(cntg*(cntg-1)*(cntg-2)/6)+(cntb*(cntb-1)*(cntb-2)/6));

cout << all << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

//reverseはO(|s|)なので間に合わない
//先頭に追加もO(|S|)なのでダメ
//vectorを2つ用意し、reveseごとにその2つをswapする
int main(){
    string s;
    int q;
    cin >> s >> q;
    //これが2つ目のベクトル
    string t; 
    rep(qi,q){
        int ty;
        cin >> ty;
        if(ty==1){
            //swapはO(1)でできる
            swap(s,t);
        }
        else{
            int f; char c;
            cin >> f >> c;
            if(f==1){
                //先頭に追加=tに追加
                t += c;
            }
            else{
                //末尾に追加=sに追加
                s += c;
            }
        }
    }
    reverse(all(t));
    t += s;
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 4044
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    As = [list(map(int, input().split())) for i in range(3)]
    n = int(input())

    for i in range(n):
        b = int(input())

        for j in range(3):
            for k in range(3):
                if As[j][k] == b:
                    As[j][k] = -1

    for i in range(3):
        if As[i] == [-1, -1, -1]:
            print('Yes')
            return
        ri = [_[i] for _ in As]

        if ri == [-1,-1,-1]:
            print('Yes')
            return

    if As[0][0] == As[1][1] == As[2][2] == -1 or As[2][0] == As[1][1] == As[0][2] == -1:
        print('Yes')
        return
    
    print('No')


    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5072
n = int(input())
#x, y = map(int,input().split())
li = list(map(int, input().split()))

li2 = []
for i in range(n):
    li2.append([li[i],i+1])
li2.sort()

for i in range(len(li2)):
    print(li2[i][1],end = " ")

Measured memory_bytes: 21440
#include<iostream>
using namespace std;
#define FIO \
    freopen("input.txt","r",stdin); \
    freopen("output.txt","w",stdout);
int main()
{
    //FIO;
    int n; cin>>n;
    int i = 1; 
    int cnt=0;
    while(i <= n)
    {
        int temp; cin>>temp;
        if(i&1 && temp&1)
          cnt++;
        i++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    n %= 1000;
    if (n == 0) {
        cout << 0 << endl;
        exit(0);
    }
    cout << 1000 - n << endl;
    return 0;
}

Measured memory_bytes: 3648
a, b, c, x, y = map(int, input().split())

ans = float('inf')
for k in range(2*max(x, y)+1):
    cost = c * k
    need_x = max(0, x - k // 2)
    need_y = max(0, y - k // 2)
    cost += a * need_x + b * need_y
    ans = min(ans, cost)
print(ans)

Measured memory_bytes: 41324
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    string s;
    cin >> s;
    if(s.size() < 4) cout << "No" << endl;
    else if(s.at(0) == 'Y' && s.at(1) == 'A' && s.at(2) == 'K' && s.at(3) == 'I') cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
#define int long long
const int N=1e6+5;
char a[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
signed main()
{
	scanf("%s",a+1);
	if(a[1]=='S')puts("Cloudy");
	if(a[1]=='C')puts("Rainy");
	if(a[1]=='R')puts("Sunny");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector <int> A(N);
    REP(i,N) cin >> A[i];
    vector <int> ANS(N);
    REP(i,N){
        ANS[A[i]-1] = i+1;
    }
    REP(i,N) cout << ANS[i] << ' ';
    cout << endl;
    return 0;
}



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

int main(void){
	int n,n_l[40],count=0,cap=0;
	char w[10];
	scanf("%d",&n);

	int i;
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%s",w);
			n_l[i]=strlen(w);
		}
		for(i=0;;i++){
			count=0;
			cap=0;
			while(count<5){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=5)
				continue;
			count=0;
			while(count<7){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=7)
				continue;
			count=0;
			while(count<5){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=5)
				continue;
			count=0;
			while(count<7){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=7)
				continue;
			count=0;
			while(count<7){
				count+=n_l[i+cap];
				cap++;
			}
			if(count!=7)
				continue;
			break;
		}
		printf("%d\n",i+1);
		scanf("%d",&n);
	}
	return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	string s;
	while (cin >> s) {
		vector<string>v;
		v.push_back(s);
		rep(i, 0, 7) {
			string t; cin >> t;
			v.push_back(t);
		}
		char ans;
		rep(i, 0, 8) {
			rep(j, 0, 8) {
				if (v[i][j] == '1') {
					if (j + 1 < 8 && i + 1 < 8 && v[i][j + 1] == '1'&&v[i + 1][j] == '1'&&v[i + 1][j + 1] == '1')ans = 'A';
					else if (i + 3 < 8 && v[i + 1][j] == '1'&&v[i + 2][j] == '1'&&v[i + 3][j] == '1')ans = 'B';
					else if (j + 3 < 8 && v[i][j + 1] == '1'&&v[i][j + 2] == '1'&&v[i][j + 3] == '1')ans = 'C';
					else if (i + 1 < 8 && j + 2 < 8 && v[i][j + 1] == '1'&&v[i + 1][j + 1] == '1'&&v[i + 1][j + 2] == '1')ans = 'E';
					else if (i + 2 < 8 && j + 1 < 8 && v[i + 1][j] == '1'&&v[i + 1][j + 1] == '1'&&v[i + 2][j + 1] == '1')ans = 'F';
					else if (i + 2 < 8 && j - 1 >= 0 && v[i + 1][j] == '1'&&v[i + 1][j - 1] == '1'&&v[i + 2][j - 1] == '1')ans = 'D';
					else //if (i - 1 >= 0 && i + 1 < 8 && j + 1 < 8 && v[i][j + 1] == '1'&&v[i + 1][j] == '1'&&v[i - 1][j - 1] == '1')
						ans = 'G';
					goto here;
				}
			}
		}
	here:;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
#include <stdio.h>
#include <stack>
#include <math.h>
 
using namespace std;
 
 
int main(){
 
    int n,tmp;
    scanf("%d",&n);
 
    int L[n],length = 0;
 
    for(int i=0; i < n; i++){
        scanf("%d",&tmp);
 
        if(i == 0){
            L[0] = tmp;
        }else{
            if(L[length] < tmp){
                length++;
                L[length] = tmp;
            }else{
                for(int k = 0; k <= length; k++){
                    if(L[k] >= tmp){
                        L[k] = tmp;
                        break;
                    }
                }
            }
        }
    }
 
    printf("%d\n",length+1);
 
    return 0;
}


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

int H, W;
vector<vector<int>> field;
void dfs(int h, int w) {
    field[h][w] = 0;
    for(int dh = -1; dh <= 1; dh++) {
        for(int dw = -1; dw <= 1; dw++) {
            int nh = h + dh;
            int nw = w + dw;
            if(nh < 0 || H <= nh || nw < 0 || W <= nw) {
                continue;
            }
            if(field[nh][nw] == 0) {
                continue;
            }
            dfs(nh, nw);
        }
    }
}
int main() {
    while (cin >> W >> H) {
        if (H == 0 || W == 0) break;
        field.assign(H, vector<int>(W, 0));
        for (int h = 0; h < H; ++h) for (int w = 0; w < W; ++w) cin >> field[h][w];

        // 探索開始
        int count = 0;
        for (int h = 0; h < H; ++h) {
            for (int w = 0; w < W; ++w) {
                if (field[h][w] == 0) continue; // 残島じゃなかったらスルー
                dfs(h, w);
                ++count;
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3360
# cf16-exhibition-final-openC - Cheating Nim
def main():
    # player is second move -> make xor 0
    N, *A = map(int, open(0))
    A.sort(reverse=1)
    ans, x, flg = 0, 0, [0] * 30
    for i in A:
        x ^= i
        p = bin(i ^ i - 1)[::-1].rfind("1")  # rightmost bits of i^i-1
        flg[p] = 1
    for i in range(29, -1, -1):
        p = 2 ** i
        if x & p:  # i-th bit is on
            if flg[i]:  # possible to erase i-th bit of x
                x ^= p - 1
                ans += 1
            else:
                print(-1)
                return
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 7484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define sz(s) (int)s.size()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

ll power(ll x,ll y){
	ll t=1;
	while(y>0){
		if(y%2) y-=1,t=t*x%mod;
		else y/=2,x=x*x%mod;
	}
return t;
}

ll x[N],val[N],n;
set <ll> s;

int main(){
	ll finder=0,ans=1;
	scanf("%lld",&n);
	REP(i,n){
		scanf("%lld",&x[i]);
		s.insert(x[i]);
	}
	REPP(i,1,2*n-2){
		if (s.find(i)!=s.end()){
			if (i%2==0&&finder==i/2)
				ans=(ans*(i/2+1))%mod;
			else finder++;
		}
	}
	REP(i,n) if (x[i]>(2*n-3)) finder++;
	REPP(i,2,finder+1) ans=(ans*i)%mod;
	printf("%lld\n",ans);
	return 0;
}

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

struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
        b=s[1];
        s[1]=s[2];
        s[2]=s[4];
        s[4]=s[3];
        s[3]=b;
    }
  }
  int top() {
    return s[0];
  }
};

bool jud(int s1,int s2,int s3,int s4,int s5,int dd1,int dd2,int dd3,int dd4,int dd5){
    if(s1==dd1&&s2==dd2&&s3==dd3&&s4==dd4&&s5==dd5)return true;
    else return false;
}

int main(){
  Dice d;
  for(int i=0;i<6;i++) cin >> d.s[i];
  int di[6];
  for(int i=0;i<6;i++) cin >> di[i];

            if(d.s[0]==di[0]){
              for(int j=0;j<5;j++){
                  d.roll('R');
                  if(jud(d.s[1],d.s[2],d.s[3],d.s[4],d.s[5],di[1],di[2],di[3],di[4],di[5])){
                      cout<<"Yes"<<endl;
                      return 0;
                  }
              }
            }

      for(int i=0;i<3;i++){
          d.roll('E');
          if(d.s[0]==di[0]){
              for(int j=0;j<5;j++){
                  d.roll('R');
                  if(jud(d.s[1],d.s[2],d.s[3],d.s[4],d.s[5],di[1],di[2],di[3],di[4],di[5])){
                      cout<<"Yes"<<endl;
                      return 0;
                  }
              }
          }

      }
          for(int i=0;i<3;i++){
        d.roll('N');
          if(d.s[0]==di[0]){
              for(int j=0;j<5;j++){
                  d.roll('R');
                  if(jud(d.s[1],d.s[2],d.s[3],d.s[4],d.s[5],di[1],di[2],di[3],di[4],di[5])){
                      cout<<"Yes"<<endl;
                      return 0;
                  }
              }
          }
    }
          cout<<"No"<<endl;
  
  return 0;
    
  }






Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef pair<double, double> pdd;

int n;
vector<pdd> v;
int iter = 100;

double f(double x, double y){
	double r = 0.0;
	rep(i, n) {
		double a = v[i].fi, b = v[i].se;
		r = max(r, hypot(x - a, y - b));
	}
	return r;
}

double g(double x){
	double left = -1000.0, right = 1000.0;
	rep(i, iter){
		double m1 = (left * 2 + right) / 3;
		double m2 = (left + right * 2) / 3;
		if(f(x, m1) > f(x, m2)) left = m1;
		else right = m2;
	}

	return f(x, left);
}

double solve(){
	double left = -1000.0, right = 1000.0;
	rep(i, iter){
		double m1 = (left * 2 + right) / 3;
		double m2 = (left + right * 2) / 3;
		if(g(m1) > g(m2)) left = m1;
		else right = m2;
	}
	
	return g(left);
}

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

	cin >> n;

	v.resize(n);
	rep(i, n){
		double x, y;
		cin >> x >> y;
		v[i] = {x, y};
	}
	
	cout << fixed << setprecision(10);
	cout << solve() << endl;
}


Measured memory_bytes: 256
#include <iostream>

 using namespace std;

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



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

using namespace std;

using ll=long long;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr int mo = 1e9+7;

int h,w;
vector<vector<char>> f(25,vector<char>(25));
vector<pair<int,int>> dir = {{0,-1},{-1,0},{0,1},{1,0}};
int bfs(int i,int j){
    vector<vector<int>> fi(h,vector<int>(w,inf));
    fi[i][j] = 0;
    queue<pair<int,int>> q;
    q.push({i,j});
    while(!q.empty()){
        auto cur = q.front();q.pop();
        for(auto d : dir){
            int dy = cur.first + d.first;
            int dx = cur.second + d.second;
            if(dy < 0 or dy >= h or dx < 0 or dx >= w or f[dy][dx] == '#')continue;
            if(fi[dy][dx] > fi[cur.first][cur.second] + 1){
                fi[dy][dx] = fi[cur.first][cur.second] + 1;
                q.push({dy,dx});
            }
        }
    }
    
    int ret = 0;
    for(int i=0;i<h;++i)for(int j=0;j<w;++j)if(f[i][j] != '#'){
        ret = max(ret,fi[i][j]);
    }
    return ret;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    cin>>h>>w;
    for(int i=0;i<h;++i)for(int j=0;j<w;++j)cin>>f[i][j];
    
    int ret = 0ll;
    for(int i=0;i<h;++i)for(int j=0;j<w;++j)if(f[i][j] == '.'){
        ret = max(ret,bfs(i,j));
    }
    cout << ret << endl;
    return 0;
}


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

#define ll long long
#define mod 1000000007

using namespace std;

ll power(ll x, ll N){
	ll res = 1;
  
	for(ll i=1; i<=N; i++)
    {
		res*=x;
		res%=mod;
	}
  
	return res;
}


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

	ll total = power(10, N);
	ll noZero = power(9, N);
	ll noNine = power(9, N);
	ll neitherZeroNorNine = power(8, N);

	ll ans = total - noNine - noZero + neitherZeroNorNine;
	ans%=mod;
	ans = (ans+mod)%mod;
	cout<<ans;

	return 0;
}


Measured memory_bytes: 3612
#include <map>
typedef long long ll;

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

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int n;
int a[300];
int tot;
ll dp[90000 + 1];
ll dp2[90000 + 1];
const ll mod = 998244353;

ll mpow(ll b, ll e){
  ll ret = 1;
  while(e){
    if(e & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    e /= 2;
  }
  return ret;
}

/*
ll solve(int pos, int cnt, int sum){
  if(pos == n){
    if(cnt == n) return 3;
    if(cnt == n - 1) return 2 * 3;
    if(sum + sum > tot) return (3 * mpow(2, n - cnt)) % mod;
    if(sum + sum == tot) return (3 * mpow(2, n - cnt) - 3 + mod) % mod;
    return 0;
  }

  if(dp[pos][cnt].count(sum))
    return dp[pos][cnt][sum];

  ll res = 0;
  res = (res + solve(pos + 1, cnt + 1, sum + a[pos])) % mod;
  res = (res + solve(pos + 1, cnt, sum)) % mod;
  return dp[pos][cnt][sum] = res;
}
*/

int main(){
  n = getInt();
  REP(i,n) a[i] = getInt();


  dp[0] = 1;
  dp2[0] = 1;
  REP(i,n){
    for(int j = tot; j >= 0; j--){
      dp[j + a[i]] = (dp[j + a[i]] + dp[j]) % mod;
      dp[j] = dp[j] * 2 % mod;

      dp2[j + a[i]] = (dp2[j + a[i]] + dp2[j]) % mod;
    }
    tot += a[i];
  }

  REP(i,n) if(a[i] + a[i] >= tot){
    printf("%d\n", 0);
    return 0;
  }

  ll ans = mpow(3, n);
  ll inv = 0;

  REP(i,tot+1){
    const int sum = i;
    if(sum == tot) inv += 3 * dp[i];
    else if(sum + sum >= tot) inv += 3 * dp[i] % mod;
    if(sum + sum == tot) inv = (inv + (mod - dp2[i]) * 3) % mod;
    inv %= mod;
  }

  // printf("%lld %lld\n", ans, inv);

  ans = (ans - inv + mod) % mod;
  printf("%lld\n", ans);

  return 0;
}

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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int i,j,k;
  i=10*A+B+C;
  j=10*B+A+C;
  k=10*C+A+B;
  int s=max({i,j,k});
  cout<<s;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

int dp[101][101];
int cost2cal[101][101];
int cal2well[10101];

int main(){
  //STUNOD
  int upper_HP;
  int total_trainings;
  int training_norma;
  int total_donuts;
  int recover;
  int total_days;
  while(~scanf("%d %d %d %d %d %d",
	       &upper_HP,
	       &total_trainings,
	       &training_norma,
	       &total_donuts,
	       &recover,
	       &total_days)){
    vector<P> trainings;
    for(int training_idx=0;training_idx<total_trainings;training_idx++){
      int training_cost,consume_cal;
      scanf("%d %d",&training_cost,&consume_cal);
      trainings.push_back(P(training_cost,consume_cal));
    }
    vector<P> donuts;
    for(int donuts_idx=0;donuts_idx<total_donuts;donuts_idx++){
      int well_being_level,retain_cal;
      scanf("%d %d",&well_being_level,&retain_cal);
      donuts.push_back(P(well_being_level,retain_cal));
    }

    memset(cost2cal,-1,sizeof(cost2cal));

    cost2cal[0][0] = 0;
    for(int training_idx=0;training_idx<total_trainings;training_idx++){
      int cal = trainings[training_idx].second;
      int training_cost = trainings[training_idx].first;

      for(int prev=training_norma;prev>=0;prev--){
	for(int consumed_HP = upper_HP;consumed_HP >= 0 ;consumed_HP--){
	  if(cost2cal[consumed_HP][prev] == -1) continue;

	  cost2cal[consumed_HP][prev]
	    = max(cost2cal[consumed_HP][prev],
		  cost2cal[consumed_HP][prev]);

	  if(consumed_HP + training_cost > upper_HP) continue;
	  cost2cal[consumed_HP + training_cost][prev+1]
	    = max(cost2cal[consumed_HP][prev] + cal,
		  cost2cal[consumed_HP + training_cost][prev+1]);
	}
      }
    }

    memset(cal2well,0,sizeof(cal2well));
    for(int donuts_idx=0;donuts_idx<total_donuts;donuts_idx++){
      int well = donuts[donuts_idx].first;
      int retain = donuts[donuts_idx].second;
      for(int cal=0;cal<=10000;cal++){
	cal2well[cal + retain] = max(cal2well[cal] + well,
				     cal2well[cal + retain]);
      }
    }


    memset(dp,-1,sizeof(dp));
    dp[0][upper_HP] = 0;
    for(int day=0;day<total_days;day++){
      for(int HP=0;HP<=upper_HP;HP++){
	if(dp[day][HP] == -1) continue;
	for(int training_cost=0;training_cost<=HP;training_cost++){
	  if(cost2cal[training_cost][training_norma] == -1) continue;

	  int next_HP = min(HP - training_cost + recover,upper_HP);
	  dp[day+1][next_HP]
	    = max(dp[day][HP] + cal2well[cost2cal[training_cost][training_norma]],
		  dp[day+1][next_HP]);
	}
      }
    }

    int res = -1;
    for(int HP=0;HP<=upper_HP;HP++){
      res = max(dp[total_days][HP],res);
    }
    printf("%d\n",res);
  }
}

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

using namespace std;
typedef long long ll;
int main(){
	ll n,tw;
	cin>>n>>tw;
	ll a[n];
	ll w[n];
	for(int i=0;i<n;i++){
		cin>>w[i]>>a[i];}
	ll dp[n][tw+1];
	//for(int i=0;i<n;i++){
		for(ll j=0;j<tw+1;j++){
			if(j>=w[0] )
			dp[0][j]=a[0];
			else dp[0][j]=0;}
	for(ll i=1;i<n;i++){
		for(ll j=0;j<tw+1;j++){
		if(j-w[i]<0)  dp[i][j]=dp[i-1][j];
		else{
			//cout<<"entered else ";
		dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+a[i]);}
	}
}
		/*for(ll i=0;i<n;i++){
		for(ll j=0;j<tw+1;j++){
			cout<<dp[i][j]<<"\t";}
			cout<<endl;
		}*/
		cout<<dp[n-1][tw]<<endl;
	}
	

Measured memory_bytes: 78336
import math

N, K = map(int, input().split())
ans = 0
if N < K:
    for i in range(1, N+1):
        p = math.ceil(math.log2(K/i))
        ans += (1/2)**p
    print(ans/N)
else:
    M = K - 1
    for i in range(1, K):
        p = math.ceil(math.log2(K/i))
        ans += (1/2)**p
    ans = ans + (N - K + 1)
    print(ans/N)

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

using namespace std;

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int64_t> P(A), Q(B), R(C);
  for (int i = 0; i < A; i++) cin >> P[i];
  for (int i = 0; i < B; i++) cin >> Q[i];
  for (int i = 0; i < C; i++) cin >> R[i];
  sort(P.rbegin(), P.rend());
  sort(Q.rbegin(), Q.rend());
  sort(R.rbegin(), R.rend());

  int64_t answer = 0LL;
  for (int i = 0; i < X; i++) answer += P[i];
  for (int i = 0; i < Y; i++) answer += Q[i];

  int ia = X - 1;
  int ib = Y - 1;
  int ic = 0;

  while (ic < C) {
    int64_t gainA = -1;
    int64_t gainB = -1;
    if (ia >= 0) {
      gainA = max(gainA, R[ic] - P[ia]);
    }

    if (ib >= 0) {
      gainB = max(gainB, R[ic] - Q[ib]);
    }

    if (gainA < 0 && gainB < 0) {
      break;
    }
    if (gainA > gainB) {
      answer += gainA;
      ic++;
      ia--;
    } else {
      answer += gainB;
      ic++;
      ib--;
    }
  }

  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
	vite;
	lli n,t=0;
	cin >> n;
	lli a[n + 1];
	for (lli i = 1; i <= n;i++)
		cin >> a[i];

	for (lli i = 1;i<=n;i+=2)
	{
		if(a[i]%2==1)
			t++;
	}
	cout << t;
	// cout<<endl<<fixed << 1.0 * clock() / CLOCKS_PER_SEC << setprecision(5);
	return 0;
}

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

using namespace std;

int main(void) {
  long long a;
  cin >> a;
  string s = to_string(a);
  long long n = s.size();
  long long ans = 0;
  long long tmp;
  for (long long i = 0; i < (1 << n - 1); i++) {
    bitset<9> b(i);
    long long bai = 10;
    ans += s[n - 1] - '0';
    // 計算結果決まる
    for (long long j = n - 2; j >= 0; j--) {
      if (b.test(j)) {
        tmp = s[j] - '0';
        ans += tmp;
        bai = 10;
      } else {
        tmp = (s[j] - '0') * bai;
        ans += tmp;
        bai *= 10;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//#define NDEBUG
 
#include <bits/stdc++.h>
 
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)
 
//#define TEST
 
typedef long long ll;
typedef unsigned long long ull;
 
using namespace std;
 
const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    int now = 0;
    int ans = 0;

    int n;
    cin >> n;
    int lst;
    cin >> lst;
    for(int i = 1; i < n; i++){
        int h;
        cin >> h;
        if(h <= lst) now++;
        else now = 0;
        lst = h;
        ans = max(now, ans);
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256