akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  string s;
  cin >> s;

  string d[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  rep(i, 7)
  {
    if (s == d[i])
    {
      cout << 7 - i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N;
  cin>>N;
  vector<int>b(N);
  for(int i=0;i<N;i++){
    cin>>b[i];
  }
  int n=N;
  vector<int>ans;
  for(int i=0;i<N;i++){
    for(int j=(int)b.size()-1;j>=0;j--){
      if(b[j]==j+1){
        ans.push_back(b[j]);
        b.erase(b.begin()+j); 
        break;
      }
    }
  }
  reverse(ans.begin(),ans.end());
  if(b.size()==0){
    for(int i=0;i<N;i++){
      cout<<ans[i]<<endl;
    }
  } 
  else{cout<<-1<<endl;}
  return 0;
}

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

using namespace std;
typedef long long LL;
int frek[212121];

int main() {
	int N;
	scanf("%d", &N);
	int arr[N + 5];
	LL awal = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &arr[i]);
		awal += frek[arr[i]];
		frek[arr[i]]++;
	}
	for (int i = 0; i < N; i++) {
		cout << awal - frek[arr[i]] + 1 << "\n";
	}
}

Measured memory_bytes: 3712
using namespace std;
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

int main() {
  long long X, Y;
  cin >> X >> Y;
  int i = 1;
  while (Y >= X * (long long)(pow(2, i-1))) i++;
  cout << i - 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    string s;
    cin>>s;
    int len=s.length();
    for(int i=0;i<len;i++){
        cout<<"x";
        if(i+1==len) cout<<endl;
    }
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> B(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(), B.end());
    set<long long> jdg;
    for(int i = 0; i < N; i += 2){
        jdg.insert(B[i]);
    }
    int cnt = 0;
    for(int i = 1; i < N; i += 2){
        if(jdg.count(A[i]))cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool compare(int former, int latter){
    if(abs(former)==abs(latter)){
        return former < latter;
    }else return abs(former) < abs(latter);
}

int main(void){
    int X, N, pbuf;
    cin >> X >> N;
    vector<int> pdash;
    for(int i=0; i<N; i++){
        cin >> pbuf;
        pdash.push_back(pbuf-X);
    }
    sort(pdash.begin(), pdash.end(), compare);
    int res = 0;
    bool minus = false;
    for(int i=0; i<N; i++){
        if(res == pdash[i]){
            res = -res + (minus ? 0 : -1);
            minus = !minus;
        }else break;
    }

    cout << X + res << endl;
    return 0;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10**6)

class UnionFind:

    def __init__(self, n: int) -> None:
        self.p = [-1] * n
        self.r = [1] * n

    def find(self, x: int) -> int:
        if(self.p[x] == -1): return x
        self.p[x] = self.find(self.p[x])
        
        return self.p[x]

    def unite(self, x: int, y: int) -> None:
        x = self.find(x)
        y = self.find(y)
        if(x == y): return
        if(self.r[x] > self.r[y]): x, y = y, x
        if(self.r[x] == self.r[y]): self.r[y] += 1

        self.p[x] = y
    
    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)

    
    

def main():
    n, m = map(int, input().split())

    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        
        uf.unite(a, b)
    
    group = {}

    res = 0
    for i in range(n):
        g = uf.find(i)
        
        if(group.get(g) is None): group[g] = 1
        else: group[g] += 1

        res = max(res, group[g])
    
    print(res)

    


if __name__ == "__main__":
    main()

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

using lli = int64_t;
using vi = vector<lli>;
using vvi = vector<vi>;

int main()
{
    ios_base::sync_with_stdio(0);

    int n; cin >> n;

    vvi v(n, vi(2));

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

        if(v[i][1] % 4 == 0) v[i][0] = 2;
        else
        if(v[i][1] % 2 == 0) v[i][0] = 1;
    }

    sort(begin(v), end(v));

    vi ans(n);

    int l = 0, r = n - 1;

    for(int i = 0; i < n; i += 2) ans[i] = v[l++][1];
    for(int i = 1; i < n; i += 2) ans[i] = v[r--][1];

    int fl = 1;

    for(int i = 0; i < n - 1; i++) fl &= (ans[i] * ans[i + 1]) % 4 == 0;

    if(fl) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void YN(bool f){ cout << (f ? "YES" : "NO");}
void yn(bool f){ cout << (f ? "yes" : "no");}
void YeNo(bool f) {cout << (f ? "Yes" : "No");}
signed main(){
    int N; cin >> N;
    vector<int>v(N);
    for(auto & e : v) cin >> e;
    array<float,13> cnt = {0};
    cnt[0]++;
    for(auto  e : v)cnt[e]++;
    for(auto  e : cnt) if(e >= 3) return puts("0") * 0;
    if(cnt[0] >= 2 or cnt[12] >= 2) return puts("0")* 0;
    //distribute cnt to base
    vector<int>base(25,0LL);
    base[0] = 1;
    for(int i = 1; i <= 12; ++i){
        if(cnt[i] == 1){
            //???
        } else if(cnt[i] == 2){
            base[i] = base[ 24 - i] = 1;
        }
    }
    auto set = [](int num, int bit){
        return (num & (1LL << bit)) >= 1;
    };
    int ans = -INF;
    for(int bit = 0; bit < (1LL << 12); ++bit){
        vector<int>tbase = base;
        for(int i = 1; i <= 12; ++i){
            if(cnt[i] == 1){
                (set(bit,i-1) ? tbase[i] : tbase[24 - i]) = 1;
            }
        }
        int tans = INF;
        for(int i = 0; i < tbase.size(); ++i){
            for(int j = 0; j < tbase.size(); ++j){
                if(i != j and tbase[i] != 0 and tbase[j] != 0)
                    cmin(tans,min(max(i,j) - min(i,j),24 - (max(i,j) - min(i,j))));
            }
        }
        cmax(ans, tans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static final String SPACE = " ";
    static final String RN = "\n";

    public static void main(String[] args) {
        // input
        int x;
        int y;

        StringBuilder sb = new StringBuilder();
        Scanner sc = new Scanner(System.in);
        int temp;

        while (true) {
            x = sc.nextInt();
            y = sc.nextInt();
            if (x == 0 && y == 0) {
                break;
            }
            if (x > y) {
                sb.append(y).append(SPACE).append(x).append(RN);
            } else {
                sb.append(x).append(SPACE).append(y).append(RN);
            }
        }

        // output
        System.out.print(sb);
    }
}

Measured memory_bytes: 27612
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define mm map<ii>
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast


    int n,m;
    cin>>n>>m;

    vector<vector<int>> v(100005);

    int a,b;
    forn(i,0,n)
    {
        cin>>a>>b;
        v[a].pb(b);
    }    

    multiset<int> s;
    ll ans = 0;
    for(int i = m-1; i >= 0; i--)
    {
        for(auto j : v[m-i])
        {
            s.insert(j);
        }

        if(!s.empty())
        {
            ans += *(s.rbegin());
            s.erase(prev(s.end()));
        }
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 7808
length = input()
a_list = list(map(int, input().split()))
 
for i in range(len(a_list)-1):
  if a_list[i] < a_list[i+1]:
    a_list[i+1] -= 1
  elif a_list[i] > a_list[i+1]:
    print("No")
    exit()
    
print('Yes')


Measured memory_bytes: 14396
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

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

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let n:usize;
    input!(n);
    let a=input_vector::<usize>();
    let mut b=vec![99999999;n];
    b[0]=a[0];
    for i in 1..n{
        if b[i-1]>a[i]{
            b[i]=a[i];
        }else{
            b[i]=b[i-1];
        }
    }

    let mut ans=0;
    
    for i in 0..n{
        if a[i]<=b[i]{
            ans+=1;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 8948
#include <bits/stdc++.h>
/**
*   author: j o s e m a g o
*   date:
**/
using namespace std;
#pragma GCC optimize ("Ofast")
#define lg first
#define p second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"

typedef double db;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;

class T{
    public:
    int lg;
    char p;
    T(){};
};

string a,b;
int n,m;
T table[3009][3009];

string sub;

void sol(int i,int j,string &a){
    if(i == 0 || j == 0) return;
    if(table[i][j].p == 'D'){
        sub.pb(a[i-1]);
        sol(i-1,j-1,a);
    }
    else if(table[i][j].p == 'S'){
        sol(i-1,j,a);
    }
    else{
        sol(i,j-1,a);
    }

}


int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

    ios_base::sync_with_stdio(0); cin.tie(0);



    cin >> a >> b;
    n = a.size(); m = b.size();
    for(int i=0; i<=n; i++)  table[i][0].lg = 0;
    for(int i=0; i<=m; i++)  table[0][i].lg = 0;


    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= m;j++){
            if(a[i-1] == b[j-1]){
                table[i][j].lg = 1+table[i-1][j-1].lg;
                table[i][j].p = 'D';
            }
            else if(table[i-1][j].lg>=table[i][j-1].lg){
                table[i][j].lg = table[i-1][j].lg;
                table[i][j].p = 'S';
            }
            else{
                table[i][j].lg = table[i][j-1].lg;
                table[i][j].p = 'I';
            }
        }
    }

    sol(n,m,a);

    reverse(sub.begin(),sub.end());

    cout<<sub;


    return 0;
}

Measured memory_bytes: 70784
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		solve();
	}

	private static void solve(){
		Scanner sc=new Scanner(System.in);

		while(true){
			int n=sc.nextInt();
			if(n==0)break;
			Map<String,String> map=new HashMap<String,String>();
			for(int i=0;i<n;i++)
				map.put(sc.next(), sc.next());
			n=sc.nextInt();
			for(int i=0;i<n;i++){
				String s=sc.next();
				if(map.containsKey(s))
					System.out.print(map.get(s));
				else 
					System.out.print(s);
			}
			System.out.print("\n");
		}
	}
}

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

int main() {
  int n,k;
  cin >> n;
  k = 0;
  string s;
  cin >> s;
  if(n%2 != 0){
    cout << "No" << endl;
  }
  else {
    for(int i=0;i<n/2;i++){
      if(s.at(i) != s.at(n/2 +i)){
        k = -1;
        break;
      }
    }
    if(k == -1) cout << "No" << endl;
    else cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import math

def combinations_count(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m = map(int, input().split())
balls = 2
ans = combinations_count(n,balls) + combinations_count(m,balls)
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  cin>>n;
  while(n--){
    set<char> use;
    string str;
    string ans;
    cin>>str;
    ans += str[0];
    use.insert(str[0]);
    for(int i=3;i<(int)str.size();i+=3){
      if(use.find(str[i])!=use.end()) continue;
      if(str[i-1]=='>') ans += str[i];
      else ans = str[i]+ans;
      use.insert(str[i]);
    }
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
n, m = (int(i) for i in input().split())

lst = [[int(i) for i in input().split()] for i in range(m)]

cnt = [1 for _ in range(n)]
r = [0 for _ in range(n)]
r[0] = 1
for e in lst:
    x = e[0] - 1
    y = e[1] - 1
    if r[x] == 1:
        r[y] = 1
    cnt[x] -= 1
    cnt[y] += 1
    if cnt[x] == 0:
        r[x] = 0

print(sum(r))

Measured memory_bytes: 22792
a,b,c,d=map(int,input().split())
a,b=b,a
c,d=d,c
ok=True
while b>0 and d>0:
    d-=a
    if d<=0:
        ok=True
        break
    b-=c
    if b<=0:
        ok=False
        break
if ok:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9188
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1

    def roots(self):
        return [i for i, x in enumerate(self.table) if x < 0]

    def group_count(self):
        return len(self.roots())


def main():
    n, m = map(int, sys.stdin.buffer.readline().split())
    U = UnionFind(n)
    for x in sys.stdin.buffer.readlines():
        a, b = map(lambda x: int(x) - 1, x.split())
        U.union(a, b)
    print(U.group_count() - 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16380
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int maxN = 100005;
const ll INF = 1000000000000000000LL;

class TaskB {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int x, y;
		cin >> x >> y;
		if((y-2*x) % 2){
			cout << "No" << endl;
			return;
		}
		int a = (y - 2*x)/2;
		if(a < 0){
			cout << "No" << endl;
			return;
		}
		int b = x - a;
		if(b < 0){
			cout << "No" << endl;
			return;
		}
		cout << "Yes" << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskB solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3660
# ABC161d


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    k = int(input())

    def isOk(n):
        n = str(n)
        for i in range(len(n)):
            if (i+1 < len(n) and abs(int(n[i]) - int(n[i + 1])) > 1 or i+2 < len(n) and abs(int(n[i + 1]) - int(n[i + 2])) > 1):
                return False
        return True

    def swap(n, i, f):
        ori = n
        ns = str(n)
        try:
            t = ns[-i-1]
            w = ns[-i - 2]
        except:
            s = int(f) + 1
            l = len(ns)
            if s == 10:
                l += 1
            a = ''
            for i in range(s, -1, -1):
                a += str(i)
            a += '0'*(l-len(a))
            return int(a[:l])
        if t == w:
            return swap(n, i+1, f)
        n -= int(t) * 10 ** i
        n -= int(w)*10**(i+1)
        n += int(t) * 10 ** (i + 1)
        n += int(w) * 10 ** (i)
        l = len(ns)
        a = str(n)[:-i-1]
        for i in range(int(a[-1])-1, -1, -1):
            a += str(i)
        a = a[:l]
        a += '0'*(l-len(a))
        n = int(a[:l])
        if not isOk(n):
            return swap(ori, i+1, f)
        return n

    def calc(n, I):
        if isOk(n):
            return n
        n -= 10**I
        n += 10 ** (I + 1)
        a = str(n)[: -I - 1]
        l = len(str(n))
        for i in range(int(a[-1])-1, -1, -1):
            a += str(i)
        a = a[:l]
        a += '0'*(l-len(a))
        n = int(a[:l])
        return calc(n, I+1)

    dp = [0] * (k+1)
    ind = 0
    for i in range(k):
        # if i == 43:
            # print('hi')
        dp[i + 1] = calc(dp[i] + 1, 0)
        # if dp[i] == 123:
        # print('hi')

        # if not isOk(dp[i + 1]):
        #    dp[i + 1] = swap(dp[i], 0, str(dp[i])[0])
        #print(i, dp[i + 1])
        # if i == 990:
        # print('hi')
    print(dp[k])


if __name__ == '__main__':
    main()


Measured memory_bytes: 73816
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[55];
int B[55];

LL mask;

bool D[55][55];

bool ok() {
    memset(D, 0, sizeof D);
    REP (i, 51) D[i][i] = true;
    REP (i, 51) if (mask >> i & 1) {
	for (int j=i; j<=50; j++) {
	    D[j][j % i] = true;
	}
    }
    REP (k, 51) REP (i, 51) REP (j, 51) if (D[i][k] && D[k][j]) D[i][j] = true;

    REP (i, N) if (!D[A[i]][B[i]]) return false;
    return true;
}

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);
    REP (i, N) scanf("%d", B+i);

    mask = (1LL << 50) - 1;
    mask <<= 1;

    if (!ok()) {
	puts("-1");
	return;
    }

    for (int i=50; i>=1; i--) {
	mask ^= 1LL << i;
	if (!ok()) {
	    mask ^= 1LL << i;
	}
    }

    printf("%lld\n", mask);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main(){

  int a,b,d,r;
  double f;

  cin>>a>>b;
  d=a/b;
  r=a%b;
  f=(double)a/(double)b;

  cout<<d<<" "<<r<<" "<<fixed<<f<<endl;

  return 0;
}



Measured memory_bytes: 3284
#!/usr/bin/env python
# coding: utf-8

# In[39]:


N = int(input())
s = str(input())
t = str(input())


# In[40]:


for i in range(len(s)):
#     print(i, s[i:], t[:len(t)-i])
    if s[i:] == t[:len(t)-i]:
#         print(s[:i]+t)
        print(i+N)
        break
    elif i == len(s)-1:
#         print(s+t)
        print(2*N)


# In[ ]:






Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std
 
Willy Indrayana Komara;

using ll = long long int;

int generateGCD(int a, int b, int c)
{
    return __gcd(a, __gcd(b, c));
}

int a[201];

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

    int ans = 0;
    //generate gcd sum
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            for (int k = 1; k <= n; k++)
            {
                ans += generateGCD(i, j, k);
                //cout << generateGCD(i, j, k) << '\n';
            }
        }
    }
    cout << ans << '\n';
    /*
    
    111 = 1 1 = 1
    112 = 1 1 = 1
    121 = 1 1 = 1
    122 = 1 2 = 1
    211 = 1 1 = 1
    212 = 1 1 = 1
    221 = 2 1 = 1
    222 = 2 2 = 2
    */
    //cout << __gcd(2, 1) << endl;
    return 0;
}


Measured memory_bytes: 3652
from collections import Counter
from decimal import Decimal

def func(n):
    cnt2 = 0
    cnt5 = 0
    while n % 2 == 0:
        n //= 2
        cnt2 += 1
    while n % 5 == 0:
        n //= 5
        cnt5 += 1
    return cnt2, cnt5

def main():
    N = int(input())
    A = [input() for _ in range(N)]
    ctr = Counter()

    for a in A:
        d = Decimal(a)
        d = int(d * 1000000000)
        cnt2, cnt5 = func(d)
        ctr[(cnt2,cnt5)] += 1
    ans = 0
    for (ni1, go1), v1 in ctr.items():
        for (ni2, go2), v2 in ctr.items():
            if not (ni1 + ni2 >= 18 and go1 + go2 >= 18):
                continue
            if ni1 == ni2 and go1 == go2:
                ans += v1 * (v1 - 1)
            else:
                ans += v1 * v2


    print(ans // 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 282544
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;


public class Main {
    public static void main(String[] args)throws Exception{
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int b;
        int f;
        int r;
        int v;
        ArrayList<Integer> building1 = new ArrayList<Integer>();
        ArrayList<Integer> building2 = new ArrayList<Integer>();
        ArrayList<Integer> building3 = new ArrayList<Integer>();
        ArrayList<Integer> building4 = new ArrayList<Integer>();
        clear(building1);
        clear(building2);
        clear(building3);
        clear(building4);
        for(int i = 0;i <= n - 1;i++){
            b = scan.nextInt();
            f = scan.nextInt();
            r = scan.nextInt();
            v = scan.nextInt();
            switch(b){
                case 1:
                    vary(building1,f,r,v);
                    break;
                case 2:
                    vary(building2,f,r,v);
                    break;
                case 3:
                    vary(building3,f,r,v);
                    break;
                case 4:
                    vary(building4,f,r,v);
                    break;
            }
        }
        //出力
        dp(building1);
        System.out.println("####################");
        dp(building2);
        System.out.println("####################");
        dp(building3);
        System.out.println("####################");
        dp(building4);
    }

    public static void clear(ArrayList<Integer> building){
        for(int i = 0;i <= 29;i++){
            building.add(0);
        }    
    }
    
    //部屋の人数の処理
    public static void vary(ArrayList<Integer> building,int floor,int room,int number){
        building.set((floor - 1) * 10 + room - 1,building.get((floor - 1) * 10 + room - 1) + number);
    }
    
    //出力
    public static void dp(ArrayList<Integer> building){
        String st = "";
        for(int i = 0;i <= 29;i++){
            if(i <= 8){
                st += " " + building.get(i);
            }else if(i == 9){
                st += " " + building.get(i);
                System.out.println(st);
                st = "";
            }else if(i >= 10 && i <= 18){
                st += " " + building.get(i);
            }else if(i == 19){
                st += " " + building.get(i);
                System.out.println(st);
                st = "";
            }else if(i >= 20 && i <= 28){
                st += " " + building.get(i);
            }else if(i == 29){
                st += " " + building.get(i);
                System.out.println(st);
                st = "";
            }
        }
    }
}


Measured memory_bytes: 29708
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''D'''
n = r()
a = input()
whites = a.count('W')
if whites == 0 :
    print(0)
else:
    reds = n-whites
    s = 'R'*reds+'W'*whites
    change = 0
    for i in range(n):
        if a[i] != s[i]:
            change+=1
    print((change+1)//2)

Measured memory_bytes: 73600
#include<stdio.h>
using namespace std;
int main()
{
    int n,sum;
    scanf("%d",&n);
    if(n%2==0)
    {
        printf("%d\n",n);
    }
    else
    {
        sum=2*n;
    printf("%d\n",sum);
    }

    return 0;
}


Measured memory_bytes: 128
/* ALDS1_5_A: Exhaustive Search */

#include <iostream>
#include <string>

int N;
int *S;

bool find(int i, int goal) {
    if (goal == 0)
        return true;
    if (i == N)
        return false;
    return find(i + 1, goal - S[i]) || find(i + 1, goal);
}

int main() {
    std::ios::sync_with_stdio(false);

    std::cin >> N;
    S = new int[N];
    for (int i = 0; i < N; i++)
        std::cin >> S[i];

    int n_goals;
    std::cin >> n_goals;

    int goal;
    std::string *results = new std::string[n_goals];
    for (int i = 0; i < n_goals; i++) {
        std::cin >> goal;
        results[i] = find(0, goal) ? "yes" : "no";
    }

    for (int i = 0; i < n_goals; i++) {
        std::cout << results[i] << "\n";
    }
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  vi S(4, 0);
  double ans = (double)W * (double)H / 2;
  if (W == x * 2 && H == y * 2) {
    printf("%f 1", ans);
  } else {
    printf("%f 0", ans);
  }
}

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

  solve();

  return 0;
}


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

int n, c;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for(int i=1;i<=n;i++){
		int a, b; cin >> a >> b;
		if(a == b){
			if(++c == 3){
				cout << "Yes";
				return 0;
			}
		}else c = 0;
	}
	cout << "No";
}

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

int main(){
    int64_t L[100];
    int64_t n;
    cin>>n;

    L[0] = 2;
    L[1] = 1;

    for (size_t i = 2; i <= n; i++)
    {
        L[i] = L[i-2]+L[i-1];
    }
    cout<<L[n];
}

Measured memory_bytes: 256
// AtCoder Regular Contest 073
// E - Ball Coloring

#include <cstdio>
#include <set>
#include <algorithm>
#define MAX_N 200000
#define INF ((ll)1e10)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;


int N;
ll a;
pll xy[MAX_N];
multiset<ll> s;
ll ans;

int main() {

  ll s_s, s_l, l_s, l_l;

  scanf("%d", &N);
  s_s = s_l = INF;
  l_s = l_l = 0;
  for (int i = 0; i < N; i++) {
    scanf("%lld%lld", &xy[i].first, &xy[i].second);
    if (xy[i].first > xy[i].second) {
      swap(xy[i].first, xy[i].second);
    }
    s_s = min(s_s, xy[i].first);
    s_l = min(s_l, xy[i].second);
    l_s = max(l_s, xy[i].first);
    l_l = max(l_l, xy[i].second);
  }
  sort(xy, xy + N);

  ans = (l_s - s_s) * (l_l - s_l);

  for (int i = 0; i < N; i++) {
    s.insert(xy[i].first);
  }
  ans = min(ans, (l_l - s_s) * (*(s.rbegin()) - *(s.begin())));
  for (int i = 0; i < N; i++) {
    s.erase(s.find(xy[i].first));
    s.insert(xy[i].second);
    ans = min(ans, (l_l - s_s) * (*(s.rbegin()) - *(s.begin())));
  }

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

  return 0;

}




Measured memory_bytes: 12800
#include <iostream>
#include <bitset>

constexpr int MAX_N=(int)1e5;

int n;
int A[MAX_N];
int x[MAX_N];
bool exist[MAX_N];

int main() {

    std::cin>>n;

    for(int i=0;i<n;++i)
        std::cin>>A[i];

    for(int i=0;i<n;++i){
        int j=1;
        for(;A[i]%(1<<j)==0;++j);
        x[i]=j-1;
    }

    for(int i=0;i<n;++i)
        exist[x[i]]=true;

    int res=A[0];

    for(int i=1;i<n;++i)
        res^=A[i];

    int ans=0,index=0;

    for(;res>=(1<<index);++index);
    --index;

    if(index<0){
        std::cout<<0<<std::endl;
        return 0;
    }

    std::bitset<32> bit(res);

    for(int i=index;i>=0;--i){
        if(!bit[i])
            continue;
        if(!exist[i]){
            std::cout<<-1<<std::endl;
            return 0;
        }
        bit.flip();
        ++ans;
    }

    std::cout<<ans<<std::endl;

    return 0;
}

Measured memory_bytes: 1024
# include <iostream>
# include <cstdio>
# include <cstring>
using namespace std;
char s[1000+10];
int memo[150];
int main(){
    while(scanf("%s",s)!=EOF){
        memset(memo,0,sizeof(memo));
        for(int i = 0;s[i]!='\0';++i){
            if(memo[s[i]] == 0)
                memo[s[i]] = 1;
        }
        if(memo['N'] == 1&&memo['W'] == 1&&memo['E'] == 1&&memo['S'] == 1)
            printf("Yes\n");
        else if(memo['N'] == 1&&memo['W'] == 0&&memo['E'] == 0&&memo['S'] == 1)
            printf("Yes\n");
        else if(memo['N'] == 0&&memo['W'] == 1&&memo['E'] == 1&&memo['S'] == 0)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
char s[105];
vector<int> z;
vector<int> o;
int main(void){
    int n,k,c=1,c2=0,cn=0,cn2=0,cn3=0;char x,y;
    cin>>n>>k>>x;
    if(x=='0'){c2=1;cn2++;}
    else cn++;
    for(int i=1;i<n;i++){
        cin>>y;
        if(y=='1')cn++;
        else cn2++;
        if(x==y){c++;x=y;}
        else{
            if(x=='1'){
                o.push_back(c);
                z.push_back(0);
            }else{
                o.push_back(0);
                z.push_back(c);
            }
            c=1;
            x=y;
        }
    }
    if(x=='1'){
        o.push_back(c);
        z.push_back(0);
    }else{
        o.push_back(0);
        z.push_back(c);
    }
    
    for(int i=0;i<z.size();i++){
        if(z[i]>0)cn3++;
    }
    
    if(cn==n||cn2==n||cn3<=k){
        cout<<n<<endl;
        return 0;
    }
    
    int ans=0,s=0,l;
    
    for(int i=0;i<o.size()-k*2+1;i++){
        s=0;
        if(z[i]>0){
            l=k*2;
        }else{
            l=k*2+1;
        }
        for(int j=i;j<i+l;j++){
            s+=o[j]+z[j];
        }
        ans=max(ans,s);
    }
    cout<<ans<<endl;
    
    return 0;
}


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

#define to first
#define cnt first
#define cost second
#define MAX_N 100001
#define MOD 10007

using namespace std;

typedef pair<int,int> P;

vector<P>G[MAX_N];
bool vis[MAX_N];

P dfs(int n,P x){
  vis[n]=true;

  for(int i=0;i<G[n].size();i++){
    P e=G[n][i];
    if(x.cost<e.cost)x.cost=e.cost,x.cnt=1;
    else if(x.cost==e.cost)x.cnt++;
    if(!vis[e.to])x=dfs(e.to,x);
  }

  return x;
}

int main(void){

  int n,b,fb;

  while(cin >> n,n){

    for(int i=0;i<MAX_N;i++)G[i].clear();

    for(int i=0;i<n;i++){
      for(int j=0;j<2;j++){
	cin >> b >> fb;
	G[i].push_back(make_pair(b,fb));
      }
    }

    fill(vis,vis+MAX_N,false);
    int ans=1;
    for(int i=0;i<n;i++){
      if(!vis[i]){
	P x(0,0);
	x=dfs(i,x);
	ans=ans%MOD*x.cnt/2%MOD;
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 4256
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int n, k;
vector<int> a;
int dp[100001];


const long long MOD = 1000000007;

long long mod(long long a, long long m = MOD)
{
    long long q = a % m;
    if (q < 0)
        q += m;
    return q;
}

long long modadd(long long a, long long b, long long m = MOD)
{
    return (a + b) % m;
}

long long modsub(long long a, long long b, long long m = MOD)
{
    return mod((a % m) - (b % m));
}

long long modmul(long long a, long long b, long long m = MOD)
{
    return (a * b) % m;
}

int main()
{
    cin >> n >> k;
    REP(i, k + 1) dp[i] = 0;
    dp[0] = 1;
    REP(i, n) {
        int ai;
        cin >> ai;
        // D(i);
        int left = k - min(ai, k);
        int right = k + 1;
        int sm = 0;
        for (int j = left; j < right; ++j) {
            sm = modadd(sm, dp[j]);
        }
        // D(ai);
        // DA(dp, k + 1);
        while(right > 0) {
            // DDD(right, left, sm);
            int tmp = dp[right - 1];
            dp[right - 1] = sm;
            if (left > 0) {
                left--;
                sm = modadd(sm, dp[left]);
            }
            right--;
            sm = modsub(sm, tmp);
        }
        // DA(dp, k);
    }
    cout << dp[k] << endl;
}


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

typedef long long ll;

int main() {
	int N;
	ll D;
	cin >> N >> D;

	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		ll X, Y;
		cin >> X >> Y;
		if (X * X + Y * Y <= D * D) ++cnt;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3192
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>

using namespace std;


int main(int argc, const char * argv[]) {
    

    int x, y, z;
    cin >> x >> y >> z;
    
    cout << z << " " << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

const int MAX_N = 402;
ll dp[MAX_N][MAX_N];
bool used[MAX_N][MAX_N];
int n;
ll a[MAX_N];
ll s[MAX_N+1];

ll getA(int l, int r) {
    return s[r] - s[l];
}

ll calc(int l, int r) {
    if(used[l][r]) return dp[l][r];
    used[l][r] = true;
    auto& ret = dp[l][r];
    ret = 1e18;
    if(r - l == 1) return ret = 0LL;
    if(r - l == 2) return ret = a[l] + a[l+1];
    for(int m = l + 1; m < r; ++m) {
        chmin(ret, calc(l, m) + calc(m, r) + getA(l, m) + getA(m, r));
    }
    return ret;
} 

int main(){
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        s[i+1] = s[i] + a[i];
    }
    cout << calc(0, n) << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a.at(i);
  rep(i,n){
    if(a.at(i)%2 == 0){
      if(a.at(i)%3 != 0 && a.at(i)%5 != 0){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,r;
string s,s1,s2;
//vvl v;
//vl vis,d;


int main() {
    IOS;cin>>n;
    cin>>s;
    n=sz(s);
    s1=s.substr(0,n/2);
    s2=s.substr(n/2,(n+1)/2);
    //cout<<s1<<" "<<s2<<el;
    if(s1==s2)cout<<"Yes"<<el;
    else cout<<"No";
    return 0;
}



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

using namespace std;
typedef long long ll;
const int MAX_V = 310;
ll INF = 100000000000;
struct edge{ll to,cap,rev;};
vector<edge> G[MAX_V];
ll level[MAX_V],iter[MAX_V];
void add_edge(ll from,ll to,ll cap){
    G[from].push_back({to,cap,(ll)G[to].size()});
    G[to].push_back({from,0,(ll)G[from].size() - 1});
}

void bfs(int s){
    for(int i=0;i<MAX_V;i++){
        level[i] = -1;
    }
    level[s] = 0;
    queue<int> que;
    que.push(s);
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(int i=0;i<G[v].size();i++){
            edge &e = G[v][i];
            if(e.cap>0 && level[e.to]<0){
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

ll dfs(int v,int t,ll f){
    if(v==t) return f;
    for(ll &i = iter[v];i<G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap>0 && level[v]<level[e.to]){
            ll d = dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

ll max_flow(int s, int t){
    ll flow = 0;
    while(true){
        bfs(s);
        if(level[t]<0) return flow;
        for(int i=0;i<MAX_V;i++){
            iter[i] = 0;
        }
        while(true){
            ll f = dfs(s,t,INF);
            if(f==0) break;
            flow += f;
        }
    }
}
ll a[110];
int main(){
    int i,j,n;
    ll ans = 0;
    cin >> n;
    for(i=1;i<=n;i++){
        cin >> a[i];
        if(a[i]>=0){
            ans += a[i];
            add_edge(0,i,a[i]);
        }else{
            add_edge(i,n + 1,-a[i]);
        }
        for(j=2*i;j<=n;j+=i){
            add_edge(j,i,INF);
        }
    }
    cout << ans - max_flow(0,n + 1) << endl;
}

Measured memory_bytes: 256
A=sorted(list(map(int, input().split())))

cnt0=(A[2]-A[0])//2
A[0]+=cnt0*2
cnt1=(A[2]-A[1])//2
A[1]+=cnt1*2
A=sorted(A)
#print(A)
if A[1]==A[2] and A[0]==A[2]:
  ans=cnt0+cnt1
elif A[1]==A[2] and A[0]!=A[2]:   
  ans=cnt0+cnt1+2
elif A[2]==A[0]:
  ans=cnt0+cnt1
else:
  ans=cnt0+cnt1+1
print(ans)

Measured memory_bytes: 3064