akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 177, task a, 2020/08/29
//ms,
/*
添え字が1-indexになってるのに気づいてなくて草。
入力時に1小さいものをとるか、最初に配列を一つ大きくとるか。
*/

int main(void){
  int N, M;
  vector<vector<int>> friends(200001);
  queue<int> next;
  vector<int> dist(200001, -1);
  int ans=1;
  int group_size;

  cin >>N >>M;

  //input
  for(int i=0;i<M;i++){
    int u, v;
    cin >>u >>v;
    friends[u].push_back(v);
    friends[v].push_back(u);
  }

  //bfs
  for(int v=0;v<N;v++){
    if(dist[v] != -1) continue;

    dist[v]=0;
    next.push(v);
    group_size=1;

    while(next.size()!=0){
      int u = next.front();
      next.pop();

      for(long unsigned int i=0;i<friends[u].size();i++){
        int w = friends[u][i];
        if(dist[w] != -1) continue;

        dist[w] = dist[u]+1;
        next.push(w);
        group_size++;
      }
    }//end while
    ans = max(ans, group_size);
  }//end for

  cout <<ans<<endl;
  return 0;
}
/*
お手上げ！！！
解法はunion find木とBFSの二通り。
BFSは連結な重みなしのグラフの最短路問題を線形時間で解けるのが特徴。
また、未探索の頂点が消えるまでやり続ければ連結成分の様子がなんでもわかる。
今回は後者の特徴を使う。
友達のネットワークのグラフの、最大の連結成分の成分個のグループがあればよい。
*/


Measured memory_bytes: 15916
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int A = in.Int();
            int B = in.Int();
            out.println(Math.max(Math.max(A + B, A - B), A * B));
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23124
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn calc(x: u64) -> u64 {
    if x % 2 == 0 {
        x / 2
    } else {
        3 * x + 1
    }
}

fn main() {
    let s: u64 = read();
    let mut tmp = s;

    let mut count: u64 = 1;

    while tmp != 4 {
        tmp = calc(tmp);
        count += 1;
    }

    if s == 1 || s == 2 {
        println!("{}", 4);
    } else {
        println!("{}", count + 3);
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
	int rate;
	while(scanf("%d",&rate)!=EOF){
		if(rate<1200){
			puts("ABC");
			
		}else if(rate<2800){
			puts("ARC");
		}else{
			puts("AGC");
		
		}
	}
	return 0;
}

Measured memory_bytes: 128
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];

    println!("{}", n/3);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;
int main()
{
	string a;
	string s_array[7]{"SUN", "MON","TUE","WED","THU","FRI","SAT" };
	int ans;

	cin >> a;

	for (int i = 6; i >= 0; i--)
	{
		if (a == s_array[i])
		{
			ans = 7 - i;
		}
	}

	cout << ans << endl;

}


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 all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n,q;
    scanf(" %d %d", &n, &q);

    set<int> u;
    map<int,vector<int>> IN,OUT;
    rep(i,n){
        int s,t,x;
        scanf(" %d %d %d", &s, &t, &x);
        IN[s-x].pb(x);
        OUT[t-x].pb(x);

        // printf(" [%d %d)\n", s-x,t-x);
        u.insert(s-x);
        u.insert(t-x);
    }

    queue<int> ASK;
    rep(i,q){
        int d;
        scanf(" %d", &d);
        ASK.push(d);
        u.insert(d);
    }

    set<int> X;
    for(int i:u){
        if(OUT.count(i)) for(int j:OUT[i]) X.erase(j);
        if(IN.count(i)) for(int j:IN[i]) X.insert(j);

        if(!ASK.empty() && ASK.front()==i){
            ASK.pop();
            int ans = -1;
            if(!X.empty()) ans = *X.begin();
            printf("%d\n", ans);
        }
    }
    return 0;
}


Measured memory_bytes: 83328
n =  int(input())

cnt_eight = 0
for i in range(1,n+1):
    cnt = 0
    if i % 2 != 0 :
        for j in range(1,n+1):
            if i%j == 0 :
                cnt += 1
        if cnt == 8:
            cnt_eight += 1

print(cnt_eight)


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

int main(int argc, const char * argv[]) {
    char s[101];
    char p[101];
    char t;
    
    int a,b;
    
    int i,j;
    
    scanf("%s",s);
    scanf("%s",p);
    
    a=(int)strlen(s);
    b=(int)strlen(p);
    
    for(i=0;i<a-1;i++){
        if(strstr(s,p)!=NULL){
            break;
        }
        
        t = s[a-1];
        for(j=a;j-1>0;j--){
            s[j-1]=s[j-2];
        }
        s[0]=t;
        
//        for(j=0;j<a;j++){
//            printf("%c",s[j]);
//        }
//        printf("\n");
    }
    if(strstr(s,p)==NULL){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    
    return 0;
}



Measured memory_bytes: 2124
n=int(input())
L=[0]*4
for i in range(n):
    s=input()
    if "AC"==s:
        L[0] += 1
    elif "WA"==s:
        L[1] += 1
    elif "TLE"==s:
        L[2] += 1
    else:
        L[3] += 1
print("AC x " + str(L[0]))
print("WA x " + str(L[1]))
print("TLE x " + str(L[2]))
print("RE x " + str(L[3]))


Measured memory_bytes: 9196
#include<stdio.h>
int main()
{
    int a,b,t,ret;
    scanf("%d %d %d",&a,&b,&t);
    if( a < 1 || a > 20 ||
        b < 1 || b > 20 || 
        t < 1 || t > 20) return 0;
    ret= 0;
    while(1){
      t = t - a;
      if(t < 0) break;
      ret = ret + b;
      
    }
  
    // 出力
    printf("%d \n",ret);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n; cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  rep(i,n){
    int j = i-1;
    int have = a[i];
    while ( j >= 0 && a[j] > have){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = have;
    rep(k,n-1) cout << a[k] << " ";
    cout << a[n-1] << "\n";
  }
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int top;
int st[1010];

int pop() {
    return st[top--];
}

void push(int x) {
    st[++top] = x;
}

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

    top = 0;
    char s[20];

    while(scanf("%s", s) != EOF) {
        if(s[0] == '+') {
            int a = pop();
            int b = pop();
            push(a+b);
        } 
        else if(s[0] == '-') {
            int a = pop();
            int b = pop();
            push(b-a);
        }
        else if(s[0] == '*') {
            int a = pop();
            int b = pop();
            push(a*b);
        }
        else {
            push(atoi(s));
        }
    }

    cout << pop() << endl;
    
}



Measured memory_bytes: 3280
n,m=map(int,input().split())
h=[0]+list(map(int,input().split()))
l=[]
g=[1 for i in range(0,n+1)]
g[0]=0
for _ in range(m):
    l.append(list(map(int,input().split())))

for j in range(m):

    if h[l[j][1]]>=h[l[j][0]]:
        g[l[j][0]]=0
    if h[l[j][1]]<=h[l[j][0]]:
        g[l[j][1]]=0

print(g.count(1))


Measured memory_bytes: 94092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    ll t, a;
    cin >> t >> a;

    for(int i = 1; i < n; i++){
        ll T, A;
        cin >> T >> A;
        if((double)t / a <= (double)T / A){
            while(a % A != 0) a++;
            t = a / A * T;
        }else{
            while(t % T != 0) t++;
            a = t / T * A;
        }
    }
    cout << a + t << endl;
}

Measured memory_bytes: 256
S=input().strip()

if S=='SUN':
    print(7)
if S=='MON':
    print(6)
if S=='TUE':
    print(5)
if S=='WED':
    print(4)
if S=='THU':
    print(3)
if S=='FRI':
    print(2)
if S=='SAT':
    print(1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int N, i, tmp, A=0, B=0;
  cin >> N;
  vector<int> vec(N);
  for (i=0; i<N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (i=0; i<vec.size(); i++) {
    if (i%2==0) A+=vec.at(i);
    else B+=vec.at(i);
  }
  cout << A-B << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

s = deque(list(input()))
q = int(input())

cont = 0
for i in range(q):
    q_uery = list(map(str, input().split()))
    if int(q_uery[0]) == 1:
        cont += 1
    if int(q_uery[0]) == 2:
        if (int(q_uery[1]) + cont) % 2 == 0:
            s.append(q_uery[2])
        else:
            s.appendleft(q_uery[2])
if cont % 2 == 1:
    s.reverse()

print(''.join(s))


Measured memory_bytes: 8676
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}


fn main() {
    let (K, S)=get!(isize,isize);
    let mut cnt=0;
    for X in 0..K+1{
        if(X>S){continue;}
        else if(X==S){cnt+=1;continue;}
        for Y in 0..K+1{
            if(X+Y>S){continue;}
            else if(X+Y==S){cnt+=1;continue;}
            else if(X+Y+K>=S){cnt+=1;continue;}
            
        }
    }
    println!("{}",cnt);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll f(ll b, ll n){
    if(b < 2) return LINF;
    ll res = 0;
    while(n > 0){
        res += n % b;
        n /= b;
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, s;
    cin >> n >> s;
    ll ans = LINF;
    if(n == s) ans = n + 1;
    else{
        for(int i=2;i<sqrt(n)+1;i++) if(f(i,n) == s) chmin(ans, (ll)i);
        for(int i=1;i<sqrt(n);i++){
            ll B = (n - s) / i + 1;
            if(f(B, n) == s) chmin(ans, B);
        }
    }
    if(ans == LINF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

signed main() {
	int n = in(), k = in();
	bitset<18>b_bs;
	REP(i, k) {
		b_bs.set(in());
	}
	int b = b_bs.to_ulong();
	REP(i, pow(2, n)) {
		if ((i | b) == i) {
			cout << i << ':';
			int i_copy = i;
			for (int j = 0; i_copy > 0; ++j) {
				if (i_copy % 2 == 1)cout << ' ' << j;
				i_copy >>= 1;
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3264
h,w = map(int,input().split())
S = [['' for i in range(w+2)] for j in range(h+2)]
for i in range(h):
    S[i+1][1:w+1] = input()
for i in range(h):
    for j in range(w):
        if S[i+1][j+1]=='.':
            S[i+1][j+1]=str(sum(S[k+i][j:j+3].count('#') for k in range(3)))
    print(*S[i+1][1:w+1],sep='')


Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    
    ll ans = 0;
    reps(i, 1, n + 1){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for i in range(M)]
BC=sorted(BC,key=lambda x:x[1],reverse=True)

T=[0]*N
count=0
cntmp=0
for m in range(M):
    count+=BC[m][0]
    if count>N:
        T[cntmp:]=[BC[m][1]]*(N-count+BC[m][0])
        break
    else:
        T[cntmp:count]=[BC[m][1]]*BC[m][0]
    cntmp=count


#print(A)
#print(T)

D=A+T
D=sorted(D,reverse=True)

ANS=sum(D[:N])

print(ANS)


Measured memory_bytes: 36036
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int b[n];
    for (int i = 0; i < n; i++) cin >> b[i];

    vector <bool> used(n, false);
    vector <int> ans;
    int f = 0;
    for (int i = 0; i < n; i++) {
        int cnt = i + 1;
        for (int j = n-1; j >= 0; j--) {
            if (used[j]) {
                cnt--;
            } else {
                if (b[j] == cnt) {
                    used[j] = true;
                    ans.push_back(cnt);
                    break;
                }
            }
        }
    }

    if (ans.size() != n) {
        cout << -1 << '\n';
    } else {
        for (int x : ans) {
            cout << x << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 888
module fast_prime_sieve
  implicit none
contains
  subroutine primes(p, m, n)
    integer, allocatable, intent(inout) :: p(:)
    integer, intent(inout) :: m
    integer, intent(in) :: n
    integer :: lp(n), pr(n), i, j
    lp(n) = 0
    m = 0
    do i = 2, n
      if (lp(i) == 0) then
        lp(i) = i
        m = m + 1
        pr(m) = i
      end if
      j = 1
      do j = 1, m
        if (pr(j) > lp(i) .or. i * pr(j) > n) exit
        lp(i * pr(j)) = pr(j)
      end do
    end do
    allocate(p(m))
    p = pr(1:m)
  end
end module fast_prime_sieve
module bisection
  implicit none
  integer, private, parameter :: intkind = 4
contains
  integer function lower_bound(a, b) result(res)
    integer(intkind), intent(in) :: a(:), b
    integer :: l, r, m
    l = 0
    r = size(a) + 1
    do while (r - l > 1)
      m = (l + r) / 2
      if (a(m) < b) then
        l = m
      else
        r = m
      end if
    end do
    res = r
  end
  integer function upper_bound(a, b) result(res)
    integer(intkind), intent(in) :: a(:), b
    integer :: l, r, m
    l = 0
    r = size(a) + 1
    do while (r - l > 1)
      m = (l + r) / 2
      if (a(m) > b) then
        r = m
      else
        l = m
      end if
    end do
    res = l
  end
end module bisection
program coprime
  use fast_prime_sieve
  use bisection
  implicit none
  integer :: n, m, d, q, i, j
  integer, allocatable :: a(:), b(:), p(:)
  character(8), parameter :: x = 'pairwise', y = 'setwise ', z = 'not     '
  read(*,*) n
  allocate(a(n))
  read(*,*) a
  call primes(p, m, maxval(a(1:n)))
  allocate(b(m))
  b = 0
  do i = 1, n
    d = a(i)
    do j = 1, m
      q = p(j)
      if (q * q > d) exit
      if (mod(d, q) == 0) then
        b(j) = b(j) + 1
        do while (mod(d, q) == 0)
          d = d / q
        end do
      end if
    end do
    if (d /= 1) then
      j = lower_bound(p, d)
      b(j) = b(j) + 1
    end if
  end do
  write(*,'(a)') trim(merge(x, merge(y, z, all(b < n)), all(b < 2))) // ' coprime'
end program coprime

Measured memory_bytes: 11604
N = int(input())
b_list = list(map(int,input().split()))

a_list = []
a_list.append(b_list[0])

for i in range(len(b_list)-1):
    a_list.append(min(b_list[i],b_list[i+1]))

a_list.append(b_list[-1])

print(sum(a_list))

Measured memory_bytes: 38384
module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let vs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun v -> v in
  let (odds, evens) =
    Array.fold_left (fun (odds, evens) v ->
      (evens, IntMap.add v (1 + try IntMap.find v odds with Not_found -> 0) odds))
    (IntMap.empty, IntMap.empty) vs in
  Printf.printf "%d\n" @@ ( - ) n @@
  match
    List.sort (fun (_, x) (_, y) -> compare y x) @@
    IntMap.bindings odds,
    List.sort (fun (_, x) (_, y) -> compare y x) @@
    IntMap.bindings evens
  with
  | [(u, l)], [(v, m)] ->
      if u = v then max l m else l + m
  | (u, l) :: (_, m) :: _, [(v, n)] -> 
      if u = v then max l (m + n) else l + n
  | [(u, l)], (v, m) :: (_, n) :: _ -> 
      if u = v then max (l + n) m else l + m
  | (u, l) :: (_, m) :: _, (v, n) :: (_, o) :: _ ->
      if u = v then max (l + o) (m + n) else l + n


Measured memory_bytes: 18816
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b-a-b+1<<endl;
}


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

int main(void){
  int k;
  cin >> k;
  int ans = 0;
  rep(a,k) rep(b,k) rep(c,k){
    ans += gcd(a,gcd(b,c));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct range_add_point_value{
	int N;
	vector<T> ST;
	range_add_point_value(int n){
		N = 1;
		while (N < n){
			N *= 2;
		}
		ST = vector<T>(N * 2 - 1, 0);
	}
	range_add_point_value(vector<T> A){
		int n = A.size();
		N = 1;
		while (N < n){
			N *= 2;
		}
		ST = vector<T>(N * 2 - 1, 0);
		for (int i = 0; i < n; i++){
			ST[N - 1 + i] = A[i];
		}
	}
	T operator [](int k){
		k += N - 1;
		T ans = ST[k];
		while (k > 0){
			k = (k - 1) / 2;
			ans += ST[k];
		}
		return ans;
	}
	void add(int L, int R, T x, int i, int l, int r){
		if (R <= l || r <= L){
			return;
		} else if (L <= l && r <= R){
			ST[i] += x;
			return;
		} else {
			int m = (l + r) / 2;
			add(L, R, x, i * 2 + 1, l, m);
			add(L, R, x, i * 2 + 2, m, r);
			return;
		}
	}
	void range_add(int L, int R, T x){
		add(L, R, x, 0, 0, N);
	}
};
int main(){
  int n, q;
  cin >> n >> q;
  range_add_point_value<int> a(n);
  for (int i = 0; i < q; i++){
    int T;
    cin >> T;
    if (T == 0){
      int s, t, x;
      cin >> s >> t >> x;
      a.range_add(s - 1, t, x);
    }
    if (T == 1){
      int t;
      cin >> t;
      cout << a[t - 1] << endl;
    }
  }
}


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

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<n+1;i++){
        if(i%3==0){
            cout<<" "<<i;
        } else if(i%10==3){
            cout<<" "<<i;
        } else if((i%100)/10==3){
            cout<<" "<<i;
        } else if((i%1000)/100==3){
            cout<<" "<<i;
        } else if((i%10000)/1000==3){
            cout<<" "<<i;
        }
    }
    cout<<endl;
}



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

using namespace std;

#define int long long

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}

#define FOR(a,b,c) for(int a=b, __c=c; a<=__c; ++a)
#define FORD(a,b,c) for(int a=b, __c=c; a>=__c; --a)
#define forv(a,b) for(auto &a:b)

#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define reset(f,x) memset(f,x,sizeof(f))
#define fasty ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)

#define bit(x,i) (x>>(i-1)&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))

const int N=2e6+5;
const int mod=1e9+7;
int n,m,f[N],g[N],k;
ii a[N];
int dp[N];

int pw(int x,int i){
   int b=1;
   for(; i; i>>=1, x=x*x%mod) if(i&1) b=b*x%mod;
   return b;
}
int C(int n,int k){
   if(k>n) return 0;
   return f[n]*g[k]%mod*g[n-k]%mod;
}
int ways(int i,int j){
   return C(a[j].fi-a[i].fi+a[j].se-a[i].se, a[j].se-a[i].se);
}

int32_t main(){
   fasty;

   cin>>n>>m>>k;
   FOR(i,1,k) cin>>a[i].fi>>a[i].se;
   a[0]={1,1};
   a[++k]={n,m};
   sort(a+1, a+k+1);

   f[0]=1;
   FOR(i,1,2000000) f[i]=f[i-1]*i%mod;
   g[2000000]=pw(f[2000000],mod-2);
   FORD(i,2000000,1) g[i-1]=g[i]*i%mod;

   FOR(i,1,k){
      dp[i]=ways(0,i);
      FOR(j,1,i-1) if(a[j].se<=a[i].se){
         dp[i]=(dp[i]-ways(j,i)*dp[j]%mod+mod)%mod;
      }
   }
   cout<<dp[k]<<'\n';
}


Measured memory_bytes: 34932
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>

struct Point{ double x, y; };

Point set_p(double a, double b)
{
    Point p;
    p.x = a; p.y = b;
    return p;
}

struct Vector{ double vx, vy; };

Vector set_v(const Point &p1, const Point &p2)
{
    Vector v;
    v.vx = p2.x - p1.x;
    v.vy = p2.y - p1.y;
    return v;
}

double dist(const Point &p1, const Point &p2)
{
    return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}

double norm(const Vector &v)
{
    return (v.vx) * (v.vx) + (v.vy) * (v.vy);
}

double inpro(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vx) + (v1.vy * v2.vy);
}

Point move(const Point &p, const Vector &v, const double t)
{
    Point moved_p;
    moved_p.x = p.x + t * v.vx;
    moved_p.y = p.y + t * v.vy;
    return moved_p;
}

Point horizontal(Point &p1, Point &p2, Point &p3)
{
    Vector v2 = set_v(p1, p2);
    Vector v3 = set_v(p1, p3);
    double t;
    t = inpro(v2, v3) / norm(v2);
    Point p = move(p1, v2, t);
    return p;
}

int main()
{
    double p1x, p1y, p2x, p2y;
    scanf("%lf %lf %lf %lf", &p1x, &p1y, &p2x, &p2y);
    Point P1 = set_p(p1x, p1y);
    Point P2 = set_p(p2x, p2y);
 
    int q;
    scanf("%d", &q);
    double px, py;

    for(int i = 0; i < q; i++){
        scanf("%lf %lf", &px, &py);
        Point P = set_p(px, py);
        Point H = horizontal(P1, P2, P);
        printf("%.12f %.12f\n", 2 * H.x - P.x, 2 * H.y - P.y);
    }

    return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;

typedef vector<ll> vec;
typedef vector<vec> mat;

mat mul(mat A, mat B)
{
	mat C(A.size(), vec(B[0].size()));
	rep(i, A.size()) {
		rep(k, B.size()) {
			rep(j, B[0].size()) {
				C[i][j] += A[i][k] * B[k][j];
				C[i][j] %= MOD;
			}
		}
	}
	return C;
}

mat pow(mat A, ll n)
{
	mat B(A.size(), vec(A.size()));

	rep(i, A.size()) {
		rep(j, A.size()) B[i][j] = 0;
		B[i][i] = 1;
	}

	while (n) {
		if (n & 1) B = mul(B, A);
		A = mul(A, A);
		n >>= 1;
	}

	return B;
}

const int MM = 100010;

int N, M;
int X[MM];

int main() {
	scanf("%d %d", &N, &M);
	rep(i, M) scanf("%d", &X[i]);
	X[M++] = N;

	mat dp{{0},{0},{1}};
	const mat coef{{2,2,1}, {1,1,1}, {1,0,1}};
	const mat skip{{1,2,1}, {0,1,1}, {0,0,1}};

	int la = -1;

	rep(i, M) {
		if (i) {
			dp = mul(skip, dp);
		}

		int k = X[i] - la - 1;
		la = X[i];

		mat t = coef;
		t = pow(t, k);
		dp = mul(t, dp);
	}

	cout << dp[0][0] << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int Height[] = new int[N];
        int ans=0;
        int Max=0;
        for(int i=0;i<N;i++){
            Height[i]=scan.nextInt();
            if(i!=0&&Height[i-1]>=Height[i]){
                ans++;
              if(ans>Max){
                Max=ans;
              }
            }else if(i!=0&&Height[i-1]<Height[i]){
                ans=0;
            }
        }
        
        System.out.println(Max);
    }
}


Measured memory_bytes: 50240
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try{
	    String st;
	    while((st=sc.readLine())!=null){
		String[] sp = st.split(",");
		int[] kyori = new int[12];
		for(int i=0; i<12; i++)
		    kyori[i] = Integer.valueOf(sp[i]);
		int s = 0;
		for(int i=0; i<10; i++)
		    s+=kyori[i];
		double t = (double)s/(kyori[10]+kyori[11]);
		double ss = t * (double)kyori[10];
		for(int i=0; i<10; i++){
		    ss -= (double)kyori[i];
		    if(ss==0){
			System.out.println(i+1);
			break;
		    }
		    else if(ss<0){
			System.out.println(i+1);
			break;
		    }
		}
	    }
	}catch (Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 998244353
const int inf=4e18;
vector<int> prime_factors_freq(int n)
{
	vector<int> f;
	for(int x=2;x*x<=n;x++)
	{
		int cnt=0;
		while(n%x==0)
		{
			cnt++;
			n/=x;
		}
		f.emplace_back(cnt);
	}
	if(n>1)
		f.push_back(1);
	return f;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;cin>>n;
	vector<int> v=prime_factors_freq(n);
	int o=0;
	for(int i=0;i<v.size();i++)
	{
		int j=1;
		for(;;j++)
		{
			if((j*(j+1))/2>v[i])
				break;
		}
		o+=j-1;
	}
	cout<<o<<endl;
}

Measured memory_bytes: 11564
#!/usr/bin/env python3
#ABC57 B

n,m = map(int,input().split())

ab = [list(map(int,input().split())) for _ in range(n)]
cd = [list(map(int,input().split())) for _ in range(m)]

for i in range(n):
    mi = float('inf')
    x,y = ab[i]
    for j in range(m):
        c,d = cd[j]
        if mi > abs(x-c) + abs(y-d):
            ans = j+1
            mi = abs(x-c) + abs(y-d)
    print(ans)


Measured memory_bytes: 39408
#include<bits/stdc++.h>
#define DB(x)            cout << '>' << #x << ':' << x << endl;
#define DB2(x,y) 	     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define rep(i,a,b)       for (ll i = a; i < b; i++)
#define repr(i,a,b)      for (ll i = a; i >= b; i--)
#define pb               push_back
#define F                first
#define S                second
#define mp               make_pair
#define MOD              1000000007
#define MAX              1e9
#define MIN              -1e9
#define vec(i)           vector<i>
#define PLL           	 pair<ll,ll>
#define mem(a,v)         memset(a,v,sizeof(a))
#define pf               printf
#define sc               scanf
#define _s               "%s"
#define _d               "%d"
#define _ll              "%lld"
#define _c               "%c"
#define FAST_IO          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(c) 		     c.begin(),c.end()
typedef long long ll;
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll a[n],val=0,ans=INT_MAX,x=INT_MAX,y=INT_MIN;
	rep(i,0,n)
	{
		cin>>a[i];
		x=min(x,a[i]);
		y=max(y,a[i]);
	}
	rep(i,x,y+1)
	{
		val=0;
		rep(j,0,n)
			val+=abs(i-a[j])*abs(i-a[j]);
		ans=min(ans,val);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())

c_x = 0
c_y = 0
c_t = 0
for i in range(n):
  t, x, y = map(int, input().split())
  d_x = abs(c_x - x)
  d_y = abs(c_y - y)
  d = d_x + d_y
  d_t = t - c_t
  if d_t < d or (d_t - d) % 2 != 0:
    print('No')
    sys.exit(0)
  c_x = x
  c_y = y
  c_t = t
print('Yes')

Measured memory_bytes: 45928
#include "bits/stdc++.h"

using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1127
// Only English

vector<int> parents;
vector<int> ranks;

void init(int n) {
    parents = vector<int>(n, 0);
    ranks = vector<int>(n, 0);
    for (int i = 0; i < n; ++i) {
        parents[i] = i;
    }
}

int find(int x) {
    if (parents[x] == x) {
        return x;
    }
    else {
        parents[x] = find(parents[x]);
        return parents[x];
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
        return;
    }

    if (ranks[x] < ranks[y]) {
        parents[x] = y;
    }
    else if (ranks[x] > ranks[y]) {
        parents[y] = x;
    }
    else {
        parents[y] = x;
        ++ranks[x];
    }
}

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

struct Corridor {
    int start;
    int end;
    double length;
};

const double eps = 1e-12;

bool comp(const Corridor& c1, const Corridor& c2) {
    return c1.length < c2.length;
}

void solve(int n) {
    vector<double> x(n, 0.0), y(n, 0.0), z(n, 0.0), r(n, 0.0);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> z[i] >> r[i];
    }

    vector<Corridor> corridors;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            double l = sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2) + pow(z[i] - z[j], 2));
            Corridor c;
            c.start = i;
            c.end = j;
            if (l + eps < r[i] + r[j]) {
                c.length = 0.0;
            }
            else {
                c.length = l - r[i] - r[j];
            }
            corridors.push_back(c);
        }
    }

    init(n);
    sort(corridors.begin(), corridors.end(), comp);
    double ans = 0.0;
    for (int i = 0; i < corridors.size(); ++i) {
        const Corridor& c = corridors[i];
        if (!same(c.start, c.end)) {
            unite(c.start, c.end);
            ans += c.length;
        }
    }
    cout << ans << endl;
}

void Main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        solve(n);
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(3);
    Main();
    return 0;
}



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

namespace ConsoleApplication17 {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            var result = Method(n);
            Console.WriteLine(result);
        }


        private static int Method(int n) {

            int X = 800; //今までに払った金額
            int y = 200; //もらった金額
            int result = 0; //結果
            
            result = (n * X) - (y * (n / 15));

            return result;
        } 

    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}


int main() {
	int n, m;
	cin >> n >> m;
	hei(llint) a(m), s(m);
	rep(i, 0, m) {
		cin >> a[i];
	}
	sort(a);
	ll sum = 0;
	rep(i, 1, m) {
		s[i] = a[i] - a[i - 1];
		sum += s[i];
	}
	sort(s);
	reverse(s);
	ll x = 0;
	rep(i, 0, n-1) {
		if (i >= m)break;
		x += s[i];
	}
	ll ans = sum - x;
	cout << ans << endl;
	return 0;

}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a,b;
  cin >> a >> b;
  if(a>b)
    swap(a,b);

  REP(i, b)
    cout << a;
  cout << endl;
}


Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())
if H >= 12:
    H -= 12
choperminute = 360/60 ##一分で長針が何度動くか
tanperminute = 30/60 ##一分で短針が何度動くか

tankaku = H*30 + tanperminute*M
chokaku = choperminute*M

if chokaku >= tankaku:
    angle = chokaku -tankaku
else:
    angle = tankaku - chokaku
    
if angle > 180:
    angle = 360 -angle
    
ansjyou = (A**2) + (B**2) - (2*A*B*math.cos(math.radians(angle)))
print(ansjyou**0.5)

Measured memory_bytes: 9260
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, std::vector<long long> a){
    if(find(ALL(a), 1)==a.end()){cout<<-1<<endl;return;}
    else{
        int ans=0;
        int cnt=1;
        REP(i, N){
            if(a[i]==cnt){
                cnt++;
            }
            else{
                ans++;
            }
        }

        cout<<ans<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<limits.h>
using namespace  std;
typedef long long int ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define filla(a,k,n) memset(a,k,sizeof(a[0])*n)
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
int main()
{
	ll n;
	cin>>n;
	ll a[n][3];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	ll dp[n][3];
	fillv(dp,0);
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(ll i=1;i<n;i++)
	{
		for(ll j=0;j<3;j++)
		{
			for(ll k=0;k<3;k++)
			{
				if(k!=j)
				{
					dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
				}
			}
		}
	}
	// for(ll i=0;i<n;i++)
	// {
	// 	for(ll j=0;j<3;j++)
	// 		cout<<dp[i][j]<<" ";
	// 	ln;
	// }
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
#define MIN(x,y) ((x<y)?(x):(y))

int main(){
	int i,j,n,r[10010],a[5];
	while(scanf("%d%d%d",&a[0],&a[1],&a[2])!=EOF){
		if(a[0]==0 && a[1]==0 && a[2]==0)break;
		int m=MIN(a[0]*a[0]+a[1]*a[1],a[2]*a[2]+a[1]*a[1]);
		if(m>a[0]*a[0]+a[2]*a[2])m=a[0]*a[0]+a[2]*a[2];
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d",&r[i]);
			printf("%s\n",(r[i]*r[i]*4>m)?"OK":"NA");
		}
	}
	return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 110
const int MOD = 1000000007;

char mat[maxn][maxn];

int h, w;

bool valid(int a, int b) {
    return a >= 1 and a <= h and b >= 1 and b <= w;
}

int dp[210][210][2];

int solve(int i, int j, bool subs = false) {
    if (i == h and j == w) {
        return 0;
    }

    int &ans = dp[i][j][subs];
    if (ans != -1)
        return ans;
    ans = 1e10;
    int x = i + 1, y = j;
    if (valid(x, y)) {
        if (mat[x][y] == '#') {
            if (subs)
                ans = min(ans, solve(x, y, subs));
            else
                ans = min(ans, 1 + solve(x, y, true));
        } else {
            ans = min(ans, solve(x, y, false));
        }
    }
    x = i, y = j + 1;
    if (valid(x, y)) {
        if (mat[x][y] == '#') {
            if (subs)
                ans = min(ans, solve(x, y, subs));
            else
                ans = min(ans, 1 + solve(x, y, true));
        } else {
            ans = min(ans, solve(x, y, false));
        }
    }
    return ans;
}

void solve() {
    memset(dp, -1, sizeof dp);
    cin >> h >> w;

    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            cin >> mat[i][j];

    bool fl = false;
    if (mat[1][1] == '#')
        fl = true;
    cout << solve(1, 1, fl) + fl << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
    long  long int l,r;

    scanf("%lld %lld",&l,&r);

    int ld = l / 2019;
    int rd = r / 2019;
    int ans = 2020;
    int rr = r% 2019;
    int ll = l%2019;
    int i,j;
    if(ld == rd)
    {
      for(i=ll;i<=rr-1;i++)
      {
        for(j=i+1;j<=rr;j++)
        {
            if(ans > ((i*j)%2019))
                ans = (i*j)%2019;
        }

        if(ans == 0)
        break;
      }
    }
    else 
    {
        ans = 0;
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    int n;cin >>n;
    vector<string>s(n);
    V t(n);
    for (int i = 0; i < n; ++i) {
        cin >>s[i]>>t[i];
    }
    string x;cin >>x;
    int ans=0;
    bool flg=false;
    for (int i = 0; i < n; ++i) {
        if(flg)ans+=t[i];
        if(s[i]==x)flg=true;
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 3604
public class Main{
	
	public static void main(String[] args) {
	    for(int i = 1; i < 10; i++) {
	        for(int j = 1; j < 10; j++) {
	        int k = i * j;
	        System.out.println(i + "x" + j + "=" + k);
	
	        }
	   }
	}
}


Measured memory_bytes: 24416
#include <bits/stdc++.h>
using namespace std;
int main(){
    string A, B;
    cin >> A >> B;
    int ans = -1;
    if (A == B) ans = 0;
    else{
        if (A.size() > B.size()) ans = 1;
        else if (A.size() < B.size()) ans = 2;
        else{
            int64_t count = 0;
            while(ans == -1){
                if (A.at(count) > B.at(count)) ans = 1;
                else if (A.at(count) < B.at(count)) ans = 2;
                else count++;
            }
        }
    }
    if (ans == 0) cout << "EQUAL" << endl;
    if (ans == 1) cout << "GREATER" << endl;
    if (ans == 2) cout << "LESS" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define soja(i,a,n) for(ll i=a;i<=n;i++)
#define ulta(i,n,a) for(ll i=n;i>=a;i--)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define in insert
#define ve vector<ll>
#define se set<ll>
#define ma map<ll,ll>
#define mp make_pair
#define pll vector<pair<ll,ll>>
#define ff first
#define ss second
const ll maxx=1e9+7;
ll n,m,k,sum,t;
int main()
{
  bool fg=0,mg=0;
  cin>>n>>m;
soja(i,0,n-1)
{
    if((4*(n-i)+2*(i))==m||(2*(n-i)+4*i)==m)
    {fg=1;
    //cout<<n-i<<" "<<i<<endl;
    break;}
}
    if(fg)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3620