Language: C++

#include <bits/stdc++.h>

#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;

using namespace std;

short a[100007];
short b[100007];
short c[100007];
long long arr[100007];
long long brr[100007];
long long crr[100007];

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	loop(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}

	arr[0] = a[0];
	brr[0] = b[0];
	crr[0] = c[0];
	for (int i = 1; i < n; ++i)
	{
		/* code */
		arr[i] = a[i] + max(brr[i - 1], crr[i - 1]);
		brr[i] = b[i] + max(arr[i - 1], crr[i - 1]);
		crr[i] = c[i] + max(arr[i - 1], brr[i - 1]);
	}

	cout << max({arr[n - 1], brr[n - 1], crr[n - 1]});

}#include <bits/stdc++.h>

#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;

using namespace std;

short a[100007];
short b[100007];
short c[100007];
long long arr[100007];
long long brr[100007];
long long crr[100007];

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	loop(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}

	arr[0] = a[0];
	brr[0] = b[0];
	crr[0] = c[0];
	for (int i = 1; i < n; ++i)
	{
		/* code */
		arr[i] = a[i] + max(brr[i - 1], crr[i - 1]);
		brr[i] = b[i] + max(arr[i - 1], crr[i - 1]);
		crr[i] = c[i] + max(arr[i - 1], brr[i - 1]);
	}

	cout << max({arr[n - 1], brr[n - 1], crr[n - 1]});

}#include <bits/stdc++.h>

#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;

using namespace std;

short a[100007];
short b[100007];
short c[100007];
long long arr[100007];
long long brr[100007];
long long crr[100007];

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	loop(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}

	arr[0] = a[0];
	brr[0] = b[0];
	crr[0] = c[0];
	for (int i = 1; i < n; ++i)
	{
		/* code */
		arr[i] = a[i] + max(brr[i - 1], crr[i - 1]);
		brr[i] = b[i] + max(arr[i - 1], crr[i - 1]);
		crr[i] = c[i] + max(arr[i - 1], brr[i - 1]);
	}

	cout << max({arr[n - 1], brr[n - 1], crr[n - 1]});

}#include <bits/stdc++.h>

#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;

using namespace std;

short a[100007];
short b[100007];
short c[100007];
long long arr[100007];
long long brr[100007];
long long crr[100007];

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	loop(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}

	arr[0] = a[0];
	brr[0] = b[0];
	crr[0] = c[0];
	for (int i = 1; i < n; ++i)
	{
		/* code */
		arr[i] = a[i] + max(brr[i - 1], crr[i - 1]);
		brr[i] = b[i] + max(arr[i - 1], crr[i - 1]);
		crr[i] = c[i] + max(arr[i - 1], brr[i - 1]);
	}

	cout << max({arr[n - 1], brr[n - 1], crr[n - 1]});

}#include <bits/stdc++.h>

#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;

using namespace std;

short a[100007];
short b[100007];
short c[100007];
long long arr[100007];
long long brr[100007];
long long crr[100007];

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	loop(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}

	arr[0] = a[0];
	brr[0] = b[0];
	crr[0] = c[0];
	for (int i = 1; i < n; ++i)
	{
		/* code */
		arr[i] = a[i] + max(brr[i - 1], crr[i - 1]);
		brr[i] = b[i] + max(arr[i - 1], crr[i - 1]);
		crr[i] = c[i] + max(arr[i - 1], brr[i - 1]);
	}

	cout << max({arr[n - 1], brr[n - 1], crr[n - 1]});

}#include <bits/stdc++.h>

#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;

using namespace std;

short a[100007];
short b[100007];
short c[100007];
long long arr[100007];
long long brr[100007];
long long crr[100007];

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	loop(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}

	arr[0] = a[0];
	brr[0] = b[0];
	crr[0] = c[0];
	for (int i = 1; i < n; ++i)
	{
		/* code */
		arr[i] = a[i] + max(brr[i - 1], crr[i - 1]);
		brr[i] = b[i] + max(arr[i - 1], crr[i - 1]);
		crr[i] = c[i] + max(arr[i - 1], brr[i - 1]);
	}

	cout << max({arr[n - 1], brr[n - 1], crr[n - 1]});

}

Compiler output:
a.cc:54:2: error: stray '#' in program
   54 | }#include <bits/stdc++.h>
      |  ^
a.cc:107:2: error: stray '#' in program
  107 | }#include <bits/stdc++.h>
      |  ^
a.cc:160:2: error: stray '#' in program
  160 | }#include <bits/stdc++.h>
      |  ^
a.cc:213:2: error: stray '#' in program
  213 | }#include <bits/stdc++.h>
      |  ^
a.cc:266:2: error: stray '#' in program
  266 | }#include <bits/stdc++.h>
      |  ^
a.cc:54:3: error: 'include' does not name a type
   54 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:71:7: error: redefinition of 'short int a [100007]'
   71 | short a[100007];
      |       ^
a.cc:18:7: note: 'short int a [100007]' previously declared here
   18 | short a[100007];
      |       ^
a.cc:72:7: error: redefinition of 'short int b [100007]'
   72 | short b[100007];
      |       ^
a.cc:19:7: note: 'short int b [100007]' previously declared here
   19 | short b[100007];
      |       ^
a.cc:73:7: error: redefinition of 'short int c [100007]'
   73 | short c[100007];
      |       ^
a.cc:20:7: note: 'short int c [100007]' previously declared here
   20 | short c[100007];
      |       ^
a.cc:74:11: error: redefinition of 'long long int arr [100007]'
   74 | long long arr[100007];
      |           ^~~
a.cc:21:11: note: 'long long int arr [100007]' previously declared here
   21 | long long arr[100007];
      |           ^~~
a.cc:75:11: error: redefinition of 'long long int brr [100007]'
   75 | long long brr[100007];
      |           ^~~
a.cc:22:11: note: 'long long int brr [100007]' previously declared here
   22 | long long brr[100007];
      |           ^~~
a.cc:76:11: error: redefinition of 'long long int crr [100007]'
   76 | long long crr[100007];
      |           ^~~
a.cc:23:11: note: 'long long int crr [100007]' previously declared here
   23 | long long crr[100007];
      |           ^~~
a.cc:78:5: error: redefinition of 'int main()'
   78 | int main() {
      |     ^~~~
a.cc:25:5: note: 'int main()' previously defined here
   25 | int main() {
      |     ^~~~
a.cc:107:3: error: 'include' does not name a type
  107 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:124:7: error: redefinition of 'short int a [100007]'
  124 | short a[100007];
      |       ^
a.cc:18:7: note: 'short int a [100007]' previously declared here
   18 | short a[100007];
      |       ^
a.cc:125:7: error: redefinition of 'short int b [100007]'
  125 | short b[100007];
      |       ^
a.cc:19:7: note: 'short int b [100007]' previously declared here
   19 | short b[100007];
      |       ^
a.cc:126:7: error: redefinition of 'short int c [100007]'
  126 | short c[100007];
      |       ^
a.cc:20:7: note: 'short int c [100007]' previously declared here
   20 | short c[100007];
      |       ^
a.cc:127:11: error: redefinition of 'long long int arr [100007]'
  127 | long long arr[100007];
      |           ^~~
a.cc:21:11: note: 'long long int arr [100007]' previously declared here
   21 | long long arr[100007];
      |           ^~~
a.cc:128:11: error: redefinition of 'long long int brr [100007]'
  128 | long long brr[100007];
      |           ^~~
a.cc:22:11: note: 'long long int brr [100007]' previously declared here
   22 | long long brr[100007];
      |           ^~~
a.cc:129:11: error: redefinition of 'long long int crr [100007]'
  129 | long long crr[100007];
      |           ^~~
a.cc:23:11: note: 'long long int crr [100007]' previously declared here
   23 | long long crr[100007];
      |           ^~~
a.cc:131:5: error: redefinition of 'int main()'
  131 | int main() {
      |     ^~~~
a.cc:25:5: note: 'int main()' previously defined here
   25 | int main() {
      |     ^~~~
a.cc:160:3: error: 'include' does not name a type
  160 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:177:7: error: redefinition of 'short int a [100007]'
  177 | short a[100007];
      |       ^
a.cc:18:7: note: 'short int a [100007]' previously declared here
   18 | short a[100007];
      |       ^
a.cc:178:7: error: redefinition of 'short int b [100007]'
  178 | short b[100007];
      |       ^
a.cc:19:7: note: 'short int b [100007]' previously declared here
   19 | short b[100007];
      |       ^
a.cc:179:7: error: redefinition of 'short int c [100007]'
  179 | short c[100007];
      |       ^
a.cc:20:7: note: 'short int c [100007]' previously declared here
   20 | short c[100007];
      |       ^
a.cc:180:11: error: redefinition of 'long long int arr [100007]'
  180 | long long arr[100007];
      |           ^~~
a.cc:21:11: note: 'long long int arr [100007]' previously declared here
   21 | long long arr[100007];
      |           ^~~
a.cc:181:11: error: redefinition of 'long long int brr [100007]'
  181 | long long brr[100007];
      |           ^~~
a.cc:22:11: note: 'long long int brr [100007]' previously declared here
   22 | long long brr[100007];
      |           ^~~
a.cc:182:11: error: redefinition of 'long long int crr [100007]'
  182 | long long crr[100007];
      |           ^~~
a.cc:23:11: note: 'long long int crr [100007]' previously declared here
   23 | long long crr[100007];
      |           ^~~
a.cc:184:5: error: redefinition of 'int main()'
  184 | int main() {
      |     ^~~~
a.cc:25:5: note: 'int main()' previously defined here
   25 | int main() {
      |     ^~~~
a.cc:213:3: error: 'include' does not name a type
  213 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:230:7: error: redefinition of 'short int a [100007]'
  230 | short a[100007];
      |       ^
a.cc:18:7: note: 'short int a [100007]' previously declared here
   18 | short a[100007];
      |       ^
a.cc:231:7: error: redefinition of 'short int b [100007]'
  231 | short b[100007];
      |       ^
a.cc:19:7: note: 'short int b [100007]' previously declared here
   19 | short b[100007];
      |       ^
a.cc:232:7: error: redefinition of 'short int c [100007]'
  232 | short c[100007];
      |       ^
a.cc:20:7: note: 'short int c [100007]' previously declared here
   20 | short c[100007];
      |       ^
a.cc:233:11: error: redefinition of 'long long int arr [100007]'
  233 | long long arr[100007];
      |           ^~~
a.cc:21:11: note: 'long long int arr [100007]' previously declared here
   21 | long long arr[100007];
      |           ^~~
a.cc:234:11: error: redefinition of 'long long int brr [100007]'
  234 | long long brr[100007];
      |           ^~~
a.cc:22:11: note: 'long long int brr [100007]' previously declared here
   22 | long long brr[100007];
      |           ^~~
a.cc:235:11: error: redefinition of 'long long int crr [100007]'
  235 | long long crr[100007];
      |           ^~~
a.cc:23:11: note: 'long long int crr [100007]' previously declared here
   23 | long long crr[100007];
      |           ^~~
a.cc:237:5: error: redefinition of 'int main()'
  237 | int main() {
      |     ^~~~
a.cc:25:5: note: 'int main()' previously defined here
   25 | int main() {
      |     ^~~~
a.cc:266:3: error: 'include' does not name a type
  266 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:283:7: error: redefinition of 'short int a [100007]'
  283 | short a[100007];
      |       ^
a.cc:18:7: note: 'short int a [100007]' previously declared here
   18 | short a[100007];
      |       ^
a.cc:284:7: error: redefinition of 'short int b [100007]'
  284 | short b[100007];
      |       ^
a.cc:19:7: note: 'short int b [100007]' previously declared here
   19 | short b[100007];
      |       ^
a.cc:285:7: error: redefinition of 'short int c [100007]'
  285 | short c[100007];
      |       ^
a.cc:20:7: note: 'short int c [100007]' previously declared here
   20 | short c[100007];
      |       ^
a.cc:286:11: error: redefinition of 'long long int arr [100007]'
  286 | long long arr[100007];
      |           ^~~
a.cc:21:11: note: 'long long int arr [100007]' previously declared here
   21 | long long arr[100007];
      |           ^~~
a.cc:287:11: error: redefinition of 'long long int brr [100007]'
  287 | long long brr[100007];
      |           ^~~
a.cc:22:11: note: 'long long int brr [100007]' previously declared here
   22 | long long brr[100007];
      |           ^~~
a.cc:288:11: error: redefinition of 'long long int crr [100007]'
  288 | long long crr[100007];
      |           ^~~
a.cc:23:11: note: 'long long int crr [100007]' previously declared here
   23 | long long crr[100007];
      |           ^~~
a.cc:290:5: error: redefinition of 'int main()'
  290 | int main() {
      |     ^~~~
a.cc:25:5: note: 'int main()' previously defined here
   25 | int main() {
      |     ^~~~