akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

	while(sc.hasNext()){
	    String[] a_number = sc.nextLine().split(" ");
	    String[] b_number = sc.nextLine().split(" ");

	    int hit = 0;
	    int brow = 0;

	    for(int i = 0; i < 4; ++i)
		if(a_number[i].equals(b_number[i])){
		    ++hit;
		}

	    for(int i = 0; i < 4; ++i)
		for(int j = 0; j < 4; ++j)
		    if(i != j && a_number[i].equals(b_number[j])){
			++brow;
		    }

	    System.out.printf("%d %d\n", hit, brow);
	}
    }
}

Measured memory_bytes: 17328
#include <bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef long double ld;
using namespace std;

const int MAXN = 1000 * 1000, MOD = 1000 * 1000 * 1000 + 7;
ll dp[MAXN + 1], cur[10], n, res, s[MAXN + 1];

void gen(int t) {
    if(t == n + 2) {
        for(int i = 1; i <= n; i++) {
            map<int, int> cnt;
            for(int j = i + 1; j <= min(n + 1, i + cur[i]); j++)
                cnt[cur[j]]++;
            if(cnt.size() != 1)
                return;
        }
        if(cur[n] != cur[n + 1])
            return;
        for(int i = 1; i <= n + 1; i++)
            cout << cur[i] << " ";
        cout << "\n";
        res++;
    }
    else {
        for(int i = 1; i <= n; i++) {
            cur[t] = i;
            gen(t + 1);
        }
    }
}

void add(ll &x, ll y) {
    x += y;
    if(x >= MOD)
        x -= MOD;
}

int main() {
    //ios_base::sync_with_stdio(false)
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n;
    //gen(1);
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 1;
    s[0] = 1;
    s[1] = 2;
    s[2] = 3;
    //cout << res << "\n";
    for(int i = 3; i <= n; i++) {
        add(dp[i], dp[i - 1]);
        add(dp[i], s[i - 3]);
        add(s[i], s[i - 1]);
        add(s[i], dp[i]);
    }
    if(n == 1)
        cout << 1 << "\n";
    else {
        ll res = 0;
        for(int i = 0; i <= n - 2; i++) {
            add(res, dp[i] * (n - 1) % MOD * (n - 1) % MOD);
            add(res, dp[i] * (i + 1) % MOD);
        }
        add(res, dp[n - 1] * (n - 1) % MOD);
        add(res, dp[n]);
        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 15872
<?php
error_reporting(0);
//$N = explode(" ",trim(fgets(STDIN)));
$N = trim(fgets(STDIN));
//list($H,$W) = explode(" ",trim(fgets(STDIN)));
$S = explode(" ",trim(fgets(STDIN)));
if (in_array("Y",$S)) {
  printf("Four\n");
}
else {
  printf("Three\n");
}


Measured memory_bytes: 3828
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	vector<int> nums(n); fore(e, nums) cin >> e;
	int sm = accumulate(nums.begin(), nums.end(), 0);
	int cord = sm/n+1, cord2 = sm/n;
	int ans = 0, ans2 = 0;
	fore(e, nums) {
		ans += abs(e-cord)*abs(e-cord);
		ans2 += abs(e-cord2)*abs(e-cord2);
	}
	println(min(ans, ans2));
}


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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if(a == b){
         cout << "1" << endl;
         return 0;
    }
    if(n == 1 || a > b){
        cout << "0" << endl;
        return 0;
    }
    ll ans = (n-2)*(b-a)+1;
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php 
  
  //zの数を数える。
  //はじめにでたaからカウントして行ってすべてのzをだしきった時点でカウントを終了
fscanf(STDIN,"%s",$s);
$len=strlen($s);
$j=$len-1;
$first=true;
$first2=true;

for($i=0;$i<$len;$i++){
 if($s[$i]=='A'&&$first){
   $a_first=$i;
   $first=false;
     // echo $a_first."\n";

 }
 if($s[$j]=='Z'&&$first2){
   $z_last=$j;
   $first2=false;
   //echo $z_last."\n";
 }
  $j--;
}

echo ($z_last-$a_first+1)."\n";

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 1e4;

void solve() {
  int n; cin >> n;
  int res = 0;
  for (int a = 1; a < n; a++) {
    for (int b = 1; a * b < n; b++) {
      res++;
    }
  }
  cout << res;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(2);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 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 main() {
	string s, t;
	ll a, b;
	string u;
	cin >> s >> t >> a >> b >> u;

	if (s == u) {
		a--;
	} else {
		b--;
	}

	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,W;
ll w[101],v[101];
ll dp[101][301][101];
int main(){
    cin>>N>>W;
    for(ll i=0;i<N;i++)cin>>w[i]>>v[i];
    dp[0][0][0]=0;
    for(ll i=0;i<N;i++){
        for(ll j=0;j<=3*N;j++){
            for(ll k=0;k<=i;k++){
                dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
                if(j+w[i]-w[0]>3*N)continue;
                dp[i+1][j+w[i]-w[0]][k+1]=max(dp[i+1][j+w[i]-w[0]][k+1],dp[i][j][k]+v[i]);
            }
        }
    }
    ll ans=0;
    for(ll k=0;k<=N;k++){
        for(ll i=0;i<=3*N;i++){
            for(ll j=0;j<=N;j++){
                if(j*w[0]+i>W)continue;
                ans=max(ans,dp[k][i][j]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 24064
def FindSumOfDigits(n):
    s = 0
    while n > 0:
        s = s + n % 10
        n = n // 10       
    return s

inp = list(map(int,input().split()))
N = inp[0]
A = inp[1]
B = inp[2]
l=list()

sd = 0
for i in range(N+1):
    x = FindSumOfDigits(i)
    if A <= x <= B:
        sd = sd + i
    
print(sd)

Measured memory_bytes: 73084
n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
res = sum(bl)
for i in range(n-1):
    if al[i] == al[i+1]-1:
        res += cl[al[i]-1]
print(res)

Measured memory_bytes: 3064
A=int(input())  #500
B=int(input())  #100
C=int(input())  #50
X=int(input())

count=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k==X:
                count+=1

print(count) 

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
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; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
	vector< pair<ll, ll> > p;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;
		p.push_back(make_pair(i, 0));
		while((n % i) == 0) {
			n /= i;
			p[i].second += 1;
		}
		p.push_back(make_pair(n, 0));
	}

	if (n != 1) p.push_back(make_pair(n, 1));
	return p;
}

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

	vector<int> A(N, 0);
	int total = 0;
	repeat(i, N) {
		int a;
		cin >> a;
		A[i] = a;
		total += a;
	}

	double border = (double)1 / (4 * M);
	int count = 0;
	repeat(i, N) {
		double p = (double)A[i]/total;
		if (p >= border) {
			count++;
		}
	}

	cout << ((count >= M) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
int n, m;

int main(){
	int i, j;
	string s;
	cin >> n;
	cin >> s;
	ll ans=0, c=0;
	for(i=1;i<n;i++){
		map<char,bool> a;
		map<char,bool> b;
		c=0;
		for(j=0;j<i;j++){
			a[s[j]] = true;
		}for(j=i;j<n;j++){
			if(a[s[j]] && !b[s[j]])c++;
			b[s[j]] = true;
		}ans = max(c, ans);
	}cout << ans;
}


Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main()
{
	int awal,index,nilai,org;
	index=0;
	cin>>awal;
	org=awal+1;
	int arr[org];
	for (int i=1;i<=awal;i++) {
		cin>>nilai;
		arr[i]=nilai;
	}
	arr[org]=arr[1];
	for (int j=1;j<=awal;j++) {
		if (arr[j]>=arr[org]) {
			index++;
			arr[org]=arr[j];
		}
	}
	cout<<index<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    V<int> a(n);
    bool x = false;
    rep(i, n) {
        char c;
        cin >> c;
        a[i] = c - '1';
        if(a[i] == 1) x = true;
    }
    int sum[n + 1] = {};
    rep(i, 30) {
        int k = 1 << i;
        for(int j = 0; j < n; j += k)
            chmax<int>(sum[j], i);
    }
    rep(i, n) sum[i + 1] += sum[i];
    if(x) {
        int ans = 0;
        rep(i, n) {
            if(a[i] == 1 && sum[n - 1] - sum[n - 1 - i] == sum[i] - sum[0])
                ans ^= 1;
        }
        cout << ans << endl;
    } else {
        int ans = 0;
        rep(i, n) {
            if(a[i] == 2 && sum[n - 1] - sum[n - 1 - i] == sum[i] - sum[0])
                ans ^= 2;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 8064
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import statistics
import string


def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

a,b = splitintinput()
g = hcfnaive(a,b)
print(int(a*b/g))

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

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main(){
	int a[5]; rep(i, 5) cin >> a[i];
	sort(a, a + 5);
	cout << a[4] << ' ' << a[3] << ' ' << a[2] << ' ' << a[1] << ' ' << a[0] <<endl;
	
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    ll ans = (ll)N * (N-1) / 2;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

  int n;
  cin>>n;
  
  cout<<(n*(n+1))/2;
  
    
    
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    string s;
    cin >> s;
    int p[4];
    rep(i,4) p[i] = stoi(s.substr(i,1));

    rep(i,2)
        rep(j,2)
            rep(k,2)
            {
                int sum = p[0]+p[1]*(2*i-1)+p[2]*(2*j-1)+p[3]*(2*k-1);
                if(sum==7)
                {
                    printf("%d%s%d%s%d%s%d=7\n",
                        p[0],(i==0 ?"-":"+"),
                        p[1],(j==0 ?"-":"+"),
                        p[2],(k==0 ?"-":"+"),
                        p[3]);
                    return 0;
                }
            }

    return 0;
}

Measured memory_bytes: 256
///in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    string s[n];
    set<string>se;
    set<string>:: iterator it;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        se.insert(s[i]);

    }
    sort(s,s+n);
    ll a=0,b=0,c=0,d=0;
    for(it=se.begin();it!=se.end();it++)
    {
        int l=lower_bound(s,s+n,*it)-s;
        int u=upper_bound(s,s+n,*it)-s;
        //cout<<*it<<  " "<<u-l<<" "<<u<<" "<<l<<endl;
        if(*it=="AC")
            a=u-l;
        else if(*it=="WA")
            b=u-l;
        else if(*it=="TLE")
            c=u-l;
        else if(*it=="RE")
            d=u-l;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;

}



Measured memory_bytes: 6728
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>

using namespace std;


int main() {

    int K, S;
    cin >> K >> S;

    int count = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {


            if (((S - (x + y)) >= 0) and ((S - (x + y)) <= K)) {
                count += 1;
            }

        }
    }

    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>


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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll n; cin >> n;
	string s;
	ll t = 0;
	for (ll i = 1; i * (i + 1) / 2 < n; i++) {
		chmax(t, i);
	}
	s += ")(";
	for (int i = 0; i < t; i++) s += ')';
	for (int i = 0; i < t; i++) s += '(';
	for (int i = 1; i <= n - t * (t + 1) / 2 - 1; i++) {
		swap(s[i], s[i + 1]);
	}
	cout << s << endl;
}



Measured memory_bytes: 3376
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

signed main()
{
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	int a = D - C;

	if (A > B)
	{
		int temp = A;
		A = B;
		B = temp;
	}

	for (int i = 0; i <= N; i += 2)
	{
		int p = i;
		int o = N - p - 1;

		int r = i / 2 * a;
		int b1 = B - r;
		int b2 = B + r;

		int min = A + o * C;
		int max = A + o * D;

		if (B >= min && b1 <= max)
		{
			cout << "YES" << endl;
			return 0;
		}

		if (b2 >= min && B <= max)
		{
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;
}

Measured memory_bytes: 384
import math


def main():
    N, M = map(int, input().split())
    rt = int(math.sqrt(M))
    div = []
    for i in range(1, rt+1):
        if M % i == 0:
            div.append(i)
            if i ** 2 != M:
                div.append(M//i)
    ans = 1
    for d in div:
        if d * N <= M:
            ans = max(ans, d)
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int deg[MAXN];

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		deg[x]++;
		deg[y]++;
	}
	for(int i = 1; i <= n; i++)
		if (deg[i] & 1){
			puts("NO");
			return; 
		}
	puts("YES");
}

void printans(){

}

int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

Measured memory_bytes: 640
import itertools
import math
N = int(input())
As =list(map(int,input().split(" ")))
odds = 0
two = 0
four = 0
nums = []
for a in As:
    if a % 2 == 1:
        odds += 1
    elif a % 4 == 0:
        four += 1
    else:
        two += 1
if odds > 0:
    nums.append(1)
    odds -= 1
elif two > 0:
    nums.append(2)
    two -=1
else:
    nums.append(4)
    four-=1
ans = "Yes"

if N==2:
    if As[0] * As[1]%4 !=0:
       ans = "No"
else:
    for i in range(1,N):
        if nums[i-1] == 1:
            if four > 0:
                nums.append(4)
                four -=1
            else:
                ans = "No"
                break
        elif nums[i - 1] == 2:
            if two> 0:
                nums.append(2)
                two -= 1
            elif four > 0:
                nums.append(4)
                four -=1
            else:
                ans = "No"
                break
        elif nums[i - 1] == 4:
            if odds> 0:
                nums.append(1)
                odds -= 1
            elif two> 0:
                nums.append(2)
                two -= 1
            elif four > 0:
                nums.append(4)
                four -=1

print(ans)

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

using namespace std;

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		int num;
		cin >> num;
		vector<int> Vec;
		while(num)
		{
			Vec.push_back(num % 10);
			num /= 10;
		}
		sort(Vec.begin(), Vec.end());
		int max = 0, min = 0;
		for(int i = Vec.size() - 1; i >= 0; --i)
		{
			max *= 10;
			max += Vec[i];
		}
		for(int i = 0; i < Vec.size(); ++i)
		{
			min *= 10;
			min += Vec[i];
		}
		cout << max - min << endl;
	}
}

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

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

int main() {
    int n, sum;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int ans = 1e9+7;
    for(int i=-100; i<=100; i++){
        int sum = 0;
        for(int j=0; j<n; j++){
            sum += pow((a[j] - i), 2);
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> L(M), R(M);
  for (int i = 0; i < M; i++) {
  	cin >> L.at(i) >> R.at(i);
  }
  int L_max = 0, R_min = 100000;
  for (int i = 0; i < M; i++) {
  	if (L_max < L.at(i)) {
      L_max = L.at(i);
    }
    if (R_min > R.at(i)) {
      R_min = R.at(i);
    }
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
  	if (i + 1 >= L_max && i + 1 <= R_min) {
      count++;
    }
  }
  cout << count << endl;
}


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

using namespace std;

#define MAX 32
#define INF (1<<29)
typedef pair<int, int> pii;

int H, W, S, sum;
int u[MAX][MAX];
pii memo[MAX][MAX][MAX][MAX];

int get_cost(int h1, int w1, int h2, int w2)
{
    int cost = 0;
    for (int i = h1; i <= h2; i++) {
        for (int j = w1; j <= w2; j++) {
            cost += u[i][j];
        }
    }
    return cost;
}

pii solve(int h1, int w1, int h2, int w2)    
{
    pii res = memo[h1][w1][h2][w2];
    if (res.first != -1) {
        return res;
    }
    
    res = pii(1, S - (sum - get_cost(h1, w1, h2, w2)));
    for (int i = h1; i <= h2-1; i++) {
        int c1 = get_cost(h1, w1, i, w2);
        int c2 = get_cost(i+1, w1, h2, w2);
        
        if (sum - c1 <= S && sum - c2 <= S) {
            pii n1 = solve(h1, w1, i, w2);
            pii n2 = solve(i+1, w1, h2, w2);
            pii n = pii(n1.first + n2.first, min(n1.second, n2.second));
            res = max(res, n);
        }        
    }

    for (int i = w1; i <= w2-1; i++) {
        int c1 = get_cost(h1, w1, h2, i);
        int c2 = get_cost(h1, i+1, h2, w2);
        
        if (sum - c1 <= S && sum - c2 <= S) {
            pii n1 = solve(h1, w1, h2, i);
            pii n2 = solve(h1, i+1, h2, w2);
            pii n = pii(n1.first + n2.first, min(n1.second, n2.second));
            res = max(res, n);
        } 
    }
    return memo[h1][w1][h2][w2] = res;
}

int main()
{
    while (cin >> H >> W >> S, H) {
        sum = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> u[i][j];
                sum += u[i][j];
                for (int k = 0; k < H; k++) {
                    for (int l = 0; l < W; l++) {
                        memo[i][j][k][l] = pii(-1, -1);
                    }
                }
            }
        }
        
        pii res = solve(0, 0, H-1, W-1);
        cout << res.first << " " << res.second << endl;
    }    
    return 0;
}

Measured memory_bytes: 11288
a['~~'],j,s;main(i){for(;++i<98;)for(j=i;j<1e4;a[j+=i]=1);for(;~scanf("%d",&i);s=!printf("%d\n",s))for(j=i;--j>1;)s+=!a[j]&!a[i-j+1];}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int N;
int A[110];

void show(){
	for(int i=1;i<=N;i++){
		if(i!=N) cout << A[i]  << " ";
		else cout << A[i] << endl;
	}
}
int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> A[i];
	}
	for(int i=1;i<=N;i++){
		int v = A[i];
		int j = i-1;
		while(j>=0 && A[j]>v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		show();
	}
}


Measured memory_bytes: 3076
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,M = mint()
if N==M==1:
    print(1)
else:
    print(abs(N-2)*abs(M-2))

Measured memory_bytes: 65572
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int main(){
 
    int n;
    double m;
 
    cin >> n >> m;
 
    vector<double> a_(n);

int num = 0;
double a_total = 0.0;
 
    rep(i, n) {
        cin >> a_[i];
        a_total += a_[i];
    }

    double m_4 = a_total / 4 / m;

        rep(i, n) {
         if(a_[i] >= m_4) num++;
    }

   
    int m_ = (int)(m);
 
    if(num >= m_) cout << "Yes";
    else cout << "No";
 
 
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int t,count=0;
string n;
cin>>t>>n;
for(int i=0;i<t-2;i++)
{
    if(n[i]=='A'&&n[i+1]=='B'&&n[i+2]=='C')
        count++;
}
cout<<count<<endl;
return 0;
}

Measured memory_bytes: 256
// C - ID

// 座標圧縮の考え方による解法

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int P[100000];
int Y[100000];
map<int, vector<int>> Y_list;

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

	for (int i=0; i<M; i++) {
		cin >> P[i] >> Y[i];
		Y_list[P[i]].push_back(Y[i]);
	}

	for (auto& itr : Y_list) {
		sort(itr.second.begin(), itr.second.end());
	}

	vector<string> ans(M);

	for (int i=0; i<M; i++) {
		int I = lower_bound(Y_list[P[i]].begin(), Y_list[P[i]].end(), Y[i]) - Y_list[P[i]].begin();
		char P_formatted[10], I_formatted[10];
		sprintf(P_formatted, "%06d", P[i]);
		sprintf(I_formatted, "%06d", I + 1);
		ans[i] = (string)P_formatted + (string)I_formatted;
	}

	for (string a : ans) {
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 18016
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(n);
    string ans = "No";
    for(int i=0;i<n;i++){
        string x;
        cin >> x;
        a[i] = x;
    }
    for(int i=0;i<m;i++){
        string x;
        cin >> x;
        b[i] = x;
    }
    for(int i=0;i<n-m+1;i++){
        for(int j=0;j<n-m+1;j++){
            bool flag = true;
            for(int k=0;k<m;k++){
                for(int p=0;p<m;p++){
                    if(a[i+k][j+p]!=b[k][p]){
                        flag = false;
                    }
    }
        
    }
    if(flag ==true){
        ans ="Yes";
        break;
    }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, K, Q = list(map(int, input().split()))
A = [int(input()) for _ in range(Q)]

l = [0] * N
for a in A:
    l[a - 1] += 1

y = Q - K
for x in l:
    if  x > y:
        print("Yes")
    else:
        print("No")

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<61)

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

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int X, t;
  cin >> X >> t;
  cout << (X - t >= 0 ? X - t : 0) << endl;
  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  fio();
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  rep (i, n - 2) {
    if (s.substr(i, 3) == "ABC") cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
def main():
    N, W = map(int, input().split())
    wv = {0: 0}
    for _ in range(N):
        w, v = map(int, input().split())
        kw = sorted(list(wv.keys()), reverse=True)
        for k in kw:
            if k + w not in wv:
                wv[k + w] = wv[k] + v
            else:
                wv[k + w] = max(wv[k + w], wv[k] + v)
    kw = sorted(list(wv.keys()))
    ans = 0
    for k in kw:
        if k > W:
            break
        ans = max(ans, wv[k])
    print(ans)


main()


Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <algorithm>
int main(){
  long long n; std::cin >> n;
  
  std::string answer;
  while (n > 0) {
    int amari = n % 26;
    
    if (amari != 0) {
      answer += char('a' + amari - 1);
      n /= 26;
      continue;
    }
    answer += 'z';
    n /= 26;
    --n;
  }
  std::reverse(answer.begin(), answer.end());
  std::cout << answer << std::endl;
}

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

using namespace std;

const int N = 100010;

int cnt[N];

int main() {
  int n;
  scanf("%d", &n);
  memset(cnt, 0, sizeof cnt);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int foo;
    scanf("%d", &foo);
    if (foo >= N) {
      ++ans;
    } else {
      ++cnt[foo];
    }
  }
  for (int i = 0; i < N; ++i) {
    ans += cnt[i];
    if (cnt[i] >= i) {
      ans -= i;
    }
  }
  printf("%d\n", ans);
}


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

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

    for(int i = max(x - k + 1, -1000000); i < min(x + k, 1000001); i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int a,b;
    FOR(i,0,s.size()-1){
        if (s[i]=='A'){
            a = i;
            break;
        }
    }
    RFOR(i,s.size()-1,0){
        if (s[i]=='Z'){
            b = i;
            break;
        }
    }
    cout<<b-a+1<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<int>>;

vector<int> A;
vector<ll> a, b, c, d;
int N, M, Q;
vector<ll> ans;


//列Aのスコアを計算

ll score (vector<int> &A) {

	ll res = 0;
	for (int i = 0; i < Q; i++) {
		if (A[b[i] - 1] - A[a[i] - 1] == c[i]) res += d[i];
	}
	return res;
}
//Aを生成し、各Aについてスコアをansに突っ込む

void dfs(vector<int> &A, int add) {
	if (A.size() == N) {
      	ans.push_back(score(A));
      return;
    }

	for (int i = add; i <= M; i++) {
		A.push_back(i);
		dfs(A, i);
		A.pop_back();
	}
}

int main() {
	cin >> N >> M >> Q;
	a.resize(Q);
	b.resize(Q);
	c.resize(Q);
	d.resize(Q);

	for (int i = 0; i < Q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	

	dfs(A, 1);
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());

	cout << ans[0] << endl;
	
}

Measured memory_bytes: 4140
n = int(input())
lis = [input() for _ in range(n)]

ans = []

for i in "abcdefghijklmnopqrstuvwxyz":
    mn = 50
    for j in lis:
        mn = min(mn,j.count(i))

    ans.append(i*mn)
    
print(''.join(ans))  

Measured memory_bytes: 2940
# https://atcoder.jp/contests/abc138/tasks/abc138_d

import sys
input = sys.stdin.readline
from copy import deepcopy


class Graph:
    def __init__(self, n, dictated=False, decrement=True, edge=[]):
        self.n = n
        self.dictated = dictated
        self.decrement = decrement
        self.edge = [set() for _ in range(self.n)]
        self.parent = [-1]*self.n
        self.info = [-1]*self.n
        for x, y in edge:
            self.add_edge(x,y)

    def add_edge(self, x, y):
        if self.decrement:
            x -= 1
            y -= 1
        self.edge[x].add(y)
        if self.dictated == False:
            self.edge[y].add(x)

    def add_adjacent_list(self, i, adjacent_list):
        if self.decrement:
            self.edge[i] = set(map(lambda x:x-1, adjacent_list))
        else:
            self.edge[i] = set(adjacent_list)

    def dfs2(self, info, start, goal=-1, time=0, save=False):
        """
        :param info: 各頂点の付加情報
        :param start: スタート地点
        :param goal: ゴール地点
        :param save: True = 前回の探索結果を保持する
        :return: ゴール地点までの距離。存在しなければ -1
        """

        if self.decrement:
            start -= 1
            goal -= 1
        if not save:
            self.parent = [-1] * self.n

        edge2 = deepcopy(self.edge)

        p, t = start, time
        self.parent[p] = -2
        while True:
            if edge2[p]:
                q = edge2[p].pop()
                if q == self.parent[p] and not self.dictated:
                    """ 逆流した時の処理 """
                    """"""""""""""""""""
                    continue
                if self.parent[q] != -1:
                    """ サイクルで同一点を訪れた時の処理 """
                    """"""""""""""""""""
                    continue
                if q == goal:
                    """ ゴール時の処理"""
                    # return t + 1
                    """"""""""""""""""""
                    continue
                """ p から q への引継ぎ"""
                info[q] += info[p]
                """"""""""""""""""""
                self.parent[q] = p
                p, t = q, t + 1
            else:
                """ 探索完了時の処理 """
                """"""""""""""""""""
                if p == start and t == time:
                    break
                p, t = self.parent[p], t-1
                """ 二度目に訪問時の処理 """

                """"""""""""""""""""
        return info


######################################################################################################

N, Q = map(int, input().split())  # N:頂点数, Q: クエリの数
M = N-1

graph = Graph(N, dictated=False)

for _ in range(M):
    x, y = map(int, input().split())
    graph.add_edge(x,y)

info = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    info[p - 1] += x

print(*graph.dfs2(info, start=1))


Measured memory_bytes: 282652
use std::io;
use std::collections::HashSet;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let n = buf.trim().parse::<usize>().unwrap();
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let s = buf.as_str();
    let mut pos = 0;
    let mut max = 0;
    for i in 0..n {
        let pre: HashSet<_> = s[0..i].chars().collect();
        let post: HashSet<_> = s[i..].chars().collect();
        let ovr = pre.intersection(&post).count();
        if max < ovr {
            pos = i;
            max = ovr;
        }
    }
    println!("{}", max);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  vector<string> a(h);
  for(int i=0;i<h;i++)
    cin>>a.at(i);
  vector<vector<int>> dp(h+1,vector<int>(w+1,0));
  dp[0][1]=1;
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++)
      dp[i][j]=(a.at(i-1).at(j-1)=='.'?dp[i-1][j]+dp[i][j-1]:0)%1000000007;
  cout<<dp[h][w]<<endl;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N;
  cin>>N;
  
  vector<ll>B(N-1);
  vector<ll>b(N);
 
  
  rep(i,N-1){
    cin>>B[i];
  }
  if(N==2){
    cout<<2*B[0]<<endl;
  }
else{
  
   b[0]=B[0];
  
  
 for(ll i=1;i<N-1;i++){
    
      b[i]=min(B[i],B[i-1]);
    
  }
ll ans=0;
  rep(i,N-1){
    ans+=b[i];
  }

  cout<<ans+B[N-2]<<endl;
}
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var d int
	fmt.Scan(&d)

	if d == 25 {
		fmt.Println("Christmas")
	} else if d == 24 {
		fmt.Println("Christmas Eve")
	} else if d == 23 {
		fmt.Println("Christmas Eve Eve")
	} else {
		fmt.Println("Christmas Eve Eve Eve")
	}
}


Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

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

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for(auto& val: A)
    std::cin >> val;
  std::unordered_map<int, int> m;
  long long ans = 0;
  for(int i = 0; i < A.size(); ++i)
  {
    auto it = m.find(i - A[i]);
    if(it != m.end())
    {
      ans += it->second;
    }
    m[i + A[i]]++;
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 12076
import java.util.Scanner;
public class Main{
	int x;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		x=sc.nextInt();
		System.out.println(x*x*x);
	}
	
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17156
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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--)
#define mp make_pair
#define fi first
#define sc second
ll n;
ll m;
ll cou[200000];
int main(){
	cin >> n >> m;

	REP(i,m) {
		ll a,b;
		cin >> a >> b;
		cou[a - 1]++;
		cou[b - 1]++;
	}

	REP(i,n)
		if(cou[i] % 2 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MAX 100000
using namespace std;
int main(){
    
    int n,v;
    cin>>n;
    
    int v1[MAX + 1] = {};
    int v2[MAX + 1] = {};
    
    for(int i=0;i<n;i++){
        
        cin>>v;
        
        if(i%2 == 1){
            v1[v]++;
        }
        else{
            v2[v]++;
        }
    }
    
    int v1tmp,v2tmp;
    int mx1=0,mx2=0;
    
    for(int i=0;i<MAX + 1;i++){
        if(v1[i]>mx1){
            mx1=v1[i];
            v1tmp=i;
        }
        if(v2[i]>mx2){
            mx2=v2[i];
            v2tmp=i;
        }
    }
    
    sort(v1,v1+MAX+1);
    reverse(v1,v1+MAX+1);
    sort(v2,v2+MAX+1);
    reverse(v2,v2+MAX+1);
    
    if(v1tmp==v2tmp) cout<<n-max(v1[0]+v2[1],v1[1]+v2[0])<<endl;
    
    else cout<<n-v1[0]-v2[0]<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include<iomanip>
using namespace std;

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

int main()
{
   string S;
   cin>>S;
   int size = S.size();
   int count = 0;
   rep(i,size)
   {
       if(i >= size -i)break;
       if(S[i]!=S[size-i-1])count++;
   }
   cout<<count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(b-(2*a)<0) cout<<"No\n";
    else if((b-(2*a))%2!=0) cout<<"No\n";
    else if(a- ((b-(2*a))/2)<0 ) cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}


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

int main() {
    int n;
    cin>>n;
    int a[n];
    map<long long int,long long int> m;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    long long int sum=0;
    for(auto itr = m.begin(); itr != m.end(); ++itr)
    {
        sum += ((itr->second*(itr->second-1))/2);
    }
    for(int i=0;i<n;i++)
    cout<<(sum-(m[a[i]]-1))<<endl;
    fflush(stdout);
}

Measured memory_bytes: 11920
while True:
    try:
        N, M = map(int, input().split())
        
        K = []
        S = []
        for _ in range(M):
            k, *s = map(int, input().split())
            K.append(k)
            S.append(list(map(lambda x:x-1, s)))
        
        p = list(map(int, input().split()))
        ans = 0
        # N switches have 2**N combinations of "on"/"off" state
        for i in range(1<<N):
            flag = True
            for j in range(M):
                cnt = 0
                for k in S[j]:
                    if (i >> k) & 1:
                        cnt += 1
                if cnt%2 != p[j]:
                    flag = False
                    break
            if flag:
                ans += 1
                
        print(ans)
    except:
        break

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int n,m;
    

    scanf("%d", &n);
    
    m = n % 10;
    if (m == 3) 
        printf("bon\n");
    else  if (m == 0 || m == 1|| m == 6|| m == 8)
        printf("pon\n");
    else
        printf("hon\n");

    return 0;
}

Measured memory_bytes: 1660
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP((i),0,(n))
#define ALL(v) (v).begin(),(v).end()

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int p1 = n * a;
	if (p1 < b)cout << p1 << endl;
	else cout << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N, M, Q; cin >> N >> M >> Q;
    vector<string> S(N); for (auto &s : S) cin >> s;
    vector<vector<int>> V(N+1, vector<int>(M+1)), Ex(N, vector<int>(M+1)), Ey(N+1, vector<int>(M));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            V[i+1][j+1] = V[i][j+1] + V[i+1][j] - V[i][j] + (S[i][j] == '1');
        }
    }
    for (int i = 0; i < N-1; i++) {
        for (int j = 0; j < M; j++) {
            Ex[i+1][j+1] = Ex[i][j+1] + Ex[i+1][j] - Ex[i][j] + (S[i][j] == '1' && S[i+1][j] == '1');
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M-1; j++) {
            Ey[i+1][j+1] = Ey[i][j+1] + Ey[i+1][j] - Ey[i][j] + (S[i][j] == '1' && S[i][j+1] == '1');
        }
    }
    for (int i = 0; i < Q; i++) {
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        x1--, y1--;
        int v = V[x2][y2] - V[x2][y1] - V[x1][y2] + V[x1][y1];
        int ex = Ex[x2-1][y2] - Ex[x2-1][y1] - Ex[x1][y2] + Ex[x1][y1];
        int ey = Ey[x2][y2-1] - Ey[x2][y1] - Ey[x1][y2-1] + Ey[x1][y1];
        cout << v - ex - ey << '\n';
    }
    return 0;
}

Measured memory_bytes: 52992
S = list(input())
before = int(S[0] + S[1])
after = int(S[2] + S[3])

if before == 0 or before > 12:
    if after >= 1 and after <= 12:
        print('YYMM')
    else:
        print('NA')
else:
    if after >= 1 and after <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')

Measured memory_bytes: 3060