akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b


def lcm(a, b):
    y = a*b / gcd(a, b)
    return int(y)

def f(n):
  if n < 2:
    return 1
  elif n >= 2:
    return n * f(n - 2)


n = INT()
# print@(f(n))

# while n != 1 or n != 2:
#   n = n - 2
#   print(n)

# print(p_l)
# print(two)
# print(five)
# exit()
# a = n // 10
# print(a)
# print(124999999999999995-a)
# b = n // 2
# c = n // 5
# print(b)
# print(c)
a = 5
a_l = []

if n % 2 == 1:
  print(0)
elif n % 2 == 0: # 偶数
# if n == 0:
#   print(1)
# if 
# elif n > 1 and n <= 5:
#   print(0)

# elif n % 2 == 0:
  a = 5
  n = n // 2
  while a <= n:
    a_l.append(a)
    a = a * 5
  # print(a_l[-1])
  # print(a_l)
  ans = 0
  for a in a_l:
    ans += n // a
  
  print(ans)
# elif n % 2 == 1:





Measured memory_bytes: 5228
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////


int main() {
ll ans = 0;
	int N; cin >> N;
	ll a[N+1];
	ll b[N+1];
	ll c[N+1];

	rep(i,N){cin >> a[i] >> b[i] >> c[i];}

	ll A[N+1]; // i日目にaを選んだ時の幸福度の和
	ll B[N+1];
	ll C[N+1];

	rep(i,N)
	{
		if(i == 0){A[0] = a[0]; B[0] = b[0]; C[0] = c[0];continue;}

		A[i] = max(B[i-1],C[i-1]) + a[i];
		B[i] = max(A[i-1],C[i-1]) + b[i];
		C[i] = max(A[i-1],B[i-1]) + c[i];
	}


	ans = max(A[N-1],max(B[N-1],C[N-1]));

	cout << ans << endl;
}

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

int main(){
  double r,s,l,pi;
  scanf("%lf",&r);
  pi=3.141592653589;
  s=r*r*pi;
  l=2*r*pi;
  printf("%f %f\n",s,l);
  return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;(a)<=i;--i)
template<class T> class segtree{
	int n = 1;
	vector<T> dat;
	T def;
	function<T(T, T)> f1;
	function<void(T&, T)> f2;
public:
	segtree(const int& _n, function<T(T, T)> _f1, function<void(T&, T)> _f2, const T _def = 0)
		: f1(_f1), f2(_f2), def(_def) {
		while (n < _n)n <<= 1;
		dat.resize(n << 1, def);
	}
	segtree(const vector<T>& _dat, function<T(T, T)> _f1, function<void(T&, T)> _f2, const T _def = 0)
		: f1(_f1), f2(_f2), def(_def) {
		int _n = _dat.size();
		while (n < _n)n <<= 1;
		dat.resize(n << 1, def);
		FOR(i, 0, _n)dat[i + n] = _dat[i];
		rFOR(i, 1, n)dat[i] = f1(dat[i << 1], dat[i << 1 | 1]);
	}
	void update(int i, T a) {
		i += n;
		f2(dat[i], a);
		while (1 < i) {
			i >>= 1;
			dat[i] = f1(dat[i << 1], dat[i << 1 | 1]);
		}
	}
	T value(const int a, const int b, int l, int r, int k) {
		if (a <= l && r <= b)return dat[k];
		if (r <= a || b <= l)return def;
		T s = value(a, b, l, l + r >> 1, k << 1);
		T t = value(a, b, l + r >> 1, r, k << 1 | 1);
		return f1(s, t);
	}
	T value(const int a, const int b) { return value(a, b, 0, n, 1); }
};

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int q; cin >> q;

	vector<int> a(n);
	FOR(i, 0, n)a[i] = 1 << (s[i] - 'a');
	segtree<int> seg(a,
		[](int a, int b) {return a | b; },
		[](int& a, int b) {a = b; });

	while (q--) {
		int t; cin >> t;
		if (t == 1) {
			int i; char c; cin >> i >> c;
			seg.update(i - 1, 1 << (c - 'a'));
		}
		else {
			int l, r; cin >> l >> r;
			int b = seg.value(l - 1, r);
			int ans = 0;
			FOR(i, 0, 26)if (b & (1 << i))++ans;
			cout << ans << "\n";
		}
	}
}

Measured memory_bytes: 7044
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] s = new int[N];
    int total =0;
    for (int i =0; i<N; i++) {
      s[i] = sc.nextInt();
      total += s[i];
    }
    Arrays.sort(s);
    int a =0;
    while (total % 10 == 0) {
      if (s[a] % 10 != 0) {
        total -= s[a];
      }
      a++;
      if (a == N) {
        total = 0;
        break;
      }
    }
    System.out.println(total);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod2 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9


int main()
{
    int n;
    cin >> n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    sort(v.begin(),v.end(),greater<int>());
    int ind=1,f=0;
    lli ans=v[0];
    for(int i=2;i<n;i++)
    {
        ans+=v[ind];
        if(f==0)
            f=1;
        else
        {
            ind+=1;
            f=0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    int A, B;
    cin >> A >> B;
    int ans = std::max(0, A-2*B);
    cout << ans << endl;
    return 0;
}


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

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

    // int n; cin>>n;
    string s;
    cin>>s;

    bool flag = false;
    for(int i=0; i<3; i++){
        if(s[i]=='7'){
            flag=true;
            break;
        }
    }

    if(flag)    cout<<"Yes";
    else       cout<<"No";

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

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

void solve(ll N, vector<ll> A, ll Q, vector<ll> B, vector<ll> C) {
  unordered_map<ll, ll> count;
  REP(i, N)
    count[A[i]]++;

  ll ans(0);
  for (auto& pair : count)
    ans += pair.first * pair.second;

  REP(i, Q) {
    count[C[i]] += count[B[i]];
    ans += count[B[i]] * (C[i] - B[i]);
    count[B[i]] = 0;

    cout << ans << endl;
  }
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
  }
  ll Q;
  cin >> Q;
  vector<ll> B(Q);
  vector<ll> C(Q);
  REP(i, Q) {
    cin >> B[i];
    cin >> C[i];
  }

  solve(N, move(A), Q, move(B), move(C));

  return 0;
}


Measured memory_bytes: 9452
#include<cstdio>
using namespace std;

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

char f[5][8];
signed main(void){
  int i, j, n;
  for(int t = 0;;t++){
    if(scanf("%d", &n) == -1)break;
    if(t)puts("");
    rep(i, 5){
      rep(j, 8)f[i][j] = '*';
      f[i][2] = '=';
      f[i][1 - (n % 10) / 5] = ' ';
      f[i][3 + (n % 5)] = ' ';
      n /= 10;
    }

    rep(j, 8){
      rep(i, 5)printf("%c", f[4 - i][j]);
      puts("");
    }
  }
  return 0;
}

Measured memory_bytes: 2552
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt()
	D := readInt()
	X := make([][]int, N)
	for i := range X {
		X[i] = make([]int, D)
		for j := range X[i] {
			X[i][j] = readInt()
		}
	}

	var ans int
	for i := range X {
		for j := i + 1; j < N; j++ {
			d2 := dist2(X[i], X[j])
			r := int(math.Sqrt(float64(d2)))
			if r*r == d2 {
				ans++
			}
		}
	}
	println(ans)
}

func dist2(x, y []int) int {
	var ans int
	for i := range x {
		ans += (x[i] - y[i]) * (x[i] - y[i])
	}
	return ans
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
n,k=map(int,input().split())
a=[0]*n
a=list(map(int,input().split()))
a=sorted(a)
mod=10**9+7
ans=1

if (k%2==0 or a[-1]>=0):
    mlt1=a[0]*a[1]
    mlt2=a[-2]*a[-1]
    l=0
    r=-1
    for i in range(k//2):
        if (mlt1>=mlt2):
            ans*=mlt1%mod
            l+=2
            if (l<=n-2):
                mlt1=a[l+1]*a[l]
        else:
            ans*=mlt2%mod
            r-=2
            if (r>=-n+1):
                mlt2=a[r-1]*a[r]
        ans%=mod
    if (k%2==1):
        ans*=a[r]
        ans%=mod
    
else:
    for i in range(k):
        ans*=a[n-1-i]
        ans%=mod
        
print(ans)

Measured memory_bytes: 33292
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;
using namespace std;

void solve(long long N) {

  long long ret = 180 * (N - 2);
  std::cout << ret << '\n';
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
signed main()
{
    fast;
    int n;
    cin>>n;
    int num = (n+1)/2;
    ld ans = num/(ld)(n);
    cout<<fixed<<setprecision(12)<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
const int INF = 100000000;
typedef pair<int, int> P;
int R, C;
int sx, sy, gy, gx;
char grid[50][50];
int d[50][50];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int bfs() {
	queue<P>que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) {
			d[i][j] = INF;
		}
	}
	que.push(P(sy, sy));
	d[sy][sx] = 0;
	while (que.size()) {
		P p = que.front(); que.pop();
		if (p.first == gy&&p.second == gx) {
			break;
		}
		rep(i, 4) {
			int nx = p.second + dx[i];
			int ny = p.first + dy[i];
			if (0 <= nx&&nx < C && 0 <= ny&&ny < R&&grid[ny][nx] != '#'&&d[ny][nx] == INF) {
				que.push(P(ny, nx));
				d[ny][nx] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[gy][gx];
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> R >> C ;
	int ans = R*C;
	sy = 0;
	sx = 0;
	gy = R - 1;
	gx = C - 1;
	rep(i, R) {
		rep(j, C) {
			cin >> grid[i][j];
			if (grid[i][j] == '#') { ans--; }
		}
	}
	cout <<max(-1,ans- bfs()-1 )<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T>using onset=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll n; 
    cin>>n; 
    ll a[n];
    for(ll i=0;i<n;i++){
      cin>>a[i];
    }
    sort(a,a+n,greater<ll>());
    ll k=0,s=a[k],c=0;
    k=1;
    for(ll i=2;i<n;i++){
      if(c<2){
        s+=a[k];
        c++;
      }
      if(c==2){
        c=0;
        k++;
      }
    }
    cout<<s<<endl; 
    
    //printclock;
    return 0;
}
    

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

using namespace std;

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

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 5;

ll n, a[N], dp[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    cin >> n;

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

    dp[0] = 0;
    dp[1] = llabs(a[0] - a[1]);
    for (int i = 2; i < n; ++i) 
        dp[i] = min(dp[i - 1] + llabs(a[i] - a[i - 1]), 
                dp[i - 2] + llabs(a[i] - a[i - 2]));
    cout << dp[n - 1] << endl;
}

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

using namespace std;

int main(){
    int N; cin>>N;
    int left=0,right=0;
    int ans,ANS=100000;
    vector<int> W(N+1);

    for(int i=1;i<=N;i++){
        cin>>W[i];
    }
    for(int T=1;T<N;T++){
        for(int i=1;i<=T;i++){//左からiこ
            left+=W[i];
        }
        for(int i=T+1;i<=N;i++){
            right+=W[i];
        }
        ans=left-right;
        if(ans<0) ans=-ans;
        if(ans<ANS) ANS=ans;
        left=0;
        right=0;
    }
    printf("%d",ANS);


    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = 'APPROVED'

for i in range(len(A)):
  if A[i] % 2 == 0:
    if A[i] % 3 == 0 or A[i] % 5 == 0:
      continue
    else:
      ans = 'DENIED'

print(ans)

Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_N 100000

using namespace std;
typedef pair<int, int> ipair;

int main(int argc, char **argv) {
    int N;
    llong A[MAX_N + 1];
    cin >> N;
    for(int i = 0; i < N; ++i)
        cin >> A[i];

    sort(A, A + N);

    llong res1 = 0;
    llong res2 = 0;
    for(int i = 0; i < N; i += 2) {
        if(i == N - 1) {
            res1 += A[i];
            break;
        }

        if(A[i] + A[i + 1] <= 0)
            res1 += -(A[i] + A[i + 1]);
        else if(A[i] + A[i + 1] >= 0)
            res1 += A[i] + A[i + 1];
    }

    for(int i = N - 1; i >= 0; i -= 2) {
        if(i == 0) {
            res2 += A[i];
            break;
        }

        if(A[i] + A[i - 1] <= 0)
            res2 += -(A[i] + A[i - 1]);
        else if(A[i] + A[i - 1] >= 0)
            res2 += A[i] + A[i - 1];
    }
    
    cout << max(res1, res2) << endl;
}

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

#define mod 1000000007

int main() {
  int n;
  string s1, s2;
  cin >> n >> s1 >> s2;
  long long ans = 1;
  int before = 0;
  for (int i = 0; i < n; ++i) {
    if (s1[i] == s2[i]) {
      if (before == 0)
        ans *= 3;
      else if (before == 2)
        ans *= 1;
      else if (before == 1)
        ans *= 2;
      before = 1;
    } else {
      if (before == 0)
        ans *= 6;
      else if (before == 1)
        ans *= 2;
      else if (before == 2)
        ans *= 3;
      before = 2;
      ++i;
    }
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=2e5+1000;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    ll x,y,z;cin>>x>>y>>z;
    ll d=(x+y-1)/y;
    cout<<d*z<<endl;
    return 0;
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, Ma, Mb;
int cost[405][405];

int main() {
    //cout.precision(10);
    cin >> N >> Ma >> Mb;
    for(int i = 0; i <= 400; i++) {
        for(int j = 0; j <= 400; j++) cost[i][j] = INF;
    }
    cost[0][0] = 0;
    while(N--) {
        int a, b, c;
        cin >> a >> b >> c;
        for(int beforea = 400 - a; beforea >= 0; beforea--) {
            for(int beforeb = 400 - b; beforeb >= 0; beforeb--) {
                cost[beforea+a][beforeb+b] = min(cost[beforea+a][beforeb+b], cost[beforea][beforeb] + c);
            }
        }
    }
    int ans = INF;
    for(int a = 1; a <= 400; a++) {
        if(a % Ma != 0) continue;
        for(int b = 1; b <= 400; b++) {
            if(b % Mb != 0) continue;
            if(a / Ma != b / Mb) continue;
            ans = min(ans, cost[a][b]);
        }
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 896
import java.util.*;

public class Main {
    void solve(){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        System.out.print(2018);
        for(int i = 4; i < s.length(); i++) System.out.print(s.charAt(i));
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
  int no_of_input;
  int input;
  vector<int> vect1;
  multiset<int> currhas;
  cin >> no_of_input;
  for(int i=0;i<(1<<no_of_input);i++){
    cin >> input;
    vect1.push_back(input);
  }
  multiset<int> set1;
  sort(vect1.begin(),vect1.end());
  currhas.insert(vect1[vect1.size()-1]);
  for(int i=0;i<vect1.size()-1;i++){
    set1.insert(vect1[i]);
  }
  for(int i=0;i<no_of_input;i++){
    vector<int> temp;
    for(auto k:currhas){
      auto j = set1.lower_bound(k);
      if(j==set1.begin()){
        cout << "No";
        return 0;
      }
      j--;
      temp.push_back(*j);
      set1.erase(j);
    }
    for(auto k:temp){
      currhas.insert(k);
    }
  }
  cout << "Yes";
  
}

Measured memory_bytes: 16112
import java.util.Scanner;

class Main {
    
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        long val = scanner.nextLong();
        scanner.close();
        long sum = 0;
        for(long i=1; i<=val; i++){
            if(i%3!=0 && i%5!=0){
                sum += i;
            }
        }
        System.out.print(sum);
    }
    
}

Measured memory_bytes: 27068
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

struct Combination{
    vector<long long> _fac,_finv,_inv;
    const int m = MOD;

    Combination(int sz) : _fac(sz),_finv(sz),_inv(sz){
        _fac[0] = _fac[1] = 1;
        _finv[0] = _finv[1] = 1;
        _inv[1] = 1;
        for(int i = 2; i <= sz; i++){
            _fac[i] = _fac[i-1]*i%m;
            _inv[i] = m-_inv[m%i]*(m/i)%m;
            _finv[i] = _finv[i-1]*_inv[i]%m;
        }
    }

    inline long long fac(int n){return _fac[n];}
    inline long long inv(int n){return _inv[n];}
    inline long long finv(int n){return _finv[n];}

    long long comb(int n,int k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return _fac[n]*(_finv[k]*_finv[n-k]%m)%m;
    }
};

ll modpow(ll a, ll n, ll m){
    if(n == 0) return 1;
    ll half = modpow(a,n/2,m);
    ll res = half * half % m;
    if(n & 1) res = res * (a%m) % m;
    return res;
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(){
    int N; cin >> N;
    vector<ll> x(N);
    rep(i,N) cin >> x[i];
    Combination C(200000);
    vector<ll> c(N-1);
    c[0] = 1;
    rep(i,N-2){
        c[i+1] = c[i]+modinv(i+2,MOD);
        c[i+1] %= MOD; 
    }
    ll ans = 0;
    rep(i,N-1){
        ans += c[i]*(x[i+1]-x[i])%MOD;
        ans %= MOD;
    }
    ans *= C.fac(N-1);
    ans %= MOD;
    cout << ans << endl;
}



Measured memory_bytes: 6528
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

#define amen ;
#define vec vector
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef double d;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;
typedef unsigned int ui;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int  k = i, cnt = 0;
        while(k)
        {
            cnt++;
            k /= 10;
        }
        if (cnt % 2)
            ans++;
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	bool def = false;
	for(int i = 1; i <= B; i++){
		if((A * i) % B == C){
			def = true;
			break;
		}
	}
	printf(def ? "YES\n" : "NO\n");
	return 0;
}


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

const ll NB = 4;
const ll NF = 3;
const ll NR = 10;

int main(){
    ll num[NB][NF][NR] = {0};

    ll n;
    cin >> n;
    REP(i, n){
        ll b, f, r, v;
        cin >> b >> f >> r >> v;
        b--; f--; r--;
        num[b][f][r] += v;
    }

    REP(i, NB){
        REP(j, NF){
            REP(k, NR){
                cout << ' ' << num[i][j][k];
            }
            cout << endl;
        }
        if(i + 1 < NB){
            cout << "####################" << endl;
        }
    }
}



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

int main(){
  string s;
  cin>>s;
  if(s=="AAA"){
    cout<<"No"<<endl;
  }else if(s=="BBB"){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  return 0;
}

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

using namespace std;

void Lower()
{
  int n;
  int ans = 0;
  cin >> n;
  int pre_h;
  int h;
  cin >> pre_h;
  int count=0;

  for (int i = 1; i < n; i++)
  {
    cin >> h;
    if (pre_h >= h)count++;
    else
    {
      if (count > ans)ans = count;
      count = 0;
    }
    pre_h = h;
  }
  if (count > ans)ans = count;

  cout << ans << endl;
  return;
}


int main()
{
  Lower();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    ll A,B,V,W,T;
    string S;
    cin >> A>>V>>B>>W>>T;
    if(V<=W){
        cout << "NO" << endl;
        return 0;
    }
    ll D;
    ll TD;
    if (A>B){
        D = A-B;
    }else {
        D = B-A;
    }
    
    if (V>W){
        TD = V-W;
    }else {
        TD = W-V;
    }
    if(TD*T >= D){
        cout << "YES" << endl;
    } else {
       cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;


int main(void)
{
    ull N, M;
    cin >> N >> M;

    ull flipped;
    if(N > 1 && M > 1){
        flipped = N*M - (2*N + 2*M - 4);
    } else if((N > 1 && M == 1) || (N == 1 && M > 1)){
        flipped = max(N, M) - 2;
    } else {
        flipped = 1;
    }

    cout << flipped << endl;
    return 0;
}


Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.rmi.server.ExportException;
import java.util.Arrays;
        import java.util.Scanner;

class Main {
    static Scanner sc;

    private static void nextArr(int[] h) {
        for(int i = 0; i < h.length; i++) h[i] = sc.nextInt();
    }

    private static int nextInt() {
        return sc.nextInt();
    }

    private static void print(Object... vals) {
        for(int i = 0; i < vals.length; i++) {
            if (i != vals.length - 1) {
                System.out.print(vals[i] + ",");
            } else {
                System.out.print(vals[i]);
            }
        }
        System.out.println();
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        int n = s.length();
        int m = t.length();

        int[][] dp = new int[n + 1][m + 1];
        int[][][] prev = new int[n + 1][m + 1][2];
        for(int i = 0; i <= n; i++) {
            for (int j = 0; j <= m; j++) {
                dp[i][j] = Integer.MIN_VALUE;
                dp[i][0] = 0;
                dp[0][j] = 0;
                prev[i][j][0] = -1;
                prev[i][j][1] = -1;
            }
        }

        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= m; j++) {
                char left = s.charAt(i - 1);
                char right = t.charAt(j - 1);
                if (left == right && dp[i - 1][j - 1] != Integer.MIN_VALUE) {
                    int val = dp[i - 1][j - 1] + 1;
                    if (val >= dp[i][j]) {
                        dp[i][j] = val;
                        prev[i][j][0] = i - 1;
                        prev[i][j][1] = j - 1;
                    }
                }
                if (left != right) {
                    if (dp[i][j - 1] != Integer.MIN_VALUE) {
                        int val = dp[i][j - 1];
                        if (val >= dp[i][j]) {
                            dp[i][j] = val;
                            prev[i][j][0] = i;
                            prev[i][j][1] = j - 1;
                        }
                    }
                    if (dp[i - 1][j] != Integer.MIN_VALUE) {
                        int val = dp[i - 1][j];
                        if (val >= dp[i][j]) {
                            dp[i][j] = val;
                            prev[i][j][0] = i - 1;
                            prev[i][j][1] = j;
                        }
                    }
                }
            }
        }
        int x = n;
        int y = m;
        StringBuffer ans = new StringBuffer();
        while(x > 0 && y > 0) {
            int px = x;
            int py = y;
            x = prev[px][py][0];
            y = prev[px][py][1];
            if (x == px - 1 && y == py - 1) {
                ans.append(s.charAt(px - 1));
            }
        }
        print(ans.reverse().toString());
    }
}


Measured memory_bytes: 388180
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		Arrays.sort(s);
		List<String> alphabetList = new ArrayList<String>();
		alphabetList.add("a");
		alphabetList.add("b");
		alphabetList.add("c");
		alphabetList.add("d");
		alphabetList.add("e");
		alphabetList.add("f");
		alphabetList.add("g");
		alphabetList.add("h");
		alphabetList.add("i");
		alphabetList.add("j");
		alphabetList.add("k");
		alphabetList.add("l");
		alphabetList.add("m");
		alphabetList.add("n");
		alphabetList.add("o");
		alphabetList.add("p");
		alphabetList.add("q");
		alphabetList.add("r");
		alphabetList.add("s");
		alphabetList.add("t");
		alphabetList.add("u");
		alphabetList.add("v");
		alphabetList.add("w");
		alphabetList.add("x");
		alphabetList.add("y");
		alphabetList.add("z");
		for(int i=0;i <s.length;i++) {
			if(i ==0) {
				alphabetList.remove(s[i]);
				continue;
			}
			if(s[i].equals(s[i-1])) {
				continue;
			}else {
				alphabetList.remove(s[i]);
			}
		}
		if(alphabetList.isEmpty()) {
			System.out.println("None");
		}else {
			System.out.println(alphabetList.get(0));
		}
	}
}

Measured memory_bytes: 34820
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,k,ar[100005],dp[100005];
ll findmin(ll i){
	if(i==n){
		return 0;
	}
	if(dp[i]!=-1){
		return dp[i];
	}
	ll an=1e18,j;
	for(j=1;j<=k;j++){
		if(i+j<=n){
			an=min(an,findmin(i+j)+abs(ar[i]-ar[i+j]));
		}
	}
	return dp[i]=an;
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll i,j,l;
	cin>>n>>k;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	memset(dp,-1,sizeof(dp));
	ll an=findmin(1);
	cout<<an;
	return 0;
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = int(2e5) + 2;
const int LG = 20;
const ll mod = 998244353;
const int INF = (int)1e9 + 7;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-9;

int n, a, b, c, d;
string s;

bool can (int from, int to){
    while (from < to){
        if (s[from + 1] == '.') ++from;
        else {
            if (s[from + 2] == '.') from += 2;
            else return 0;
        }
    }
    return 1;
}

bool ok (int from, int to){
    for (int i = from; i <= to; ++i){
        if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') return 1;
    }
    return 0;
}

int main (){
    cin >> n >> a >> b >> c >> d >> s;
    a--, b--, c--, d--;
    if (can(b, d) && can(a, c)){
        if (c < d || ok(b, d)) return !printf ("Yes\n");
    }
    printf ("No\n");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std ;
const int MAXN = 100 ;
char s1[ MAXN ] , s2[ MAXN ] ;
int n , m ;
bool flag = 1 ;
signed main () {
    cin >> s1 + 1 >> s2 + 1 ;
    n = strlen ( s1 + 1 ) ;
    for ( int i = 1 ; i <= n ; i ++ ) {
        if ( s1[ i ] != s2[ i ] ) {
            cout << "No\n" ;
            return 0 ;
        }
    }
    cout << "Yes\n" ;
    return 0 ;
}

Measured memory_bytes: 3620
import math
n, d = list(map(int, input().split()))
vs = []
for i in range(n):
  vs.append(list(map(int, input().split())))

result = 0
for i in range(n):
  for j in range(i+1, n):
    a = sum((vs[i][k] - vs[j][k]) ** 2 for k in range(d))
    if int(math.sqrt(a)) == math.sqrt(a):
      result += 1
print(result)


Measured memory_bytes: 3064
S = list(str(input()))
S = [int(s) for s in S]
n = len(S)

S.reverse()

def power(a, n, mod):
  bi=str(format(n,"b")) #2進数
  res=1
  for i in range(len(bi)):
    res=(res*res) %mod
    if bi[i]=="1":
      res=(res*a) %mod
  return res

cum1 = [-1]*(n+1)
cum1[0] = 0
for i in range(n):
    temp = cum1[i]+S[i]*power(10, i, 673)
    cum1[i+1] = temp%673
#print(cum1)

cum2 = [-1]*(n+1)
cum2[0] = 0
for i in range(n):
    temp = cum2[i]+S[i]*power(10, i, 3)
    cum2[i+1] = temp%3
#print(cum2)

d = {}
ans = 0
for i in range(n+1):
    c1 = cum1[i]
    c2 = cum2[i]
    if (c1, c2) in d:
        ans += d[(c1, c2)]
        d[(c1, c2)] += 1
    else:
        d[(c1, c2)] = 1
print(ans)


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

int main()
{
	string s;
	cin >> s;
	s += 'F';
	int n = s.size();
	long long int ans = 0, a = 0;
	int p = 0, abc_check = 0;
	while(p < n){
		if(s[p] == 'A'){
			if(abc_check == 0 || abc_check == 1){
				++a;
			}else{
				a = 1;
			}
			abc_check = 1;
		}else if(abc_check == 1 && s[p] == 'B'){
			abc_check = 2;
		}else if(abc_check == 2 && s[p] == 'C'){
			ans += a;
			abc_check = 1;
		}else{
			a = abc_check = 0;
		}
		++p;
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string vwl="aeiou";
	set<char> st(vwl.begin(), vwl.end());
	char ch; cin>>ch;
	cout << (st.find(ch)!=st.end() ? "vowel" : "consonant") << endl;
	return 0;
}


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

int main()
{
    int X, Y, Z, K;
    std::cin >> X >> Y >> Z >> K;
    std::vector<long long> A(X), B(Y), C(Z);
    for(int i=0; i<X; i++) scanf(" %lld", &A[i]);
    for(int i=0; i<Y; i++) scanf(" %lld", &B[i]);
    for(int i=0; i<Z; i++) scanf(" %lld", &C[i]);

    std::vector<long long> AB;
    for(int i=0; i<X; i++){
        for(int j=0; j<Y; j++) AB.push_back(A[i] + B[j]);
    }
    std::sort(AB.begin(), AB.end(), std::greater<long long>());

    std::vector<long long> all;
    int M = std::min(K, X*Y);
    for(int i=0; i<M; i++){
        for(int j=0; j<Z; j++) all.push_back(AB[i] + C[j]);
    }
    std::sort(all.begin(), all.end(), std::greater<long long>());

    for(int i=0; i<K; i++) printf("%lld\n", all[i]);
}

Measured memory_bytes: 43240
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#include<cstdio>
#include<sstream>
#include<vector>
#include<bitset>
#include<algorithm>

using namespace std;
#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define gc(x)  scanf(" %c",&x);
#define mmt(x,y)  memset(x,y,sizeof x)
#define write(x) printf("%d\n",x)
#define pii pair<int,int>
#define INF 0x3f3f3f3f
#define ll long long
const ll mod =  998244353;
const int N = 100000 + 100;
const int M = 2e6 + 1005;
int dp[N];
int c[] = {0,100,101,102,103,104,105};
int main()
{
    int n;
    cin>>n;
    dp[0] = 1;
    for(int i = 1;i <= 6;++i){
        for(int j = c[i];j <= n;++j){
           if(dp[j - c[i]]) dp[j] = 1;
        }
    }
    if(dp[n]) cout<<1;
    else cout<<0;
}


Measured memory_bytes: 640
n = int(input())
A = []
not10a = set()

for _ in range(n):
    a = int(input())
    A.append(a)
    if a%10 != 0:
        not10a.add(a)

ans = sum(A)
if ans%10 !=0:
    print(ans)
else:
    if not10a:
        print(ans - min(not10a))
    else:
        print(0)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[2];
		int x = sc.nextInt();
		sc.close();
		if (isH(x)) {
			System.out.println(x);
			System.exit(0);
		} else {
			for (int i = x - 1; i >= 0; i--) {
				if (isH(i)) {
					a[0] = i;
					break;
				}
			}

			for (int i = x + 1; i < 15000; i++) {
				if (isH(i)) {
					a[1] = i;
					break;
				}
			}
		}
		if ((Math.abs(a[0] - x)) > (Math.abs(a[1] - x))) {
			System.out.println(a[1]);
		} else if ((Math.abs(a[0]) - x) == (Math.abs(a[1]) - x)) {
			System.out.println(min(a[0], a[1]));
		} else {
			System.out.println(a[0]);
		}

	}
	static boolean isH(int x) {
		int sum = 0;
		int a = 0;
		int x1 = x;
		while (x != 0) {
			a = x % 10;
			sum = sum * 10 + a;
			x /= 10;
		}
		if (x1 == sum)
			return true;
		return false;
	}
	static int min(int x, int y) {
		if (x > y)
			return y;
		return x;
	}

}



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

int main() {
	string s;
	cin >> s;
	vector<int> v;
	for (int i = 1; i < s.size(); i++) {
		if (s[i - 1] != s[i]) {
			v.push_back(i);
		}
	}
	int k = s.size();
	if (v.size() > 0) {
		k = max(v[0], (int)s.size() - v[0]);
		for (int i = 1; i < v.size(); i++) {
			int l = v[i - 1], m = v[i] - v[i - 1], r = (int)s.size() - v[i];
			k = min(k, max(max(l, r), min(l + m, m + r)));
		}
	}
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, K, C;
  string S;
  
  cin >> N >> K >> C;
  cin >> S;

  vector<int> L;
  {
    int i=0;
    while(i<N){
      if(S[i]=='o'){
        L.push_back(i);
        i += C+1;
      }else{
        i++;
      }
    }
  }
  if(L.size() == 0) return 0;
  if(L.size() != K) return 0;

  vector<int> R(L.size(), -1);
  int cnt = L.size()-1;
  {
    int i=N-1;
    while(i>=0){
      if(S[i]=='o'){
        R[cnt] = i;
        i -= C+1;
        cnt--;
      }else{
        i--;
      }
    }
  }

  rep(i,L.size()){
    //cout << L[i] << " " << R[i] << endl;
    if(L[i] == R[i]) cout << L[i]+1 << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 3448
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define ll long long
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;
const int inf = 1000000000; // 10^9

int main(){
    ll a, b, n, max = -1 * inf, i = 0, x;
    cin >> a >> b >> n;

    max = floor(a * n / b) - a * floor(n / b);

    rep(i, 100000) upd_max(max, floor(a * (n - i) / b) - a * floor((n -  i) / b));
    rep(i, 10000000) if(b+i < n) upd_max(max, floor(a * (b + i) / b) - a * floor((b + i) / b));
    rep(i, 10000000) if(b-i < n) upd_max(max, floor(a * (b - i) / b) - a * floor((b - i) / b));

    cout << max << endl;

    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> v(4);
	for (int q = 0; q < n; q++)
	{
		int a;
		cin >> a;
		v[a]++;
	}
	double dp[n+1][n+1][n+1];
	dp[0][0][0] = 0;
	for (int c = 0; c <= n; c++)
	{
		for (int b = 0; b <= n; b++)
		{
			for (int a = 0; a <= n; a++)
			{
				if (a+b+c > n)
				{
					break;
				}
				if (a+b+c == 0)
				{
					continue;
				}
				double tot = (a+b+c) * 1.0;
				dp[a][b][c] = n/tot;
				
				if (c > 0)
				{
					dp[a][b][c] += c * dp[a][b+1][c-1] / tot;
				}
				if (b > 0)
				{
					dp[a][b][c] += b * dp[a+1][b-1][c] / tot;
				}
				if (a > 0)
				{
					dp[a][b][c] += a * dp[a-1][b][c] / tot;
				}
			}
		}
	}
	printf("%.15f\n", dp[v[1]][v[2]][v[3]]);
	return 0;
}


Measured memory_bytes: 212992
N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = [c for c in input()]

hand_points = {"p": P, "r": R, "s": S}

def win(enemy_hand):
  if enemy_hand == "r":
    return "p", P
  elif enemy_hand == "s":
    return "r", R
  elif enemy_hand == "p":
    return "s", S
  else:
    raise ValueError("HAND IS WRONG")

total_point = 0
my_hands = []
for enemy_hand in T:
  my_hand, point = win(enemy_hand)
  total_point += point
  my_hands.append(my_hand)

for i in range(K, N):
  my_hand = my_hands[i]
  if my_hand == my_hands[i-K]:
    total_point -= hand_points[my_hand]
    my_hands[i] = "any"

print(total_point)
  

Measured memory_bytes: 4796
N = int(input())
 
c = [[0]*10 for _ in range(10)]
for i in range(1,N+1):
	c[int(str(i)[0])][int(str(i)[-1])] += 1
    
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += c[i][j]*c[j][i]

print(ans)


Measured memory_bytes: 40428