akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

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

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M >> K;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	vector< int > B(M);
	rep(i, M) cin >> B[i];
	int j = M - 1;
	int tmp = 0;
	rep(j, M) tmp += B[j];
	int ans = 0;
	rep(i, N + 1) {
		while (tmp > K && j >= 0) {
			tmp -= B[j];
			j--;
		}
		if (tmp > K)
			break;
		chmax(ans, i + j + 1);
		if (i < N)
			tmp += A[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <stack>
#include <string>

int main()
{
  std::stack<char> strStack;
  std::string str;
  
  std::cin >> str;
  
  std::string::iterator itr = str.begin();
  while (itr != str.end()) {
    if (*itr == 'S') {
      strStack.push(*itr);
    } else if (*itr == 'T') {
      if (strStack.empty()) {
        strStack.push(*itr);
      } else {
        if (strStack.top() == 'S') {
          strStack.pop();
        } else {
          strStack.push(*itr);
        }
      }
    }

    itr++;
  }
  
  //出力
  std::cout << strStack.size() << std::endl;
  
  return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 1; i <= m; ++i)
    {
        int x;
        cin >> x;
        sum += x;
    }

    if (n >= sum)
        cout << n - sum;
    else
        cout << -1;

}


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

using namespace std;

#define int long long
#define fi first
#define se second
#define inf 1e9
const int mod=(int)1e9+7;

void test_case(){
	int k,n;
	cin>>k>>n;
	vector<int> arr(n),t;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int ans=inf;
	for(int i=0;i<n;i++){
		int mx=(i+n-1>=n?arr[(i+n-1)%n]+k:arr[(i+n-1)%n]);
		ans=min(ans,mx-arr[i]);
	}
	cout<<ans;
	
}

signed main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)test_case();
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
    int a,b;
    int count =0;
    cin >> a >> b;
    for(int i = a;i<=b;i++){
        int cp = i;
        int ue = 0;
        ue += cp/10000;
        cp %= 10000;
        ue += (cp/1000)*10;
        cp %= 1000;
        cp %= 100;
        if(cp == ue){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>

using namespace std;

void Solution()
{
    int a, b, c;
    
    int n = 0;
    
    cin>>a>>b>>c;
    
    for (int i = a; i <= b; i++)
    {
        if (c % i == 0)
        {
            n++;
        }
    }
    
    cout<<n<<endl;
    
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, K;
  cin>>N>>K;
  vector<ll> A(N), F(N);
  for(int i=0;i<N;++i) cin>>A[i];
  for(int i=0;i<N;++i) cin>>F[i];
  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), greater<ll>());
  ll l=0, r=big, m;
  ll tmp;
  while(l<r) {
    m = (l+r)/2;
    tmp = 0;
    for(int i=0;i<N;++i) {
      if(A[i]*F[i]<=m) continue;
      tmp += A[i]-m/F[i];
    }
    if(tmp>K) l = m+1;
    else r = m;
  }
  cout<<l<<endl;
}


Measured memory_bytes: 6400
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int maxa = 0, mina = inf;
  int a;
  for(int i=0;i<N;++i) {
    cin>>a;
    maxa = max(maxa, a);
    mina = min(mina, a);
  }
  cout<<maxa-mina<<endl;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//~ using namespace __gnu_pbds; 
#define mp make_pair
#define endl '\n'
typedef long long ll;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=2e5+5;
const int mod=1e9+7;	
const ll oo=1e18+5;

//~ typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

class IT{
	struct node{
		int left,right;
		ll val,lazy;
	};
	vector<node> a;
	void push_down(int id){
		ll plus=a[id].lazy;
		a[id].lazy=0;
		a[id<<1].val+=plus;
		a[id<<1].lazy+=plus;
		a[id<<1|1].val+=plus;
		a[id<<1|1].lazy+=plus;
	}
	void push_up(int id){
		a[id].val=max(a[id<<1].val,a[id<<1|1].val);
	}
	void build(int l,int r,int id){
		a[id].left=l,a[id].right=r;
		if(l==r) return;
		int mid=(l+r)>>1;
		build(l,mid,id<<1);
		build(mid+1,r,id<<1|1);
	}
	public:
	IT(int n):a(n<<2){
		build(0,n,1);
	}
	void add(int l,int r,ll val,int id=1){
		if(a[id].left>=l&&a[id].right<=r){
			a[id].val+=val;
			a[id].lazy+=val;
			return;
		}
		push_down(id);
		int mid=(a[id].left+a[id].right)>>1;
		if(l<=mid) add(l,r,val,id<<1);
		if(r>mid) add(l,r,val,id<<1|1);
		push_up(id);
	}
	ll get_max(int l,int r,int id=1){
		if(l<=a[id].left&&a[id].right<=r) return a[id].val;
		push_down(id);
		ll maxx=-9e18;
		int mid=(a[id].left+a[id].right)>>1;
		if(l<=mid) maxx=max(maxx,get_max(l,r,id<<1));
		if(r>mid) maxx=max(maxx,get_max(l,r,id<<1|1));
		push_up(id);
		return maxx;
	}
};

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	int n,m;
	cin>>n>>m;
	vector<ll> beg(n+1);
	vector<vector<pair<int,ll>>> fin(n+1);
	for(int i=0;i<m;++i){
		int l,r;
		ll val;
		cin>>l>>r>>val;
		beg[l]+=val;
		fin[r].emplace_back(l,val);
	}
	IT tree(n+1);
	ll ans=0;
	for(int i=1;i<=n;++i){
		// put 1 here 
		// add all vals start from i
		tree.add(0,i-1,beg[i]);
		ll cur_max=tree.get_max(0,i-1); 
		ans=max(ans,cur_max);
		tree.add(i,i,cur_max); // add cur in here 
		for(pair<int,ll> x:fin[i]){
			tree.add(0,x.first-1,-x.second);
		}
	}
	cout<<ans;
	return 0;	
}


Measured memory_bytes: 31488
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
    s:chars
    );
    let ans = if s[2] == s[3] && s[4] == s[5] {"Yes"} else { "No" };
    println!("{}", ans);
}



Measured memory_bytes: 4352
/*
** 斐波那契数列 使用动态规划来避免重复的计算
*/

# include <cstdio>
# include <cstring>

const int MAX = 44 + 5;

int n, dp[MAX];

// 记忆化递归 
/*
int fib(int i) {
    if (dp[i] != 0) {
        return dp[i];
    }
    if (i <= 1) {
        return 1;
    }
    dp[i] = fib(i - 1) + fib(i - 2);
    return dp[i];
}
*/

// 动态规划

int fib(int t) {
    dp[0] = dp[1] = 1;
    for (int i = 2; i <= t; i++) {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    return dp[t];
}

void solve() {
    scanf("%d", &n);
    memset(dp, 0, sizeof(dp));
    printf("%d\n", fib(n));
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 2760
//It is coded by ning-mew on 9.28
#include<bits/stdc++.h>
using namespace std;

const int maxn=2000+7;

int n,K,ans=maxn;
int head[maxn],cnt=0,depth[maxn];
int siz[maxn],root=0,root2=0,maxx[maxn];
struct Edge{int nxt,to,from;}edge[maxn*2];

void add(int from,int to){
	edge[++cnt].nxt=head[from];edge[cnt].to=to;edge[cnt].from=from;head[from]=cnt;	
}
void dfs2(int u,int fa){
	depth[u]=depth[fa]+1;
	for(int i=head[u];i!=0;i=edge[i].nxt){
		int v=edge[i].to;if(v==fa)continue;
		dfs2(v,u);
	}return;
}
void dfs3(int u,int fa){
	depth[u]=depth[fa]+1;
	for(int i=head[u];i!=0;i=edge[i].nxt){
		int v=edge[i].to;
		if(depth[v]>depth[u]+1){
			dfs3(v,u);
		}
	}
}
int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<n;i++){
		int x,y;scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
	if(K%2==0){
		for(int i=1;i<=n;i++){
			memset(depth,0,sizeof(depth));
			dfs2(i,i);
			int box=0;
			for(int i=1;i<=n;i++)if(depth[i]>1+K/2)box++;
			ans=min(ans,box);
		}
		printf("%d\n",ans);
		return 0;
	}else{
		K--;
		for(int i=1;i<=cnt;i+=2){
			memset(depth,0,sizeof(depth));
			dfs2(edge[i].from,edge[i].from);
			depth[edge[i].to]=0;
			dfs3(edge[i].to,edge[i].to);
			int box=0;
			for(int i=1;i<=n;i++)if(depth[i]>1+K/2)box++;
			ans=min(ans,box);
		}
		printf("%d\n",ans);
	}
	return 0;
}
/*
11 3
1 2
1 3
2 4
2 5
3 6
3 7
6 8
6 9
7 10 
7 11
*/

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

int main() {
    int A[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    int b[N];
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }

    bool ok = false;
    vector<vector<bool>> vec(3, vector<bool> (3, false));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < N; k++) {
                if (A[i][j] == b[k]) vec[i][j] = true;
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        if (vec[i][0] && vec[i][1] && vec[i][2]) ok = true;
        if (vec[0][i] && vec[1][i] && vec[2][i]) ok = true;
    }

    if (vec[0][0] && vec[1][1] && vec[2][2]) ok = true;
    if (vec[0][2] && vec[1][1] && vec[2][0]) ok = true;


    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define H 500001
int n;
int largest = 0;
int A[H];
int left(i)
{
  return 2 * i;
}
int right(i)
{
  return 2 * i + 1;
}
void maxHeapify(int i)
{
  int l, r;
  int tmp;
  l = left(i);
  r = right(i);
  if(l <= n && A[l] > A[i])
    {
      largest = l;
    }
  else
    {
      largest = i;
    }
  if(r <= n && A[r] > A[largest])
    {
      largest = r;
    }
  if(largest != i)
    {
      tmp = A[i];
      A[i] = A[largest];
      A[largest] = tmp;
      maxHeapify(largest);
    }
}

 void buildMaxHeap(void)
{
  int i;
  for(i  = n / 2; i >= 1; i--)
    {
      maxHeapify(i);
    }
}


int main()
{
  int i;
  scanf("%d", &n);
  for(i = 1; i <= n; i++)
    {
      scanf("%d", &A[i]);
    }
  buildMaxHeap();
  for(i = 1; i <= n; i++)
    {
      printf(" %d", A[i]);
    }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 2019;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

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

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *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 { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};

int main()
{
  string s;
  cin >> s;

  ll arr[200100];
  ll count[3000];

  ll keta = 1;
  reverse(s.begin(), s.end());
  rep(i, s.size())
  {
    ll val = (keta * (s[i] - '0')) % 2019;
    if (i == 0)
      arr[i] = val % 2019;
    else
      arr[i] = (arr[i - 1] + val) % 2019;
    count[arr[i]]++;
    keta *= 10;
    keta %= 2019;
  }

  ll ans = 0;
  count[0]++;
  rep(i, 2019)
  {
    ans += (count[i] * (count[i] - 1)) / 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5332
n = int(input())
s = list(input())
if n%2 == 0:
    n_2 = n//2
    flag = 0
    for i in range(n_2):
        if s[i] != s[i + n_2]:
            flag = 1
    if flag:
        print("No")
    else:
        print("Yes")
else:
    print("No")

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

using namespace std;

typedef long long ll;
ll n,m;
const int maxn = 2e5 ;
ll a[maxn],b[maxn],c[maxn];
bool cmp(ll a,ll b) {
    return a > b;
}
ll make(string str) {
    ll x[2000],y[2000],z[2000],s[2000];
    for(int i = 1; i <= n; i++) x[i] = a[i],y[i] = b[i],z[i] = c[i];
    for(int j = 1; j <= 3; j++) {
        if(j == 1 && str[j] == '1')
            for(int i = 1; i <= n; i++)
                x[i] =- x[i];
        else if(j == 2 && str[j] == '1') {
            for(int i = 1; i <= n; i++)
                y[i] =- y[i];
        } else if(j == 3 && str[j] == '1') {
            for(int i = 1; i <= n; i++)
                z[i] =- z[i];
        }
    }
    for(int i = 1; i <= n; i++) s[i] = x[i] + y[i] + z[i];
    sort(s + 1,s + 1 + n,cmp);
    ll sum1 = 0,sum2 = 0,sum3 = 0;
    int num = m;
    for(int i = 1; num; i++,num--)
        sum1 += s[i];
    return sum1;
}
int main() {
    string str[20];
    for(int i = 1; i <= 19; i++) str[i] = "";
    for(int i = 1; i <= 8; i++) {
        for(int j = 3; j >= 0; j--)
            if((1 << j) & i) str[i] += "1";
            else str[i] += "0";
    }
    while(cin >> n >> m) {
        for(int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
        ll ans = 0;
        for(int i = 1; i <= 8; i++)
            ans = max(make(str[i]),ans);
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
    int a, b, c;
        cin >> a >> b >> c;
            int n = 0; 
            for(int i = a; i <= b; i++ ){ 
                if(c%i == 0){
                    n++;
            } 
        }
        cout << n << endl;
}

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

using namespace std;

int main(void)
{
    string s;
    int n;
    cin >> n;

    cin >> s;

    if(n % 2)
    {
        cout << "No" << endl;
        return 0;
    }

    if(s.substr(0, n / 2) == s.substr(n / 2, n / 2))
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


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

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;


int main(){
    int N;
    cin >> N;
    if(N<1000){
        cout << "ABC";
    }else{
        cout << "ABD";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>

using namespace std;

int main(){
  int n,m;
  for(;cin>>n>>m,n;)
    {
      bool virus[n];
      vector<pair<int, pair<int,int> > > data;

      memset(virus,false,sizeof(virus));
      virus[0]=true;
      for(int i=0;i<m;i++)
	{
	  int t,s,d;
	  cin>>t>>s>>d;
	  s--;
	  d--;
	  data.push_back(make_pair(t,make_pair(s,d)));
	}
      sort(data.begin(),data.end());
      for(int i=0;i<m;i++)
	{
	  if(virus[data[i].second.first])
	    virus[data[i].second.second]=true;
	}
      int ans=0;
      for(int i=0;i<n;i++)
	{
	  if(virus[i])
	    ans++;
	}
      cout<<ans<<endl;
    }

}

Measured memory_bytes: 1700
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		StringBuilder center = new StringBuilder();
		StringBuilder atama = new StringBuilder();
		StringBuilder ketsu = new StringBuilder();

		center.append(scanner.nextLine());
		int n  = Integer.parseInt(scanner.nextLine());
		int t  = 0;
		int m  = 0;
		int f  = 0;


		for(int i = 0; i < n; i++) {

			m  = scanner.nextInt();
			t += m;

			if(m == 2){

				f  		= scanner.nextInt();
				char c  = scanner.next().toCharArray()[0];

				if(f == 1 && t % 2 == 0) {

					 atama.append(c);

				}else if(f == 2 && t % 2 == 1) {

					 atama.append(c);

				}else {
					 ketsu.append(c);
				}
			}
		}

		if(t % 2 == 0) {

			System.out.println(atama.reverse().toString()+ center.toString() + ketsu.toString());

		}else {
			System.out.println(ketsu.reverse().toString()+ center.reverse().toString() + atama.toString());
		}
	}
}

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

int counter;

int main()
{
    double n, d, x, y;
    scanf("%lf%lf", &n, &d);

    for(int i = 0; i < n; i++)
    {
        scanf("%lf%lf", &x, &y);
        if(sqrt(x*x+y*y) <= d)
            counter++;
    }

    printf("%d", counter);


    return 0;
}


Measured memory_bytes: 3836
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i, h) cin >> s[i];

	vector<vi> c(h, vi(w+1));
	rep(i, h) rep(j, w) c[i][j+1] += c[i][j] + (s[i][j] - '0');

	int ans = INF;
	for(int i = 0; i < (1 << (h-1)); i++) {
//		if(i == 0) continue;
		int l = 0;
		bool fail = false;
		int tmp = 0;
		for(int j = 0; j < h; j++) {
			if(i & (1 << j)) tmp++;
		}
		for(int r = 1; r <= w; r++) {
			vi v;
			int ls = 0;
			for(int j = 0; j < h; j++) {
				ls += c[j][r] - c[j][l];
				if(i & (1 << j)) {
					v.push_back(ls);
					ls = 0;
				}
				if(j == h-1) v.push_back(ls);
			}
//			show(v, 2);
			for(auto j: v) {
				if(j > k && r - l == 1) {
//					cout << "fail:" << j << ' ' << l << ' ' << r << endl;
					fail = true;
					break;
				}
				else if(j > k && r - l > 1) {
					l = r - 1;
					tmp++;
					break;
				}
			}
			if(fail) {
				tmp = INF;
				break;
			}
		}
		chmin(ans, tmp);
	}
/*
	for(int i = 0; i < (1 << (h-1)); i++) {
		int r = w;
		bool fail = false;
		int tmp = 0;
		for(int j = 0; j < h; j++) {
			if(i & (1 << j)) tmp++;
		}
		for(int l = w-1; l >= 0; l--) {
			vi v;
			int ls = 0;
			for(int j = 0; j < h; j++) {
				ls += c[j][r] - c[j][l];
				if(i & (1 << j)) {
					v.push_back(ls);
					ls = 0;
				}
				if(j == h-1) v.push_back(ls);
			}
			for(auto j: v) {
				if(j > k && r - l == 1) {
					fail = true;
				}
				else if(j > k && r - l > 1) {
					r = l + 1;
					tmp++;
				}
			}
			if(fail) {
				tmp = INF;
				break;
			}
		}
		chmin(ans, tmp);
	}*/

	cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        A: [i64; N],
    }

    let mut cnt: HashMap<i64, i64> = HashMap::new();
    let mut ans: i64 = 0;

    for (i, &a) in A.iter().enumerate() {
        ans += *cnt.entry((i as i64) - a).or_default();
        *cnt.entry((i as i64) + a).or_insert(0) += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 18372
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long LL;

LL solve2(LL a, LL b, LL n) {
	LL ans = -1LL << 60;
	for (LL x = 0; x <= n; ++x) {
		LL p = (a * x) / b;		// 100*221 / 222
		LL q = a * (x / b);
		ans = max(ans, p - q);
	}
	return ans;
}

LL solve(LL a, LL b, LL n) {
	if (n >= b - 1) {
		LL x = b - 1;
		LL p = (a * x) / b;		// 100*221 / 222
		LL q = a * (x / b);
		return p - q;
	}
	LL x = n;
	LL p = (a * x) / b;		// 100*221 / 222
	LL q = a * (x / b);
	return p - q;
}

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL a = -1, b, n;
		cin >> a >> b >> n;
		if (a < 0) return 0;
		LL ans = solve(a, b, n);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
A = input() + ' '
B = input() + ' '
C = input() + ' '
s = A[0]
while(len(A) != 0 and s != ' ' ) and  (len(B) != 0 and s != ' ') and (len(B) != 0 and s != ' '):
  if s == 'a':
    s = A[0]
    A = A[1:]
  elif s == 'b':
    s = B[0]
    B = B[1:]
  else:
    s = C[0]
    C = C[1:]
  if s == ' ':
    break;
  else:
    p = s
print(p.upper())

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


int main(){
  int X1,X2,Y1,Y2;

  cin >>X1>>Y1>>X2>>Y2;
  int desx = X2-X1, desy = Y2-Y1;

  cout << X2 - desy<<' '<<Y2 + desx<<' '<<X2 - desy-desx<<' '<<Y2 + desx -desy<<endl;

  return 0;
}


Measured memory_bytes: 256
N, X = gets.split.map(&:to_i)

Len = [1]
Pat = [1]

(1..N).each do |i|
    Len[i] = Len[i-1] * 2 + 3
    Pat[i] = Pat[i-1] * 2 + 1
end

def rec(n, x)
    return 1 if n == 0
    ans = 0
    x -= 1
    if x > 0
        if x >= Len[n-1]
            ans += Pat[n-1]
            x -= Len[n-1]
        else
            ans += rec(n-1, x)
            return ans
        end
    end
    if x > 0
        ans += 1
        x -= 1
    end
    if x > 0
        if x >= Len[n-1]
            ans += Pat[n-1]
            x -= Len[n-1]
        else
            ans += rec(n-1, x)
            return ans
        end
    end
    ans
end

puts rec(N, X)

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

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

    int A, B;
    int abA, abB;

    cin >> A >> B;

    if (A%2==0 && B%2==1)
    {
        cout << "IMPOSSIBLE";
    }
    else if (A%2==1 && B%2==0)
    {
        cout << "IMPOSSIBLE";
    }
    else
    {
        int X = max(A, B);
        rep(i, X)
        {
            abA = abs(A-i);
            abB = abs(B-i);
            if (abA==abB)
            {
                cout << i;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
tmp = input()
N = int(tmp.split()[0])
M = int(tmp.split()[1])
AB = []
for i in range(N):
	tmp = input()
	AB.append([int(tmp.split()[0]),int(tmp.split()[1])])

AB.sort()

cnt=0
total=0
i = 0
while cnt < M:
	cnt += AB[i][1]
	total += AB[i][0]*AB[i][1]
	i+=1
total -=  AB[i-1][0]*(cnt-M)
print(total)

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

int n, k;
int a;
int res;

int main()
{
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        res += a >= k;
    }
    printf("%d\n", res);
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  int kisu=0;
  int a;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a%2) kisu++;
  }
  if(kisu%2) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
const int MOD=1e9+7;
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

using namespace std;

int n,t[100005],x[100005],y[100005];
class CTraveling {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n;
		t[0]=x[0]=y[0]=0;
		f(i,1,n+1)
		{
			in >> t[i] >> x[i] >> y[i];
			int diff=(t[i]-t[i-1])-(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]));
			if(diff<0||diff&1)
			{
				out << "No\n";
				return;
			}
		}
		out << "Yes\n";

	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	CTraveling solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2560
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define forn(i,a,b) for (int i = a; i <= b; i ++ )
#define mod(n,k) (((n%k)+k)%k)
using namespace std;
typedef long long ll;

ll N, M, sum;

int main()
{
    optimiza_io
    cin >> N >> M;
    while( M -- ) {
        ll x;
        cin >> x;
        sum += x;
    }
    cout << max( -1LL , N - sum ) << "\n";
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            //整数A Bの入力
            int A, B, max;

            var word = Console.ReadLine().Split(' ');

            A = int.Parse(word[0]);
            B = int.Parse(word[1]); 

            //最大値maxを求める
            max = A + B;

            if (max < A - B)
				max = A - B;
            if (max < A * B)
				max = A * B;
            

			
                           

            //最大値を出力(表示)
            Console.WriteLine(max);
            //入力
            Console.ReadKey();




        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	int ans;
	for (ll i = 1; i*i <= N; ++i){
		ans=i*i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
vector<T> compress(vector<T> v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}

template<typename T>
map<T, Int> dict(const vector<T> &v){
  map<T, Int> res;
  for(Int i=0;i<(Int)v.size();i++)
    res[v[i]]=i;
  return res;
}


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


//INSERT ABOVE HERE
signed main(){
  Int n;
  while(cin>>n,n){
    vector<Int> xs(n),ys(n);
    for(Int i=0;i<n;i++) cin>>xs[i]>>ys[i];

    vector<Int> as(4),bs(4);
    for(Int i=0;i<4;i++) cin>>as[i]>>bs[i];
    
    vector<Int> vx(xs),vy(ys);
    for(Int i=0;i<4;i++){
      vx.emplace_back(as[i]);
      vy.emplace_back(bs[i]);
    }
    vx.emplace_back(-20001);
    vy.emplace_back(-20001);
    vx.emplace_back(+20001);
    vy.emplace_back(+20001);

    vx=compress(vx);
    vy=compress(vy);
    auto dx=dict(vx);
    auto dy=dict(vy);

    Int h=vy.size(),w=vx.size();
    auto dp=make_v<Int>(h,w);
    fill_v<Int>(dp,0);

    for(Int i=0;i<n;i++){
      if(~i&1) dp[dy[ys[i]]][dx[xs[i]]]++;
      else dp[dy[ys[i]]][dx[xs[i]]]--;
    }
    
    for(Int i=0;i<h;i++)
      for(Int j=1;j<w;j++)
        dp[i][j]+=dp[i][j-1];

    for(Int i=1;i<h;i++)
      for(Int j=0;j<w;j++)
        dp[i][j]+=dp[i-1][j];

    Int a1=*min_element(as.begin(),as.end());
    Int a2=*max_element(as.begin(),as.end());
    Int b1=*min_element(bs.begin(),bs.end());
    Int b2=*max_element(bs.begin(),bs.end());
    
    Int ans=0;
    for(Int i=0;i+1<h;i++){
      for(Int j=0;j+1<w;j++){
        if(b1<=vy[i]&&vy[i]<b2&&a1<=vx[j]&&vx[j]<a2) continue;
        ans+=abs(dp[i][j])*(vy[i+1]-vy[i])*(vx[j+1]-vx[j]);
      }
    }
    cout<<ans<<endl;
  }  
  return 0;
}



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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

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

    int W[N], csum[N+1];
    csum[0] = 0;
    REP(i, N) {
        cin >> W[i];
        csum[i+1] = csum[i] + W[i];
    }

    int ans = 1000000;
    REP2(i, 1, N-1) {
        int sum1 = csum[i] - csum[0];
        int sum2 = csum[N] - csum[i];
        ans = min(ans, abs(sum1-sum2));
    }

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


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    long M = scanner.nextInt();
    long V = scanner.nextInt();
    int P = scanner.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) A[i] = scanner.nextInt();
    Arrays.sort(A);
    reverse(A);
    long[] cum = new long[N];
    for (int i = 1; i < N; i++) cum[i] = cum[i - 1] + A[i - 1];

    int count = P;
    for (int i = P; i < N && A[i] + M >= A[P - 1]; i++)
      if (M * (P - 1 + N - i) + (i - P + 1) * (A[i] + M) - (cum[i] - cum[P - 1]) >= M * V) count++;
    System.out.println(count);
  }

  private static void reverse(int[] a) {
    int i = 0;
    int j = a.length - 1;
    while (i < j) {
      int tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
      i++;
      j--;
    }
  }
}


Measured memory_bytes: 51272
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>
 
using namespace std;
 
void solve();
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
 
void solve() {
    int n;
    cin >> n;
    int t[n],x[n],y[n];
    for(int i = 0; i < n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    int now = 0;
    int nx = 0;
    int ny = 0;
    for(int i = 0; i < n; i++) {
        int time = abs(x[i] - nx) + abs(y[i] - ny);
        if(time + now == t[i] || (time + now <= t[i] && (time + now - t[i]) % 2 == 0)) {
            now = t[i];
            nx = x[i];
            ny = y[i];
        } else {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;
import java.util.HashSet;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    HashSet<Long> set = new HashSet<Long>();
    boolean hantei = true;
    
    for(int i=0; i<N; i++){
      int bSize = set.size();
      Long A = sc.nextLong();
      if(set.contains(A) == true){
        hantei = false;
        break;
      } else set.add(A);
    }
    if(hantei == true) System.out.println("YES");
    else System.out.println("NO");
  }
}


Measured memory_bytes: 102872
N,M,V,P=gets.split.map(&:to_i)
as=gets.split.map(&:to_i)
as.sort!
as.reverse!
l=0
r=N-1
while true
    border=(l+r)/2
    add=as[border]+M
    rank=as.bsearch_index{|e|e<=add}
    if rank.nil? || P-1<rank
        ok=false
    elsif V-1-rank<=0
        ok=true
    else #V-1-rank>0 自分より下位に点数を入れる
        rest=M*(V-1-rank) # うまく使う
        attack=P-rank-1
        (N-rank).times do |i|
            j=rank+i
            if border==j
                next
            elsif attack>0
                rest-=M
                attack-=1 if as[j]+M>add
            else
                rest-=[add-as[j],M].min
            end
        end
        ok=true if rest<=0
        ok=false if rest>0
    end
    
    if ok
        l=border
    else
        r=border
    end
    break if r-l<=1 
end

border=r
add=as[border]+M
rank=as.bsearch_index{|e|e<=add}
if rank.nil? || P-1<rank
    ok=false
elsif V-1-rank<=0
    ok=true
else #V-1-rank>0 自分より下位に点数を入れる
    rest=M*(V-1-rank) # うまく使う
    attack=P-rank-1
    (N-rank).times do |i|
        j=rank+i
        if border==j
            next
        elsif attack>0
            rest-=M
            attack-=1 if as[j]+M>add
        else
            rest-=[add-as[j],M].min
        end
    end
    ok=true if rest<=0
    ok=false if rest>0
end

idx=ok ? r : l
ans=0
N.times do |i|
    ans+=1 if as[i]>=as[idx]
end
puts ans


Measured memory_bytes: 11152
#include <iostream>

int main(){
	int n = 1;
  	int x;
  	for(int i = 0; i < 5; i++){
    	std::cin >> x;
      	if(x == 0) {
        	std::cout << n;
        }
      	else {
        	n++;
        }
    }
}

Measured memory_bytes: 3584
n = int(input())
s = input()
 
r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')
 
ans = r_cnt * g_cnt * b_cnt
 
for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
print(ans)

Measured memory_bytes: 9204
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)


def calc(x):
    if A[x] >= K:
        return True
    dp = [False] * K
    dp[0] = True
    ma = 0
    for i in range(N):
        if i == x:
            continue
        for k in range(ma, -1, -1):
            if k + A[i] >= K:
                continue
            dp[k + A[i]] |= dp[k]
        ma = min(K - 1, ma + A[i])

    return sum(dp[K - A[x]:K])


l, r = 0, N - 1
if not calc(N - 1):
    print(N)
    exit()
if calc(0):
    print(0)
    exit()
while r - l > 1:
    mi = (l + r) // 2
    if calc(mi):
        r = mi
    else:
        l = mi

print(r)


Measured memory_bytes: 44832
n = int(input())
dp = [[-1,-1,-1] for i in range(n)]
abc = []
for i in range(n):
    abc.append(list(map(int, input().split())))

dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1, n):
    dp[i][0] = max(dp[i][0], dp[i-1][1] + abc[i][0], dp[i-1][2] + abc[i][0])
    dp[i][1] = max(dp[i][1], dp[i-1][0] + abc[i][1], dp[i-1][2] + abc[i][1])
    dp[i][2] = max(dp[i][2], dp[i-1][0] + abc[i][2], dp[i-1][1] + abc[i][2])

print(max(dp[n-1]))


Measured memory_bytes: 50380
import java.util.*;

public class Main {
	static final int r = 1000000000 + 7;
	static int prime[];
	static List<Integer> primes;

	/*
	 * a: 基数, b: 指数, r: 剰余数 a^b % rを繰り返し二乗法で求めるもの
	 */
	public static int binarypow(long a, long b, int r) {
		if (b == 0)
			return 1;
		if (b == 1)
			return (int) (a % (long) r);
		if (b % 2 == 1)
			return (int) ((a * binarypow(a, b - 1, r)) % (long) r);
		long tmp = binarypow(a, b / 2, r);
		return (int) ((tmp * tmp) % (long) r);
	}

	public static void initprime(int n) {
		prime = new int[n + 1];
		primes = new ArrayList<Integer>();
		prime[0] = prime[1] = -1;
		for (int i = 2; i <= n; ++i) {
			if (prime[i] == 0) {
				prime[i] = 1;
				primes.add(i);
				for (int j = 2; i * j <= n; ++j) {
					prime[i * j] = -1;
				}
			}
		}
	}

	public static boolean isPrime(int t) {
		return prime[t] == 1;
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		initprime(k);
		sc.close();
		long ans = 0;
		int dp[] = new int[k + 1];
		for (int i = 1; i <= k; ++i) {
			dp[i] = binarypow((long) (k / i), (long) n, r);
			dp[i] %= r;
		}
		for(int p : primes){
			for(int i = p; i <= k; i += p){
				dp[i / p] -= dp[i];
				dp[i / p] %= r;
			}
		}

		for(int i = 1; i <= k; ++i){
			ans += (long)dp[i] * (long)i;
			ans %= (long)r;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 37380
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define pri 1000000007
using namespace std;
ll dp[100001][2];
void dfs1(ll pt,vector <ll> adj[],ll old){
	ll v=1;
	for(auto j:adj[pt]){
		if(j==old)continue;
		dfs1(j,adj,pt);
	}
	ll v1=1;
	ll v2=1;
	for(auto j:adj[pt]){
		
		if(j==old)continue;
		v1=(v1*dp[j][0])%pri;
		v2=(v2*(dp[j][0]+dp[j][1]))%pri;
	}
	//cout<<pt<<" "<<v1<<v2<<endl;
	dp[pt][0]=v2;
	dp[pt][1]=v1;
	
}
int main() {
	ll n;
	cin>>n;
	vector <ll>  adj[n+1];
	
     for(ll i=0;i<n-1;i++){
     	ll x,y;
     	cin>>x>>y;
     	adj[x].PB(y);
     	adj[y].PB(x);
     }
     dfs1(1,adj,0);
     cout<<(dp[1][0]+dp[1][1])%pri;
     
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> n(N);
  for (int i = 0; i < N; ++i)
    cin >> n[i];

  vector< vector<long long> > dp(N, vector<long long>(21));
  dp[1][n[0]] = 1;
  for (int i = 2; i <= N - 1; ++i) {
    for (int j = 0; j <= 20; ++j) {
      if (0 <= j - n[i - 1])
        dp[i][j - n[i - 1]] += dp[i - 1][j];
      if (j + n[i - 1] <= 20)
        dp[i][j + n[i - 1]] += dp[i - 1][j];
    }
  }

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


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}




int main(){

  ll n,x;
  cin >> n >> x;

  vector<ll> a(n);
  FOR(i,0,n)cin>>a[i];

  ll ans = 0;
  FOR(i,1,n){
    ll del = a[i]+a[i-1]-x;
    if(del<=0)continue;
    ans += del;
    if(a[i]>=del){
      a[i] -= del;
    }else{
      a[i] = 0;
    }

  }
  cout << ans << endl;

}


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

using namespace std;

struct Point {
    vector<int> coords;
};

bool is_dist_int(const Point& p0, const Point& p1) {
    uint32_t sum = 0;
    for(int i = 0; i < p0.coords.size(); i++) {
        uint32_t p = (uint32_t)abs(p0.coords[i] - p1.coords[i]);
        sum += (p*p);
    }
    // sum 何かの二乗かどうか。わからんから力技で
    for(int i = 0; i <= sum; i++) {
        if(i*i == sum) {
            return true;
        }
    }
    return false;
}

int main(int argc, const char * argv[]) {
    int N = 0;
    int D = 0;
    cin >> N >> D;

    vector<Point> points(N);
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < D; j++) {
            int p_j = 0;
            cin >> p_j;
            points[i].coords.push_back(p_j);
        }
    }

    int count = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i+1; j < N; j++) {
            //cout << "dist between " << i << " and " << j << " is ";
            if(is_dist_int(points[i], points[j])) {
                //cout << "int" << endl;
                count++;
            } else {
                //cout <<"NOT int" << endl;
            }
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 768
E = ["S","H","C","D"]
n=int(input())
x=[[0 for j in range(14)]for i in range(4)]
for i in range(n):
	a,b=input().split()
	a=E.index(a)
	b=int(b)
	x[a][b]=1
	
for z in range(4):
	for c in range(1,14):
		if x[z][c]==0:
			print(f"{E[z]} {c}")


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

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

int digitSum(int64_t n) {
    int res = 0;
    while (n > 0) {
        res += n % 10;
        n /= 10;
    }
    return res;
}

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

    int k;
    cin >> k;

    int64_t d = 1;

    vector<int64_t> cand;
    for (int i = 0; i < 14; i++) {
        for (int p = 1; p < 300; p++) {
            int64_t c = p * d - 1;
            if (c == 0) continue;

            cand.push_back(c);
        }
        d *= 10;
    }

    sort(cand.begin(), cand.end());
    cand.erase(unique(cand.begin(), cand.end()), cand.end());

    // 4000個弱

    int next = -1;
    repeat (i, k) {
        bool flag = false;

        while (!flag) {
            next++;
            flag = true;
            for (int j = next + 1; j < cand.size(); j++) {
                if (cand[next] * digitSum(cand[j]) > cand[j] * digitSum(cand[next])) {
                    flag = false;
                    break;
                }
            }
        }
        cout << cand[next] << endl;
    }

    return 0;
}


Measured memory_bytes: 384
function Main(arg) {
 
    var N = arg.split("\n")[0];
    
    var ans = Number.MAX_SAFE_INTEGER;
    for (var i = 1; i <= Math.sqrt(N); i++){
        if (N % i === 0) {
            var tmp = (i - 1) + (N / i - 1);
            if (ans > tmp) {
                ans = tmp;
            }
        }
    }

    console.log(ans)

    return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug1(x) cout<<#x<<" : "<<x<<endl
#define debug2(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl

typedef long long ll;
typedef pair<ll,ll> pii;
const ll modd=1e9+7;

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

/*-----------------------------------------------------------------------*/

double pro[3000];

int main(){
   fastt;
   
   ll n;
   cin>>n;

   double p[n];

   for(ll i=0;i<n;i++)  cin>>p[i];

   pro[0]=1;

   for(ll i=0;i<n;i++){
       double copy[3000];
       for(ll j=0;j<3000;j++)
          copy[j]=pro[j];
       for(ll j=2999;j>=0;j--)
          pro[j]=(copy[j]*(1-p[i])); 
       for(ll j=2999;j>=1;j--)
          pro[j]=(pro[j]+copy[j-1]*p[i]);
    }

   double ans=0;

   for(ll i=n;i>n/2;i--){
      ans=(ans+pro[i]);
   }
  
   cout<<setprecision(9)<<ans<<endl;

   return 0;
}


Measured memory_bytes: 384
x1, y1, x2, y2 = map(int, input().split())

def solve1(a,b,x,y):
    return -y + b + a, x - a + b

def solve2(a,b,x,y):    
    return y - b + a, -x + a + b

x3,y3 = solve2(x2,y2,x1,y1)
x4,y4 = solve1(x1,y1,x2,y2)
print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    int count[2] = {};
    for(int i = 0;i < s.size();i++)
    {
        count[s[i] - 'A']++;
    }
    if(count[0] && count[1])
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256