akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,m;cin>>n>>m;
  V<ll> h(n);
  rep(i,0,n)cin>>h[i];

  VV<int> e(n,V<int>(0));
  rep(i,0,m){
    int a,b;cin>>a>>b;
    a--;b--;
    e[a].pb(b);
    e[b].pb(a);
  }

  ll ans=0;
  rep(i,0,n){
    bool good=true;
    for(auto&& to:e[i]){
      if(h[i]<=h[to])good=false;
    }
    if(good)ans++;
  }

  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 9232
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll R, G;

int main()
{

  std::cin >> R >> G;

  std::cout << G*2-R << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {
  string S;cin >> S;
  if (S == "AAA" || S == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;

	return 0;
}



Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		String s = kb.next();
		int count = 0;
		for (int i = 0; i < n - 2; i++) {
			if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'B' && s.charAt(i + 2) == 'C') {
				count += 1;
			}
		}
		System.out.println(count);
		kb.close();
	}

}


Measured memory_bytes: 23892
#include<iostream>
#include<vector>
#include<set>
using namespace std;

#define MAX 100000

vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX], parent[MAX], lowest[MAX], timer;

void dfs(int current, int prev) {
	prenum[current] = lowest[current] = ++timer;
	
	visited[current] = true;
	
	int next;
	
	for(int i = 0; i < G[current].size(); i++) {
		next = G[current][i];
		if(!visited[next]) {
			parent[next] = current;
			
			dfs(next, current);
			
			lowest[current] = min(lowest[current], lowest[next]);
		} else if(next != prev) {
			lowest[current] = min(lowest[current], prenum[next]);
		}
		
	}
	
}

void art_points() {
	for(int i = 0; i < N; i++) visited[i] = false;
	timer = 1;
	
	dfs(0, -1);
	
	int np = 0;
	set<int> ap;
	
	for(int i = 1; i < N; i++) {
		int p = parent[i];
		if(p == 0) np++;
		else if(prenum[p] <= lowest[i]) ap.insert(p);
	}
	if(np > 1) ap.insert(0);
    for(set<int>::iterator it = ap.begin(); it != ap.end(); it++)
	    cout << *it << endl; 
}

main() {
	int m, s, t;
	cin >> N >> m;
	
	for(int i = 0; i < m; i++) {
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s); 
	}
	
	art_points();
	
	return 0;
	
}

Measured memory_bytes: 6772
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)

int main() {
  int n; cin >> n;
  vector<int> x(n), y(n); REP(i, n) cin >> x[i] >> y[i];
  
  double dist = 0;
  REP(i, n-1) {
    FOR(j, i+1, n) {
      dist += sqrt(pow(x[j] - x[i], 2.0) + pow(y[j] - y[i], 2.0));
    }
  }
  
  cout << fixed << setprecision(10) << dist * 2 / n << endl;
  
  return 0;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

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

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                // assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"3 3
1 7
3 2
1 7"# => r#"702"#,

r#"3 2
2 1
2 3"# => r#"-1"#,

r#"3 1
1 0"# => r#"-1"#,

}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        n: usize,
        m: usize,
        sc: [(usize, usize); m],
    }

    let mut ans = "-1".to_string();

    for i in 0..1000 {
        let mut flag = true;

        let i_str = i.to_string();
        if i_str.len() != n {
            continue;
        }

        let i_array = i_str.chars().collect::<Vec<char>>().iter().map(|&i| i as usize - 48).collect::<Vec<usize>>();

        for j in 0..m {
            if i_array[ sc[j].0 - 1 ] != sc[j].1 {
                flag = false;
                break;
            }
        }

        if flag {
            ans = i_str;
            break;
        }
    }

     ans.to_string()
}

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

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();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    string S; cin >> S;
    int dp[N+1][N+1]; REP(i,N+1)REP(j,N+1) dp[i][j] = 0;

    int ans = 0;
    REP(i,N-1)FOR(j,i+1,N){
        if(S[i] == S[j]){
            if(i == j-1) dp[i+1][j+1] = 1;
            else{
                if(i < j-dp[i][j]) dp[i+1][j+1] = dp[i][j] + 1;
                else dp[i+1][j+1] = dp[i][j];
            }
            chmax(ans, dp[i+1][j+1]);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 97920
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a, b, x;
    cin >> a >> b >> x;
    if (a <= x && a + b >= x)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}

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

int main() {
  int N; cin >> N;
  vector<int> mp(N);
  for (int i = 0; i < N; ++i) {
    int p; cin >> p; --p;
    mp[p] = i;
  }
  int mx = 1, cnt = 1;
  for (int i = 1; i < N; ++i) {
    if (mp[i - 1] > mp[i]) cnt = 0;
    mx = max(mx, ++cnt);
  }
  cout << N - mx << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int mod = 1000000007;

int main() {
    int n;
    ll k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) ans++;
        }
    }
    ans = ans * k % mod;

    int smaller[n];
    for (int i = 0; i < n; i++) {
        smaller[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i] > a[j]) smaller[i]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int add = (ll) smaller[i] * ((k - 1) * k / 2 % mod) % mod;
        ans = (ans + add) % mod;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<set>
using namespace std;
using ll = long long;



int main(void){
	int a, b;
	cin >> a >> b;
	if ((a*b) % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;

	}
	return 0;
}

Measured memory_bytes: 256
# import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb

# def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
INF = 1001001001001
# MOD = 1000000007


def main():

    N = int(input())
    X = list(map(int, input().split()))

    point = INF
    for p in range(1, 101):
        s = 0
        for x in X:
            s += (x - p)**2
        point = min(point, s)

    print(point)


if __name__ == '__main__':
    main()


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n, m, x, y;
  cin >> n >> m >> x >> y;

  vector<int> v(n);
  vector<int> w(m);
  REP (i, n) {
    cin >> v[i];
  }
  REP (i, m) {
    cin >> w[i];
  }

  int a = *max_element(v.begin(), v.end());
  int b = *min_element(w.begin(), w.end());

  if (a < b) {
    FOR (i, a + 1, b + 1) {
      if (x < i && i <= y) {
        cout << "No War" << endl;
        exit(0);
      }
    }
  }
  cout << "War" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

void factor(int M, vector<int>& V) {
    for (int i = 1; i * i <= M; i++) {
        if (M % i == 0) {
            V.push_back(i);
            if (M / i != i) V.push_back(M/i);
        }
    }
}

int main() {
    int N, M; cin >> N >> M;
    vector<int> V;
    factor(M, V);
    sort(V.begin(), V.end());
    auto x = lower_bound(V.begin(), V.end(), M/N);
    if (x == V.end() ) {
        cout << V[V.size() - 1] << endl;
    } else if (*x == M/N) {
        cout << *x << endl;
    } else {
        cout << *prev(x) << endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if(s < t) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
	int num;
	int a[3];
	int max;
	int max_no;
	int sum;
	cin>>num;
	for(int i=0;i<num;i++){
	cin>> a[0]>> a[1]>> a[2];
	max=a[0];
	max_no=0;
	sum=0;
	for(int j=0;j<2;j++){
	if(max<a[j+1]){
	max=a[j+1];
	max_no=j+1;
	}
	}
	for(int j=0;j<3;j++){
		if(j!=max_no){
		sum+=a[j]*a[j];
		}
	}
	if(sum==max*max){
		cout<< "YES"<<endl;
	}else{
		cout<< "NO"<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
#define ll long long
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >>a.at(i);
    ll ans = 0, ma = a.at(0);
    rep(i,n){
      if(a.at(i) < ma){
        ans += ma - a.at(i);
        a.at(i) = ma; 
      }
      else ma = a.at(i);
    }
    cout << ans << endl;
}

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

int gcd(int x, int y) {return (y?gcd(y,x%y):x);}

int gcd(vector<int> &a) {
    int ans = a[0];
    rep(i,a.size()-1) ans = gcd(ans,a[i+1]);
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    cout << gcd(a) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <set>
using namespace std;
int ab(int A, int B){


    if (B % A == 0){
        return A + B;
    }else{
        return B - A;
    }
}

void b(){
    int N,M;
    vector< vector<int> > Aij;
    vector< int > K_list;

    cin >> N >> M;
    for(int i = 0; i < N; i++){
        int K_i;
        cin >> K_i;
        K_list.push_back(K_i);
        Aij.push_back({});
        for(int j = 0; j < K_i; j++){
            int aij;
            cin >>aij;
            Aij[i].push_back(aij);

        }

    }

    set<int> loved(Aij[0].begin(), Aij[0].end());
    for(int i=1; i < N; i++){
        set<int> new_love;
        for(auto x: Aij[i]){
            if (loved.find(x) != loved.end())
                new_love.insert(x);
            }
        loved = move(new_love);
        }

        cout << loved.size();

}

int gcd(int n, int m){
    if (n < m) {
        swap(n, m);
    }
    
    int r = n % m;
    while(r != 0){
        n = m;
        m = r;
        r = n % m;
    }

    return m;

}

int monster(int N, vector<int> Alist){
    int gcd_all = Alist[0];
    for(int i = 1; i < N ; i++){
        gcd_all = gcd(gcd_all, Alist[i]);
    }

    return gcd_all;


}
void c(){
    int N;
    cin >> N;
    vector<int> Alist;
    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        Alist.push_back(tmp);
    }

    cout << monster(N, Alist);

}

int main(){

    c();

    return 0;

}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
	ll n, m;
	cin >> n >> m;
	
	multimap<ll, ll> mapping;
	
	for(ll i=0; i < n; i++) {
		ll cost, cnt;
		cin >> cost >> cnt;
		mapping.insert({cost, cnt});
	}
	
	ll total_cost = 0;
	for(auto& p : mapping) {
		ll cnt = min(m, p.second);
		m -= cnt;
		total_cost += cnt * p.first;
		
		if(m == 0) break;
	}
	
	cout << total_cost;
	
	return 0;
}

Measured memory_bytes: 6528
unittest
{
	assert( [ "3", "aab", "ccb" ].parse.expand.solve == 6 );
	assert( [ "1", "Z", "Z" ].parse.expand.solve == 3 );
	assert( [ "52", "RvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn", "RLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn" ].parse.expand.solve == 958681902 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto s1 = input.front.to!( dchar[] );
	input.popFront;
	auto s2 = input.front.to!( dchar[] );
	return tuple( s1, s2 );
}

auto solve( dchar[] s1, dchar[] s2 )
{
	const MOD = 10L ^^ 9 + 7;
	auto ans = 0L;
	auto i = 0L;
	auto v = false;
	
	// 初手
	if( s1[ i ] == s2[ i ] )
	{
		// 縦置きの場合
		ans = 3;
		i++;
		v = true;
	}
	else
	{
		// 横置きの場合
		ans = 6;
		i += 2;
		v = false;
	}
	
	// 2列目以降
	while( i < s1.length )
	{
		if( s1[ i ] == s2[ i ] )
		{
			// 縦置きの場合
			if( v ) ans = ans * 2 % MOD;		// 縦置き⇒縦置き
//			else    ans = ans * 1 % MOD;		// 横置き⇒縦置き
			i++;
			v = true;
		}
		else
		{
			// 横置きの場合
			if( v ) ans = ans * 2 % MOD;		// 縦置き⇒横置き
			else    ans = ans * 3 % MOD;		// 横置き⇒横置き
			i += 2;
			v = false;
		}
	}
	return ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<math.h>
using namespace std;
int main()
{
    long long int a,b,c,d,f,i,j;
      cin>>a>>b>>c;
      d=a+b+c;
      if(d<22) cout<<"win"<<endl;
      else cout<<"bust"<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pub push_back 
#define pob pop_back 
#define puf push_front
#define pof pop_front
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
using namespace std ;
int main()
{
	ll n ; 
	cin >> n ;
	ll arr[n + 1] , sor[n];
	fo(i , n + 1)
	{
		cin >> arr[i] ;
	}
	fo(i , n)
		cin >> sor[i] ;
	ll ans = 0 ;
	fo(i , n)
	{
		if(arr[i] >= sor[i])
			ans += sor[i] ;
		else
		{
			ans += arr[i] ;
			sor[i] -= arr[i] ;
			if(arr[i+1] >= sor[i])
			{
				ans += sor[i] ;
				arr[i+1] -= sor[i] ;
			}
			else
			{
				ans += arr[i +1] ;
				arr[i + 1] = 0 ;
			}
		}
			
	}
	cout << ans<< endl ;	

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define fill(x, v) memset(x, v, sizeof(x))
// #define int long long
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}

int32_t main()
{
    int n, w;
    cin >> n >> w;
    int dp[n + 1][w + 1];
    int wt[n + 1], val[n + 1];
    fill(dp, 0);
    for (int i = 1; i <= n; i++)
    {
        cin >> wt[i] >> val[i];
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (wt[i] <= j)
            {
                dp[i][j] = max(val[i] + dp[i - 1][j - wt[i]], dp[i - 1][j]);
            }
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    cout << dp[n][w] << endl;
}


Measured memory_bytes: 79104
import itertools

n = int(input())
ln = list(map(int, input().split()))
num = [i for i in range(n)]
combi_list = []
for i in itertools.combinations(num, 3):
    combi_list.append(i)
Ans = 0
for i in range(len(combi_list)):
    hen = sorted([ln[combi_list[i][0]],ln[combi_list[i][1]],ln[combi_list[i][2]]])
    if hen[2] < hen[0]+hen[1] and (hen[0]!=hen[1] and hen[1]!=hen[2] and hen[2] != hen[0]):
        Ans +=1
print(Ans)

Measured memory_bytes: 20592
package main

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

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := bufio.NewScanner(stdin)

	/* 単語ごとに入力するならこれ */
	sc.Split(bufio.ScanWords)

	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	s := sc.Text()

	if a >= 3200 {
		_, _ = fmt.Fprintf(stdout, "%v\n", s)
	} else {
		_, _ = fmt.Fprintf(stdout, "red\n")
	}
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}

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

using namespace std;

#define td typedef
td long long ll;

ll in()
{
    ll a;
    scanf("%lld",&a);
    return a;
}

bitset <2005*2005> ase;

int main()
{
    int n=in(),a[2005],sum=0;
    for(int i=0;i<n;i++){
        a[i]=in();
        sum+=a[i];
    }
    ase.set(0);
    for(int i=1;i<=n;i++)
        ase=ase|(ase<<a[i-1]);
    for(int i=(sum+1)/2;i<=sum;i++)
    {
        if(ase[i])
        {
            printf("%d\n",i);
            return 0;
        }
    }
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
    using namespace std;
    #define ll  long long
    #define rep(i,n) for(ll i=0;i<n;i++)
    #define pb push_back
    #define in insert
    #define test   ll t;cin>>t;while(t--)
    #define bs  binary_search
    #define rep1(x,n) for(ll x=n-1;x>=0;x--) 
    
    #define SORT(x) sort(x.begin(),x.end())
    #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
    #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
    #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
    #define All(x) (x).begin(),(x).end()
    #define rAll(x) (x).rbegin(),(x).rend()
    #define db  double
    #define sc scanf
    #define pf printf
    const ll MAX=1e8;
    //ll d[MAX],h[MAX];
    const double pi=3.14159265358979323846;
    const ll M=2e18 +7;
    ll gcd(ll x,ll y){
    	if(x==0)return y;
    	else return gcd(y%x,x);
    }
    ll lcm(ll x,ll y){
    	return (x*y)/gcd(x,y);
    }
   
      bool isPrime(ll n) 
{  
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6){ 
        if (n % i == 0 || n % (i + 2) == 0){ 
            return false; 
        }
    }
    return true; 
} 
bool pdrome(string s){
    ll n = s.length();
    for(ll i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            return false;
        }
    }
    return true;
}
ll mindig(ll x){
    ll ans = 9;
    ll t = x;
    while(x){
        ans = min(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll maxdig(ll x){
    ll ans = 0;
    ll t = x;
    while(x){
        ans = max(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll modpow(ll x,ll n,ll M){
	if(n==0)return 1%M;
	ll u=modpow(x,n/2,M);
	u=(u*u)%M;
	if(n%2==1)u=(u*x)%M;
	return u;

}
ll sum(ll a) {
    ll result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}
ll digits(long long n) 
{ 
    return floor(log10(n) + 1); 
}                                  

    int main() {
    	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    	int n;
    	cin>>n;
    	int ans=0;
    	for(int x=1;x<=n;x++){
    		int y;
    		cin>>y;
    		if((y&1)&&(x&1))ans++;
    		
    	}
    	cout<<ans;
    return 0;
}
    


Measured memory_bytes: 3696
N = int(input())
A = [0] + list(map(int,input().split()))
B = [0] + list(map(int,input().split()))
C = [0] + list(map(int,input().split()))
ans=0
pre = -2
for i in range(1,N+1,1):
    ans += B[A[i]]
    if A[i]-pre == 1:
        ans+=C[pre]
    pre = A[i]
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) {  // 発見できたとき
    return 1;
  } else {  // 発見できなかったとき
    return 0;
  }
}
unsigned GetDigit(unsigned num) { return log10(num) + 1; }
int main() {
  int n, x, t, cnt = 0;
  cin >> n >> x >> t;
  while (n > 0) {
    n = n - x;
    cnt++;
  }
  cout << t * cnt;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<climits>
#include<cmath>
using namespace std;

vector<vector<int> >G;
vector<int>vec;
int a[100003];
int n,m;

int main(){
    
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=INT_MAX;
    for(int i=-100;i<=100;i++){
        int cur=0;
        for(int j=0;j<n;j++){
            cur+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,cur);
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

struct edge{int from, to, cost;};

const int MAX_N = 1e5;
int N, p[MAX_N], r[MAX_N];
P xx[MAX_N], yy[MAX_N];
edge e[2*MAX_N];

bool cmp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

void init(int n){
    for(int i=0;i<n;i++){
        p[i] = i;
        r[i] = 0;
    }
}

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

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

    if(r[x] < r[y]) p[x] = y;
    else{
        p[y] = x;
        if(r[x]==r[y]) r[x]++;
    }
}

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

int kruskal(){
    sort(e, e+2*N, cmp); init(N);
    
    int res = 0;
    for(int i=0;i<2*N;i++){
        edge ee = e[i];
        if(!same(ee.from, ee.to)){
            unite(ee.from, ee.to);
            res += ee.cost;
        }
    }
    return res;
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        int x, y; cin >> x >> y;
        xx[i].first = x; xx[i].second = i;
        yy[i].first = y; yy[i].second = i;
    }

    sort(xx, xx+N); sort(yy, yy+N);

    for(int i=0;i<N-1;i++){
        e[2*i].from = xx[i].second; e[2*i].to = xx[i+1].second; e[2*i].cost = xx[i+1].first - xx[i].first;
        e[2*i+1].from = yy[i].second; e[2*i+1].to = yy[i+1].second; e[2*i+1].cost = yy[i+1].first - yy[i].first;
    }

    cout << kruskal() << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	while (n--) {
		int out_count = 0;
		int runner_count = 0;
		int score = 0;
		while (true) {
			string event;
			cin >> event;
			if (event == "HIT") {
				if (runner_count != 3) {
					++runner_count;
				}
				else {
					++score;
				}
			}
			else if (event == "HOMERUN") {
				score += runner_count + 1;
				runner_count = 0;
			}
			else { // event == "OUT"
				if (++out_count == 3) {
					cout << score << endl;
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 3136
#include<cstdio>

int n,a[1000001],i;

int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=n-1;i>0;i--)
	{
		if(a[i]<a[i-1])
			a[i-1]--;
		if(a[i-1]==0||a[i-1]>a[i])
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define ll long long
#define cases ll t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)


int main(){
    fast;
    ll i,j,k,n,l,r,m;
    cin>>r;
    double pi=3.141592653589793238;
    cout<<2*pi*r;

    return 0;
}



Measured memory_bytes: 3796
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <climits>
#include <sstream>
#include <algorithm>
#define fastio() ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long 
#define MOD 1000000007
#define inf 9223372036854775807ll
using namespace std;

int maxValRecursive(int days[][3], int i, int avoid, int dp[][3]){
	
	if(i == -1) return 0;

	int ans = 0;
	for(int k = 0; k < 3; k++){
		if(k == avoid) continue;
		if(dp[i][k] != -1) {
			ans = max(ans, dp[i][k]);
			continue;
		}
		ans = max(ans, days[i][k] + maxValRecursive(days, i - 1, k, dp));
		dp[i][k] = ans;
	}
	return ans;
}

int maxValIterative(int days[][3], int n){
	int dp[100001][3];
	memset(dp, -1, sizeof(dp));

	for(int i = 0; i < 3; i++) dp[0][i] = days[0][i];

	for(int i = 1; i < n; i++){
		for(int k = 0; k < 3; k++){
			for(int j = 0; j < 3; j++){
				if(j != k) dp[i][k] = max(dp[i][k], days[i][k] + dp[i - 1][j]);	
			}
		}
	}

	int ans = 0; 
	for(int k = 0; k < 3; k++){
		ans = max(ans, dp[n - 1][k]);
	}

	return ans;

}

int main(){
	int n; cin >> n;
	int days[100001][3];
	
	for(int i = 0; i < n; i++){
		for(int k = 0; k < 3; k++) cin >> days[i][k];
	}

	cout << maxValIterative(days, n);

	return 0;
}

Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N;
LL K;

const LL MOD = 1000000007;
int A[2222];

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	LL ans = 0;
	LL tri1 = (K * (K - 1) / 2) % MOD;
	LL tri2 = (K * (K + 1) / 2) % MOD;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < i; ++j) {
			if (A[j] > A[i]) {
				ans += tri2;
				ans %= MOD;
			}
			else if (A[j] < A[i]) {
				ans += tri1;
				ans %= MOD;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <tuple>
#define FOR0(var, max) for (ui (var) = 0; (var) < (max); ++(var))
#define FOR_INV(var, min, max) for (ui (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

static ui N, K;

int main(void) {
  cin >> N;
  cin >> K;
  ui res = 1;
  FOR0(i, N) {
    if (res + K < res * 2) {
      res += K;
    } else {
      res *= 2;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

def calc(t):
  ans = su = 0
  for i in range(n):
    su += a[i]
    if i % 2 == t:
      if su > 0:
        pass
      else:
        x = 1 - su
        ans += abs(x)
        su = 1
    else:
      if su < 0:
        pass
      else:
        x = - 1 - su
        ans += abs(x)
        su = -1
  return ans
print(min(calc(1), calc(0)))

Measured memory_bytes: 19836
#include <stdio.h>

int f(int);

int main()
{
	int d,total;

	while(scanf("%d",&d) != EOF){
		total = 0;
		for(int i = 1; d*i < 600; i++){
			total += f(d*i) * d;
		}
		printf("%d\n",total);
	}

	return 0;
}

int f(int d){
	return (d * d);
}

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

int main(void){
	int N;
	cin >> N;
	ll L[N];
	rep(i,N) cin >> L[i];

	int ans = 0;

	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			for (int k = j+1; k < N; k++) {
				if (L[i]==L[j] || L[j]==L[k] || L[k]==L[i]) continue;
				ll Lsum = L[i] + L[j] + L[k];
				ll Lmax = max(L[i], L[j]);
				Lmax = max(Lmax, L[k]);
				if (Lsum>2*Lmax) ans++;
			}
		}
	}
	cout << ans << endl;
return 0;
}


Measured memory_bytes: 3636
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn sieve_of_eratosthenes(n: usize) -> Vec<usize> {
    let mut primes = Vec::new();
    if n < 2 {
        return primes;
    } else if n == 2 {
        primes.push(2);
        return primes;
    }
    let mut nums = vec![false; n + 1];
    let mut i = 2;
    while i * i <= n {
        if !nums[i] {
            let mut j = i * 2;
            while j <= n {
                nums[j] = true;
                j += i;
            }
        }
        i += 1;
    }
    for i in 2..nums.len() {
        if nums[i] == false {
            primes.push(i);
        }
    }
    primes
}
fn is_prime(n: usize) -> bool {
    if n <= 3 {
        if n == 0 || n == 1 {
            return false;
        } else {
            return true;
        }
    }
    if n % 2 == 0 {
        return false;
    }
    if n % 3 == 0 {
        return false;
    }
    if n % 6 != 1 && n % 6 != 5 {
        return false;
    }
    let mut i = 5;
    while i * i <= n {
        if n % i == 0 {
            return false;
        }
        if n % (i + 2) == 0 {
            return false;
        }
        i += 6;
    }
    true
}
fn main() {
    let q = get!(usize);
    let mut v = Vec::with_capacity(q);
    for _ in 0..q {
        let tmp = get!(usize, usize);
        v.push(tmp);
    }

    let primes = sieve_of_eratosthenes(100010);
    let mut sum = vec![0; 100010];
    let mut ptr = 1;
    for i in 2..100001 {
        if primes[ptr] == i {
            if is_prime((primes[ptr] + 1) / 2) {
                sum[i] += 1;
            }
            ptr += 1;
        }
        sum[i] += sum[i - 1];
    }
    for i in v.iter() {
        println!("{}", sum[i.1] - sum[i.0 - 1]);
    }
}


Measured memory_bytes: 6780
import java.util.*;

class Main {
        public static void main(String args[]) {
                int[] stack = new int[1000];
                int i = 0;
                try (Scanner sc = new Scanner(System.in)) {
                        while (sc.hasNext()) {
                                String S = sc.next();
                                if (S.charAt(0) == '+') {
                                        stack[i-2] += stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '*'){
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                }
                        }
                }
                System.out.println(stack[0]);
        }
}

Measured memory_bytes: 25960
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	ll sum = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] < a[i - 1]) {
			sum += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}

	cout << sum << endl;
}


Measured memory_bytes: 3992
import fractions
import sys

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
dif = [abs(X-i) for i in x]
d_min = min(dif)

gcd = d_min
for i in dif:
    tmp = fractions.gcd(gcd, i)
    if tmp == 1:
        print(1)
        sys.exit()
    else:
        gcd = tmp

print(gcd)
            

Measured memory_bytes: 16240
from sys import stdin
from itertools import repeat
from collections import defaultdict
def main():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split(), repeat(10, n))
    ans = s = 0
    d = defaultdict(int)
    d[0] = 1
    for x in a:
        s += x
        ans += d[s]
        d[s] += 1
    print ans
main()


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N (1<<18)

ll n;
ll a[111111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	ll res=a[0]-1;
	ll taboo=1;
	repl(i,1,n){
		if(taboo+1<a[i]){
			if(a[i]%(taboo+1)==0){
				res+=(a[i]-1)/(taboo+1);
			}else res+=(a[i]-a[i]%(taboo+1))/(taboo+1);
		}else if(taboo+1==a[i]){
			taboo++;
		}
		//dbg(res);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
N,A,B = [int(i) for i in input().split()]
S = input()

all_passed = 0
foreign_passed = 0
for s in S :
    if (s == 'a' and all_passed < A+B) :
        all_passed += 1
        print("Yes")
        continue
    
    if (s == 'b' and all_passed < A+B and foreign_passed < B) :
        all_passed += 1
        foreign_passed += 1
        print("Yes")
        continue
    
    print("No")


Measured memory_bytes: 4016
#include<iostream>
#include<cstdlib>

using namespace std;
#define MAX 1000
#define N 100

int data[N],num1,num2;

bool flag=false;

bool solve(int i,int m){

  if(i>num1) return false;
  else if(m<0) return false;
  if(m== 0 || m-data[i] == 0){
    flag=true;
    return true;
  }
    else{
      solve(i+1,m);
      solve(i+1,m-data[i]);
  }   
}

int main(){

  int i,m;


  cin >>num1;

  for(i=0;i<num1;i++){
    cin >>data[i];
  }

  cin >>num2;

  for(i=0;i<num2;i++){
    cin >>m;
    flag=false;

    solve(-1,m);
    if(flag==true){
      cout <<"yes"<<endl;
    }  
    else cout <<"no"<<endl;
  }

  return 0;
}

Measured memory_bytes: 856
#include <iostream>
#include <fstream>
#include <limits.h>
#include <algorithm>
using namespace std;

int n, k, v[100005], dp[100005];

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

    for(int i = 1; i <= n; ++i)
        cin >> v[i];

    for(int i = 2; i <= n; ++i){

        int minn = INT_MAX;
        for(int j = i-1; j >= 1 && j >= i - k ; --j){
            minn = min(abs(v[i] - v[j]) + dp[j], minn);
        }
        dp[i] = minn;
    }

    cout << dp[n];

    return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	string s; cin>>s;
	int n=s.size();
	int ans=0;
	rep(i,0,n)if(s[i]=='x')ans++;
	if(ans<8)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,d;
    char c;
    
    scanf("%d %c %d", &a, &c, &b);
    
    switch(c){
        case '+':
            d = a + b;
            break;
        case '-':
            d = a - b;
            break;
    }
    
    cout << d << "\n";
}


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

int main() {
  int N;
  cin>>N;
  int count;
  for(int i=0;i<N;i++) {
    int l_i,r_i;
    cin>>l_i>>r_i;
    count+=r_i-l_i+1;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i]; a[i]--;
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		int val; cin >> val;
		ans += val;
	}

	vector<int> c(n-1);

	for (int i = 0; i < n-1; i++) {
		cin >> c[i];
	}

	for (int i = 0; i < n - 1; i++) {
		if (a[i] + 1 == a[i + 1])ans += c[a[i]];
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [N, K] = r.nn()
    const A = r.nn()

    A.sort((a, b) => b - a)

    let sum = 0

    for (let i = K; i < N; i++) {
      sum += A[i]
    }

    return sum
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}


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

using namespace std;
using ll = long long;

void max_self(ll& a, ll b) {
    a = max(a, b);
}

void min_self(ll& a, ll b) {
    a = min(a, b);
}

const ll INF = 1e18L + 5;

signed main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for (int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); 
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for (int item = 0; item < n; item++) {
        for (int value_already = sum_value - value[item]; value_already >= 0; value_already--) {
            min_self(dp[value_already + value[item]], dp[value_already] + weight[item]);
        }
    }
    ll ans = 0;
    for (int i = 0; i <= sum_value; i++) {
        if (dp[i] <= W) {
            ans = max(ans, (ll) i);
        }
    }
    printf("%lld\n", ans);
    return false;
}

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

using namespace std;

#define ll long long 
#define Fastest ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

vector<pair<int,int>>v;

int main()
{
   int n,a,b;
   
   cin >> n;
   
   for(int i = 1; i <= n; i++)
   {
	   cin >> a >> b;
	   v.push_back(make_pair(b,a));
   }
   
   sort(v.begin(), v.end());
   
   ll sum = 0;
   
   for(int i= 0; i < n; i++)
   {
	   if((sum + v[i].second) > v[i].first)
	   {
		   cout << "No\n";
		   return 0;
	   }
	   else sum += v[i].second;
   }
   
   cout << "Yes\n";
   
   return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	string s;
	cin >> s;
	if (s == "ABC") cout << "ARC\n";
	else cout << "ABC\n";
}

Measured memory_bytes: 3616