akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
        A[i] *= -1;
    }
    vector<int> B;
    REP(i, N) {
        auto itr = UB(B, A[i]);
        if (itr == B.end()) {
            B.push_back(A[i]);
        } else {
            *itr = A[i];
        }
    }
    cout << B.size() << endl;
    return 0;
}


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

using namespace std;

void solve() {
    int H, W, M;
    cin >> H >> W >> M;
    vector<pair<int, int>> tag;
    vector<int> tag_h(H, 0), tag_w(W, 0);
    for (int i = 0; i < M; i++)
    {
        int h, w;
        cin >> h >> w;
        h--;
        w--;
        tag.push_back(make_pair(h, w));
        tag_h[h]++;
        tag_w[w]++;
    }

    sort(tag.begin(), tag.end());
    int tag_h_max = 0, tag_w_max = 0;
    for (int i = 0; i < H; i++)
    {
        tag_h_max = max(tag_h_max, tag_h[i]);
    }
    for (int i = 0; i < W; i++)
    {
        tag_w_max = max(tag_w_max, tag_w[i]);
    }
    
    vector<int> a_h, a_w;
    for (int i = 0; i < H; i++)
    {
        if (tag_h[i] == tag_h_max)
        {
            a_h.push_back(i);
        }
    }
    for (int i = 0; i < W; i++)
    {
        if (tag_w[i] == tag_w_max)
        {
            a_w.push_back(i);
        }
    }

    for (int i = 0; i < (int)a_h.size(); i++)
    {
        for (int j = 0; j < (int)a_w.size(); j++)
        {
            pair<int, int> p = make_pair(a_h[i], a_w[j]);
            if(!binary_search(tag.begin(), tag.end(), p)){
                cout << tag_h_max + tag_w_max << endl;
                return;
            };
        }
        
    }
    cout << tag_h_max + tag_w_max - 1 << endl;
}

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

Measured memory_bytes: 12316
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <bitset>
typedef unsigned long long int ll;
const ll INF = 876543210987654321;
const int MOD = 1000000007;
#define REP(i,n) for(int i=0;i<n;++i)
#define pd(x) cout<<x<<endl
using namespace std;
//vector<vector<int>>(h, vector<int>(w, f));


int main() {
	string s;
	cin >> s;
	ll a[30] = {};
	ll n = s.size();
	for (int i = 0; s[i]; ++i) {
		a[s[i] - 'a']++;

	}
	ll ans = n*(n - 1) / 2;
	for (int i = 0; i < 26; ++i) {
		if (a[i] > 1)ans -= a[i] * (a[i] - 1) / 2;
	}
	cout << ans+1 << endl;
	int aa;
	cin >> aa;
	return 0;

}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <math.h>
#include <list>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX_N 10005
#define MAX_M 100

int N;
int A[MAX_N];

int main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - h * W - w * H + h * w << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n,q;
    ll k;
    cin >> n >> k >> q;
    vector<int> cnt(n, 0);
    rep(i, q){
        int a;
        cin >> a;
        cnt[a-1]++;
    }
    ll border = k - q;
    rep(i,n){
        if(border + cnt[i] > 0){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

ll h, w;
vvl ansMap;

void check(vvb isBomMap, ll tate, ll yoko){
	if (tate > 0 && yoko > 0) if (isBomMap[tate - 1][yoko - 1]) ansMap[tate][yoko]++;
	if (tate > 0) if (isBomMap[tate - 1][yoko]) ansMap[tate][yoko]++;
	if (tate > 0 && yoko < w - 1) if (isBomMap[tate - 1][yoko + 1]) ansMap[tate][yoko]++;
	if (yoko < w - 1) if (isBomMap[tate][yoko + 1]) ansMap[tate][yoko]++;
	if (tate < h - 1 && yoko < w - 1) if (isBomMap[tate + 1][yoko + 1]) ansMap[tate][yoko]++;
	if (tate < h - 1) if (isBomMap[tate + 1][yoko]) ansMap[tate][yoko]++;
	if (tate < h - 1 && yoko >0) if (isBomMap[tate + 1][yoko - 1]) ansMap[tate][yoko]++;
	if (yoko > 0) if (isBomMap[tate][yoko - 1]) ansMap[tate][yoko]++;
}

int main(){
	cin >> h >> w;
	vvb isBomMap(h, vb(w, false));
	ansMap.resize(h, vl(w, 0));
	rep(i, h) rep(j, w){
		char c; cin >> c;
		isBomMap[i][j] = (c == '.' ? false : true);
	}
	rep(i, h) rep(j, w) if (!isBomMap[i][j]) check(isBomMap, i, j);
	rep(i, h){
		rep(j, w){
			if (isBomMap[i][j]) cout << "#";
			else cout << ansMap[i][j];
		}cout << endl;

	}
	return 0;
}

Measured memory_bytes: 256
#include<set>
#include<iostream>
#include<ctime>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<functional>
#include<string.h>
#include<limits.h>
#define int long long
using namespace std;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a*b / gcd(a, b);
}
signed main() {
	int n; cin >> n;
	for (int i = 1; i <= 3500; i++) {
		int b = lcm(i, n);
		for (int j = 1; j <= 3500; j++) {
			int k = lcm(b, j);
			int sum = k / i + k / j;
			sum = k / n * 4 - sum;
			if (sum > 0 && k%sum == 0 && k / sum <= 3500) {
				cout << i << " " << j << " " << k / sum << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 888
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	string c1, c2, c3;
	cin >> c1 >> c2 >> c3;

	cout << c1[0] << c2[1] << c3[2] << endl;


	return 0;

}


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

int main () {
  string n;
  cin >> n;
  
  for (int i = 0; i < 3; i++) {    
    if (n.at(i) == '1') {
      n.at(i) = '9';
    }
    else if (n.at(i) == '9') {
      n.at(i) = '1';
    }
  }
  cout << n << endl;
}

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

int main(){
    int N = 0, num = 0;
    cin >> N;

    vector<int> H(N,0);

    for(int i=0;i<N;i++){
        cin >> num;
        H[i] = num;
    }

    int maxnum = 0;
    int count = 0;
    for(int i=0;i<N;i++){
        if(H[i] >= maxnum){
            maxnum = H[i];
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n,K;
    scanf("%d%d", &n, &K);
    vector<int> a(n);
    int i;
    int cnt = 0;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    int ans = INF;
    int k=lower_bound(a.begin(), a.end(), 0) - a.begin();
    if (n - k >= K && k+K-1>=0) {
        ans = MIN(ans, a[k + K - 1]);
    }
    if (k-K>=0 && k-K<n) {
        ans = MIN(ans, -a[k - K]);
    }
    for (i = 1; i <= MIN(k, K); i++) {
        int j = K - i;
        if (j > 0 && k+j-1<n) {
            int tmp0 = -a[k - i];
            int tmp1 = a[k + j - 1];
            ans = MIN(ans, tmp0 + tmp1 + MIN(tmp0, tmp1));
        }
    }
    printf("%d\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 640
N = int(input())
K = int(input())
x = list(map(int,input().split()))
total = 0
for i in range (N):
  if x[i]<K/2:
    total += 2*x[i]
  elif x[i]>= K/2:
    total += 2*(K-x[i])
print(total)

Measured memory_bytes: 9072
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int dp[1'001][1'001];

void solve(const string& x, const string& y)
{
    irep(i, x.size()) irep(j, y.size())
    {
        if (i == 0 || j == 0) {
            dp[i][j] = 0;
        } else {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (x[i - 1] == y[j - 1]) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
            }
        }
    }
    cout << dp[x.size()][y.size()] << endl;
}

int main()
{
    int n;
    cin >> n;
    rep(i, n)
    {
        string x, y;
        cin >> x >> y;
        solve(x, y);
    }
    return 0;
}


Measured memory_bytes: 7076
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n; cin >> n;
	ll a[n], b[n];
	for(ll i = 0; i < n; ++i) cin >> a[i] >> b[i];
	ll ans = 0;
	for(ll i = n - 1; i >= 0; --i){
		ll po = (a[i] + ans) / b[i];
		ll yo = (a[i] + ans) % b[i];
		if(yo) ans += b[i] * (po + 1) - (a[i] + ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

#define int long long

const int MAXN = 3010;
const int INF = 2e9;
const int mod = 998244353;

int n,ans,s,a[MAXN];
int l[MAXN];

signed main () {
	cin >> n >> s;
	for(register int i = 1;i <= n; ++i) 
		cin >> a[i];
	l[a[1]] = 1;
	for(register int i = 2;i <= n; ++i) {
		for(register int p = s - a[i];p >= 1; --p)
			if(l[p]) (l[p + a[i]] += l[p]) %= mod;
		(l[a[i]] += i) %= mod;
		if(l[s]) (ans += l[s]) %= mod;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int n, m;
    while (cin >> n >> m) {
        if (n == 0) break;
        vector<int> a(n);
        for (int i=0; i<n; ++i) cin >> a[i];

        int mx = 0;
        for (int i=0; i<n; ++i) {
            for (int j=i+1; j<n; ++j) {
                if (a[i] + a[j] > mx && a[i] + a[j] <= m) {
                    mx = a[i] + a[j];
                }
            }
        }
        if (mx == 0) {
            cout << "NONE" << endl;
        } else {
            cout << mx << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3072
#B - Good Distance
import math
N,D = map(int,input().split())
X = []
for _ in range(N):
    Xi = list(map(int,input().split()))
    X.append(Xi)
count = 0
for i in range(N):
    for k in range(i+1,N):
        D_sqrt = 0
        for j in range(D):
            D_sqrt += (X[i][j] - X[k][j])**2
        D_ans = math.sqrt(D_sqrt)
        if D_ans.is_integer():#float型が整数か判定するメソッド
            count += 1
print(count)

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

struct t_node{
    int x;
    t_node *prev;
    t_node *next;
};

int main(){
    t_node *head=NULL, *tail=NULL;
    char in[16];
    int n;
    cin >> n;
    while(n--){
        cin >> in;
        if( in[0] == 'i' ){
            int k;
            cin >> k;
//            t_node *newNode = new t_node;
			t_node *newNode = (t_node*)malloc(sizeof(t_node));
			newNode->x = k;
            if(head==NULL){
                head = newNode;
                head->prev = head->next = NULL;
            }else{
                newNode->next = head;
                newNode->prev = NULL;
                head->prev = newNode;
                head = newNode;
            }
            if(tail==NULL)  tail = newNode;
        }else if( in[6] == 'F' ){
            t_node *del = head;
            if(head==tail)  tail = NULL;
            head = head->next;
			if(head!=NULL)  head->prev = NULL;
//			delete del;
            free(del);
        }else if( in[6] == 'L' ){
            t_node *del = tail;
            if(tail==head)  head = NULL;
            tail = tail->prev;
			if(tail!=NULL)  tail->next = NULL;
//			delete del;
            free(del);
        }else{
			int k;
            cin >> k;
            t_node *cur = head;
            while( cur!=NULL ){
                if( cur->x == k ){
                    if( cur->prev!=NULL )
                        cur->prev->next = cur->next;
                    if( cur->next!=NULL )
                        cur->next->prev = cur->prev;
                    if(cur==head)   head = cur->next;
                    if(cur==tail)   tail = cur->prev;
					//                    delete cur;
					free(cur);
                    break;
                }
                cur = cur->next;
			}
		}
    }
	if(head!=NULL){
		cout << head->x;
		head = head->next;
	}
    while(head!=NULL){
        t_node *cur = head;
        head = head->next;
        cout << " " << cur->x;
//        delete cur;
		free(cur);
    }
	cout << endl;
    return 0;
}

Measured memory_bytes: 32444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N;
    cin >> N;
    vector<vector<int>> G(N,vector<int>(N));
    rep(i,N) rep(j,N) cin >> G[i][j];
    vector<ll> dp(1<<N,0);
    dp[0]=1;
    rep(i,N){
        rep(bit,1<<N){
            if (i!=__builtin_popcount(bit)) continue;
            rep(j,N){
                if (G[i][j]==1&&!(bit&(1<<j))){
                    dp[bit|1<<j]+=dp[bit];
                    dp[bit|1<<j]%=MOD;
                }
            }
        }
    }
    cout << dp[(1<<N)-1] << endl;
}

Measured memory_bytes: 16640
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		int N = nextInt();
		ArrayList<Integer> tmp = nextIntArray();
		int[] list = new int[N];
		for(int i = 0; i < N; i++){
			list[i] = tmp.get(i);
		}
		for(int i = N - 1; i > 0; i--){
			if(list[i - 1] > list[i]){
				list[i - 1]--;
				if(list[i - 1] > list[i]){
					myout("No");
					return;
				}
			}
		}
		myout("Yes");
	}
	//Method addition frame start




	//Method addition frame end
}


Measured memory_bytes: 50888
//
//  main.cpp
//  C- Vacation
//  Category: Dynamic Programming
//  Created by dz2701 on 8/25/20.
//  Copyright © 2020 dz2701. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5+1;

int N, dp[MAX][4], activity[MAX][4];
//dp[i][j] = ith row, choose j --> max happiness (j: 1~3);

int main(){
    cin >> N;
    for(int i=1;i<=N;i++)for(int j=1;j<=3;j++)cin >> activity[i][j];
    //init dp
    for(int i=1;i<=3;i++){
        dp[1][i] = activity[1][i];
    }
    for(int i=2;i<=N;i++){
        dp[i][1] = max(dp[i-1][2]+activity[i][1], dp[i-1][3]+activity[i][1]);
        dp[i][2] = max(dp[i-1][1]+activity[i][2], dp[i-1][3]+activity[i][2]);
        dp[i][3] = max(dp[i-1][1]+activity[i][3], dp[i-1][2]+activity[i][3]);
    }
    cout << max(max(dp[N][1],dp[N][2]),dp[N][3]);
    return 0;
}


Measured memory_bytes: 6692
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


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

  string S;
  cin >> S;

  ll N = S.length();
  vector<ll> dp(N+1); // dp[i] = sum of patterns after S[i]
  dp[N]=0;

  ll sum = 0;
  for(ll i=N;i>0;i--){
    for(ll j=N;j>i;j--){
      dp[i] += atoll(S.substr(i,j-i).c_str()) * max((ll)1, (ll)pow(2, N-j-1)) + dp[j];
    }
    sum += atoll(S.substr(0,i).c_str()) * max((ll)1, (ll)pow(2, N-i-1)) + dp[i];
  }

  cout << sum << "\n";
  return 0;
}


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

Measured memory_bytes: 580
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 9999999999
#define N 300003
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , r;
int main(){
fcin;
	cin>>n>>r;
	if(n>=10) cout<<r<<endl;
	else cout<<100*(10-n)+r<<endl;

}

Measured memory_bytes: 256
"use strict";

/**
 * Resolves problem.
 * @param  {string} input
 * @returns {string}
 */
var main = function(input) {
    return parseInt(input) < 1000 ? "ABC" : "ABD";
};

const output = main(require("fs").readFileSync("/dev/stdin", "utf8"));
console.log(output); // console.log outputs with trailing new line!


Measured memory_bytes: 21956
#include <stdio.h>

int main(void)
{	
	int ami[31], n, i, copy, a, b, w;
	scanf("%d", &w);
	for (i = 0; i < w; i++){
		ami[i] = i + 1;
	}
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d%*c%d", &a, &b);
		copy = ami [b - 1];
		ami [b - 1] = ami[a - 1];
		ami[a - 1] = copy;
	}
	for (i = 0; i < w; i++){
		printf("%d\n", ami[i]);
	}
	return (0);
}

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

using namespace std;
typedef long long ll;

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

    int l = s.length();

    if (s.find("AC") != string::npos) {
        cout << "Yes" << endl;
    } else {

        cout << "No" << endl;
    }
}

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

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

int main(){
	long N,A,B;
	cin >> N >> A >> B;

	long out = (N-2) * (B-A) +1;
	if(out < 0) out = 0;

	cout << out << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define float double
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vc = vector<char>; using vvc = vector<vc>;
using vf = vector<float>; using vvf = vector<vf>; using vd = vector<double>; using vvd = vector<vd>;
using str = string; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pff = pair<float, float>; using pdd = pair<double, double>;
using psl = pair<string, ll>; using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7; static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline int ord(char c) {return (int)c;}
static inline char chr(int n) {return (char)n;}
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int max_cnt(IN(vector<pii>) tasks) {
    var tks = tasks;
    int N = tks.size();
    sort(all(tks), [](IN(pii) left, IN(pii) right){
        return left.second < right.second;});
    int cnt = 1;
    int t = tks[0].second;
    for(int i = 1; i<N; i++) {
        if (t <= tks[i].first) {
            t = tks[i].second;
            cnt += 1;
        }
    }
    return cnt;
}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    int N,M; cin>>N>>M;
    vi A(M),B(M); REP(i,M)cin>>A[i]>>B[i];

    vector<pii> bgs;
    REP(i,M)
        bgs.emplace_back(mkpr(A[i], B[i]));

    int ans = max_cnt(bgs);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 5104
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int numOfObs=scan.nextInt();
        int numOfRoad=scan.nextInt();
        ArrayList<Integer> obsHeights=new ArrayList<>();
        for (int i = 0; i <numOfObs ; i++) {
            obsHeights.add(scan.nextInt());
        }
        boolean[] badObs=new boolean[numOfObs];
        for (int i = 0; i <numOfRoad ; i++) {
            int a=scan.nextInt()-1;
            int b=scan.nextInt()-1;
            if (obsHeights.get(a)<obsHeights.get(b)){
                badObs[a]=true;
            }else if(obsHeights.get(a)>obsHeights.get(b)){
                badObs[b]=true;
            }else{
                badObs[a]=true;
                badObs[b]=true;
            }
        }
        int count=0;
        for (int i = 0; i <numOfObs; i++) {
            if (!badObs[i]){
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 62236
#include <bits/stdc++.h>
using namespace std; 
#define ll long long 
#define pll pair<ll,ll> 

int main() {
  ll H, W; 
  cin >> H >> W; 
  ll h, w;
  cin >> h >> w; 
  cout << ((H * W) - (H * w) - (h * W) + (w * h)); 
}

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LONG_LONG_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main() {
    int n, k;
    cin >> n >> k;
    int count = 0;
    while(n > k -1) {
        n /= k;
        count++;
    }
    cout << count + 1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

ll f(ll b, ll n){
  return (n<b) ? n : f(b, n/b)+n%b;
}

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

  ll n, s;
  cin >> n >> s;
  
  if (n==s){
    cout << n+1 << "\n";
    return 0;
  }

  REP3(b,2,sqrt(n)+1){
    if (f(b,n)==s){
      cout << b << "\n";
      return 0;
    }
  }
  
  ll res = INF;
  REP3(p,1,sqrt(n)){
    ll b = (n-s)/p+1;
    if (b<2) continue;
    if (f(b,n)==s){
      res = min(b, res);
    }
  } 
  
  cout << ((res==INF) ? -1 : res)<< "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> A(N + 1);
  rep(i, N)
  {
    cin >> A[i];
  }

  rep(i, min(K, 100))
  {
    vector<int> temp(N + 1);
    rep(j, N)
    {
      int left = max(0, j - A[j]);
      int right = min(N - 1, j + A[j]);
      temp[left]++;
      temp[right + 1]--;
    }

    rep(j, N)
    {
      temp[j + 1] += temp[j];
    }
    A = temp;
  }

  rep(i, N)
  {
    cout << A[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4836
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

s = sInLH()
n = int(s[0] + s[1])

if int(math.sqrt(n)) ** 2 == n:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 62548
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define int long long
using namespace std;

signed main()
{
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());

    int ansi, ansj, ans = -1;
    int j = 0;
    for (int i = 0; i < n; i++)
    {
        while (j < n && 2 * a[j] <= a[i]) j++;

        int s = a[i], k = a[j];

        if (j != n && i != j)
        {
            if (ans < k*(s - k))
            {
                ans = k*(s - k);
                ansi = i;
                ansj = j;
            }
        }
        if (j != 0 && i != j - 1)
        {
            k = a[j - 1];
            if (ans < k*(s - k))
            {
                ans = k*(s - k);
                ansi = i;
                ansj = j - 1;
            }
        }
    }
    cout << a[ansi] << ' ' << a[ansj];
    return 0;
}


Measured memory_bytes: 1024
x,n=map(int,input().split())
p=list(map(int,input().split()))
t1=x
t2=x
while True:
  if t1 in p:
    t1=t1-1
  else:
    print(t1)
    break
  if t2 in p:
    t2=t2+1
  else:
    print(t2)
    break

Measured memory_bytes: 9184
inf = float('inf')

N,K = map(int,input().split())
ans = inf
X = []
Y = []
XY = []
for _ in range(N):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(y)
    XY.append((x,y))

X = sorted(X)
Y = sorted(Y)

for i in range(N):
    for j in range(i+1,N):
        for k in range(N):
            for l in range(k+1,N):
                cnt = 0
                for x, y in XY:
                    if X[i] <= x <= X[j] and Y[k] <= y <= Y[l]:
                        cnt += 1
                if cnt < K: continue
                S = (Y[l]-Y[k])*(X[j]-X[i])
                if S < ans:
                    ans = S

print(ans)

Measured memory_bytes: 48476
odd = list(map(str, input()))
even = list(map(str, input()))
if len(odd)==len(even):
  L=len(odd)*2
else:
  L=len(odd)+len(even)
li=[]

for i in range(1,L+1):
  if i%2==1:
    if i==1:
      li.append(odd[0])
    else:
      li.append(odd[i//2])
  else:
    li.append(even[i//2-1])
    
print(''.join(li))

Measured memory_bytes: 8980
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    int n;
    cin>>n;
    n=n%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9)
    cout<<"hon";
    else if(n==3)
    cout<<"bon";
    else cout<<"pon";
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
	char s[8];
	int i,flag=1;
	scanf("%s",s);
	for(i=0;i<strlen(s)-1;i++)
	{
		if(s[i]=='A'&&s[i+1]=='C')
		{
			cout<<"Yes"<<endl; 
			flag=0;
			break;
		}
	}
	if(flag) cout<<"No"<<endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define nl "\n"
#define pb push_back
#define sp " "
typedef long long ll;
#define len(x) x.length()
#define vsort(x) sort(x.begin(), x.end();
using namespace std;
ll inf=2e18;

int main()

{

    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("bruh.txt","r",stdin);
    #endif
    int k,n;
    cin >> k >> n;
    ll temp, a,mx=0;
    cin >>temp;
    ll bru=temp;
    n--;
    while(n--){
        cin>>a;
        mx=max(mx,abs(temp-a));
        temp=a;
    }
   //cout<<bru <<sp<<temp<<nl;
    mx=max(mx,abs(k-temp)+bru);
    cout<<k-mx<<nl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

#define MAX_V 100005

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>


int V;
vector<edge> G[MAX_V];
int d[MAX_V];
int d2[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}



int main(){
  int u, v;
  cin >> V >> u >> v;
  u--; v--;
  rep(i, V-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    edge e = {b, 1};
    edge e2 = {a, 1};
    G[a].push_back(e);
    G[b].push_back(e2);
  }
  dijkstra(u);
  swap(d, d2);
  dijkstra(v);
  int ans=0;
  rep(i, V){
    if(d[i]>d2[i]){
      ans=max(ans, d[i]);
    }
  }
  ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11176
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

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

  int ans;
  if (N%2 == 0) ans = N/2;
  else ans = N/2+1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;

// ユークリッドの互除法
LL extgcd(LL a, LL b, LL& x, LL& y)
{
	LL g = a; x = 1; y = 0;
	if (b != 0)
	{
		g = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	return g;
}

// 逆元
LL mod_inverse(LL a, LL m)
{
	LL x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

// 階乗
std::vector<LL>fact;
void mod_fact(LL n, LL m)
{
	fact.resize(n + 1);
	fact[0] = 1;
	for (LL i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i % m;
}

// nCk mod p
LL mod_comb(LL n, LL k, LL m)
{
	if (n < k) return 0;
	return fact[n] * mod_inverse(fact[k] * fact[n - k] % m, m) % m;
}

int main()
{
	LL N, M, K;
	in >> N >> M >> K;

	LL ans = 0;
	mod_fact(N * M, mod);
	rep(i, M) (ans += (((i * (M - i)) % mod * N) % mod * N) % mod) %= mod;
	rep(i, N) (ans += (((i * (N - i)) % mod * M) % mod * M) % mod) %= mod;
	(ans *= mod_comb(N * M - 2, K - 2, mod)) %= mod;

	out << ans << std::endl;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll a, p;cin >> a >> p;
	p += a * 3;
	cout << p / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int n = S.Count(c => c == 'N');
		int e = S.Count(c => c == 'E');
		int w = S.Count(c => c == 'W');
		int s = S.Count(c => c == 'S');
		
		bool chk = true;
		if(n > 0 && s == 0) chk = false;
		if(e > 0 && w == 0) chk = false;
		if(w > 0 && e == 0) chk = false;
		if(s > 0 && n == 0) chk = false;
		
		Console.WriteLine(chk ? "Yes" : "No");
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
N,M=map(int,input().split())
a= [int(input()) for i in range(M)]
d=[None]*(N+1)
for i in range(M):
    d[a[i]]=0
d[0]=1
if d[1]!=0:
    d[1]=1
for i in range(2,N+1):
    if d[i]!=0:
        d[i]=(d[i-1]+d[i-2])%1000000007
print(d[N])

Measured memory_bytes: 50136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int first[][] = new int[10][10];
		for (int i=1;i<=N;i++) {
			int temp =i ;
			while (temp>=10) {
				temp/=10;
			}
			first[temp][i%10]++;
		}
		long count =0;
		for (int i=1;i<10;i++) {
			for (int j=1;j<10;j++) {
				count += first[i][j]*first[j][i];
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35668
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

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

   // boolの初期値はfalse
   // x+1個falseで初期化して,
   // b**pをそのままindexとして用いる.
   vector<bool> expo(x+1);
   expo[1] = 1;
   for(int b = 2; b <= x; b++){
      int v = b*b;   // b**2
      while(v <= x){
         expo[v] = 1;
         v *= b;     // b**(2,3,4,...,n)
      }
   }
   for(int i = x; i >= 1; i--){
      if(expo[i]){
         cout << i << endl;
         return 0;
      }
   }
   return 0;
}

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

int main() {
  long L, R;
  std::cin >> L >> R;

  const unsigned long R_max = R;
  const unsigned long R_min = std::max(R - 2019, L + 1);
  const unsigned long L_max = std::min(L + 2019, R - 1);
  const unsigned long L_min = L;

  unsigned long min_val = 2019;

  for (unsigned long r = R_min; r <= R_max; ++r) {
    for (unsigned long l = L_min; l <= L_max; ++l) {
      min_val = std::min((r * l) % 2019, min_val);
      if (min_val == 0) {
        std::cout << 0 << std::endl;
        return 0;
      }
    }
  }
  std::cout << min_val << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int n;
string s;
int fl[100005], fr[100005], res[100005];

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> s;
    n = s.size();
    for (int i = 0; i < n; i++){
        if (s[i] == 'R') fr[i] = i;
        else fr[i] = fr[i - 1];
    }
    for (int i = n - 1; i >= 0; i--){
        if (s[i] == 'L') fl[i] = i;
        else fl[i] = fl[i + 1];
    }
    for (int i = 0; i < n; i++){
        if (s[i] == 'R'){
            if ((fl[i] - i) % 2 == 0) res[fl[i]]++;
            else res[fl[i] - 1]++;
        }else{
            if ((i - fr[i]) % 2 == 0) res[fr[i]]++;
            else res[fr[i] + 1]++;
        }
    }
    for (int i = 0; i < n; i++) cout << res[i] << ' ';
    return 0;
}


Measured memory_bytes: 1872
yesOrNo :: [Integer] -> [Char]
yesOrNo [w,h,x,y,r]
  | (x - r) < 0 = "No"
  | (x + r) > w = "No"
  | (y - r) < 0 = "No"
  | (y + r) > h = "No"
  | otherwise   = "Yes"

main :: IO ()
main = do
  s <- getLine
  putStrLn $ (yesOrNo . map read . words) s

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



int main() {

  int N, K; cin >> N >> K;
  int x[N];
  rep(i,N) cin >> x[i];
  int ans = 0;
  rep(i,N){
    int A = x[i] * 2;
    int B = abs(x[i] - K) * 2;
    ans+= min(A,B);
  }
  cout << ans << endl;




  return 0;
}








Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
const int maxn=200010;
struct At{
	char c;
	At* next;
	At* last;
}	c[maxn];
int main(){
	string s;
	cin>>s;
	//
	int size=s.size();
	c[0]={s[0],&c[1],NULL};
	for(int i=1;i<size-1;i++){
		c[i]={s[i],&c[i+1],&c[i-1]};
	}
	c[size-1]={s[size-1],NULL,&c[size-2]};
	//
	int t=maxn;
	At* x=&c[0];
	while(t--){
		int update=0;
		for(At* i=x;i->next!=NULL;i=i->next){
			if(i->c=='S'&&i->next->c=='T'){
				if(i->last!=NULL){
					x=i->last;
					x->next=i->next->next;
					if(i->next->next!=NULL)
						i->next->next->last=x;
				}
				else{
					x=i->next->next;
					if(i->next->next!=NULL)
						i->next->next->last=NULL;
				}
				size-=2;
				update=1;
				break;
			}
		}
		if(!update||size==0||x==NULL)
			break;
	}
	cout<<size<<endl;
	return 0;
}

Measured memory_bytes: 5244