akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    vector<ll> v;
    map<ll, ll> m;
    ll tmp;
    REP(i, n) {
        cin >> tmp;
        if (m.find(tmp) == m.end()) {
            v.push_back(tmp);
            m[tmp] = 0;
        }
        m[tmp]++;
    }
    sort(v.begin(), v.end(), greater<ll>());
    ll w = 0;
    ll h = 0;
    REP(i, v.size()) {
        if (m[v[i]] >= 4) {
            if (w == 0) {
                w = v[i];
                h = v[i];
                break;
            } else if (h == 0) {
                h = v[i];
                break;
            }
        } else if (m[v[i]] >= 2) {
            if (w == 0) {
                w = v[i];
            } else if (h == 0) {
                h = v[i];
                break;
            }
        }
    }
    if ((w != 0) && (h != 0)) {
        cout << w * h << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 10224
#include<iostream>
//#include<algorithm>
//#include<vector>
//#include<set>
#include <string>

using namespace std;


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

auto lmdisCenter = [](const string& s, size_t start, int len) -> bool
{
    bool isOdd = len % 2;
    int center = isOdd ? len / 2 + 1 : len / 2;
    string a, b;
    bool flg = true;
    for(size_t i = start; i < center && flg; ++i)
        if(i != len-i - 1)
            flg = s[i] == s[len - i - 1];
    
    return flg;
};

bool ans = lmdisCenter(s, 0, s.length()) && lmdisCenter(s, 0, (s.length() - 1) / 2) && lmdisCenter(s, (s.length() + 3) / 2, s.length());
    
cout << (ans ? "Yes" : "No") << "\n";

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>

int n, k;
std::pair<long long, int> data[100005];
std::priority_queue<std::pair<long long, int>> que;
int ate[100005];
int main() {
	std::cin >> n >> k;
	for (int i = 0; i < n; ++i)
		std::cin >> data[i].second >> data[i].first;
	std::sort(data, data + n, std::greater<std::pair<long long, int>>());

	long long type = 0, sum = 0;

	for (int i = 0; i < k; ++i) {
		sum += data[i].first;
		++ate[data[i].second];
		if (ate[data[i].second] == 1)
			++type;
		que.emplace(-data[i].first, data[i].second);
	}

	long long ans = type * type + sum;
	for (int i = k; i < n; ++i) {
		auto d = data[i];
		if (ate[d.second] != 0)
			continue;
		while (!que.empty()) {
			auto p = que.top();
			que.pop();
			if (ate[p.second] == 1)
				continue;
			--ate[p.second];
			++ate[d.second];
			sum += p.first;
			sum += d.first;
			++type;
			break;
		}
		ans = std::max(ans, type*type + sum);
	}

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


Measured memory_bytes: 4340
#include <iostream>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	int s;
	s=n*a;
	if(s>b)
	cout<<b;
	if(s<b)
	cout<<s;
	if(s==b)
	cout<<b;
	return 0;
 } 
 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
string s;
bool lt[30];
int an,ans;
int main(){
cin>>s;
cin>>s;
for(int i=0;i<s.size();i++)
{
for(int j=0;j<i;j++)
lt[s[j]-'a']=1;
for(int j=i;j<s.size();j++)
if(lt[s[j]-'a']==1){
an++;
lt[s[j]-'a']=0;
}
ans=max(ans,an);
for(int j=0;j<30;j++)
lt[j]=0;
an=0;
}
cout<<ans;
system("pause");
return 0;
}

Measured memory_bytes: 504
//Rextester.Program.Main is the entry point for your code. Don't change it.
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            
          var input = Console.ReadLine();

            var first  = input.IndexOf("A");
            var last = input.LastIndexOf("Z");
            Console.WriteLine(last - first +1);
    
            
       
        }
    }
}

Measured memory_bytes: 3928
#pragma region

#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin); i < (end); i++)
#define IFOR(i, begin, end) for (int i = (end)-1; i >= (begin); i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define MOD 1000000007
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  REP(i, vec.size())
  i == 0
      ? os << vec[i]
      : os << ", " << vec[i];
  os << " ]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &deq) {
  os << "deq[ ";
  REP(i, deq.size())
  i == 0
      ? os << deq[i]
      : os << ", " << deq[i];
  os << " ]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &m) {
  os << "{ ";
  for (auto &&k : m) &k == &(*m.begin()) ? os << k.first << " => " << k.second : os << ", " << k.first << " => " << k.second;
  os << " }";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &m) {
  os << "{ ";
  for (auto &&k : m) &k == &(*m.begin()) ? os << k.first << " => " << k.second : os << ", " << k.first << " => " << k.second;
  os << " }";
  return os;
}

#pragma endregion

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

  int N;
  cin >> N;
  vector<ll> A(N);
  cin >> A;

  ll sum = 0;
  REP(i, N)
  sum += A[i];

  ll st = 0;
  REP(i, N) {
    st += A[i];
    if (st >= sum / 2) {
      cout << min(st * 2 - sum, sum - (st - A[i]) * 2) << "\n";
      return 0;
    }
  }
}


Measured memory_bytes: 1792
n, m = map(int, input().split())

digit = [-1] * n
flag = True
for _ in range(m):
    s, c = map(int, input().split())
    if digit[s - 1] == -1:
        digit[s - 1] = c
    elif digit[s - 1] != c:
        flag = False
        break

if not flag:
    print(-1)
elif n == 1:
    print(digit[0] if digit[0] > 0 else 0)
elif digit[0] == 0:
    print(-1)
else:
    ans = 0
    for i in range(len(digit)):
        if digit[i] == -1:
            digit[i] = 1 if i == 0 else 0

        ans += 10 ** (n - i - 1) * digit[i]
    print(ans)

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

int main(){
    int coin_a,coin_b,cost;
    cin >> coin_a >> coin_b >> cost;
    if(coin_a + coin_b >= cost){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
return 0;
}

Measured memory_bytes: 256
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loope(i,a,b) for(int i=a;i<=b;i++)
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
LL nck(int n,int k)
{
	LL C[k+1]={0};
	C[0]=1;
	for(int i=0;i<=n;i++)
	{
		for(int j=min(i,k);j>0;j--)
		{
			C[j]+=C[j-1]%mod;
		}
	}
	return C[k];
}
int main()
{      
  LL n, k;
    cin >> n >> k;
 
    vector<vll> comb(n+1,vector<LL>(n+1));
    for(int i=0;i<=n;++i) 
    	comb[i][0]=1;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=i;++j)
        {
            (comb[i][j]+=comb[i-1][j-1]+comb[i-1][j])%=mod;
        }
    }
 
    for (int i = 1; i <= k; ++i)
        cout<<(comb[k-1][i-1]*comb[n-k+1][i])%mod << '\n';
 
   
  return 0;
}

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

int main(){
    for(int i=1;i<=5;i++){
        int x;
        cin >> x;
        if(x==0){
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3588
n,m = map(int,input().split())
a_list = list(map(int,input().split()))
a_list.sort()
b_c_list = []
for i in range(m):
  b_c_list.append(list(map(int,input().split())))

b_c_list.sort(key=lambda x: x[1],reverse = True)
                  
count = 0
d = []
for b_c in b_c_list:
  for i in range(b_c[0]):
    d.append(b_c[1])
    count += 1
    if count >= n:
      break
  if count >= n:
    break
    

for i in range(min(n,len(d))):
  if a_list[i] < d[i]:
    a_list[i] = d[i]
  else:
    break
    
print(sum(a_list))

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

using namespace std;

const int N = 2999;

double p[N + 1];
bool vis[N + 1][N + 1];
double dp[N + 1][N + 1];

double prob(int i, int h)
{
	if (!vis[i][h]) {
		if (i == 1) {
			if (h == 1) {
				dp[i][h] = p[i];
			} else if (h == 0) {
				dp[i][h] = 1 - p[i];
			} else {
				dp[i][h] = 0;
			}
		} else if (h == 0) {
			dp[i][h] = (1 - p[i]) * prob(i - 1, 0);
		} else {
			dp[i][h] = p[i] * prob(i - 1, h - 1) + (1 - p[i]) * prob(i - 1, h);
		}
		vis[i][h] = true;
	}
	return dp[i][h];
}

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

	int n; cin >> n;
	double ans = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> p[i];
	}
	for (int i = n - (n / 2); i <= n; ++i) {
		ans += prob(n, i);
	}
	cout << fixed << setprecision(10) << ans << endl;
}

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

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

using namespace std;

int main(){
    int N;
    int s[100];
    cin >> N;
    int ans=0;
    rep(i,N){
        cin >> s[i];
        ans += s[i];
    }
    if(ans%10){
        cout << ans << endl;
        return 0;
    }

    sort(s,s+N);
    rep(i,N){
        if(s[i]%10){
            cout << ans-s[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 0114c
ll n;
ll ans = 0;
void dfs(ll nn, int a, int b, int c){
    if (a and b and c and nn <=n) ans++;
    if (nn <= n){
        dfs(nn*10+3, 1, b, c);
        dfs(nn*10+5, a, 1, c);
        dfs(nn*10+7, a, b, 1);
    }
}

int main(){
    cin >> n;
    dfs(0LL, 0, 0, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
	ll n;
	cin >> n;
	string c;
	cin >> c;

	ll rcnt = 0;
	REP(i, n){
		if(c[i] == 'R'){
			rcnt ++;
		}
	}

	ll ans = 0;
	REP(i, rcnt){
		if(c[i] == 'W'){
			ans ++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

#define _ << ": " <<
#define watch1(var1) (cerr << (#var1) _ var1 << '\n')
#define watch2(var1, var2) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << '\n';
#define watch3(var1, var2, var3) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << ", " << (#var3) _ var3 << '\n';
#define wloop(size, arr) cerr << (#arr) << ": "; for (int i = 0; i < size; i++) cerr << arr[i] << " \n"[i+1 == size];

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ints(a...) int a; read(a)
#define longs(a...) int64_t a; read(a)

const string A = "abcdefghijklmnopqrstuvwxyz";

void solve() {
    longs(n);
    array<short, 100000> v;
    int pos = 0;
    while (n) {
        n--;
        v[pos++] = n % 26;
        n /= 26;
    }
    for (int i = pos - 1; ~i; i--) cout << A[v[i]];
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 3660
//Have a nice day:)
#include<bits/stdc++.h>
using namespace std;
#define LL long long

inline LL read();

const int N=50+2;
LL n;
LL cnt, a[N];

bool Minus()
{
    int id=0;
    for(int i=1; i<=n; ++i)
        if(a[i]>a[id]) id=i;
     
    if(id)
    {
        LL k=a[id]/n; a[id]%=n; cnt+=k;
        for(int j=1; j<=n; ++j) 
            if(j^id) a[j]+=k;
        return true;
    }

    return false;
}

void Work()
{
    n=read(); a[0]=n-1;
    for(int i=1; i<=n; ++i) a[i]=read();
    while(Minus());
    printf("%lld", cnt);
}

int main()
{
    #ifdef gc
    freopen("79c.in","r",stdin);
    freopen("79c.out","w",stdout);
    #endif

    Work();

    return 0;
}

inline LL read()
{
    char c; bool type=1;
    while((c=getchar())<'0' || c>'9')
        if(c=='-') type=0;
    LL ans=c^48;
    while((c=getchar())>='0' && c<='9')
        ans=(ans<<3)+(ans<<1)+(c^48);
    return type?ans:-ans;
}


Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
 long long int n;
  cin >> n;
  vector<long long int> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  while(vec.at(n-2)>0){
    for(int i=0;i<n-1;i++){
      if(vec.at(i)!=0){
        for(int j=i+1;j<n;j++){
          if(vec.at(j)>=vec.at(i)){
          vec.at(j)=vec.at(j)%vec.at(i);
          }         
        }
      }
    }
  sort(vec.begin(), vec.end());
  }
  cout << vec.at(n-1) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;

const int N = 20005;
const long long INF = 0x3f3f3f3f3f3f3f3f;

int n, x, t;
string s;

int main()
{
	cin >> s;
	for(auto c: s)
		x += c - '0';
	if(x % 9) puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 3716
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int a, b, c;
    scan(a, b, c);
    writeln(b - a == c - b ? "YES" : "NO");
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0;lli sum=0ll;
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        if(i%3!=0&&i%5!=0)
            sum+=i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3652
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    k,n = inpm()
    a = inpl()
    a.append(a[0]+k)
    MAX = 0
    for i in range(n):
        d = a[i+1]-a[i]
        MAX = max(MAX,d)
    print(k-MAX)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 101444
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] p = new int[M];
        String[] S = new String[M];
        String A = "AC";
        String W = "WA";
        int ac = 0;
        int wa = 0;
        String[] sn = new String[N + 1];
        int[] wn = new int[N + 1];
        int[] an = new int[N + 1];
 
        for(int i=0; i<M; i++){
            p[i] = sc.nextInt();
            S[i] = sc.next();
            if(an[p[i]]==1){
                continue;
            }
            else{
                if(S[i].equals(A)){
                    an[p[i]] = 1;
                }
                else if(S[i].equals(W)){
                    wn[p[i]] += 1;
                }
            }
        }
 
        for(int i=1; i<=N; i++){
            if(an[i]==1){
                ac += 1;
                wa += wn[i];
            }
        }
 
        System.out.println(ac + " " + wa);
    }
}

Measured memory_bytes: 68472
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

#define drobucs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main() {
	drobucs;

	int n, a, b;
	cin >> n >> a >> b;

	if (a * n > b) {
		cout << b;
	}
	else {
		cout << a * n;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i,j,k;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,x;
  ll ans = 0;
  cin>>a>>b>>c>>x;
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        if(i*500+j*100+k*50 == x)ans++;
      }
    }
  }
  cout<<ans<<endl;
}

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


Measured memory_bytes: 256
import sys
from itertools import accumulate

# functions used
r = lambda: sys.stdin.readline().strip() #single: int(r()), line: map(int, r().split())
R = lambda: list(map(int, r().split())) # line: R(), lines: [R() for _ in range(n)]
Rmap = lambda: map(int, r().split())
# set inputs
N, C = R()
STC = [R() for _ in range(N)]
#  0.5sec as one unit
tbl = [[0]*(2*(10**5)+5) for _ in range(C)]

for s, t, c in STC:
    c -= 1
    # if we can record the programms continuously (ver1)
    if tbl[c][2*s] == -1:
        tbl[c][2*s] = 0
        tbl[c][2*t] = -1
    # if we can record the programms continuously (ver2)
    elif tbl[c][2*t-1] == 1:
        tbl[c][2*t-1] = 0
        tbl[c][2*s-1] = 1
    # else:
    else:
        tbl[c][2*s-1] = 1
        tbl[c][2*t] = -1

tbl2 = [list(accumulate(a)) for a in tbl]
for i in range(200002):
     for j in range(C):
         if tbl2[j][i]>1:
          	tbl2[j][i]=1

ans = max([sum(x) for x in zip(*tbl2)])
print(ans)

# tmp = [sum(x) for x in zip(*tbl2)]

# res = 0
# for i in range(200002):
#     cc = 0
#     for j in range(C):
#         if tbl2[j][i]:
#             cc += 1
#     res = max(res, cc)
# print(res)


Measured memory_bytes: 178388
function main(input){
  const lines = input.split('\n');
  const N = parseInt(lines.shift().split(' '));
  const ABC = lines.map(line => line.split(' ').map(x => parseInt(x)) );

  const DP = Array(3);
  DP[0] = Array(N).fill(Infinity);
  DP[1] = Array(N).fill(Infinity);
  DP[2] = Array(N).fill(Infinity);
  DP[0][0]=ABC[0][0];
  DP[1][0]=ABC[0][1];
  DP[2][0]=ABC[0][2];

  for(var i=1;i<N;i++){
    DP[0][i]=ABC[i][0] + Math.max(DP[1][i-1], DP[2][i-1]);
    DP[1][i]=ABC[i][1] + Math.max(DP[0][i-1], DP[2][i-1]);
    DP[2][i]=ABC[i][2] + Math.max(DP[0][i-1], DP[1][i-1]);
  }

  const result = Math.max(DP[0][N-1], DP[1][N-1], DP[2][N-1]);
  console.log(result);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 58360
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int bw=0,wb=0,i,n,res;
  string s,t;
  cin >> s;
  n=s.size();
  for(i=0;i<n;i++){
    t=s.substr(i,1);
    if(i%2==0){
      if(t=="0") wb++;
      else bw++;
    } else{
      if(t=="0") bw++;
      else wb++;
    }
  }
  res=min(bw,wb);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

struct UnionFind {
    UnionFind(int n) {
        parent.resize(n, -1);
        weight.resize(n, 0);
    }
    int find(int x) {
        if (parent[x] < 0)
            return x;
        else
            return parent[x] = find(parent[x]);
    }
    bool isSame(int x, int y) { return find(x) == find(y); }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            weight[x]++;
            return;
        }
        if (parent[x] < parent[y])
            swap(x, y);
        parent[x] += parent[y];
        parent[y] = x;
        weight[x] += weight[y] + 1;
    }
    int getSize(int x) { return -parent[find(x)]; }
    int getWeight(int x) { return weight[find(x)]; }

private:
    vector<int> parent;
    vector<int> weight;
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> p(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        cin >> p[i];
    }

    UnionFind uf(N + 1);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (uf.isSame(i, p[i])) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
def ans(a,b,c):
    return c - (a + b) / 2

a, b, c = map(int, input().split())
l =[a, b, c]

odd = 0
even = 0

for i in range(3):
    if l[i] % 2 == 0:
        even = even + 1
    else:
        odd = odd + 1

if abs(even - odd) == 3:
    l.sort()
    print(int(ans(l[0], l[1], l[2])))

elif even - odd == 1:
    for i in range(3):
        if l[i] % 2 == 0:
            l[i] = l[i] + 1
    
    l.sort()
    print(int(1 + ans(l[0], l[1], l[2])))

elif odd - even == 1:
    for i in range(3):
        if l[i] % 2 == 1:
            l[i] = l[i] + 1
    
    l.sort()
    print(int(1 + ans(l[0], l[1], l[2])))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z;
	return 0;
}

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

int main() {
  int N,A,B,ans;
  cin>>N;
  if(N==1)cout<<"Hello World"<<endl;
  else if(N==2){
    cin>>A>>B;
    ans=A+B;
    cout<<ans<<endl;
  }

}


Measured memory_bytes: 256
list1 =[]
total =0
for i in range(3):
  MM = input().split()
  a = int(MM[0])
  b = int(MM[1])
  list1.append(a)
  list1.append(b)
for i in range(5):
  x = list1.count(i)
  if x >2:
    total +=1
if total == 0:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9116
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n){
    vector<int> ans(n + 1, 0);
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            int su1 = (i * i + j * j + i * j);
            if(su1 >= n)
                break;
            for(int k = 1; k <= n; ++k){
                int su2 = su1 + (k * k + k * i + k * j);
                if(su2 > n)
                    break;
                ++ans[su2];
            }
        }
    }
    for(int i = 1; i <= n; ++i)
        cout << ans[i] << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include <cstring>
using namespace std;

int dp[1005];

int main() {
    int n,w,t=1;
    while(scanf("%d", &w), w) {
        memset(dp, -1, sizeof(dp));
        scanf("%d", &n);
        dp[0] = 0;

        int v,x;
        for(int i=0; i<n; ++i) {
            scanf("%d,%d", &v,&x);
            for(int j=w; j>=0; --j) {
                if(dp[j] == -1 || j+x > w) continue;
                dp[j+x] = max(dp[j+x],dp[j]+v);
            }
        }

        int ans = 0,ai = 0;
        for(int j=0; j<=w; ++j) {
            if(ans < dp[j]) ai = j;
            ans = max(ans, dp[j]);
        }
        printf("Case %d:\n%d\n%d\n", t++, ans, ai);
    }
}

Measured memory_bytes: 0
#include <iostream>
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 << 2 << endl;
	else cout << 3 << endl;

}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N; cin >> N;
	vector<int> T(N);
	int sum = 0;
	rep(i, N) {
		cin >> T[i];
		sum += T[i];
	}

	int M; cin >> M;
	vector<int> ans(M, sum);
	rep(i, M) {
		int p, x; cin >> p >> x;
		ans[i] -= T[p - 1] - x;
	}

	for (auto x : ans) cout << x << endl;
	return 0;
}


Measured memory_bytes: 3568
#include<cstdio>

using i64 = long long;

constexpr int maxn = 2000;
constexpr int p = 924844033;

template <class x_tp, class y_tp>
	inline int pls(const x_tp &x, const y_tp &y)
		{return (p <= x + y) ? (x + y - p) : (x + y);}

inline int io() {static int _; return scanf("%d", &_), _;}

int fac[maxn + 1],
	dp[maxn + 1][maxn + 1][4],
	f[maxn + 2][maxn + 1];

int main() {
	const int n = io(), k = io(), nmk = n - k, ndk = (n - 1) / k + 1;

	fac[0] = fac[1] = 1;
	for (int i = 2; i <= n; ++i)
		fac[i] = (i64)fac[i - 1] * i % p;

	for (int i = 1; i <= k; ++i)
		dp[i][0][0] = 1,
		dp[i][1][2] = (i <= nmk);
	for (int i = k + 1; i <= nmk; ++i) {
		dp[i][0][0] = pls(dp[i - k][0][0], dp[i - k][0][1]);
		dp[i][0][1] = pls(dp[i - k][0][2], dp[i - k][0][3]);
		for (int j = 1; j <= ndk; ++j) {
			dp[i][j][0] = pls(pls(dp[i - k][j][0], dp[i - k][j][1]), dp[i - k][j - 1][0]);
			dp[i][j][1] = pls(pls(dp[i - k][j][2], dp[i - k][j][3]), dp[i - k][j - 1][2]);
			dp[i][j][2] = pls(dp[i - k][j - 1][0], dp[i - k][j - 1][1]);
			dp[i][j][3] = pls(dp[i - k][j - 1][2], dp[i - k][j - 1][3]);
		}
	}
	for (int i = (k < nmk ? nmk : k) + 1; i <= n; ++i) {
		dp[i][0][0] = pls(dp[i - k][0][0], dp[i - k][0][1]);
		dp[i][0][1] = pls(dp[i - k][0][2], dp[i - k][0][3]);
		for (int j = 1; j <= ndk; ++j) {
			dp[i][j][0] = pls(pls(dp[i - k][j][0], dp[i - k][j][1]), dp[i - k][j - 1][0]);
			dp[i][j][1] = pls(pls(dp[i - k][j][2], dp[i - k][j][3]), dp[i - k][j - 1][2]);
		}
	}

	f[n + 1][0] = 1;
	for (int i = n, del; i != nmk; --i)
		for (int j = 0; j <= ndk; ++j)
			if (del = pls(pls(dp[i][j][0], dp[i][j][1]), pls(dp[i][j][2], dp[i][j][3])))
				for (int l = j; l <= n; ++l)
					f[i][l] = (i64)(f[i][l] + (i64)f[i + 1][l - j] * del) % p;

	int* const& las = f[nmk + 1];
	i64 ans = (n & 1) ? 0 : las[n];
	for (int i = 1; i <= n; i += 2)
		ans += (i64)((i64)las[i - 1] * fac[n - i + 1] - (i64)las[i] * fac[n - i]) % p;
	printf("%d", pls(ans % p, p));

	return 0;
}


Measured memory_bytes: 78080
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    int temp=1;
    for(int i=0;i<n;i++){
        if(a[i]==temp){
            temp++;
        }
        else{
            ans++;
        }
    }
    if(ans==n){
        cout<<-1<<endl;
    }
    else{
    cout<<ans<<endl;
}
    return 0;
}


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

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/
int solve(int x, int y) {
    if(x<=y) return y-x;
    return 2000000000;
}

/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int x, y; cin >> x >> y;
    cout << min({solve(x,y), solve(x,-y)+1, solve(-x,y)+1, solve(-x,-y)+2}) << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b)
{
	return a>b;
}
int a[100+1];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		a[x]=1;
	}
	int s=0;
	sort(a+1,a+100+1,cmp);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1)
		s++;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;

int a[12][12];

int main(int argc, char const *argv[]) {
  //入力
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }

  int ans = INF;      //最小値を求めるので、答えを最大化する
  rep(s, 1 << n) {    // s=0...0~1...1まで(2進数表示)
    int cost = 0;     //各パターンにおけるコスト
    vector<int> d(m); //各パターンにおけるそれぞれの理解度
    rep(i, n) {
      if (s >> i &
          1) { //ビットが立っているか判定。iビットシフトし1とANDをすると、最下位ビットに1が立ってるかわかる。
        cost += c[i];
        rep(j, m) d[j] += a[i][j];
      }
    }
    //全て目標値に達しているかと答えの更新
    bool flag = true;
    rep(j, m) if (d[j] < x) flag = false; //達していない時flagをfalseにする
    if (flag)
      ans = min(ans, cost); //達している時ansとcostを比較しansを更新する
  }
  //出力
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3548
#include <vector>
#include <math.h>
#include <string>
#include <ios>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int N, K;
	string S;
	cin >> N >> K >> S;

	
	cout << S.substr(0,K-1) << (char)tolower(S.c_str()[K - 1]) << S.substr(K,N) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

void solve(){
  ll n; cin >> n;
  vector<ll> a(n + 1), d(n + 1);
  for(int i = 0; i <= n; i++){
    cin >> a[i];
  }
  d[n] = a[n];
  for(int i = n - 1; i >= 0; i--){
    d[i] = d[i + 1] + a[i];
  }
  /*for(int i = 0; i <= n; i++){
    cout << d[i] << endl;
  }*/
  ll ans = 0, x = 1;
  bool ok = true;
  for(int i = 0; i <= n; i++){
    if((a[i] > x) || (a[i] == x && i != n) || x <= 0){
      ok = false;
      break;
    }
    ll y = min(x, d[i]);
    ans += y;
    x = (y - a[i]) * 2;
  }
  if(!ok) cout << -1 << endl;
  else cout << ans << endl;
  return;
}

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


Measured memory_bytes: 4840
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>

#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i = int(a); i >= int(b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
const double pi = acos(-1.0);

using namespace std;

typedef long long ll;

const int N = 10010;

int flg[N] = {1, 1}, ans[N] = {};

int cur[N], next[N];

int gen()
{
    memset(cur, 0, sizeof(cur));
    repi(i, 2, N) if (!flg[i]) {
        cur[0] = 1;
        memset(next, 0, sizeof(next));
        for (int j = i * i; j < N; j += i)
            flg[j] = 1;
        repi(j, i, N) {
            ans[j] += cur[j - i];
            next[j] += cur[j - i];
        }
        memcpy(cur, next, sizeof(cur));
    }
}

signed main()
{
    gen();

    for (int n; cin >> n && n; )
        cout << ans[n] << endl;

    return 0;
}

Measured memory_bytes: 1324
w, h, n = map(int, input().split())
l, r, d, u = 0, w, 0, h
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        if x > l:
            l = x
    elif a == 2:
        if x < r:
            r = x
    elif a == 3:
        if y > d:
            d = y
    elif a == 4:
        if y < u:
            u = y
    if l >= r or d >= u:
        print(0)
        break
else:
    print(w * h - l * h - (w - r) * h - (r - l) * d - (r - l) * (h - u))


Measured memory_bytes: 3064
from collections import deque
import sys

n = int(input())
li = deque()

def insertitem(item):
    li.appendleft(item)

def deleteitem(item):
    try:
        li.remove(item)
    except ValueError:
        pass

def deletefirst():
    li.popleft()

def deletelast():
    li.pop()

for i in sys.stdin:
    if i[6] == ' ':
        item = i[7:-1]
        if i[5] == 't':
            insertitem(item)
        else:
            deleteitem(item)
    elif i[6] == 'F':
        deletefirst()
    else:
        deletelast()

print(*li)


Measured memory_bytes: 69772
import numpy as np

N = int(input())
a = np.zeros((N,3))
for i in range(N):
    a[i][0],a[i][1],a[i][2] = map(int,input().split())

memo = np.zeros((N,3))

memo[0][0], memo[0][1], memo[0][2] = a[0][0],a[0][1],a[0][2]
day = 1

while (day < N):
    memo[day] = [max(memo[day-1][(x+1)%3],memo[day-1][(x+2)%3]) + a[day][x] \
                   for x in [0,1,2]]
    day += 1

print(int(max(memo[day - 1])))

Measured memory_bytes: 31156
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , k , ans = -INF , v[MAXN];

int main() {
    fast_io;

    cin >> n >> k;
    for(ll i = 0 ; i < n ; i++) cin >> v[i];

    for(ll l = 0 ; l < n ; l++){
        for(ll r = l - 1 ; r < n ; r++){
            multiset<ll> ms;
            for(ll i = 0 ; i < l ; i++){
                ms.insert(v[i]);
            }
            for(ll i = r + 1 ; i < n ; i++){
                ms.insert(v[i]);
            }
            if(ms.size() > k) continue;
            ll sum = 0 , t = k - SZ(ms);
            while(t > 0 && ms.size() > 0 && *ms.begin() < 0){
                t--;
                ms.erase(ms.begin());
            }
            for(auto &i : ms)   sum += i;
            ans = max(ans , sum);
        }
    }
    cout << ans << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
    }
    map<ll, ll> mp;
    ll ans = 0;
    rep(i, n) {
        ans += mp[i - a[i]];
        mp[a[i] + i]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27796
A,B,C,X,Y = map(int,input().split())

p = A+B
q = 2*C
z = min(X,Y)
r = abs(X-Y)
if p <= q :
    ans = A*X+B*Y
else :
    ans = q*z
    if z == Y :
        if A <= 2*C :
            ans += A*r
        else :
            ans += q*r
    else :
        if B <= 2*C :
            ans += B*r
        else :
            ans += q*r
print(ans)


Measured memory_bytes: 3060
def main():
    K, N = map(int,input().split())
    L = list(map(int,input().split()))
    
    d = [L[i+1]-L[i] for i in range(N-1)]
    d.append(L[0] - (L[-1]-K))
    
    m = max(d)
    ans = sum(d) - m
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 32368
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc =new Scanner(System.in);
		
		HashMap <String, String> Hashy = new HashMap<String, String>();
		Hashy.put("A", "T");
		Hashy.put("T", "A");
		Hashy.put("G", "C");
		Hashy.put("C", "G");
		String S = sc.next();
		System.out.println(Hashy.get(S));
	}

}


Measured memory_bytes: 35704
(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)


(defun main ()
  (let* ((k (read))
         (x (read)))
    (loop with init = t
          for i from (+ 1 (- x k)) below (+ x k)
          do (if init (setq init nil) (write-char #\ ))
             (princ i))
    (terpri)))

#-swank (main)


Measured memory_bytes: 5476
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int month, day, daycnt;
		int[] days = {31,29,31,30,31,30,31,31,30,31,30};
		String[] weekday = {"Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur"};
		
		for(;;){
			month = sc.nextInt();
			day = sc.nextInt();
			if(month == 0 && day == 0) break;

			daycnt = 0;
			for(int i = 0; i < month - 1; i++){
				daycnt += days[i];
			}

			System.out.println(weekday[(daycnt + day + 3) % 7] + "day");
		}
	}
}

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

using namespace std;
using ll = long long;

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

    ll N, K;
    cin >> N >> K;
    for (ll i = 0; i < N; ++i) {
        ll tmp;
        cin >> tmp;
    }
    for (ll i = 0; i < N; ++i) {
        if (K + (K - 1) * i >= N) {
            cout << i + 1 << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > A(N);
  std::vector<int > dp(N, -1);
  for (int i=0; i<N;i++){
    scanf("%d", &A[i]);
  }
  for (int i=0; i<N; i++){
    //printf("i=%d\n", i);
    auto itr = std::lower_bound(dp.begin(), dp.end(), A[i]);
    itr--;
    *itr = A[i];
  }
  int counter=N-1;
  while (counter>=0){
    //printf("dp[%d]=%d\n", counter, dp[counter]);
    if (dp[counter]==-1){
      break;
    }
    counter--;
  }
  std::cout << N-1-counter << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define inf 1000000000000000009
#define mod 1000000007
typedef long long ll;
using namespace std;
ll table[210][210];
int lis[8];
ll ans;
int n,m,k;

bool vis[8];
void DFS(int last,ll cnt){
	bool ful=true;
	lol(r,k)ful&=vis[r];
	if(ful){
		ans=min(ans,cnt);
		return;
	}
	lol(r,k){
		if(vis[r]==true)continue;
		vis[r]=true;
		ll tmp=cnt+table[lis[last]][lis[r]];
		DFS(r,tmp);
		vis[r]=false;
	}
}

int main(){
	cin>>n>>m>>k;
	lol(i,n){
		lol(j,n){
			if(i==j)table[i][j]=0;
			else table[i][j]=inf;
		}
	}
	lol(i,k){
		cin>>lis[i];
		lis[i]--;
	}
	lol(u,m){
		int a,b;ll c;
		cin>>a>>b>>c;
		a--,b--;
		table[a][b]=min(c,table[a][b]);
		table[b][a]=min(c,table[a][b]);
	}
	lol(r,n){
		lol(i,n){
			lol(j,n){
				ll tmp=table[i][r]+table[r][j];
				if(tmp<inf){
					table[i][j]=min(table[i][j],tmp);
				}
			}
		}
	}
	ans=inf;
	lol(r,k)vis[r]=false;
	lol(r,k){
		vis[r]=true;
		DFS(r,0);
		vis[r]=false;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  string s;
  int k;
  cin >> s >> k;
  set<string> t;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 1; j <= k; j++) {
      t.insert(s.substr(i, j));
    }
  }
  vector<string> v;
  for (auto e : t) {
    v.push_back(e);
  }
  cout << v[k - 1] << endl;
  return 0;
}


Measured memory_bytes: 1920