akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>

using namespace std;


int main() {

    string S, T;
    cin >> S >> T;
    int cnt = 0;
    for(int i = 0 ; i < S.length(); i++)
    {
        if(S[i]==T[i]) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


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

#define long long long

using namespace std;

const int N = 3e3+5;

int n, M;
long fac[N], inv[N], dp[N][N];

long modpow(long a, long b) {
    long ret = 1;
    for( ; b; b >>= 1) {
        if(b & 1) ret = ret * a % M;
        a = a * a % M;
    }
    return ret;
}

long ncr(int a, int b) {
    if(a < b) return 0;
    return fac[a] * inv[b] % M * inv[a - b] % M;
}

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

    for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) {
        if(i == 0 && j == 0) dp[i][j] = 1;
        else {
            if(i && j) dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % M;
            if(i) dp[i][j] = (dp[i][j] + dp[i-1][j] * (j + 1) % M) % M;
        }
    }

    fac[0] = inv[0] = 1;
    for(int i = 1; i < N; i++) {
        fac[i] = fac[i-1] * i % M;
        inv[i] = modpow(fac[i], M - 2);
    }

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

        long mul = modpow(2, n - i), k = 1;
        for(int j = 0; j <= i; j++) {
            add = (add + dp[i][j] * k % M) % M;
            k = k * mul % M;
        }
        long p = 2;
        for(int j = 1; j <= n - i; j++) p = p * p % M;
        add = add * ncr(n, i) % M * p % M;

        if(i & 1) ans = (ans - add + M) % M;
        else ans = (ans + add) % M;
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 70784
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
class Dice {
	int num[6];
public:
	Dice(int a,int b,int c,int d,int e,int f) {
		num[0] = a; num[1] = b; num[2] = c;
		num[3] = d; num[4] = e; num[5] = f;
	}

	void rotate(char c) {
		assert(c == 'N' || c == 'S' || c == 'E' || c == 'W');
		int memo = num[0];
		if (c == 'N') {
			num[0] = num[1];
			num[1] = num[5];
			num[5] = num[4];
			num[4] = memo;
		}
		else if (c == 'S') {
			num[0] = num[4];
			num[4] = num[5];
			num[5] = num[1];
			num[1] = memo;
		}
		else if (c == 'E') {
			num[0] = num[3];
			num[3] = num[5];
			num[5] = num[2];
			num[2] = memo;
		}
		else {
			num[0] = num[2];
			num[2] = num[5];
			num[5] = num[3];
			num[3] = memo;
		}
	}

	int getNum(int index) { return num[index]; }
};
int a[6];
string s;
signed main() {
	rep(i, 6)cin >> a[i];
	cin >> s;
	Dice dice(a[0], a[1], a[2], a[3], a[4], a[5]);
	rep(i, s.size())dice.rotate(s[i]);
	cout << dice.getNum(0) << endl;
}


Measured memory_bytes: 3160
import java.util.*;
import java.io.*;
import java.lang.*;

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

        String s = sc.next();

        if (s.charAt(s.length()-1) == 's')
            System.out.println(s+"es");
        else
            System.out.println(s+'s');
    }
}

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

int main()
{
    int a, b;

    cin >> a >> b;

    if (a > b) {
        cout << "a > b" << endl;

    }

    if (a < b) {
        cout << "a < b" << endl;
    }

    if (a == b) {
        cout << "a == b" << endl;
    }

    return 0;
    }


Measured memory_bytes: 3104
def main():
    n, k = map(int, raw_input().split())
    s = 0
    aa = k / 2 if k % 2 == 0 else k
    for a in xrange(aa, n + 1, aa):
        b_min = (a / k + 1) * k - a
        if b_min < a:
            s += ((n - (a / k + 1) * k + a) / k + 1) * ((a - b_min) / k) * 2
        s += (n - ((a / k + 1) * k - a)) / k + 1
    print s


main()


Measured memory_bytes: 29420
n,x,y=map(int, input().split())
es=[[] for _ in range(n)]
for i in range(n):
    if i<n-1:
        es[i].append(i+1)
    if i>0:
        es[i].append(i-1)
    es[x-1].append(y-1)
    es[y-1].append(x-1)

from collections import deque, defaultdict

def bfs(s,es):
    d=[-1]*n
    d[s]=0
    que=deque()
    que.append(s)
    while que:
        p=que.popleft()
        cnt=d[p]+1
        for e in es[p]:
            if d[e]!=-1:
                continue
            que.append(e)
            d[e]=cnt
    return d

x=[]

for i in range(n):
    x+=bfs(i,es)[i:]
    
x=sorted(x)
#print(x)
from bisect import bisect_left, bisect_right

for i in range(1,n):
    l=bisect_left(x,i)
    r=bisect_right(x,i)
    print(r-l)

Measured memory_bytes: 126712
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int INF = 1000000000;

int main(){
    int n; cin >> n;
    vector<int> a(n), dp(n, INF);

    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    for(int i = 0; i < n; i++){
        *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
    
    auto ite = lower_bound(dp.begin(), dp.end(), INF);
    cout << distance(dp.begin(), ite) << endl;
    
    return 0;
}

Measured memory_bytes: 1788
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long x = sc.nextLong();
		long result = 0;
		long pre = 0;
		for(int i = 0; i < n; i++){
		    long a = sc.nextLong();
		    if(i == 0){
		        pre = a;
		    }else{
		        result += max(0, a+pre-x);
		        pre = max(0, a-max(0, a+pre-x));
		    }
		}
		
		// 計算
		//long result = 0;
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 43696
import           Control.Monad
import           Control.Applicative
import           Data.List
import qualified Data.Map                      as M
import           Data.Char
--import qualified Data.Vector as V
--import qualified Data.Vector.Mutable as VM

getBysplit = map read . words <$> getLine

main :: IO ()
main = do
  [n, k] <- getBysplit :: IO [Int]
  s      <- getLine
  putStrLn $ solve [] s (k - 1)


solve :: String -> String -> Int -> String
solve acc s 0 = acc ++ (f s)
 where
  f :: String -> String
  f []       = undefined
  f (x : xs) = (toLower x) : xs
solve acc (s : xs) k = solve (acc ++ [s]) xs (k - 1)


Measured memory_bytes: 508
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);

int main(){
  int N, cnt=0;
  cin >> N;
  int C[N];
  rep(i, N){
    cin >> C[i];
  }
  int B[9] = {0};
  rep(i, N){
    rep(j, 8){
    if(400*j <= C[i] && C[i] < 400*(j+1))
      B[j]++;
     }
  }
  rep(i, N){
    if(C[i] >= 3200)
    B[8] ++;
  }
  rep(i, 8){
    if(B[i] !=0 )
      cnt ++;
  }
  int min;
  if(B[8] == N) min = 1;
  else min = cnt;
  int max = cnt + B[8];
  cout << min << " " <<max <<  endl;
}

Measured memory_bytes: 256
//include tourist
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){ 
  ll a, b, k;
  cin >> a >> b >> k;
  ll res = 0;
  ll aa = a, bb = b;
  if (a > k) aa -= k;
  else aa = 0;
  k = max(0LL, k - a);
  if (b > k) bb -= k;
  else bb = 0;
  cout << aa << " " << bb << endl;
  return 0;
} 

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

int _; 

const int mod=1e9+7;

int n;
long long a1=1,a2=1,a3=1,a4=1; 

int main()
{	
	//for(scanf("%d",&_);_;_--)
	scanf("%d",&n);
	if(n <= 1)
		return printf("0\n"),0;
	n -= 2;
	for(int i=0;i<2+3*(n+1);i++)
	{
		a1 <<= 1;
		a1 %= mod;
	} 
	for(int i=0;i<n+1;i++)
	{
		a2 <<= 1;
		a2 %= mod;
	}
	for(int i=0;i<n+2;i++)
	{
		a3 *= 5;
		a3 %= mod;
	} 
	for(int i=0;i<n+2;i++)
	{
		a4 *= 9;
		a4 %= mod;
	} 
	printf("%lld\n",((a1+a2*a3-a4) << 1)%mod);
	return 0;
}  
// 2^(2+3*(n+1))+2^(n+1)*5^(2+n)-9^(2+n)

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<char>> vec(N,vector<char>(M));
  for (int i = 0; i < N; i++) {
    for(int j=0; j<M; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  vector<int> aisu(N);
  for(int i=0; i<N; i++){
    int a=0;
    for(int j=0; j<M;j++){
      if(vec.at(i).at(j)=='.'){
        a++;
      }
    }
    if(a==M){
      aisu.at(i)=1;
      
    }
    else
      aisu.at(i)=2;
  }
  
  for(int i=0; i<M; i++){
    int a=0;
    for(int j=0; j<N; j++){
      if(vec.at(j).at(i)=='.')
        a++;
    }
    if(a==N){
      for(int j=0; j<N; j++){
        vec.at(j).at(i)='0';
      }
    }
  }
  for(int i=0; i<N; i++){
    if(aisu.at(i)==1)
      continue;
    for(int j=0; j<M; j++){
      if(vec.at(i).at(j)!='0'){
        cout<<vec.at(i).at(j);
      }
    }
    cout<<endl;
  }

}



Measured memory_bytes: 3600
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Q = sc.nextInt();
    Node[] map = new Node[N + 1];
    for (int i = 0; i < map.length; i++) {
      map[i] = new Node(i, 0);
    }
    for (int i = 0; i < N - 1; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      map[a].to.add(b);
      map[b].to.add(a);
    }
    int[] X = new int[N + 1];
    for (int i = 0; i < Q; i++) {
      int p = sc.nextInt();
      int x = sc.nextInt();
      X[p] += x;
    }
    boolean[] isVisited = new boolean[N+1];
    Queue<PNode> queue = new ArrayDeque<>();
    queue.add(new PNode(-1, map[1]));
    while (!queue.isEmpty()) {
      PNode pnode = queue.poll();
      Node cur = pnode.me;
      if (isVisited[cur.n]) continue;
      isVisited[cur.n] = true;
      cur.weight += X[cur.n];
      for (Integer next : cur.to) {
        if (next != pnode.paren) {
          map[next].weight += cur.weight;
          queue.add(new PNode(cur.n, map[next]));
        }
      }
    }
    System.out.print(map[1].weight);
    for (int i = 2; i <= N; i++) {
      System.out.print(" " + map[i].weight);
    }
  }

  static class Node {
    int n, weight;
    ArrayList<Integer> to = new ArrayList<>();

    Node(int n, int weight) {
      this.n = n;
      this.weight = weight;
    }
  }
  static class PNode {
    int paren;
    Node me;
    PNode(int paren, Node me) {
      this.paren = paren;
      this.me = me;
    }
  }
}

Measured memory_bytes: 211468
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

typedef long long ll;

const int MAX_N = 200000;

vector<int> graph[MAX_N];
vector<int> used(MAX_N, 0);

pair<int, ll> dfs(int node, ll dist) {
  used[node] = 1;
  pair<int, ll> ret = {node, dist};
  for (int next_node : graph[node]) {
    if (used[next_node]) continue;
    pair<int, ll> q = dfs(next_node, dist + 1);
    if (ret.second < q.second) {
      ret = q;
    }
  }
  return ret;
}

ll calc_diameter() {
  pair<int, ll> u = dfs(0, 0);
  used = vector<int>(MAX_N, 0);
  return dfs(u.first, 0).second;
}

signed main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  int n, a, b;
  cin >> n;

  for (int i = 0; i < n - 1; ++i) {
    cin >> a >> b;
    --a;
    --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  if (calc_diameter() % 3 != 1) {
    cout << "First\n";
  } else {
    cout << "Second\n";
  }
}


Measured memory_bytes: 23296
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n,m;
  std::cin>>n>>m;

  std::vector<ll> fib(n+10,0);
  fib[1]=1;
  fib[2]=1;

  rep(i,3,n+10)fib[i]=(fib[i-1]+fib[i-2])%MOD;
  std::vector<ll> a(m);
  rep(i,0,m)std::cin>>a[i];

  if(m==0){
    std::cout<<fib[n+1]<<"\n";
    return 0;
  }

  ll ans=1;

  rep(i,0,m-1){
    ans*=fib[a[i+1]-a[i]-1];
    ans%=MOD;
  }

  ans*=fib[a[0]];
  ans%=MOD;
  ans*=fib[n-a[m-1]];
  ans%=MOD;

  std::cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	ll L, R;
	ll mod = 2019;

	cin >> L >> R;

	ll min = 10000;
	for (ll i = L; i <= R; i++) {
		for (ll j = i + 1; j <= R; j++) {
			int m = (i % mod) * (j % mod) % mod;
			if (m < min) {
				min = m;
			}
			if (m == 0) {
				cout << "0" << endl;
				return 0;
			}
		}
	}

	cout << min << endl;

	return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    string S, T;
    cin >> S;
    cin >> T;
    int N = S.size();
    int ans = 0;
    for_(i,0,N) if (S[i] != T[i]) ++ans;
    cout << ans << endl;
}

Measured memory_bytes: 3864
#include <stdio.h>

int main()
{

int n,l;    

    int a[300],i,m=0;
    
    scanf("%d %d",&n,&l);

    for(i=0;i<n;i++)
    {
        a[i] = l+i;
        m += a[i]; 
    }

    for(i=0;i<n;i++)
    {
        if(a[i] == 0)
        {
            break;
        }

        if(i>0&&a[i] > 0)
        {

            if(a[i-1]*-1 > a[i])
            {
                m -= a[i];
            }
            else
            {
                m -= a[i-1];
            }
            break;
        }
        else if(i==0 && a[i] > 0)
        {
            m -= a[i];
            break;
        }
        


    }

    if(i == n)
        m -= a[i-1];


    printf("%d\n",m);


    return 0; 
}

Measured memory_bytes: 128
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> num_turn_w(N, 0);
	vector<int> num_turn_e(N, 0);

	string S;
	cin >> S;

	REP(i, N) {
		if (i > 0) {
			num_turn_w[i] = num_turn_w[i - 1] + (S[i - 1] == 'W');
		}
		//cout << num_turn_w[i];
	}
	//cout << endl;

	REP(i, N) {
		if (i > 0) {
			num_turn_e[i] = num_turn_e[i - 1] + (S[N  - i] == 'E'); 
		}
	}
	//REP(i, N) {
	//	cout << num_turn_e[N - 1 - i];
	//}


	//cout << endl;

	int min_num_turn = 1e9;

	REP(i, N) {
		min_num_turn = min(min_num_turn, num_turn_w[i] + num_turn_e[N - 1 - i]);
	}

	cout << min_num_turn << endl;

	return 0;
}


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

typedef long long ll;
ll N;


ll Divsa(ll n)
{   
    ll res = 0;
    for(ll i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            res++;
            if(i * i != n) res++;
        }
    }
    res--;
    return res;
}

ll Divs(ll n, ll i, ll &res)
{   
    if(i == 1) return 0;
    ll tmp = n;
    while(tmp % i == 0) tmp = tmp / i;
    if(tmp % i == 1 && tmp < n) res++;
    return 0;
}

ll Divsb(ll n)
{
    ll res = 0;
    ll tmp = n;
    for(ll i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            Divs(n, i, res);
            if(i * i != n) Divs(n, n / i, res);
        }
    }
    return res;
}




int main()
{
    cin >> N;

    cout << Divsa(N - 1) + Divsb(N) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

const int MAX = 3000;
int N, A[MAX];
bool vis[MAX][MAX + 1];
ll memo[MAX][MAX + 1];

ll dp(int L, int R) {
    if (L >= R) return 0;
    if (vis[L][R]) return memo[L][R];
    vis[L][R] = true;

    int diff = N - (R - L);

    ll res = 0;
    if (diff % 2 == 0) {
        res = max(dp(L + 1, R) + A[L], dp(L, R - 1) + A[R - 1]);
    } else {
        res = min(dp(L + 1, R) - A[L], dp(L, R - 1) - A[R - 1]);
    }
    return memo[L][R] = res;
}

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

    cout << dp(0, N) << endl;
    return 0;
}

Measured memory_bytes: 79488
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long N, K;
    cin >> N >> K;
    long long ans = 0;
    if(K == 0){
        for(int i = K + 1; i <= N; i++) ans += N;
        cout << ans << endl;
        return 0;
    }
    for(int i = K + 1; i <= N; i++){
        ans += (N / i) * (i - K);
        if(N % i >= K) ans += N % i - K + 1;
    }
    cout << ans << endl;
}

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

using namespace std;
#define ll long long
#define ld long double
#define eb emplace_back
#define mod 1000000007
#define pii pair<int, int>

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k;
    cin >> k;
    
    for(int i=0; i < k; i++){
        cout << "ACL";
    }
}


Measured memory_bytes: 3612
n,m=map(int,input().split())
h=list(map(int,input().split()))
good=set(range(n))
for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]<=h[b-1]:
        good.discard(a-1)
    if h[b-1]<=h[a-1]:
        good.discard(b-1)
print(len(good))

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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

    if(N/100==7||(N%100)/10==7||N%10==7){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3648
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
import Debug.Trace
-- trace _ = id

solve :: Int -> [Int] -> String
solve bN as | (n2 == 0 && n1 - 1 <= n4) || n1 <= n4 = "Yes"
            | otherwise = "No"
  where
    as2 = filter (\x -> x `mod` 2 == 0) as
    as4 = filter (\x -> x `mod` 4 == 0) as2
    n4 = length as4
    n2 = length as2 - n4
    -- n1 = traceL "x" (n1X,n2,n4) n1X
    n1 = bN - (n2 + n4)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> String
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN]:remLines1 = remLines0
      bN = readBInt bs_bN
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve bN as

outAnswer :: String -> IO ()
outAnswer = putStrLn

main :: IO ()
main = outAnswer . tmain =<< B.getContents

traceL :: Show a => String -> a -> b -> b
traceL label showObj val = trace (label ++ " " ++ show showObj) val

traceLM :: (Monad m, Show a) => String -> (b -> a) -> m b -> m b
traceLM label showFn act = do
  aaa <- act
  traceL label (showFn aaa) (return ())
  return aaa


-------------------------------------------------------------------------------

inp1 = "3\n1 10 100\n"
inp2 = "4\n1 2 3 4\n"
inp3 = "3\n1 4 1\n"
inp4 = "2\n1 1\n"
inp5 = "6\n2 7 1 8 2 8\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
tv4 = tmain $ B.pack inp4
tv5 = tmain $ B.pack inp5
test1 = tv1 == "Yes"
test2 = tv2 == "No"
test3 = tv3 == "Yes"
test4 = tv4 == "No"
test5 = tv5 == "Yes"
alltest = test1 && test2 && test3 && test4 && test5



Measured memory_bytes: 8060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ln "\n"
#define pb push_back
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vector<ll>>
#define sll stack<ll>
#define qll queue<ll>
#define mp make_pair
#define f first
#define s second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define Test ll t;cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define init(x,n,v) for(ll i=0;i<=n;i++) x[i]=v; 
ll MOD = 1e9 + 7 , MAX = 1e18;
int main() 
{
	fast_io;
	string s;
	cin>>s;
	ll n,i,j;
	n=s.size();
	vll l,ans(n);
	i=0;
	while(i<n)
	{
	    while(i<n && s[i]=='R') i++;
	    l.pb(i);
	    while(i<n && s[i]=='L') i++;
	}
	j=0,i=0;
	while(i<n)
	{
	    while(i<n && s[i]=='R') 
	    {
	        if((l[j]-i)%2) ans[l[j]-1]++;
	        else ans[l[j]]++;
	        i++;
	    }
	    l[j]--;
	    while(i<n && s[i]=='L')
	    {
	        if((i-l[j])%2) ans[l[j]+1]++;
	        else ans[l[j]]++;
	        i++;
	    }
	    j++;
	}
	for(auto k: ans) cout<<k<<" ";
	return 0;
}

Measured memory_bytes: 1864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    string s;   cin >> s;
    int k;  cin >> k;
    vector<vector<ll>> state(26);
    REP(i, s.size()){
        state[s[i]-'a'].push_back(i);
    }
    map<string, int> mp;
    REP(i, 26){
        for(auto x: state[i])
            REP(j, min((int)s.size(), k)) mp[s.substr(x,j+1)] += 1;
        
        if(k<=mp.size()) break;
    }
    int cnt=0;
    for(auto x: mp){
        cnt += 1;
        if(cnt<k) continue;
        cout << x.first << endl; return 0;
    }
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans1 = a*x + b*y;
		int ans2 = 2*c*Math.min(x, y);
		if(x>y)ans2 += (x-y)*a;
		else if(x<y)ans2 += (y-x)*b;
		int ans3 = 2*c*Math.max(x, y);
		System.out.println(Math.min(ans1, Math.min(ans2, ans3)));
	}

}


Measured memory_bytes: 23124
/*input
4
1 1 1 1

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define mod 1000000007
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE

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

#define out(container) cout << #container << " "; for (auto it : container) cout << it << " "; cout << endl;

template < typename T> int sz(T x) {return x.size();}
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
    int x = 1 % mod;
    while(b){
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

bool isPrime (ll n) {
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}


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

  int n, m;
  cin >> n >> m;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  int dp[n + 1];
  memset(dp, 0, sizeof(dp));
  map <int, int> mp;
  int v;
  for (int i = 0; i < m; i++) {
    cin >> v;
    mp[v] = 1;
  }
  dp[0] = 1;
  if (mp[1] == 0) dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (mp[i] == 1) continue;
    dp[i] = add(dp[i - 1], dp[i - 2]);
  }
  cout << dp[n] << endl;


  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll res_a,res_b;

    if(c <= a)
    {
      res_a = a - c;
      res_b = b;
    }
    else
    {
      c -= a;

      res_a = 0;
      res_b = max(0ll, b - c);
    }


    cout << res_a << " " << res_b << endl;

    return 0;    
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	// Atcoder用のサンプルプログラム
	public static void main(String[] args) {
		String line = "";
		try {
			line = readLine();

			StringTokenizer st = new StringTokenizer(line, " ");
			String tempK = st.nextToken();
			String tempS = st.nextToken();

			int k = Integer.parseInt(tempK);
			int s = Integer.parseInt(tempS);
			int cnt = 0;
			// x y S-x-y
			for (int i = 0; i < s + 1; i++) {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			}
			System.out.println(cnt);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}

}


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

int main() {
int n; cin>>n;
  if(n>=28){cout<<"Yes"<<endl;
  return 0;}
  for(int i=0;i<=7;i++){
    if(n-4*i>=0&&(n-4*i)%7==0){
      cout<<"Yes"<<endl;
      return 0;}
  }
    cout<<"No"<<endl;
    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  vector<int> v(3);
  rep(i, 3) cin >> v[i];
  sort(rall(v));
  int k;
  cin >> k;
  rep(i, k) v[0] *= 2;

  int ans = 0;
  rep(i, 3) ans += v[i];

  cout << ans << endl;
}


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

int main() {

	int N;
	cin >> N;

	int L;
	int sum = 0;
	int m = 0;

	for (int i = 0; i < N; i++) {
		cin >> L;
		sum += L;
		m = max(m, L);
	}

	if (m < sum - m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

std::string getInitial(std::string word);
 
int main() {
    std::string firstWord;
    std::string secondWord;
    std::string thirdWord;
    std::cin >> firstWord >> secondWord >> thirdWord;
    
    std::string abbreviation = getInitial(firstWord) + getInitial(secondWord) + getInitial(thirdWord);
    
    std::cout << abbreviation << std::endl;    
}

std::string getInitial(std::string word) {
    return std::string {word.at(0)};
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int maxn=405;
int n;
int64 a[maxn],f[maxn][maxn];
void Input()
{
    cin >> n;
    FOR(i,1,n) {
        cin >> a[i];
        a[i]+=a[i-1];
    }
}
int64 calc(int l, int r)
{
    if (l==r) return 0;
    int64 &res=f[l][r];
    if (res!=-1) return res;
    res=1e18;
    FOR(k,l,r-1)
        res=min(res,calc(l,k)+calc(k+1,r));
    return (res+=a[r]-a[l-1]);
}
void Solve()
{
    fillchar(f,sizeof(f),255);
    cout << calc(1,n);
}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF=1e9+7;
int n, m;
vector<int> g[1010], gr[1010];
int calc(int a, int b, vector<int>& ret){
	int d[1010];
	fill(d, d+n, INF);
	d[a]=0;
	queue<int> que;
	que.push(a);
	while(!que.empty()){
		int x=que.front();
		que.pop();
		for(auto y:g[x]){
			if(d[y]>d[x]+1){
				d[y]=d[x]+1;
				que.push(y);
			}
		}
	}
	if(d[b]==INF) return d[b];
	int x=b;
	ret.push_back(b);
	while(x!=a){
		for(auto y:gr[x]){
			if(d[y]==d[x]-1){
				x=y;
				ret.push_back(x);
				break;
			}
		}
	}
	reverse(ret.begin(), ret.end());
	return d[b];
}
int main()
{
	cin>>n>>m;
	for(int i=0; i<m; i++){
		int a, b; cin>>a>>b; a--; b--;
		g[a].push_back(b); gr[b].push_back(a);
	}
	int mn=INF;
	vector<int> ans;
	for(int a=0; a<n; a++){
		for(auto b:g[a]){
			vector<int> ret;
			int d=calc(b, a, ret);
			if(d<mn){
				ans=ret;
				mn=d;
			}
		}
	}
	if(mn==INF){
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans.size()<<endl;
	for(auto x:ans) cout<<x+1<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include <stdlib.h>

int main()
{
    int h, w, sum=0, min=1000000;
    double p = 3.1415;
    int max = 1-1000001;

    
    while (1){
        scanf("%d%d", &h, &w);
        if(h==0 && w==0){
            break;
        }
        else {
            for (int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if ( (i+j) % 2 == 0){
                    printf("#");
                    }else {
                        printf(".");
                        }        
                    
                }
                printf("\n");
            }
            printf("\n");
        }
    }
        return 0;
}           


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];
    REP(i, N) A[i]--;

    if(K == 1){
        cout << 0 << endl;
        return 0;
    }

    vector<long long> B(N+1);
    REP(i, N)
        B[i+1] = (B[i] + A[i]) % K;

    long long ans = 0;
    map<long long, long long> mp;

    mp[0] = 1;
    REP(i, 1, N+1){
        ans += mp[B[i]];
        mp[B[i]]++;
        if(i-K+1 >= 0)
            mp[B[i-K+1]]--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k,c = LI()
s = input()
l,r = [0]*k, [0]*k
i = 0
cnt = 0
while i < n:
    if s[i] == 'o':
        if cnt >= k:
            quit()
        l[cnt] = i
        cnt += 1
        i += c
    i += 1
i = n-1
cnt = k-1
while i >= 0:
    if s[i] == 'o':
        if cnt < 0:
            quit()
        r[cnt] = i
        cnt -= 1
        i -= c
    i -= 1
for i in range(k):
    if l[i] == r[i]:
        print(l[i]+1)

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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

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

int main() {
  ll N, M;
  cin >> N >> M;
  if (N == 1 && M == 1) {
    cout << 1 << endl;
  } else if (N == 1 || M == 1) {
    if (N > M) {
      swap(N, M); // N = 1;
    }
    cout << M - 2 << endl;
  } else {
    cout << (M-2)*(N-2) << endl;
  }

  return 0;
};


Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
cnt=0
ans=0
for i in range(n):
    cnt+=a[i]
    if cnt==x:
        ans=i+1
        break
    elif cnt>x:
        ans=i
        break
    elif i==n-1:
        ans=n-1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;

main(){
    int n;cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    ll dp[n][3];
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

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

Measured memory_bytes: 7032
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    N, M = LI()
    P = [0]*N
    S = [LSI()for _ in range(M)]
    pena = 0
    ac = set()
    for p,s in S:
        p = int(p)-1
        if s=="WA":
            P[p] += 1
        else:
            if p in ac:
                continue
            ac.add(p)
            pena += P[p]

    print(len(ac),pena)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

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

    char a1[300000], a2[300000];

    int Q;
    cin >> Q;
    int count = 0;
    int i1 = 0, i2 = 0;
    for (int i = 0; i< Q; i++) {
        int T, F;
        char C;
        scanf("%d", &T);
        if (T == 1) count++;
        else {
            cin >> F >> C;
            if (count % 2) {
                if (F == 1) {
                    a2[i2] = C;
                    i2++;
                } else {
                    a1[i1] = C;
                    i1++;
                }
            } else {
                if (F == 1) {
                    a1[i1] = C;
                    i1++;
                } else {
                    a2[i2] = C;
                    i2++;
                }
            }
        }
    }

    if (count % 2) {
        for (int i = i2; i >= 1; i--) {
            putchar(a2[i-1]);
        }
        reverse(S.begin(), S.end());
        cout << S;
        for (int i = 0; i < i1; i++) {
            putchar(a1[i]);
        }
    } else {
        for (int i = i1; i >= 1; i--) {
            putchar(a1[i-1]);
        }
        cout << S;
        for (int i = 0; i < i2; i++) {
            putchar(a2[i]);
        }
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 1024
f=lambda:map(int,input().split())
g=range
R,C,K=f()
a=[[0]*(R+1) for _ in g(C+1)]
for _ in g(K):
  r,c,v=f()
  a[c][r]=v
dp=[[0]*4 for _ in g(R+1)]
for i in g(1,C+1):
  for j in g(1,R+1):
    t=a[i][j]
    if t:
      for k in [3,2,1]:
        dp[j][k]=max(dp[j][k],dp[j][k-1]+t)
      dp[j][1]=max(dp[j][1],max(dp[j-1])+t)
    dp[j][0]=max(dp[j][0],max(dp[j-1]))
print(max(dp[R]))

Measured memory_bytes: 146456
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int k = input.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++){
            p[i] = input.nextInt();
        }
        Arrays.sort(p);
        int ans = 0;
        for (int i = 0; i < k; i++){
            ans += p[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 38548
use std::io;

fn main() {
    let (a, b) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let ans = (a + b - 3) / (a - 1);
    println!("{}", ans);
}

#[allow(unused)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}


#[allow(unused)]
fn read_one<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 2080
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, K; cin >> N >> K;
	ll res = 1;
	for (int i = 0; i < N;i++) {
		res = min(res + K, res * 2);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}


bool f[1001001];
int main(void){
	int s,ans=1;
	fill(f,f+1001001,false);
	cin >> s;
	while(!f[s]){
		f[s] = true;
		++ans;
		s = ((s%2)?(3*s+1):(s/2));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1280
N = int(input())
ans = [-1] * N
ans[0] = 0
root = [[] for i in range(N)]
for i in range(N - 1):
  u, v, w = map(int, input().split())
  root[u - 1].append([v - 1, w])
  root[v - 1].append([u - 1, w])
#print(root)

visited = [0] * N
visited[0] = 1
queue = [0]
while queue:
  x = queue.pop()
  for i, value in root[x]:
    if value % 2 == 0:
      ans[i] = ans[x]
    else:
      ans[i] = abs(1 - ans[x])
    if visited[i] == 0:
      visited[i] = 1
      queue.append(i)
      
#print(ans)      
for i in range(N):
  print(ans[i])
              
      
      
      
      
      



Measured memory_bytes: 46380
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  long long int X=0;
  cin >> N;
  vector<int> a(3*N);
  for (int i=0;i<3*N;i++){
    cin >> a[i];
  }
  sort(a.rbegin(),a.rend());
  for(int i=0;i<2*N;i+=2){
    X+=a[i+1];
  }
  cout << X << endl;
  return 0;
}

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

int main()
{
    int m_lb = (1868*10000)+9*100+8,
        t_lb = (1912*10000)+7*100+30,
        s_lb = (1926*10000)+12*100+25,
        h_lb = (1989*10000)+1*100+8;
    int y,m,d,now;
    while(cin>>y>>m>>d)
    {
        now = y*10000+m*100+d;
        if(now<m_lb){cout << "pre-meiji"<<endl;continue;}
        if(now<t_lb){cout << "meiji "<<y-1867 << " " <<m<<" "<< d<<endl; continue;}
        if(now<s_lb){cout << "taisho "<<y-1911 << " " <<m<<" "<< d<<endl; continue;}
        if(now<h_lb){cout << "showa "<<y-1925 << " " <<m<<" "<< d<<endl; continue;}
        cout << "heisei "<<y-1988 << " " <<m<<" "<< d<<endl; continue;

    }

    return 0;
}

Measured memory_bytes: 0
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int N, M;
	cin >> N;
	int a[N-1], b[N-1]; 
	for (int i=0; i<N; i++)
	{
		cin >> a[i];
	}
	b[0]=a[0];
	M=a[1]-b[0];
	for(int j=1; j<N-1; j++)
	{
		b[j]=min(b[j-1], a[j]);
		M=max(M, a[j+1]-b[j]);
	}
	cout << M << endl;
	return 0;
}

Measured memory_bytes: 2720
import math
a, b = map(int, input().split())
x0 = math.ceil(a * 100 / 8)
x1 = math.ceil((a + 1) * 100 / 8)
y0 = b * 10
y1 = (b + 1) * 10
if y1 <= x0 or x1 <= y0:
    print(-1)
else:
    print(max(x0, y0))

Measured memory_bytes: 62104
package main

import "fmt"

func main() {
	var o, e string
	fmt.Scan(&o, &e)
	ret := make([]rune, len(o)+len(e))
	index := 0
	for _, v := range o {
		ret[index] = v
		index += 2
	}
	index = 1
	for _, v := range e {
		ret[index] = v
		index += 2
	}
	fmt.Println(string(ret))
}


Measured memory_bytes: 1780