akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define de(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(int i=(a); i<(b); i++)
//-----
int n;
int main() {
	scanf("%d", &n);
	if(n/100==n%10)puts("Yes");
	else puts("No");
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//







int main(){

        priority_queue<P> que;

        int n,m;
        cin >> n >> m;
        vector<ll> a(n);
        for(int i = 0; i < n; i++){
                cin >> a[i];
                que.push(make_pair(a[i],1));
        }

        vector<ll> b(m), c(m);
        for(int i = 0; i < m; i++){
                cin >> b[i] >> c[i];
                que.push(make_pair(c[i],b[i]));
        }

        ll sumsize = 0;;
        ll ans = 0;
        while(sumsize < n){
                auto p = que.top();
                que.pop();

                ans += p.first;
                p.second--;
                sumsize++;

                if(p.second > 0){
                        que.push(p);
                }
        }

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



















Measured memory_bytes: 8688
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath> 
using namespace std;
int main(int argc, char *argv[])
{
	int n;
	cin>>n;
	int a[n+5],b[n+5];
	for(int i=0;i<n;i++)
	{cin>>a[i];b[i]=a[i];}
	sort(a,a+n);
	int t=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[i])
			t++;
		if(t>2)
			break;
	}
	if(t>2)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	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 all(x) (x).begin(),(x).end()
typedef long long ll;
int wareru(int a){
    int cnt = 0;
    while(a%100==0){
        cnt++;
        a/=100;
    }
    return cnt;
}

int main(){
    int d,n;
    cin >> d >> n;
    int cnt = 0;
    int a = 0;
    while(cnt!=n){
        a++;
        if(wareru(a)==d){
            cnt++;
        }
        
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int sum;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    for(int j=i+1;j<s.size();j++){
      if(s[i]==s[j])sum++;
    }
  }
  if(sum==0)cout<<"yes";
  else cout<<"no";
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
	int n, k, x[50], y[50], _x[50], _y[50];
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i];
		_x[i] = x[i];
		_y[i] = y[i];
	}

	sort(_x, _x+n); sort(_y, _y+n);

	ll area = 1ll*(_x[n-1]-_x[0])*(_y[n-1]-_y[0]);
	//cout<<area<<endl;
	for(int xi=0;xi<n;xi++){
		for(int xj=0;xj<n;xj++){
			for(int yi=0;yi<n;yi++){
				for(int yj=0;yj<n;yj++){

					int cnt=0;

					ll lx = _x[xi], rx = _x[xj],
					   by = _y[yi], uy = _y[yj];

					for(int i=0;i<n;i++){
						if(lx<=x[i]&&x[i]<=rx&&by<=y[i]&&uy>=y[i])
							cnt++;
					}
					if(cnt>=k)
						area = min(area, 1ll*(rx-lx)*(uy-by));
				}
			}
		}

	}
	cout<<area<<endl;
}


Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

n = int(input())
k = int(input())
x = int(input())
y = int(input())

temp = n - k

if (temp >= 0):
    print(x*k + temp*y)
else:
    print(x*n)



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

using namespace std;

int main(){
    int n;
    float total=0;
    cin >>n;
    float a[n];
    for (int ia=0;ia<n;ia++){
        cin >>a[ia];
        total= total+1/a[ia];
    }

    cout << 1/total <<endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int search(int A[], int n, int key) {

   int i = 0;
   A[n] = key;

   while (A[i] != key) i++;
   return i != n;
}

int main() {
   int i, n, A[10000+1], q, key, sum = 0;

   scanf("%d", &n);
   for(i = 0;i < n; i++)
   scanf("%d", &A[i]);

   scanf("%d", &q);
   for (i = 0;i < q; i++) {
    scanf ("%d", &key);
    if (search(A, n, key)) sum++;
   }

    printf("%d\n", sum);
    return  0;
}

Measured memory_bytes: 636
import itertools

def check(honest_people):
	ans = True
	for i in honest_people:
		for x, y in shogen[i]:
			if (y == 1 and x not in honest_people) or (y == 0 and x in honest_people):
				ans = False
	return ans

if __name__ == "__main__":
	N = int(input())
	shogen = []
	for i in range(N):
		A = int(input())
		shogen_i = []
		for i in range(A):
			x, y = map(int, input().split())
			shogen_i.append((x - 1, y))
		shogen.append(shogen_i)

	seq = [i for i in range(N)]
	for i in range(0, N + 1):
		comb = list(itertools.combinations(seq, i))
		for honest_people in comb:
			if check(list(honest_people)):
				ans = i
	print(ans)

Measured memory_bytes: 5364
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        ab: [(i64, i64); n],
    }

    let x = ab.iter().max().unwrap();

    println!("{}", x.0 + x.1);
}


Measured memory_bytes: 5452
a,b,c=map(int,input().split())
k=int(input())


d=a//b//2


if not b*2**d>a:
    d+=1
b=b*2**d

e=b//c//2
if not c*2**e>b:
    e+=1

if k>=d+e:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
int main() {
    int H, W, K; cin >> H >> W >> K;
    Int a = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c; cin >> c;
            if (c == '#') a |= (1LL << (i * W + j));
        }
    }
    auto display = [&](Int x) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (x & (1LL << (i * W + j))) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << '\n';
        }
    };
    vector<Int> row(1 << H), col(1 << W);
    for (int i = 0; i < (1 << H); i++) {
        for (int j = 0; j < H; j++) {
            for (int k = 0; k < W; k++) {
                if (i & (1 << j)) {
                    row[i] |= (1LL << (j * W + k));
                }
            }
        }
    }
    for (int i = 0; i < (1 << W); i++) {
        for (int j = 0; j < H; j++) {
            for (int k = 0; k < W; k++) {
                if (i & (1 << k)) {
                    col[i] |= (1LL << (j * W + k));
                }
            }
        }
    }
    int cnt = 0;
    for (int i = 0; i < (1 << H); i++) {
        for (int j = 0; j < (1 << W); j++) {
            Int b = a & ~row[i] & ~col[j];
            if (__builtin_popcountll(b) == K) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    long double left = sqrtl((long double)(a * b));
    long double right = (long double)(c - a - b) / (long double)2;

    string ans = left < right ? "Yes" : "No";

    cout << ans << endl;
}


Measured memory_bytes: 256
//Name: Property Distribution
//Level: 2
//Category: 塗りつぶし,幅優先探索,BFS
//Note: 

/**
 *
 */
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

template<typename T, typename U>
int paint(vector<T> &g, int sr, int sc, U nullv) {
    static const int DR[] = {0, -1, 0, 1};
    static const int DC[] = {1, 0, -1, 0};
    const int H = g.size();
    const int W = g[0].size();
    queue<pair<int,int>> q;

    const auto target = g[sr][sc];
    q.push(make_pair(sr, sc));
    g[sr][sc] = nullv;
    int cnt = 1;
    while(!q.empty()) {
        const int r = q.front().first;
        const int c = q.front().second;
        q.pop();
        for(int d = 0; d < 4; ++d) {
            const int nr = r + DR[d];
            const int nc = c + DC[d];
            if(nr < 0 || nr >= H || nc < 0 || nc >= W) continue;
            if(g[nr][nc] != target) continue;
            g[nr][nc] = nullv;
            q.push(make_pair(nr, nc));
            ++cnt;
        }
    }
    return cnt;
}

bool solve() {
    int H, W;
    if(!(cin >> H >> W)) return false;
    if(!H && !W) return false;

    vector<string> field(H);
    for(int r = 0; r < H; ++r) {
        cin >> field[r];
    }
    int ans = 0;
    for(int r = 0; r < H; ++r) {
        for(int c = 0; c < W; ++c) {
            if(field[r][c] != '.') {
                paint(field, r, c, '.');
                ++ans;
            }
        }
    }
    cout << ans << endl;

    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<vector>
#include<string>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;

int main() {
	string s;
	cin >> s;
	int N = 0;
	int S = 0;
	int W = 0;
	int E = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'N')N++;
		if (s[i] == 'S')S++;
		if (s[i] == 'W')W++;
		if (s[i] == 'E')E++;
	}
	if (N + S > 0 && N*S == 0) {
		cout << "No" << endl;
		return 0;
	}
	if (W + E > 0 && W*E == 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;

}

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

using namespace std;

int main(void) {
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    if(accumulate(A.begin(), A.end(), 0) >= H) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,x;
int a[110];
ll sum=0;
int ans=0;

int main(){
	cin>>n>>x;
	REP(i,n)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n-1;i++){
		sum+=(ll)a[i];
		if(sum<=x){
			ans++;
		}
	}
	if(sum+a[n-1]==x)ans++;
	cout<<ans<<endl;
	return 0;
}

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

void showMe(int *a, size_t size)
{
    for (size_t i = 0; i < size; ++i)
    {
        cout << (i == 0 ? "" : " ") << a[i];
    }
    cout << endl;
}

int doSelectionSort(int *a, size_t size)
{
    int num_of_swap = 0;
    size_t minj;
    for (size_t i = 0; i < size; ++i)
    {
        minj = i;
        for (size_t j = i; j < size; ++j)
        {
            if (a[j] < a[minj])
                minj = j;
        }
        if (i != minj)
        {
            swap(a[i], a[minj]);
            ++num_of_swap;
        }
    }
    return num_of_swap;
}

int main()
{
    int a[100] = {};
    size_t size;
    cin >> size;
    for (size_t i = 0; i < size; ++i)
    {
        cin >> a[i];
    }

    int numOfSwap = doSelectionSort(a, size);
    showMe(a, size);
    cout << numOfSwap << endl;

    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define endl '\n'
using namespace std;
const int N=1e5+1;


int32_t main()
 {
 ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
int n; cin>>n; int A[n];
for(int i=0;i<n;i++){cin>>A[i];} int ct=0;
for(int i=0;i<n;i++)
{
    for(int j=i;j<n;j++)
    {
        for(int k=j;k<n;k++)
        {
          int a,b,c;
          a=A[i],b=A[j],c=A[k];
          if((a!=b && b!=c && c!=a)&&((a+b>c)&&(b+c>a)&&(a+c>b)) ){ct++;}
        }
    }
}
cout<<ct;
 }


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int d = std.nextInt();
        StringBuilder ans = new StringBuilder("Christmas");
        int diff = 25 - d;
        for (int i = 0; i < diff; i++) {
            ans.append(" Eve");
        }

        System.out.println(ans.toString());
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int n, k;
ll H[100200];
ll mem[100200];
ll dp(int at){
    if(at >= n){
        return 10000000000;
    }
    if(at == n-1) return 0;
    if(mem[at] != -1) return mem[at];
    ll ans = 10000000000;
    rep(i,1,k+1){
        ans = min(ans, abs(H[at]-H[at+i])+dp(at+i));
    }
    return mem[at] = ans;
}

int main()
{
    cin.sync_with_stdio(false);
    memset(mem, -1, sizeof(mem));
    rep(i,0,100200) H[i] = -10000000000;
    cin >> n >> k;
    rep(i,0,n) cin >> H[i];
    cout << dp(0) << endl;
    return 0;
}


Measured memory_bytes: 6528
package main

import (
	"fmt"
	"strings"
)

func main() {
	var str1 string
	var str2 string
	fmt.Scanf("%s", &str1)
	fmt.Scanf("%s", &str2)

	str2 = str2[:len(str2)-1]
	result := strings.Compare(str1, str2)
	if result == 0 {
		fmt.Printf("Yes")
	} else {
		fmt.Printf("No")
	}
}

Measured memory_bytes: 1820
#include<stdio.h>
#include<ctype.h>
int main(){
	char a[1200];
	int i;
	while(1){
		scanf("%c",&a[i]);
		if(a[i]=='\n'){
			printf("\n");
			break;
		}
		if(isupper(a[i])){
			printf("%c",tolower(a[i]));
		}
		else if(islower(a[i])){
			printf("%c",toupper(a[i]));
		}
		else{
			printf("%c",a[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 2596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;
	cin>>s;
	rep(i,3){
		if(s[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cmath>
#include <iomanip>

int main(){
 int A,B,H,M;
 std::cin>>A>>B>>H>>M;
 int mintime=H*60+M;
 //double angleA=2*;
 //double angleB;
 double ans=sqrt(A*A+B*B-2*A*B*cos(2*M_PI*(12*M-mintime)/(12*60)));
 std::cout<<std::fixed << std::setprecision(10)<<ans<<std::endl;

}

Measured memory_bytes: 4240
#include<bits/stdc++.h>
#define ll long long
#define ljc 998244353
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
int n,K,ans,a[1010101],dep[1010101];
vector<int> e[1010101];
int dfs(int u){
	int mx=dep[u];
	for (auto v:e[u]){
		dep[v]=dep[u]+1;
		mx=max(mx,dfs(v));
	}
	int dis=mx-dep[u]+(u!=1);
	if (dis>=K&&a[u]!=1) ans++,mx=-1;
	return mx;
}
signed main(){
	n=read(),K=read();
	for (int i=1;i<=n;i++) a[i]=read();
	if (a[1]!=1) a[1]=1,ans++;
	for (int i=2;i<=n;i++) e[a[i]].push_back(i);
	dfs(1);
	cout<<ans;
	return 0;
}



Measured memory_bytes: 37516
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll n;
vll p;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    p.resize(n);
    vll pidx(n + 1);
    for (ll i = 0; i < n; i++) {
        cin >> p[i];
        pidx[p[i]] = i;
    }

    ll ans = 0;
    multiset<ll> iset;
    iset.insert(n); iset.insert(n); iset.insert(-1); iset.insert(-1);
    for (ll i = n; i >= 1; i--) {
        ll pi = pidx[i];
        auto it = iset.lower_bound(pi);
        ll r1max = *it;
        it++;
        ll r2max = *it;
        it--, it--;
        ll l1max = *it;
        it--;
        ll l2max = *it;
        ll cnt = (l1max - l2max) * (r1max - pi) + (r2max - r1max) * (pi - l1max);
        // cout << l2max << ' ' << l1max << ' ' << r1max << ' ' << r2max << '\n';
        // cout << i << ' ' << cnt << '\n';
        ans += i * cnt;
        iset.insert(pi);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <iomanip>
#include <climits>
#include <string>
#include <sstream>
#include <numeric>
#include <stack>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	int A, B;
	cin >> N >> A >> B;
	int ans = N / (A + B) * A + min(N % (A + B), A);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>N) {
		ll v = 1LL;
		ll sign=1;
		string ans;
		REP(loop, 40) {
			if(N&v) {
//				DD(N);
				N-=sign*v;
//				DD(N);
//				DD(v);
//				DD(sign);
				ans.PB('1');
			} else {
				ans.PB('0');
			}
			v<<=1;
			sign*=-1;
		}
		reverse(ALL(ans));
		string a;
		bool one=0;
		REP(i, ans.size()) {
			if(ans[i]=='1') one=1;
			if(one) a.PB(ans[i]);
		}
		if(!a.size()) a.PB('0');
		
		cout<<a<<endl;
//		break;
	}
	
	return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = a; i >= (b); --i)
#define trav(a, x) for(auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n; cin >> n;
  vi v(n);
  rep(i,0,n) cin >> v[i];

  vi dp(n,0);
  for (int i = 1; i < n; i++) {
    dp[i] = dp[i - 1] + abs(v[i] - v[i-1]);
    if (i > 1)
      dp[i] = min(dp[i - 2] + abs(v[i] - v[i - 2]), dp[i]);
  }
  cout << dp[n - 1];
}

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

using namespace std;

long long a[3];
int main()
{
	cin >> a[0] >> a[1] >> a[2];
	sort (a , a + 3);
	if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0)
	{ 
		cout << 0;
	}
	else
	{
		cout << a[0] * a[1];
	}
	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  
  int b1,b2;
  b1=b-(b%a);
  b2=b1/a;
  if(b2<c){
   printf("%d\n",b2); 
  }else{
   printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	dir := 0
	c := 1
	for len(A) > 1 {
		if A[0] == A[1] {
			A = A[1:]
			continue
		}
		if A[0] < A[1] {
			if dir == 0 || dir == 1 {
				dir = 1
				A = A[1:]
			} else {
				dir = 0
				c++
				A = A[1:]
			}
			continue
		}
		if A[0] > A[1] {
			if dir == 0 || dir == -1 {
				dir = -1
				A = A[1:]
			} else {
				dir = 0
				c++
				A = A[1:]
			}
			continue
		}
	}
	fmt.Println(c)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

#define NIL -1
#define MAX 10000

struct Node{
    int left, right, parent;
};

Node T[MAX];
void preparse(int u){
    if(u == NIL){
        return;
    }
    cout << " " << u;
    preparse(T[u].left);
    preparse(T[u].right);
}

void inparse(int u){
    if(u == NIL)return;
    inparse(T[u].left);
    cout << " " << u;
    inparse(T[u].right);
}

void postparse(int u){
    if(u == NIL)return;
    postparse(T[u].left);
    postparse(T[u].right);
    cout << " " << u;
}

int main(void){
    // Your code here!
    int n, a, b, c, root;
    cin >> n;
    for(int i = 0; i < n; i++){
        T[i].parent = NIL;
    }
    for(int i = 0; i < n; i++){
        cin >> a >> b >> c;
        T[a].left = b;
        T[a].right = c;
        if(b != NIL)T[b].parent = a;
        if(c != NIL)T[c].parent = a;
    }
    
    for(int i = 0; i < n; i++){
        if(T[i].parent == NIL)root = i;
    }
    
    cout << "Preorder" << endl;
    preparse(root);
    cout << endl;
    cout << "Inorder" << endl;
    inparse(root);
    cout << endl;
    cout << "Postorder" << endl;
    postparse(root);
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 3108
/*
[agc034] B - ABC
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

string s;
int N;

ll solve() {
    ll ans = 0;
    int cnt_a = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'A') {
            cnt_a++;
        } else if (i < N - 1 && s[i] == 'B' && s[i + 1] == 'C') {
            ans += cnt_a;
        } else if (i > 0 && s[i - 1] == 'B' && s[i] == 'C') {
        } else {
            cnt_a = 0;
        }
    }

    return ans;
}

int main() {
    cin >> s;
    N = s.length();

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 640
H,W=map(int,input().split())
c=[list(map(int,input().split())) for _ in [0]*10]
a=[list(map(int,input().split())) for _ in [0]*H]
def dp(i,j,l,lim):
    if lim<0:
        return 10**4
    else:
        return min([c[i][j]]+[c[i][k]+dp(k,j,l+[k],lim-c[i][k]) for k in range(10) if k not in l])
cc=[dp(i,1,[i,1],c[i][1]) for i in range(10)]
print(sum([cc[j] for i in a for j in i if j!=-1]))

Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int len = s.length();
        if (len < 3) {
            System.out.println(s);
        } else {
            System.out.print(s.charAt(0));
            System.out.print(len-2);
            System.out.print(s.charAt(len-1));
        }
    }
}

Measured memory_bytes: 22736
using System;

namespace ABC152C
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string[] str = Console.ReadLine().Split(' ');
			int[] p = new int[n];
			for (int i = 0; i < n; i++)
			{
				p[i] = int.Parse(str[i]);
			}
			int c = p[0];
			int ans = 0;
			for(int i = 0; i < n; i++)
			{
				if(c >= p[i])
				{
					ans++;
					c = p[i];
				}

			}
			Console.WriteLine(ans);
		}
		
	}
}

Measured memory_bytes: 33116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B___Common_Raccoon_vs_Monster
{
    class Program
    {
        static void Main(string[] args)
        {
            var ue = new List<string[]>();
            int H = 0;
            int N = 0;
           
            var up = Console.ReadLine();
            string[] arrup = up.Split(' ');
            H = int.Parse(arrup[0]);
            N = int.Parse(arrup[1]);

           
            var down = Console.ReadLine();
            int downcount = 0;
            string[] arrdown = down.Split(' ');
            //下の行の要素数をカウント
            downcount = arrdown.Length;
            int goukeiten = 0;
            for (int i = 0; i < downcount; i++)
            {
                goukeiten = goukeiten + int.Parse(arrdown[i]);
            }
            if (goukeiten >= H)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
          
        }
    }
}


Measured memory_bytes: 18144
#include<stdio.h>
int main(){
    char str[20];
    int n=0,x=0,t=0;
    fgets(str,20,stdin);
    sscanf(str,"%d %d %d",&n,&x,&t);
    if(n%x==0)printf("%d",n*t/x);
    else printf("%d",(n/x+1)*t);
    return 0;
}


Measured memory_bytes: 1688
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

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

odd = False
for i in range(len(A)):
    if A[i] < 0:
        A[i] *= -1
        odd = not odd

if odd:
    print(sum(A) - min(A) * 2)
else:
    print(sum(A))


Measured memory_bytes: 14224
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(l: f64);
    let l = l / 3.0;
    puts!("{}\n", l.powf(3.0));
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
n = int(input())
tasks = []
for _ in range(n):
    a, b = map(int, input().split())
    tasks.append([a, b])

tasks = sorted(tasks, key=lambda x: x[1])
time = 0
for task in tasks:
    time += task[0]
    if time > task[1]:
        print("No")
        exit()
print("Yes")

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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N+1);
  for (int i = 0; i < N; i++) cin >> A[i+1];
  
                             
  
  vector<int> perm;
  
  int last = N;
  for (int i = 1; i <= N; i++) {
    for (int j = last; j >= 1; j--) {
      
      // A[j] = j となる j を大きい方から探して見つかったらその要素を捨てる
      if (A[j] == j) {
        perm.push_back(j);
        A.erase(A.begin() + j);
        break;
      }
      
      // もし最後までA[j] = j となる j が見つからなかったら不可能
      if (j == 1) {
        cout << -1 << endl;
        return 0;
      }      
    }
    last--;
  }
  
  for (int i = N-1; i >= 0; i--) {
    cout << perm[i] << endl;
  }
  
                                      
  
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
using ulong=unsigned long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

bool solve(){
    int N,H,W;
    cin >> N>>W>>H;
    vi ximos(W+1,0),yimos(H+1,0);
    rep(i,N){
        int xi,yi,wi;
        cin >> xi>> yi>> wi;
        {
            int mm=max(0,xi-wi);
            int mx=min(W,xi+wi);
            ximos[mm]++;
            ximos[mx]--;
        }
        {
            int mm=max(0,yi-wi);
            int mx=min(H,yi+wi);
            yimos[mm]++;
            yimos[mx]--;
        }
    }
    auto cnt=0;
    bool rt=true;
    rep(i,W){
        cnt+=ximos[i];
        if(cnt<=0) rt=false;
    }
    cnt=0;
    rep(i,H){
        cnt+=yimos[i];
        if(cnt<=0 && !rt) return false;
    }
    return true;
}

int main(){
    out(solve()?"Yes":"No");
}



Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

ll gcd(ll a, ll b){
	if(b==0){
		return a;
	}else{
		return gcd(b, a%b);
	}
}

int main(void){
	ll a,b;
	cin>>a>>b;
	if((a+b)%2 == 1){
		cout<<"IMPOSSIBLE"<<endl;
	}else{
		cout<<(a+b)/2<<endl;
	}
	return 0;
}


Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int n, count=0;
  std::cin >> n;
  std::vector<int> num(n);
  for(int i=0;i<n;i++) std::cin >> num[i];
  for(int i=1;i<n-1;i++) {
    if(num[i]>num[i-1]&&num[i]<num[i+1]) count++;
    else if(num[i]<num[i-1]&&num[i]>num[i+1]) count++;
  }
  std::cout << count << '\n';
  return 0;
}


Measured memory_bytes: 888
// B

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N;
  cin>>N;
  for (int i(1);i<=N;i++){
    if ((int)(i*1.08) == N){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　　￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    string s;
    cin >> s;
    Yes(s[2] == s[3] && s[4] == s[5]);
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct node_t {
	int val;
	struct node_t *prev, *next;
} node;

node* new_node(int val) {
	static int it = 0;
	static node pool[500100];
	pool[it] = (node) { val, NULL, NULL };
	return &pool[it++];
}

int main(void)
{
	int q, com, x, cnt = 0;
	node *st = new_node(0), *it = st, *tmp;
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &com);
		if (com == 0) {
			scanf("%d", &x);
			tmp = new_node(x);
			if (it == st) st = tmp;
			tmp->next = it;
			tmp->prev = it->prev;
			if (it->prev) it->prev->next = tmp;
			it->prev = tmp;
			it = tmp;
			++cnt;
		}
		else if (com == 1) {
			scanf("%d", &x);
			if (x >= 0) {
				while (x--) it = it->next;
			}
			else {
				x = -x;
				while (x--) it = it->prev;
			}
		}
		else {
			tmp = it;
			it = it->next;
			if (tmp == st) st = it;
			if (tmp->prev) tmp->prev->next = it;
			it->prev = tmp->prev;
			--cnt;
		}
	}
	while (st->next) {
		printf("%d\n", st->val);
		st = st->next;
	}
	return 0;
}



Measured memory_bytes: 13428
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
#pragma endregion

void solve() {
    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;
    ll res = 1;
    bool two = false;
    int i = 0;
    if (s1.front() == s2.front()) {
        res = 3;
        i++;
    } else {
        res = 6;
        two = true;
        i += 2;
    }
    while (i < n) {
        if (s1.at(i) == s2.at(i)) {
            if (!two) {
                res *= 2;
                res %= MOD;
            }
            two = false;
            i++;
        } else {
            if (two) {
                res *= 3;
                res %= MOD;
            } else {
                res *= 2;
                res %= MOD;
            }
            two = true;
            i += 2;
        }
    }
    cout << res << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF (1 << 30) - 1 + (1 << 30)
#define EPS 1.0e-6

using namespace std;

int n, q;
int mx[1050000];

int init(int n_)
{
	int k = 1;
	while (k < n_)k *= 2;
	for (int i = 0; i < 2 * k; i++) {
		mx[i] = (1 << 30) - 1 + (1 << 30);
	}
	return k;
}

void update(int ind, int val)
{
	ind += n;
	mx[ind] = val;
	ind /= 2;
	while (ind > 0) {
		int l = mx[2 * ind];
		int r = mx[2 * ind + 1];
		mx[ind] = min(l, r);
		ind /= 2;
	}
}

int find(int l, int r, int bottom = 0, int top = n, int node = 1)
{
	if (l <= bottom&&top <= r)return mx[node];
	if (top <= l || r <= bottom)return INF;

	int mid = (bottom + top) / 2;
	int lmx = find(l, r, bottom, mid, 2 * node);
	int rmx = find(l, r, mid, top, 2 * node + 1);

	return min(lmx, rmx);
}


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

	n=init(n);

	int k, x, y;
	for (int i = 0; i < q; i++) {
		cin >> k >> x >> y;
		if (k == 0)update(x, y);
		if (k == 1)cout<<find(x, y + 1,0,n,1)<<endl;
	}

	return 0;
}

Measured memory_bytes: 4088
#include<stdio.h>
int main(void){
	int W=0,H=0,x=0,y=0,r=0;

	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

	if(x+r>W || x+r<0)/** x+r>xまたは<0なら偽 **/{
		printf("No\n");
	}else if(x-r>W || x-r<0)/** x-r>xまたは<0なら偽 **/{
		printf("No\n");
	}else if(y+r>H||y+r<0)/**y+r>yまたは<0なら偽**/{
		printf("No\n");
	}else if(y-r>H||y+r<0)/**y-r<0または>yなら偽**/{
		printf("No\n");
	}else{
		printf("Yes\n");
	}

	//それ以外は真
}



Measured memory_bytes: 2104
use proconio::input;

#[proconio::fastout]
fn main() {
    input! {
        d: i32,
        c: [i32; 26],
        s: [[i32; 26]; d],
    }
    let mut satification = 0;
    let mut last: Vec<i32> = vec![0; 26];
    for i in 1..d+1 {
        let mut best_contest: usize = 1;
        let mut best_satification = -1_000_000_000;
        for t in 0..26 {
            let pre_last = last[t];
            last[t] = i;
            last[t as usize] = i as i32;
            let tmp_satification = {
                satification
                + s[(i-1) as usize][t as usize]
                - last.iter().zip(&c).map(|(l, c)| {c*(i as i32 - l)}).sum::<i32>()
            };
            last[t] = pre_last;
            if best_satification < tmp_satification {
                best_contest = t;
                best_satification = tmp_satification;
            }
        }
        satification = best_satification;
        last[best_contest] = i;
        println!("{}", best_contest+1);
    }
}


Measured memory_bytes: 2252
#include <stdio.h>
#include <stdlib.h>


int gcd(int a, int b)
{
    if (a == 0)
        return b;
    if (b == 0)
        return a;

    if (a == b)
        return a;

    if (a > b)
        return gcd(a - b, b);
    return gcd(a, b - a);
}

int main() {
    int i, j;

    scanf("%d %d", &i, &j);

    printf("%d\n", gcd(i, j));
    return 0;

}



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


Measured memory_bytes: 9192