akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define pool(i,m,n) for(lli i=m; i>n; i++)
#define maxe *max_element
#define mine *min_element
#define plli pair<lli, lli>
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define mp make_pair
#define inp1(a) cin >> a
#define inp2(a, b) cin >> a >> b
#define inp3(a, b, c) cin >> a >> b >> c
#define inp4(a, b, c, d) cin >> a >> b >> c >> d
#define inp5(a, b, c, d, e) cin >> a >> b >> c >> d >> e
#define inp6(a, b, c, d, e, f) cin >> a >> b >> c >> d >> e >> f
#define pr0() cout << " "
#define pr1(a) cout << a << " "
#define pr2(a, b) cout << a << " " << b << " "
#define pr3(a, b, c) cout << a << " " << b << " " << c << " "
#define pr4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << " "
#define emp emplace //used to push a pair etc..
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x, 0;
#define all(v) v.begin(),v.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
//especially for deque both sides dynamic
#define pf push_front
//list doubly linked lists can insert at mid. splice fn can be used
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli modi(lli n,lli m=mod){ 
    if(n==0) return 0;
    n%=m;
    n+=m;
    n%=m;
    return n;
}
 
lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}
const lli INF=1e18;
const lli N=2e5+5;
lli a[N]={0},b[N]={0};

int32_t main(){
    fast_io
    lli i = 0,j=0;
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    
    vt v,v1,v2;
    lli a,b,c,d,e,f,n,k;

    cin >> n >> a >> b;
    cout << (n/(a+b))*a+min((n%(a+b)),a);


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, M;cin >> N >> M;
	int sum = 0;
	rep(i, 0, M) {
		int a; cin >> a;
		sum += a;
	}
	N -= sum;
	cout << (N >= 0 ? N : -1) << "\n";

	return 0;
}

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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

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

	for(int d = M / N; d > 0; d--){
		if(M % d == 0){
			cout << d << endl;
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 256
import numpy as np
a,b,x=map(int, input().split())
V=a*a*b
if(V/2<x):
  print(np.rad2deg(np.arctan(2*(V-x)/(a*a*a))))
else:
  print(90-np.rad2deg(np.arctan(2*x/(a*b*b))))
  

Measured memory_bytes: 12396
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
 
const double EPS = 1e-8, PI = acos(-1);
const int MAXN = 105;
 
struct point {
	double x, y;
	int id;
	
	point() {}
	point(double _x, double _y, int _id = -1) : x(_x), y(_y), id(_id) {}
	bool operator<(const point &another) const;
};
 
struct ans {
	double val;
	int id;
 
	ans() {}
	bool operator<(const ans &another) const
	{
		return id < another.id;
	}
};
 
int tot, n;
point p[MAXN], s[MAXN], normal[MAXN];
ans an[MAXN];
bool visited[MAXN];
 
int sgn(double x)
{
	if (fabs(x) < EPS) return 0;
	return (x > 0 ? 1 : -1);
}
 
double det(const point &a1, const point &a2, const point &b1, const point &b2)
{
	return ((a2.x - a1.x) * (b2.y - b1.y) - (a2.y - a1.y) * (b2.x - b1.x));
}
 
double dot(const point &a1, const point &a2, const point &b1, const point &b2)
{
	return ((a2.x - a1.x) * (b2.x - b1.x) + (a2.y - a1.y) * (b2.y - b1.y));
}
 
double dist(const point &p1, const point &p2)
{
	return sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));
}
 
bool point::operator<(const point &another) const
{
	if (sgn(det(p[0], *this, p[0], another)) == 0)
		return dist(p[0], *this) < dist(p[0], another);
	else
		return det(p[0], *this, p[0], another) > 0;
}
 
void graham()
{
	double min_y = p[0].y, min_x = p[0].x;
	int index = 0;
	for (int i = 1; i <= n - 1; i++) {
		if (p[i].y < min_y || (sgn(p[i].y - min_y) == 0 && p[i].x < min_x)) {
			min_y = p[i].y;
			min_x = p[i].x;
			index = i;
		}
	}
	swap(p[0], p[index]);
	sort(p + 1, p + n);
	s[0] = p[0]; s[1] = p[1];
	tot = 2;
	for (int i = 2; i <= n - 1; i++) {
		while (tot >= 2 && sgn(det(s[tot - 1], p[i], s[tot - 1], s[tot - 2]) < 0)) tot--;
		s[tot++] = p[i];
	}
}
 
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf %lf", &p[i].x, &p[i].y);
		p[i].id = i;
	}
	graham();
	for (int i = 0; i < tot; i++) {
		if (i == 0) {
			normal[i].y = -(s[i].x - s[tot - 1].x);
			normal[i].x = s[i].y - s[tot - 1].y;
			normal[i].id = s[i].id;
		}
		else {
			normal[i].y = -(s[i].x - s[i - 1].x);
			normal[i].x = s[i].y - s[i - 1].y;
			normal[i].id = s[i].id;
		}
	}
	point zero(0, 0);
	for (int i = 0; i < tot; i++) {
		if (i == tot - 1) {
			an[i].val = acos(dot(zero, normal[i], zero, normal[0]) / dist(zero, normal[i]) / dist(zero, normal[0])) / PI / 2;
			an[i].id = normal[i].id;
		}
		else {
			an[i].val = acos(dot(zero, normal[i], zero, normal[i + 1]) / dist(zero, normal[i]) / dist(zero, normal[i + 1])) / PI / 2;
			an[i].id = normal[i].id;
		}
	}
	memset(visited, false, sizeof(visited));
	for (int i = 0; i < tot; i++) visited[s[i].id] = true;
	for (int i = 0; i < n; i++)
		if (!visited[i]) {
			an[tot].val = 0.0000000;
			an[tot++].id = i;
		}
	sort(an, an + n);
	for (int i = 0; i < n; i++) printf("%.8f\n", an[i].val);
	return 0;
}



Measured memory_bytes: 384
#include<iostream>
#define ll long long
using namespace std;

ll MOD = 1e9 + 7;

int a[100005];

int main(){
	int n,d;
	cin >> n;
	int ans = 1;
	if(n%2 == 0){
		for(int i = 1; i<=n; i++){
			cin >> d;  
			a[d]++;
			if(d % 2 == 0 || a[d] > 2){
				ans = 0;
				break;
			}
			else if(a[d] == 1){
				ans = (ans*2) % MOD;
			}
		}
		cout << ans;
	}
	else{
		for(int i = 1; i<=n; i++){
			cin >> d;
			a[d]++;
			if(d % 2 ==1 || a[d] > 2 || (a[0] > 1)){
				ans= 0;
				break;
			}
			else if (a[d] == 1 && d != 0)
			{
				ans = (ans*2) % MOD;
			}
		}
		cout << ans;
	}
	
	return 0;
}  

Measured memory_bytes: 3916
#include<iostream>
using namespace std;
int main(){
	int H, W;
	while (1){
		cin >> H>>W;
		if (H == 0 & W == 0)break;
		for (int i = 0; i < H; i++){
			for (int k = 0; k < W; k++){
				if (i == 0 || k == 0 || i==H-1 || k==W-1){
					cout << "#";
				}
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}
	

Measured memory_bytes: 2980
def readln():
    return list(map(int, input().split()))


S = input()
tmp = 0
ans = 0
for s in S:
    if s == 'A' or s == 'T' or s == 'C' or s == 'G':
        tmp += 1
        ans = max(tmp, ans)
    else:
        tmp = 0

print(ans)


Measured memory_bytes: 2940
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int n;
    cin>>n;

    int ans=n+n*n+n*n*n;
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n;
char c;
unordered_set<char> st;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> c;
        st.insert(c);
    }
    if (st.size() == 3)
        cout << "Three" << endl;
    else
        cout << "Four" << endl;
    return 0;
}


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

int main() {
    int N,M;
    cin >> N >> M; 
    vector<int>cnt(M);
    for(int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for(int j = 0; j < K; j++) {
            int A;
            cin >> A;
            cnt[A-1]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
        if(cnt[i] == N) {
            ans++;
        }
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

a, b, c, x, y = inintm()

ans = 0

for i in range(max(x, y)):
    if x != 0 and y != 0:
        if c*2 < a + b:
            ans += c*2
            x -= 1
            y -= 1
        else:
            ans = ans + a + b
            x -= 1
            y -= 1
    else:
        if x == 0:
            if c*2 < b:
                ans += c*2
                y -= 1
            else:
                ans += b
                y -= 1
        else:
            if c*2 < a:
                ans += c*2
                x -= 1
            else:
                ans += a
                x -= 1

print(ans)


Measured memory_bytes: 64360
#include<iostream> //cinなど
#include<string> //文字列
#include<algorithm> //sort など
#include<math.h> //paw(冪乗など)
#include<set> // 集合
#include<map> //写像
#include<stdio.h> //printf
#include<stack>

using namespace std;
int main(){
  int a,b,c;
  cin>> a >> b >> c ;
  if(b-a == c-b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline

lst1 = [list(map(int,readline().split())) for i in range(3)]

n = int(readline())

lstans = [[0]*3 for i in range(3)]

for i in range(n):
    b = int(readline())
    for i in range(3):
        for j in range(3):
            if lst1[i][j] == b:
                lstans[i][j] = 1
flag = 0
for i in range(3):
    if sum(lstans[i]) == 3:
        flag = 1
for i in range(3):
    res = 0
    for j in range(3):
        res += lstans[j][i]
    if res == 3:
        flag = 1

if lstans[0][0] + lstans[1][1] + lstans[2][2] == 3:
    flag = 1
if lstans[0][2] + lstans[1][1] + lstans[2][0] == 3:
    flag = 1

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;
#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

pii in[55];

int main() {
	int N, i, j, k, l;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &in[i].first, &in[i].second);

	if (N == 2) {
		db d = (in[2].first - in[1].first)*(in[2].first - in[1].first) + (in[2].second - in[1].second)*(in[2].second - in[1].second);
		return !printf("%.20lf\n", sqrt(d) / 2);
	}

	sort(in + 1, in + N + 1);

	db ans = LL_INF;
	for (i = 1; i <= N; i++) {
		for (j = 1; j < i; j++) {
			int x1 = in[i].first, y1 = in[i].second;
			int x2 = in[j].first, y2 = in[j].second;

			db X = (x1 + x2) / 2.0, Y = (y1 + y2) / 2.0;
			db d = 0;
			for (l = 1; l <= N; l++) {
				db d2 = (in[l].first - X)*(in[l].first - X) + (in[l].second - Y)*(in[l].second - Y);
				d = max(d, d2);
			}
			ans = min(ans, sqrt(d));
		}
	}
	for (i = 1; i <= N; i++) {
		for (j = 1; j < i; j++) {
			for (k = 1; k < j; k++) {
				int x1 = in[i].first, y1 = in[i].second;
				int x2 = in[j].first, y2 = in[j].second;
				int x3 = in[k].first, y3 = in[k].second;

				db a1 = (x1 - x2), b1 = (y1 - y2);
				db c1 = a1 * (x1 + x2) / 2 + b1 * (y1 + y2) / 2;
				
				db a2 = (x1 - x3), b2 = (y1 - y3);
				db c2 = a2 * (x1 + x3) / 2 + b2 * (y1 + y3) / 2;

				if (abs(a1*b2 - a2 * b1) < 1e-3) continue;

				db X = (c1*b2 - c2 * b1) / (a1*b2 - a2 * b1);
				db Y = (c1*a2 - c2 * a1) / (b1*a2 - b2 * a1);

				db d = 0;
				for (l = 1; l <= N; l++) {
					db d2 = (in[l].first - X)*(in[l].first - X) + (in[l].second - Y)*(in[l].second - Y);
					d = max(d, d2);
				}
				ans = min(ans, sqrt(d));
			}
		}
	}

	return !printf("%.20lf\n", ans);
}

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

prev_x = 0
prev_y = 0
prev_t = 0
for i in range(N):

    x_i = abs(txy[i][1] - prev_x)
    y_i = abs(txy[i][2] - prev_y)
    t_i = (txy[i][0] - prev_t) - x_i - y_i

    if t_i == 0 or (t_i > 0 and t_i % 2 == 0):
        prev_t, prev_x, prev_y = txy[i][0], txy[i][1], txy[i][2]
    else:
        print('No')
        break
else:
    print('Yes')
        





Measured memory_bytes: 27380
if __name__ == '__main__':
    char = list('abcdefghijklmnopqrstuvwxyz')
    S = input()
    for i in range(len(S)):
        if S[i:i+1] in char:
            char.remove(S[i:i+1])
    if len(char) == 0:
        print('None')
    else:
        print(char[0])


Measured memory_bytes: 3188
N=int(input())
X=list(map(int, input().split()))
 
import copy
X_sort=copy.deepcopy(X)
X_sort.sort()
X_sort
 
median_control=(X_sort[N//2-1]+X_sort[N//2])/2
for i in range (N):
    if X[i]>median_control:
        print (X_sort[N//2-1])
    if X[i]<=median_control:
        print (X_sort[N//2])
 

Measured memory_bytes: 25620
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N;
  ll a[SIZE];

  scanf("%d", &N);

  ll base = 0;

  for (int i = 0; i < N; i++) {
    scanf("%lld", a + i);
    base ^= a[i];
  }

  for (int i = 0; i < N; i++) {
    printf("%lld%c", a[i] ^ base, " \n"[i + 1 == N]);
  }

  return 0;
}


Measured memory_bytes: 5348
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    rep(i, 0, N) { cin >> A[i]; }
    int max = 0;
    int max2 = 0;
    int maxi = 0;
    rep(i, 0, N) {
        if(max < A[i]) {
            max2 = max;
            max = A[i];
            maxi = i;
        } else if(max2 < A[i]) {
            max2 = A[i];
        }
    }
    rep(i, 0, N) {
        if(i == maxi) {
            cout << max2 << endl;
        } else {
            cout << max << endl;
        }
    }
}

Measured memory_bytes: 3200
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
L = LI()
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            Li = [L[i], L[j], L[k]]
            if len(set(Li)) != 3:
                continue
            Li.sort()
            if Li[2] < Li[0] + Li[1]:
                cnt += 1

print(cnt)



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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N; cin >> N;
  int temp = 0;
  int min = 100;
  for(int i=1; i<N; ++i) {
    int temp = findSumOfDigits(i) + findSumOfDigits(N-i);
      if (temp < min) min = temp;
  }
  cout << min << endl;
}

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

int exp();
int factor();
int term();

int factor() {
  int num=0;
  while('0' <= str[p] && str[p] <= '9') {
    num*=10;
    num += str[p] - '0';
    p++;
  }

  //  cout <<"one"<< num << endl;
  if(num != 0) return num;

  else if (str[p] == '('){
    p++;
    num = exp();
  }
  if(str[p] == ')'){
    // cout <<"two"<< num << endl;
    p++;
    return num;
  } 
  return 0;
}

int term(){
 int val = factor();
  while(str[p] == '*' || str[p] == '/') {
    if(str[p] == '*') {
      p++;
      val *= factor();
    } else if(str[p] == '/'){
      p++;
      val /= factor();
    }
  }

  return val;
}
 
int exp() {
  int val = term();
  while(str[p] == '+' || str[p] == '-') {
    if(str[p] == '+') {
      p++;
      val += term();
    } else if(str[p] == '-'){
      p++;
      val -= term();
    }
  }

  return val;
}

int main() {
  int n;

  cin >> n;
  
  for(int i=0;i<n;i++) {
    p = 0;
  cin >> str;
  cout << exp() << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000009;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[210000];
int main(){
	
	int a;scanf("%d",&a);
	int b=0;
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<a;i++)b^=p[i];
	for(int i=0;i<a;i++){
		if(i)printf(" ");
		printf("%d",b^p[i]);
	}printf("\n");
}

Measured memory_bytes: 3220
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
    int N;
    string S, T;
    cin >> N >> S >> T;
    for(int i = 0; i < N; i++) {
        cout << S[i] << T[i];
    }
    cout << endl;
}


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

using namespace std;

int main() {
    int n; cin >> n;
    int sum = 0;
    int tmp = n;
    while (tmp > 0) {
        sum += tmp % 10;
        tmp /= 10;
    }
    if (n % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int flag = true;
	int T, F;
	char C;
	string S;
	cin >> S;
	deque<char>A;
	rep(i, S.size()) {
		A.push_back(S[i]);
	}
	int Q;
	cin >> Q;
	rep(i, Q) {
		cin >> T;
		if (T == 1) {
			if (flag == true) {
				flag = false;
			}
			else if (flag == false) {
				flag = true;
			}
		}
		else if (T == 2) {
			cin >> F >> C;
			if (flag == true && F == 1) {
				A.push_front(C);
			}
			else if (flag == true && F == 2) {
				A.push_back(C);
			}
			else if (flag == false && F == 1) {
				A.push_back(C);
			}
			else if (flag == false && F == 2) {
				A.push_front(C);
			}
		}
	}
	if (flag == true) {
		rep(i, A.size()) {
			cout << A[i];
		}
	}
	else if (flag == false) {
		rep(i, A.size()) {
			cout << A[A.size() - i - 1];
		}
	}
	cout << endl;
}


Measured memory_bytes: 896
#include<stdio.h>

int main(void){
  int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  
  if(a<c && b>c){
    printf("Yes");
  }else if(a>c && b<c){
    printf("Yes");
  }else{
    printf("No");
  }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) (m*n)/GCD(m,n)
# define mod 1000000007

ll arr[100001];
int main()
{
   ll i,j,k,n,m,t,cnt=0,flag=0,prod=1;
   memset(arr,0,sizeof(arr));
   cin >> n;
   if(n==1)
      cout << 0;
   ll a[n];
   for(i=0;i<n;i++)
    cin >> a[i];
   if(n==2)
   {
       cout << abs(a[0]-a[1]);
       return 0;
   }
    arr[0]=0;
    arr[1]=abs(a[0]-a[1]);
    for(i=2;i<n;i++)
        arr[i]=min(arr[i-2]+abs(a[i-2]-a[i]),arr[i-1]+abs(a[i-1]-a[i]));
    cout << arr[n-1];
}


Measured memory_bytes: 5180
#include <iostream>

using namespace std;

int main() {
    int n, *b, i;
    cin >> n;
    b = new int[n+1];
    b[0] = b[n] = 1000000;
    for (i = 1; i < n; i++) {
        cin >> b[i];
    }

    int ans = 0;

    for (i = 0; i < n; i++) {
        ans += min(b[i], b[i+1]);
    }

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

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

using namespace std;

int main() 
{
    int n, x, y;
    scanf("%d", &n);
    
    vector<pair<int, int> > v;
    
    for(int i = 0; i < n; i++)
    {
        scanf("%d %d", &x, &y);
        v.emplace_back(make_pair(x, y));
    }
    
    sort(v.begin(), v.end());
    
    for(auto p : v)
        printf("%d %d\n", p.first, p.second);
    
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b;
  cin >> a >> b;
  int n = b-a;
  if(a > 0 && b > 0) cout << "Positive" << endl;
  else if(n%2 && a < 0 && b < 0) cout << "Positive" << endl;
  else if(a < 0 && b < 0) cout << "Negative" << endl;
  else cout << "Zero" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x;
	cin >> x;
	ll lb = 2, ub = INF * INF + INF;
	while(ub - lb > 1) {
		ll mid = (ub + lb) / 2;
		ll cnt = 0;
		ll lgt = mid;
		while(lgt > 2) {
			cnt++;
			lgt = (lgt - 1) / 2;
		}
		if(cnt >= x + 1) ub = mid;
		else lb = mid;
	}
	cout << lb << endl;
	return 0;
}

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, L; cin >> N >> L;
    int a[100010];
    rep(i, N) cin >> a[i];
    int idx = -1;
    int l = -1;
    rep(i, N - 1) {
        if (a[i] + a[i + 1] > l) {
            l = a[i] + a[i + 1];
            idx = i;
        }
    }
    if (l < L) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    rep(i, idx) {
        cout << i + 1 << endl;
    }
    RREP(i, N - 2, idx) {
        cout << i + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 1664
#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> P;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) :par(n) {
        rep(i, n) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;

        par[x] = y;
    }
};

int main(){
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind uf1(n), uf2(n);
    rep(i, k) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        uf1.unite(p, q);
    }
    rep(i, l) {
        int r, s;
        cin >> r >> s;
        r--; s--;
        uf2.unite(r, s);
    }
    
    map<P, int> m;
    rep(i, n) {
        P p = P(uf1.root(i), uf2.root(i));
        m[p]++;
    }
    rep(i, n) {
        P p = P(uf1.root(i), uf2.root(i));
        cout << m[p] << " ";
    }

    return 0;
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
#define mp make_pair
#define pb push_back
#define p(k) printf("%d ",k)
#define pl(k) printf("%lld ",k)
#define pn(k) printf("%d\n",k)
#define pln(k) printf("%lld\n",k)
#define ps(str) printf("%s",str)
#define s(k) scanf("%d",&k)
#define sl(k) scanf("%lld",&k)
#define ss(str) scanf("%s",str)
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define ppi pair<int,int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ft first
#define sd second
#define count(x) __builtin_popcount(x)

using namespace std;

void test_case(){
	int n,i,l;
	cin>>n;
	string str;
	cin>>str;
	vector<int>dp(n+5,0);
	vector<int>dp2(n+5,0);
	vector<int>pre(n+5,0);
	dp[1] = 1;
	for(l=2;l<=n;l++){
		for(i=1;i<=l;i++){
			pre[i] = (i!=1)?(pre[i-1]+dp[i])%M:dp[i];
			//~ p(dp[i]);
		}
		for(i=1;i<=l;i++){ // for length of l.
			dp2[i] = 0;
			if(str[l-2] == '<'){
				dp2[i] = pre[i-1];
			}
			else {
				dp2[i] = (pre[l-1] - pre[i-1] + M)%M;
			}
			//~ dp[l][i] = dp[l-1][j] // if str[l-2] == '<'. for j<i.
			//~ dp[l][i] = dp[l-1][j] // if str[l-2] == '>'. for j>=i.
		}
		swap(dp,dp2);
	}
	int sum = 0;
	for(i=1;i<=n;i++){
		sum = (sum + dp[i])%M;
	}
	pn(sum);
	return ;
}
signed main(){
	int t;
	t = 1;
	//~ s(t);
	while(t--){
		test_case();
	}
	return 0;
}


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

int main() {
    string s;
    int a_min = 200000;
    int z_max = 0;

    cin >> s;
    for (int i=0; i<s.length(); ++i) {
      if (s[i] == 'A' && a_min > i) a_min = i;
      if (s[i] == 'Z' && z_max < i) z_max = i;
    }
    cout << (z_max - a_min + 1) << endl;

    return 0;
}

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

/********************************************************************/
#define M1 1000000007
#define M3 1000000009
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

/********************************************************************/
const double pi = 3.1415926535;
ll n, m;
const int mx = 69;
char grid[mx][mx];
ll blocked[mx][mx];
ll vis[mx][mx];
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

/********************************************************************/

ll power(ll a, ll b)
{
	ll res = 1;
	for (int i = 1; i <= b; ++i)
		res *= a;

	return res;
}
ll sum(ll x) {
	ll ans = 0;
	while (x > 0) {
		ans += (x % 10);
		x /= 10;
	}
	return ans;
}

bool opp(int x, int y)
{
    return ((x ^ y) < 0);
}

int main()
{
  FAST();
  
    ll n;
    cin>>n;
    ll arr[n+1],dp[n+1];
    for(ll i=1;i<=n;i++)
    {
      cin>>arr[i];
    }
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    for(ll i=3;i<=n;i++)
    {
    	dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]));
    }
    cout<<dp[n]<<"\n";
  
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

const int maxN = 1000000;
int dp1[maxN+1] = {0}, dp2[maxN+1] = {0};
int temp[maxN+1];

typedef long long ll;

int f(ll n) {
	return n * (n+1) * (n+2) / 6;
}

void knapsack(int dp[], const vector<int>& v) {
	int *now = dp, *next = temp;
	fill(now, now+maxN+1, inf); now[0] = 0;
	for (int i = 0; i < v.size(); ++i) {
		fill(next, next+maxN+1, inf);
		for (int j = 0; j <= maxN; ++j) {
			next[j] = min(next[j], now[j]);
			int nj = j + v[i];
			if (nj <= maxN) {
				now[nj] = min(now[nj], now[j]+1);
			}
		}
		swap(now, next);
	}
	for (int i = 0; i <= maxN; ++i) {
		dp[i] = now[i];
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	vector<int> v1, v2;
	REP(i, maxN+1) {
		if ( f(i) >= maxN ) break;
		v1.push_back( f(i) );
		if ( f(i) % 2 == 1 ) {
			v2.push_back( f(i) );
		}
	}
	knapsack(dp1, v1);
	knapsack(dp2, v2);

	int N;
	while (cin >> N, N) {
		cout << dp1[N] << " " << dp2[N] << endl;
	}
}

Measured memory_bytes: 14876
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

bool check(vector<int> vi, int n) {
    bool dp[2][20000];
    bool *prev = dp[0], *next = dp[1];
    fill(prev, prev + 20000, false);
    fill(next, next + 20000, false);
    prev[vi[0] + 10000] = true;
    FOR(i, 1, vi.size()) {
        REP(j, 20000) {
            if (prev[j]) {
                next[j + vi[i]] = true;
                next[j - vi[i]] = true;
                prev[j] = false;
            }
        }
        swap(prev, next);
    }
    return prev[n + 10000];
}

int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;

    s += 'T';
    vector<int> hv, vv;
    int count = 0;
    bool horizontal = true;
    REP(i, s.length()) {
        if (s[i] == 'T') {
            if (count > 0) {
                if (horizontal) hv.push_back(count);
                else vv.push_back(count);
            }
            horizontal = !horizontal;
            count = 0;
        }
        else count++;
    }

    bool okh = false, okv = false;
    if (hv.size() == 0) okh |= x == 0;
    else {
        okh |= check(hv, x);
        if (s[0] == 'T') {
            hv[0] *= -1;
            okh |= check(hv, x);
        }
    }
    if (vv.size() == 0) okv |= y == 0;
    else {
        okv |= check(vv, y);
        vv[0] *= -1;
        okv |= check(vv, y);
    }

    if (okh && okv) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
program ABC070B
    implicit none
    integer(8)::X,Y,i,flg
    flg=0
    read*,X,Y
    do i=0,X
        if(2*i+4*(X-i)==Y)flg=1
    end do

    if(flg==0)print'(A)',"No"
    if(flg==1)print'(A)',"Yes"
end program ABC070B

Measured memory_bytes: 2864
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    ll n,m;
    cin >> n >> m;
    ll sum = 0;
    ll a[m] = {};
    rep(i,0,m){
        cin >> a[i];
        sum += a[i];
    }
    cout << max(-1LL,n - sum) << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

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

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    set<char> foundCharacters;
    repeat (i, S.size()) {
        if (foundCharacters.find(S[i]) != foundCharacters.end()) {
            cout << "no" << endl;
            return 0;
        }
        foundCharacters.insert(S[i]);
    }
    cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <iostream>
#include <queue>
#include <set>

#define ll long long
#define sf(a) scanf("%lld",&a)
#define pf(b) printf("%lld",b)
#define sp printf(" ")
#define nw printf("\n")
#define mp make_pair
#define pi pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define fast ios_base::sync_with_stdio(false)
using namespace std;

vector<pi> ar;
bool cmp(pi a,pi b)
{
  return a.s<b.s;
}
int main()
{
   ll n,sum=0;
   sf(n);
   for(ll i=0;i<n;i++)
   {
    ll x,y;
    sf(x),sf(y);
    ar.pb(mp(x,y));
   }
   sort(ar.begin(),ar.end(),cmp);
   for(auto e:ar)
   {
    sum+=e.f;
    if(sum>e.s) 
    {
      printf("No");
      return 0;
    }
   }
   printf("Yes");
}

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

int main()
{
  int n; cin >> n;
  int t_score = 0, h_score = 0;
  string t_str, h_str;

  rep(i, n){
    cin >> t_str >> h_str;
    if (t_str > h_str) {
      t_score += 3;
    } else if (t_str < h_str) {
      h_score += 3;
    } else {
      t_score ++;
      h_score ++;
    }
  }

  cout << t_score << " " << h_score << endl;

  return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int N, a;
  cin >> N;
  int ans = 0;
  vector<int> vec(N);
  vector<int> arr(N);
  
  for (int i = 0; i < N; i++){
    cin >> a;
    vec.at(i) = a;
    arr.at(i) = a;
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  int mx = vec.at(0);
  int subMax = 0;
  int cnt = 0;
  bool flag = false;
  for (int i = 0; i < N; i++){
    if(vec.at(i) == mx) cnt++;
    if(cnt > 1) {
      flag = true;
    }
    if(vec.at(i) < mx){
      subMax = max(subMax, vec.at(i));
    }
  }

  for (int i = 0; i < N; i++){
    if(arr.at(i) < mx || flag == true) cout << mx << endl;
    else cout << subMax << endl;
  }

  return 0;
}

Measured memory_bytes: 4732