akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> pii;
int main() {
    int n, m; cin >> n >> m;
    vector<pii> vec(m);

    rep(i, m){
        cin >> vec.at(i).first >> vec.at(i).second;
        vec.at(i).first--;
        vec.at(i).second--;
    }
    sort(vec.begin(), vec.end(), [](const pii l_p, const pii r_p){
            return l_p.second != r_p.second ? l_p.second < r_p.second : l_p.first > r_p.first;
        });
    int brige = vec.at(0).second-1;
    int count=1;
    for(int i = 1; i < m; i++){
        if(vec.at(i).first <= brige && brige < vec.at(i).second) continue;
        brige = vec.at(i).second-1;
        count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 4048
#include<stdio.h>
char map[9][9];
int isC(int i,int j){
	if(map[i+1][j+1]=='1'){
		if(map[i+1][j]=='1'){
			if(map[i][j+1]=='1'){printf("A\n");return 1;}
			if(map[i+2][j+1]=='1'){printf("F\n");return 1;}
		}
		if(map[i][j+1]=='1'){printf("E\n");return 1;}
	}
	if(map[i][j+1]=='1'){
		if(i<7 &&map[i+1][j]=='1'){printf("G\n");return 1;}
		printf("C\n");return 1;
	}
	if( map[i+1][j]=='1'){
		if(j>0 &&map[i+1][j-1]=='1'){printf("D\n");return 1;}
		printf("B\n");return 1;
	}
}
f,j;int main(){
	int u,i=0;
	while(1){
		u=0;
		for(i=0;i<8;i++){
			if(scanf("%s",map[i])==EOF){
				f=1;
				break;
			};
		}
		if(f)break;
		for(i=0;i<8;i++){
			if(u)break;
			for(j=0;j<8;j++){
				if(map[i][j]=='1'){
					if(isC(i,j)){
						u=1;break;
					}
				}
			}
		}
	}
	exit(0);
}

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

int main() {
	int n;
	cin >> n;
	vector<long> B;

	for (int i = 0; i < n; i++) {
int a;
		cin >> a;
		B.push_back(a-i-1);
	}
	int med[2] = {};
sort(B.begin(),B.end());
	if (n % 2 == 0)med[0] = int(B[n/2] + B[n/2-1])/2,med[1] = med[0]+1;
	else med[0] = B[n / 2], med[1] = B[n / 2];

	long sum[2] = {};
	for (auto v : B) {
		sum[0] += abs(v - med[0]);
		sum[1] += abs(v - med[1]);
	}
	if (n % 2 == 0)cout << min(sum[0],sum[1]) << endl;
	 else cout << sum[0] << endl;
	return 0;

}

Measured memory_bytes: 2420
N=int(input())
S=input()
S2 = ""
for i in list(S):
	C = chr(ord(i) + N)
	if chr(ord(i) + N) > "Z":
		C = chr(ord(C) - ord("Z") + ord("A") - 1)
	S2 += C
print(S2)

Measured memory_bytes: 3060
W, H, N = map(int, input().split())
tyoten = [0, 0]
ans = W*H
for i in range(N):
    x, y, a = map(int, input().split())
    
    if a == 1:
        
        if tyoten[0] < x < W:
            tyoten[0] = x
        elif W <= x:
            ans = 0
    
    elif a == 2:
        
        if tyoten[0] < x < W:
            W = x
        elif x <= tyoten[0]:
            ans = 0
    
    elif a == 4:
        
        if tyoten[1] < y < H:
            H = y
        elif y <= tyoten[1]:
            ans = 0
        
    elif a == 3:
        
        if tyoten[1] < y < H:
            tyoten[1] = y
        elif H <= y:
            ans = 0

print(0 if ans == 0 else (W-tyoten[0])*(H-tyoten[1]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main() {
    ll n;
    cin>>n;
    ll bits = 0;
    while(n!=0) {
        bits++;
        n = n>>1;
    }
    ll ans = 1;
    while(bits) {
        ans = ans<<1;
        bits--;
    }
    cout<<ans-1;
}

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,n) for(int i=1;i<=n;i++)
typedef long long ll;

ll const INF = 9223372036854775807;

int main(){
	int n,k;
	cin >> n >> k;
	vector<pair<ll,ll>> p(n);
	vector<ll> x(n);
	vector<ll> y(n);
	rep(i,n){
		ll a,b;
		cin >> a >> b;
		x[i] = a;
		y[i] = b;
		p[i] = make_pair(a,b);
	}
	ll ans = INF;
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	for (int x1 = 0; x1 < n; ++x1) {
		for (int x2 = x1+1; x2 < n; ++x2) {
			for (int y1 = 0; y1 < n; ++y1) {
				for (int y2 = y1+1; y2 < n; ++y2) {
					ll lx = x[x1];
					ll rx = x[x2];
					ll by = y[y1];
					ll uy = y[y2];
					int count = 0;
					rep(i,n){
						ll px = p[i].first;
						ll py = p[i].second;
						if(lx <= px && px <= rx && by <= py && py <= uy) count++;
					}
					if(count >= k){
						ans = min(ans, (rx-lx)*(uy-by));
					}
				}
			}
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main(){
  char S[10];
  scanf("%s",S);
  int i,cnt;
  for(i=0;S[i]!='\0';i++){
    cnt++;
  }
  if(S[0]=='\0'){
      printf("No");
      return 0;
    }
  while(1){
    if(strncmp(S,"hi",2)==0){
      for(i=0;i<cnt;i++) S[i]=S[i+2];
      if(S[0]=='\0'){
        printf("Yes");
        return 0;
      }
    }
    else{
      printf("No");
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 128
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
void solve() {
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<string> arr(n);
	forn(i, n) cin >> arr[i];
	vvi pos(3);
	forn(i, n){
		if(arr[i] == "AB"){
			pos[0].pb(i);
		}else if(arr[i] == "BC"){
			pos[1].pb(i);
		}else{
			pos[2].pb(i);
		}
	}
	forn(i, 3) pos[i].pb(n);
	bool ok = true;
	string ans;
	forn(i, n){
		if(arr[i] == "AB"){
			if(!a && !b){
				ok = false;
				break;
			}
			else if(a == 1 && b == 1 && c == 0){
				int ind1 = *upper_bound(all(pos[1]), i);
				int ind2 = *upper_bound(all(pos[2]), i);
				if(ind1 < ind2){
					a--, b++;
					ans += "B";
				}else{
					b--, a++;
					ans += "A";
				}
			}
			else{
				if(a > b){
					ans += "B";
					b++, a--;
				}else{
					ans += "A";
					a++, b--;
				}
			}
		}else if(arr[i] == "BC"){
			if(!b && !c){
				ok = false;
				break;
			}
			else if(b == 1 && c == 1 && a == 0){
				int ind1 = *upper_bound(all(pos[0]), i);
				int ind2 = *upper_bound(all(pos[2]), i);
				if(ind1 < ind2){
					c--, b++;
					ans += "B";
				}else{
					b--, c++;
					ans += "C";
				}
			}
			else{
				if(c > b){
					ans += "B";
					b++, c--;
				}else{
					ans += "C";
					c++, b--;
				}
			}
		}else{
			if(!a && !c){
				ok = false;
				break;
			}
			else if(a == 1 && c == 1 && b == 0){
				int ind1 = *upper_bound(all(pos[0]), i);
				int ind2 = *upper_bound(all(pos[1]), i);
				if(ind1 < ind2){
					a++, c--;
					ans += "A";
				}else{
					a--, c++;
					ans += "C";
				}
			}
			else{
				if(a > c){
					ans += "C";
					c++, a--;
				}else{
					ans += "A";
					a++, c--;
				}
			}
		}
	}
	if(!ok) cout << "No";
	else{
		cout << "Yes\n";
		trav(c, ans) cout << c << '\n';
	}
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 7288
import java.util.*;
 
public class Main{
  
 public static void main(String arg[])
 {
  Scanner sc=new Scanner(System.in);
   String s=sc.next();
   if(s.charAt(s.length()-2)=='B')System.out.println("ARC");
   else System.out.println("ABC");
 }
}


Measured memory_bytes: 35620
/*
 * @Author: Kaizyn
 * @Date: 2020-06-01 08:30:28
 * @LastEditTime: 2020-06-01 20:23:47
 */ 
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int N = 3e3+7;

int n, s;
int a[N];
int dp[N][N];

inline void solve() {
  cin >> n >> s;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= s; ++j) {
      dp[i][j] = dp[i-1][j]*2%MOD;
    }
    for (int j = s; j >= a[i]; --j) {
      (dp[i][j] += dp[i-1][j-a[i]]) %= MOD;
    }
  }
  cout << dp[n][s] << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 38916
class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.children = children
        self.depth = 0
        
    def show_info(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print(self.children)


def set_node(i_s):
    i_l = list(map(int, i_s.split()))
    num = i_l[0]
    children = i_l[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        T[-1] -= n

def set_pd(n_i, parent, depth):
    node = T[n_i]
    node.parent = parent
    node.depth = depth
    for n in node.children:
        set_pd(n, n_i, depth + 1)


import sys

n = int(sys.stdin.readline())

T = [None] * n

T.append(int(n * (n - 1) / 2))

for x in sys.stdin.readlines():
    set_node(x)

set_pd(T[-1], -1, 0)

for n in T[:-1]:
    n.show_info()

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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << 0 << ln;
    } else {
        cout << 10 << ln;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <stdexcept>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

ll gcd(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
}

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int ctoi(const char c){
    if ('0' <= c && c <= '9') return (c-'0');
    return -1;
}

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

    int res, ans=INF;

    FOR(i,0,S.length()-2){
        if(S[i]=='7'){
            res = ctoi(S[i]) * 100 + ctoi(S[i + 1]) * 10 + ctoi(S[i + 2]);
            if(abs(753-res)<ans){
                ans = abs(753-res);
            }
        }else{
            res = ctoi(S[i]) * 100 + ctoi(S[i + 1]) * 10 + ctoi(S[i + 2]);
            if (abs(753 - res) < ans)
            {
                ans = abs(753 - res);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int N;
  char A[70];
  cin >> N;
  int res = 0; 
  for (int i = 0; i < N ; i++) {
    cin >> A[i];
    if (A[i] == 'C' && A[i-1] == 'B' && A[i-2] == 'A') {
      res += 1;
    }
  }
    cout << res << '\n';
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),


signed main(){
    FASTER;
    int x,k,d;cin>>x>>k>>d;
    int ans=INF;
    if(x<0){
        int stps=min(k,(-x/d));
        x=x+d*min(k,stps);
        k-=stps;
        if(k>0 && k&1){
            x+=d;
        }
        ans=abs(x);
    }else if(x>0){
        int stps=min(k,(x/d));
        x=x-d*min(k,stps);
        k-=stps;
        if(k>0 && k&1){
            x-=d;
        }
        ans=abs(x);
    }else{
        if(k&1)ans=d;
        else ans=0;
    }
    cout<<ans;
}






Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,m,nrlin[300001],nrcol[300001],k,ans;
map<pii,bool> f;
vector<int> lin[300001];
multiset<int> s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>k;
    for(int i=1;i<=k;i++)
    {
        int x,y;
        cin>>x>>y;
        f[{x,y}]=1;
        nrlin[x]++;
        nrcol[y]++;
        lin[x].push_back(y);
    }
    for(int i=1;i<=m;i++)
        s.insert(nrcol[i]);
    for(int i=1;i<=n;i++)
    {
        for(auto poz:lin[i])
        {
            s.erase(s.find(nrcol[poz]));
            s.insert(nrcol[poz]-1);
        }
        ll val=nrlin[i];
        auto it=s.end();
        it--;
        val+=(*it);
        ans=max(ans,val);
        for(auto poz:lin[i])
        {
            s.erase(s.find(nrcol[poz]-1));
            s.insert(nrcol[poz]);
        }
    }
    cout<<ans;
    return 0;
}



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

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int cnt = 0;
	while (A>=B){
		cnt++;
		B *= 2;
	}
	while (B>=C){
		cnt++;
		C *= 2;
	}
	if (cnt<=K)	cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int maxi = 0;
  int ans = 0;
  rep(i, n) {
    if (h[i] >= maxi) ++ans;
    maxi = max(maxi, h[i]);
  }
  out(ans);
}


Measured memory_bytes: 3560
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <vector>

int main(int argc, char* argv[]) {
  int64_t N;
  std::cin >> N;
  std::vector<int> a(N + 1, 0);
  std::vector<int> b(N + 1, 0);
  std::vector<int> c(N + 1, 0);
  for (int64_t i = 1; i <= N; ++i) {
    std::cin >> a[i] >> b[i] >> c[i];
  }

  std::vector<int64_t> dp_a(N + 1, 0);
  std::vector<int64_t> dp_b(N + 1, 0);
  std::vector<int64_t> dp_c(N + 1, 0);
  for (size_t i = 1; i <= N; ++i) {
    const auto j{i - 1};
    dp_a[i] = std::max({dp_b[j], dp_c[j]}) + a[i];
    dp_b[i] = std::max({dp_c[j], dp_a[j]}) + b[i];
    dp_c[i] = std::max({dp_a[j], dp_b[j]}) + c[i];
  }
  std::cout << std::max({dp_a[N], dp_b[N], dp_c[N]}) << std::endl;
  return 0;
}


Measured memory_bytes: 3712
# https://qiita.com/HUVEC/items/97739696ab51cacd10f2
N = int(input())
A = list(map(int, input().split()))
A.sort()                  #エラトステネスの篩にかけるためソート
Amax = A[-1]
dp = [1]*(Amax+1)         #Aの最大値までのエラトステネスの篩を作る。
ans = 0
for i in range(len(A)-1):
  p = A[i]
  if dp[p] == 1:          #A[i]がA[j]の倍数でないかをエラトステネスの篩でチェック
    for q in range(Amax//p+1):
      dp[p*q] = 0         #A[i]の倍数をすべて0にする
    if A[i] != A[i+1]: 
      ans += 1            #A[i]が重複していなければカウント
if dp[Amax] == 1:         #重複チェック時にレンジオーバーするためAmaxだけ別で判定 
  ans += 1
print(ans)

Measured memory_bytes: 116704
#include <stdio.h>
int gcd(int,int);
int main(){
  int x,y,z;
  scanf("%d%d",&x,&y);
  z=gcd(x,y);
  printf("%d\n",z);
  return 0;
}

int gcd(int x,int y){
  int tmp,r;
  if(x<y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
    return x;
    
}	



Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define fastio   ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll        long long
#define yes       printf("YES\n")
#define no        printf("NO\n")
#define pb        push_back
#define srtd(x)   sort(x.begin(),x.end())
#define rvsd(x)   reverse(x.begin(),x.end())
#define scn(n)    scanf("%lld",&n)
#define scab(a,b) scanf("%lld %lld",&a,&b)
#define pn(n)     printf("%lld",n)
#define pab(a,b)  printf(%lld %lld",a,b)
#define nl        cout<<endl
#define MAX       1000005
#define PI        acos(-1.0)
#define mmst(a,b) memset(a,b,sizeof(a));
#define FOR(i,n)  for(ll i=1;i<=n;i++)
#define LOP(i,n)  for(ll i=0;i<n;i++)
//Emama_Nahid//
using namespace std;
int main()
{
   ll a,b,c,i,j,k;
   scn(a);
   scab(b,c);
   j=c;
   LOP(i,10)
   {
       k=(a*j)-b;
       j=k;
       pn(k);
       nl;
   }


    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 repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  string s;
  int ans=0;
  cin>>s;
  rep(i,6){
    if(s[i]=='1')ans++;
  }
  cout<<ans<<endl;
}

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

int main( void )
{
    int x, y;
    cin >> x >> y;
    if ( x == 2 || y == 2 )
    {
        cout << "No";
    }
    else if ( x == 4 && ( y == 6 || y == 9 || y == 11 ) )
    {
        cout << "Yes";
    }
    else if ( x == 6 && ( y == 9 || y == 11 ) )
    {
        cout << "Yes";
    }
    else if ( x == 9 && ( y == 11 ) )
    {
        cout << "Yes";
    }
    else if ( x == 11 )
    {
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }

    return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
if(ch=='A')return 1;
else if(ch=='C')return 2;
else if(ch=='G')return 3;
else if(ch=='T')return 4;
else return 0;
}

long long getKey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0)return 0;
  }
return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++)H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
if(com[0]=='i'){
  insert(str);
}else{
  if(find(str)){
    printf("yes\n");
  }
else {
  printf("no\n");
}
}
  }
return 0;
}



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

int main(){
	int n,k,sum=0,now=1,ans=0;
	cin>>n>>k;
	for(;;){
		if(sum+now>n)break;
		else if(sum<=now*k)sum+=now,ans++;
		else now++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std ;
#define ulli unsigned long long int 
#define lli long long int
int mod = 1000000007 ;
/*ulli fact(int n){
    ulli ans = 1 ;
    for(int i=1;i<=n;i++){
        ans = (ans * (i%mod))%mod ;
        ans = ans%mod;
        ans = ans%mod ;
    }
    return ans%mod ;
}*/

void solve(){    
  
    int n ;
    cin>>n ;
    vector<int> bro(n,0) ;
    for(int i=0;i<n;i++)
        cin>>bro[i] ;
    sort(bro.begin(),bro.end()) ;
    n = bro.size() ;
    int count = 0 ;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(bro[i]+bro[j]>bro[k] and bro[i]!=bro[j] and bro[j]!=bro[k] and bro[i]!=bro[k])
                    count++ ;
            }
        }
    }
    cout<<count ;
}
int main()
{   
    cin.tie(0);
	ios_base::sync_with_stdio(false);  
    int t ;
    t = 1 ;
    while(t--)
        solve() ;
    return 0; 
}

Measured memory_bytes: 3648
package main

import (
	"fmt"
)

func main() {
	a := make([]int, 5)
	for i := 0; i <5;i++{
		fmt.Scan(&a[i])
	}

	sum := 0
	max := 0
	for i := 0; i < 5; i++ {
		sum += a[i]
		if v := a[i] % 10; v != 0 {
			p := 10 - v
			if p > max {
				max = p
			}
			sum += p
		}
	}
	fmt.Println(sum-max)

}


Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=300005;
const int mod=1e9+7;
int cnt[60];
int n;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        ll x;scanf("%lld",&x);
        for(int i=0;i<60;i++)if(x>>i&1)cnt[i]++;
    }
    ll ans=0;
    for(int i=0;i<60;i++){
        ans+=(1ll<<i)%mod*cnt[i]%mod*(n-cnt[i])%mod;
    }
    ans%=mod;
    printf("%lld\n",ans);
    return 0;
}

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


int main(){
    int A,B,K;
    cin>>A>>B>>K;

    for(int i = A; i <= min(B, A+K-1); i++)
        cout << i << endl;
    
    for(int i = max(B-K+1, A+K); i <= B; i++)
        cout << i << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+10;
const ll MOD=2019;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
ll take_p5(ll n){
	return (n*n*n*n*n);
}
int main() 
{
	int n ,a , b;
	string s, t;
	cin>>s>>t;
	string ans="";
	bool flag=true;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i])
			flag=false;
	}
	if(flag)
		cout<<"Yes";
	else
		cout<<"No";

}

Measured memory_bytes: 27032
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;

}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, W, w[maxn], v[maxn];
ll dp[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n >> W;
    for(int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];
    for(int i = 0; i < maxn; i++)
        dp[i] = -LLONG_MAX;
    dp[0] = 0;
    for(int i = 1; i <= n; i++)
        for(int j = W; j >= w[i]; j--)
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
    cout << *max_element(dp, dp + W + 1) << "\n";
    return 0;
}


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

#define deb(x) cout << #x << "=" << x << endl;
#define fo(i, n) for (ll i = 0; i < n; i++)
#define fo1(i, n) for (ll i = 1; i <= n; i++)i
#define sn(x) cin >> x;
#define pn(x) cout << x << "\n"
#define ps(x) cout << x << " ";
#define pb() cout << "\n";
#define sort(x) sort(x.begin(), x.end())

using namespace std;


typedef long long ll;
ll INF = INT_MAX;

void solve()
{

    ll n,jumps;
    cin >> n >> jumps;
    vector<ll>v(n),dp(n);

fo(i,n){
    cin>>v[i];
    dp[i]=INF;
}
   
dp[0]=0;
dp[1]=abs(v[1]-v[0]);

for(ll i=2;i<n;i++){
    for(ll j=1;j<=jumps;j++){
        if(j<=i)
           dp[i]= min(dp[i],abs(v[i-j]-v[i])+dp[i-j]);
       } 
   }

    cout << dp[n-1] << endl;

}

int main()
{

#ifndef ONLINE_JUDGE
   freopen("a.in", "r", stdin);
    freopen("err.txt", "w", stderr);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll test = 1;
    //cin >> test;
    while (test--){
        solve();
    }
}


Measured memory_bytes: 4788
import java.util.Scanner; 

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

    while (in.hasNext()) {
      String S = in.next();
      int former = Integer.valueOf(S.substring(0, 2));
      int later = Integer.valueOf(S.substring(2));

      String ans = "";
      if (former == 0) {
        if (later == 0 || later > 12) {
          ans = "NA";
        } else {
          ans = "YYMM";
        }
      } else if (former <= 12) {
        if (later == 0 || later > 12) {
          ans = "MMYY";
        } else if (later <= 12) {
          ans = "AMBIGUOUS";
        }        
      } else if (former > 12) {
        if (later == 0 || later > 12) {
          ans = "NA";
        } else {
          ans = "YYMM";
        }
      }

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

Measured memory_bytes: 21844
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>
#endif

// 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 <atomic>
#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>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int m = 0;
    int ans = 0;
    REP(i,n){
        int a;
        cin >> a;
        if(m<=a){
            m = a;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
k = []
s = []
M.times do |i|
  tmp = []
  s[i] = []
  tmp = gets.split.map(&:to_i)
  k[i] = tmp[0]
  s[i] = tmp.slice(1, k[i])
end
p = []
p = gets.split.map(&:to_i)

# N,Mは最大10なのでbit全探索でいけそう
# 電球の全bitパターン検索
ans = 0
# iのjbit目が1のときスイッチon，0のときoff
(1<<N).times do |i|
  # puts "bit = #{i.to_s(2)}"
  flag = false
  # 各電球が点灯するか調べる
  M.times do |j|
    cnt = 0
    # 自分のつながってる各スイッチがon/offか見る
    s[j].each do |sw|
      cnt += i[sw-1]
    end
    cnt %= 2 
    # puts "電球#{j} cnt = #{cnt}"
    # 1こでもonにならない電球があればbreak
    if cnt != p[j]
      flag = true
      break
    end
  end
  if !flag
    ans += 1
  end
end

puts ans

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;


struct SegmentTree
{
  int sz;
  vector< tree< pair< int, int >, null_type, less< pair< int, int > >, rb_tree_tag, tree_order_statistics_node_update > > seg;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.resize(2 * sz - 1);
  }

  int query(int a, int b, int lower, int upper, int k, int l, int r)
  {
    if(a >= r || b <= l) {
      return (0);
    } else if(a <= l && r <= b) {
      return (seg[k].order_of_key(make_pair(upper, -1)) - seg[k].order_of_key(make_pair(lower, -1)));
    } else {
      return (query(a, b, lower, upper, 2 * k + 1, l, (l + r) >> 1) + query(a, b, lower, upper, 2 * k + 2, (l + r) >> 1, r));
    }
  }

  int query(int a, int b, int l, int r)
  {
    return (query(a, b, l, r, 0, 0, sz));
  }

  void set(int k, int x, bool type)
  {
    int pv = k;
    k += sz - 1;
    if(type) seg[k].insert({x, pv});
    else seg[k].erase({x, pv});
    while(k > 0) {
      k = (k - 1) >> 1;
      if(type) seg[k].insert({x, pv});
      else seg[k].erase({x, pv});
    }
  }
};

int main()
{
  int H, W, T, Q;
  scanf("%d %d %d %d", &H, &W, &T, &Q);

  SegmentTree tree1(H), tree2(H);
  queue< tuple< int, int, int > > addev;
  int add = 0;

  for(int i = 0; i < Q; i++) {
    int t, c, h, w;
    scanf("%d %d %d %d", &t, &c, &h, &w);

    while(!addev.empty() && get< 0 >(addev.front()) <= t) {
      int x, y, z;
      tie(x, y, z) = addev.front();
      addev.pop();
      tree1.set(y, z, false);
      tree2.set(y, z, true);
      --add;
    }

    if(c == 0) {
      addev.emplace(t + T, --h, --w);
      tree1.set(h, w, true);
      ++add;
    } else if(c == 1) {
      tree2.set(--h, --w, false);
    } else {
      int h2, w2;
      scanf("%d %d", &h2, &w2);
      --h, --w;
      printf("%d %d\n", tree2.query(h, h2, w, w2), tree1.query(h, h2, w, w2));
    }
  }
}

Measured memory_bytes: 79892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
#define mod 1000000007
class DSU{
    ll * rank, * parent, n;
public:
    DSU(ll n){
        rank=new ll[n];
        parent=new ll[n];
        this->n=n;
        makeset();
    }
    void makeset(){
        for(ll i=0;i<n;i++){
            parent[i]=i;
        }
    }
    ll find(ll x){
        if(parent[x]!=x){
            parent[x]=find(parent[x]);
        }
        return parent[x];
    }
    void Union(ll x, ll y){
        ll xset=find(x);
        ll yset=find(y);
        if(xset==yset){
            return;
        }
        if(rank[xset]<rank[yset]){
            parent[xset]=yset;
        }
        else if(rank[xset]>rank[yset]){
            parent[yset]=xset;
        }
        else{
            parent[xset]=parent[yset];
            rank[yset]++;
        }
    }
};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    DSU dsu(n);
    REP(i,m){
        ll u,v;
        cin>>u>>v;
        u--;
        v--;
        dsu.Union(u,v);
    }
    set<ll> s;
    REP(i,n){
        s.insert(dsu.find(i));
    }
    cout<<s.size()-1<<endl;
}


Measured memory_bytes: 8476
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(N)]

AB.sort()

ans=0

for ab in AB:
    if M==0:
        break
    if ab[1]<=M:
        M-=ab[1]
        ans+=ab[0]*ab[1]
    elif ab[1]>M:
        ans+=ab[0]*M
        M-=M

print(ans)


Measured memory_bytes: 27884
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		long n = fs.nextLong();
		
		if(n == 1) {
			System.out.println(0);
			return;
		}
		
		int sqrt = (int)Math.sqrt(n)+1;
		
//		HashMap<Long, Integer> insuMap = new HashMap<>();
		
		int[] insuArr = new int[sqrt+1];
		
		for(int i = 2; i <= sqrt; i++) {
			while(n % i == 0) {
				insuArr[i]++;
				n /= i;
			}
		}
		
		long ans = 0;
		
		if(n != 1) {
			ans++;
		}
		
		for(int i = 0; i <= sqrt; i++) {
			
			if(insuArr[i] > 0) {
				int now = 1;
				while(insuArr[i] >= now) {
					ans++;
					insuArr[i] -= now;
					now++;
				}
			}
		}
		
		System.out.println(ans);
		
	}	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


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

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vin(v,n) copy_n(istream_iterator<int>(cin),n,back_inserter(v));
#define all(v) v.begin(),v.end()
#define INF 2000000000
#define MOD 1000000007
#define ll long long 
#define vi vector<int>
#define ii pair<int,int>
#define si set<int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define f1(i,a,b) for(int i = a;i<b;i++)
#define f2(i,a,b) for(int i = a;i<=b;i++)

using namespace std;

const int N = 3005;
int dp[N-1][N-1][2];
vi a;

int solve(int l, int r, int turn)
{
	if(r<l)
		return 0;
	if(dp[l][r][turn]!=-1)
		return dp[l][r][turn];

	if(turn==1)
		dp[l][r][1] = max(a[l]+solve(l+1,r,0), a[r]+solve(l,r-1,0));
	else
		dp[l][r][0] = min(-a[l]+solve(l+1,r,1), -a[r]+solve(l,r-1,1));
	
	return dp[l][r][turn];
	
}

int32_t main() 
{
	IOS;
	int n;
	cin >> n;
	vin(a,n);
	f1(i,0,n) f1(j,0,n) dp[i][j][0] = -1, dp[i][j][1] = -1;

	cout << solve(0,n-1,1);
}


Measured memory_bytes: 141312
iipt=lambda:int(input())
miipt=lambda: list(map(int, input().split()))

n,l,t=miipt()
a=[miipt() for i in range(n)]
d=0
for x,w in a:
    d+=(x+(t if w==1 else -t))//l
d=d%n

e=[(x+(t if w==1 else -t))%l for x, w in a]

e.sort()


for i in range(n):
    print(e[(d+i)%n])

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

int main(){
int N;
  cin>>N;
  vector<int>moji(N);
  for(int i=0;i<N;i++){
  cin>>moji.at(i);
  }
  bool nazo=true;
  sort(moji.begin(),moji.end());
  for(int i=0;i<N-1;i++){
  	if(moji.at(i)==moji.at(i+1)){
    nazo=false;
    }
  }
  if(nazo){
  cout<<"YES"<<endl;
  }
  else{
  cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 4024
/* 十 聖イシドールスよ、迷えるプログラマを導き給え！ 十 */
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

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

const long long INF = 1LL << 60;

int main()
{
	int N;
	std::cin >> N;
	std::vector<int> d(N);
	rep(i, N)	std::cin >> d[i];
	
	std::sort( d.begin(), d.end() );

	// 1:存在するか?
	int mid = d.size() / 2;
	mid--;	// index 
	bool isOk = false;
	if( d[mid] != d[mid+1] )
	{
		isOk = true;
	}

	// 2:何通りあるか?
	int ans = d[mid+1] - d[mid];

	if( isOk == true )
	{
		std::cout << ans << std::endl;
	}
	else
	{
		std::cout << 0 << std::endl;
	}
	
    return 0;
}


Measured memory_bytes: 3800
import numpy as np

n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))

L = len(f'{10**12:b}')
res = 0
for i in range(-1, L):
    if i != -1 and not (k >> i) & 1:
        continue
    val = 0
    for j in range(L):
        d = np.count_nonzero((a >> j) & 1)
        if i < j:
            if (k >> j) & 1:
                val += (n-d) * 2**j
            else:
                val += d * 2**j
        elif i == j:
            val += d * 2**j
        else:
            val += max(d, n-d) * 2**j
    res = max(res, val)
print(res)


Measured memory_bytes: 38372
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define mod 1000000007
using namespace std;

void Onigiri()
{
  string s;
  cin>>s;
  for(auto x:s)
    if(x=='7'){cout<<"Yes";return;}
cout<<"No";


}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 3772
package main

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

var inputs [4]int

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var keepStr string
	fmt.Fscan(r, &keepStr)

	keep, _ := strconv.Atoi(keepStr)

	var tmp int
	forDiv := 1000
	for i := 0; i < 4; i++ {
		tmp = keep / forDiv
		inputs[i] = tmp
		keep -= tmp * forDiv
		forDiv /= 10
	}

	ops := search()

	for i := 0; i < 3; i++ {
		fmt.Fprint(w, inputs[i])
		if ops[i] == 0 {
			fmt.Fprint(w, "+")
		} else {
			fmt.Fprintf(w, "-")
		}
	}
	fmt.Fprintf(w, "%d=7\n", inputs[3])

}

func search() [3]int {
	var ops [3]int
	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			for k := 0; k < 2; k++ {
				tmp := inputs[0]
				if i == 0 {
					tmp += inputs[1]
				} else {
					tmp -= inputs[1]
				}

				if j == 0 {
					tmp += inputs[2]
				} else {
					tmp -= inputs[2]
				}

				if k == 0 {
					tmp += inputs[3]
				} else {
					tmp -= inputs[3]
				}

				if tmp == 7 {
					ops = [3]int{i, j, k}
					return ops
				}
			}
		}
	}

	return ops
}


Measured memory_bytes: 1844
#include <stdio.h>
int main()
{
    char str[1001], meirei[10], p[1001], c;
    int q, i, j, k, a, b;
    scanf("%s", str);
    scanf("%d", &q);
    for(i=0; i<q; i++){
        scanf("%s", meirei);
        if(strcmp(meirei, "print")==0){
            scanf("%d %d", &a, &b);
            for(j=a; j<b+1; j++){
            printf("%c", str[j]);
            }
            printf("\n");
        } else if(strcmp(meirei, "reverse")==0){
            scanf("%d %d", &a, &b);
            for(j=0; j<b-a; j++){
                for(k=b-j; k>a; k--){
                    c=str[a];
                    str[a]=str[k];
                    str[k]=c;
                }
            }
        } else if(strcmp(meirei, "replace")==0){
            scanf("%d %d %s", &a, &b, p);
            for(j=0; j<b-a+1; j++){
                c=str[a+j];
                str[a+j]=p[j];
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
int bsrc(int arr[],int x,int n){
    int l=0,m,h=n-1;
    while(l<=h){
        m=(l+h)/2;
        if(arr[m]==x){
            return 1;
        }

        else if(arr[m]>x) h=m-1;
        else l=m+1;
    }
    return 0;
}
int main ()
{
    int A[10];
    A[9]='\0';
    for(int i=0;i<9;i++){
        cin>>A[i];
    }
    int N;
    cin>>N;
    int B[N];
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    sort(B,B+N);
    int C[10];
    C[9]='\0';
    for(int i=0;i<9;i++){
        C[i]= bsrc(B,A[i],N);
    }
    if(C[0]*C[1]*C[2]==1) cout<<"Yes";
    else if(C[0]*C[3]*C[6]==1) cout<<"Yes";
    else if(C[3]*C[4]*C[5]==1) cout<<"Yes";
    else if(C[8]*C[7]*C[6]==1) cout<<"Yes";
    else if(C[1]*C[4]*C[7]==1) cout<<"Yes";
    else if(C[2]*C[5]*C[8]==1) cout<<"Yes";
    else if(C[0]*C[4]*C[8]==1) cout<<"Yes";
    else if(C[2]*C[4]*C[6]==1) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		switch(S) {
		case "Sunny":
			System.out.println("Cloudy");
			break;
		case "Cloudy":
			System.out.println("Rainy");
			break;
		case "Rainy":
			System.out.println("Sunny");
			break;
		}

	}
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n+1);
  for(int i=0; i<n+1; ++i){
    cin >> a[i];
  }
  vector<int> b(n);
   for(int i=0; i<n; ++i){
    cin >> b[i];
  }
  
  long ans=0;
  for(int i=0; i<n; ++i){
    if(a[i]<=b[i]){
      ans+=a[i];
      b[i]-=a[i]; 
      if(a[i+1] >= b[i]){
        ans += b[i];
        a[i+1]-=b[i];
        b[i]=0;
      }else{
        ans += a[i+1];
        a[i+1]=0;
        b[i]-=a[i+1];
      }      
    }else{
      ans+=b[i];
      b[i]=0;
    }
   
  
  }
  if(a[n]>b[n-1]){
    ans+=b[n-1];
     
  
  }else{
    ans+=a[n];
      
  
  }
    
  cout << ans << endl;
  
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <functional>
#include <array>
#include <climits>
//#include "debug.h"
using namespace std;
 
#define A first
#define B second
 
typedef long long ll;
constexpr int MOD = 1e9 + 7;

void solve() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll ans = max({A * C, A * D, B * C, B * D});
  cout << ans;
}   
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  T = 1;
  //cin >> T;
  while(T--){
    solve();
  }
}

Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split()))
count = 0
s = 0

while(True):
    for i in range(len(A)):
        s += A[i]%2
    
    if s != 0:
        break
    else:
        A = list(map(lambda x:x/2,A))
        count +=1

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,a,b;
    cin>>k>>a>>b;
    if(b-a<=2 || k<=a-1) cout<<1+k<<endl;
    else{
      k-=a-1;
      a+=(b-a)*(k/2);
      if(k%2==1) a++;
      cout<<a<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
  cin>>n>>m;
  int ans=(n*(n-1))/2;
  ans+=(m*(m-1))/2;
  cout<<ans<<endl;
  
  
  
  
  
  
  
  
  
  
  
    return 0;
}

Measured memory_bytes: 256