akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n;
    cin >> n;
    VI p(n);
    FOR(i, 0, n) {
        cin >> p[i];
        p[i]--;
    }

    int ans = 0;
    FOR(i, 0, n - 1) {
        if (p[i] == i) {
            swap(p[i], p[i + 1]);
            ans++;
        }
    }
    ans += (p[n - 1] == n - 1);
    cout << ans << "\n";
}

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

long long fib_(int n,long long a,long long b){
  if(n==2) return a+b;
  return fib_(n-1,b,a+b);
}

long long fib(int n){
  if(n==0) return 1;
  if(n==1) return 1;
  return fib_(n,1,1);
}


int main(){
  int n; cin>>n;
  cout<<fib(n)<<endl;
}

Measured memory_bytes: 3088
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        int cnt = 0;
        for (int i = a; i <= b; i++) {
            int r2 = i % 10;
            int r1 = i % 100 / 10;
            int l1 = i % 10000 / 1000;
            int l2 = i / 10000;
            
            if (r2 == l2 && r1 == l1)
                cnt++;
        }

        System.out.println(cnt);
    }
}


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

using namespace std;

string fld[21];
int w,h;
bool flg[21][21];
int ans;

void solve(int x, int y){
    if(flg[y][x]||fld[y][x]=='#'){
        return;
    }

    ans++;
    flg[y][x] = true;

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

    for(int i=0;i<4;i++){
        int nx = x+dx[i];
        int ny = y+dy[i];
        if(nx<0||nx>=w||ny<0||ny>=h){
            continue;
        }

        solve(nx, ny);
    }
}


int main(){
    while(cin>>w>>h,w!=0){
        for(int i=0;i<21;i++){
            for(int k=0;k<21;k++){
                flg[k][i] = false;
            }
        }
        ans = 0;

        for(int y=0;y<h;y++){
            cin >> fld[y];
        }

        int sx,sy;
        for(int y=0;y<h;y++){
            for(int x=0;x<w;x++){
                if(fld[y][x]=='@'){
                    sx = x;
                    sy = y;
                }
            }
        }

        solve(sx, sy);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
n,k=map(int, input().split())
x=0
a=list(range(0,n+1))
aa=list(range(1,n+2))
mod=10**9+7
from itertools import accumulate
A=list(accumulate(a))
for i in range(k-1,n+1):
    x+=(2*A[i]-1)%mod
    x%=mod
print(((sum(aa[k-1:])%mod*n)-x+mod)%mod)

Measured memory_bytes: 82008
#include <iostream>

using namespace std;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if((A+B)>(C+D)) {
        cout << "Left" << endl;
    } else if((A+B)==(C+D)) {
        cout << "Balanced" << endl;
    } else {
        cout << "Right" << endl;
    }

    return 0;

}

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

using namespace std;

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

    int count =0;
    for(int i = 0; i < N; i++) {
        for(int j = N - 1; j > 0; j--) {
            if(A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                count++;
            }
        }
    }
    for(int i = 0; i < N; i++) {
        if(i != 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
}


Measured memory_bytes: 3108
import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		String s = buf.readLine();
		String p = buf.readLine();
		String str1;

		str1 = s+s;

		if(str1.contains(p) == true)
			System.out.println("Yes");
		else
			System.out.println("No");
		
	}
}

Measured memory_bytes: 24472
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let mut cnts: Vec<u64> = vec![0; n + 10];
    let mut result: u64 = 0;
    for &x in a.iter() {
        cnts[x] += 1;
    }
    //println!("{:?}", cnts);
    for &x in cnts.iter() {
        if x >= 2 {
            //xC2
            result += x * (x - 1) / 2;
        }
    }
    //eprintln!("result: {}", result);
    for &i in a.iter() {
        let mut ans = result;
        let x = cnts[i];
        if x >= 2 {
            ans -= x * (x - 1) / 2;
            let y = cnts[i];
            ans += (y - 1) * (y - 2) / 2;
        }
        println!("{}", ans);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;

constexpr int INF = 0x3f3f3f3f;

struct SegmentTree {
	struct Node {
		Node *left_child, *right_child;
		int left, right, mid, max, tag_add;

		void add(int d) {
			max += d;
			tag_add += d;
		}

		void clear_tags() {
			left_child->add(tag_add);
			right_child->add(tag_add);
			tag_add = 0;
		}
	};

	Node *root;
	int left_bound, right_bound;
	
	void build(Node *&p, int left, int right) {
		p = new Node;
		p->left = left;
		p->right = right;
		p->mid = (left + right) / 2;
		p->tag_add = 0;

		if (left == right) {
			p->max = 0 - (right_bound - left);
			p->left_child = p->right_child = nullptr;
		} else {
			build(p->left_child, p->left, p->mid);
			build(p->right_child, p->mid + 1, p->right);
			p->max = max(p->left_child->max, p->right_child->max);
		}
	}

	explicit SegmentTree(int left, int right): left_bound(left), right_bound(right) {
		build(root, left, right);
	}

	void destroy(Node *p) {
		if (p) {
			destroy(p->left_child);
			destroy(p->right_child);
			delete p;
		}
	}

	~SegmentTree() {
		destroy(root);
	}

	void insert(Node *p, int pos) {
		if (p->right <= pos) {
			p->add(1);
		} else {
			p->clear_tags();
			insert(p->left_child, pos);
			if (pos > p->mid) insert(p->right_child, pos);
			p->max = max(p->left_child->max, p->right_child->max);
		}
	}

	void insert(int pos) {
		insert(root, pos);
	}

	int query() {
		return root->max;
	}

	void traverse(Node *p, int sp) {
		if (!p) return;
		traverse(p->left_child, sp + 1);

		for (int i = 0; i < sp; ++i) cout << "  ";
		cout << '[' << p->left << ", " << p->right << "] " << p->max << endl;

		traverse(p->right_child, sp + 1);
	}

	void traverse() {
		traverse(root, 0);
		cout << endl;
	}
};

struct Wish {
	int l, r;
} wishes[200000];

int main() {
	ios_base::sync_with_stdio(false);

	int n, m;

	cin >> n >> m;
	for (int i = 0; i < n; ++i) cin >> wishes[i].l >> wishes[i].r;

	sort(wishes, wishes + n, [](const Wish &x, const Wish &y) {
		return x.l < y.l;
	});

	int ans = max(n - m, 0);
	SegmentTree sgt(0, m + 1);
	for (int i = 0, j = 0; i <= m + 1; ++i) {
		for (; j < n && wishes[j].l == i; ++j)
			sgt.insert(wishes[j].r);
		// cout << i << endl; sgt.traverse(); cout << endl;
		ans = max(ans, sgt.query() - i);
	}

	cout << ans << endl;

	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)      //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++)    //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);
    
    int n, m; cin >> n >> m;
    cout << 6-n-m << '\n';
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	long long int x;
	long long int y;
	long long int sum = 0;
	cin >> x >> y;
	sum = (x + y) / 3;
	if ((x + y) % 3 != 0) {
		cout << 0;
		return 0;
	}
	if (max(x, y) > 2 * min(x, y)) {
		cout << 0;
		return 0;
	}
	long long int conbi = 0;
	conbi = min(x, y) - sum;
	COMinit();

	cout << COM(sum, conbi);
}

Measured memory_bytes: 16640
import collections
N, M = map(int, input().split())
toshi = []
for i in range(M):
    a, b = map(int, input().split())
    toshi.append(a)
    toshi.append(b)

toshicount = collections.Counter(toshi)
for i in range(N):
    print(toshicount[i+1])


Measured memory_bytes: 3316
// Crane and Turtle

func main() {
    let xy = readLine()!.split(separator: " ").map{Int($0)!}
    let (x,y) = (xy[0], xy[1])

    for i in 0...x {
        if i * 4 + (x - i) * 2 == y {
            print("Yes")
            return
        }
    }
    print("No")
}

main()

Measured memory_bytes: 8252
/*Practice hard*/
#include <bits/stdc++.h>
using namespace std;

//_______MACROS_______//
#define   fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define   int   long long int
#define   pb    push_back
#define   f     first
#define   s     second
#define   PI    3.1415926535898


int n, ans ;
void input()
{
    cin >> n ;
}
void solve()
{
    int p = 100 ;
    while(p < n)
    {
        p += p / 100;
        ans ++;
    }
    cout << ans << endl;
}
signed main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 3580
#include<stdio.h>

int main(){
  int i, j, n, k, id;
  scanf("%d", &n);

  int v[n+1][n+1];
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      v[i][j] = 0;
    }
  }
  for(i = 1; i <= n; i++){
    scanf("%d%d", &id, &k);
    if(k != 0){
      int v2;
      for(j = 1; j <= k; j++){
	scanf("%d", &v2);
	v[i][v2] = 1;
      }
    }
  }
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      if(j == n) printf("%d\n", v[i][j]);
      else printf("%d ",v[i][j]);
    }
  }

  return 0;
}
    



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

using namespace std;
using ll = long long;

int main() {
  ll A, B;
  cin >> A >> B;
  ll a = A%2==0 ? A : A+1;
  ll ret = ll((B-a+1)/2)%2==0 ? 0 : 1;
  if(A != a)
    ret ^= A;
  if((B-a+1)%2!=0)
    ret ^= B;
  cout << ret << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  int i;
  char str[1001];
  scanf("%s",str);  
  for(i=0;i<strlen(str);i++){
    if(str[i]=='A'||str[i]=='B'||str[i]=='C'){
      str[i]=str[i]+23;
    }
    else{
      str[i]=str[i]-3;
    }
    printf("%c",str[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
from itertools import combinations_with_replacement
N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
for t in combinations_with_replacement(range(1, M+1), N):
    an = 0
    for a, b, c, d in ABCD:
        if t[b-1]-t[a-1] == c:
            an += d
    if ans < an:
        ans = an
print(ans)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int M = 120000;
typedef long long ll;
int n,m,k;
int main(){
    cin>>n;
    int u;
    bool fg=1;
    fo(i,1,n){
        cin>>u;
        if(u&1) continue;
        if(u%3==0||u%5==0) continue;
        fg=0;
    }
    if(fg) puts("APPROVED");
    else puts("DENIED");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 101

int main() {
    int n;
    int G[MAX][MAX];

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

    int k, u, m;
    for (int i=1; i<=n; i++) {
        scanf("%d", &u);
        scanf("%d", &m);
        for (int j=1; j<=m; j++) {
            scanf("%d", &k);
            G[u][k] = 1;
        }
    }

    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            if (j==1) printf("%d", G[i][j]);
            else printf(" %d", G[i][j]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2788
# coding: utf-8

def gcd(n1, n2):
    if n1 < n2:
        n1, n2 = n2, n1

    while n1 % n2 != 0:
        rest = n1 % n2
        n1, n2 = n2, rest

    return n2

def lcm(n1, n2):
    return n1 * n2 // gcd(n1, n2)

def getM(alist):
    nLcm = lcm(alist[0], alist[1])
    for i in range(2, len(alist)):
        nLcm = lcm(nLcm, alist[i])
    
    return nLcm-1

def f(m, alist):
    t_sum = 0
    for ai in alist:
        t_sum +=  m % ai

    return t_sum
    
if __name__ == "__main__":
    N = int(input())
    alist = [int(x) for x in input().split(" ")]
    print(f(getM(alist), alist))
    


Measured memory_bytes: 3316
colormap = input('')
colormaplist = [int(i) for i in colormap]
changecounter = 0
for i in range(len(colormaplist)-1):
    if colormaplist[i+1] == colormaplist[i]:
        colormaplist[i+1] = 1-colormaplist[i+1]
        changecounter+=1
print(changecounter)





Measured memory_bytes: 4084
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20

N,K = map(int,input().split())
h = list(map(int,input().split()))
ans = 0
for value in h:
    if value >= K:
        ans += 1
print(ans)

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

int main(){
    int i,j,x,t,n,k,q,a[100000];
    cin>>n>>k>>q;
    for(i=0;i<n;i++){
        a[i]=k-q;
    }
    for(i=0;i<q;i++){
        cin>>x;
        a[x-1]++;
    }
    for(i=0;i<n;i++){
        if(a[i]>0){cout<<"Yes"<<endl;}
        else{cout<<"No"<<endl;}
    }
    return 0;
}



Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
N = int(input())
ABC = [list(map(int,input().split())) for i in range(N)]

dp = [0]*(N+1)
dp[0] = [0,0,0]

for i in range(1,N+1):
    dp[i] = [max([dp[i-1][k]+ABC[i-1][j] for k in range(3) if j != k]) for j in range(3)]

print(max(dp[N]))

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string s, t;
  cin >> s >> t;
  SORT(s);
  RSORT(t);
  cout << (s<t?"Yes":"No") << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
aMax=0
multi=0
a = [0 for i in range(n)]
for i in range(n):
  a[i] = int(input())
  if aMax == a[i]:
    multi = 1
  elif aMax < a[i]:
    aMax = a[i]
    multi = 0

if multi == 1:
  for i in range(n):
    print(aMax)
else:
  for i in range(n):
    if aMax != a[i]:
      print(aMax)
    else:
      if i == 0:
        print(max(a[1:]))
      elif i == n - 1:
        print(max(a[0:i]))  
      else:
        aMax2=max(max(a[:i]),max(a[i+1:]))
        print(aMax2)  


Measured memory_bytes: 14064
#include <stdio.h>
int gcd(int x,int y){
  if(y==0)
    return x;
  else
    return gcd(y,x%y);
}
int main(void){
  int x,y;
  while(scanf("%d %d",&x,&y)!=EOF){
    printf("%d\n",gcd(x,y));
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;


#define rep(a,n) for(int a = 0;a < n;a++)

const ll mod = 1000000007;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

//階乗とその逆元を求めて計算に利用するクラス
class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};

ll merge(ll n, ll m) {
	ll left = 0;
	for (int d = 1; d < n; d++) {
		left += (n - d) * d;
		left %= mod;
	}
	left *= m;
	left %= mod;
	left *= m;
	left %= mod;
	return left;
}

int main(void)
{
	ll n, m, k;
	cin >> n >> m >> k;

	Factorial f(n * m);
	auto c = f.cmb(n * m - 2, k - 2);
	auto a = merge(n, m);
	auto b = merge(m, n);
	auto sum = a + b;
	sum %= mod;
	sum *= c;
	sum %= mod;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3440
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

s = read()
old = ''
for i in list(s):
    if old == i:
        print("Bad")
        exit()
    old = i
print("Good")

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

using namespace std;

int main ()
{
   int a,b;
   std::locale loc;
   cin>>a>>b;
   string s;
   cin>>s;
   char ar[a];
   for(int i=0;i<s.size();i++)
   {
       ar[i]=s[i];
   }
  // boost::to_upper(ar[]);
    for(int i=0;i<s.size();i++)
   {
       if(b==i+1)
       {
           cout<<tolower(ar[i],loc);
       }
       else cout<<ar[i];
   }
  
  return 0;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

static large solve(const int* const a, const int n, const large r) {
    if (n <= 1) return r;

    auto firstbuyday = -1;
    for (auto i = 0; i + 1 < n; ++i) {
        if (a[i] < a[i + 1]) {
            firstbuyday = i;
            break;
        }
    }
    if (firstbuyday < 0) return r;

    auto firstsellday = firstbuyday + 1;
    for (auto i = firstbuyday + 1; i + 1 < n; ++i) {
        if (a[i] >= a[i + 1]) {
            firstsellday = i;
            break;
        }
    }
    auto stocks = r / a[firstbuyday];
    auto profit = stocks * (a[firstsellday] - a[firstbuyday]);
    return solve(a + firstsellday + 1, n - firstsellday - 1, r + profit);
}

int main()
{
    int n;
    cin >> n;
    auto a = vector<int>(n);
    for (auto& a_i : a)
        cin >> a_i;

    auto highest = solve(a.data(), n, 1000);
    cout << highest << endl;
    return 0;
}


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

int main() {
	int N, D, X;
	cin >> N >> D >> X;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	int res = X;
	for (int i = 0; i < N; ++i) {
		++res;
		res += ((D - 1) / a[i]);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N, M = map(int, input().split())
X = [False] * N
D = defaultdict(int)
ans = 0
for i in range(M):
    p, s = input().split()
    p = int(p) - 1

    if X[p] is False:
        if s == 'WA':
            D[p] += 1
            ans += 1
        else:
            X[p] = True


for i in range(N):
    if X[i] is False:
        ans -= D[i]

print(sum(X), ans)


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int x, a;
	cin >> x >> a;
	if (x < a)
		cout << "0";
	else
		cout << "10";

	return 0;
}


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

int main() {
	int n, ans = 0, minElement = INT_MAX, p;
	cin >> n;
	while (n--) {
		cin >> p;
		if (p <= minElement) {
			ans++;
		}
		minElement = min (minElement, p);
	}
	cout << ans << endl; 
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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 int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int x; cin >> x;
  for (int i = x; i > 1; i--) {
    for (int j = 2; j * j <= x; j++) {
      for (int k = 2; k < 11; k++) {
        if (pow(j, k) == i) {
          cout << i << endl;
          return 0;
        }
      }
    }
  }

  cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

unsigned long long solve(unsigned long long a){
    if(a%2 != 0) { 
        return ((a+1)/2)%2;
    }
    else { return (a+1)^solve(a+1); }
}

int main(void)
{
    unsigned long long a, b;
    scanf("%lld %lld", &a, &b);
    printf("%lld\n", solve(a-1)^solve(b));
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
  char cells[4] = {0};
  int count = 0;
  int i;
  
  scanf("%s", cells);
  
  for (i = 0; i < 3; i++) {
    if (cells[i] == '1') {
      count++;
    }
  }
  
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 128
n = int(input())
h = [0] + list(map(int, input().split()))

ans = 0
tmp = 0

for i in range(1, len(h)-1):
    if h[i] >= h[i+1]:
        tmp += 1
        ans = max(ans, tmp)
    else:
        ans = max(ans, tmp)
        tmp = 0

print(ans)

Measured memory_bytes: 20592
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>

using namespace std;
using ll = long long;
const int BIG = 100000007;

int main() {
    string s,t;
    cin >> s >> t;
    ll c = 0;
    for(int i = 0;i < s.length();++i){
        if(s[i] != t[i])++c;
    }
    cout << c << endl;
}




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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

};


int main() {
    int n, k, l;
    cin >> n >> k >> l;

    UnionFind trains(n);
    UnionFind roads(n);


    rep(i, k) {
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        roads.connect(p, q);
    }

    rep(i, l) {
        int r, s;
        cin >> r >> s;
        r--;
        s--;
        trains.connect(r, s);
    }

    map<int, map<int, int>> memo;

    for (int i = 0; i < n; i++) {
        int r_root = roads.root(i);
        int t_root = trains.root(i);
        memo[r_root][t_root]++;
    }

    for (int i = 0; i < n; i++) {
        int r_root = roads.root(i);
        int t_root = trains.root(i);
        cout << memo[r_root][t_root] << endl;
    }

}


Measured memory_bytes: 27776
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	string a,b;
 	cin >> a>>b;
 	bool ans=false;
 	for (int i = 0; i < a.size(); i++) {
 	if(a.substr(a.size()-i-1)+a.substr(0,a.size()-i-1)==b){
 		ans=true;
 	}
 	} 	
 	if(ans){
 		cout << "Yes" << endl;
 	}else{
 		cout << "No" << endl;
 	}
 }

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    let ans = (a + b + 1) / 2;
    ans.to_string()
}


Measured memory_bytes: 2124
using System;
using System.Globalization;
using System.IO.Pipes;
using System.Runtime.InteropServices;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] s = new int[5] { 0, 0, 0, 0, 0 };
            int k;
            for (k = 0; k < 5; k++)
            {
                s[k] = int.Parse(Console.ReadLine());
            }
            int i,j,l;
            string ans = "Yay!";
            l = int.Parse(Console.ReadLine());

            for (i= 0; i<5; i++){
                for (j = 0; j < 5; j++)
                {
                    if (i<j)
                    {
                        if (Math.Abs(s[i] - s[j]) > l)
                        {
                            ans = ":(";
                        }
                    }
                }
            }
            Console.WriteLine(ans);
        }

    }
}


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

const int ms = 256 + 17;
int arr[ms];


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

    int n;
    cin >> n;

    cout << n / 3 << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[1001][1001];
char c[1001][1001];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
      for(int j=1;j<=m;j++)
      {
      	cin>>c[i][j];
      }
    for(int i=1;i<=n;i++)
      for(int j=1;j<=m;j++)
      {
      	if(c[i][j]=='#')
      	{
      		a[i][j-1]++;
      		a[i][j+1]++;
      		a[i-1][j+1]++;
      		a[i-1][j-1]++;
      		a[i+1][j+1]++;
      		a[i+1][j-1]++;
      		a[i-1][j]++;
      		a[i+1][j]++;
      	}
      }
    for(int i=1;i<=n;i++)
    {  
		for(int j=1;j<=m;j++)
    	{
      		if(c[i][j]=='.')
      	  	  cout<<a[i][j];
      		else
      	  	  cout<<"#";
    	}
    	cout<<endl;
    }
	return 0;
}
//23.28 到 24.48


Measured memory_bytes: 512
/* ex9_1
    fmuacshai */

# include<stdio.h>
#include<stdlib.h>
#include<string.h>
# define SIZE 20
//スタックの定義
typedef struct{
    int size;
    int count;
    char string[SIZE];
    char *top;
} stack;
//データの追加
void push(stack *stk,char character){
    if(stk->count>=stk->size){
        exit(1);
    }else{
        stk->top--;
        *(stk->top)=character;
        stk->count++;
    }
}
//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count<=0){
        exit(1);
    }else{
        latest=*(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}
//データの初期化
void initialize(stack *stk){
    stk->size=SIZE;
    stk->count=0;
    stk->top=&(stk->string[SIZE]);
}
//データの出力
void output(stack *stk){
    int i;
    for(i=0;i<stk->count;i++){
        printf("%c",stk->string[SIZE-i-1]);
    }
    printf("\n");
}

int main(void){
    int i;
    //stack stkの定義
    stack stk;
    //入力で利用するinputを定義
    char input[SIZE];
    //データを初期化
    initialize(&stk);
    //入力
    scanf("%s",input);
    //追加と消去をする
    for(i=0;i<strlen(input);i++){
        // 0 or 1ならスタックに保存
        if(input[i]=='0'||input[i]=='1'){
            push(&stk, input[i]);
        //Bならスタックから一つ取り出す。（取り出すものがある場合）
        }else if(input[i]=='B'&&stk.count>0){
            pop(&stk);
        }
    }
    //出力
    output(&stk);
    return 0;
}








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

int main() {
  int n;
  string s;
  cin>>n>>s;
  long long ans=0;
  long long r=0;
  long long g=0;
  long long b=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='R') r++;
    if(s.at(i)=='G') g++;
    if(s.at(i)=='B') b++;
  }
  ans=r*b*g;
  for(int i=0;i<n-2;i++){
    for(int j=1;i+j*2<n;j++){
        if(s.at(i)!=s.at(i+j) && s.at(i+j)!=s.at(i+j*2) && s.at(i+j*2)!=s.at(i)) ans--;
      }
    }
  cout<<ans;
}
        

Measured memory_bytes: 3632
import bisect
s = input()
t = input()

l = len(s)
d = dict()
for i in range(l):
    if s[i] in d.keys():
        d[s[i]].append(i+1)
    else:
        d[s[i]] = [i+1]

ans = 0
now = 0
for i in t:
    if i not in d.keys():
        print(-1)
        exit()

    a = bisect.bisect_right(d[i], now)
    if a == len(d[i]):
        now = d[i][0]
        ans += l
    else:
        now = d[i][a]

print(ans + now)


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,m,num,ans=0;
vector <int> g[200010];
bool vis[200010];

void dfs(int pos)
{
	vis[pos]=true;
	num++;
	rep(i,g[pos].size()) if(!vis[g[pos][i]]) dfs(g[pos][i]);
}

int main()
{
	cin>>n>>m;
	int x,y;
	rep(i,m)
	{
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	repn(i,n)
	{
		if(vis[i]) continue;
		num=0;
		dfs(i);
		ans=max(ans,num);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 21120
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

const int N = 1e5+5;
ll a[N];
ll n, m, v, p;

bool poss(int idx) {
  if (idx < p) return true;
  ll val = a[idx] + m;
  if (val < a[p-1]) return false;
  ll cast = 0;
  cast += p*m;
  cast += (n-idx-1)*m;
  for (int i = p-1; i < idx; ++i) {
    assert(val >= a[i]);
    cast += val - a[i];
  }
  return (cast >= m*v);
}

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  cin >> n >> m >> v >> p;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a+n, greater<ll>());
  int lo = 0;
  int hi = n;
  while (lo+1 < hi) {
    int mid = (lo+hi)/2;
    if (poss(mid)) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  cout << hi << nl;
  return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include <stdlib.h>
#include <string.h>
#include <math.h>

using namespace std;
int main(){
    int n;
    double p;
    cin >> n;

    if(n % 2 == 0){
        p = (n / 2.)/n;
    }else{
        p =((n + 1.) / 2.)/n;
    }

    cout << p;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
int main()
{
    fastIO;
    ll a,b;
    cin>>a>>b;
    set<ll>s;
    s.insert(1);
    s.insert(3);
    s.insert(2);
    s.erase(a);
    s.erase(b);
    cout<<*s.begin()<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */
int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    /*rep(i, k) {
        ll p = b + c;
        ll q = c + a;
        ll r = a + b;
        a = p; b = q; c = r;
        cout << a << ' ' << b << ' ' << c << endl;
    }
    if(abs(a - b) > 1e18) {
        cout << "Unfair" << endl;
        return 0;
    }*/
    if(abs(a - b) > 1e18) {
        cout << "Unfair" << endl;
    }
    else if(k % 2 == 0){
        cout << a - b << endl;
    }
    else cout << b - a << endl;
    return 0;
}


Measured memory_bytes: 3596
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	num, _ := strconv.Atoi(next())
	return num
}

func nextInts(n int) [][]int {
	ints := make([][]int, n)
	for i := range ints {
		ints[i] = make([]int, 3)
	}
	for i := 0; i < n; i++ {
		ints[i][0], ints[i][1], ints[i][2] = nextInt(), nextInt(), nextInt()
	}
	return ints
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {

	scanner.Split(bufio.ScanWords)
	n := nextInt()
	a := nextInts(n)

	dp := make([][]int, n)
	for i := range dp {
		dp[i] = make([]int, 3)
	}

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

	fmt.Println(max(dp[n-1][2], max(dp[n-1][0], dp[n-1][1])))
}


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

using namespace std;

int main(void) {
  int N; cin >> N;
  int dp[N+1][3];
  dp[0][0] = dp[0][1] = dp[0][2] = 0;

  for (int i = 0; i < N; i++) {
    int a, b, c; cin >> a >> b >> c;
    dp[i+1][0] = a + max(dp[i][1], dp[i][2]);
    dp[i+1][1] = b + max(dp[i][2], dp[i][0]);
    dp[i+1][2] = c + max(dp[i][0], dp[i][1]);
  }

  cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
  
  return 0;
}

Measured memory_bytes: 1408
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.InputStream;

import java.io.PrintWriter;

import java.util.Arrays;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);

        final int N = nextInt();

        int[] p = new int[N];

        for (int i = 0; i < N; i++) p[i] = nextInt();

        Arrays.sort(p);

        int sum = 0;
        for (int i = 0; i < N - 1; i++) sum += p[i];

        sum += p[N - 1] / 2;
        out.println(sum);

        out.flush();
    }

    // FastScanner start
    static final InputStream in = System.in;
    static final byte[] buffer = new byte[1024];
    static int ptr = 0;
    static int buflen = 0;
    static boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    static int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    static boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    static String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    static long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    static int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    static double nextDouble() {
        return Double.parseDouble(next());
    }
    // FastScanner end
}


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


namespace ACprac
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] itmp = Console.ReadLine().Split(' ');
            int m = int.Parse(itmp[0]);
            int d = int.Parse(itmp[1]);

            if (m <= d)
            {
                Console.WriteLine(m);
            }
            else
            {
                Console.WriteLine(m-1);
            }
        }
    }
}

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

#define ll long long

using namespace std;

const int N = 2e5 + 123;

ll n, k;

ll a[N], b[N], r, l = 0, pos, ans;

bool check (ll x) {
    ll sum = 0;
    for (int i = 1;i <= n;i ++) {
        sum += max (0ll, a[i] - x / b[i]);
    }
    return sum <= k;
}

int main () {
    cin >> n >> k;
    for (int i = 1;i <= n;i ++) cin >> a[i];
    for (int i = 1;i <= n;i ++) cin >> b[i];
    sort (a + 1, a + n + 1);
    r = 1e18 * 1ll;
    sort (b + 1, b + n + 1);
    reverse (b + 1, b + n + 1);
    while (l <= r) {
        ll mid = (l + r) >> 1;
        if (check (mid)) {
            pos = mid;
            r = mid - 1;
        }else {
            l = mid + 1;
        }
    }
    cout << pos;
}


Measured memory_bytes: 3328
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n;
int solve(){
   vector<string>s(n);
   rep(i,n)cin>>s[i];
   set<string>st;
   rep(i,n)st.insert(s[i]);
   return st.size();
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    cout<<solve()<<endl;
    return 0;
}

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

int main(){
  int n,x;
  cin >> n >> x;
  int k=0;
  int i;
  for(i=0;i<n;i++){
    int a;
    cin >> a;
    k+=a;
    if(k>x)
      break;
  }
  cout << i+1 << endl;
}

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

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

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}


int main()
{
    //textIO();
    fastIO();

    long long n;
    cin >> n;
    vector<long long> arr(n);
    map <long long, long long> mp;
    for(long long i=0;i<n;i++){
        cin >> arr[i];
        mp[arr[i]]++;
    }
    long long nw = 0;
    for(auto it=mp.begin(); it!=mp.end();it++){
        long long c = it->second;
        nw+=(c*(c-1))/2;
    }
    for(long long i=0;i<n;i++){
        long long o = mp[arr[i]], n;
        n = ((o-1)*(o-2))/2;
        o = (o*(o-1))/2;
        cout << nw - (o-n) << '\n';
    }

    return 0;
}


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

int main()
{
  // long long n;

  // cin >> n;

  string s;

  cin >> s;

  if (s.at(0) == 'R' && s.at(1) == 'R' && s.at(2) == 'R')
  {
    cout << 3;
  }
  else if (s.at(0) == 'R' && s.at(1) == 'S' && s.at(2) == 'R')
  {
    cout << 1;
  }
  else if (s.at(0) == 'R' && s.at(1) == 'R' && s.at(2) == 'S')
  {
    cout << 2;
  }
  else if (s.at(0) == 'S' && s.at(1) == 'R' && s.at(2) == 'R')
  {
    cout << 2;
  }
  else if (s.at(0) == 'R' && s.at(1) == 'S' && s.at(2) == 'S')
  {
    cout << 1;
  }
  else if (s.at(0) == 'S' && s.at(1) == 'S' && s.at(2) == 'R')
  {
    cout << 1;
  }
  else if (s.at(0) == 'S' && s.at(1) == 'R' && s.at(2) == 'S')
  {
    cout << 1;
  }
  else{
    cout << 0;
  }

    // vector<int> p(n);

    // rep(i, n) cin >> p.at(i);
  }


Measured memory_bytes: 3616