akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	string s,t;
	 cin>>s>>t;
	 int ss=s.length(),tt=t.length();
	 vector<vector<int>> dp=vector<vector<int>>(ss+1,vector<int>(tt+1,0));
	 vector<vector<int>> back=vector<vector<int>>(ss+1,vector<int>(tt+1,0));
	 FORQ(i,1,ss){
		 FORQ(j,1,tt){
			 dp[i][j]=max(max(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1]+(s[i-1]==t[j-1]));
			 if(dp[i-1][j-1]+(s[i-1]==t[j-1])==dp[i][j])back[i][j]=3;
			 else if(dp[i][j]==dp[i-1][j])back[i][j]=1;
			 else if(dp[i][j]==dp[i][j-1])back[i][j]=2;
		 }
	 }
	 int sz=dp[ss][tt];
	 vector<char> ans(sz);
	 int a=ss,b=tt,i=sz;
	 while(back[a][b]!=0){
		 //cerr<<a<<" "<<b<<" "<<back[a][b]<<" "<<s[a-1]<<" "<<t[b-1]<<endl;
		 if(back[a][b]==1){
			 a--;
		 }else if(back[a][b]==2){
			 b--;
		 }else if(back[a][b]==3){
			 if(s[a-1]==t[b-1]){
				 i--;
				 ans[i]=s[a-1];
			 }
			 a--;b--;
		 }
	 }
	 FOR(i,0,sz){
		 cout<<ans[i];
	 }
	 cout<<endl;
    return 0;
}


Measured memory_bytes: 70912
#include <iostream>
#include <vector>

using namespace std;

class tou
{
    public:
      int num[3][10];
    
};

int main()
{
    
    int N, a;
    vector<tou> vec;
    
    cin >> N;
    
    for(int i = 0; i < 4; ++i)
    { 
      tou t;
      
      for(int j = 0; j < 3; ++j)
      {
          for(int k = 0; k < 10; ++k)
          { t.num[j][k] = 0; }
      }
      vec.push_back(t);
    }
    
    for(int i = 0; i < N; ++i)
    {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        vec[b-1].num[f-1][r-1] += v;
    }
    
    for(int i = 0; i < 4; ++i)
    { 
      for(int j = 0; j < 3; ++j)
      {
          for(int k = 0; k < 10; ++k)
          { cout << " " << vec[i].num[j][k] ; }
          cout << endl;
      }
    
      if(i != 3)
      { cout << "####################" << endl; }
    }
    
    return 0;
}


Measured memory_bytes: 3120
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Akash
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFrog1 solver = new AFrog1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFrog1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = in.nextInt();

            int dp[] = new int[n + 5];
            dp[0] = 0;
            dp[1] = Math.abs(a[0] - a[1]);
            if (n > 2) {
                dp[2] = Math.min(dp[0] + Math.abs(a[0] - a[2]), dp[1] + Math.abs(a[1] - a[2]));
                for (int i = 3; i < n; i++) {
                    dp[i] = Math.min(dp[i - 1] + Math.abs(a[i - 1] - a[i]), dp[i - 2] + Math.abs(a[i - 2] - a[i]));
                }
            }

            out.println(dp[n - 1]);
        }

    }
}



Measured memory_bytes: 50832
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    N = int(input())
    L_list = list(sorted(list(map(int, input().split()))))
    ans = 0
    for i in range(0, 2 * N, 2):
        ans += min(L_list[i], L_list[i + 1])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <math.h>


int main()
{
	int n, num;
	int count, flag;
	int i, j;


	scanf("%d", &n);

	count = 0;
	for(i = 0; i < n; i++){
		scanf("%d", &num);

		if(num == 2){
			count++;
			continue;
		}else if(num < 2 || num % 2 == 0)
			continue;

		j = 3;
		flag = 1;
		while(j <= sqrt(num)){
			if(num % j == 0){
				flag = 0;
				break;
			}
			j += 2;
		}
		if(flag == 1){
//			printf("%d:%d\n", num, count);
			count++;
		}
	}

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

	return 0;
}


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

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
const int MAX_N = 100010;
vector<tuple<int, int, int>> abc;
ll dp[MAX_N][3];
int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        abc.emplace_back(mt(a, b, c));
    }
    dp[0][0] = get<0>(abc[0]);
    dp[0][1] = get<1>(abc[0]);
    dp[0][2] = get<2>(abc[0]);

    for (int i = 1; i < N; i++)
    {
        int a, b, c;
        tie(a, b, c) = abc[i];
        dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a);
        dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b);
        dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c);
    }
    ll result = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            result = max(result, dp[i][j]);
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3828
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

int main(void){
    string s,t;
    cin >> s;
    int n = s.size();
    bool check = true;
    
    for(int i = 0;i < n/2;i++){
        if(s[i] != s[n-1-i])check = false;
    }
    
    for(int i = 0;i < (n-1)/4;i++){
        if(s[i] != s[(n-1)/2-1-i])check = false;
    }
    
    for(int i = (n+3)/2-1;i < n;i++){
        if(s[i] != s[n-1-(i-(n+3)/2)-1])check = false;
    }
    
    if(!check)cout << "No" << endl;
    else cout << "Yes";
}


Measured memory_bytes: 256
//43
#include<iostream>
#include<cmath>

using namespace std;

#define S(X) ((X)*(X))

double dsq(double x,double y,double z,double xx,double yy,double zz){
  return S(xx-x)+S(yy-y)+S(zz-z);
}

int main(){
  for(int n;cin>>n,n;){
    double x[30],y[30],z[30];
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i]>>z[i];
    }
    double cx=0,cy=0,cz=0;
    double f;
    for(double d=10;d>1e-9;d/=10){
      for(int i=0;i<1000;i++){
	int dx=0;
	for(int j=0;j<n;j++){
	  if(dsq(cx,cy,cz,x[dx],y[dx],z[dx])<dsq(cx,cy,cz,x[j],y[j],z[j])){
	    dx=j;
	  }
	}
	double bx,by,bz;
	bx=x[dx]-cx;
	by=y[dx]-cy;
	bz=z[dx]-cz;
	f=sqrt(S(bx)+S(by)+S(bz));
	cx+=bx*d/f;
	cy+=by*d/f;
	cz+=bz*d/f;
      }
    }
    cout.precision(5);
    cout<<fixed<<f<<endl;
  }
  return 0;
}

Measured memory_bytes: 1292
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, k: i64, q: usize,
        a: [usize1; q],
    }
    let mut pts = vec![k - q as i64; n];
    for &a in &a {
        pts[a] += 1;
    }
    for i in 0..n {
        puts!("{}\n", if pts[i] > 0 { "Yes" } else { "No" });
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using namespace std;

int main()
{

    int n,q;
    long long S[10000], T[10000];
    cin >> n;
    for(int i = 0; i<n;i++)
        cin >> S[i];
    cin >> q;
    for(int i = 0; i<q;i++)
        cin >> T[i];
    int count =0;

        for(int j = 0;j<q;j++)
            for(int i = 0;i<n;i++)
    {
        if (S[i]==T[j])
           {

            count++;
            break;}
    }
    cout << count <<endl;
    return 0;
}



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

int main(){

  string s;
  string t[4] = {"maerd", "remaerd", "esare", "resare"};

  cin >> s;

  reverse(s.begin(), s.end());
  int idx = 0;
  bool flag = true;

  while(idx < s.size() && flag){
    int prev = idx;
    int n = 5;
    while(n < 8){
      for(int i = 0; i < 4; i++){
        if(s.substr(idx, n) == t[i]) idx += n;
      }
      if(prev != idx) break;
      n++;
    }
    if(prev == idx) flag = false;
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main
{
    private static List<Integer> numbers;

    public static void main(String[] args)
    {
	Scanner scanner = new Scanner(System.in);
	int nEvenBalls = scanner.nextInt();
	int mOddBalls = scanner.nextInt();
	scanner.close();

	numbers = new ArrayList<>();
	generateNumbers(nEvenBalls, true);
	generateNumbers(mOddBalls, false);

	int numberOfEvenPairs = 0;

	for (int i = 0; i < numbers.size(); i++)
	{
	    for (int j = i + 1; j < numbers.size(); j++)
	    {
		int sum = numbers.get(i) + numbers.get(j);

		if ((sum % 2) == 0)
		{
		    // even
		    numberOfEvenPairs++;
		}
	    }
	}

	System.out.println(numberOfEvenPairs);

    }

    private static void generateNumbers(int howMany, boolean even)
    {
	for (int i = 1; i <= howMany; i++)
	{
	    numbers.add(even ? 2 : 1);
	}
    }

}


Measured memory_bytes: 23380
#include <stdio.h>

int N, M, Q;
int a[64], b[64], c[64], d[64];

int A[12];
int kotae = 0;

void zentan(int pos) {
	if (pos >= N) {
		int kitaeri = 0;
		int i;
		for (i = 0; i < Q; i++) {
			if (A[b[i] - 1] - A[a[i] - 1] == c[i]) kitaeri += d[i];
		}
		if (kitaeri > kotae) kotae = kitaeri;
	} else {
		int i;
		for (i = pos == 0 ? 1 : A[pos - 1]; i <= M; i++) {
			A[pos] = i;
			zentan(pos + 1);
		}
	}
}

int main(void) {
	int i;
	if (scanf("%d%d%d", &N, &M, &Q) != 3) return 1;
	for (i = 0; i < Q; i++) {
		if (scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]) != 4) return 1;
	}

	zentan(0);
	printf("%d\n", kotae);

	return 0;
}


Measured memory_bytes: 1736
#include <iostream>
using namespace std;
int main(){
	int tail,c1,c2;
	char str[102];
	int f[102]={0};
	char *s;
	while(1){
		tail=1;
		fgets(str,102,stdin);
		if(str[0]=='.') break;
		s=str;
 		c1=0; c2=0;
		for(;!(*s == '.');s++){
			if(*s=='(') f[tail++]=1;
			if(*s=='[') f[tail++]=2;
			if(*s==')') if(!(f[--tail]==1)) break;
			if(*s==']') if(!(f[--tail]==2)) break;
		}
		if(tail==1 && *s == '.') cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

string ans = "keyence";
string S;


int main(void) {
	cin >> S;
	int n = S.length();
	ll flag = 0;
	ll deflag = 0;
	FOR(i, 0, n) {
		FOR(k, 0, n) {
			string cur;
			FOR(t, 0, n) {
				if (t >= i && t <= k)continue;
				cur += S[t];
			}
			if (cur == ans) {
				ct("YES");
				return 0;
			}
		}
	}
	ct("NO");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    int cnt = 0;
    rep(i,s.size()) {
        int tmp = 0;
        for(int j=0; j<=i; ++j) {
            if (s[j]=='A' || s[j]=='C' || s[j]=='T' || s[j]=='G') {
                tmp++;
            } else {
                tmp = 0;
            }
        }
        cnt = max(cnt, tmp);
    }
    cout << cnt << "\n";
}



Measured memory_bytes: 256
/* Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define debug(x) cout << #x << " " << x <<endl;
#define set_bits __builtin_popcount
typedef long long ll;
typedef unsigned long long ull;
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod)
{ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll* fact) {ll val1 = fact[n]; ll val2 = mminvprime(fact[r], m); ll val3 = mminvprime(fact[n - r], m); return ((val1 * val2) % m * val3) % m;}
/*--------------------------------------------------------------------------------------------------------------------------*/
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	char ch;
	cin >> ch;
	if (ch >= 'A' && ch <= 'Z')
		cout << 'A' << endl;
	else
		cout << 'a' << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

bool pair_smaller(pair<int, pair<string,int>> a, pair<int, pair<string,int>> b) {
    if(a.second.first != b.second.first)
        return a.second.first < b.second.first;
    else
        return a.second.second > b.second.second;
    
}

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

    vector<pair<int, pair<string,int>>> sp(N);
    for(int i=0; i<N; i++) {
        string s;
        int p;
        cin >> s >> p;
        sp[i] = pair<int, pair<string,int>>(i+1, pair<string,int>(s, p));
    }

    sort(sp.begin(), sp.end(), pair_smaller);

    for(auto& a : sp) {
        cout << a.first << endl;
    }

    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll f(ll n){
    ll sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main(void)
{
    ll n,ans=INF; cin>>n;
    for(int i=1;i<n;i++){
        ll j=n-i;
        ans=min(ans,f(i)+f(j));
        
    }
    cout<<ans<<endl;
    return 0;
}

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

		System.out.println(a >= 13 ? b : a <= 5 ? 0 : b / 2);
	}
}

Measured memory_bytes: 35640
#import
#import math
#import numpy as np
x= int(input())
#= input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= [int(input()) for _ in range(N)]
#= {i:[] for i in range(N)}

if x >= 30:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}


void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  rep(i, n) a[i]--;
  vector<int> b(n);
  cin >> b;
  vector<int> c(n - 1);
  cin >> c;

  ll ans = 0;
  rep(i, n) {
    ans += b[a[i]];
    if (i && a[i] == a[i - 1] + 1) {
      ans += c[a[i - 1]];
    }
  }
  cout << ans << endl;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] Input_ID = Console.ReadLine().Split(' ');
            int[] ID = Input_ID.Select(int.Parse).ToArray();
            int[] counter = new int[N];
            foreach(int a in ID)
            {
                counter[a - 1]++;
            }
            foreach(int ans in counter)
            {
                Console.WriteLine(ans);
            }
        }
    }
}

Measured memory_bytes: 43604
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int dp[3010][3010] = {};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s="+", t="-" , tmp;
  cin >> tmp;
  s += tmp;
  cin >> tmp;
  t += tmp;
  int slen = s.size(), tlen = t.size();
  REP2(i,1,slen)REP2(j,1,tlen){
    if(s[i] == t[j]) dp[i][j] = dp[i-1][j-1] + 1;
    else{
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
  }
  int len = dp[slen-1][tlen-1];
  string ans ="";
  int snow = slen-1, tnow = tlen-1;
  while(len > 0){
    if(len == 0) break;
    if(s[snow] == t[tnow]){
      ans += s[snow];
      snow--; tnow--; len--; 
    }else{
      if(dp[snow][tnow] == dp[snow-1][tnow]){
        snow--;
      }else{
        tnow--;
      }
    }
  }
  reverse(ALL(ans));
  cout << ans;
  return 0;
}

Measured memory_bytes: 35584
fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    println!("{}", solve(&input));
}

fn solve(input: &str) -> String {
    use std::collections::HashMap;
    let mut iter = input.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut count = HashMap::new();
    for _ in 0..n {
        let s = iter.next().unwrap().to_string();
        *count.entry(s).or_insert(0) += 1;
    }
    let mut pairs: Vec<(i32, &String)> = count.iter().map(|(s, &k)| (-k, s)).collect();
    pairs.sort();
    let mut res = String::new();
    let k_max = pairs[0].0;
    for i in 0..pairs.len() {
        if pairs[i].0 != k_max {
            break;
        }
        res.push_str(pairs[i].1);
        res.push('\n');
    }
    res
}

Measured memory_bytes: 26068
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<min(1,C-A);
return 0;}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
const int inf=0x3f3f3f3f;
int n,m[530000][2],li,id[200001],tot;
struct Node{
	int l,r,x,b,e;
};
bool operator < (Node x,Node y){
	return m[x.l+li][x.x]>m[y.l+li][y.x];
}
priority_queue <Node> q;
void build(){
	for (int i=li-1;i;--i){
		m[i][0]=m[i<<1][0]<m[i<<1|1][0]?m[i<<1][0]:m[i<<1|1][0];
		m[i][1]=m[i<<1][1]<m[i<<1|1][1]?m[i<<1][1]:m[i<<1|1][1];
	}
}
int query(int l,int r,int x){
	int ans=inf;
	for (l+=li-1,r+=li+1;l^r^1;l>>=1,r>>=1){
		if (~l&1&&ans>m[l^1][x]) ans=m[l^1][x];
		if (r&1&&ans>m[r^1][x]) ans=m[r^1][x];
	}
	return ans;
}
Node make(int b,int e,int x){
	int t=id[query(b,e,x)];
	return (Node){t,id[query(t,e,x^1)],x,b,e};
}
void read(int& x){
    x=0;
    int y=1;
    char ch=getchar();
    while (ch<'0'||ch>'9'){
        if (ch=='-') y=-1;
        ch=getchar();
    }
    while (ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    x=x*y;
}
int main(){
	//freopen("ferry.in","r",stdin);
	int i,x;
	Node y;
	read(n);
	memset(m,0x3f,sizeof(m));
	for (li=1;li<n+2;li<<=1);
	for (i=1;i<=n;++i){
		read(m[i+li][i&1]);
		id[m[i+li][i&1]]=i;
	}
	build();
	q.push(make(1,n,1));
	//for (i=1;i<=li<<1;++i) printf("m[%d][0]=%d m[%d][1]=%d\n",i,m[i][0],i,m[i][1]);
	n>>=1;
	for (i=1;i<=n;++i){
		y=q.top();
		q.pop();
		printf("%d %d ",m[li+y.l][y.x],m[li+y.r][y.x^1]);
		if (y.b<y.l) q.push(make(y.b,y.l-1,y.x));
		if (y.r<y.e) q.push(make(y.r+1,y.e,y.x));
		if (y.l+1<y.r) q.push(make(y.l+1,y.r-1,y.x^1));
	}
	return 0;
}

Measured memory_bytes: 7284
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Foldable                 as DF
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Sequence                 as SQ
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n <$> readString
toPair [x, y] = (x, y)

main = do
  [n] <- readInt
  print $ solve n

solve n = f n 1 0
 where
  f n a acc
    | n < a * a = acc
    | n `mod` a == 0 = f n
                         (a + 1)
                         (max (length $ show a) (length $ show $ n `div` a))
    | otherwise = f n (a + 1) acc


Measured memory_bytes: 508
// Ivan Carvalho
// Problem A - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 2 * 1e9;

int dp[MAXN], N, K, h[MAXN];

int main() {


	scanf("%d", &N);
	K = 2;
	for (int i = 1; i <= N; i++) {
		scanf("%d", &h[i]);
		dp[i] = INF;
	}
	dp[1] = 0;
	for (int i = 1; i <= N; i++) {
		//dp[i] = INF;
		//dp[i] = min(abs(h[i] - h[i + 1]), abs(h[i] - h[i + 2]));
		for (int j = 1; j <= min(K, N - i); j++)
		{
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[j + i]));
		}
		// for(int j = i+1;j>=max(i - K,1);j--){
		// 	dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]) );

	}

	printf("%d\n", dp[N]);

	return 0;

}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
string s;
using MIte = multimap<int, int>::iterator;



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

	vector<int> vp(N, 0);
	for (int i = 0; i != N; ++i) {
		int p = 0;
		cin >> p;
		vp[i] = p;
	}

	int cnt = 0;
	for (int i = 1; i != N - 1; ++i) {
		if ((vp[i] - vp[i - 1]) * (vp[i] - vp[i + 1]) < 0) {
			cnt++;
		}
	}

	cout << cnt << endl;
  	
	return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

# import numpy as np
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

P = [int(i) for i in read().split()]
P.sort()
print(sum(P[:len(P)-1]))



Measured memory_bytes: 3060
#include "bits/stdc++.h"
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
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
    if (x == 0 && y == 0) return 1;
	else if (x == 0) return 0;
    else if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int Co(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return Co(n + r - 1, r);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    fact();
    int gamma = Div(100 - C, 100);
    int alpha = Div(Div(A, 100),gamma);
    int beta = Div(Div(B, 100),gamma);
    //dump(beta);
    int ans = 0;
    REP(i, 0, N - 1) {
        int pattern = Co(N - 1 + i, N - 1);
        int L = power(alpha, N - 1);
        int R = power(beta, i);
        int len = N + i;
        ans = (ans + Mul(len, Mul( Mul(pattern, Mul(L, R)),alpha))) % mod;

        //ans = (ans + Mul(N + i, Mul(Co(N - 1 + i, N - 1), Mul(alpha, Mul(power(alpha, N - 1), power(beta, i)))))) % mod;
        //dump(ans);
        //cout << len << " " << pattern <<" " << L << " " << R << endl;
    }
    REP(i, 0, N - 1) {
       int pattern = Co(N - 1 + i, N - 1);
        int L = power(beta, N - 1);
        int R = power(alpha, i);
        int len = N + i;
        ans = (ans + Mul(len, Mul( Mul(pattern, Mul(L, R)),beta))) % mod;

        //ans = (ans + Mul(N + i, Mul(Co(N - 1 + i, N - 1), Mul(alpha, Mul(power(alpha, N - 1), power(beta, i)))))) % mod;
        //dump(ans);
        //cout << len << " " << pattern <<" " << L << " " << R << endl;
    }
    //cout << ans << endl;
    cout << Div(ans, gamma) << endl;
    //cout << Div(8, 3) << endl;

    return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
constexpr char nl = '\n';

int main() {
    string s;
    cin >> s;
    for (int len = (s.size() - 1) / 2 * 2; len >= 0; len -= 2) {
        if (s.substr(0, len / 2) == s.substr(len / 2, len / 2)) {
            cout << len << nl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

string S;
string S2 = "keyence";

string f(int i, int n) {

}

signed main() {
    cin >> S;
    for (int pre = 0; pre <= 7; ++pre) {
        int suf = 7 - pre;
        bool flag = true;
        rep(i, pre) {
            if (S[i] != S2[i])flag = false;
        }
        rep(i, suf) {
            if (S[S.size() - suf + i] != S2[pre + i])flag = false;
        }
        if (flag) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p.at(i);
	}

	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		if ((p.at(i + 1) > p.at(i) && p.at(i + 1) < p.at(i + 2)) ||
		 		(p.at(i + 1) < p.at(i) && p.at(i + 1) > p.at(i + 2))) {
					ans++;
				}
	}
	cout << ans << endl;
}


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


int main() {
    string a,b;
    cin>>a>>b;
    int n=a.size();
    int m=b.size();
    vector <vector <int>> dp(a.size(),vector <int> (b.size(),0));
    vector <vector <int>> path(a.size(),vector <int> (b.size(),0));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            int up=(i==0)?0:dp[i-1][j];
            int back=(j==0)?0:dp[i][j-1];
            int prev=(i==0||j==0)?0:dp[i-1][j-1];
            if(up>back){dp[i][j]=up;path[i][j]=1;}
            else {dp[i][j]=back;path[i][j]=0;}
            if(a[i]==b[j]){
                if(prev+1>dp[i][j]){
                    dp[i][j]=prev+1;
                    path[i][j]=2;
            }}
        }
    }
    string ans="";
    int i=n-1;
    int j=m-1;
    if(dp[i][j]>0){
    while(true){
        if(path[i][j]==0){j--;}
        else if(path[i][j]==1){i--;}
        else {ans+=a[i];if(dp[i][j]==1)break;i--;j--;}
    }}
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
 
using namespace std;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long mod = pow(10, 9) + 7;

	long long n, a, b;

	cin >> n >> a >> b;

	long long count = modpow(2, n, mod) - 1;
	count %= mod;

	long long base = 1;

	for(long long i = n - a + 1; i <= n; i++) {
		base *= i % mod;
		base %= mod;
	}

	long long un = 1;

	for(long long i = 2; i <= a; i++) {
		un *= i % mod;
		un %= mod;
	}

	base *= modpow(un, mod - 2, mod) % mod;
	base %= mod;

	count -= base;
	if(count < 0) count += mod;

	base = 1;

	for(long long i = n - b + 1; i <= n; i++) {
		base *= i % mod;
		base %= mod;
	}

	un = 1;

	for(long long i = 2; i <= b; i++) {
		un *= i % mod;
		un %= mod;
	}

	base *= modpow(un, mod - 2, mod) % mod;
	base %= mod;

	count -= base;
	if(count < 0) count += mod;

	cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;

int n,t[55],c[55];

int main(){
  while(cin>>n,n){
    vector<P>v;
    r(i,n)cin>>t[i]>>c[i];
    r(i,n)v.push_back(P(t[i],i));
    sort(v.begin(),v.end());
    queue<P2>q[2];
    r(i,n)q[0].push(P2(v[i].fi,P(v[i].se,c[v[i].se])));
    int cur=0,ans=0;
    while(q[0].size()+q[1].size()){
      vector<P2>v;
      if(q[cur].empty())cur^=1;
      else if(q[cur^1].size()&&q[cur].front().fi>q[cur^1].front().fi)cur^=1;

      int nxt=q[cur].front().fi;
      //cout<<nxt<<endl;
      while(!q[cur].empty()&&q[cur].front().fi<=nxt){
        v.push_back(q[cur].front());
        v[v.size()-1].fi=nxt+t[v[v.size()-1].se.fi];
        q[cur].pop();
      }
      sort(v.begin(),v.end());
      r(i,v.size()){
        if(cur==1)v[i].se.se--;
        if(v[i].se.se==0)ans=nxt;
        else q[cur^1].push(P2(v[i].fi,P(v[i].se.fi,v[i].se.se)));
      }
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3056
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	string S;
	cin >> S;

	cout << S[0] << S[1] << S[2] << endl;

EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}




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

int main() {
    long long N;
    cin >> N;
    vector <long long> table(1e5+10,0);
    for (long long i=0; i<N; i++) {
        long long a;
        cin >> a;
        a+=1;
        table.at(a-1)++;
        table.at(a)++;
        table.at(a+1)++;
    }
    sort(table.begin(), table.end());
    reverse(table.begin(), table.end());
    cout << table.at(0);
}

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

using namespace std;

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

int main(){
  string S;
  cin >> S;
  int n = S.size();
  int A = 0, B = 0;
  rep(i, n){
    char c;
    if (i%2 == 0) c = '0';
    else c = '1';
    if (S[i] != c) ++A;
  }
  rep(i, n){
    char c;
    if (i%2 == 1) c = '0';
    else c = '1';
    if (S[i] != c) ++B;
  }
  cout << min(A, B) << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int h, w;
    char a[100+5][100+5];
    scanf("%d %d", &h, &w);
    for(int i=0; i<h; i++)scanf("%s", a[i]);
    // check bit
    for(int i=0; i<h; i++)a[i][w]='x';
    for(int i=0; i<w; i++)a[h][i]='x';
    
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(a[i][j]=='#'){
                a[i][w]='o';
                a[h][j]='o';
            }
        }
    }
    
    for(int i=0; i<h; i++){
        if(a[i][w]=='o'){
            for(int j=0; j<w; j++){
                if(a[h][j]=='o')printf("%c", a[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 1628
using System;

class AOJ
{
	public static void Main()
	{
		int num = int.Parse(Console.ReadLine().Trim());
		int input, min_val = 0, max_val = 0;
		for(int i = 1; i<= num; i++)
		{
			input = int.Parse(Console.ReadLine().Trim());
			if(i == 1){ min_val = input; }
			else
			{
				if(i == 2)
				{
					max_val = input - min_val;
					min_val = Math.Min(min_val, input);
				}
				else
				{
					max_val = Math.Max(max_val, input - min_val);
					min_val = Math.Min(min_val, input);
				}
			}
		}
		Console.WriteLine(max_val);
	}
}

Measured memory_bytes: 15832
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  int n;cin >> n;
  string s;cin >> s;
  string left = s.substr(0, n);
  string right = s.substr(n, n);
  reverse(right.begin(), right.end());

  map<pair<string,string>,ll> mp;
  rep(mask, (1 << n)) {
    string red = "", blue = "";
    rep(i,n) {
      if( (mask >> i) & 1) red += left[i];
      else blue += left[i];
    }
    mp[ {red, blue} ]++;
  }

  ll res = 0;
  rep(mask, (1 << n)) {
    string red = "", blue = "";
    rep(i,n) {
      if( (mask >> i) & 1) red += right[i];
      else blue += right[i];
    }
    res += mp[ {red, blue} ];
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 91904
#include<stdio.h>
#include<stdbool.h>
int d[] = {[0 ... 1<<18] -1};
int find(int x){
	if(d[x] < 0) return x;
	return d[x] = find(d[x]);
}
bool unite(int x, int y){
	x = find(x); y = find(y);
	if(x == y)return false;
	if(d[x] > d[y]){
		int tmp = x;
		x = y;
		y = tmp;
	}
	d[x] += d[y];
	d[y] = x;
	return true;
}
bool same(int x, int y){return find(x) == find(y);}
int Q, t, u, v;
int main(){
	scanf("%*d%d", &Q);
	while(Q--){
		scanf("%d%d%d", &t, &u, &v);
		if(t){
			printf("%d\n", same(u, v));
		}else {
			unite(u, v);
		}
	}
}

Measured memory_bytes: 2392
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = in.nextInt();
		}
		int ans = 0;
		char sign = '0';
		for (int i = 0; i < N - 1; i++) {
			char tmp = A[i + 1] - A[i] > 0 ? '+' : A[i + 1] - A[i] == 0 ? '0' : '-';
			if (tmp == '0' || sign == '0') {
				sign = tmp != '0' ? tmp : sign;
			} else if (tmp != sign) {
				ans++;
				sign = '0';
			}
		}
		ans++;
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 51108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int taka = (a+d-1)/d;
  int aoki = (c+b-1)/b;
  if(taka>=aoki){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int N; cin >> N;
	vector<vector<int>> G(N, vector<int>(N,INF));
	rep(i,N) G[i][i] = 0;
	vector<string> S(N);
	rep(i,N) cin >> S[i];
	rep(i,N) rep(j,N) if (S[i][j] == '1') G[i][j] = 1;

	rep(k,N) {
		rep(i,N) {
			if (G[i][k] == INF) continue;
			rep(j,N) {
				if (G[k][j] == INF) continue;
				chmin(G[i][j],G[i][k]+G[k][j]);
			}
		}
	}
    
	int p = -1;
	int maxd = 0;
	rep(i,N) rep(j,N) if (chmax(maxd,G[i][j])) p = i;

	vector<int> d(N,-1);
	d[p] = 0;
	queue<int> que;
	que.emplace(p);
	while (!que.empty()) {
		int v = que.front(); que.pop();
		rep(i,N) {
			if (G[v][i] != 1) continue;
            if (d[i] == -1) {
				d[i] = d[v] + 1;
				que.emplace(i);
			} else {
				if (d[i] == d[v]) {
					cout << -1 << endl;
					return 0;
				}
			}

		}
	}

	cout << maxd+1 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

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

int main()
{
  int A, B, T; cin >> A >> B >> T;

  int t = 0, ans = 0;
  while (t < T+0.5) {
    t += A;
    ans += B;
  }

  cout << ans-B << endl;
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

const ll MAX_N = 200200;

ll par[MAX_N];
ll u_rank[MAX_N];

void init(ll n) {
    for(ll i = 0; i < n; i++) {
        par[i] = i;
        u_rank[i] = 0;
    }
}

ll find(ll x) {
    if(par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if(x == y)
        return;
    if(u_rank[x] < u_rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if(u_rank[x] == u_rank[y])
            u_rank[x]++;
    }
}

bool same(ll x, ll y) { return find(x) == find(y); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k, l;

    ll N, M;
    cin >> N >> M;
    init(N);
    vll A, B;
    for(i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        A.push_back(a);
        B.push_back(b);
        unite(a, b);
    }
    vll counts(N, 0);
    for(i = 0; i < N; i++) {
        counts[find(i)]++;
    }
    ll ans = 0;
    for(i = 0; i < N; i++) {
        ans = max(ans, counts[i]);
    }
    cout << ans << endl;

    return 0;
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  
  int k, r;
  k = m / n;
  r = m % n;
  while (r % k != 0) {
    --k;
    r = m - n * k;
  }
  cout << k << endl;
  return 0;
}

Measured memory_bytes: 256