akhauriyash/Code-Regression huggingface dataset:
import sys
import math
a = int(input())
b = int(input())
c = int(input())
x = int(input())
counter = 0
a_min = min( math.floor(x/500) ,a)
for ai in range(a_min+1):
    rem_a = x - (ai * 500)
    if rem_a == 0:
        counter+=1
        break
    b_min = min( math.floor(rem_a/100) ,b)
    for bi in range(b_min+1):
        rem_b = rem_a - (bi * 100)
        if rem_b == 0:
            counter+=1
            break
        c_min = min( math.floor(rem_b/50) ,c)
        for ci in range(c_min+1):
            rem_c = rem_b - (ci * 50)
            if rem_c == 0:
                counter+=1
                break
print(counter)

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

struct Node {
    vector<pair<int, LL>> edges;

    Node(){}
    Node(vector<pair<int, LL>> edges) {
        this->edges = edges;
    }
};

vector<LL> dijkstra(vector<Node> nodes, int start) {
    vector<LL> cost;
    vector<bool> visited;
    cost.resize(nodes.size());
    visited.resize(nodes.size());

    fill(ALL(cost), LINF);
    fill(ALL(visited), false);

    cost[start] = 0;
    visited[start] = true;

    for(auto edge : nodes[start].edges) {
        cost[edge.first] = edge.second;
    }

    REP(i, nodes.size() - 1) {
        LL min_cost = LINF;
        LL min_index;
        REP(j, nodes.size()) {
            if(!visited[j] && cost[j] < min_cost) {
                min_index = j;
                min_cost = cost[j];
            }
        }

        cost[min_index] = min_cost;
        visited[min_index] = true;
        for(auto edge : nodes[min_index].edges) {
            cost[edge.first] = min(cost[edge.first], cost[min_index] + edge.second);
        }
    }
    return cost;
}

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

    vector<Node> nodes(10);
    REP(i, 10) {
        REP(j, 10) {
            LL c;
            cin >> c;
            nodes[i].edges.push_back(make_pair(j, c));
        }
    }

    vector<LL> cost(10);
    REP(i, 10) {
        cost[i] = dijkstra(nodes, i)[1];
    }
    
    LL res = 0;
    REP(h, H) {
        REP(w, W) {
            int a;
            cin >> a;
            if(a == -1)continue;
            res += cost[a];
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (ll)(1000000000000000000);

int main(){
    ll a;
    long double b; 
    cin >> a >> b;
    ll ib = b*100 + 0.1;
    ll res;
    res = a*ib;
    res /= 100;
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll , ll > pll;
typedef vector < ll > vi;
#define INF (2e18)
#define eps (1e-6)
#define pb push_back
#define mp make_pair
#define modulo1e9 ((ll)1e9 + 7)

ll mn(ll a , ll b) {if (a < b) return a; return b;}
ll mx(ll a , ll b) {if (a > b) return a; return b;}

ll n , m;
vi a;
vi d;
ll sum = 0;

int main(){
	
	cin >> n >> m;
	if (n >= m){
		cout << 0 << endl;
		return 0;
	}
	for (ll i = 0 ; i < m ; i ++){
		ll x; cin >> x;
		a.pb(x);
	}
	sort(a.begin() , a.end());

	sum = a[m-1] - a[0];

	for (ll i = 0 ; i < a.size() - 1; i ++){
		ll x1 = a[i];
		ll x2 = a[i + 1];
		d.pb(x2 - x1);
	}
	sort(d.rbegin() , d.rend());

	
		

	for (ll i = 0 ; i < n-1 ; i ++ ){
		sum -= d[i];
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
//for(int i = 0; i < n; i++)

int main() {
  int n;
  double m = 0;
  cin >> n;
  vector<double> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  for(int i = 1; i < n; i++) a.at(i) = (a.at(i - 1) + a.at(i)) / 2.0;
  cout << a.at(n - 1) << endl;
}

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

int main(){
    int num , k, price_sum;
    price_sum = 0;
    std::vector<int> prices;
    std::cin >> num >> k;

    for(int price; std::cin >> price;){
        prices.push_back(price);
    }

    std::sort(prices.begin(), prices.end()); //昇順ソート

    for(int i = 0; i < k; ++i){
            price_sum += prices.at(i);
    }

    std::cout << price_sum << std::endl;

}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);++i)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
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);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N, 0);
	for (int k = 0; k < K; ++k) {
		int d;
		int a;
		cin >> d;
		R(i, d) {
			cin >> a;
			--a;
			A[a]++;
		}
	}
	int ans = 0;
	R(i, N) {
		if (A[i] == 0)ans++;
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 3660
N = int(input())
A = sorted(list(map(int, input().split())))

n = 0
n_cnt = 0
ans = 0
for a in A + [0]:
	if a != n:
		ans += n_cnt if n_cnt < n else n_cnt - n
		n = a
		n_cnt = 1
	else:
		n_cnt += 1

print(ans)

Measured memory_bytes: 14268
#! /usr/bin/env ruby

loop do
  n = gets.chomp.to_i
  break if n.zero?

  ice = {}
  10.times do |i|
    ice[i] = 0
  end

  n.times do
    ice[gets.chomp.to_i] += 1
  end

  ice.sort.each do |i|
    if i[1].zero?
      print '-'
    else
      i[1].times do
        print '*'
      end
    end
    puts
  end
end



Measured memory_bytes: 6888
#include<stdio.h>

signed main()
{

  int a,p;
  scanf("%d %d",&a,&p);

  int x = p / 2;
  int k = p % 2;
  int y =  ((a * 3) + k) / 2;

  printf("%d\n",x + y );

  return 0;

}

Measured memory_bytes: 128
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

for i in range(1000):
    flag = True
    i = str(i)
    if len(i) != N:
        continue

    for s, c in sc:
        if int(i[s-1]) != c:
            flag = False
            break
    if flag:
        print(int(i))
        exit()

print(-1)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m,x,y;

int main(){
  cin>>n>>m>>x>>y;
  int xmax=-2521, ymin=2521;
  while(n--){
    int c; cin>>c; CHMAX(xmax, c);
  }
  while(m--){
    int c; cin>>c; CHMIN(ymin, c);
  }
  FOR(z,x+1,y+1){
    if(xmax < z && z <= ymin){
      puts("No War");
      return 0;
    }
  }
  puts("War");
  return 0;
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        t: Chars,
    }
    let n = t.len();
    for i in 0..n {
        if t[i] == '?' {
            print!("D");
        } else {
            print!("{}", t[i]);
        }
    }
    println!("");
}


Measured memory_bytes: 3092
#n=int(input())
#n,k=map(int, input().split())
#a=[[0]*n for _ in range(3)]
n,we=map(int,input().split())
w=[0]*n
v=[0]*n
for i in range(n):
  w[i],v[i]=map(int,input().split())
dp=[[float('inf')]*(n+1) for _ in range(sum(v)+1)]
for i in range(n+1):
    dp[0][i]=0
for j in range(1,n+1):
  for i in range(1,sum(v)+1):
    if(v[j-1]<=i):
      dp[i][j]=min(w[j-1]+dp[i-v[j-1]][j-1],dp[i][j-1])
    else:
      dp[i][j]=dp[i][j-1]
ans=0
for i in range(sum(v)+1):
  #print(dp[i][n])
  if(dp[i][n]<=we):
  	ans=i
print(ans)


Measured memory_bytes: 285308
from math import hypot, factorial
from itertools import permutations

N = int(input())
xs, ys = [], []
for _ in range(N):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)

ans = 0
for ptn in permutations(range(N)):
    dist = 0
    for i in range(N-1):
        j1, j2 = ptn[i], ptn[i+1]
        dist += hypot(xs[j1]-xs[j2], ys[j1]-ys[j2])
    ans += dist

print(ans / factorial(N))


Measured memory_bytes: 3064
N=int(input())
t_list=[0]
x_list=[0]
y_list=[0]
ans="Yes"
for i in range(N):
    t,x,y=map(int,input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)
for i in range(N):
    T=t_list[i+1]-t_list[i]
    X=x_list[i+1]-x_list[i]
    Y=y_list[i+1]-y_list[i]
    X=abs(X)
    Y=abs(Y)
    if T<X+Y or T%2!=(X+Y)%2:
        ans="No"
print(ans)

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

int N,W;
long dp[25][50005];
vector<long> v(100);
vector<long> w(100);


int main() {

cin>>W>>N;
for(int i=0;i<N;i++) cin>>v[i];


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

for(int i=0;i<=N;i++){
  for(int j=0;j<=W;j++){
    if(j>=v[i]) dp[i+1][j]=min(dp[i][j],dp[i+1][j-v[i]]+1);
    else dp[i+1][j]=dp[i][j];
  }
}

for(int i=0;i<=N;i++){
  for(int j=0;j<=W;j++){
    //cout<<dp[i][j]<<" ";
  }
  //cout<<endl;
}

cout<<dp[N][W]<<endl;
}



Measured memory_bytes: 11728
using System;
using System.Linq;

public class ABC0129_A1v1 {
    private static void Main(string[] args) {
        var input = Console.ReadLine().Trim();
        Prepare(input);
    }

    private static void Prepare(string input) {
        var numStrs = input.Split();
        var durations = numStrs
            .Select(x => int.Parse(x))
            .OrderBy(n => n)
            .ToArray();

        Compute(durations);
    }

    private static void Compute(int[] durations) {
        var answer = durations[0] + durations[1];
        OutputAnswer(answer.ToString());
    }

    private static void OutputAnswer(string text) => Console.WriteLine(text);
}

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

int main(){
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	
	int aa,ab;
	aa=a*e;
	if(c>=e){
		ab=b;
		}
		else{
			ab=b+((e-c)*d);
			}
			
			if(aa>=ab){
				cout<<ab<<endl;
				}
				
			else{
				cout<<aa<<endl;
				}	
		return 0;		
	}

Measured memory_bytes: 3084
#include <iostream>
using namespace std;
int main ()
{

    char c;
    cin >>c;
    if (c == 'e' || c == 'a' || c == 'o' || c == 'u' || c == 'i') {
        cout << "vowel";
    } else {
        cout << "consonant";
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int n[7],m[7],o[7];
int i,q,j,k,a=0,l;
void dice_S(){
  int tmp;
  tmp = n[2];
  n[2]=n[1];
  n[1]=n[5];
  n[5]=n[6];
  n[6]=tmp;
}
void dice_E()
{
  int tmp;
  tmp = n[6];
  n[6]=n[3];
  n[3]=n[1];
  n[1]=n[4];
  n[4]=tmp;
}
//縦方向，横方向で重複しないようS・Eのみ
int main()
{
  for(i=1; i<=6; i++) scanf("%d",&m[i]);//回転させるサイコロ
  for(i=1; i<=6; i++) scanf("%d",&o[i]);//確認されるサイコロ

    k=0;
    a=0;
    for(j=1; j<=6; j++)
      n[j]=m[j];//配列の中身を固定
    if(n[1]==o[1]&&n[2]==o[2]&&n[3]==o[3]&&n[4]==o[4]&&n[5]==o[5]&&n[6]==o[6]){//初期でそろってたらif文を抜けて出力
      k=1;
      puts("Yes");
    }

   if(k==0){//初期でそろってない場合
      for(j=0; j<4; j++){
	for(l=0; l<4; l++){
	  //	  printf("%d %d %d %d %d %d %d %d\n",n[1],n[2],n[3],n[4],n[5],n[6],top[i],front[i]);
	  dice_S();
	  a++;
	  if(n[1]==o[1]&&n[2]==o[2]&&n[3]==o[3]&&n[4]==o[4]&&n[5]==o[5]&&n[6]==o[6]){
	    k=1;
	    puts("Yes");
	    break;
	  }
	  if(a==4){
	    dice_E();
	    a=0;
	  }
	}
	if(k==1)
	  break;
      }
      //上記でひょうじされない場合（n[5])
      if(k==0){
	dice_S();
	dice_E();
	for(j=0; j<4; j++){
	  dice_S();
	  if(n[1]==o[1]&&n[2]==o[2]&&n[3]==o[3]&&n[4]==o[4]&&n[5]==o[5]&&n[6]==o[6]){
	    k=1;
	    puts("Yes");
	    break;
	  }
	}
      }
      //n[2]
      if(k==0){
	dice_E();
	dice_E();
	for(j=0; j<4; j++){
	  dice_S();
	  if(n[1]==o[1]&&n[2]==o[2]&&n[3]==o[3]&&n[4]==o[4]&&n[5]==o[5]&&n[6]==o[6]){
	    k=1;
	    puts("Yes");
	    break;
	  }
	}
      }
      //最終的にそろわなかった場合
      if(k==0)
	puts("No");
   }
  

return 0;
}


Measured memory_bytes: 2084
from collections import deque

N = int(input())
nl = [[] for _ in range(N + 1)]
i = 0
for a, b in [tuple(map(int, input().split())) for _ in range(N - 1)]:
    nl[a].append((b, i))
    nl[b].append((a, i))
    i += 1

print(max(map(len, nl)))

ans = [-1 for _ in range(N - 1)]
q = deque()
q.append((1, -1, -1))
while len(q) > 0:
    v, p, pc = q.popleft()
    color = 1
    for next_v, i in nl[v]:
        if next_v == p:
            continue
        if color == pc:
            color += 1
        ans[i] = color
        q.append((next_v, v, color))
        color += 1
for a in ans:
    print(a)


Measured memory_bytes: 89376
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  vector<double>x(n);
  vector<double>y(n);
  rep(i,n) cin >> x[i] >> y[i];
  double sum=0;
  rep(i,n){
    rep(j,n){
      sum+=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
    }
  }
  cout << fixed << setprecision(10) << sum/n << endl;
 
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
   int n,i,j,min,max,R[10000000];
   scanf("%d",&n);
   
   for(i=0;i<n;i++)
       scanf("%d",&R[i]);
       
       min=R[0];
       max=R[1]-R[0];
       
   for(j=1;j<n;j++){
   if(max<=R[j]-min)
      max=R[j]-min;
   
      if(min>R[j])
          min=R[j];
}

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

return 0;
}


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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] A = new int[M];
    int[] B = new int[M];
    for (int i = 0; i < M; i++) {
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    Main abc120D = new Main();
    abc120D.solve(N, M, A, B);
  }

  public void solve(int N, int M, int[] A, int[] B) {
    ABC120DSolve abc120DSolve = new ABC120DSolve();
    long[] ans = abc120DSolve.solve(N, M, A, B);
    for (int i = 0; i < M; i++) {
      System.out.println(ans[i]);
    }
  }

  class ABC120DSolve {

    public long[] solve(int N, int M, int[] A, int[] B) {
      int[] node = IntStream.rangeClosed(0, N+1).toArray();
      int[] size = new int[N + 1];
      Arrays.fill(size, 1);
      long[] ans = new long[M];
      ans[M - 1] = (long) N * (N - 1) / 2;
      for (int i = M - 1; i > 0; i--) {
        int aRoot = root(node, A[i]);
        int bRoot = root(node, B[i]);
        if(aRoot != bRoot){
          ans[i - 1] = ans[i] - size[aRoot] * size[bRoot];
          size[bRoot] += size[aRoot];
          node[aRoot] = bRoot;
        } else {
          ans[i - 1] = ans[i];
        }

      }
      return ans;
    }

    private int root(int[] node, int i) {
      if (node[i] == i) {
        return i;
      } else {
        int ret = root(node, node[i]);
        node[i] = ret;
        return ret;
      }
    }
  }
}


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

namespace Test
{
    class AIZU
    {
        static void Main(string[] args)
        {
            var list= new List<char>();
            while(true){
                int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if(n[0]==-1&&n[0]==n[1]&&n[1]==n[2]){
                    break;
                }
                list.Add(Grade(n[0],n[1],n[2]));
            }
            foreach(char c in list){
                Console.WriteLine(c);
            }
        }
        static char Grade(int m,int f,int r){
            if(m==-1||f==-1){
                return 'F';
            } 
            int t=m+f;
            if(t>=80){
                return 'A';
            }else if(t>=65){
                return 'B';
            }else if(t>=50){
                return 'C';
            }else if(t>=30){
                if(r>=50){
                    return 'C';
                }else{
                    return 'D';
                }
            }else{
                return 'F';
            }
            
        }
        
    }
}



Measured memory_bytes: 18412
import java.util.Scanner;

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

        int l1 = s.length(), l2 = t.length();
        int[][] dp = new int[l1 + 1][l2 + 1];

        for (int i = 1; i <= l1; ++i) {
            for (int j = 1; j <= l2; ++j) {
                if (s.charAt(i - 1) == t.charAt(j - 1)) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }

        StringBuilder ans = new StringBuilder();

        int i = l1, j = l2;
        while (i > 0 && j > 0) {
            if (s.charAt(i - 1) == t.charAt(j - 1)) {
                ans.insert(0, s.charAt(i - 1));
                i--;
                j--;
            } else if (dp[i - 1][j] > dp[i][j - 1]) {
                i--;
            } else j--;
        }

        System.out.println(ans.toString());
    }
}


Measured memory_bytes: 77588
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,
                  log2, pi, radians, sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits


def inp():
    return(int(input()))


def inlist():
    return(list(map(int, input().split())))


def instr():
    s = input()
    return(list(s[:len(s)]))


def invr():
    return(map(int, input().split()))


a = inp()

print(a + a*a + a*a*a)


Measured memory_bytes: 10508
N=int(input())
F=[]
for m in range(0,N):
  F.append([0,0,0])
F[0]=  list(map(int,input().split(" ")))
#print(F[0])

for i in range(1,N):
  a,b,c=map(int,input().split(" "))
  F[i]=[a+max(F[i-1][1],F[i-1][2]), b+max(F[i-1][0],F[i-1][2]),c+max(F[i-1][0],F[i-1][1])]
  #print(F[i])
  
#print(F)
print(max(F[N-1]))

Measured memory_bytes: 22772
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using static Func;
class E { static void Main() => new J(); }
class J
{
	int F => int.Parse(Console.ReadLine());
	int[] G => Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
	HashSet<int>[] es;
	Range[] r;
	int[] z;
	public J()
	{
		Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
		var N = F;
		z = new int[N];
		for (var i = 0; i < N; i++) z[i] = -1;
		r = new Range[N];
		for (var i = 0; i < N; i++) r[i] = new Range();
		es = new HashSet<int>[N];
		for (var i = 0; i < N; i++) es[i] = new HashSet<int>();
		for (var i = 0; i < N - 1; i++)
		{
			var e = G;
			int a = e[0] - 1, b = e[1] - 1;
			es[a].Add(b); es[b].Add(a);
		}
		var K = F;
		var root = -1;
		for (var i = 0; i < K; i++)
		{
			var q = G;
			z[root = --q[0]] = q[1];
		}
		if (DFS(root, -1, z[root] % 2) == null) Console.WriteLine("No");
		else
		{
			Console.WriteLine("Yes");
			DFS2(root, z[root]);
			for (var i = 0; i < N; i++) Console.WriteLine(z[i]);
		}
		Console.Out.Flush();
	}
	void DFS2(int u, int p)
	{
		z[u] = p;
		foreach (var v in es[u])
		{
			if (z[v] >= 0) DFS2(v, z[v]);
			else if (r[v].Contains(p + 1)) DFS2(v, p + 1);
			else DFS2(v, p - 1);
		}
	}
	Range DFS(int u, int p, int e)
	{
		es[u].Remove(p);
		foreach (var v in es[u])
		{
			var b = DFS(v, u, 1 - e);
			if (b == null) return null;
			r[u].AndWith(b);
		}
		if (!r[u].OK) return null;
		if (z[u] >= 0)
		{
			if (!r[u].Contains(z[u]) || z[u] % 2 != e) return null;
			return new Range(z[u]);
		}
		return r[u];
	}
}
class Range
{
	int l, r;
	public Range() : this(-Inf, Inf) { }
	public Range(int a) : this(a, a) { }
	public Range(int a, int b) { l = a; r = b; }
	public bool OK => l <= r;
	public bool Contains(int x) => l <= x && x <= r;
	public void AndWith(Range x) { l = Max(l, x.l - 1); r = Min(r, x.r + 1); }
}
static class Func
{
	public const int Inf = 1073741789;  // 2 * Inf < int.MaxValue, and Inf is a prime number
}

Measured memory_bytes: 45532
#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 main() {
    int a, b, c, d; cin>> a >> b >> c >> d;
    if(a > c) swap(a, c), swap(b, d);
    cout << max(0, min(d-c, b-c));
}


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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		int cnt = 0;
		for (int x = 1; x <= sqrt(n); x++) {
			for (int y = 1; y <= sqrt(n); y++) {
				double d = sqrt(-2*x*y -3*pow(x,2) -3*pow(y,2) +4*i);
				if (floor(d) == d) {
					double z = (-x-y+d)/2;
					if (floor(z) == z && z > 0) {
						if (pow(x, 2) + pow(y, 2) + pow(z, 2) + x*y + y*z + z*x == i)
							cnt++;
					}
				}
			}
		}
		cout << cnt << '\n';
	}
	return 0;
}

Measured memory_bytes: 3720
#include <cstdio>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

ll W, H;
std::vector<P> pqs;

int main()
{
  scanf( "%lld%lld", &W, &H );
  rep( i, W )
  {
    ll p;
    scanf( "%lld", &p );
    pqs.push_back( P( p, false ) );
  }
  rep( i, H )
  {
    ll q;
    scanf( "%lld", &q );
    pqs.push_back( P( q, true ) );
  }

  std::sort( all(pqs) );

  ll a = W+1, b = H+1;
  ll ans = 0;

  for( auto &v : pqs )
  {
    if( v.second )
    {
      ans += a*v.first;
      --b;
    }
    else
    {
      ans += b*v.first;
      --a;
    }
  }

  printf( "%lld\n", ans );

  return 0;
}

Measured memory_bytes: 6384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;

void insert(int);
void inParse(Node);
void preParse(Node);

Node root;

int main(){

   int i;
   int n;
   int key;
  char str[7];

  scanf("%d",&n);

  for(i=0;i<n;i++){
  scanf("%s",str);
  if(strcmp(str,"insert")==0){
    scanf("%d",&key);
    insert(key);
  }

  else if(strcmp(str,"print")==0){
     inParse(root);
     printf("\n");
     preParse(root);
     printf("\n");
   }
  }

  return 0;
}

void insert(int k){

  Node x = root;
  Node y = NULL;
  Node z;

  z = malloc(sizeof(struct node));

  z->left  = NULL;
  z->right = NULL;
  z->key = k;

  while(x!=NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
    z->parent = y;
  }
  if(y==NULL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inParse(Node n){
  if(n==NULL) return;  
  inParse(n->left);
  printf(" %d",n->key);
  inParse(n->right);
}


void preParse(Node n){
  if(n==NULL) return;
  printf(" %d",n->key);
  preParse(n->left);
  preParse(n->right);
}

Measured memory_bytes: 24040
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    System.out.printf("#");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 57552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	vector<int> a(26);
	rep(i,4) a.at(s.at(i)-'A')++;
	rep(i,26) if(a.at(i)>0 && a.at(i)!=2){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}


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

int main()
{
  ll N; cin >> N;
  vector<ll> A(N), s(N);
  rep(i,N){
    cin >> A[i];
    s[i] = A[i];
  }
  sort(s.begin(), s.end(), greater<ll>());
  rep(i,N) {
    if(s[0] == A[i])
      cout << s[1] << endl;
    else
      cout << s[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long
#define PI 3.14159265358979323846

using namespace std;
int main() {
    intt N; std::cin >> N;
    std::vector<intt> L(N);
    for (auto& r : L)
        std::cin >> r;
    std::sort(L.begin(), L.end());
    int ans = 0;
    for (intt i = 0; i < N - 1; ++i) {
        for (intt j = i + 1; j < N; ++j) {
            intt k = std::lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();
            ans += std::max((int)(k - (j + 1)), 0);
        }
    }
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3652
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math as mt
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MOD = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
d = dict()
for _testcases_ in range(int(input())):
    s = input()
    d[s] = 1
ans  = 0
for k, v in d.items():
    ans += 1
print(ans)


# #########################################################################################
'''
THE LOGIC AND APPROACH WAS DEVELOPED BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
PLEASE DO NOT PLAGIARISE.
'''

Measured memory_bytes: 126432
#include<bits/stdc++.h>
#define iid dqy[i].id
#define hh dqy[head].id^1
#define tt dqy[tail].id^1
using namespace std;
const int nn=4e5+10;
int p[nn];
long long s[nn];
struct orz{
	long long v;
	int id;
}dqy[nn];
bool cmp(orz a,orz b){return a.v<b.v;}
int main(){
	int n;
	scanf("%d",&n);
	int n2=n<<1;
	if(n==1)return putchar('0'),0;
	for(int i=1,a,b;i<=n;i++){
		a=(i<<1)-2,b=a+1;
		scanf("%lld%lld",s+a,s+b);
		dqy[a].v=s[a],dqy[a].id=a;
		dqy[b].v=s[b],dqy[b].id=b;
	}sort(dqy,dqy+n2,cmp);
	for(int i=0;i<n2;i++)p[iid]=i;
	long long maxs=0,minb=INT_MAX,lb=dqy[0].v,ub=dqy[n2-1].v;
	for(int i=n2-2;i;i--){
		if(dqy[i].v<=s[iid^1])maxs=max(maxs,dqy[i].v);
		if(dqy[i].v>=s[iid^1])minb=min(minb,dqy[i].v);
	}long long ans=(maxs-lb)*(ub-minb);
	if((dqy[0].id^1)!=(dqy[n2-1].id)&&ans!=0){
		int head=1,tail=0,num=0;
		for(;num<n;){
			tail++;
			if(p[tt]<1||tail<p[tt])num++;
		}while(head<=p[hh]&&p[hh]<=tail)head++;
		long long di=dqy[tail].v-dqy[head].v;
		while(true){
			head++;
			while(head<=p[hh]&&p[hh]<=tail)head++;
			for(tail++;head<=p[tt]&&p[tt]<=tail&&tail<n2-1;tail++);
			if(tail==n2-1)break;
			di=min(di,dqy[tail].v-dqy[head].v);
		}ans=min(ans,di*(dqy[n2-1].v-dqy[0].v));
	}printf("%lld",ans);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int r = 0;
  for (int i = 1; i <= n; i *= 100) {
    r += min(10 * i, n + 1) - i;
  }
  cout << r << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
	int A,B;
	std::cin >> A >> B;
	int sum,sub,mul;
	sum = A+B;
	sub = A-B;
	mul = A*B;
	if(sum > sub){
		if(sum > mul){
			std::cout << sum;
		}else{
			std::cout << mul;
		}
	}else if(sub > mul){
		std::cout << sub;
	}else{
		std::cout << mul;
	}
	return 0;
}

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

using namespace std;

int main()
{
  int c[3][3];

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

  int a[3],
      b[3];

  a[1] = 0;

  for (int i = 0; i < 3; i++)
  {
    b[i] = c[0][i] - a[0];
  }

  for (int i = 0; i < 3; i++)
  {
    a[i] = c[i][0] - b[0];
  }

  bool can = true;

  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      if (c[i][j] != a[i] + b[j])
      {
        can = false;
        break;
      }
    }
    if (!can)
      break;
  }

  printf(can ? "Yes" : "No");
}


Measured memory_bytes: 256
main = do
	cs <- getLine
	let ns = toIntList cs
	putStrLn $ showAnswer (ns !! 0) (ns !! 1)

toIntList :: String -> [Integer]
toIntList = map read . words

showAnswer :: Integer -> Integer -> String
showAnswer a b
	| a == b = "a == b"
	| a < b = "a < b"
	| a > b = "a > b"


Measured memory_bytes: 3636
#include<stdio.h>

int main(){
    int a,b,n,i,j,sum=0,s=0;
    
    scanf("%d",&n);
    scanf(" %d",&a);
    scanf(" %d",&b);
    
    for(i=1;i<=n;i++){
        for(j=i;j!=0;j=j/10){
            s=s+j%10;
        }
        if(s>=a&&s<=b){
            sum=sum+i;
        }
        s=0;
    }
    printf("%d",sum);
    return(0);
}

Measured memory_bytes: 128
n, m = map(int, input().split())
if m == 0:
    print("0 0")
else:
    p = 0
    p_flag = [0] * n
    s = 0
    s_flag = [0] * n
    for i in range(m):
        b = input().split()
        b[0] = int(b[0])
        if b[1] == 'AC':
            if s_flag[b[0] - 1] == 0:
                s += 1
                s_flag[b[0] - 1] = 1
                p += p_flag[b[0] - 1]
        else:
            p_flag[b[0] - 1] += 1
    print(str(s) + " " + str(p))


Measured memory_bytes: 4596
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 1;
    while(ans * 2 <= N) ans *= 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
 
int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };
 
 
int main(void) {
    long long int n,T;
	long long int total=0;
	long long int first,end;

	cin>>n>>T;
	vector<long long int > t(n);
	FOR(i,0,n-1){
		cin>>t[i];
	}
	first=0;
	end=T;

	FOR(i,1,n-1){
		if(end>=t[i]){
			end=max(end,t[i]+T);
			
		}else{
			total+=end-first;
			first=t[i];
			end=t[i]+T;
		}
		
	}
	total+=end-first;

	cout<<total<<endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<sstream>
using namespace std;

int main(){
    // def inputs
    int num_in, k, i = 0;
    vector<int> num_ins;
    string exists = ":(";
    string not_exist = "Yay!";

    // parse input
    while(cin >> num_in){
        if(i == 5){
            k = num_in;
            break;
        }else{
            num_ins.push_back(num_in);
            i++;
        }
    }

    // brute force
    for(int p_i = 0; p_i < 5; ++p_i){
        for(int q_i = 5; p_i < q_i; --q_i){
            if(num_ins[q_i] - num_ins[p_i] > k){
                cout << exists << endl;
                return 0;
            }
        }
    }
    cout << not_exist << endl;

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

	cout << n << ":";

	while (!(n % 2)) {
		cout << " 2";
		n /= 2;
	}

	for (int i = 3; i <= sqrt(n); i += 2) {
		while (!(n % i)) {
			cout << " " << i;
			n /= i;
		}
	}
	if (n != 1) cout << " " << n;

	cout << endl;
} 


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

int N;

int main() {
    cin >> N;

    int ans = N;
    for (int i = 0; i <= N; i++) {
        int num = 0;
        int t = i;
        while (t > 0) {
            num += t % 6;
            t /= 6;
        }
        t = N - i;
        while (t > 0) {
            num += t % 9;
            t /= 9;
        }
        if (ans > num) ans = num;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

const int N = 1e5 + 5;

int n, dp[N][3], a[3];

int main()
{
//    freopen("input.inp", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j < 3; ++j)
        {
            int gain;
            cin >> gain;
            for (int k = 0; k < 3; ++k)
            {
                if (k != j)
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + gain);
            }
        }
    cout << max({dp[n][0], dp[n][1], dp[n][2]});
    return 0;
}


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

int main(){
    int a,b,c,k,max;
    scanf("%d %d %d %d",&a,&b,&c,&k);

    max = a;
    if(b>max)
        max = b;
    else if(c>max)
        max = c;
    
    if(max==a)
        max = ((1<<k)*a) + b + c; //
    else if (max==b)
        max = ((1<<k)*b) + a + c;
    else if (max==c)
        max = ((1<<k)*c) + a + b;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int n, k;

int main() {
  cin >> n >> k;
  int h[n];
  rep(i, n) cin >> h[i];
  
  int counter = 0;
  rep(i,n) {
    if(h[i] >= k) counter++;
  }
  
  cout << counter;
}


Measured memory_bytes: 640
def resolve():
    N = int(input())
    c = input()

    r = w = 0
    for i in range(N):
        if c[i] == "R":
            r += 1

    ans = max(r, w)
    for i in range(N):
        if c[i] == "R":
            r -= 1
        else:
            w += 1
        current = max(r, w)
        ans = min(ans, current)
    print(ans)

if __name__ == "__main__":
    resolve()

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; cin >> n >> k;
	string s; cin >> s;
		s[k-1]=tolower(s[k-1]);
	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    char s[3];
  	char a[]="AAA";
  	char b[]="BBB";
    scanf("%s",s);

    if(strcmp(s,a)==0 || strcmp(s,b)==0){
        printf("No");
    }

    else{
        printf("Yes");
    }
  
  	return 0;

}

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

int factorial(int x){
	if(x==1) return 1;
	return x*factorial(x-1);
}

int main(){
	int n;	cin>>n;
	long long march[5]={0};

	for(int i=0;i<n;i++){
		string s;	cin>>s;
		switch(s[0]){
			case 'M':
				march[0]++;
				break;
			case 'A':
				march[1]++;
				break;
			case 'R':
				march[2]++;
				break;
			case 'C':
				march[3]++;
				break;
			case 'H':
				march[4]++;
				break;

			default:
				break;
		}
	}

	long long comb[3][10]={
		{0,0,0,0,0,0,1,1,1,2},
		{1,1,1,2,2,3,2,2,3,3},
		{2,3,4,3,4,4,3,4,4,4}};

	long long ans=0;
	for(int i=0;i<10;i++){
		ans+=march[comb[0][i]]*march[comb[1][i]]*march[comb[2][i]];
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}


int main() {
    int i,j;
    int n;
    char s[11];
    int cnt=0,max = 0;;

    scanf("%s", s);

    for(i=0;i<strlen(s); i++){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            cnt++;
        }else{
            if(cnt > max) max = cnt;
            cnt = 0;
        }
    }
    if(cnt > max) max = cnt;
    printf("%d", max);
    return 0;

}

Measured memory_bytes: 128
import collections


def main():
    s = list(input())
    if s.count("C") == 0 or s.count("F") == 0:
        print("No")
        return

    clen, flen = 0, 0
    for i in range(len(s)):
        if clen == 0:
            if s[i] == "C":
                clen = i
        if s[i] == "F":
            flen = i
    print("Yes" if flen > clen else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9328
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n,m;
  cin>>n>>m;
  priority_queue<P> que;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    que.push(P(-b,a));
  }
  int ans=0;
  while(!que.empty()){
    int e=-que.top().first;
    while(!que.empty()){
      P t=que.top();
      if(e==-t.first||e>t.second){
	que.pop();
	continue;
      }
      break;
    }
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main(){

    int N, H, W;
    cin >> N >> H >> W;
    int count=0;
    int A,B;
    for(int i=0; i<N; i++){
        cin >> A >> B;
        if(A >= H && B >= W) count++;
    }

    cout << count << endl;

    return 0;
}


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

using namespace std;

ll mod = 1e9 + 7;
ll n,k,a[100005];
ll dp[105][100005];
ll pre[100005];
ll sum (int l,int r)
{
    if (l <= 0)return pre[r];
    else return (((pre[r] - pre[l - 1]) + mod )%mod)%mod;
}
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> k;
    for (int i=1;i<=n;i++)cin >> a[i];
    dp[0][0] = 1;
    for (int i=0;i<=k;i++)
    {
        if (i)pre[i] = pre[i - 1];
        pre[i] += dp[0][i];
    }
    for (int i=1;i<=n;i++)
    {
        for (int j=0;j<=k;j++)
        {
            int o = a[i];
            dp[i][j] += sum(j - a[i] , j);
            dp[i][j] %= mod;
        }
        for (int j=0;j<=k;j++)
        {
            if (i)pre[j] = pre[j - 1];
            pre[j] += dp[i][j];
            pre[j] %= mod;
        }
    }
    cout << dp[n][k] << endl;
    return 0;
}


Measured memory_bytes: 79360
#ALL you can eat 
#0-1 なっぷサック問題をとく* N

#要領T-1のバックと　大きさがA,価値がBの荷物がNこずつある。　この時これらを使って価値をT-1をこえない範囲で最大にする方法を考える。


#dpl[N][V]=1番目からN番目までの荷物を用いて、重さをVにする上で実現可能な価値の最大値
N,T=map(int,input().split())
d=[]
for i in range(N):
    a,b=map(int,input().split())
    d.append((a,b))
dpl=[[0 for i in range(T)] for j in range(N+1)]
for i in range(N):
    weight,value=d[i]
    for j in range(T):
        if j>=weight:
            dpl[i+1][j]=max(dpl[i][j],dpl[i][j-weight]+value)
        else:
            dpl[i+1][j]=dpl[i][j]

            
#dpr[K][V]=K番目からN番目までの荷物を用いて、重さをVにする上で実現可能な価値の最大値
dpr=[[0 for i in range(T)] for j in range(N+2)]
for i in range(1,N+1):
    weight,value=d[-i]
    for j in range(T):
        if j>=weight:
            dpr[N+1-i][j]=max(dpr[N+2-i][j],dpr[N+2-i][j-weight]+value)
        else:
            dpr[N+1-i][j]=dpr[N+2-i][j]

#dpr[K][V]=K番目からN番目までの荷物を用いて重さをV以下にする上で実現可能な価値の最大値にする
for i in range(1,N+1):
    for j in range(1,T):
        dpr[i][j]=max(dpr[i][j],dpr[i][j-1])
    
ans=0
for i in range(N):
    sub=d[i][1]
    #i+1番目の物を使わない
    add=0
    for j in range(T):
        add=max(add,dpl[i][j]+dpr[i+2][T-1-j])
    sub+=add
    ans=max(sub,ans)
print(ans)

Measured memory_bytes: 194948
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(b/a >= c){
        cout << c;
    }
    else
    {
        cout << b/a;
    }
    
    cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <string>
#include <math.h>
#include <time.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
using namespace std;
typedef long long ll;
int  frq[26];
int main() {
	int n, s=0;
	cin >> n;
	int x = n;
	while (x) {
		s += x % 10;
		x /= 10;
	}
	if (n%s == 0)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  cin>>n>>m;
  int a[n*2],sum=0,ma=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[n+i]=a[i];
    sum+=a[i];
    ma=max(ma,a[i]);
  }
  srand((unsigned)time(NULL));
  time_t start=clock();
  set<int> s;
  int ans=sum;
  while((double)(clock()-start)/CLOCKS_PER_SEC<7.0){
    int p=rand()%n;
    if(s.count(p)) continue;
    s.insert(p);
    int l=ma-1,r=sum;
    while(l+1<r){
      int mid=(l+r)/2;
      int v=p,t=a[p],c=0;
      while(1){
	while(v+1<p+n&&t+a[v+1]<=mid){
	  v++;
	  t+=a[v];
	} 
	c++;t=0;
	if(v+1>=p+n) break;
      }
      if(c<=m) r=mid;
      else l=mid;
    }
    //cout<<r<<endl;
    ans=min(ans,r);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4116
package main

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

func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}
func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func newLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	var n int
	n, _ = strconv.Atoi(newLine())
	h := make([]int, n+20)
	inputLine := strings.Split(newLine(), " ")
	for i, v := range inputLine {
		h[i], _ = strconv.Atoi(v)
	}
	dp := make([]int, n+20)
	for i := 0; i < n+20; i++ {
		dp[i] = 10000000000
	}
	dp[0] = 0

	for i := 0; i < n; i++ {
		chmin(&dp[i+1], dp[i]+abs(h[i]-h[i+1]))
		chmin(&dp[i+2], dp[i]+abs(h[i]-h[i+2]))
	}
	fmt.Println(dp[n-1])
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int n;
  cin >> n;
  for (int c = 0; c < 26; c++) {
    int tmp = n - 4 * c;
    if (tmp < 0) {
      continue;
    }
    if (tmp % 7 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 384
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define WAIT system ("pause")
#define rt0 return 0
using namespace std;
int main()
{
    int n,d,x,cnt=0;
    cin>>n>>d>>x;
    vector <int> a(n,0);
    for(int i=0;i<n;i++) 
    {
        cin>>a[i];
        for(int j=1;j<=d;j+=a[i]) cnt++;
    }
    cout<<cnt+x;
    WAIT;
    rt0;
}

Measured memory_bytes: 504