akhauriyash/Code-Regression huggingface dataset:
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int n;
    lint sum = 0;
    cin >> n;
    FOR(i,1,n + 1){
        if(i % 3 == 0 || i % 5 == 0)
            continue;
        sum += i;
    }
    cout << sum << endl;
    return 0;
} 

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

int main() 
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c)
  {
    cout << 1 << endl;
  }
  else if (a != b && b != c && c != a)
  {
    cout << 3 << endl;
  }
  else
  {
    cout << 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        boolean hasZero = false;
        boolean isOver = false;
        long sum = 1;

        for (int i = 0; i < N; i++) {
            long A = scanner.nextLong();
            if (A == 0) {
                System.out.println("0");
                return;
            }

            try {
                sum = Math.multiplyExact(sum, A);
                if (sum > 1000000000000000000L) {
                    isOver = true;
                }
            } catch (ArithmeticException e) {
                isOver = true;
            }
        }

        System.out.println(isOver ? "-1" : sum);
    }
}




Measured memory_bytes: 48904
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mod 1000000007
using namespace std;
//const ll N=100005;
//ll fact[N];
//bool v[N];
ll power(ll x,ll n)
{
    ll res=1;
    while(n>0)
    {
        if(n%2) res=(x*res)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return res;
}
ll invmod(ll x)
{return power(x,mod-2);}
void solve()
{
    ll n,m,q,a,b,c,d,e,s,x;
    cin>>n;
    map<ll,ll> hm;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        hm[x]++;
    }
    if(n%2 && hm[0]!=1) cout<<"0\n";
    else
    {   bool f=0;
        ll cnt=0;
        for(auto y:hm)
        {if(y.first==0) continue;
            if(y.second!=2) f=1;
            else cnt++;}
        if(f) cout<<"0\n";
        else cout<<power(2,cnt)<<"\n";
    }
}
int main()
{
 speed_up;
 ll t=1;
/* fact[0]=1;
 for(ll i=1;i<N;i++) fact[i]=(fact[i-1]*i)%mod;*/
 //cin>>t;
 while(t--)
    solve();


}


Measured memory_bytes: 4224
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

cur = N
dp = list(range(cur + 1))
for i in range(cur + 1):
    if i >= As[0]:
        if dp[i] < dp[i - As[0]] + Bs[0]:
            dp[i] = dp[i - As[0]] + Bs[0]
    if i >= As[1]:
        if dp[i] < dp[i - As[1]] + Bs[1]:
            dp[i] = dp[i - As[1]] + Bs[1]
    if i >= As[2]:
        if dp[i] < dp[i - As[2]] + Bs[2]:
            dp[i] = dp[i - As[2]] + Bs[2]

cur = dp[cur]
dp = list(range(cur + 1))
As, Bs = Bs, As
for i in range(cur + 1):
    if i >= As[0]:
        if dp[i] < dp[i - As[0]] + Bs[0]:
            dp[i] = dp[i - As[0]] + Bs[0]
    if i >= As[1]:
        if dp[i] < dp[i - As[1]] + Bs[1]:
            dp[i] = dp[i - As[1]] + Bs[1]
    if i >= As[2]:
        if dp[i] < dp[i - As[2]] + Bs[2]:
            dp[i] = dp[i - As[2]] + Bs[2]


print(dp[cur])

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    string s, t;
    cin >> s;
    cin >> t;
    int count;
    REP(i, 3) {
        if(s[i] == t[i]) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let _n: usize = parse_line().unwrap();
    let a: Vec<usize> = parse_line().unwrap();
    let mut ans = 0;

    for mut ai in a {
        let mut cnt = 0;
        while ai % 2 == 0 {
            ai /= 2;
            cnt += 1;
        }
        ans += cnt;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2248
#include <stdio.h>


int main (void){
 
 int h=-1 , w=-1 , i , j;
 
 while(1){
     
     scanf("%d %d", &h, &w);
     if(h + w == 0) break;
     
     for(i=0; i < h; i++){
        
        if(i == 0 || i == h - 1){ 
            for(j=0; j < w; j++){
                printf("#"); 
            }
            puts("");
        }else{
            printf("#");
            for(j=0; j < w-2; j++){
                printf(".");
            }
            printf("#");
            puts("");
        }
        
     }
     
     puts("");
 }
 return 0;
 
}
 

Measured memory_bytes: 588
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll mod = 1000000007;
const ll Mod = 998244353;
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p = mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int n, a, b;
	cin >> n;
	if (n == 1) cout << "Hello World\n";
	else {
		cin >> a >> b;
		cout << a + b << endl;
	}
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s,t;
	cin >> s >> t;
	s+=s;
	Yes(s.find(t)!=string::npos);
	return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
int main(void){
	int h,w,n,a[100001];
	scanf("%d%d%d",&h,&w,&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	int c[h][w],count=0,ind=0;
	for(int i=0;i<h;i++){
		if(i%2==0){
			for(int j=0;j<w;j++){
				c[i][j]=(ind+1);
				count++;
				if(count==a[ind]){
					ind++;
					count=0;
				}
			}
		}else{
			for(int j=w-1;j>=0;j--){
				c[i][j]=(ind+1);
				count++;
				if(count==a[ind]){
					ind++;
					count=0;
				}
			}
		}
	}
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%d ",c[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#line 1 "main.cpp"

/**
 * @title Template
 */

#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>
#include <cassert>

#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/chmin_chmax.cpp"

template <class T, class U>
constexpr bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
constexpr bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

/**
 * @title Chmin/Chmax
 */
#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

#line 4 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

class range {
public:
  class iterator {
  private:
    int64_t M_position;

  public:
    constexpr iterator(int64_t position) noexcept: M_position(position) { }
    constexpr void operator ++ () noexcept { ++M_position; }
    constexpr bool operator != (iterator other) const noexcept { return M_position != other.M_position; }
    constexpr int64_t operator * () const noexcept { return M_position; }
  };

  class reverse_iterator {
  private:
    int64_t M_position;
  
  public:
    constexpr reverse_iterator(int64_t position) noexcept: M_position(position) { }
    constexpr void operator ++ () noexcept { --M_position; }
    constexpr bool operator != (reverse_iterator other) const noexcept { return M_position != other.M_position; }
    constexpr int64_t operator * () const noexcept { return M_position; }
  };
  
private:
  const iterator M_first, M_last;

public:
  constexpr range(int64_t first, int64_t last) noexcept: M_first(first), M_last(std::max(first, last)) { }
  constexpr iterator begin() const noexcept { return M_first; }
  constexpr iterator end() const noexcept { return M_last; }
  constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(*M_last - 1); } 
  constexpr reverse_iterator rend() const noexcept { return reverse_iterator(*M_first - 1); } 
};

/**
 * @title Range
 */
#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/rev.cpp"

#include <type_traits>
#include <iterator>
#line 6 "/Users/kodamankod/Desktop/cpp_programming/Library/other/rev.cpp"

template <class T>
class rev_impl {
public:
  using iterator = decltype(std::rbegin(std::declval<T>()));

private:
  const iterator M_begin;
  const iterator M_end;

public:
  constexpr rev_impl(T &&cont) noexcept: M_begin(std::rbegin(cont)), M_end(std::rend(cont)) { }
  constexpr iterator begin() const noexcept { return M_begin; }
  constexpr iterator end() const noexcept { return M_end; }
};

template <class T>
constexpr decltype(auto) rev(T &&cont) {
  return rev_impl<T>(std::forward<T>(cont));
}

/**
 * @title Reverser
 */
#line 17 "main.cpp"

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

int main() {
  i32 x;
  std::cin >> x;
  std::cout << 1 - x << '\n';
  return 0;
}


Measured memory_bytes: 3632
n = gets.to_i
ss = n.times.map { gets.chomp[0] }

counts = ss.each_with_object(Hash.new(0)) { |s, h| h[s] += 1 }
ans = %w(M A R C H).combination(3).inject(0) do |r, (a, b, c)|
  r + counts[a] * counts[b] * counts[c]
end

puts ans


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

int main(){
    ll n; cin >> n;
    string a;
    while(n!=0){
        int now = (n-1)%26;
        a = (char)(now+'a') + a;
        n -= now+1;
        n /= 26;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main(){
	int a = 0;
	int b = 0;
	cin >> a;
	cin >> b;
	if (a < b){
		cout << "a < b" << endl;
	}
	if (a>b){
		cout << "a > b" << endl;
	}
	if (a==b){
		cout << "a == b" << endl;
	}
	
	return 0;
}

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

inline int64_t ceiling_div(int64_t a, int64_t b){
  int64_t ans= ((a>=0 && b > 0) || (a<=0 && b < 0)) ? (abs(a)+abs(b)-1)/abs(b)
                                                    : -abs(a)/abs(b);
  return ans;
}

int main(){
  using P= pair<int64_t, int64_t>;
  int N;
  cin >> N;

  vector<P> ratios(N);
  for(int i=0; i<N; i++){
    cin >> ratios.at(i).first >> ratios.at(i).second;
  }

  int64_t Avote= 1;
  int64_t Bvote= 1;
  for(auto ratio:ratios){
    int64_t Ashare,Bshare;
    tie(Ashare, Bshare)= ratio;

    int64_t multiply= max(ceiling_div(Avote, Ashare), ceiling_div(Bvote, Bshare));

    Avote= multiply* Ashare;
    Bvote= multiply* Bshare;
  }
  int64_t ans= Avote+ Bvote;

  cout << ans << endl;
}

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


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

typedef long long ll;
const int inf = 1e9;

int x, t;

int main(){
	cin>>x;
	if(x >= 400 && x <= 599)t = 8;
	if(x >= 600 && x <= 799)t = 7;
	if(x >= 800 && x <= 999)t = 6;
	if(x >= 1000 && x <= 1199)t = 5;
	if(x >= 1200 && x <= 1399)t = 4;
	if(x >= 1400 && x <= 1599)t = 3;
	if(x >= 1600 && x <= 1799)t = 2;
	if(x >= 1800 && x <= 1999)t = 1;
	cout<<t<<endl;
	return 0;
}


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

using namespace std;

typedef long long LL;

const int MAX_N = 1e6 + 10;
const int MOD = 1e9 + 7;

LL dp[MAX_N], sum;

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

	LL n;

	cin >> n;
	dp[1] = n, sum = n - 1;
	for (int i = 2; i <= n; i++)
	{
		if (i > 3) sum = (sum + dp[i - 3] - 1) % MOD;

		dp[i] = ((n - 1) * (n - 1) % MOD + dp[i - 1] + sum) % MOD;
	}//for i

	cout << dp[n] << '\n';

	return 0;
}//main

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n;
    string s;
    int a,b,c;
    cin >> a >> b >> c;
    cout << c <<" "<< a <<" "<< b;


}

Measured memory_bytes: 256
n = int(raw_input())
H = map(int, raw_input().split())
res = 0
for i in range(1, max(H) + 1):
    consecutives = 0
    in_consecutive = False
    for j in range(n):
        if not in_consecutive and H[j] >= i:
            in_consecutive = True
        elif in_consecutive and H[j] < i:
            in_consecutive = False
            consecutives += 1
        else:
            continue
    if in_consecutive:
        consecutives += 1
    res += consecutives
print res

Measured memory_bytes: 2568
class Integer
  def factorial
    return 1 if self == 0
    (1..self).inject { |a, b| a * b % (1_000_000_007) }
  end
end

N, M = gets.chomp.split.map(&:to_i)

if (N - M).abs > 1
  puts 0
else
  if N == M
    puts 2 * N.factorial * M.factorial % 1_000_000_007
  else
    puts (N.factorial * M.factorial) % 1_000_000_007
  end
end


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;

int main()
{
  int n,m,sum,line,ans;
  ans=1;
  sum=0;
  cin>>n>>m;
  vector<int> a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i);
    sum+=a.at(i);
  }
  if(sum%(m*4)==0)
    line=sum/(m*4)-1;
  else
    line=sum/(m*4);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(int i=0;i<m;i++)
  {
    if(a.at(i)<=line)
    {
      ans=0;
      break;
    }
  }
  if(ans==1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3632
N, K = map(int, input().split())
P = list(map(int, input().split()))
tmp = sum([(p + 1) / 2 for p in P[:K]])
ans = tmp
for i in range(N - K):
    tmp = tmp - (P[i] + 1) / 2 + (P[K + i] + 1) / 2
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 24812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}

int main(){
    string s;cin >> s;
    if(s == "ABC"){
        cout << "ARC\n";
    }else{
        cout << "ABC\n";
    }
}

Measured memory_bytes: 3624
n, m, q = map(int, input().split())
queries = [tuple(map(int, input().split())) for _ in range(q)]
ans = 0

def calc_score(p):
    score = 0
    for a, b, c, d in queries:
        if p[b-1] - p[a-1] == c:
            score += d
    return score

def f(p):
    if len(p) == n:
        global ans
        ans = max(ans, calc_score(p))
        return
    l = p[-1] if len(p) else 1
    for x in range(l, m+1):
        f(p + [x])

f([])

print(ans)


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >>h >>w;
  vector<vector<string>> a(h,vector<string>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >>a[i][j];
      if(a[i][j]=="snuke"){
        printf("%c",'A'+j);
        cout<< i+1 <<endl;
      }
    }
  }
  
}

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

int main() {
  int n,d;
  cin>>n;
  cout<<3*n*n<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
X = [int(i) for i in input().split()]
D = defaultdict(int)
for x in X:
    D[x] += 1

B = []
for x in D:
    for _ in range(D[x] // 2):
        B.append(x)
B.sort()
ans = B[-1] * B[-2] if len(B) >= 2 else 0
print(ans)

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

int main() {
  int N, M;
  cin >> N >> M;
  
  set<int> keys;
  map<int64_t, int64_t> cards;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    keys.insert(A);
    cards[A] += 1;
  }
  
  for (int j = 0; j < M; j++) {
    int B, C;
    cin >> B >> C;
    while (true) {
      int min_key = *begin(keys);
      if (min_key >= C) {
        break;
      }
      else {
        if (cards[min_key] > B) {
          cards[min_key] -= B;
          keys.insert(C);
          cards[C] += B;
          break;
        }
        else if (cards[min_key] == B) {
          cards.erase(min_key);
          keys.erase(min_key);
          keys.insert(C);
          cards[C] += B;
          break;
        }
        else {
          keys.insert(C);
          cards[C] += cards[min_key];
          B -= cards[min_key];
          cards.erase(min_key);
          keys.erase(min_key);
        }
      }
    }
  }
  int64_t sum = 0;
  for (auto _cards : cards) {
    sum += _cards.first * _cards.second;
  }
  cout << sum << endl;
}

Measured memory_bytes: 11136
n = gets.strip.to_i - 1
bars = gets.strip.split(' ').map(&:to_i)
max_count = 0
count = 0
n.times do |i|
  if bars[i] >= bars[i + 1]
    count += 1
    max_count = count if count > max_count
  else
    count = 0
  end
end

puts max_count

Measured memory_bytes: 9732
n, a, b = map(int, input().split())
s = str(input())
cur = 0
ab = 0
for i in range(n):
    #j = i+1
    if s[i] == 'a':
        if cur < a+b:
            print('Yes')
            cur += 1
        else:
            print('No')
    elif s[i] == 'b':
        if cur < a+b and ab <= b-1:
            print('Yes')
            cur += 1
            ab += 1
        else:
            print('No')
    else:
        print('No')


Measured memory_bytes: 53080
n,m = map(int,input().split())
toi=[0 for i in range(n)]
ac=0
wa=0
for i in range(m):
  p,s=map(str,input().split())
  p=int(p)
  if s=="AC":
    if toi[p-1]!=-1:
      wa+=toi[p-1]
      ac+=1
      toi[p-1]=-1
  else:
    if toi[p-1]!=-1:
      toi[p-1]+=1
print(ac,wa)
 


Measured memory_bytes: 9980
#include <bits/stdc++.h>
using namespace std;
const int maxn=2010;
int n,k,tot,ans,x,y;
bool vis[maxn];
vector <int> e[maxn];
void dfs(int node,int fa,int dep){
	if(dep>k/2)tot++;
	for(int i=0;i<e[node].size();++i)
		if(e[node][i]!=fa)
			dfs(e[node][i],node,dep+1);
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;++i){
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	ans=n-k-1;
	if(k&1){
		for(int i=1;i<=n;++i){
			for(int j=0;j<e[i].size();++j){
				tot=0;
				dfs(i,e[i][j],0);
				dfs(e[i][j],i,0);
				ans=min(ans,tot);
			}
		}
	}
	else {
		for(int i=1;i<=n;++i){
			tot=0;
			dfs(i,0,0);
			ans=min(ans,tot);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main(){
int n,i;
char moji[4];
int ac=0,wa=0,tle=0,re=0;
scanf("%d",&n);
for(i=0;i<n;i++){
  scanf("%s",moji);
  if(strcmp(moji,"AC")==0){
    ac++;
  }else if(strcmp(moji,"WA")==0){
    wa++;
  }else if(strcmp(moji,"TLE")==0){
    tle++;
  }else if(strcmp(moji,"RE")==0){
    re++;
  }
}
printf("AC x %d\n",ac);
printf("WA x %d\n",wa);
printf("TLE x %d\n",tle);
printf("RE x %d\n",re);
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, h, x, y, cnt = 0, ans = 0;
	vector<int> a, b, c;
	cin >> n >> h;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		a.push_back(x);
		b.push_back(y);
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	for (int i = 0; i < n; i++) {
		if (b[i] > a[0]) {
			c.push_back(b[i]);
			cnt++;
		}
	}
	for (int i = 0; i < cnt; i++) {
		if (h > 0) {
			h -= c[i];
			ans++;
		} if (h < 0) {
			cout << ans << endl;
			return 0;
		}
	}
	if (h % a[0] == 0) {
		ans += h / a[0];
	} else {
		ans += h / a[0] + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
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(){
  int X,N; cin >> X >> N;
  set<int> st;
  rep(i,N){
    int p; cin >> p;
    st.insert(p);
  }
  int ab = 3000;
  int ans = 0;
  for(int i=-1000;i<1000;i++){
    if(!st.count(i)){
      if(ab>abs(i-X)){
        ans = i;
        ab = abs(i-X);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
using namespace std;

#define Pr pair<long int, long int>
#define Tp tuple<int, long int, long int>

static const int MAX_M = 100010;

int main(void){
  //入力
  long int N, M;
  long int P[MAX_M], Y[MAX_M];
  long int x[MAX_M];
  Tp id_in[MAX_M];
  long int p_cnt[MAX_M];
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    cin >> P[i] >> Y[i];
    get<0>(id_in[i]) = Y[i];
    get<1>(id_in[i]) = P[i];
    get<2>(id_in[i]) = i;
  }
  for(int i = 0; i < N; i++){
    p_cnt[i] = 0;
  }
  //下6桁について並び替えを行う。
  //まず，Pごとに分ける。:
  sort(id_in, id_in + M);
  //Y[i]を下から見ていって，P[i]のcntを増やしつつ，x[i]を割り振っていく。
  for(int i = 0; i < M; i++){
    x[get<2>(id_in[i])] = p_cnt[get<1>(id_in[i])];
    p_cnt[get<1>(id_in[i])]++;
  }
  //出力列の生成
  for(int i = 0; i < M; i++){
    if(P[i] < 10) cout << 0 << 0 << 0 << 0 << 0 << P[i];
    else if(P[i] < 100) cout << 0 << 0 << 0 << 0 << P[i];
    else if(P[i] < 1000) cout << 0 << 0 << 0 << P[i];
    else if(P[i] < 10000) cout << 0 << 0 << P[i];
    else if(P[i] < 100000) cout << 0 << P[i];
    else cout << P[i];
    if(x[i] + 1 < 10) cout << 0 << 0 << 0 << 0 << 0 << x[i] + 1;
    else if(x[i] + 1 < 100) cout << 0 << 0 << 0 << 0 << x[i] + 1;
    else if(x[i] + 1 < 1000) cout << 0 << 0 << 0 << x[i] + 1;
    else if(x[i] + 1 < 10000) cout << 0 << 0 << x[i] + 1;
    else if(x[i] + 1 < 100000) cout << 0 << x[i] + 1;
    else cout << x[i] + 1;
    if(i < M - 1) cout << endl;
  }
  return 0;
}


Measured memory_bytes: 7040
bingo = Array.new(3).map{Array.new(3, false)}
a = []
3.times do
    a << gets.chomp.split.map(&:to_i)
end
n = gets.chomp.to_i
n.times do
    b = gets.chomp.to_i
    3.times do |i|
        3.times do |j|
            bingo[i][j] = true if b == a[i][j]
        end
    end
end
ans = false
3.times do |i|
    ans = bingo[0][i] && bingo[1][i] && bingo[2][i]
    break if ans
    ans = bingo[i][0] && bingo[i][1] && bingo[i][2]
    break if ans
end
if ans then
    puts "Yes"
else
    res1 = bingo[0][0] && bingo[1][1] && bingo[2][2]
    res2 = bingo[0][2] && bingo[1][1] && bingo[2][0]
    puts res1 || res2 ? "Yes" : "No"
end

Measured memory_bytes: 14216
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;

signed main() {
	string A, B, C;
	cin >> A >> B >> C;
	if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0])cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main() {
	int i, j, dice[6], rgst[6];
	char dir[100];
	size_t len;
	scanf("%d%d%d%d%d%d", &dice[0], &dice[1], &dice[2], &dice[3], &dice[4], &dice[5]);
	scanf("%s", dir);
	len = strlen(dir);
	for (i = 0; i < len; i++) {
		for (j = 0; j < 6; j++) {
			rgst[j] = dice[j];
		}
		if (dir[i] == 'N') {
			dice[0] = rgst[1];
			dice[1] = rgst[5];
			dice[4] = rgst[0];
			dice[5] = rgst[4];
		} else if (dir[i] == 'E') {
			dice[0] = rgst[3];
			dice[2] = rgst[0];
			dice[3] = rgst[5];
			dice[5] = rgst[2];
		} else if (dir[i] == 'S') {
			dice[0] = rgst[4];
			dice[1] = rgst[0];
			dice[4] = rgst[5];
			dice[5] = rgst[1];
		}
		else if (dir[i] == 'W') {
			dice[0] = rgst[2];
			dice[2] = rgst[5];
			dice[3] = rgst[0];
			dice[5] = rgst[3];
		}
	}

	printf("%d\n", dice[0]);

	return 0;
}

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

int check(string &s) {
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != s[s.size()-1-i]) {
			return 0;
		}
	}
	return 1;
}

int main()
{
	string s; cin >> s;
	int n = s.size();string s1=s.substr(0, (n-1)/2),s2=s.substr((n+3)/2-1, 105);
	if (check(s) && check(s1) && check(s2))
		puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << 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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> a(n);
    ll sum = 0;
    map<ll, ll> mp;
    rep(i,n) {
        cin>>a[i];
        mp[a[i]]++;
        sum+=a[i];
    }

    int q; cin>>q;
    while (q--) {
        ll b,c; cin>>b>>c;
        ll cnt = mp[b];
        mp[b] = 0;
        ll tmp = b*cnt;
        sum -= tmp;

        mp[c] += cnt;
        sum += c*cnt;

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

Measured memory_bytes: 9888
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn min_opt<T: Ord>(x: Option<T>, y: Option<T>) -> Option<T> {
    match (x, y) {
        (x, None) => x,
        (None, y) => y,
        (Some(x), Some(y)) => Some(min(x, y)),
    }
}

fn main() {
    let (N, M) = read!(usize, usize);
    let mut keys = vec![];
    for _ in 0..M {
        let (a, _) = read!(i64, usize);
        let C = read![[usize]];

        let mut s = 0;
        for c in C {
            s |= 1 << (c - 1);
        }

        keys.push((a, s));
    }

    let mut dp = vec![vec![None; 1 << N]; M + 1];
    dp[0][0] = Some(0);

    for i in 0..M {
        let (a, t) = keys[i];

        for s in 0..1 << N {
            dp[i + 1][s] = min_opt(dp[i + 1][s], dp[i][s]);

            dp[i + 1][s | t] = min_opt(dp[i + 1][s | t], dp[i][s].map(|x| x + a));
        }
    }

    let min_opt = dp[M][(1 << N) - 1];

    match min_opt {
        None => println!("-1"),
        Some(x) => println!("{}", x),
    }
}


Measured memory_bytes: 73980
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int mun = INF;
    for (int i = 0; i <= n - k; i++) {
        chmin(mun, a[i + k - 1] - a[i]);
    }
    cout << mun << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define ll long long

const int N = 303;
const int mod = 998244353;

using namespace std;

int n, k;
int d[N][N];
int f[N][N];
int rem;
string s;

void add(int &x, int y)
{
        x += y;
        if(x >= mod){
                x -= mod;
        } else if(x < 0){
                x += mod;
        }
}

void make(int x)
{
        rem -= x;
        for(int i = 0; i <= k; i++){
                for(int j = 0; j <= i; j++){
                        for(int h = min(x, i - j); h >= 0; h--){
                                add(f[i][j + h], d[i][j]);
                        }
                        for(int h = min(rem, k - i); h > 0; h--){
                                add(f[i + h][j], d[i][j]);
                        }
                }
        }
        for(int i = 0; i <= k; i++){
                for(int j = 0; j <= k; j++){
                        d[i][j] = f[i][j];
                        f[i][j] = 0;
                }
        }
}

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

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> s >> k;
        n = s.size();
        k = min(k, n);
        rem = n;

        vector < int > a = {0};
        for(int i = 0; i < n; i++){
                if(s[i] == '0'){
                        a.push_back(0);
                } else{
                        a.back() += 1;
                }
        }
        n = a.size();
        d[0][0] = 1;
        for(int x: a){
                make(x);
        }
        int res = 0;
        for(int i = 0; i <= k; i++){
                add(res, d[i][i]);
        }

        cout << res << "\n";
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int count = 0;
	for (int i = n - 1; i >= 0; i--) {
		for (int j = i * 2 + 1; j < n; j += i + 1) {
			a[i] ^= a[j];
		}
		count += a[i];
	}
	cout << count << endl;
	for (int i = 0; i < n; i++) {
		if (a[i])
			cout << i + 1 << " ";
	}

}


Measured memory_bytes: 1792
import bisect
n = int(input())
A = [int(input()) for i in range(n)]
m = 10**9
X = []
for a in A:
    i = bisect.bisect_right(X, -a)
    if i == len(X):
        X.append(-a)
    else:
        X[i] = -a
print(len(X))


Measured memory_bytes: 11036
#include <bits/stdc++.h>
#define ll long long
const int MOD = 1e9 + 7;
using namespace std;
int main() {
    int N, M;
    string s;
    cin >> N >> M;
    cin >> s;
    vector <int> v1;
    for (int i = 0; i <= N; ++i) {
        if(s[i] == '0') {
            v1.emplace_back(i);
        }
    }
    int curr = v1.size()-1, i = curr-1, flag = 0;
    vector <int> ans;
    while(i >= 0) {
        int count = 0;
        while(v1[curr] - v1[i] <= M && i >= 0) {
            i--;
            count++;
        }
        if(count == 0) {
            flag = 1;
            break;
        }
        ans.push_back(v1[curr] - v1[i+1]);
        curr = i + 1;
        // cout << v1[curr] << " ";
    }
    if(flag == 1) {
        cout << "-1\n";
    }
    else {
        reverse(ans.begin(), ans.end());
        for (int i : ans) {
            cout << i << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 1592
#include <iostream>
#include <string>

using namespace std;

int main(){
	int i;
	string hoge;
	cin >> i;
	if(i%2 == 1){
		cout << "No";
		return 0;
	}
	cin >> hoge;
	int n = i/2;
	for(int k=0; k<=n-1; k++){
		if(!(hoge[k]==hoge[n+k])){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define pow fuck
#define int long long
using namespace std;
const int mod=1e9+7;
int sqr(int x){return x*x%mod;}
int pow(int a,int n){return !n?1:sqr(pow(a,n/2))*(n&1?a:1)%mod;}
int f[1000011],dp[1000011],n,h,d,s[1000011];
main()
{
	cin>>n>>h>>d;
	f[1]=s[1]=1;
	for(int i=2;i<=n;i++)
	{
		f[i]=f[i-1]*i%mod;
		s[i]=(s[i-1]+f[i])%mod;
	}
	int sum=dp[0]=1;
	for(int i=1;i<=h;i++)
	{
		dp[i]=sum*s[n]%mod;
		sum=(sum+dp[i])%mod;
		if(i>=d)sum=(sum-dp[i-d]+mod)%mod;
	}
	cout<<dp[h]*f[n]%mod*pow(s[n],mod-2)%mod<<'\n';
}


Measured memory_bytes: 23680
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll n;
cin>>n;
ll t[n];
ll sum=0;
for(ll i=0;i<n;i++){
    cin>>t[i];
    sum+=t[i];
}
ll m;
cin>>m;
ll p,x;
for(ll i=0;i<m;i++){
    cin>>p>>x;
    cout<<sum-t[p-1]+x<<endl;
}

}










Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];

  sort(a.begin(), a.end());

  cout << a[0] + a[1] + a[2]*10 << endl;


  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int n2 = sc.nextInt();
        int m2 = sc.nextInt();
        int k = sc.nextInt();

        System.out.println((n2 - n) * 60 + (m2 - m) - k);

        sc.close();
    }

}


Measured memory_bytes: 35760
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
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 main(){
    ll a,b,c;
    std::cin >> a>>b>>c;
    
    ll result = 0;
    
    result += min(c,b+a+1);
    // cが食える枚数はa+b+1が最大
    result += b;
    
    std::cout << result << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 50;
int N, P;
int A[MAX_N];
ll fact[MAX_N+1];
ll inv_fact[MAX_N+1];

//整数a,bに対し、ax + by = gcd(a,b) を満たす整数x,y,gcd(a,b) を計算する
ll extgcd(ll a, ll b, ll& x, ll& y) {
  ll d = a;
  if (b != 0) {
    d = extgcd(b, a%b, y, x);
    y -= (a/b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}

//ax ≡ gcd(a,m) (mod m) を満たすxを計算する。
ll mod_inverse(ll a, ll m) {
  ll x, y;
  extgcd(a, m, x, y);
  return (m + x%m) % m;
}


void init(ll n, ll mod) {
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) fact[i] = (fact[i-1]*i)%mod;

  for (int i = 0; i <= n; ++i) inv_fact[i] = mod_inverse(fact[i], mod);
}

ll mod_comb(ll n, ll r, ll mod) {
  return fact[n]*inv_fact[r]%mod*inv_fact[n-r]%mod;
}

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

  cin >> N >> P;
  rep(i, N) cin >> A[i];
  init(N, MOD);
  ll odd = 0, even = 0;
  rep(i, N) {
      if (A[i]%2 == 0) {
          ++even;
      } else {
          ++odd;
      }
  }

  ll ans = 0;
  if (P == 0) {
      ans += pow(2ll, even);
      for (int i = 2; i <= odd; i += 2) {
          ans += pow(2ll, even) * mod_comb(odd, i, MOD);
      }
  } else {
      for (int i = 1;  i <= odd; i += 2) {
          ans += pow(2ll, even) * mod_comb(odd, i, MOD);
      }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
int main()
{
	string s;
	cin >> s;
	for (int i=0;i<s.size()-1;i++)
	{
		set<char> st;
		st.insert(s[i]);
		st.insert(s[i+1]);
		if (st.size()==1)
		{
			cout << i+1 << ' ' << i+2;
			return 0;
		}
		if (i+2<s.size())
		{
			st.insert(s[i+2]);
			if (st.size()==2)
			{
				cout << i+1 << ' ' << i+3;
				return 0;
			}
		}
	}
	cout << "-1 -1";
}

Measured memory_bytes: 512
from string import ascii_lowercase
h = {ascii_lowercase[i]:i for i in range(26)}
S = input()
c = set(ascii_lowercase) - set(S)
if len(c) > 0:
    print(S + sorted(c)[0])
else:
    for i in range(len(S)-1, -1, -1):
        j = h[S[i]]
        for k in range(j+1, 26):
            if not ascii_lowercase[k] in S[:i]:
                print(S[:i] + ascii_lowercase[k])
                exit()
    print(-1)


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;cin >> n;
    vector<int> b(n-1);
    rep(i,n-1) cin >> b[i];
    ll sum = b[0];
    for(int i=0;i<n-2;i++){
        sum += min(b[i],b[i+1]);
    }
    sum += b[n-2];
    cout << sum << endl;
}

Measured memory_bytes: 256