akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<numeric>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
typedef map<string,int> dict;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
double eps = 1e-10 ;

template <typename T>
void out(vector < T > v)
{
  for(size_t i = 0; i < v.size(); i++)
  {
    debug(v[i]);
  }
}

template<typename T>
string ntos( T i ) {
  ostringstream s ;
  s << i ;
  return s.str() ;
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s,s2;
  cin >> n;
  rep(i,n){
    cin >> s;
    s2 = s ;
    std::sort(all(s2)) ;
    std::sort(all(s)) ;
    reverse(all(s)) ;
    cout << ston(s,1) - ston(s2,1) << endl ;
  }

  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <cassert>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9;
const ll INF = 1e18;
const ld PI = 3.1415926535897932384626433832795;

int cnt[MAXN];
ll dp[MAXN], tab[MAXN];
bool vis[MAXN], used[MAXN];

vector<int> G[MAXN];
vector<ll> V;
set<ll> S;
map<ll, int> M;
stack<ll> St;
queue<ll> Q;

struct Item {
    ll w, v;
};

Item item[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

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

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> item[i].w >> item[i].v;
    }

    sort(item, item + n, [](Item a, Item b) {
        if (a.w == b.w) {
            return a.v > b.v;
        }
        return a.w < b.w;
    });

    for (int i = 0; i < n; i++) {
        for (int j = m; j >= 0; j--) {
            if (j == 0 or dp[j]) {
                dp[j + item[i].w] = max(dp[j + item[i].w], dp[j] + item[i].v);
            }
        }
    }

    ll res = *max_element(dp, dp + m + 1);
    cout << res << "\n";
}


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

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] s = scanner.next().toCharArray();
    char[] t = scanner.next().toCharArray();
    if (possible(s, t)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  private static boolean possible(char[] s, char[] t) {
    Arrays.sort(s);
    Arrays.sort(t);
    reverse(t);
    for (int i = 0; i < s.length && i < t.length; i++) {
      if (s[i] < t[i]) return true;
      if (s[i] > t[i]) return false;
    }
    return s.length < t.length;
  }

  private static void reverse(char[] a) {
    int i = 0;
    int j = a.length - 1;
    while (i < j) {
      char tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
      i++;
      j--;
    }
  }
}


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

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

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] l = new int[n];
            int[] result = new int[n];
            for (int i = 0; i < n; ++i) {
                l[i] = in.nextInt();
            }
            int beginIndex = 0;
            int endIndex = n - 1;
            boolean putBegin = true;
            for (int i = n - 1; i >= 0; --i) {
                if (putBegin) {
                    result[beginIndex++] = l[i];
                } else {
                    result[endIndex--] = l[i];
                }
                putBegin = !putBegin;
            }
            for (int i = 0; i < n; ++i) {
                if (i > 0) out.print(" ");
                out.print(result[i]);
            }
        }

    }
}



Measured memory_bytes: 90240
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int input1, input2;
    string op;
    cin>> input1;
    cin>> op;
    cin>> input2;

    if(op=="+"){
        cout<<input1+input2<< endl;
    }
    else{
        cout<<input1-input2<< endl;
    }

    return 0;
}



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

int main () {
  int n;
  cin >> n;
  set<int> d;
  for (int i = 0; i < n; i++) {
    int j;
    cin >> j;
    d.insert(j);
  }
  cout << d.size() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
a=min(a,b);
c=min(c,d);
cout<<a+c;
system("pause");
return 0;
}

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

int main(){
  string s;
  int k;
  cin >> k >> s;
  int size = s.size();
  
  if (size <= k){
    cout << s << endl;
  }
  else{
    for(int i = 0; i < k; i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3632
<?php

fscanf(STDIN, '%d', $n);
$line = trim(fgets(STDIN));
$S = array_unique(explode(' ', $line));
fscanf(STDIN, '%d', $q);
$line = trim(fgets(STDIN));
$T = explode(' ', $line);
echo count(array_intersect($S, $T)), PHP_EOL;

Measured memory_bytes: 9492
def trace(A, N):
    print(*A)

def insertion_sort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i -1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        trace(A, N)


N = int(input())
A = list(map(int, input().split()))
trace(A, N)
insertion_sort(A, N)


Measured memory_bytes: 5984
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  stack<int> a;
  string ops = "+-*/";
  string s;
  while (cin >> s) {
    if (s == "=") {
      cout << a.top() << endl;
      continue;
    }
    if (ops.find(s[0]) != string::npos) {
      a.push(s[0]);
      continue;
    }
    if (a.size() && ops.find(a.top()) != string::npos) {
      char op = a.top();
      a.pop();
      int x1 = a.top(), x2 = stoi(s);
      a.pop();
      if (op == '+') a.push(x1 + x2);
      if (op == '-') a.push(x1 - x2);
      if (op == '*') a.push(x1 * x2);
      if (op == '/') a.push(x1 / x2);
    } else {
      a.push(stoi(s));
    }
  }
}

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

int main(){
    int n, m, d;
    scanf("%d%d%d", &n, &m, &d);
    long double ans = n-d;
    if(d != 0) ans *= 2;
    ans /= n*1ll*n;
    ans *= m-1;
    printf("%.10Lf\n", ans);
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

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

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


int N, Q;
int counter[200000];
vector<int> adj[200000];
bool visited[200000];

void dfs(int index, int acc){
    if(visited[index]) return;
    visited[index] = true;
    counter[index] += acc;
    for(auto next : adj[index]){
        dfs(next, counter[index]);
    }
}

signed main(){
    cin >> N >> Q;
    int a, b, p, x;
    REP(i, N - 1){
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
        visited[i] = visited[i + 1] = false;
        counter[i] = counter[i + 1] = 0;
    }
    REP(i, Q){
        cin >> p >> x;
        p--;
        counter[p] += x;
    }
    dfs(0, 0);
    REP(i, N){
        cout << counter[i];
        cout << ((i == N - 1) ? "\n" : " ");
    }
    return 0;
}

Measured memory_bytes: 20608
//package beginner176;

import java.util.*;

public class Main {

    public static class Node{
        int r;
        int c;

        public Node(int pr, int pc){
            r = pr;
            c = pc;
        }
    }

    public static class Record{
        int index;
        int cnt;
        public Record(int i, int c){
            index = i;
            cnt = c;
        }
    }

    public static void main(String[] args){
        int H, W;

        Scanner in = new Scanner(System.in);

        H = in.nextInt();
        W = in.nextInt();
        int M = in.nextInt();
        int row[] = new int[H + 1];
        int col[] = new int[W + 1];
        int target[][] = new int[M][2];
        TreeMap<Node, Integer> treeMap = new TreeMap<Node, Integer>(new Comparator<Node>() {
            @Override
            public int compare(Node o1, Node o2) {
                if(o1.r != o2.r){
                    return o1.r - o2.r;
                }
                return o1.c - o2.c;
            }
        });
        Map<Integer, List<Integer>> edgeRow = new HashMap<>();

        for(int i = 0; i < M; i++){
            int r = in.nextInt();
            int c = in.nextInt();
            target[i][0] = r;
            target[i][1] = c;
            treeMap.put(new Node(r, c), 0);
            row[r]++;
            col[c]++;
            add(r, c, edgeRow);

        }

        Comparator<Record> cmp = new Comparator<Record>() {
            @Override
            public int compare(Record o1, Record o2) {
                return o2.cnt - o1.cnt;
            }
        };

        List<Record> colList = new ArrayList<Record>();
        for(int i = 1; i <= W; i++){
            colList.add(new Record(i, col[i]));
        }
        colList.sort(cmp);

        int result = 0;

        for(int i = 1; i <= H; i++){
            int r = row[i];
            result = Math.max(result, r);
            if(edgeRow.containsKey(i)){
                List<Integer> list = edgeRow.get(i);

                for(int x : list){
                    result = Math.max(result, r - 1 + col[x]);
                }
            }
            for(int j = 0; j < colList.size(); j++){
                Record record = colList.get(j);
                if(treeMap.containsKey(new Node(i, record.index))){
                    continue;
                }
                result = Math.max(result, r + record.cnt);
                break;
            }
        }
        System.out.println(result);

    }

    public static void add(int i, int j, Map<Integer, List<Integer>> map){
        if(map.containsKey(i)){
            map.get(i).add(j);
        }else{
            List<Integer> list = new ArrayList<>();
            list.add(j);
            map.put(i, list);
        }
    }
}


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

int main()
{
  int N, sum;
  cin >> N;
  sum = 0;
  vector<int> L(N);
  for (int i = 0; i < N; ++i)
  {
    cin >> L[i];
    sum += L[i];
  }
  for (int i = 0; i < N; ++i)
  {
    if (L[i] * 2 >= sum)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

int main(){
        int N, A, B, res;
        cin >> N >> A >> B;
        res = N - A % N;

        if(A < N){ 
                if(B < N) cout << "NG" << endl;
                else cout << "OK" <<endl;
        }
        else{
                if(res <= B - A || A % N == 0) cout << "OK" << endl;
                else cout << "NG" << endl;
        }

        return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
    cin>>a>>b;
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    sort(a.begin(),a.end());
    if(a<b)
    {
    	cout<<"Yes";
	}
    else
    {
    	cout<<"No";
	}
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define N 100005
#define INF 1000000000
#define int long long
using namespace std;
int n,A,B,h[N],l=1,r=INF,mid,ans;
bool check(int x) {
    int cnt=0;
    for(int i=1;i<=n;++i) {
        int tmp=h[i]-x*B;
        if(tmp<=0) continue;
        cnt+=(tmp-1)/(A-B)+1;
    }
    return cnt>x ? false : true;
}
main() {
    scanf("%lld%lld%lld",&n,&A,&B);
    for(int i=1;i<=n;++i) scanf("%lld",h+i);
    while(l<=r) {
        mid=l+r>>1;
        if(check(mid)) ans=mid, r=mid-1;
        else l=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 200020, maxm = 2020, mod = 2019;
int cnt[2][maxm];
int n;
char w[maxn];
ll res;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> w;
	n = strlen(w);
	for (int i = 0;i < n;++i) {
		auto &now = cnt[i&1], &lst = cnt[~i&1];
		fill(now, now+maxm, 0);
		for (int j = 0;j < maxm;++j)
			now[(j*10+(w[i]-'0')) % mod] += lst[j];
		res += now[0];
		++now[w[i]-'0'];
	}
	cout << res << '\n';

}



Measured memory_bytes: 3852
#include <iostream>
#include <vector>
using namespace std;
int n, q;
vector<int> tree[200010];
vector<int> ans(200010);

void dfs(int v, int p = -1) {
    for (int e :tree[v]) {
        if (e == p) continue;
        ans[e] += ans[v];
        dfs(e, v);
    }
}

int main() {
    cin >> n >> q;
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b;
        a--, b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    for (int i = 0; i < q; i++) {
        int p, x; cin >> p >> x;
        ans[p - 1] += x;
    }
    dfs(0);
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 23552
#include <stdio.h>

int main(){
  int n;  scanf("%d", &n);
  long ans = 0;
  for(int i=0; i<n; i++){
    long a;  scanf("%ld", &a);
    long count = 0;
    while(a%2==0){
      count++;
      a /= 2;
    }
    ans += count;
  }
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
//#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200000];
vll v;
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            v.push(p);
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[60];
void power()
{
    powe[0]=1;
    REP(i,1,15)
    {
        powe[i]=2*powe[i-1];
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll fact[100005];
void factorial()
{
    fact[0]=1;
    REP(i,1,100002)
    {
        fact[i]=mymod(i*fact[i-1], num);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k,s;
    cin>>n>>k>>s;
    int diff=n-k;
    REP(i,0,diff)
    {
        if(s==1000000000) cout<<"999999999 ";
        else cout<<s+1<<" ";
    }
    REP(i,diff,n)
    {
        cout<<s<<" ";
    }
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

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

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

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll H,W;
    cin>>H>>W;
    vector<vector<bool>> s(H,vector<bool>(W));
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            char c;
            cin>>c;
            if(c=='#')s[i][j]=true;
            else s[i][j]=false;
        }
    }
    
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            if(s[i][j]){
                if(i>0&&s[i-1][j])continue;
                if(i<H-1&&s[i+1][j])continue;
                if(j>0&&s[i][j-1])continue;
                if(j<W-1&&s[i][j+1])continue;
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
hs = gets.split.map(&:to_i)
ans = 0
count = 0
current = 1 << 60
(hs + [1 << 60]).each do |h|
  if current >= h
    count += 1
  else
    ans = count if count > ans
    count = 1
  end
  current = h
end
puts([ans - 1, 0].max)


Measured memory_bytes: 9348
#include <bits/stdc++.h>
#define iso ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
using namespace std;
int main()
{ iso
    unsigned ll n,s=0,w=0;
    cin>>n;
    vector<unsigned ll>vec;
    while(n--)
    {
        ll x;
        cin>>x;
        vec.push_back(x);
        s+=x;
    }

    for(int i=0;i<vec.size();i++)
    {
        s-=vec[i];
        w+=s%1000000007*vec[i]%1000000007;
        w%=1000000007;
    }
    cout<<w<<"\n";

    return 0;
}


Measured memory_bytes: 5308
S=input()

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


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int> 
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 12
using namespace std;
typedef long long ll;
int main(){
	int a,b,c;cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0)puts("0");else cout<<min(1ll*a*b,min(1ll*a*c,1ll*b*c));
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = [None] + list(map(int, input().split()))
dp = [None] * (n + 1)
dp[1] = 0
dp[2] = abs(h[1] - h[2])
for i in range(3, n + 1):
    dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))
print(dp[n])

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

int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = A; i <= B; i++) {
    int a = i % 10; //1桁目
    int b = i / 10000 % 10; 
    int c = i / 10 % 10;
    int d = i / 1000 % 10;
    if (a == b && c == d) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>
#include <stack>

using namespace std;

const long MOD = 1e9+7;
#define long long long
#define fi first
#define se second
typedef pair<int,int> ii;

long G[603];
long dp[603][603];
bool con[603];
int A[603], B[603], pref[603];
int n, m;
int uc(int x, int y) { return pref[y]-pref[x-1]; }

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	G[0] = G[2] = 1;
	for(int i = 4; i <= 600; i+=2)
		G[i] = (1LL*(i-1)*G[i-2])%MOD;



	scanf("%d %d", &n, &m); n = 2*n;
	for(int i = 1; i <= m; i++)
	{
		scanf("%d %d", &A[i], &B[i]);
		if(A[i] > B[i]) swap(A[i], B[i]);
		con[A[i]] = 1;
		con[B[i]] = 1;
	}
	for(int i = 1; i <= n; i++)
		pref[i] = (1-con[i])+pref[i-1];

	long res = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = i; j <= n; j++)
		{
			// printf("%d %d\n", i, j); fflush(stdout);
			bool bol = 1;
			for(int k = 1; k <= m; k++)
			{
				bool inA = (i <= A[k] && A[k] <= j);
				bool inB = (i <= B[k] && B[k] <= j);
				bol &= (inA == inB);
			}
			if(bol == 0) continue;

			int hit = 0;
			for(int k = 1; k < i; k++) hit += (1-con[k]);
			for(int k = j+1; k <= n; k++) hit += (1-con[k]);

			
			long Gy = G[hit];
			dp[i][j] = (G[uc(i,j)])%MOD;
			// printf("	%lld %d %d\n", dp[i][j], hit, uc(i, j));
			
			for(int k = i+1; k < j; k++)
			{
				dp[i][j] -= (((dp[i][k]*G[uc(k+1, j)])%MOD))%MOD;
				// printf("	%d %lld %lld\n", k, dp[i][k], (((dp[i][k]*G[uc(k+1, j)])%MOD))%MOD);
				dp[i][j] %= MOD;
			}
			// printf("	%lld\n", dp[i][j]);
			res =(res+(dp[i][j]*Gy)%MOD)%MOD;
		}
	}
	printf("%lld\n", ((res%MOD)+MOD)%MOD);
}










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

using Int = long long int;
using UInt = unsigned long long int;

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return a / b + 1;
    }
}

int main(void) {
    Int n;
    cin >> n;
    Int rt, ra;
    cin >> rt >> ra;
 
    Int t, a;
    for (Int i = 1; i < n; ++i) {
        cin >> t >> a;
        Int times;
        if (rt > t && ra > a) { 
            times = max(Ceil(rt, t), Ceil(ra, a));
        } else if (rt <= t && ra > a) {
            times = Ceil(ra, a);
        } else if (rt > t && ra <= a) {
            times = Ceil(rt, t);
        } else {
            times = 1;
        }
        rt = t * times;
        ra = a * times;
    }
    cout << rt + ra << endl;
    return 0;
}


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

using namespace std;

typedef long long lint;
const lint mod = 1e9+7, N = 1e6+100;
lint x, y, fat[N];

lint fpow(lint b, lint e){
	if (b == 0)
		return 0;
	if (e == 0)
		return 1;
	if (e % 2 == 0){
		lint p = (fpow(b, e/2))%mod;
		return (p * p)%mod;
	} else {
		return ((b%mod) * fpow(b, e-1))%mod;
	}
}

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%lld %lld", &x, &y);

	if ((x + y)%3 != 0){
		printf("0\n");
		return 0;
	}

	lint a = (2*y - x) / 3;
	lint b = (2*x - y) / 3;

	//cout << a << "  " << b << endl;

	if (a < 0 || b < 0){
		printf("0\n");
		return 0;
	}

	fat[0] = fat[1] = 1;

	for (lint i = 2; i < N; i++){
		fat[i] = (i * fat[i - 1])%mod;
	}

	lint ans = fat[(a+b)] * fpow(fat[b], mod-2) % mod * fpow(fat[a], mod-2) % mod;

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

	return 0;
}

Measured memory_bytes: 11644
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        
        List<Integer> list = new ArrayList<Integer>();
        
        for(int i=0;i<N;i++){
            list.add(sc.nextInt());
        }
        
        Collections.sort(list);
        Collections.reverse(list);
        
        int tmp = Math.min(K,N);
        
        list.subList(0, tmp).clear();
        
        long cnt = 0;
        
        for(int i=0;i<list.size();i++){
            cnt += list.get(i);
        }
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 64588
from collections import Counter
S = input()
def lower_s(string):
    big_c = 0
    for c in string[1:]:
        if c == "C":
            if big_c == 1:
                return False
            else:
                big_c = 1
                continue
        if c == c.upper():
            return False
    return True
if (S[0] == "A") and (Counter(S[2:-1])["C"] == 1) and lower_s(S):
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3316
//2018.9.12 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int N=1e2+10;
namespace MAIN{
    int n;
    int a[N<<1];
    int ans;
    inline void MAIN(){
        n=read();
        for(res i=0;i<n<<1;i++)a[i]=read();
        sort(a,a+2*n);
        for(res i=0;i<n;i++)ans+=a[i<<1];
        printf("%d\n",ans);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    IOS;
    //freopen("inputfile.txt","r",stdin);
   ll n;cin>>n;
   string s;
   while(n!=0)
   {
       ll mod = n%26;
       //cout<<char(mod-97)<<endl;
       if(mod==0){s.push_back('z');n=(n/26)-1;}
       else {s.push_back(char(mod-1+97));n = n/26;}
       //cout<<n<<endl;
   }
   reverse(s.begin(),s.end());
    cout<<s<<endl;
   return 0;
}



Measured memory_bytes: 3628
// In God We Trust


# include <bits/stdc++.h>
using namespace std;

# define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second
signed main(){
  int n, weight;
  cin >> n >> weight;
  int w[n], v[n];
  for (int i = 0 ; i < n ; i++)
    cin >> w[i] >> v[i];
  long long dp[n][weight + 1];
  for (int j = 1 ; j <= weight; j++)
    if (w[0] <= j)
      dp[0][j] = v[0];
    else
      dp[0][j] = 0;
  for (int i = 0; i < n ; i++)
    dp[i][0] = 0;
  
  for (int i = 1 ; i < n; i ++)
    for (int j = 1 ; j <= weight; j++){
      dp[i][j] = dp[i - 1][j];
      if ( j - w[i] >= 0)
	dp[i][j] = max(dp[i][j], v[i] + dp[i - 1][j - w[i]]);
    }
  cout << dp[n - 1][weight] << endl;


  
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

int N, K;
map<int, int> mp;
vi dis(200050, INF);
int b, e;

int count(int pre, int now, int cnt) {
    if(dis[now]!=INF) {
        b=now; e=pre;
        return cnt-dis[now];
    }
    dis[now] = cnt;
    return count(now, mp[now], cnt+1);
}

signed main() {
    cin >> N >> K;
    rep(i, N) {
        int a;
        cin >> a;
        a--;
        mp[i] = a;
    }
    int cnt = count(0, 0, 0);
    //cout << b << " " << e << " " << K-dis[b] << endl;
    if(K>=dis[b]) {
    K = (K-dis[b])%cnt;
    int res = b;
    while(K>0) {
        res = mp[res];
        K--;
    }
    cout << res+1 << endl;
    } else {
        int res = 0;
        while(K>0) {
            res = mp[res];
            K--;
        }
        cout << res+1 << endl;
    }

    return 0;
}

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

using namespace std;

template <typename T> T gcd(T a, T b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}

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

  vector<int> left(N + 1, 0), right(N + 1, 0);
  for (int i = 0; i < N; i++) {
    left[i + 1] = gcd(left[i], A[i]);
  }
  for (int i = N; i > 0; i--) {
    right[i - 1] = gcd(right[i], A[i - 1]);
  }

  int res = 0;
  for (int i = 0; i < N; i++) {
    res = max(res, gcd(left[i], right[i + 1]));
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[102][102], n, res;
int main()
{
	cin >> n;
	for (int i = 1; i <= 2; i++)
		for (int j = 1; j <= n; j++)
			cin >> dp[i][j];
	for (int i = 1; i <= 2; i++)
		for (int j = 1; j <= n; j++)
			dp[i][j] += max(dp[i - 1][j], dp[i][j - 1]);
	cout << dp[2][n] << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

int m[10005];
ll ans;
int tmp[200005];

ll po(ll a, ll x, ll p) {
  ll res = 1;
  while(x > 0) {
    if(x & 1) res = a * res % p;
    a = a * a % p;
    x >>= 1;
  }
  return res;
}

int main() {
  ll n,p;
  cin >> n >> p;
  string s;
  cin >> s;

  if(p == 2 || p == 5) {
    for(int i = n - 1; i >= 0; i--) {
      if((s[i] - '0') % p == 0) {
	ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }
  
  tmp[n] = 0;
  m[tmp[n]]++;
  
  for(int i = n - 1; i >= 0; i--) {
    tmp[i] = ((s[i] - '0') * po(10,n-1-i,p) % p + tmp[i+1]) % p;
   
    m[tmp[i]]++;
  }
  //  for(int i = 0; i <= p; i++) cout << m[i] << endl;
  for(int i = 0; i < n; i++) {
    m[tmp[i]]--;
    ans += m[tmp[i]];
  }
  cout << ans << endl;
}
	   
  


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X, Y;
  cin >> X >> Y;
  
  if((Y%2==0) && (Y-2*X>=0) && (4*X>=Y)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

const int N = 1e5 + 9;

int n, a[N], t[2], g, b[N], m, num;
bool o;

void Ext (bool o) { puts(o ? "First" : "Second"); exit(0); }
int gcd (int a, int b) { return b ? gcd(b, a % b) : a; }
bool sum () { bool sum = 0; for (int i = 1; i <= n; ++i) sum ^= (a[i] & 1) ^ 1; return sum; }

int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	while (1) {
		t[0] = t[1] = m = g = 0;
		if (n <= 1) Ext(o);
		for (int i = 1; i <= n; ++i) ++t[a[i] & 1];
		if ((t[0] & 1) && t[1])
		Ext(o ^ 1);
		if (!(t[0] & 1) && t[1] > 1)
		Ext(o);
		for (int i = 1; i <= n; ++i) if (a[i] & 1) {
		if (a[i] == 1) 
		Ext(sum() ^ o);
		 --a[i];  break;
		}
		for (int i = 1; i <= n; ++i) if (!g) g = a[i]; else g = gcd(g, a[i]);
		for (int i = 1; i <= n; ++i) {
			a[i] /= g;
			b[++m] = a[i];
		}
		if (m != n) o ^= 1;
		for (int i = n = m; i; --i) a[i] = b[i];
		o ^= 1;
	}
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000

int main() {
	int n;
	scanf("%d", &n);
	n /= 200;
	n = 10 - n;
	printf("%d\n", n);
	return 0;
}


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

using namespace std;

int main() {
    int a , b , c;
    cin>>a>>b>>c;
    int cnt[10] = {0};
    cnt[a]++;
    cnt[b]++;
    cnt[c]++;
    if(cnt[5] == 2 && cnt[7] == 1)cout<<"YES\n";
    else cout<<"NO\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 2000000

int parent(int a){
  return (a / 2);
}
int left(int a){
  return (2 * a);
}
int right(int a){
  return (2 * a + 1);
}

int main(){
  int i,Heap,T[N];

  scanf("%d",&Heap);

  for(i=1; i<=Heap; i++){
    scanf("%d",&T[i]);
  }

  for(i=1; i<=Heap; i++){
    printf("node %d: key = %d, ",i,T[i]);
    if(parent(i) >= 1) printf("parent key = %d, ",T[parent(i)]);
    if(left(i) <= Heap)printf("left key = %d, ",T[left(i)]);
    if(right(i) <= Heap) printf("right key = %d, ",T[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2048
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N;cin >> N;
    vector<int> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    map<int,int> M;
    for(int i = 0;i<N;i++){
        M[retu.at(i)]++;
    }
    bool ok = true;
    if(N % 2 == 0){
        for(auto A : M){
            int B = A.second;
            if(B != 2) ok = false;
        }
    }
    else{
        for(auto C : M){
            int ex = C.first;
            int D = C.second;
            if(ex == 0 && D != 1) ok = false;
            if(ex != 0 && D != 2) ok = false;
        }
    }

    if(ok){
        cout << mod_pow(2,N/2) << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

int main() {
	//cout << fixed << setprecision(10);
	long long int k, s, t,n,m,a=0,b,c,d;
	string str;
	cin >> n>>str;
	for (int i = 0; i < n; i++) {
		if (str[i]=='R') {
			a++;
		}
		else {
			a--;
		}
	}
	if (a>0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
	

}

Measured memory_bytes: 256
import collections
import string
n = int(input())
res = []
for _ in range(n):
  s = list(input())
  cnt = collections.Counter(s)
  res.append(cnt)

ans = ""
for cha in list(string.ascii_lowercase):
  hoge = []
  for cnt in res:
    if(cha in cnt):
      hoge.append(cnt[cha])
  if (len(hoge) == n) :
    ans += cha * min(hoge)
print(ans)      


Measured memory_bytes: 3768
from functools import reduce
from fractions import gcd

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

n = int(input())
T = [int(input()) for _ in  range(n)]

ans = 1

for t_i in T:
  ans = lcm(ans, t_i)
  
print(ans)

Measured memory_bytes: 5128
package main
 
import (
  "fmt"
)
 
func main() {
 
  var n int
  fmt.Scan(&n)
  dam := make([]int, n)
  rain := make([]int, n)
  amt := 0
  
  for i := 0; i < n; i++ {
    fmt.Scan(&dam[i])
    rain[i] = 0
    amt += dam[i]
  }
  
  rain[0] = amt
  
  for i := 1; i < n-1; i+=2 {
    rain[0] -= 2 * dam[i]
  }
  
  for i := 1; i <= n-1; i++ {
    rain[i] = 2 * dam[i-1] - rain[i-1]
  }
  
  for i := 0; i < n; i++ {
    fmt.Print(rain[i]," ")
  }
}

Measured memory_bytes: 6528
n=int(input())
a=list(map(int,input().split()))
ans = [0]*n
an=[]
for i in range(n-1,-1,-1):
	now = i
	cnt=0
	while(now<n):
		cnt+=ans[now]
		now+=i+1
	ans[i] = a[i]^(cnt%2)
	if ans[i]:
		an.append(i+1)
an.reverse()
print(sum(ans))
print(" ".join([str(x)for x in an]))

Measured memory_bytes: 72156
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define int long long 
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

int dp[100005][3];

signed main() {
    FASTIO;
    //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        //freopen("stderr.txt", "w", stderr);
    //#endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        int n;
        cin>>n;
        vi a(n);
        rep(i,n) cin>>a[i];
        dp[0][1]=dp[0][2]=0;
        dp[1][1]=abs(a[0]-a[1]);
        dp[1][2]=inf;
        loop(i,2,n){
            dp[i][1]=min(dp[i-1][1],dp[i-1][2])+abs(a[i]-a[i-1]);
            dp[i][2]=min(dp[i-2][1],dp[i-2][2])+abs(a[i]-a[i-2]);
        }
        cout<<min(dp[n-1][1],dp[n-1][2])<<endl;

        
    // }
    cerr<<"Time Elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<" sec";
    return 0;
}

Measured memory_bytes: 3456
N, K = map(int, input().split())
S = input()
R = []
L = []
direction = S[0]
cnt = 1
for i in range(1, N):
    if S[i] == direction:
        cnt += 1
    else:
        if direction == 'L':
            L.append(cnt)
        else:
            R.append(cnt)
        cnt = 1
        direction = S[i]
if direction == 'L':
    L.append(cnt)
else:
    R.append(cnt)
# print(L, R)
res = sum(L) - len(L) + sum(R) - len(R)
res += 2 * K
print(min(res, N - 1))


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

int main() {
  int X, Y;
  cin >> X >> Y;

  int c = X, t = 0;
  while (0 <= c) {
    if (2 * c + 4 * t == Y) {
      cout << "Yes" << endl;
      return 0;
    } else {
      c--, t++;
    }
  }

  cout << "No" << endl;
  return 0;
}


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

 int A, B, C;

 cin >> A >> B >> C;

 if (((A < C) && (C < B)) || ((A > C) &&  (C > B))) cout << "Yes" << endl;
  else cout << "No" << endl;


 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  long long dp[110][25];
  int sum[110];
  int n;
  cin>>n;
  
  loop(i,1,n+1)cin>>sum[i];
  memset(dp,0,sizeof(dp));

  dp[1][sum[1]] = 1;
  loop(i,2,n){
    loop(j,0,20+1){
      if(j+sum[i] <= 20)dp[i][j+sum[i]] += dp[i-1][j];
      if(0 <= j-sum[i]) dp[i][j-sum[i]] += dp[i-1][j];
    }
  }
  cout<<dp[n-1][sum[n]]<<endl;
}

Measured memory_bytes: 1184
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

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

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    string a,b,c;
    cin >> n;
    cin >> a >> b >> c;
    int cnt = 0;
    REP(i,0,n) {
        if (a[i] != b[i]) ++cnt;
        if (a[i] != c[i] && b[i] != c[i]) ++cnt;
    }
    cout << cnt << endl;
}

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

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c,d;
scanf("%d%d%d%d", &a, &b, &c, &d);
  
  while(1){
    c=c-b;
    if(c<=0){
      printf("Yes\n");
      return 0;
    }
    a=a-d;
    if(a<=0){
            printf("No\n");
      return 0;
    }
  }

}


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

int main(){
int n, neg = 0;
bool c = false;
long long int sum = 0;
cin >> n;
vector <long long int> a(n+1);
vector <long long int> b;
for (int i = 1; i<=n;i++){
cin >> a[i];
if (a[i] < 0){
++neg;
}
if (a[i] == 0){
c = true;
}
b.push_back(abs(a[i]));
}
sort(b.begin(),b.end());
for (int j = 0; j < n; ++j){
sum += b[j];
}
if (neg % 2 == 1){
if (!c){
sum -= 2 * b[0];
}
}
cout << sum << "\n";
return 0;
}



Measured memory_bytes: 2296
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int n;
  string a,b;
  cin >> n >> a >> b;
  vll dp(n+1);
  if(a[0]==b[0]){
    dp[1] = 3;
    rep2(i,1,n){
    if(a[i]==b[i]){
      if(a[i-1]==b[i-1]){
        dp[i+1] = dp[i]*2;
        dp[i+1]%=mod;
      }
      
      else{
        dp[i+1] = dp[i];
        dp[i+1]%=mod;
      }
    }
    else{
      if(a[i-1]==b[i-1]){
        dp[i+2] = dp[i]*2;
        dp[i+2]%=mod;
      }
      else {
        dp[i+2] = dp[i]*3;
        dp[i+2]%=mod;
      }
      i++;
    }
  }
  }
  else{
    dp[2] = 6;
    rep2(i,2,n){
    if(a[i]==b[i]){
      if(a[i-1]==b[i-1]){
        dp[i+1] = dp[i]*2;
        dp[i+1]%=mod;
      }
      
      else{
        dp[i+1] = dp[i];
        dp[i+1]%=mod;
      }
    }
    else{
      if(a[i-1]==b[i-1]){
        dp[i+2] = dp[i]*2;
        dp[i+2]%=mod;
      }
      else {
        dp[i+2] = dp[i]*3;
        dp[i+2]%=mod;
      }
      i++;
    }
  }
  }
  
  
  cout << dp[n] << endl;
}




Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int ans[] = new int[4];
        String str[] = {"AC", "WA", "TLE", "RE"};

        for (int i = 0; i < N; i++) {
            String S = sc.next();
            if (S.equals("AC")) ans[0]++;
            else if (S.equals("WA")) ans[1]++;
            else if (S.equals("TLE")) ans[2]++;
            else ans[3]++;
        }

        for (int i = 0; i < 4; i++) {
            System.out.print(str[i]);
            System.out.print(" x ");
            System.out.println(ans[i]);
        }
    }
}


Measured memory_bytes: 57980