akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main(){
	string s;
	cin >> s;
	long long int ans=0;
	int B_start=-1;
	int B_serch=-1;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]=='B'){
			B_start=i;
			B_serch=i;
			break;
		}
			
	}
	if(B_start==-1){
		cout << "0" <<endl;
		return 0;
	}else{
		for(int i=B_serch;i<s.size();i++){
			if(s[i]=='W'){
				ans+=(i-B_start);
				B_start++;
				B_serch=i;
				s[i]='B';
				s[B_start]='W';
			}
		}

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


Measured memory_bytes: 640
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, N);
    vector<int> cnt(N);

    rep(i, 1, N) {
        var(int, x);
        --x;
        cnt[x] += 1;
    }

    rep(i, 0, N) { print(cnt[i]); }

    return 0;
}


Measured memory_bytes: 3960
loop do
    n, a, b, c, x = gets.split.map(&:to_i)
    break if n == 0 && a == 0 && b == 0 && c == 0 && x == 0
    y = gets.split.map(&:to_i)
    i = 0
    bl = false
    10001.times do |count|
        if y[i] == x
            i += 1
        end
        if i == n
            puts count
            bl = true
            break
        end
        x = (a * x + b) % c
    end
    next if bl
    puts "-1"
end

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

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

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> red(a), green(b), white(c);
    for (int i = 0; i < a; i++) cin >> red[i];
    for (int i = 0; i < b; i++) cin >> green[i];
    for (int i = 0; i < c; i++) cin >> white[i];
    sort(red.rbegin(), red.rend());
    sort(green.rbegin(), green.rend());
    sort(white.rbegin(), white.rend());
    long long ans = 0;
    for (int i = 0; i < x; i++) ans += red[i];
    for (int i = 0; i < y; i++) ans += green[i];
    int last_r = x - 1, last_g = y - 1;
    int idx = 0;
    auto upd_red = [&]() {
        ans -= red[last_r];
        last_r--;
        ans += white[idx];
        idx++;
    };
    auto upd_green = [&]() {
        ans -= green[last_g];
        last_g--;
        ans += white[idx];
        idx++;
    };
    while (1) {
        if (last_r < 0 && last_g < 0) break;
        if (idx == c) break;
        if (last_r < 0) {
            // greenを交換
            if (green[last_g] >= white[idx]) break;
            upd_green();
            continue;
        }
        if (last_g < 0) {
            // redを交換
            if (red[last_r] >= white[idx]) break;
            upd_red();
            continue;
        }
        if (red[last_r] < green[last_g]) {
            // redを交換
            if (red[last_r] >= white[idx]) break;
            upd_red();
            continue;
        }
        // greenを交換
        if (green[last_g] >= white[idx]) break;
        upd_green();
    }
    cout << ans << endl;
}


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

int main(){
  int n,p[999999];
  bool ip[1000000];
  int m=0;
  for(int i=0;i<=1000000;i++) ip[i]=true;
  ip[0]=ip[1]=false;
  for(int i=2;i<=1000000;i++){
    if(ip[i]){
      p[m++]=i;
      for(int j=2*i;j<=1000000;j+=i) ip[j]=false;
    }
  }
  while(cin>>n){
    for(int i=0;i<m;i++){
      if(p[i]>n){
	cout<<i<<endl;
	break;
      }
    }
    if(n>=p[m-1]) cout<<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 4312
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] nm = new int[]{sc.nextInt(), sc.nextInt()};
        int[][] a = new int[nm[0]][nm[1]];
        int[] b = new int[nm[1]];
        for (int i = 0; i < nm[0]; i++) {
            for (int j = 0; j < nm[1]; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < nm[1]; i++) {
            b[i] = sc.nextInt();
        }

        for (int i = 0; i < nm[0]; i++) {
            int sum = 0;
            for (int j = 0; j < nm[1]; j++) {
                sum += a[i][j] * b[j];
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 40472
#include <stdio.h>

char str[11];
int num[11];
int len;
long long int tsum;

void solve(int now, long long int su, long long int sum) {
    if(now>len) tsum+=sum;
    else {
        solve(now+1, num[now], sum+su);
        if(now<len) solve(now+1, su*10+num[now], sum);
    }
}

int main(void){

    scanf("%s", str);

    while(str[++len]);

    for(int i=0; i<len; i++) num[i]=str[i]-'0';

    solve(1, num[0], 0);

    printf("%lld", tsum);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using T = tuple<ll,int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  int n;
  cin >> n;
  auto v = vector<int>(n);
  for(int i = 0;i < n;++i){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  int from = v[n/2 - 1];
  int to = v[n/2];
  cout << to - from << endl;
  return 0;
}


Measured memory_bytes: 640
def main():
    W = input().lower()
    words = []
    while True:
        T = input()
        if T == "END_OF_TEXT":
            break

        words.extend(T.split(" "))

    ans = sum(1 for word in words if word.lower() == W)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 5564
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>

#define ok printf("ok\n");
#define MAX 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define pb push_back

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

int main()
{
	int x,y,ans = 0,cal;
	string s,t;
	vi v,w;
	cin >> x >> y;
	cin >> s;
	rep(i,s.size())
	{
		if (s[x] != '-')
		{
			puts("No");
			//ok
			return 0;
		}
		if(i != (x) && s[i] == '-')
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	ll N, M, Y[100000], P[100000], d[100000], keta[100000];
	vector<pll> a[100000];
	cin >> N >> M;
	REP(i, M) {
		cin >> P[i] >> Y[i];
		a[P[i] - 1].push_back(pll(Y[i], i));
	}
	REP(i, N) {
		sort(a[i].begin(), a[i].end());
		ll t = 0, k = i + 1;
		while (k > 0) {
			t++;
			k /= 10;
		}
		REP(j, a[i].size()) {
			d[a[i][j].second] = ((ll)i + 1) * 1000000 + (ll)j + 1;
			keta[a[i][j].second] = t;

		}
	}

	REP(i, M) {
		
		REP(j, 6-keta[i]) {
			cout << "0";
		}
		cout << d[i] << endl;
		
	}

	return 0;
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int cnt=0;
  cin>>s;
  for(int i=s.size()-1;i>0;i--){
    if(i%2==0){
      int now=i/2;
      for(int j=0;j<now;j++){
	if(s[j]!=s[now+j])break;
	cnt++;
      }
      if(cnt==now)break;
    }
    cnt=0;
  }
  cout<<cnt*2<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>

using namespace std;

typedef long long ll;

int main(void){
  ll a,b;
  cin >> a >> b;
  ll cnt = 0;
  ll s = 1;
  while(s < b){
    s--;
    s += a;
    cnt++;
  }
  cout << cnt << endl;
  /*
  if(b != 0){
    cout << cnt + 1 << endl;
  }else{
    cout << cnt << endl;
  }
  */
  return 0;
}


Measured memory_bytes: 256
#jiriki-kibishi-katta
from collections import deque
n = int(input())
p = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    p[a].append((b, c))
    p[b].append((a, c))
q, k = map(int, input().split())
visited = [-1]*(n+1)
visited[k] = 0
queue = deque()
queue.append(k)
while len(queue):
    pos = queue.popleft()
    for nxt, w in p[pos]:
        if visited[nxt] != -1:
            continue
        visited[nxt] = visited[pos]+w
        queue.append(nxt)
for i in range(q):
    x, y = map(int, input().split())
    print(visited[x]+visited[y])

Measured memory_bytes: 45340
#include <stdio.h>
#include <math.h>

int combination(int n,int m){
	int i,s=0;
	if(n>m*9)return 0;
	if(m==2)return 10-abs(n-9);
	for(i=0;i<10;i++){
		if(n-i>-1)s+=combination(n-i,m-1);
	}
	return s;
}

int main (){
	int n;
	while(scanf("%d",&n)!=EOF)printf("%d\n",combination(n,4));
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
string s,t;
int mem[3001][3001];
void print(int i,int j)
{
    if(i==0||j==0)
        return;
    if(s[i-1]==t[j-1])
    {
    print(i-1,j-1);
    cout<<s[i-1];
    }
    else if(mem[i-1][j]>mem[i][j-1])
    print(i-1,j);
    else
    print(i,j-1);
}
int main()
{
    cin>>s;
    cin>>t;
    int i,j;
    for(i=0;i<=s.length();i++)
    for(j=0;j<=t.length();j++)
    {
        if(i==0||j==0)
        mem[i][j]=0;
        else
        {
            if(s[i-1]==t[j-1])
            mem[i][j]=1+mem[i-1][j-1];
            else
            {
            if(mem[i-1][j]>mem[i][j-1])
                mem[i][j]=mem[i-1][j];
            else
                mem[i][j]=mem[i][j-1];
            }
        }
    }
    print(s.length(),t.length());
    return 0;
}


Measured memory_bytes: 35840
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define REP(i, n) for (int i=0;i<n;++i)
#define MP make_pair
#define PB push_back

typedef double DB;
typedef long long LL;

const DB EPS = 1e-8;
const DB PI = acos(-1);
const DB gg = 9.8;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;


inline void checkMin(int &a, int b){
    if (b < a) a = b;
}

inline int sgn(double x){
    return x < -EPS ? -1 : x > EPS;
}

const int N = int(1e2) + 9;
int n, l[N], b[N], r[N], t[N];
int X, Y; DB V; int low;

inline DB y(DB a, DB x) {
    DB t = x/(V*cos(a));
    return V*sin(a)*t - 0.5*gg*t*t;
}

inline DB getM(DB a){
    DB t = V*sin(a)/gg;
    return V*cos(a)*t;
}

bool ck(DB a) {

    DB h = y(a, X); if (sgn(h-Y) < 0 || sgn(h-low) > 0 ) return false;
    DB mx = getM(a), my = y(a, mx);

    REP(i, n){

        DB h1 = y(a, l[i]), h2 = y(a, r[i]);

        if (l[i] <= mx && mx <= r[i]){
            if (!(h1 <= b[i] && h2 <= b[i] && my <= b[i] || h1 >= t[i] && h2 >= t[i] && my >= t[i])) return false;
        }
        else{
            if (!(h1 <= b[i] && h2 <= b[i] || h1 >= t[i] && h2 >= t[i])) return false;
        }
    }
    return true;
}

bool ck() {

    REP(i, n){
        if (l[i] == 0 && b[i] == 0) return false;
        if (l[i] <= X && X <= r[i]  && b[i] <= Y && Y <= t[i]) return false;
    }

    DB d = PI/2/15000;
    for (DB a=d;a<=PI/2;a+=d) if (ck(a)) return true;
    return false;
}

int main() {
//    freopen("in.txt", "r", stdin);
    while (~scanf("%d%lf%d%d", &n, &V, &X, &Y)) {
        low = INF; REP(i, n){
            scanf("%d%d%d%d", &l[i], &b[i], &r[i], &t[i]);
            if (l[i] > X){
                --i; --n;
                continue;
            }
            if (r[i] >= X){
                if (b[i] >= Y) checkMin(low, b[i]);
                r[i] = X;
            }
        }
        puts(ck() ? "Yes" : "No");
    }
}

Measured memory_bytes: 1196
n, k = map(int, input().split())
p = list(map(int, input().split()))
e = []
for i in range(n):
    e.append((p[i]+1)/2)
cumsum  = []
sm = 0
for j in range(n):
    sm += e[j]
    cumsum.append(sm)
ans = cumsum[k-1]
for i in range(n-k):
    s = cumsum[i+k] - cumsum[i]
    if ans < s:
        ans = s
print(ans)

Measured memory_bytes: 107376
import scala.io.StdIn._
import scala.math._
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val a,b,c = sc.nextInt
  if(a<b){
    if(c<a){//cab
      print(abs(c-a)+abs(a-b))
    }
    else{
      if(b<c){//abc
        print(abs(a-b)+abs(b-c))
      }
      else{//acb
        print(abs(a-c)+abs(c-b))
      }
    }
  }
  else{
    if(c<b){//cba
      print(abs(c-b)+abs(b-a))
    }
    else{
      if(a<c){//bac
        print(abs(b-a)+abs(a-c))
      }
      else{//bca
        print(abs(b-c)+abs(c-a))
      }
    }
  }
}

Measured memory_bytes: 27336
#include <stdio.h>
int main()
{
    char n;
    scanf("%c",&n);
    if(n=='A')
        printf("T");
    else if(n=='T')
        printf("A");
    else if(n=='C')
        printf("G");
    else if(n=='G')
        printf("C");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n, d;
  cin >> n >> d;
  int x[n][d];

  REP(i,n){
    REP(j,d) cin >> x[i][j];
  }

  int cnt = 0;
  REP(i,n){
    for(int k = i + 1; k < n; ++k){
      int sum = 0;
      REP(j,d){
        int diff =abs(x[i][j]-x[k][j]);
        sum += (diff * diff);
      }
      for(int pi = 0; pi <= sum; ++pi){
        if(sum == pi*pi) ++cnt;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#define MAX_PROCESS_NAME_SIZE 10
#define PROCESS_QUEUE_SIZE 100001

struct Process{
  char name[MAX_PROCESS_NAME_SIZE];
  int left_time;
};

Process queue[PROCESS_QUEUE_SIZE];
int head, tail = 0;

void enqueue(Process process) {
  queue[tail] = process;
  tail = (++tail % PROCESS_QUEUE_SIZE);
}

Process dequeue() {
  Process process = queue[head];
  head = (++head % PROCESS_QUEUE_SIZE);

  return process;
}

bool is_empty() {
  return head == tail;
}

int main() {
  int number_of_queue , quantum;
  Process current_process;

  scanf("%d %d", &number_of_queue, &quantum);

  for(int i = 0; i < number_of_queue; i++) {
    scanf("%s %d", current_process.name, &current_process.left_time);

    enqueue(current_process);
  }

  int elapsed_time = 0;
  while(true) {
    if(is_empty()) {
      break;
    }

    Process process = dequeue();

    if(process.left_time > quantum) {
      process.left_time -= quantum;
      enqueue(process);

      elapsed_time += quantum;
    } else {
      elapsed_time += process.left_time;

      printf("%s %d\n", process.name, elapsed_time);
    }
  }
}



Measured memory_bytes: 4136
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

long double EPS = 1e-20;

int main(){
    long double a,b,c;cin >> a >> b >> c;
    if(2 * sqrt(a*b) < c - a - b) puts("Yes");
    else puts("No");
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a); i>=(b);i--) 

const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;

ll a[maxn];

int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   int n;
   cin >> n;
   rep(i,1,n + 1) cin >> a[i];
   ll ans = 0;
   rep(i,1,n){
      ll t; cin >> t;
      if(t > a[i]){
          if(t > a[i] + a[i + 1]) {
              ans += a[i] + a[i + 1];
              a[i + 1] = 0;
          }
          else{
              ans += t;
              a[i + 1] = a[i] + a[i + 1] - t;
          }
      }
      else ans += t;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string N;
  cin >> N;
  if (N[0] == N[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX*/

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}

const int M = 1005;

vector<vector<int>> dp(M, vector<int>(M));


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    init();

    int n, a, b, c, d;
    cin>>n>>a>>b>>c>>d;

    for (int i = 0; i<=n; i++)
        for (int j = a; j<=b; j++)
        {
            if (j==a)
            {
                if (i%a!=0) dp[i][j] = 0;
                else if ((i/a)!=0 && ((i/a)<c || (i/a)>d)) dp[i][j] = 0;
                else dp[i][j] = mul(mul(facs[i], invfacs[i/j]), po(invfacs[j], i/j));
                continue;
            }
            dp[i][j] = add(dp[i][j], dp[i][j-1]);
            for (int k = c; k<=min(d, i/j); k++)
            {
                dp[i][j] = add(dp[i][j], mul(dp[i-j*k][j-1], mul(C(i, j*k), mul(mul(facs[j*k], invfacs[k]), po(invfacs[j], k)))));
            }
        }
    /*for (int i = 0; i<=n; i++)
        for (int j = a; j<=b; j++)
        {
            cout<<i<<' '<<j<<": "<<dp[i][j]<<endl;
        }*/

    cout<<dp[n][b];
}

Measured memory_bytes: 12032
N = int(input()) + 2
X = [0, 0] + list(map(int, input().split()))
dp = [[0, 0] for _ in range(N)]
for i in range(2, N):
    if i%2:
        dp[i][1] = max(dp[i-2][1] + X[i], dp[i-1][1])
        dp[i][0] = max(dp[i-2][0] + X[i], dp[i-1][0])
    else:
        dp[i][1] = dp[i-2][1] + X[i]
        if i!=2:
            dp[i][0] = max(dp[i-2][0] + X[i], dp[i-1][1])
#print(dp)
if N%2:
    print(dp[-1][0])
else:
    print(dp[-1][1])


Measured memory_bytes: 114248
/*
     こういうやるだけDPしか出なければいいのに
     あw頭ついてないからそれでも予選落ち確定でしたw
 */

#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

#define INF 0x7fffffff

int d;
int n;
int a[200];
int b[200];
int c[200];
int t[200];
int dp[200][200]; // dp[day][used]
int ans;

int main() {
    scanf("%d %d", &d, &n);

    for (int i=0; i<d; i++) {
        scanf("%d", &t[i]);
    }

    for (int i=0; i<n; i++) {
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
    }

    for (int i=0; i<n; i++) {
        if (t[0] < a[i] || b[i] < t[0]) dp[0][i] = -INF;
    }

    for (int i=1; i<d; i++) {
        for (int j=0; j<n; j++) {
            if (t[i] < a[j] || b[j] < t[i]) continue;
            for (int k=0; k<n; k++) {
                int val;

                if (dp[i-1][k] < 0) continue;
                val = dp[i-1][k] + abs(c[j] - c[k]);
                dp[i][j] = max(dp[i][j], val);
            }
        }
    }

    for (int i=0; i<n; i++) {
        ans = max(ans, dp[d-1][i]);
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 1188
#include<iostream>
using namespace std;
int main()
{
    string S,T;
    cin>>S>>T;
    int A,B;
    cin>>A>>B;
    string U;
    cin>>U;
    if(U==S)
    {
        A=A-1;
    }
    else
    {
        B=B-1;
    }
    cout<<A<<" "<<B;
}

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

int main() {
  int N, M, c;
  cin >> N;
  M = N;
  c = 0;
  
  while(M > 0){
    c += (M % 10);
    M /= 10;
  }
  
  if(N % c == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

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

    long long a[N][3];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }

    long long dp[N+1][3];

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i][j] = 0;
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if(j == k) continue;
                else dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    
    long long res = 0;
    res = max({dp[N][0], dp[N][1], dp[N][2]});

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int dp[50];

int fib(int n)
{
	if(n == 0 || n == 1) return dp[n] = 1;
	if( dp[n] != -1) return dp[n];
	return dp[n] = fib(n-1)+fib(n-2);
}

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


Measured memory_bytes: 2108
import sys
n = int(input())
ls = list(map(int,input().split()))
mx = -float("inf")
for i in ls:
    if i < mx:
        if i + 1 != mx:
            print("No")
            sys.exit()
        else:
            mx = i + 1
    else:
        mx = i
print("Yes")


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



int main()
{
    int n, cnt = 0;
    cin >> n;

    for(int i = 0; i < n; i++)
    {
        int y;
        cin >> y;
        if((y % 2) == 1) cnt++;
    }

    bool flag;
    if((cnt % 2) == 1) flag = false;
    else flag = true;

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int m, n, l, i, j, k;
    long int A[100][100]={}, B[100][100]={}, C[100][100]={};
    cin >> m >> n >> l;
    
    for(i=0; i<m; i++){
        for(j=0; j<n; j++){
            cin >> A[i][j];
        }
    }
    
    for(j=0; j<n; j++){
        for(k=0; k<l; k++){
            cin >> B[j][k];
        }
    }
    
    for(i=0; i<m; i++){
        for(k=0; k<l; k++){
            for(j=0; j<n; j++){
                C[i][k] += (A[i][j] * B[j][k]);
            }
            cout << C[i][k];
            if(k != l-1) cout << " ";
            else cout << endl;
        }
    }
    return 0;
    
}



Measured memory_bytes: 3356
import sys
import math
import itertools

def solve(X):
    ans = 100
    i = 0
    while ans < X:
        i += 1
        ans = (math.floor(ans * 1.01))
        # print(ans)
    return i




def main():
    X = int(input())
    # solve()
    print(solve(X))
if __name__ == '__main__':
   main()

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
int main(){
  map<int,int>mpa,mpb;
  int n;
  cin >>n;
  long long int d[n]; 
  for(int i=0;i<n;i++){
    cin >>d[i];
    mpa[d[i]]++;
  }
  int m;
  cin >>m;
  long long int t[m]; 
  for(int i=0;i<m;i++){
    cin >>t[i];
    mpb[t[i]]++;
  }
  bool out=false;
  for(int i=0;i<m;i++){
    if(mpa[t[i]]<mpb[t[i]])out=true;
  }
  if(out)cout<<"NO"<<endl;
  else cout <<"YES"<<endl;
}

Measured memory_bytes: 22144
#include <iostream>
using namespace std;
#define int long long
#define maxK 201

int gcd_impl(int a, int b)
{
    if (a > b) {
        int tmp = b;
        b = a;
        a = tmp;
    }
    if (a == 0) {
        return b;
    }
    return gcd_impl(a, b % a);
}
int GCD[maxK + 1][maxK + 1];

int gcd(int a, int b, int c)
{
    return GCD[GCD[a][b]][c];
}

signed main()
{
    for (int a = 0; a <= maxK; a++) {
        for (int b = 0; b <= maxK; b++) {
            GCD[a][b] = gcd_impl(a, b);
        }
    }
    int K;
    cin >> K;
    int ans = 0;

    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                ans += gcd(a, b, c);
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
  const int MOD=1000000007;
  int N,M;cin>>N>>M;
  vector<bool> issafe;
  issafe.assign(N+1,true);
  for(int i=0;i<M;++i){
    int a;cin>>a;
    issafe[a]=false;
  }
  vector<int>dp(N+1,0);
  dp[0]=1;
  if(issafe[1])dp[1]=1;
  for(int n=2;n<=N;++n){
    if(issafe[n-1])dp[n]+=dp[n-1];
    if(issafe[n-2])dp[n]+=dp[n-2];
    dp[n]%=MOD;
  }
  
  cout<<dp[N]<<endl;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, _ := getInt(), getInt(), getInt()

	fmt.Println((a * b) / 2)

}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{  
	int a[100],i,j,temp;
	for (i=0;i<10;i++)
	{
		cin>>a[i];
	}
	for (i=0;i<9;i++)
	{
		for (j=0;j<9;j++)
		{
			if (a[j]<a[j+1])
			{
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
	for (i=0;i<3;i++)
	{
		cout<<a[i]<<endl;
	}
    return 0;  
}  

Measured memory_bytes: 1160
parseInt(x) = parse(Int,x)
parseMap(x::Array{SubString{String}, 1}) = map(parseInt, x)
function main()
    a,b,k = map(parseInt, split(readline()))
  ans = zeros(maximum([a b]));
  c  =1
  for i = 1:maximum([a b])
    if mod(a,i) == 0 && mod(b,i) == 0
      ans[c] = i
      c +=1
    end
  end
  sort!(ans)
  println(Int64(ans[end-k+1]))
end
main()


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

int main()
{
  int64_t N;
  cin >> N;
  map<string, int> mp = {{"AC", 0}, {"WA", 0}, {"TLE", 0}, {"RE", 0}};
  string s;
  for (int i = 0; i < N; i++)
  {
    cin >> s;
    mp.at(s)++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}

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

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

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

const int MAXN = 1e5 + 5;
const ll inf = 1e18;

int n;
ll a[MAXN];

ll ostalo(ll k) {
  REP(i, n) {
    k -= k % a[i];
  }

  return k;
}

int main() {
  cin >> n;
  REP(i, n) {
    cin >> a[i];
  }

  ll lo = 2, hi = inf;

  while(lo < hi) {
    ll mid = (lo + hi) >> 1;

    if(ostalo(mid) < 2)
      lo = mid + 1;
    else
      hi = mid;
  }

  ll mn = lo;
  if(ostalo(mn) != 2) {
    cout << -1;
    return 0;
  }

  lo = 2, hi = inf;

  while(lo < hi) {
    ll mid = (lo + hi + 1) >> 1;

    if(ostalo(mid) > 2)
      hi = mid - 1;
    else
      lo = mid;
  }

  cout << mn _ lo << endl;
}


Measured memory_bytes: 1024
import sys

input = sys.stdin.readline

def main():
    s = input().rstrip('\n')
    n = len(s)
    ansl = [0]*(n+1)
    for i in range(n):
        if s[i] == '<':
            ansl[i+1] = ansl[i]+1
    for i in reversed(range(n)):
        if s[i] == '>':
            ansl[i] = max(ansl[i+1]+1,ansl[i])
    print(sum(ansl))

if __name__ == '__main__':
    main()

Measured memory_bytes: 29248
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
const int MOD = 1e9+7;

struct Combination{
	std::vector<ll> fac, finv, inv;

	Combination(int max=6e5): fac(max+1), finv(max+1), inv(max+1) {
		fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
		for(int i=2; i<=max; i++){
			fac[i] = fac[i-1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
			finv[i] = finv[i-1] * inv[i] % MOD;
		}
	}

	ll C(int n, int r) const {
		if(n<0 or n<r) return 0;
		return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
	}
};

int main(){
	int x, y;
	scanf("%d %d", &x, &y);
	if((x+y)%3 or x*2<y or x>y*2) puts("0");
	else{
		Combination com(666666);
		printf("%ld\n", com.C((x+y)/3, (2*x-y)/3));
	}
	return 0;
}


Measured memory_bytes: 15872
while 1:
    n = int(input())
    if n == 0:
        break

    score = []
    for _ in range(n):
        datas = list(map(int, input().split()))
        num = datas.pop(0)

        time = 0
        for _ in range(4):
            time += datas.pop(0) * 60 + datas.pop(0)

        score.append([num, time])

    score = sorted(score, key=lambda x: x[1])
    print(score[0][0])
    print(score[1][0])
    print(score[-2][0])



Measured memory_bytes: 6440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
using Grid = vector<vector<int>>;
using vi = vector<int>;

int main(){
    int N;
    cin >> N;
    vi v(N);
    rep(i, N) cin >> v[i];
    vector<int> lsum(N + 1, 0);
    vector<int> rsum(N+1, 0);
    lsum[0] = 0;
    for (int i = 1; i <= N; i++) {
        lsum[i] = v[i - 1] + lsum[i - 1];
    }
    rsum[0] = 0;
    for (int i = 1; i <= N; i++) {
        rsum[i] = v[N - i] + rsum[i - 1];
    }
    int ans = INT_MAX;
    rep2(i, N) {
        ans = min(ans, abs(lsum[i] - rsum[N - i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

#define INF 1e18

int main()
{
    long long n,abcde[5],i,j,min = INF;
    scanf("%lld",&n);
    for (i = 0; i < 5; i++)
    {
        scanf("%lld",&abcde[i]);
        if(min > abcde[i])
        {
            min = abcde[i];
        }
    }
    printf("%lld",(n  + (min  - 1)) / min + 4);
}

Measured memory_bytes: 128
#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
if(a>=-1000 && b<=1000)
  {
    if(a<b)printf("a < b\n");
    else if(a>b)printf("a > b\n");
    else printf("a == b\n");
  }
return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if (a%2 == 1 && b%2 == 1) {
            System.out.println("Odd");
        } else {
            System.out.println("Even");
        }
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	// Shojin
	static final long mod = 998244353;

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			String str = sc.next();
			int rCnt = 0;
			int[] wCnt = new int[n];
			for (int i = 0; i < n; i++) {
				if (str.charAt(i) == 'R') {
					rCnt++;
					if (i == 0) {
						wCnt[i] = 0;
					} else {
						wCnt[i] = wCnt[i - 1];
					}
				} else {
					if (i == 0) {
						wCnt[i] = 1;
					} else {
						wCnt[i] = wCnt[i - 1] + 1;
					}
				}
			}
			if (rCnt == 0 || rCnt == n) {
				System.out.println(0);
			} else {
				System.out.println(wCnt[rCnt - 1]);
			}

		}
	}
}

Measured memory_bytes: 41456
(n, k) = [int(x) for x in input().split()]
banig = []
for x in range(n):
  banig.append(int(input()))
banig.sort()

difBanig = []
for bot in range(n-k+1):
  difBanig.append(banig[bot+k-1] - banig[bot])

print(min(difBanig))

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

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

    int S[N] = {};

    rep(i, K) {
        int di, aik;
        cin >> di;
        rep(j, di) {
            cin >> aik;
            aik--;
            S[aik]++;
        }
    }

    int ans = 0;
    rep(i, N) if (S[i] == 0) ans++;

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int MX = (int)-1e9 + 7;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	vector<vector<int>> dp(n+1, vector<int> (3, MX)); //dp[i][j] the maximum point we can get so far with i activity and jth act
	dp[0][0] = 0; dp[0][1] = 0; dp[0][2] = 0;
	for(int i=1;i<=n;i++){
		int a,b,c; cin >> a >> b >> c;
		dp[i][0] = max(dp[i-1][1], dp[i-1][2])+c;
		dp[i][1] = max(dp[i-1][0], dp[i-1][2])+b;
		dp[i][2] = max(dp[i-1][0], dp[i-1][1])+a;
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << "\n";
	return 0;
}


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

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int cnt = inpt[1] - inpt[0];

        int takasa = cnt * (cnt + 1) / 2;

        int ans = takasa - inpt[1];
        Console.WriteLine(ans);
    }


    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"




54 65



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

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

int main(){

  int n, r;
  int card[50];

  while(cin>>n>>r, n){
    for(int i=0;i<n;i++) card[i]=n-i;
    for(int i=0;i<r;i++){
      int p, c;
      cin>>p>>c;

      rotate(card, card+p-1, card+p+c-1);
    }

    cout<<card[0]<<endl;
  }

  return 0;
}

Measured memory_bytes: 3144
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())

graph = {"r":P,"s":R,"p":S,"*":0}

for i,t in enumerate(T):
  if len(T)-i-K > 0:
    if t == T[i+K]:
      T[i+K] = "*"

ans = 0
for t in T:
  ans += graph[t]
print(ans)

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

int main(){
	bool ans, ans1 = true, ans2 = true;
	string S, T;
	cin >> S >> T;
	const int l = S.size();
	char s[l], t[l];
	for(int i = 0; i < l; i++){
		s[i] = S.at(i);
		t[i] = T.at(i);
	}

	for(char abc = 'a'; abc != '{'; abc++){
		char moji;
		bool first = true;
		for(int i = 0; i < l; i++){
			if(s[i] == abc && first){
				moji = t[i];
				first = false;
			}
			if(s[i] == abc)
				ans1 = ((moji == t[i] && ans1) ? true : false);
		}
	}
	for(char abc = 'a'; abc != '{'; abc++){
		char moji;
		bool first = true;
		for(int i = 0; i < l; i++){
			if(t[i] == abc && first){
				moji = s[i];
				first = false;
			}
			if(t[i] == abc)
				ans2 = ((moji == s[i] && ans2) ? true : false);
		}
	}
	ans = ans1 && ans2;
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <utility>
#include <queue>

using namespace std;

int N, M;
priority_queue< pair<int, int>, vector< pair<int, int> >, greater< pair<int, int> > > Q;
int can[200005];

int main(void)
{
	cin >> N >> M;
	int tmp1, tmp2;
	for(int i = 0; i < M; i++){
		cin >> tmp1 >> tmp2;
		Q.push( make_pair(tmp1, tmp2) );
	}
	
	int ans = 0;
	
	pair<int, int> cur;
	while((int)Q.size()){
		cur = Q.top();
		Q.pop();
		
		if(cur.first == 1){
			can[ cur.second ] = 1;
		}else{
			if( can[cur.first] && cur.second == N ){
				ans = 1;
				break;
			}
		}
	}
	
	
	if(ans) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 2672
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;


string s;

void solve(){
	reverse(s.begin(), s.end());
	char prev = '#';
	long long ans = 0;
	int count = 0;

	for(int i=0;i<s.length();i++){
		if(prev == '#'){
			if(s[i] == 'C') prev = 'C';
		}else if(prev == 'C'){
			if(s[i] == 'B'){
				count++; 
				prev = 'B';
			}else if(s[i] == 'C'){
				count = 0;
			}else{
				count = 0;
				prev = '#';
			}
		}else if(prev == 'B'){
			if(s[i] == 'A'){
				ans += count;
			}else if(s[i] == 'C'){
				prev = 'C';
			}else{
				count = 0;
				prev = '#';
			}
		}
	}

	cout << ans << endl;

}

int main(){
	cin >> s;
	solve();
	return 0;
}



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


using ll = long long;
const int MaxN = 2e5+10;
int N;
int A[MaxN];


void solve()
{
    vector<ll> prefix(N + 1);
    vector<ll> f(N + 1);
    prefix[1] = A[1];
    for (int i = 3; i <= N; i += 2)
        prefix[i] = prefix[i - 2] + A[i];
    for (int n = 2; n <= N; n++) {
        if (n & 1)
            f[n] = max(f[n - 1], A[n] + f[n - 2]);
        else
            f[n] = max(prefix[n - 1], A[n] + f[n - 2]);
    }
    cout << f[N] << endl;
}


int main()
{
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> A[i];
    solve();
    return 0;
}


Measured memory_bytes: 7192
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
#define F(i, n) for (i = 0; i < n; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
int32_t main()
{

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll a, b, c, k, sum;
  cin >> a >> b >> c >> k;
  if (a + b < k)
    c = k - (a + b);
  else if (a + b == k)
    c = 0;
  else
  {
    if (a > k)
      a = k;
    else if (a == k)
      a = k;
    else
    {
      a = a;
      b = k - a;
    }
    c = 0;
  }

  sum = a * 1 + b * 0 + c * (-1);
  cout << sum << endl;
}

Measured memory_bytes: 3596
#include<stdio.h>

int main(void){
    
    int a,b,d,r;
    double f;
    
    
    scanf("%d %d",&a,&b);
    d = a/b;
    r = a%b;
    f = 1.0*a/b;
    
    printf("%d %d %lf\n",d,r,f);
    
    return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

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

	ll n;
	cin >> n;
	vi v(n), x, s;
	x.pb(0);
	s.pb(0);
	rep(i, n) {
		cin >> v[i];
		x.pb(x[i] ^ v[i]);
		s.pb(s[i] + v[i]);
	}

	ll l = 1, r = 1;
	ll ans = 0;
	while (l <= n) {
		while (r <= n && (x[r] ^ x[l - 1]) == (s[r] - s[l - 1])) {
			r++;
			ans++;
		}
		l++;
		ans += r - l;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2804
#!/usr/bin/env python3
import functools


def memorized(f):
    table = {}
    @functools.wraps(f)
    def wrapper(*args):
        if args in table:
            return table[args]
        rvalue = f(*args)
        table[args] = rvalue
        return rvalue
    return wrapper


N, W = map(int, input().split())
v, w = [], []
for _ in range(N):
    vi, wi = map(int, input().split())
    v.append(vi)
    w.append(wi)

@memorized
def knapsack(i, r):
    if i == N:
        return 0
    if r < w[i]:
        return knapsack(i + 1, r)
    return max(knapsack(i + 1, r), v[i] + knapsack(i + 1, r - w[i]))

print(knapsack(0, W))



Measured memory_bytes: 134536
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_N 100001

using namespace std;

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

ll N, A, B, h[MAX_N];

bool C(ll i) {
  ll D = A - B;
  ll count = 0;
  for (ll j = 0; j < N; j++) {
    count += (max(h[j] - B * i, (ll)0) + (D - 1)) / D;
  }
  return count <= i;
}


ll binary() {
  ll lb = -1, ub = 1e9;
  // (lb, ub]
  while (ub - lb > 1) {
    ll mid = (lb + ub) / 2;
    if (C(mid)) {
      ub = mid;
    } else {
      lb = mid;
    }
  }
  return ub;
}


int main() {
  cin >> N >> A >> B;
  for (ll i = 0; i < N; i++) {
    cin >> h[i];
  }

  ll ans = binary();

  cout << ans << endl;

  return 0;
}


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

struct P {
  int x, y;
  P() : x(0), y(0) { }
  P(int x, int y) : x(x), y(y) { }
};

bool operator < (const P& a, const P& b) {
  return a.x != b.x ? a.x < b.x : a.y < b.y;
}

P operator - (const P& a, const P& b) {
  return P(a.x - b.x, a.y - b.y);
}

int dot(const P& a, const P& b) {
  return a.x * b.x + a.y * b.y;
}

int cross(const P& a, const P& b) {
  return a.x * b.y - a.y * b.x;
}

int norm(const P& p) {
  return p.x * p.x + p.y * p.y;
}

int ccw(P a, P b, P c) {
  b = b - a; c = c - a;

  if(cross(b, c) > 0) return +1;
  if(cross(b, c) < 0) return -1;
  if(dot(b, c) < 0) return +2;
  if(norm(b) < norm(c)) return +2;

  return 0;
}

vector<P> convex_hull(vector<P> ps) {
  int n = ps.size(), k = 0;

  sort(ps.begin(), ps.end());

  vector<P> ch(2 * ps.size());

  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;

  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;

  ch.resize(k-1);

  return ch;
}

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

  vector<P> points;

  for(int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;

    points.push_back(P(x, y));
  }

  auto ch = convex_hull(points);

  auto i = min_element(ch.begin(), ch.end(), [](const P& a, const P& b) {
    return a.y != b.y ? a.y < b.y : a.x < b.x;
  }) - ch.begin();

  cout << ch.size() << endl;

  for(int j = 0; j < ch.size(); j++) {
    cout << ch[(i + j) % ch.size()].x << " " << ch[(i + j) % ch.size()].y << endl;
  }
}

Measured memory_bytes: 5976
#include <iostream>

using namespace std;

int main() {

	int array[3];
	int dummy;

	cin >> array[0] >> array[1] >> array[2];

	//????????????????????§
	for (int i = 2 - 1; i >= 0; i--) {
		for (int j = 0; j <= i; j++) {
			if (array[j] > array[j + 1]) {
				dummy = array[j];
				array[j] = array[j + 1];
				array[j + 1] = dummy;
			}
		}
	}

	cout << array[0] << " " << array[1] << " " << array[2] << endl;

}

Measured memory_bytes: 3096
#include <iostream>
#include <cmath>

#define MAX_MN 100

using namespace std;

int min(int a, int b){
  return a < b ? a : b;
}

int main(void) {

  int n;
  int m;
  int a[MAX_MN], b[MAX_MN];
  int c[MAX_MN], d[MAX_MN];
  int min;

  cin >> n >> m;
  for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
  for(int i = 0; i < m; i++) cin >> c[i] >> d[i];

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      if(j == 0) min = j;
      else{
        if(abs(a[i] - c[j]) + abs (b[i] - d[j]) < abs(a[i] - c[min]) + abs(b[i] - d[min])) min = j;
      }
    }
    cout << min + 1 << endl;
  }

  return 0;

}


Measured memory_bytes: 256