akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<" : "<<a<<endl;
#else
#define tr(a)    
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int N;
	cin>>N;
	vi temp(100010);
	rep(i,0,N){
		int k;
		cin>>k;
		temp[k+5]++;
	}
	partial_sum(all(temp),temp.begin());
	int ans=0;
	rep(i,3,100010)ans=max(ans,temp[i]-temp[i-3]);
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {
	    final int n = stdin.nextInt();
	    final int k = stdin.nextInt();

	    if ( n == 0 && k == 0 ) {
		break;
	    }
	    
	    final Queue<Integer> q = new LinkedList<Integer>();
	    int maxVal = Integer.MIN_VALUE;
	    int sum = 0;
	    for ( int i = 0; i < k; i++ ) {
		final int elem = stdin.nextInt();
		q.offer( elem );
		sum += elem;
	    }
	    maxVal = max( maxVal, sum );
	    for ( int i = k; i < n; i++ ) {
		final int elem = stdin.nextInt();
		sum -= q.poll();
		sum += elem;
		q.offer( elem );
		maxVal = max( maxVal, sum );
	    }
	    System.out.println( maxVal );
	}	
    }    
}

Measured memory_bytes: 65760
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

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

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

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "3\n3\n1\n2" => "2",
    "4\n3\n4\n1\n2" => "-1",
    "5\n3\n3\n4\n2\n4" => "3"
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        v: [usize; n],
    }

    let ans;
    let mut count = 0;
    let mut i = 0;

    loop {
        if count >= n {
            ans = -1;
            break;
        }

        if v[i] == 2 {
            ans = count as isize + 1;
            break;
        }

        i = v[i] - 1;
        count += 1;
    }

    ans.to_string()
}

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

/*
   AtCoder contest code
   coder : yoichidon
 */
import java.util.*;
import java.io.*;

class Mod{
    static final int MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long[] a = new long[N];
        for(int n=0; n<N; n++) a[n]=sc.nextLong();

        long[][] dp = new long[N][2*K+1];
        //dp[n][k] : 'n' children share 'k' candies
        for(int k=0; k<=a[0]; k++) dp[0][k]=1;

        for(int n=1; n<N; n++){
            //dp[n][k] = dp[n-1][k-a] + dp[n-1][k-a+1] + ... + dp[n-1][k]
            dp[n][0]=1;
            for(int k=1; k<=K; k++){
                if(k-a[n]>0) dp[n][k] = Mod.sub(dp[n][k-1] + dp[n-1][k], dp[n-1][k-1-(int)(a[n])] );
                else dp[n][k] = Mod.add(dp[n][k-1], dp[n-1][k]);
            }

        }


        System.out.println(dp[N-1][K]);



    }
}


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

ll f(ll n) {return n%2?(n+1)/2%2: n/2%2^n;}

int main() {
  ll a,b;
  cin>>a>>b;
  cout<<(f(a-1)^f(b))<<endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

// #define amari(x) ((x) % 1000000007)
#define amari(x) ((x) % 998244353)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(long i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

std::vector<ll> enum_div(ll n)//nの約数を列挙
{
	std::vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

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

  ll n;
  cin >> n;

  ll res = 0;

  vector<ll> vs = enum_div(n);
  for (ll i : vs) {
    ll a = n/i - 1;
    if (a > 0 && n/a == n%a) {
      res += n/i - 1;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n, k;
    cin >> n >> k;
    vector<pair<P, char>> c(n);
    vector<vector<int>> white(k*2, vector<int>(k*2));
    vector<vector<int>> black(k*2, vector<int>(k*2));
    int num_white = 0;
    int num_black = 0;
    rep(i, n) {
        cin >> c[i].first.first >> c[i].first.second >> c[i].second;
        c[i].first.first %= (k*2);
        c[i].first.second %= (k*2);
        if (c[i].second=='W') {
            white[c[i].first.first][c[i].first.second]++;
            num_white++;
        }
        else {
            black[c[i].first.first][c[i].first.second]++;
            num_black++;
        }
    }
    vector<vector<int>> sumw(k*2, vector<int>(k*2));
    vector<vector<int>> sumb(k*2, vector<int>(k*2));
    rep(i, 2*k) rep(j, 2*k) {
        sumw[i][j] = white[i][j];
        sumb[i][j] = black[i][j];
        if (i>0) {
            sumw[i][j] += sumw[i-1][j];
            sumb[i][j] += sumb[i-1][j];
        }
        if (j>0) {
            sumw[i][j] += sumw[i][j-1];
            sumb[i][j] += sumb[i][j-1];
        }
        if (i>0 && j>0) {
            sumw[i][j] -= sumw[i-1][j-1];
            sumb[i][j] -= sumb[i-1][j-1];
        }
        //cout << i << " " << j << endl;
        //debug(sumw[i][j]);
        //debug(sumb[i][j]);
    }
    
    int ans = 0;
    
    rep(i, k+1) rep(j, k+1) {
        int nw = 0;
        int nb = 0;
        if (i>0) {
            nw += sumw[i-1][j+k-1];
            nb += sumb[i-1][j+k-1];
            if (j>0) {
                nw -= sumw[i-1][j-1];
                nb -= sumb[i-1][j-1];
            }
        }
        if (j>0) {
            nw += sumw[i+k-1][j-1];
            nb += sumb[i+k-1][j-1];
            if (i>0) {
                nw -= sumw[i-1][j-1];
                nb -= sumb[i-1][j-1];
            }
        }
        if (i<k) {
            nw += sumw[2*k-1][j+k-1]-sumw[i+k-1][j+k-1];
            nb += sumb[2*k-1][j+k-1]-sumb[i+k-1][j+k-1];
            if (j>0) {
                nw -= sumw[2*k-1][j-1]-sumw[i+k-1][j-1];
                nb -= sumb[2*k-1][j-1]-sumb[i+k-1][j-1];
            }
        }
        if (j<k) {
            nw += sumw[i+k-1][2*k-1]-sumw[i+k-1][j+k-1];
            nb += sumb[i+k-1][2*k-1]-sumb[i+k-1][j+k-1];
            if (i>0) {
                nw -= sumw[i-1][2*k-1]-sumw[i-1][j+k-1];
                nb -= sumb[i-1][2*k-1]-sumb[i-1][j+k-1];
            }
        }
        chmax(ans, nw+num_black-nb);
        chmax(ans, nb+num_white-nw);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 67152
"use strict";
function main(input) {
  const args = input.split(" ");

  const R = parseInt(args[0]);
  const G = parseInt(args[1]);
  const B = parseInt(args[2]);
  const N = parseInt(args[3]);

  const countR = Math.floor(N / R);
  const countG = Math.floor(N / G);

  let valueRG = 0;
  let ans = 0;

  for(let i = 0; i <= countR; i++) {
      for(let j = 0; j <= countG; j++) {
          valueRG = R * i + G * j;
          if(N < valueRG) continue;
          if((N - valueRG) === 0 || (N - valueRG) % B === 0) {
              ans ++;
          }
      }
  }

  console.log(ans);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
  int h,a; cin >> h >> a;
  int ret;
  if(h%a==0){ret=h/a;}
  else{ret=1+h/a;}
  cout << ret;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <vector>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
using namespace std;
double ex[100001]={0,1.0};

double expectancy(int n,int t)
{
	if (n==0){
		return 0;
	} else if (n==1){
		return 1.0;
	} else {
		if (t < 10){
			return 1.0 + 1.0/pow(2.0,t)*expectancy(n-1,t+1) + (1.0-1.0/pow(2.0,t))*ex[n-2];
		} else {
			return 1.0 + (1.0-1.0/pow(2.0,t))*ex[n-2];
		}
	}
}

int main(void) {
	vector<string> r;
	while (true)
	{
		int n=0;
		scanf("%d",&n);
		if (n==0){
			break;
		}
		//r.push_back(expectancy(n,1));
		for(int i=2; i<=n; i++){
			ex[i] = 1.0 + ex[i-2]/2.0 + expectancy(i-1,2)/2.0;
		}
		ostringstream os;
		os << setprecision(14) << ex[n];
		r.push_back(os.str());
	}
	for(int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1768
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N, M = LI()
    par = [i for i in range(N + 1)]
    par_size = [1 for _ in range(N + 1)]
    def find(x):
        if par[x] == x:
            return x
        else:
            par[x] = find(par[x])
            return par[x]

    def same(x, y):
        return find(x) == find(y)

    def unite(x, y):
        if same(x, y):
            return 0
        par_size[find(y)] += par_size[find(x)]
        par[find(x)] = find(y)
    for _ in range(M):
        A, B = LI()
        unite(A, B)
    ans = 0
    for p in par_size:
        ans = max(ans, p)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 105728
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    ($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;;) => {
        {
            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(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let a = scan!();

    let b = scan!();
    if a == b {
        println!("EQUAL");
    } else if a.len() < b.len() || a < b {
        println!("LESS");
    } else {
        println!("GREATER")
    }
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		while(true){
			String[] input = br.readLine().split(" ");
			int numNumbers = Integer.parseInt(input[0]);
			int sum = Integer.parseInt(input[1]);
			if(numNumbers == 0 && sum == 0)	break;
			int numCombinations = 0;
//				System.out.println(base + ":" + numCombinations);
			numCombinations += getCombinations(numNumbers, sum);
			System.out.println(numCombinations);
		}
	}
	/**
	 * 指定された個数で指定された和になる組み合わせの数を求める
	 * @param numNumbers	数の個数
	 * @param sum			求める和
	 * @param min			使う最小値
	 * @return				組み合わせの数
	 */
	public static int getCombinations(int numNumbers, int sum, int min){
		if(sum < min || numNumbers <= 0)	return 0;
		else if(numNumbers == 1)	return (min <= sum && sum <= 9) ? 1 : 0;
		int combinations = 0;
		for(int value = min; value <= 9; value++){
			combinations += getCombinations(numNumbers - 1, sum - value, value + 1);
		}
		return combinations;
	}
	public static int getCombinations(int numNumbers, int sum){
		return getCombinations(numNumbers, sum, 0);
	}
}

Measured memory_bytes: 15956
// https://atcoder.jp/contests/abc153/tasks/abc153_a
import java.lang.Math.*
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val H = scn.nextInt()
    val A = scn.nextInt()

    println(Math.ceil(H.toDouble()/A.toDouble()).toInt())
}



Measured memory_bytes: 31136
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>

#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;


ll gcd(ll x, ll y){
    while(y != 0){
        ll r = x % y;
        x = y;
        y = r;
    }
    return x;
}

ll num(ll x, ll y){
    return x * y / gcd(x, y);
}

int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    ll l = num(c, d);
    ll bres = b - (b/c+b/d) + b/l;
    ll ares = (a-1) - ((a-1)/c + (a-1)/d) + (a-1)/l;
    cout << bres - ares << endl;
    return 0;
}


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

typedef long long ll;
int main(){
  int N;
  ll H;
  cin >> N >> H;
  vector<ll> B(N);
  vector<ll> C;
  ll a_max = 0;
  for(int i = 0; i < N; i++){
    ll tmp;
    cin >> tmp >> B.at(i);
    if(tmp > a_max){
      a_max = tmp;
    }
  }
  
  for(auto b: B){
    if(b >= a_max){
      C.push_back(b);
    }
  }
  sort(C.rbegin(), C.rend());
  cerr << a_max << " " << C[C.size() -1] << endl;
  
  ll ans = 0;

  for(auto c: C){
    ans++;
    H = H - c;
    if(H<=0) break;
  }
  
  if(H > 0){
    ans += (H + a_max - 1 ) / a_max;
  }
  cout << ans << endl;
    
  
}

Measured memory_bytes: 2168
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));

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

	int N;
	cin>>N;
	VI h(N);
	VI a(N,0);
	int ans=0;
	bool f=true;
	REP(i,N)cin>>h[i];
	while(f){
		f=false;
		REP(i,N){
		
			if(h[i]==a[i])continue;
			else{
				//cout<<h[i]<<endl;
				a[i]++;
				if(h[i+1]==a[i+1] && i+1<N){
					ans++;
				
				}
				if(i+1==N){
					ans++;
				}
					
				f=true;
			}
		}
		//REP(i,N){
		//	cout<<a[i];
		//}
		//cout<<endl;
	}
	
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  
  int a=0, b=0, c=0;
  cin >> a >> b >> c;
  
  int sum1 = a+b;
  int sum2 = a+c;
  int sum3 = b+c;
  
  if(sum1==c || sum2==b || sum3==a) {
    
    cout << "Yes" << endl;
    
  } else {
    
    cout << "No" << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
#define MAXM 2510
#define LL long long
#define MO 998244353
#define PII pair<int,int>
int n,a[MAXN],sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	if(a[1]<0&&a[n]>0)
	{
		int cnt=0;
		for(int i=1;i<=n;i++)
			if(a[i]<0) sum-=a[i];
			else sum+=a[i];
		for(int i=2;i<n;i++)
			if(a[i]<0) cnt++;
			else break;
		printf("%d\n",sum);
		if(cnt*2<=n-2)
		{
			for(int p1=2,p2=cnt+2;p1<=cnt+1;p1++,p2++)
			{
				printf("%d %d\n",a[p2],a[p1]);
				a[p2]-=a[p1];
			}
			for(int i=cnt+2;i<n;i++)
			{
				printf("%d %d\n",a[1],a[i]);
				a[1]-=a[i];
			}
			printf("%d %d\n",a[n],a[1]);
		}
		else
		{
			for(int p1=2,p2=cnt+2;p2<n;p1++,p2++)
			{
				printf("%d %d\n",a[p1],a[p2]);
				a[p1]-=a[p2];
			}
			for(int i=1;i<=cnt+1;i++)
			{
				printf("%d %d\n",a[n],a[i]);
				a[n]-=a[i];
			}
		}
	}
	else
	{
		if(a[n]>0)
		{
			for(int i=2;i<=n;i++) sum+=a[i];
			sum-=a[1];
			printf("%d\n",sum);
			for(int i=2;i<n;i++)
			{
				printf("%d %d\n",a[1],a[i]);
				a[1]-=a[i];
			}
			printf("%d %d\n",a[n],a[1]);
		}
		else
		{
			for(int i=1;i<n;i++) sum-=a[i];
			sum+=a[n];
			printf("%d\n",sum);
			for(int i=1;i<n;i++)
			{
				printf("%d %d\n",a[n],a[i]);
				a[n]-=a[i];
			}
		}
	}
}

Measured memory_bytes: 2176
#include <stdio.h>

#define NUMBER 10

int main(void)
{
	int height[NUMBER];
	int i, j;
	int top[NUMBER] = {0};
	int b_num[NUMBER] = {0};
	int judgment = 1;
	
	for(i = 0; i < NUMBER; i++){
		scanf("%d", &height[i]);
	}
	
	for(i = 0; i < NUMBER; i++){
		for(j = 0; j < NUMBER; j++){
			if(b_num[j] == 0){
				if(height[j] > top[i]){
					top[i] = height[j];
				}
			}
		}
		for(j = 0; j < NUMBER; j++){
			if(b_num[j] == 0){
				if(top[i] == height[j] && judgment == 1){
					b_num[j] = 1;
					judgment = 0;
				}
			}
		}
		judgment = 1;
	}
	for(i = 0; i < 3; i++)
		printf("%d\n",top[i]);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x) memset(x,0,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 1000000
/*------------------------------------------------------------*/

int main(){
	string s;
	cin>>s;
	FOR(i,0,s.length()-1){
		if(i%2==0)cout<<s[i];
	}
}
	
	
	
	
	

Measured memory_bytes: 512
s = input()
t = set(s)
ans = 10**10
for c in t:
  cnt = 0
  x = s
  while len(set(x))!=1:
    ns = ''
    for i in range(len(x)-1):
      if x[i]==c or x[i+1]==c:
        ns += c
      else:
        ns += x[i]
    if ns==x:
      break
    x = ns
    cnt += 1
  else:
    ans = min(cnt,ans)
print(ans)

Measured memory_bytes: 3064
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
#define dump(x) cerr<<#x<<"="<<x<<endl

using namespace std;

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

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

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b)
{
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

void f(ll rest,string s){
    if(rest==0){
        cout<<s<<endl;
    }else{
        for(char c='a';c<='c';c++){
            f(rest -1,s+c);
        }
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m,R;
    cin>>n>>m>>R;
    
    vector<vector<ll>> d(n+1,vector<ll>(n+1,1000000000));
    vector<ll> r(R);
    
    rep(i,R) cin>>r[i];
    
    rep(i,m){
        ll x,y; cin>>x>>y;
        ll c; cin>>c;
        d[x][y]=min(d[x][y],c);
        d[y][x]=min(d[y][x],c);
    }
    sort(ALL(r));
    rrep(i,n) d[i][i]=0;
    
    rrep(k,n){
        rrep(i,n){
            rrep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
        }
    }
    ll ans=1000000000;
    do{
        ll tmp=0;
        rep(i,R-1){
            tmp+=d[r[i]][r[i+1]];
        }
        ans=min(ans,tmp);
    }while(next_permutation(ALL(r)));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {

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

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

using namespace std;

int main(){
    
    string str;

    cin >> str;

    sort(str.begin(), str.end());

    if(str == "abc"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

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

using namespace std;

struct edge {
    int src;
    int dst;
    int cost;
};

int main() {
    int L, N, M;
    cin >> L;

    vector< edge > e;

    N = floor(log2(L)) + 1;
    M = 0;

    for (int i = 1; i < N; i++) {
        e.push_back((edge){i, i + 1, 0});
        e.push_back((edge){i, i + 1, int(pow(2, i - 1))});
        M += 2;
    }

    for (int i = N - 1; i >= 1; i--) {
        if (L - pow(2, N - 1) >= pow(2, i - 1)) {
            e.push_back((edge){i, N, int(L - pow(2, i - 1))});
            L -= pow(2, i - 1);
            M++;
        }
    }

    cout << N << " " << M << endl;
    for (int i = 0; i < M; i++) {
        cout << e[i].src << " " << e[i].dst << " " << e[i].cost << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  A,B,C,D,R,L ;
  cin >> A>> B>>C>>D;
  R=C+D;
  L=A+B;
  if ( R > L) {
    cout << "Right" << endl;
  }
  else if (R==L){
    cout <<"Balanced"<< endl;
  }
  else  {
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
// インクルード
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>

// 名前空間省略
using namespace std;

// メイン
int main()
{
	// 入出力の高速化
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// 表示精度変更
	cout << fixed << setprecision(16);

	int n,l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i=0;i<n;i++) cin >> s[i];
    sort(s.begin(), s.end());
    for(int i=0;i<n;i++) cout << s[i];
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int num_a[26]={};
    int c;
    for(c=getchar();c!=EOF;c=getchar()){
        if('a'<=c&&c<='z'){
            num_a[c-'a']+=1;
        }else if('A'<=c&&c<='Z'){
            num_a[c-'A']+=1;
        }
    }
    for(int i=0;i<26;i++){
        printf("%c : %d\n",i+'a',num_a[i]);
    }
}


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

int main() {
  int n, a, b, c, d, i, check = 0;
  string s, ans = "Yes";
  cin >> n >> a >> b >> c >> d >> s;
  
  if(c < d){
    for(i = a; i < c - 1; i++){
      if(s.at(i) == '#' && s.at(i + 1) == '#'){
        ans = "No";
      }
    }
    
    for(i = b; i < d - 1; i++){
      if(s.at(i) == '#' && s.at(i + 1) == '#'){
        ans = "No";
      }
    }
    
    cout << ans << endl;
  }
  
  else{
    for(i = a; i < c - 1; i++){
      if(s.at(i) == '#' && s.at(i + 1) == '#'){
        ans = "No";
      }
    }
    
    for(i = b - 2; i < d - 1; i++){
      if(s.at(i) == '.' && s.at(i + 1) == '.' && s.at(i + 2) == '.'){
        check++;
        break;
      }
    }
    
    if(check == 1 && ans == "Yes"){
      cout << ans << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

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

ll N;
string X;

long long modpow(const long long a, const long long n, const long long mod)
{
        if (n == 0) return 1;
        long long t = modpow(a, n / 2, mod);
        (t = t * t) %= mod;
        if (n & 1)
			(t = t * a) %= mod;
        return t;
}


int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N >> X;

	ll cnt1=0;
	for (auto e : X) cnt1+=e-'0';

	auto f = [](ll n) -> ll
			 {
				 ll cnt{0};
				 while (true)
				 {
					 if (n == 0) return cnt;
					 ++cnt;
					 n %= __builtin_popcount(n);
				 }
			 };

	ll to1, to2;
	to1 = to2 = 0;
	REP(i, N)
	{
		if (X[i] == '1')
		{
			if (cnt1 > 1)
				(to1 += modpow(2, N-1-i, cnt1-1)) %= (cnt1-1);
			(to2 += modpow(2, N-1-i, cnt1+1)) %= (cnt1+1);
		}
	}

	REP(i, N)
	{
		ll res;

		if (X[i] == '1')
		{
			if (cnt1 <= 1) res = 0;
			else res = f((to1 - modpow(2, N-1-i, cnt1-1) + (cnt1-1)) % (cnt1-1)) + 1;
		}
		else
			res = f((to2 + modpow(2, N-1-i, cnt1+1)) % (cnt1+1)) + 1;
		std::cout << res << std::endl;
	}
	
	return 0;
}


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

int main() {
  int n;
  int a = 0;    // R->Wの数
  int b = 0;    // W->Rの数
  int n_change; // 交換する回数
  std::string s;
  
  std::cin >> n >> s;


  for (int i = 0; i < n; i++)
    if (s[i] == 'R') a++; // 赤の数でaを初期化(交換回数は赤の数)

  // 境界を一番左においた時の交換回数
  n_change = std::max(a, b);

  // はじめの完成形はすべて白. 境界を左から右に移動させ左から赤色していく
  for (int i = 0; i < n; i++) {
    if (s[i] == 'W') b++; // b(W->R)が一つ増える
    else a--;             // a(R->W)がひとつ減る

    // 最小の交換回数を更新
    int now = std::max(a, b);
    n_change = std::min(now, n_change);
  }

  std::cout << n_change << std::endl;
 
  return 0;
}

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


int main() {
    string S; cin >> S;
    int given = 0;
    int digit = 1e7;
    for (int i = 0; i < S.size(); i++) {
        if (i == 4 || i == 7) {
            continue;
        }
        given += (int)(S[i] - '0') * digit;
        digit /= 10;
    }
    int base = 20190430;
    if (given <= base) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
int n;cin>>n;
int b[n-1];
rep(i,n-1)cin>>b[i];
int sum=0;
sum+=(b[0]+b[n-2]);
for(int i=1;i<n-1;i++){
    sum+=min(b[i-1],b[i]);
}
cout << sum << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while(0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N;
string s;
set<string> prefixes, ans;

signed main() {
  cin >> N >> s;
  prefixes.insert("");
  rep(i,N) {
    auto np = prefixes;
    for (auto x : prefixes) {
      string p = x + s[i];
      if (p.size() < 3)
        np.insert(p);
      if (p.size() == 3)
        ans.insert(p);
    }
    prefixes = np;
  }
  cout << ans.size() << endl;
  //for (auto x : ans) {
  //  cout << x << endl;
  //}
  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <functional>
#include <iterator>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end())
#define ll long long
#define INF 2000000000
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define PI 3.14159265358979
int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 };
using namespace std;

int main(){	
	ll a, b;
	cin >> a >> b;
	int x = 0;
	for (int i = 1; a <= b; i++) {
		x++;
		a += a;
	}
	cout << x << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,m,s[2020],t[2020];

ll memo[2020][2020];
bool done[2020][2020];

ll solve(int i, int j){
	if(done[i][j]){
		return memo[i][j];
	}
	done[i][j] = true;
	if(i==n || j==m){
		return memo[i][j] = 1ll;
	}
	memo[i][j] = (solve(i+1,j)+solve(i,j+1)+MOD-solve(i+1,j+1))%MOD;
	if(s[i]==t[j]){
		add_mod(memo[i][j],solve(i+1,j+1));
	}
	return memo[i][j];
}

int main(void){
	int i,j;
	cin >> n >> m;
	for(i=0; i<n; ++i){
		cin >> s[i];
	}
	for(j=0; j<m; ++j){
		cin >> t[j];
	}
	cout << solve(0,0) << endl;
	return 0;
}


Measured memory_bytes: 36096
//file_name:ABC91_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);
    if(x+y>=z)yn;





    return 0;
}



Measured memory_bytes: 256
import sys
S = list(input())
T = list(input())

n = len(S)
m = len(T)

for i in range(n-m,-1,-1):
    K = []
    K = S[i:i+m]
    #print(K)
    for j in range(m):
        if K[j] == "?":
            K[j] = T[j]
    if K == T:
        print("".join((S[:i]+T+S[i+m:])).replace("?","a"))
        sys.exit()

print("UNRESTORABLE")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long dp[300009];
long long inv[307009];
long long fc[323123];
long long inf[323123];
long long r[320421];long long c[128571];
long long mod = 1e9 + 7;
long long C(long long n, long long m){
    if(m > n || m < 0) return 0;
    return fc[n] * inf[m]%  mod * inf[n- m]% mod;
}
pair<long long,long long> x[100009];
int main(){

    long long H, W, n;
    cin >> H>>W>>n;
    inv [0] = inv[1] = fc[0] = inf[0] = 1;
    for(long long i = 2; i <= 200900; i++)
        inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    for(long long i = 1; i <= 200800; i++)
        fc[i] = fc[i - 1] * i % mod,
        inf[i] = inf[i -1] * inv[i] % mod;
    for(long long i = 1; i <= n; i++)
        cin >> x[i].first >> x[i].second;
    x[n + 1].first = H; x[n + 1].second = W;
    n++;
    sort(x+1, x+n+1);
    for(long long i = 1; i <= n; i++)
        r[i] = x[i].first, c[i] = x[i].second;
    for(long long i = 1; i <= n; i++){
        dp[i] = C(r[i] + c[i]-2, r[i]-1);
        for(long long j = 1; j < i; j++)
                dp[i] = (dp[i] - dp[j] * C(c[i] - c[j] + r[i] - r[j], r[i] - r[j]) % mod + mod) % mod;
  

    }
    cout << dp[n] <<endl;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, pair<int, int> > p;
 
#define MOD 1000000007

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

    ll R, C, K;
    cin >> R >> C >> K;

    vector<vector<ll> > x(R, vector<ll>(C));
    vector<vector<vector<ll> > > dp(R, vector<vector<ll> >(C, vector<ll>(3)));

    for(int i = 0; i < K; i++) {
        ll r, c, v;
        cin >> r >> c >> v;
        r--;
        c--;
        x[r][c] = v;
    }

    dp[0][0][0] = x[0][0];

    for(int i = 1; i < C; i++) {
        dp[0][i][0] = max(dp[0][i - 1][0], x[0][i]);
        dp[0][i][1] = max(dp[0][i - 1][1], x[0][i] + dp[0][i - 1][0]);
        dp[0][i][2] = max(dp[0][i - 1][2], x[0][i] + dp[0][i - 1][1]);
    }

    for(int i = 1; i < R; i++) {

        dp[i][0][0] = x[i][0] + dp[i - 1][0][0];

        for(int j = 1; j < C; j++) {
            dp[i][j][0] = max(dp[i][j - 1][0], x[i][j] + *max_element(dp[i - 1][j].begin(), dp[i - 1][j].end()));
            dp[i][j][1] = max(dp[i][j - 1][1], x[i][j] + dp[i][j - 1][0]);
            dp[i][j][2] = max(dp[i][j - 1][2], x[i][j] + dp[i][j - 1][1]);
        }
    }

    cout << *max_element(dp[R - 1][C - 1].begin(), dp[R - 1][C - 1].end()) << endl;
}

Measured memory_bytes: 565124
fun main(args: Array<String>) {
    abc111c()
}

fun abc111c() {
    val n = readLine()!!.toInt()
    val vList = readLine()!!.split(" ").map { it.toInt() }

    val halved = n / 2

    if (vList.all { it == vList[0] }) return println(halved)

    val evensFreq = vList.filterIndexed { index, i -> index % 2 == 0 }.groupBy { it }
        .map { it.value }.sortedByDescending { it.size }

    val oddsFreq = vList.filterIndexed { index, i -> index % 2 != 0 }.groupBy { it }
        .map { it.value }.sortedByDescending { it.size }

    val answer = if (evensFreq.first().first() != oddsFreq.first().first()) {
        n - evensFreq.first().size - oddsFreq.first().size
    } else {
        // 配列外参照起こさせるエッジケースはなさそうなのでこれでいいや
        if (evensFreq[1].size > oddsFreq[1].size) {
            n - evensFreq[1].size - oddsFreq.first().size
        } else {
            n - evensFreq.first().size - oddsFreq[1].size
        }
    }
    println(answer)
}


Measured memory_bytes: 60760
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
//#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

int D;
string str,s,u;
vector<int>c(26);
vector<int>t(366);
vector<vector<int>> ss(366, vector<int>(26));
//vector<vector<int>> last(365, vector<int>(26));
vector<int> last(26);
int satisfaction=0;
int init_score;

int init(){
    vector<int>c_copy(26);
    c_copy=c;
    rsort(c_copy);
    int now=1;
    srand( time(NULL) );
    for (int i = 0; i < D; ++i) {
        t[i]=now;
        //now=min(now+1,26);
        now=rand () % 26+1;
        if(now>26)now=1;
    }

    return 0;

}

int score(){
    satisfaction=0;
    for (int d = 0; d < D; ++d) {
        int i = t[d]-1;
        satisfaction+=ss[d][i];

        last[i]=d+1;
        for (int cc = 0; cc < 26; ++cc) {
            satisfaction-=c[cc]*((d+1)-last[cc]);
        }
        //cout<<satisfaction<<endl;
    }

    return satisfaction;
}

int loop(){
    int old_score=init_score;
    int new_score=0;
    srand( time(NULL) );
    for (int d = 0; d < D; ++d) {
        int now=t[d];
        //t[d]++;
        //t[d]=min(t[d]+1,26);
        t[d]=min(rand()%26+1,26);
        new_score=score();
        if(new_score<=old_score){
            t[d]=now;
            continue;
        }else{
            old_score=new_score;
        }
        //cout<<d<<" "<<new_score<<endl;
        
    }


    return 0;
}

int main() {
    IOS;
    prec;

    cin>>D;
    rep(i,0,26)cin>>c[i];
    for (int y = 0; y < D; ++y) {
        for (int x = 0; x < 26; ++x) {
            cin>>ss[y][x];
        }
    }
    //rep(i,0,D)cin>>t[i];
    //cout<<score();
    init();
    init_score=score();
    //printV(t);
    loop();
    //printV(t);
    for (int j = 0; j < D; ++j) {
        cout<<t[j]<<endl;
    }
    //cout<<satisfaction;









    cout<<endl;
    return 0;
}


Measured memory_bytes: 3712
#include <atcoder/scc>
#include <cstdio>

using namespace std;
using namespace atcoder;

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

    scc_graph g(n);

    for (int i = 0; i < m; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        g.add_edge(u, v);
    }

    auto scc = g.scc();

    printf("%d\n", int(scc.size()));
    for (auto v : scc) {
        printf("%d", int(v.size()));
        for (int x : v) {
            printf(" %d", x);
        }
        printf("\n");
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
// const ll mod = 1000000007;


int main() {
  int n;
  cin>>n;
  vector<pair<ll,ll>> ps(n);
  for (int i = 0; i < n; i++) {
    cin>>ps[i].second>>ps[i].first;
  }
  sort(ps.begin(),ps.end());
  ll time = 0;
  bool ok = true;
  for (int i = 0; i < n; i++) {
    time += ps[i].second;
    if (time > ps[i].first) {
      ok = false;
      break;
    }
  }
  if (ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)


int main(){
    int n;
    int buf;
    cin>>n;
    vi a;
    REP(i,n){
        cin>>buf;
        a.pb(buf-i-1);
    }
    sort(all(a));
    /*REP(i,n){
        cout<<a[i]<<endl;
    }*/
    int b=a[(n+1)/2-1];

    ll ans=0;
    REP(i,n){
        ans+=abs(a[i]-b);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

const int N = 1e5;
int dp[N + 10][3];

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

    for(int i = 0; i < n; i++)
        cin >> dp[i][0] >> dp[i][1] >> dp[i][2];

    for(int j = 1; j < n; j++)
    {
        dp[j][0] += max(dp[j - 1][1], dp[j - 1][2]);
        dp[j][1] += max(dp[j - 1][0], dp[j - 1][2]);
        dp[j][2] += max(dp[j - 1][0], dp[j - 1][1]);
    }
    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<ll>A(N),sum(N+1);
  REP(i,N)cin>>A[i];
  REP(i,N){
    sum[i+1]=sum[i]+A[i];
  }

  ll ans=INFLL;
  FOR(i,1,N){
    ans=min(ans,abs(sum[i]-(sum[N]-sum[i])));
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 3456