akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int a=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());
        if(a==1){ a=14; }
        if(b==1){ b=14; }
        if(a>b){ System.out.println("Alice"); }
        else if(a<b){ System.out.println("Bob"); }
        else{ System.out.println("Draw"); }
    }
}


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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  int n;
  cin>>n;
  vi a=calc(n);
  YesNo(a[0]==a[2]);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

    int a, b;
    int d, r;
    double f;

    scanf("%d %d", &a, &b);


    d = a / b;
    r = a % b;
    f = (double)a / (double)b;

    printf("%d %d %f\n", d, r, f);
    return 0;
}

Measured memory_bytes: 636
x, k, d = map(int, input().split())
time = x // d
if abs(time) > k:
    print(min(abs(x - d * k), abs(x + d * k)))
    exit()
k -= time
x -= d * time
if k % 2 == 0:
    print(abs(x))
else:
    print(min(abs(x - d), abs(x + d)))


Measured memory_bytes: 9184
#include <stdio.h>

#define N 100000

//function

struct process{
  char name[10];
  int ptime;
};
typedef struct process s_process;

void enque(s_process);
s_process deque(void);
void print_queue(void);
void print_result(void);

//global
s_process Q[N+1];
s_process R[N+1];
int length;
int head;
int tail;
int quan;
int total=0;

int main(){
  int i,count=0;
  int qtotal=0;

  s_process p;

  scanf("%d %d",&length,&quan);

  head = length/2;
  tail = length/2;

  for(i=0;i<length;i++){
    scanf("%s %d",p.name,&p.ptime);
    enque(p);
  }

  while(count != length){
      p = deque();
      if((p.ptime - quan) <= 0){
        qtotal += p.ptime;
        p.ptime = qtotal;
        R[count++] = p;
      }
      else{
        p.ptime -= quan;
        enque(p);
        qtotal += quan;
      }
  }

  print_result();
  return 0;
}

void enque(s_process p){

  Q[tail] = p;

  if(tail == length){
    tail = 0;
  }
  else tail++;
}

s_process deque(void){
  s_process p;
  p = Q[head];
  if(head == length)
    head=0;
  else head++;
  return p;
}

void print_queue(void){
  int i;

  for(i=head;i!=tail;i++){
    if(i == length){
      printf("%s %d\n",Q[i].name,Q[i].ptime);
      i=0;
    }
    printf("%s %d\n",Q[i].name,Q[i].ptime);
  }

}

void print_result(void){
  int i;

  for(i=0;i<length;i++){
    printf("%s %d\n",R[i].name,R[i].ptime);
  }

}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
#define Rep(i, j, k) for(R int i = (j), ED = (k); i >= ED; --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread (buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar (x % 10 | 48);
	}

	inline void wrn ( ll x ) { write (x); putchar (' '); }

	inline void wln ( ll x ) { write (x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn (x), wln (y); }

}

using IO::wrn;
using IO::read;

namespace Cesare {
	
	ll n, a[N], b[N], S[N];
	
	int main() {
		n = read();
		For ( i, 1, n ) a[i] = read();
		For ( i, 1, n ) S[i] = S[i - 1] + (i % 2? 1: -1) * a[i];
		wrn(S[n]); For ( i, 2, n ) wrn (S[n] = a[i - 1] * 2 - S[n]);
		return 0;
	}
	
}

int main()
{
	return Cesare::main();
}

/*
S = a[1] - a[2] + a[3] - a[4]

C[i] = a[i] - a[i + 1]

b[1] = 2 * a[1] + 2 * a[2]
b[2] = 2 * a[1] - b[1]
b[3] = 2 * a[2] - b[2]
b[i] = 2 * a[i - 1] - b[i - 1]
b[n] = 2 * a[n - 1] - b[n - 1]
b[1] = 2 * a[n] - b[n]

b[1] + b[2] = 2 * a[1]
b[2] + b[3] = 2 * a[2]
2 * a[1] - b[1] + b[3] = 2 * a[2]
b[3] + b[4] = 2 * a[3]
b[2] - b[4] = 2 * a[2] - 2 * a[3]
b[n] + b[1] = 2 * a[n]
b[n] - b[2] = 2 * a[n] - 2 * a[1]

b[1] - b[3] = 2 * a[1] - 2 * a[2]
b[2] - b[4] = 2 * a[2] - 2 * a[3]
b[3] - b[5] = 2 * a[3] - 2 * a[4]
b[n - 1] - b[1] = 2 * a[n - 1] - 2 * a[n]
b[n - 1] - b[3] = 2 * a[n - 1] - 2 * a[n] + 2 * a[1] - 2 * a[2]
b[n - 1] - b[n - 2] = 
	2 * a[n - 1] - 2 * a[n] + 2 * a[1] - 2 * a[2] + ... - 2 * a[n - 3]

b[n] - b[2] = 2 * a[n] - 2 * a[1]
b[n] - b[4] = 2 * a[n] - 2 * a[1] + 2 * a[2] - 2 * a[3]

b[n] - b[n - 1] = 
	2 * a[n] - 2 * a[1] + 2 * a[2] - 2 * a[3] +... - 2 * a[n - 2]

b[n - 1] - b[n - 2] = 2 * a[n - 1] - 2 * a[n - 2]

b[n - 1] - b[1] = 2 * a[n - 1] - 2 * a[n]
b[n] - b[1] = 2 * a[n - 1] - 2 * a[n - 2]
b[n] - b[n - 1] = 2 * a[n] - 2 * a[n - 2]
b[1] - b[n] = 2 * a[n - 2] - 2 * a[n - 1]

b[n - 2] - b[n - 3] = 2 * a[n - 2] - 2 * a[n - 4]
b[n - 1] - b[n - 3] = 2 * a[n - 1] - 2 * a[n - 4]
b[n - 2] - b[n - 1] = 2 * a[n - 2] - 2 * a[n - 1]

b[n - 1] + b[n] = 2 * a[n - 1]
b[n - 1] - b[1] = 2 * a[n - 1] - 2 * a[n]

b[i] + b[i + 1] = 2 * a[i]
b[i + 1] + b[i + 2] = 2 * a[i + 1]
b[i] - b[i + 2] = 2 * a[i] - 2 * a[i + 1]
*/






Measured memory_bytes: 2944
import sys

from collections import deque
# q = deque(); q.append(x); q.appendleft(x); q.pop() -> x; q.popleft() -> x
from collections import defaultdict
# d = defaultdict(lambda: []); d[key] -> []
import heapq
# hq = []; heapq.heappush(hq, x); heapq.heappop(hq) -> x; heapq.heappushpop(hq, x) -> x
import bisect
# i = bisect.bisect_left([1,2,3,4], 1.5); i = bisect.bisect_right([4,3,2,1], 1.5)

#import numpy as np
#from scipy.misc import comb

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    X, Y = i2nn()
    n = int(X + Y / 2)
    print(n)

main()


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int n;
	cin>>n;
	int sum=0;
	int a[200];
	for(int i=0;i<2*n;i++)cin>>a[i];
	sort(a,a+n+n);
	for(int i=0;i<2*n;i+=2){
		sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
W = list(map(int,input().split()))
W_sum = sum(W)
S = 0
ans = W_sum

for i in W[:N-1]:
    S += i
    if (ans < abs(W_sum-S*2)):
        break
    ans = W_sum-S*2

print(abs(ans))


Measured memory_bytes: 3060
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
const ld PI = (acos(-1));
 
int main() {
  ld a, b, x;
  cin >> a >> b >> x;
 
  ld ans;
  if (a * a * b / 2.0 <= x) {
    ans = atan(2 * (a * a * b - x) / (a * a * a));
  } else {
    ans = PI / 2 - atan(2 * x / (a * b * b));
  }
 
  cout << fixed << setprecision(6) << ans * 180.0 / PI << endl;
 
  return 0;
}

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

#define int long long 
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pi> 
#define vvpii vector<vpii>
#define all(V) V.begin(),V.end()
#define mpii map<int,int> 
#define mpci map<char,int> 
#define fi first
#define si second
#define pb(V) push_back(V)
#define mp(a,b) make_pair(a,b)
#define mt(a,b,c) make_tuple(a,b,c)
#define forn(i,n) for (int i = 0; i < int(n); ++i)


const int N = 2010;
const int mod = 1e9 + 7;
vi fact(N,0);

int binpow(int a,int b)
{
	int res = 1;
	while(b)
	{
		if(b & 1)
		{
			res = (res*a)%mod;
		}
		b >>= 1;
		a = (a*a)%mod;
	}
	return res%mod;
}
void precompute()
{
	fact[0] = 1;
	for(int i = 1; i < N; ++i)
	{
		fact[i] = (fact[i-1]*i)%mod;
	}
}

int nCr(int n, int r)
{
	if(n < r)
	return 0;
	int num = fact[n]%mod;
	int div = (fact[r]*fact[n-r])%mod;
	int inv = binpow(div,mod-2);
	inv %= mod;
	return (num*inv)%mod;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	precompute();
	//~ cout << fact[6] << " ";
	//~ cout << nCr(5,2);
	for(int i = 1; i <= k; ++i)
	{
		
			int x = nCr(k-1,i-1);
			int y = nCr(n-k+1,i);
			if((x*y)%mod < 0)
			{
				cout << 0 << '\n';
			}
			else
			cout << (x*y)%mod << '\n';
		
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		 int F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
	long long G()
	{
		 long long F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
}
int R(int l,int r)
{
	return (rand()<<15|rand())%(r-l+1)+l;
}
char s[222222];
int f[222222];
int next[222222][26];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	f[n+1]=0;
	for(register int i=0;i<26;++i)next[n][i]=n+1;
	for(register int i=n-1;i>=0;--i)
	{
		memcpy(next[i],next[i+1],sizeof(next[i]));
		next[i][s[i+1]-'a']=i+1;
	}
	for(register int i=n;i>=0;--i)
	{
		f[i]=n+1;
		for(register int j=0;j<26;++j)
			cmin(f[i],1+f[next[i][j]]);	
	}
	int now=0;
	while(now!=n+1)
	{
		for(register int i=0;i<26;++i)
			if(f[next[now][i]]==f[now]-1)
			{
				putchar('a'+i);
				now=next[now][i];
				break;
			}
	}
	return 0;
}


Measured memory_bytes: 21760
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;cin>>a>>b;
    int n=min(a,b);
    int B=0;
    int k;
    cin>>k;
    vector<int> A(n,0);
    for(int i = 1;i<n+1;i++){
        if(a%i==0&&b%i==0){
            A.at(B)=i;
            B++;
        }
        
    }
   sort(A.begin(),A.end()) ;
  /* for(int i = 0 ; i < n ; i++){
       cout <<A.at(i)<<" ";
   }
   */
   cout<<A.at(n-k)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include <string.h>
#include <algorithm>

using namespace std;
int dp[101][10001];
int v_l[101], w_l[101];

int main(){
  int N;cin>>N;
  int W;cin>>W;
  for (int i=1; i<= N;i++) {
    cin>>v_l[i];cin>>w_l[i];
  }

  memset(dp,-1,sizeof(dp));
  for (int i = 0; i < N; i++)dp[i][0]=0;
  for (int w = 0; w < W; w++)dp[0][w]=0;
  for (int i = 1; i <=N ; i++){
    for (int w = 1; w <=W ; w++){
      if(dp[i][w]>=0) return dp[i][w];
      if(w-w_l[i]>=0) dp[i][w]=max(dp[i-1][w],dp[i-1][w-w_l[i]]+v_l[i]);
      else dp[i][w]=dp[i-1][w];
    }
  }
  cout <<dp[N][W]<<"\n"; 
}



Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

//***********************************
//mintを定義
//***********************************
const int mod = 1000000007;
struct mint {
  int x;
  mint(int x=0):x(x%mod){}   //メンバ変数xをx%modで初期化
  int get() const { return (int)x; }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;           //thisは暗黙的に左辺のポインタ
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }

  //累乗
  mint mpow(int t) const {
    if (!t) return 1;
    mint a = mpow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  //除算
  mint minv() const {
    return mpow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.minv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

//標準出力
ostream& operator<<(ostream& st, const mint a) 
{ st << a.get(); return st; };
//--------------------------------------------------

//***********************************
//場合の数の計算
//***********************************
const int MAX = 200010;
mint fac[MAX], finv[MAX];

//前計算
inline void INIT_F(){
    fac[0] = finv[0] = 1;
    for(int i=1; i<MAX-1; i++) {
        fac[i] = (fac[i-1]*mint(i));
        finv[i] = (finv[i-1]/mint(i));
    }
}

//nCk
mint mcomb(int n, int k) {
    if(n<k || k<0) return 0;
    else return ((fac[n]*finv[k])*finv[n-k]);
}

//nHk
mint mhcomb(int n, int k) {
  return mcomb(n+k-1, k);
}
//--------------------------------------------------

signed main() {
    int N, M;
    cin >> N >> M;
    INIT_F();

    mint res = 1;
    int d = 2;
    while(d*d <= M) {
        int cnt = 0;
        while(M%d==0) {
            cnt++;
            M/=d;
        }
        res *= mhcomb(N, cnt);
        d++;
    }
    if(M > 1) res *= mhcomb(N, 1);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3456
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    c = Counter(A)
    d = c.most_common()
    ans = [i[0] for i in c.items() if i[1] == d[0][1]]
    for i in sorted(ans):
        print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49196
import java.util.Scanner;

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

        int N = sc.nextInt();
        int A[] = new int[N];
        for(int i = 0; i < N; i++) A[i] = sc.nextInt();

        int sum = 0;
        boolean flag = true;
        while(flag){
            flag = false;
            for(int i = N-1; 0 < i ; i--){
                if(A[i] < A[i-1]){
                    int m = A[i];
                    A[i] = A[i-1];
                    A[i-1] = m;
                    sum++;
                    flag = true;
                }
            }
        }
        
        for(int i = 0; i < N; i++){
            System.out.print(A[i]);
            if(i != N - 1) System.out.print(" ");
        }
        System.out.println();
        System.out.println(sum);

        sc.close();
    }
}


Measured memory_bytes: 26392
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class AAC {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s; cin >> s;
      if (s[1] == 'B') {
        s[1] = 'R';
      } else {
        s[1] = 'B';
      }
      cout << s << endl;
    }
};

signed main() {
  AAC solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
long long n,m,ans=0;
long long powmod(long long a,long long b,long long p){
	long long ans=1;
	for(;b;b>>=1){
		if(b&1)ans=(long long)(ans*a)%p;
		a=(long long)(a*a)%p;	
	}
	return ans;
}
long long inv(long long x){return powmod(x,mod-2,mod);}
long long fact[2020]={};
long long invfact[2020]={};
long long comb(long long n,long long m){/*if(n==0&&m==0)*/return ((fact[n]*invfact[m])%mod*invfact[n-m])%mod;}
int main(){
	fact[0]=1,invfact[0]=1,invfact[1]=1;
	for(int i=1;i<=2010;i++)fact[i]=(fact[i-1]*i)%mod;invfact[2010]=inv(fact[2010]);
	for(int i=2009;i>=1;i--)invfact[i]=(invfact[i+1]*(i+1))%mod;
	scanf("%lld",&n);
	if(n<3){printf("0");return 0;}
	else{
		for(int i=1;i*3<=n;i++){
			ans=(long long)(ans+comb(n-2*i-1,i-1))%mod;
		}
		printf("%lld",ans);
	}
	return 0;
}

Measured memory_bytes: 3852
def resolve():
	n = int(input())
	seq = [0] + list(map(int, input().split())) + [0]
	v = 0
	for i in range(n+1):
		v += abs(seq[i] - seq[i+1])
	for i in range(1, n+1):
		a = abs(seq[i] - seq[i-1]) + abs(seq[i] - seq[i+1])
		b = abs(seq[i - 1] - seq[i+1])
		print(v - abs(a - b))
resolve()

Measured memory_bytes: 85876
func gcd(_ a: Int, _ b: Int) -> Int {
    b == 0 ? abs(a) : gcd(b, a%b)
}

struct Fraction: Equatable, Hashable {
    let numerator, denominator: Int
    init (_ numerator: Int, _ denominator: Int) {
        switch (numerator, denominator) {
        case (0, 0):
            self.numerator = 0
            self.denominator = 0
        case (0, _):
            self.numerator = 0
            self.denominator = 1
        case (_, 0):
            self.numerator = 1
            self.denominator = 0
        default:
            let g = gcd(numerator, denominator)
            self.numerator = denominator.signum() * numerator / g
            self.denominator = abs(denominator) / g
        }
    }
    func perpendicular() -> Fraction {
        Fraction(-denominator, numerator)
    }
}

func pow(_ x: Int, _ n: Int, mod: Int) -> Int {
    precondition(n >= 0 && mod > 1)
    if n == 0 { return 1 }

    var u = pow(x, n/2, mod: mod)
    u = u &* u % mod
    if n%2 == 1 { u = u &* x % mod }
    return u
}
///////////////////////////////////////////////////////////////////////////////

let MOD = Int(1e9+7)

let N = Int(readLine()!)!
var cliques: [Fraction: Int] = [:]
var zeroes = 0
for _ in 1...N {
    let line = readLine()!.split(separator: " ").map { Int($0)! }
    let f = Fraction(line[0], line[1])
    if f == Fraction(0, 0) {
        zeroes += 1
    } else {
        cliques[f, default: 0] += 1
    }
}

var ways = 1
while let (k1, v1) = cliques.first {
    cliques.removeValue(forKey: k1)
    let k2 = k1.perpendicular()
    let v2 = cliques.removeValue(forKey: k2)

    ways *= pow(2, v1, mod: MOD) + (v2 != nil ? pow(2, v2!, mod: MOD) - 1 : 0)
    ways %= MOD
}
ways += MOD - 1
ways += zeroes
ways %= MOD
print(ways)


Measured memory_bytes: 26164
from collections import deque

d = deque()
q = int(input())
for i in range(q):
    a, *b = map(int, input().split())
    if a == 0:
        if b[0] == 0:
            d.appendleft(b[1])
        else:
            d.append(b[1])
    elif a == 1:
            print(d[b[0]])
    else:
        if b[0] == 0:
            d.popleft()
        else:
            d.pop()
        


Measured memory_bytes: 21948
n = int(input())
lec = [[0 for i in range(1001)] for j in range(1001)]
max_x = 0
max_y = 0
for i in range(n):
    x,y,s,t = map(int, input().split(" "))
    lec[y][x] += 1
    lec[y][s] -= 1
    lec[t][x] -= 1
    lec[t][s] += 1
    max_x = max(max_x, s)
    max_y = max(max_y, t)

for i in range(max_y+1):
    for j in range(1, max_x+1):
        lec[i][j] += lec[i][j-1]

for i in range(1, max_y+1):
    for j in range(max_x+1):
        lec[i][j] += lec[i-1][j]

ans = 0
for i in range(max_y+1):
    for j in range(max_x+1):
        ans = max(ans, lec[i][j])

print(ans)


Measured memory_bytes: 46144
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,m,l;
	cin>>n>>m>>l;
	if((n==5&&m==5&&l==7)||(n==5&&m==7&&l==5)||(n==7&&m==5&&l==5)){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>

using namespace std;

int h,w;
char s[2009][2009];

void solve(){
    int mx = 0;
    int rcnt[2009][2009], ccnt[2009][2009];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                rcnt[i][j] = 0;
            }
            else if(j==0){
                rcnt[i][j] = 1;
            }
            else{
                rcnt[i][j] = rcnt[i][j-1] + 1;
            }
        }
        for(int j=w-1;j>=0;j--){
            if(s[i][j]=='#'){
                rcnt[i][j]=0;
            }
            else if(j==w-1 || s[i][j+1]=='#'){
                rcnt[i][j] = rcnt[i][j];
            }
            else{
                rcnt[i][j] = rcnt[i][j+1];
            }
        }
    }
    for(int j=0;j<w;j++){
        for(int i=0;i<h;i++){
            if(s[i][j]=='#'){
                ccnt[i][j] = 0;
            }
            else if(i==0){
                ccnt[i][j] = 1;
            }
            else{
                ccnt[i][j] = ccnt[i-1][j] + 1;
            }
        }
        for(int i=h-1;i>=0;i--){
            if(s[i][j]=='#'){
                ccnt[i][j]=0;
            }
            else if(i==h-1 || s[i+1][j]=='#'){
                ccnt[i][j] = ccnt[i][j];
            }
            else{
                ccnt[i][j] = ccnt[i+1][j];
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            mx = max(mx, rcnt[i][j] + ccnt[i][j]-1);
        }
    }

    cout << mx << endl;
}

int main(){
    cin >> h >> w;
    char tmp;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> tmp;
            s[i][j] = tmp;
        }
    }
    solve();
}


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

int main()
{
	int n, k;
	cin >> n >> k;
	int a[n+1];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a, a+n);
	int ans = 0;
	for(int i=0; i<k; i++){
		ans += a[i];
	}
	cout << ans;

    return 0;
}


Measured memory_bytes: 3616
n = int(input())
A = list(map(int, input().split()))

nums = {}
for a in A:
    nums[a] = nums[a] + 1 if a in nums else 1
res = 0
for key in nums.keys():
    res += nums[key]*(nums[key]-1)//2
for a in A:
    print( res-nums[a]+1 )

Measured memory_bytes: 86348
S = ['A', 'C', 'G', 'T'] 
s = input()
ans = 0
for i in range(len(s)):
    if s[i] in S:
        for j in range(len(s)-i):
            if s[i+j] in S:
                ans = len(s[i:i+j+1]) if ans < len(s[i:i+j+1]) else ans
            else:
                break

print(ans)

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

int main() {
  int N, A, S;
  string op;
  cin >> N >> A;
  S = N / 1000;
  N = N - S * 1000;
  if (N >= 500){
  N = N - 500;
  }
  
  if (N <= A){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
  
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    int a, b;

    cin >> a >> b;

    cout << max(0, a - 2*b) << '\n';
 
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
    ll A, B;
    cin >> A >> B;
    B++;
    ll MAXbit = 50;
    ll ans = 0;
    rep(i, MAXbit) {
        ll tmp = 1LL << (i+1);
        ll cntA = A / tmp;
        cntA *= tmp/2;
        cntA += max(A%tmp-tmp/2, 0LL);

        ll cntB = B/tmp;
        cntB *= tmp/2;
        cntB += max(B%tmp-tmp/2, 0LL);

        if ((cntB-cntA) % 2 == 1) {
            ans += (1LL << i);
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
using System;

public class test
{
  static void Main(string[] args)
  {
    string s = Console.ReadLine();
    string[] arry =  s.Split(' ');

    int a = int.Parse(arry[0]);
    int b = int.Parse(arry[1]);
	int n = a * b;

    Console.WriteLine(n);
  }
}

Measured memory_bytes: 27524
#include <bits/stdc++.h>
	#define mx 300005
	using namespace std;

	int a[mx], n;
	vector<vector<bool> > vis(mx, vector<bool> (20, false));
	vector<vector<pair<int,int> > > memo(mx, vector<pair<int, int> > (20, {0, 0}));

	void dp(int num, int pos) {
		if(pos == 0) {
			memo[num][0].first = a[num];
			vis[num][0] = true;
			return;
		}
		if(vis[num][pos]) return;
 		vector<int> cons;
		dp(num, pos-1);
		cons.push_back(memo[num][pos-1].first);
		cons.push_back(memo[num][pos-1].second);
		if(num & (1<<(pos-1))) {
			dp(num ^ (1<<(pos-1)), pos-1);
			cons.push_back(memo[num ^ (1<<(pos-1))][pos-1].first);
			cons.push_back(memo[num ^ (1<<(pos-1))][pos-1].second);
		}
		sort(cons.begin(), cons.end(), greater<int>());
		memo[num][pos].first = cons[0];
		memo[num][pos].second = cons[1];
		vis[num][pos] = true;
	}

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

		cin >> n;
		for(int i = 0; i < (1<<n); ++i) {
			cin >> a[i];
			
		}
		for(int i = (1<<n) - 1; i >= 0; --i) {
			if(!vis[i][n]) {
				dp(i, n);
			}
		}
		int mxv = 0;
		for(int i = 1; i < 1<<n; ++i) {
			mxv = max(memo[i][n].first + memo[i][n].second, mxv);
			cout << mxv << "\n";	
		}
		return 0;
	}

Measured memory_bytes: 83840
sx,sy,tx,ty = map(int,input().split())
xdiff = tx-sx
ydiff = ty-sy
ans  = 'U'*ydiff+'R'*xdiff+'D'*ydiff+'L'*xdiff
ans2 = 'L'*1+'U'*(ydiff+1)+'R'*(xdiff+1)+'D'+'R'+'D'*(ydiff+1)+'L'*(xdiff+1)+'U'
print(ans+ans2)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N,M;
int L[300030],R[300030];
vector<pair<ll,int>> v;

const int DAT_SIZE=(1<<18)-1;

ll data[DAT_SIZE],datb[DAT_SIZE];

void add(int a,int b,int x,int k,int l,int r){
  if(a<=l&&r<=b){
    data[k]+=x;
  }
  else if(l<b&&a<r){
    datb[k]+=(min(b,r)-max(a,l))*x;
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
}

//[a,b),[l,r)
ll sum(int a,int b,int k,int l,int r){
  if(b<=l||r<=a){
    return 0;
  }
  else if(a<=l&&r<=b){
    return data[k]*(r-l)+datb[k];
  }
  else{
    ll res=(min(b,r)-max(a,l))*data[k];
    res+=sum(a,b,k*2+1,l,(l+r)/2);
    res+=sum(a,b,k*2+2,(l+r)/2,r);
    return res;
  }
}


int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++){
      cin>>L[i]>>R[i];
      v.push_back(make_pair(R[i]-L[i],i));
  }
  sort(v.begin(),v.end());

  vector<int> ans;
  ans.push_back(N);
  int now=0;
  for(int i=0;i<v.size();i++){
      if(v[i].first==0){
          int u=v[i].second;
          add(L[u],R[u]+1,1,0,0,M+1);
          now++;
      }else break;
  }
  for(int i=2;i<=M;i++){
      int res=N-now;
      for(int j=i;j<=M;j+=i){
          res+=sum(j,j+1,0,0,M+1);
      }
      for(int j=now;j<v.size();j++){
          if(v[j].first==i-1){
              int u=v[j].second;
              add(L[u],R[u]+1,1,0,0,M+1);
              now++;
          }else break;
      }
      ans.push_back(res);
  }

  for(int i=0;i<M;i++){
      cout<<ans[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 13544
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P =pair<int ,int>;
int main(){
  int n;
  string s;
  std::cin >> n>>s;


  std::vector<int> ecnt(n);
  std::vector<int> wcnt(n);

  int now=0;
  for(int i=0; i<n ;i++){
    ecnt[i]=now;
    if(s[i]=='W')now++;
  }

  now=0;
  for(int i=n-1; i>=0 ;i--){
    wcnt[i]=now;
    if(s[i]=='E')now++;
  }

  int mi=1001001001;
  for(int i=0; i<n ;i++){
    mi=min(mi,ecnt[i]+wcnt[i]);
  }


  std::cout << mi<< '\n';


  return 0;
}


Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int nax=100005;
int dp[nax];

#undef int
int main() {
#define int long long
    int n,k;
    cin >> n >> k;
    int a[n];

    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }

    for(int i=0;i<=k;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i>=a[j] && dp[i-a[j]]==false)
                dp[i]=true;
        }
    }
    if(dp[k])
       cout << "First" << endl;
    else
       cout << "Second" << endl;
}

Measured memory_bytes: 1024
input = raw_input

n = int(input())

def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: # choufuku
                divisors.append(n//i)
    # divisors.sort()
    return divisors


def f(n, k):
    tmp = [n]
    while True:
        q = n % k
        if q == 0:
            n /= k
            tmp.append(n)
        elif q == 1:
            tmp.append(q)
            #print(tmp)
            return True
        else:
            return False

#out = 0
#for k in range(2, n): 
#    flag = f(n, k)
#    if flag:
#        print("ans", n, k)
#        out += 1
#out += 1 # k = n

elms = fctr1(n-1) 
out1 = 1
for a, b in elms:
    out1 *= (b+1)
out1 -= 1

yaku2 = make_divisors(n)
out2 = 0
yaku2.remove(n)
yaku2.remove(1)
for ya1 in yaku2:
    ya2 = n // ya1
    while ya1 % ya2 == 0:
        ya1 //= ya2
    if ya1 % ya2 == 1:
        out2 += 1
out2 += 1 # n

#print(out1, out2)
out = out1 + out2

print(out)

Measured memory_bytes: 30316
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

const int N = 200 + 10;
char s[N][N];
int d[N];

int solve(int u, int n) {
  vector<int> Q;
  fill(d, d + n, -1);
  d[u] = 0;
  Q.push_back(u);
  for (int i = 0; i < Q.size(); ++i) {
    int u = Q[i];
    for (int v = 0; v < n; ++v) {
      if (s[u][v] == '0') continue;
      if (d[v] < 0) {
        d[v] = d[u] + 1;
        Q.push_back(v);
      } else if (abs(d[u] - d[v]) != 1) {
        return -1;
      }
    }
  }
  return d[Q[n - 1]] + 1;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  int best = -1;
  for (int i = 0; i < n; ++i) {
    int cur = solve(i, n);
    best = max(best, cur);
  }
  printf("%d\n", best);
  return 0;
}


Measured memory_bytes: 384
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();
    int n = 0;
    
    for (int i = a; i <= b; i++) {
      if (i / 10000 == i % 10 && i % 10000 / 1000 == i % 100 / 10 ) n++;
    }
    
    System.out.println(n);
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int num,minnum = 100000000;
  string s,sa;
  cin >> s;
  for(int i=0; i<s.length()-2; i++){
    sa[0] = s[i];
    sa[1] = s[i+1];
    sa[2] = s[i+2];
    num = atoi(sa.c_str());
    num -= 753;
    num = abs(num);
    minnum = min(minnum,num);
  }
  cout << minnum << endl;
  return 0;
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<int>& a) { for (int x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

i32 M = 998244353;
i32 dp[310][90310];
i32 dq[310][90310];

signed main() {
  i32 n;
  cin >> n;
  vector<i32> A(n);
  i32 sum = 0;
  REP(i, n) {
    cin >> A[i];
    sum += A[i];
  }
  i32 lim = (sum - 1) / 2;
  dp[0][0] = 1;
  dq[0][0] = 1;
  REP(i, n) {
    REP(t, 90000) {
      (dp[i + 1][t] += dp[i][t] * 2) %= M;
      (dp[i + 1][t + A[i]] += dp[i][t]) %= M;
      (dq[i + 1][t] += dq[i][t]) %= M;
      (dq[i + 1][t + A[i]] += dq[i][t]) %= M;
    }
  }
  i32 ans = 1;
  REP(i, n) {
    ans = (ans * 3) % M;
  }
  FOR(t, lim + 1, 90000) {
    ans = (ans - dp[n][t] * 3) % M;
  }
  if (sum % 2 == 0) {
    ans = (ans + dq[n][sum / 2] * 3) % M;
  }
  ans = (ans + M) % M;
  cout << ans << endl;
}

Measured memory_bytes: 427648
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long int

int main()
{
	int n,x,i,sol=0;
	scanf("%i",&n);
	while(n--)
	{
		scanf("%i",&x);
		while(!(x&1))
		{
			sol++;
			x/=2;
		}
	}
	printf("%i\n",sol);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

template <typename T>
vector<pair<int, T>> RLE(vector<T> v){
	int n = v.size();
	vector<pair<int, T>> res;
	T pre = v[0];
	int cnt = 1;
	for(int i = 1; i < n; i++){
		if(v[i] != pre){
			res.emplace_back(cnt, pre);
			pre = v[i];
			cnt = 0;
		}
		cnt++;
	}
	res.emplace_back(cnt, pre);
	return res;
}

signed main(){
	int n,k;
	cin >> n >> k;
	string s;
	cin >> s;
	vector<char> c(n);
	rep(i,n){
		c[i] = s[i];
	}
	vector<pair<int, char>> v = RLE(c);
	int m = v.size();
	v.emplace_back(0, '1');
	int ans = 0, now = 0, cnt = 0;
	int right = 0;
	for(int left = 0; left < m; left++){
		while(cnt <= k && right <= m){
			ans = max(ans, now);
			now += v[right].first;
			if(v[right].second == '0') cnt++;
			right++;
		}
		now -= v[left].first;
		if(v[left].second == '0') cnt--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1656
#include<stdio.h>
int main(){
  int a,b,c,i;
  char s[15];
  scanf("%d%d%s",&a,&b,s);
  for(i=0;i<a+b+1;i++){
    if(i==a){
      if(s[i]!='-'){
        puts("No");
        return 0;
      }
    }
    else {
      if('0'>s[i] || s[i]>'9'){
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 128
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars
    };
    let n = s.len();
    let mut t = vec![];
    let mut i = 0;
    while i < n {
        if s[i] == 'B' && i + 1 < n && s[i + 1] == 'C' {
            t.push('D');
            i += 2;
        } else {
            t.push(s[i]);
            i += 1;
        };
    }
    let mut c = 0_i64;
    let mut c_a = 0_i64;
    for &t_i in t.iter() {
        match t_i {
            'A' => c_a += 1,
            'D' => c += c_a,
            _ => c_a = 0,
        }
    }
    println!("{}", c);
}


Measured memory_bytes: 3924
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    vector<char> buf[2];
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int i, j, k;
    string s;
    cin >> s;

    int cnt(0);
    int n;
    cin >> n;
    while(n--) {
        int t, f;
        char c;
        cin >> t;
        if (t == 1) {
            cnt ^= 1;
            continue;
        }
        cin >> f >> c;
        if (f == 1) {
            buf[cnt].push_back(c);
        } else {
            buf[cnt^1].push_back(c);
        }
    }
    for (int i = buf[cnt].size() - 1; i >= 0; i--) {
        cout << buf[cnt][i];
    }
    if (cnt) {
        reverse(s.begin(), s.end());
    }
    cout << s;
    cnt ^= 1;
    rep(i, buf[cnt].size()) {
        cout << buf[cnt][i];
    }
    cout << endl;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string S;
	cin >> S;
	int len = S.size();
	vector<int> N(S.size());
	for (int i = 0; i < len; i++)
	{
		N[i] = S[i] - '0';
	}

	vector<vector<vector<int>>> DP(len + 1, vector<vector<int>>(2, vector<int>((1 << 3), 0)));

	if (N[0] == 7)
	{
		DP[0][0][(1 << 2)] = 1;
	}
	if (N[0] == 5)
	{
		DP[0][0][(1 << 1)] = 1;
	}
	if (N[0] == 3)
	{
		DP[0][0][(1 << 0)] = 1;
	}

	if (7 < N[0])
	{
		DP[0][1][(1 << 2)] = 1;
	}
	if (5 < N[0])
	{
		DP[0][1][(1 << 1)] = 1;
	}
	if (3 < N[0])
	{
		DP[0][1][(1 << 0)] = 1;
	}

	
	for (int i = 0; i + 1 < len; i++)
	{
		DP[i][1][0] = 1;
		for (int j = 0; j < 8; j++)
		{
			if (N[i + 1] == 7)
			{
				DP[i + 1][0][(1 << 2) | j] += DP[i][0][j];
			}
			if (N[i + 1] == 5)
			{
				DP[i + 1][0][(1 << 1) | j] += DP[i][0][j];
			}
			if (N[i + 1] == 3)
			{
				DP[i + 1][0][(1 << 0) | j] += DP[i][0][j];
			}

			if (7 < N[i + 1])
			{
				DP[i + 1][1][(1 << 2) | j] += DP[i][0][j];
			}
			if (5 < N[i + 1])
			{
				DP[i + 1][1][(1 << 1) | j] += DP[i][0][j];
			}
			if (3 < N[i + 1])
			{
				DP[i + 1][1][(1 << 0) | j] += DP[i][0][j];
			}

			DP[i + 1][1][(1 << 2) | j] += DP[i][1][j];
			DP[i + 1][1][(1 << 1) | j] += DP[i][1][j];
			DP[i + 1][1][(1 << 0) | j] += DP[i][1][j];
		}
	}

	cout << DP[len - 1][0][7] + DP[len - 1][1][7] << endl;

	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

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

void input(){
   string s, t; cin >> s >> t;
   int cnt = 0;
   f(i, 3)if(s[i] == t[i])++cnt;
   cout << cnt <<endl;
}
int main()
{
 input();
 return 0;
}


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

typedef long long lint; typedef pair<int, int> ii;
const int MOD = 1'000'000'007, MOD2 = 1'000'000'009;
const int INF = 0x3f3f3f3f; const lint BINF = 0x3f3f3f3f3f3f3f3fLL;

lint q, h, s, d, n;

int solve(){
	cin >> q >> h >> s >> d >> n;
	n = n * 4;
	lint one = q;
	lint two = min(one + one, h);
	lint four = min(two + two, s);
	lint eight = min(four + four, d);

	lint ans = 0;
	ans += n / 8 * eight; n %= 8;
	ans += n / 4 * four; n %= 4;
	ans += n / 2 * two; n %= 2;
	ans += n * one;
	cout << ans << endl;
    return 0;
}

int main(){
	ios::sync_with_stdio(0);
	// int t; cin >> t; while(t--)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

bool isPrime(int x) {
  int i = 2;
  for (i = 2; i * i <= x; i++)
    if (x % i == 0) return false; 
  return true;
}

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

  int x; std::cin >> x;
  while(!isPrime(x))
    x++;
  std::cout << x << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int N,d[100010];
    cin>>N;
    for(int i=0;i<N;++i)cin>>d[i];
    sort(d,d+N);
    cout<<d[N/2]-d[N/2-1]<<endl;
    return 0;
}

Measured memory_bytes: 640