akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	string a;
	cin>>a;
	int b=0;
	fo(i,4){
	if(a[i]=='2')
		b++;
    }
	cout<<b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll N, M, i, X[100001], Y[100001], Z[100001];

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号  (例) par[3] = 2 : 3の親が2
    vector<ll> rank; // 木の深さ
    vector<ll> siz; // 集合のサイズを表す配列

    UnionFind(ll N) : par(N), rank(N), siz(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++){
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        x = root(x);
        y = root(y);
        if (x == y) return; //xとyの根が同じ(=同じ木にある)時はそのまま

        if(siz[x] < siz[y]){
            swap(x, y);
        }

        siz[x] += siz[y];
        par[y] = x;
        if(rank[x] == rank[y]) rank[x]++;
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    ll size(ll x){ // xが属する集合の要素数
        return siz[root(x)];
    }
};

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

    UnionFind tree(N);

    for(i=1; i<=M; i++){
        cin >> X[i] >> Y[i] >> Z[i];
        tree.unite(X[i]-1, Y[i]-1);
    }

    ll ans = 0;

    for(i=0; i<N; i++){
        if(tree.root(i)==i) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  cout << 'A' << char(toupper(s2[0])) << 'C' << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<long long> v(n);
    for(long long &i : v)
        cin >> i;
    long long ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++) {
            if (i != j) {
                ans = max(ans,abs(v[i]-v[j]));
            }
        }    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var H = parseInt(input[0].split(" ")[0]);
  var W = parseInt(input[0].split(" ")[1]);
  var A = new Array(H);
  var A = new Array(H+2);
  var C = new Array();
  var C1=new Array(W+2).fill(-1);
  A[0]=C1;
  for(var i=0;i<H;i++){
    var tmp=input[i+1].split("");
    for(var j=0;j<W;j++){
      if(tmp[j]=="#"){
        C.push([i+1,j+1]);
        tmp[j]=0;
      }
    }
    tmp.splice(0,0,-1);
    tmp.push(-1);
    A[i+1]=tmp;
  }
  A[H+1]=C1;
  var ans =0;
  for(var i=0;i<H*W;i++){
    if(A[C[i][0]+1][C[i][1]]=="."){
      A[C[i][0]+1][C[i][1]]=A[C[i][0]][C[i][1]]+1;
      C.push([C[i][0]+1,C[i][1]]);
      ans=Math.max(ans,A[C[i][0]][C[i][1]]+1);
    }
    if(A[C[i][0]-1][C[i][1]]=="."){
      A[C[i][0]-1][C[i][1]]=A[C[i][0]][C[i][1]]+1;
      C.push([C[i][0]-1,C[i][1]]);
      ans=Math.max(ans,A[C[i][0]][C[i][1]]+1);
    }
    if(A[C[i][0]][C[i][1]+1]=="."){
      A[C[i][0]][C[i][1]+1]=A[C[i][0]][C[i][1]]+1;
      C.push([C[i][0],C[i][1]+1]);
      ans=Math.max(ans,A[C[i][0]][C[i][1]]+1);
    }
    if(A[C[i][0]][C[i][1]-1]=="."){
      A[C[i][0]][C[i][1]-1]=A[C[i][0]][C[i][1]]+1;
      C.push([C[i][0],C[i][1]-1]);
      ans=Math.max(ans,A[C[i][0]][C[i][1]]+1);
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >>y;
  int ans = max(x, y) * 2 * c;
  if(a+b>c*2){
    ans = min(ans, c*2*min(x, y)+a*(x-min(x,y))+b*(y-min(x,y)));
  }else{
    ans = min(ans, a*x+b*y);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

A = [None]*(N+1)
A[0] = 0
cnt = 0
for i,s in enumerate(S[::-1]):
    if s=='.':
        A[i+1] = A[i]+1
    else:
        A[i+1] = A[i]-1
        cnt += 1
print(min(A)+cnt)

Measured memory_bytes: 11272
k = int(input())

run = [1,2,3,4,5,6,7,8,9]

val = ['' for i in range(10)]

kouho = []
#val = 0
#num = 0

def dfs(pos,keta,num):
    if keta == pos:
        #num += 1
        val[pos] = num
        #print(val)  
        tmp = 0
        for i in range(keta+1):
            #if val[keta-1-i] != '':
            tmp += val[i] * 10 ** (keta-i)
            #print(val[i],keta-i)
        #print(val)
        kouho.append(tmp)
        """
        if num == k:
            print(tmp)
            exit()
            #return tmp
        """
        #val = 0
        return
    
    for i in range(3):
        #print(i,kouho,num)
        val[pos] = num
        #print(val)
        if num-1+i > 9:
            continue
        if num-1+i < 0:
            continue
        dfs(pos+1,keta,num-1+i)
    
for i in range(10):
    for j in range(1,10):
        #print(i,j,j,j,j)
        dfs(0,i,j)
#print(kouho)
#exit()
print(kouho[k-1])

Measured memory_bytes: 12104
#include<iostream>
using namespace std;
int main(){
  int n,k,u,num;
  int g[150][150]={};
	
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>num;
      g[u][num]=1;          //numは各頂点を表す。
    }
  }
	
  for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++){
		cout<<g[i][j];
		if(j!=n){
			cout<<" ";
		}
	}
  	cout<<"\n";
  }
	return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;

  int c_a = 0;
  int c_bc = 0;

  ll ans = 0;

  REP(i, s.size()) {
    if (s[i] == 'A') {
      c_a++;
    } else if (s[i] == 'B' && s[i + 1] == 'C') {
      c_bc++;
      i++;
    } else {
      c_a = 0;
      c_bc = 0;
    }
    if (c_a && c_bc) {
      ans += c_a;
    }
    c_bc = 0;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define N 100005
int st[N],nd[N],a[N];
int pos[2*N],dfn[2*N],cnt,sum[N][2],s1;
int fa[N][20],dep[N],ans[N],n,m,an;
int g1[N][2];
bool f[N];
struct mzls
{
	int l,r,id,aa,bb;
	bool p;
}a1[N];
struct node
{
	int to,co,ct;
	node(){}
	node(int xx,int yy,int zz)
	{
		to=xx,co=yy,ct=zz;
	}
};
vector<node>g[N];
inline bool cmp(mzls x,mzls y)
{
	if(pos[x.l]!=pos[y.l])
		return pos[x.l]<pos[y.l];
	return x.r<y.r;
}
map<int,int>mp;
inline void dfs(int x)
{
	dfn[++cnt]=x;
	st[x]=cnt;
	dep[x]=dep[fa[x][0]]+1;
	for(int i=1;i<20;i++)
		fa[x][i]=fa[fa[x][i-1]][i-1];
	int l1=g[x].size();
	for(int i=0;i<l1;i++)
	{
		int v=g[x][i].to,co=g[x][i].co,ct=g[x][i].ct;
		if(v==fa[x][0])
			continue;
		fa[v][0]=x;
		g1[v][0]=co,g1[v][1]=ct;
		dfs(v);
	}
	dfn[++cnt]=x;
	nd[x]=cnt;
}
inline int LCA(int x,int y)
{
	if(dep[x]<dep[y])
		swap(x,y);
	for(int i=19;i>=0;i--)
		if(dep[fa[x][i]]>=dep[y])
			x=fa[x][i];
	if(x==y)
		return x;
	for(int i=19;i>=0;i--)
		if(fa[x][i]!=fa[y][i])
		{
			x=fa[x][i];
			y=fa[y][i];
		}
	return fa[x][0];
}
inline void modify(int x)
{
	if(!f[x])
	{
		sum[g1[x][0]][0]++;
		sum[g1[x][0]][1]+=g1[x][1];
		s1+=g1[x][1];
		f[x]=1;
	}
	else
	{
		sum[g1[x][0]][0]--;
		sum[g1[x][0]][1]-=g1[x][1];
		s1-=g1[x][1];
		f[x]=0;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		int x,y,x1,y1;
		scanf("%d%d%d%d",&x,&y,&x1,&y1);
		g[x].push_back(node(y,x1,y1));
		g[y].push_back(node(x,x1,y1));
	}
	dfs(1);
	int d=sqrt(n);
	for(int i=1;i<=2*n;i++)
		pos[i]=(i-1)/d;
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d%d%d",&a1[i].aa,&a1[i].bb,&a1[i].l,&a1[i].r);
		if(st[a1[i].l]>st[a1[i].r])
			swap(a1[i].l,a1[i].r);
		if(nd[a1[i].l]>st[a1[i].r])
		{
			x=st[a1[i].l]+1;
			y=st[a1[i].r];
			a1[i].p=0;
		}
		else
		{
			x=nd[a1[i].l];
			y=st[a1[i].r];
			a1[i].p=1;
		}
		a1[i].l=x;
		a1[i].r=y;
		a1[i].id=i;
	}
	sort(a1+1,a1+m+1,cmp);
	int l1=1,r1=0;
	for(int i=1;i<=m;i++)
	{
		while(l1>a1[i].l)
			modify(dfn[--l1]);
		while(l1<a1[i].l)
			modify(dfn[l1++]);
		while(r1<a1[i].r)
			modify(dfn[++r1]);
		while(r1>a1[i].r)
			modify(dfn[r1--]);
		int lc=LCA(dfn[l1],dfn[r1]);
		//if(a1[i].p)
		//	modify(lc);
		ans[a1[i].id]=s1-sum[a1[i].aa][1]+sum[a1[i].aa][0]*a1[i].bb;
		//if(a1[i].p)
		//	modify(lc);
	}
	for(int i=1;i<=m;i++)
		printf("%d\n",ans[i]);
	return 0;
}


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

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    long long h[n];
    for(int i=0;i<n;++i) {
        cin>>h[i];
    }
    long long dp[n];
    for(int i=0;i<n;++i) {
        dp[i] = 10000000000000;
    }
    dp[0] = 0;
    for(int i=1;i<n;++i) {
        for(int j=i-1;j>=max(0,i-k);--j) {
            dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
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();

    	if (b == 1) {
            System.out.println(0);
    		return;
    		//1個だけなら、0返す。
        }
        int res = 1;
        int total = a;
        while (total < b) {
          //個数分ループ
          total += (a - 1);
          //繋げようタブを引き
            res += 1;
        }
        System.out.println(res);
    }

}


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){
  size_t len = s.length();
  if(len == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}


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

    long double cur = 100;
    ll y = 1;

    while(true){
      cur =  floor(cur * 1.01);
      
      if(cur >= X){
        cout << y << endl;
        return 0;
      }
      y++;
    }
}

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

int main() {
  int N,D; cin >> N >> D;
  int ans = 0;
  
  vector<vector<int>> data(N,vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> data.at(i).at(j);
    }
  }
  
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      int d2=0;
      for(int k=0;k<D;k++){ //d^2を計算
        d2 += 
           (data.at(i).at(k) - data.at(j).at(k))
            * (data.at(i).at(k) - data.at(j).at(k));
      }
      
      //整数か判定
      for(int l=0;l<=d2;l++){
        if(l*l == d2) ans++;
      }
      
    }
  }
  
  cout << ans << endl;
}


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

int dp[500][500];

int main() {
    int H, W;
    cin >> H >> W;

    rep(i, 10) rep(j, 10) {
        int c;
        cin >> c;
        dp[i][j] = c;
    }

    vector<vector<int>> A(H, vector<int>(W));
    rep(i, H) rep(j, W) cin >> A[i][j];

    for(int k = 0; k < 10; ++k) {
        for(int i = 0; i < 10; ++i) {
            for(int j = 0; j < 10; ++j) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
        }
    }

    int ans = 0;
    rep(i, H) rep(j, W) if (A[i][j] != -1) ans += dp[A[i][j]][1];
    cout << ans << endl;
}

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

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p%i == 0) return false;
	}
	return true;
}

int n;

int main() {
	cin >> n;
	for (int i = 11; i <= 55555; i += 5) {
		if (isprime(i) == true) {
			if (i != 11) cout << " ";
			cout << i; n--;
		}
		if (n == 0) break;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
from_zero_count = 0
from_one_count = 0
for i in range(N):
  if i%2 == 0 and S[i] == "0":
    from_one_count += 1
  elif i%2 == 0 and S[i] == "1":
    from_zero_count += 1
  elif i%2 == 1 and S[i] == "0":
    from_zero_count += 1
  elif i%2 == 1 and S[i] == "1":
    from_one_count += 1
print(min([from_one_count, from_zero_count]))

Measured memory_bytes: 3188
n = int(input())
food = [[int(i) for i in input().split()] for _ in range(n)]
food.sort(key=lambda x:sum(x),reverse=True)
hpns = [0,0]
for i in range(n): hpns[i%2] += food[i][i%2]
print(hpns[0]-hpns[1])

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


int main(){
    long N,M;
    cin>>N>>M;
    pair<long,long>itv[N];
    for(int i=0;i<N;i++)cin>>itv[i].first>>itv[i].second;

    sort(itv,itv+N);
    long ans=0,s=0;
    for(long i=0;i<N;i++){
        if(s+itv[i].second<M){
            s+=itv[i].second;
            ans+=itv[i].first*itv[i].second;
        }
        else{
            ans+=(M-s)*itv[i].first;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <bits/stdc++.h> 
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
 
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 
 
using namespace std;
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();  	
}

void solve() {
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int num; cin >> num;
        if (num >= k) {
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(){
  int a, b, k; cin >> a >> b >> k;
  if ( a-b-2 >= -2*k ) {
    for ( int i = a; i < b+1; i++ ) {
    cout << i <<endl;
  }
  }
  else{
    for ( int i = a; i < a+k; i++ )  cout << i << endl;
    for ( int i = b-k+1; i < b+1; i++ )   cout << i<< endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  int n;
  cin >> n;
  vi fib(50, -1);
  fib.at(0) = 1;
  fib.at(1) = 1;

  for(int i = 2; i <= n; i++){
    fib.at(i) = fib.at(i-1) + fib.at(i-2);
  }
  cout << fib.at(n) << endl;
}



Measured memory_bytes: 3112
D, G = map(int, input().split())
p = []
c = []
for _ in range(D):
    pi, ci = map(int, input().split())
    p.append(pi)
    c.append(ci)

res = 10**9
# どの問題を全完するか決め打つ
for bit in range(1 << D):
    sum = 0
    num = 0

    # bitが立っている = 全完する問題について
    for i in range(D):
        if bit & (1 << i):
            sum += c[i] + p[i] * 100 * (i + 1)
            num += p[i]

    # 既にGを超えていたら「中途半端に」解く必要はない
    if sum >= G:
        res = min(res, num)

    # 「中途半端に」解く必要がある場合
    else:
        # どの問題を「中途半端に」解くか
        # 全完していない問題のうち、最も点数が高いもの
        # 全て全完している場合に注意
        d = -1
        for i in range(D - 1, -1, -1):
            if not(bit & (1 << i)):
                d = i
                break
        if d == -1:
            continue
        else:
            # 全完１歩手前まで順に試す
            for j in range(p[d] - 1):
                sum += 100 * (d + 1)
                num += 1
                if sum >= G:
                    break
            # p-1問解いてもGに達していない場合に注意
            if sum >= G:
                res = min(res, num)

print(res)


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int n; cin >> n;
        vector<int> a(n); cin >> a;


        auto pos = [](vector<int> a) -> ll {
                ll sum = 0, ans = 0;
                for (int i = 0; i < sz(a); i++) {
                        int temp = a[i];
                        sum += a[i];
                        if (sum <= 0 && i % 2 == 0) {
                                sum -= a[i], a[i] = 1 - sum, sum += a[i];
                        } else if (sum >= 0 && i & 1) {
                                sum -= a[i], a[i] = -1 - sum, sum += a[i];
                        }
                        ans += abs(temp - a[i]);
                }

                return ans;
        };

        auto neg = [](vector<int> a) -> ll {
                ll sum = 0, ans = 0;
                for (int i = 0; i < sz(a); i++) {
                        int temp = a[i];
                        sum += a[i];
                        if (sum >= 0 && i % 2 == 0) {
                                sum -= a[i], a[i] = -1 - sum, sum += a[i];
                        } else if (sum <= 0 && i & 1) {
                                sum -= a[i], a[i] = 1 - sum, sum += a[i];
                        }

                        ans += abs(temp - a[i]);
                }

                return ans;
        };


        cout << min(pos(a), neg(a));
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 4488
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
int main()
{
int i,n,c=0;
cin>>n;
string s;
cin>>s;
for(i=0;i<s.size();i++)
{
    if(s[i]!=s[i+1])
        c++;
}
if(c==0)
    cout<<"1"<<endl;
else
    cout<<c<<endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<int> > Graph;
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; }

    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;}
const ll INF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<int>h(n);
    int s=0;
    rep(i,n){
        cin >> h[i];
    }
    int res=0;
    while(true){
        if(*max_element(h.begin(),h.end())==0)break;
        int i=0;
        while(i<n){
            if(h[i]==0)i++;
            else{
                ++res;
                while(i<n&&h[i]>0){
                    h[i]--;
                    i++;
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	llong N, K;
	string S;

	cin >> N >> K;
	cin >> S;

	llong ans = 0;
	llong bad = 0;
	for (int i = 0; i < N-1; ++i) {
		if (S[i] != S[i+1])
			bad++;

		if (i > 0 && S[i] == 'L')
			ans += S[i-1] == 'L';
		if (i < N-1 && S[i] == 'R')
			ans += S[i+1] == 'R';
		// cerr << ans << endl;
	}
	if (S[N-1] == S[N-2] && S[N-1] == 'L')
		ans++;

	// cerr << ans << " " << bad << endl;
	while (bad > 0 && K > 0) {
		ans += min(2ll, bad);
		bad -= 2;
		K--;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

const int INF = 1 << 30;

int N;
vector< int > g[200000], rg[200000];
int in[200000], grundy[200000];
bool notloop[200000];

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++) {
    int p;
    cin >> p;
    g[--p].push_back(i);
    rg[i].push_back(p);
    ++in[p];
  }

  queue< int > que;

  for(int i = 0; i < N; i++) if(in[i] == 0) que.emplace(i);
  while(!que.empty()) {
    int p = que.front();
    notloop[p] = true;
    que.pop();
    set< int > st;
    for(auto &to : g[p]) st.emplace(grundy[to]);
    while(st.count(grundy[p])) ++grundy[p];
    for(auto &to : rg[p]) if(--in[to] == 0) que.emplace(to);
  }

  vector< int > vertex;
  set< int > qs;
  for(int i = 0; i < N; i++) if(!notloop[i]) vertex.push_back(i);
  for(int i : vertex) {
    set< int > st;
    for(auto &to : g[i]) if(notloop[to]) st.emplace(grundy[to]);
    while(st.count(grundy[i])) ++grundy[i];
    qs.emplace(grundy[i]);
  }
  if(vertex.size() % 2 == 1 && qs.size() == 1) cout << "IMPOSSIBLE" << endl;
  else cout << "POSSIBLE" << endl;
}


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

typedef long long ll;
const int N = 25400, K = 432, mod = 1000000007;

int n, m, R;
int a[N], c[K], d[K];
int f[N], g[N];
int fact[K], finv[K];

inline void add(int &x, const int y) {x += y - mod, x += x >> 31 & mod;}
ll PowerMod(ll a, int n, ll c = 1) {for (; n; n >>= 1, a = a * a % mod) if (n & 1) c = c * a % mod; return c;}

void init(int n) {
	int i;
	for (*fact = i = 1; i <= n; ++i) fact[i] = (ll)fact[i - 1] * i % mod;
	finv[n] = PowerMod(fact[n], mod - 2);
	for (i = n; i; --i) finv[i - 1] = (ll)finv[i] * i % mod;
}

inline ll iA(int n, int r) {return (ll)finv[n] * fact[n - r] % mod;}

namespace DP {
	int B1[K];

	inline void step(int *f) {
		int i, g = mod - f[R - 1];
		memcpy(B1, f, R << 2), *B1 = B1[1];
		for (i = R - 1; i; --i) f[i] = (B1[i - 1] * (R - i + 1ll) + g) % mod;
	}

	inline void init(int *f) {
		int i; f[R] = 0;
		for (i = R - 1; i; --i) add(f[i], f[i + 1]);
	}

	inline void trans(int len, int *f, int *g) {
		int i; *g = f[1];
		for (i = 1; i <= len; ++i) step(f), g[i] = f[1];
	}
}

int main() {
	int i, j, l = 0, r = 0, x, kinds = 0, ans = 0, I;
	scanf("%d%d%d", &n, &R, &m), init(K);
	I = PowerMod(R, n - m, n - m + 1);
	for (i = 0; i < m + R; ++i) {
		if (i < m) {
			scanf("%d", a + i), kinds += !c[ x = a[i] ]++;
			if (c[x] == 2) l || (l = i);
		}				
		if (i >= R) {
			kinds -= !--c[ x = a[i - R] ];
			if (c[x] == 1) r = m - (i - R) - 1;
		}
		if (kinds == R) return printf("%d\n", I), 0;
	}
	assert(R > 1), memset(c, 0, (R + 1) << 2);
	if (l) {
		assert(l < R && r < R);
		c[l] = 1, DP::init(c), DP::trans(n - m, c, f);
		d[r] = 1, DP::init(d), DP::trans(n - m, d, g);
		for (i = 0; i <= n - m; ++i) ans = (ans + (ll)f[i] * g[n - m - i]) % mod;
	} else {
		assert(m < R);
		c[1] = R, DP::init(c);
		d[1] = (m == 1 ? R : 0), DP::init(d);
		for (i = 1; i < n; ++i) {
			DP::step(c), DP::step(d);
			for (j = 0; j < m; ++j) add(d[j], c[m]);
			for (; j < R; ++j) add(d[j], c[j]);
		}
		ans = d[1] * iA(R, m) % mod;
	}
	ans = I - ans;
	printf("%d\n", ans + (ans >> 31 & mod));
	return 0;
}

Measured memory_bytes: 512
import math
n = int(input())
y = []
for i in range(n):
    a = list(map(int, input().split()))
    y.append(a)

q = 1
for j in range(n):
    q *= (j+1)

ans = 0
for k in range(n):
    for l in range(n):
        c = (y[k][0] - y[l][0]) ** 2 + (y[k][1] - y[l][1]) ** 2
        d = math.sqrt(c)
        ans += d


print(ans / n)
    
        



        


    







        



Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int a,b,c,q,cnt = 0;
    scanf("%d %d %d",&a,&b,&c);
    q = a;
    while(q <= b){
        if(c % q == 0)cnt++;
        q++;
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 2084
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int numa,numb,num[3];
int main(){
	int i,j;
	for(i=0;i<3;i++){
		scanf("%d",&num[i]);
	} 
	sort(num,num+3);
	int ans=0;
	int k=(num[2]-num[0])/2;
	ans+=k;
	num[0]+=k*2;
	k=(num[2]-num[1])/2;
	ans+=k;
	num[1]+=k*2;
	sort(num,num+3);
	if(num[0]==num[1]&&num[1]!=num[2]){
		ans++;
	}
	if(num[0]!=num[1]&&num[1]==num[2])
		ans+=2;
	printf("%d\n",ans);	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main() {
  string s;
  cin >> s;
  deque<char> d; //前からも後ろからも格納できる関数
  for (char c : s) d.push_back(c);  //文字列sを先に格納
  bool flip = false;   //反転の有無
  int q;
  cin >> q;
  rep(i,q) {
    int t;
    cin >> t;
    if (t == 1) {
      flip = !flip;  //false→true
    } else {
      int f; char c;
      cin >> f >> c;
      if(flip) f=3-f; //文字列の前後が反転している状態では、
                      //前後どちらに加えるかを変えるだけで、
                      //いちいち毎回反転させずに済む。
      if (f == 1) {
        d.push_front(c); //前に加える
      } else {
        d.push_back(c);  //後ろに加える
      }
    }
  }
  if (flip) reverse(all(d));  //deque関数はreverseができる
  string ans;
  for (char c : d) ans += c;
  cout << ans << endl;
}

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

int main() {
    int N;
    int T;
    int A;
    int H[1100];
    int idx;
    float diff;
    float temp = 1000.0;

    cin >> N;
    cin >> T >> A;
    for (int i=1; i<N+1; ++i) {
      cin >> H[i];
      diff = (T - A) - (H[i] * 0.006);
      if ( temp*temp > diff*diff ) {
        idx = i;
        temp = (T - A) - (H[i] * 0.006);
      }
    }
    cout << idx << endl;

    return 0;
}

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

int main()
{
	int h_in, m_in, s_in, h_out, m_out, s_out, in, out, stay, h_stay, m_stay, s_stay;

	for(int i=1; i<=3; i++){

		cin >> h_in >> m_in >> s_in >> h_out >> m_out >> s_out;

		in = h_in*3600 + m_in*60 + s_in;
		out = h_out*3600 + m_out*60 + s_out;

		stay = out - in;

		h_stay = stay/3600;
		m_stay = stay%3600/60;
		s_stay = stay%60;

		cout << h_stay << ' ' << m_stay << ' ' << s_stay << endl;
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = 0;
    rep(i, N - 1) ans += A[N - (i + 1) / 2 - 1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4828
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	cin >> n;
	vector<string> v;
	for(char i = '1'; i <= '9'; ++i){ v.emplace_back(1, i); }
	int l = 0;
	while((int)v.size() < n){
		int r = v.size();
		for(int i = l; i < r; ++i){
			string s = v[i];
			char last = *s.rbegin();
			for(char c = max<char>(last - 1, '0'); c <= last + 1 && c <= '9'; ++c){
				v.push_back(s + c);
			}
		}
		l = r;
	}
	cout << v[n - 1] << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 13936
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int q;
	cin >> q;
	int t, f;
	char c;
	vector<char> flont, back;
	bool rev = 0;
	for (int i = 0; i < q; i++) {
		cin >> t;
		if (t == 1) {
			rev = rev ? false : true;
		}
		else {
			cin >> f >> c;
			if (f == 1) {
				if (rev) {
					back.push_back(c);
				}
				else {
					flont.push_back(c);
				}
			}
			else {
				if (rev) {
					flont.push_back(c);
				}
				else {
					back.push_back(c);
				}
			}
		}
	}
	if (rev) {
		reverse(s.begin(), s.end());
		reverse(back.begin(), back.end());
		for (int i = 0; i < back.size(); i++) {
			cout << back[i];
		}
		cout << s;
		for (int i = 0; i < flont.size(); i++) {
			cout << flont[i];
		}
		cout << endl;
	}
	else {
		reverse(flont.begin(), flont.end());
		for (int i = 0; i < flont.size(); i++) {
			cout << flont[i];
		}
		cout << s;
		for (int i = 0; i < back.size(); i++) {
			cout << back[i];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
n = int(input())
ab_num = 0
a_num = 0
b_num = 0
double = 0
for _ in range(n):
    s = input()
    ab_num += s.count("AB")
    if s[0] == "B":
        b_num += 1
    if s[-1] == "A":
        a_num += 1
    if (s[0] == "B") & (s[-1] == "A"):
        double += 1
ans = ab_num + min(a_num, b_num)
if (a_num == double) & (b_num == double):
    ans = ab_num + double - 1
if (a_num == 0) & (b_num == 0) & (double == 0):
    ans = ab_num
print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[n / 2] - a[n / 2 - 1] << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int main(){
  int a,b,c,d,x;
  cin >> x;
  d=x%10; x/=10;c=x%10;x/=10;b=x%10;x/=10;a=x%10;
  if(a+b+c+d==7) cout << a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a+b+c-d==7) cout << a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a+b-c+d==7) cout << a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a-b+c+d==7) cout << a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a+b-c-d==7) cout << a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a-b+c-d==7) cout << a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a-b-c+d==7) cout << a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a-b-c-d==7) cout << a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;

}


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

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int     MOD = (int) 1E9 + 7;

    public static void main(String[] args) {
        int N = nint();
        final int A = 0, B = 1, C = 2;
        
        long[][] value = new long[3][N+1];
        for (int n = 0; n < N; n++) {
            for (int i = A; i <= C; i++) {
                value[i][n+1] = nlong();
            }
        }
        
        long[][] sum = new long[3][N+1];
        for (int i = A; i <= C; i++) {
            sum[i][1] = value[i][1];
        }
        
        
        for (int n = 2; n <= N; n++) {
            for (int i = A; i <= C; i++) {
                sum[i][n] = max(sum[(i+1)%3][n-1], sum[(i+2)%3][n-1]) + value[i][n];
            }
        }
        
        System.out.println(IntStream.rangeClosed(A, C).mapToLong(i -> sum[i][N]).max().getAsLong());
    }

    @Deprecated
    private static int nint() {
        return sc.nextInt();
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static double ndouble() {
        return sc.nextDouble();
    }

    private static double[] ndoubles(int n) {
        return ndoubles(n, 0, 0);
    }

    private static double[] ndoubles(int n, int padL, int padR) {
        double[] d = new double[n + padL + padR];
        for (int i = 0; i < n; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0, 0);
    }

    private static char[][] nchars2(int h, int w, int padLU, int padRD) {
        char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);
        return a2;
    }

    private static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    private static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    private static long abs(long a) {
        return Math.abs(a);
    }
}


Measured memory_bytes: 101800
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll r,b;
ll n;
int main(){FAST;
cin>>n;
string s;cin>>s;
for(ll i=0;i<n;i++){
	if(s[i]=='R')r++;
	else b++;
}
if(r>b){
	cout<<"Yes";
}
else{
	cout<<"No";
}
return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const K=input[0].split(' ')[0]-0;
  const X=input[0].split(' ')[1]-0;
  console.log(K*500>=X?'Yes':'No');
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 29500
#include <bits/stdc++.h>
#define long long ll
using namespace std;
int n,c[509],s[509],f[509];
int main(){
  cin >> n;
  for(int i=0;i<n-1;i++) cin >> c[i] >> s[i] >> f[i];
  vector<int> x;
  for(int i=0;i<n-1;i++){
    int t = 0;
    for(int j=i;j<n-1;j++){
      if(t <= s[j]){
        t = s[j] + c[j];
      }else{
        int wait = 0;
        while(t>s[j]+f[j]*wait) wait++;
        t = s[j] + c[j] + f[j]*wait;
      }
    }
    x.push_back(t);
  }
  x.push_back(0);
  for(int i=0;i<x.size();i++){
    cout << x[i] << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

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

      int r = Integer.parseInt(sc.next());
      int D = Integer.parseInt(sc.next());
      int x2000 = Integer.parseInt(sc.next());

	  int[] ans = new int[11];
      
      ans[0] = x2000;
      
      for(int i=1;i<11;i++){
      	ans[i] = r*ans[i-1]-D;
       	System.out.println(ans[i]); 
      }

    }
}


Measured memory_bytes: 21332
h,w = map(int,input().split())
ans = [["#" for i in range(w+2)] for i in range(h+2)]

a = [input() for i in range(h)]

for i in range(h):
    for j in range(w):
        ans[i+1][j+1] = a[i][j]

for i in range(h+2):
    for j in range(w+2):
        print(ans[i][j],end="")
    print()

Measured memory_bytes: 4468
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
# Written by NoKnowledgeGG @YlePhan
 
#import math
#mod = 10**9+7
 
 
 
def main():
  a,b = map(int,input().split())
  s = input()
  
  if s.count('-') == 1 and s[a] == '-':
    print('Yes')
  else:
    print('No')
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Read(a);
    Readln(b);
    count:=0;
    max  :=0;
    min  :=100;

    Writeln((a-1)*(b-1));
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 128
n,c,k = map(int,input().split())
#cは乗客kは時間
T = []
for i in range(n):
    t = int(input())
    T.append(t)
T.sort()
bus = 0
while(True):
    if len(T) == 0:
        break
    start = T[0]
    for i in range(c):
        if len(T)!=0: 
            if start+k >= T[0]:
                T.remove(T[0])
            else:
                break
    bus += 1
print(bus)

Measured memory_bytes: 7384
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int a,b;
    cin >> a >> b;
    pr((a+b+1)/2);
}

Measured memory_bytes: 256