akhauriyash/Code-Regression huggingface dataset:
// C - Make a Rectangle
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vi A(N);
	rp(i, 0, N) cin>>A[i];
	sort(allr(A));
	vi ab(2);
	for(int c=0, i=0; i<N && c<2; ++i)
		if(A[i-1] == A[i]) ab[c++] = A[i++];
	cout<< (ll)ab[0]*ab[1] <<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<" "
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define sp << " " <<
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);

int main()
{
    fast;
    ll h,w;
    cin >> h >> w;
    string s[h];
    fr(i,0,h)
        cin >> s[i];
    ll dp[h][w];
    fr(i,0,h)
    {
        fr(j,0,w)
        {
            if(i==0 && j==0)
                dp[i][j]=1;
            else if(s[i][j]=='#')
                dp[i][j]=0;
            else if(i==0)
                dp[i][j]=dp[i][j-1];
            else if(j==0)
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=md;
        }
    }
    cout << dp[h-1][w-1];
}

Measured memory_bytes: 9088
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

const long long INF = 1LL << 60;

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define MAX 100005
#define NIL -1

int main() {
    int n, a, ans[100005] = {};
    cin >> n;
    rep(i, n) {
        cin >> a;
        ans[a - 1] = i + 1;
    }
    rep(i, n) {
        if(i)
            printf(" ");
        printf("%d", ans[i]);
    }
    printf("\n");
}

Measured memory_bytes: 1152
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B&lang=jp

#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef pair<int, int>P;

class MCF{
public:
	class edge{
	public:
		int to, cap, cost, rev;
		edge(){};
		edge(int _to, int _cap, int _cost, int _rev){
			to = _to;
			cap = _cap;
			cost = _cost;
			rev = _rev;
		}
	};

	vector<vector<edge> >G;
	vector<int>h;
	vector<int>dist;
	vector<int>prevv;
	vector<int>preve;
	MCF(int n){
		G.resize(n);
		preve.resize(n, 0);
		prevv.resize(n, 0);
	}
	void addEdge(int from, int to, int cap, int cost){
		G[from].push_back(edge(to, cap, cost, G[to].size()));
		G[to].push_back(edge(from, 0, -cost, G[from].size() - 1));
	}
	int flow(int s, int t, int f){
		int res = 0;
		h.clear();
		h.resize(G.size(), 0);
		while (f > 0){
			priority_queue<P, vector<P>, greater<P> >que;
			dist.clear();
			dist.resize(G.size(), 1145141919);
			dist[s] = 0;
			que.push(P(0, s));
			while (!que.empty()){
				P p = que.top();
				que.pop();
				int v = p.second;
				if (dist[v] < p.first)continue;
				for (int i = 0; i < G[v].size(); i++){
					edge &e = G[v][i];
					if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
						dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
						prevv[e.to] = v;
						preve[e.to] = i;
						que.push(P(dist[e.to], e.to));
					}
				}
			}
			if (dist[t] == 1145141919){
				return res;
                return -1;
			}
			for (int v = 0; v < G.size(); v++)h[v] += dist[v];
			int d = f;
			for (int v = t; v != s; v = prevv[v]){
				d = min(d, G[prevv[v]][preve[v]].cap);
			}
			f -= d;
			res += d*h[t];
			for (int v = t; v != s; v = prevv[v]){
				edge &e = G[prevv[v]][preve[v]];
				e.cap -= d;
				G[v][e.rev].cap += d;
			}
		}
		return res;
	}
};

int main(){

    for(int n;cin>>n,n;){
        MCF mcf(202);
        vector<vector<int> >mt(n);
        vector<int>vol(n, 1);
        int sum = 0;
        for(int i=0;i<n;i++){
            for(int j = 0; j< 3;j++){
                int tmp;
                cin>>tmp;
                mt[i].push_back(tmp);
                vol[i]*=tmp;
            }
            sort(mt[i].begin(), mt[i].end());
            sum += vol[i];
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                int f = 0;
                for(int k = 0; k < 3; k++){
                    if(mt[i][k] >= mt[j][k])f=1;
                }
                if(f)continue;
                mcf.addEdge(i, 100+j, 1, -vol[i]);
            }
            mcf.addEdge(200, i, 1, 0);
            mcf.addEdge(100+i, 201, 1, 0);
        }
        cout<<sum + mcf.flow(200, 201, 100)<<endl;
    }

	return 0;
}


Measured memory_bytes: 3224
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=1e6+5;
string s[N];
struct node{
	int x,y,id,dis;
};
node a[N];
bool cmp(node a,node b){
	if(a.id!=b.id)
	return a.id>b.id;
	if(a.id>0)
	return a.y>b.y;
	else if(a.id<0){
		if(a.dis!=b.dis)
		return a.dis>b.dis;
		return a.x<b.x;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		int cnt=0,mn=0;
		for(int j=0;j<s[i].size();j++){
			if(s[i][j]=='('){
				cnt++;
			}
			else if(s[i][j]==')'){
				cnt--;
			}
			mn=min(mn,cnt);
		}
		if(cnt<0)
		a[i]={cnt,mn,0,cnt-mn};
		else
		a[i]={cnt,mn,1,cnt-mn};
	}
	sort(a+1,a+n+1,cmp);
	int sum=0;
	for(int i=1;i<=n;i++){
		if(sum+a[i].y<0){
			cout<<"No";
			return 0;
		}
		if(sum+a[i].x<0){
			cout<<"No";
			return 0;
		}
		sum+=a[i].x;
	}
	if(sum==0)
	cout<<"Yes";
	else
	cout<<"No";
}


Measured memory_bytes: 50500
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  string s; cin >> s;
  vector<bool> dic(26, 0);
  int n = s.size();

  if(n < 26) {
    rep(i, n) {
      dic[s[i] - 'a'] = 1;
    }
    rep(i, 26) {
      if(!dic[i]) {
        cout << s << alphabet[i] << endl;
        return 0;
      }
    }

    cout << -1 << endl;
    return 0;
  }

  int iz = 0;
  rep(i, n) {
    if(s[i] == 'z') {
      iz = i;
      break;
    }
  }
  if(iz == 0) {
    cout << -1 << endl;
    return 0;
  }

  string b = s;
  next_permutation(s.begin(), s.end());
  rep(i, n) {
    cout << s[i];
    if(b[i] != s[i]) break;
  }
  cout << endl;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);

int main() {
	int a[3]; REP(i, 3)cin >> a[i];
	if (a[0] == a[1]) {
		cout << a[2];
	}
	else {
		if (a[1] == a[2]) {
			cout << a[0];
		}
		else cout << a[1];
	}
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}

Measured memory_bytes: 256
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
	ll C[n + 1][k + 1]; 
	ll i, j; 


	for (i = 0; i <= n; i++) 
	{ 
		for (j = 0; j <= min(i, k); j++) 
		{ 
			
			if (j == 0 || j == i) 
				C[i][j] = 1; 

			else
				C[i][j] = (C[i - 1][j - 1] + 
										C[i - 1][j])%MOD; 
		} 
	} 

	return C[n][k]; 
}
bool compare(const string &a , const string&b){
	
}
 
void solve()
{
	int a[3] ;
	cin>>a[0]>>a[1]>>a[2] ;
	sort(a , a+3) ;
	if(a[0]==5 && a[1]==5 && a[2]==7){
		cout<<"YES\n";
	}
	else{
		cout<<"NO\n";
	}
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (int)(s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
constexpr long long INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}
#define IN(a, x, b) (a<=x && x<b)

signed main(){
	int N;
	cin >> N;
	multiset<pair<int,int>>l,r;
	vector<int>L(N),R(N);
	REP(i,N){
		cin>>L[i]>>R[i];
		l.insert({L[i],R[i]});
		r.insert({R[i],L[i]});
	}
	int ans = 0,now = 0;
	REP(i,N){
		if(l.empty())break;
		auto ma = prev(l.end());
		l.erase(ma);
		r.erase(r.find({ma->second,ma->first}));
		if(!IN(ma->first,now,ma->second+1)){
			ans += abs(now-ma->first);
			now = ma->first;
		}
		if(l.empty())break;
		auto mi = r.begin();
		r.erase(mi);
		l.erase(l.find({mi->second,mi->first}));
		if(!IN(mi->second,now,mi->first+1)){
			ans += abs(now-mi->first);
			now = mi->first;
		}
	}
	ans += abs(now);
	int aans = ans;
	now = 0;ans = 0;
	REP(i,N){
		l.insert({L[i],R[i]});
		r.insert({R[i],L[i]});
	}
	REP(i,N){
		if(l.empty())break;
		auto mi = r.begin();
		r.erase(mi);
		l.erase(l.find({mi->second,mi->first}));
		if(!IN(mi->second,now,mi->first+1)){
			ans += abs(now-mi->first);
			now = mi->first;
		}
		if(l.empty())break;
		auto ma = prev(l.end());
		l.erase(ma);
		r.erase(r.find({ma->second,ma->first}));
		if(!IN(ma->first,now,ma->second+1)){
			ans += abs(now-ma->first);
			now = ma->first;
		}
	}
	ans += abs(now);
	cout << max(ans,aans) << endl; 
}


Measured memory_bytes: 14336
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            double a = cin.ReadInt;
            double b = cin.ReadInt;
            double k = (a + b) / -2;
            WriteLine(k - (int)k == 0 ? Abs(k).ToString("#") : "IMPOSSIBLE");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
import sys
input = sys.stdin.readline
from math import sqrt


def Eratosthenes(n):
    """n(>=6)未満の素数列挙 """
    n, correction = n - n % 6 + 6, 2 - (n % 6 > 1)
    sieve = [True] * (n // 3)
    for i in range(1, int(sqrt(n)) // 3 + 1):
        if sieve[i]:
            k = 3 * i + 1 | 1
            sieve[k * k // 3::2 * k] = [False] * ((n // 6 - k * k // 6 - 1) // k + 1)
            sieve[k * (k - 2 * (i & 1) + 4) // 3::2 * k] = [False] * ((n // 6 - k * (k - 2 * (i & 1) + 4) // 6 - 1) // k + 1)
    s = [False] * n
    for i in range(1, n // 3 - correction):
        if sieve[i]:
            s[3 * i + 1 | 1] = True
    s[2] = True
    s[3] = True
    return s


sieve = Eratosthenes(10 ** 5 + 1)
ans = [0] * (10 ** 5 + 1)
for i in range(3, 10 ** 5, 2):
    if sieve[i] and sieve[(i + 1) // 2]:
        ans[i] += 1
for i in range(3, 10 ** 5):
    ans[i + 1] += ans[i]
q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(ans[r] - ans[l - 1])


Measured memory_bytes: 77900
class node():
    def __init__(self, key, parent=None, left=None, right=None):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right
 
 
class binarysearchtree(list):
    def __init__(self):
        list.__init__(self)
        self.root = None
 
    def insert(self, z):
        z = node(z)
        y = None
        x = self.root
 
        while x is not None:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
 
        if y is None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z
 
    def inorder(self):
        def inparse(u):
            if u == None:
                return
            inparse(u.left)
            print(" " + str(u.key), end="")
            inparse(u.right)
        inparse(self.root)
        print("")

    def outorder(self):
        def outparse(u):
            if u == None:
                return
            print(" " + str(u.key), end="")
            outparse(u.left)
            outparse(u.right)
        outparse(self.root)
        print("")
 
    def print(self):
        self.inorder()
        self.outorder()
 
    def find(self, k):
        x = self.root
        while x is not None and k != x.key:
            if k < x.key:
                x = x.left
            else:
                x = x.right
        return x
 
n = int(input())
clist = [input().split(" ") for i in range(n)]
tree = binarysearchtree()

for c in clist:
    if c[0] == "insert":
        tree.insert(int(c[1]))
    elif c[0] == "find":
        f = tree.find(int(c[1]))
        if f is None:
            print("no")
        else:
            print("yes")
    else:
        tree.print()


Measured memory_bytes: 226132
// ACM-ICPCà\I2010 F. Ã¢L¯

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

const int INF = 100000000;

int d;
string mes, cur;
vector<string> piece;
vector<int> connect[30][20];
vector<string> ans;
set<string> mem[43];
int dp[43][43];

bool editDist(int s, int e){
	for(int i=s+1;i<=e;i++){
		int m = INF;
		for(int j=max(1,i-d);j<=min((int)mes.size(),i+d);j++){
			if(cur[i-1]==mes[j-1]) dp[i][j] = dp[i-1][j-1];
			else {
				dp[i][j] = dp[i-1][j-1]+1;
				dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
				dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
			}
			m = min(m, dp[i][j]);
		}
		if(m > d) return false;
	}
	return true;
}

void dfs(int pIdx){
	int len = piece[0].size();
	int csize = cur.size();
	if(dp[csize][mes.size()] <= d) ans.push_back(cur);
	for(int j=len-1;j>=0;j--){
		int nsize = csize + len - j;
		if(nsize > mes.size() + d) break;
		cur += ' ';
		for(int i=0;i<connect[pIdx][j].size();i++){
			bool flag = true;
			for(int k=j;k<len;k++){
				cur[csize+k-j] = piece[connect[pIdx][j][i]][k];
				if(!editDist(csize+k-j, csize+k-j+1)){
					flag = false;
					break;
				}
			}
			if(!flag) continue;
			if(mem[nsize].count(cur)) continue;
			mem[nsize].insert(cur);
			dfs(connect[pIdx][j][i]);
		}
	}
	cur = cur.substr(0, csize);
}

int main(){
	int n, len;
	for(int i=0;i<=42;i++) dp[i][0] = dp[0][i] = i;
	while(cin >> d >> n, n){
		cin >> mes;
		piece.clear();
		for(int i=0;i<n;i++){
			string str; cin >> str;
			piece.push_back(str);
		}
		sort(piece.begin(), piece.end());
		piece.erase(unique(piece.begin(), piece.end()), piece.end());
		len = piece[0].size();
		for(int i=1;i<=mes.size()+d;i++)
			for(int j=1;j<=mes.size()+d;j++)
				if(abs(i-j) > d) dp[i][j] = INF;
		for(int i=0;i<piece.size();i++){
			for(int k=0;k<len;k++){
				connect[i][k].clear();
				for(int j=0;j<piece.size();j++){
					if(piece[i].substr(len-k) == piece[j].substr(0,k))
						connect[i][k].push_back(j);
				}
			}
		}
		for(int i=0;i<=mes.size()+d;i++)
			mem[i].clear();
		ans.clear();
		for(int i=0;i<piece.size();i++){
			cur = piece[i];
			if(!editDist(0, len)) continue;
			dfs(i);
		}
		sort(ans.begin(), ans.end());
		cout << ans.size() << endl;
		if(ans.size() <= 5){
			for(int i=0;i<ans.size();i++)
				cout << ans[i] << endl;
		}
	}
}

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

int main(){
  int n, m, d;
  cin >> n >> m >> d;
  ll cnt = 0;
  for(int i=1; i<=n; ++i){
    if(d == 0){ ++cnt; continue;}
    if(i-d >=1) ++cnt;
    if(i+d <=n) ++cnt;
  }
  cnt *= m-1;
  double ans = (double)cnt /n /n;
  printf("%.10f", ans);
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n;
  rep(i,0,n)cin >> d[i];
  ll sum1 = 0,sum2 = 0;
  ll ans1 = 0,ans2 = 0;
  rep(i,0,n){
    sum1 += d[i];
    if(i % 2 == 0){
      if(sum1 <= 0){
        ans1 += -sum1+1;
        sum1 = 1;
      }
    }else{
      if(sum1 >= 0){
        ans1 += sum1 + 1;
        sum1 = -1;
      }
    }
  }
  rep(i,0,n){
    sum2 += d[i];
    if(i % 2 == 0){
      //-
      if(sum2 >= 0){
        ans2 += sum2 + 1;
        sum2 = -1;
      }
    }else{
      if(sum2 <= 0){
        ans2 += -sum2 + 1;
        sum2 = 1;
      }
    }
  }
  print(min(ans1,ans2));
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

void quick(int *,int,int);

int main(){

int N,K;
scanf("%d%d",&N,&K);

int h[N];

for (int i = 0; i < N; i++){
    scanf("%d",&h[i]);
}

quick(h,0,N-1);

int min = 2000000000;
for (int i = 0; i < N-K+1; i++)
{
  if(min > h[i]-h[K+i-1]){min = h[i]-h[K+i-1];}
}

printf("%d",min);

return 0;

}

void quick(int h[],int left,int right)
{
    int s,t,i,j;
    if (left<right){
        s=h[(left+right)/2];    
        i=left-1; j=right+1;   
        while (1){            
            while (h[++i]>s);
            while (h[--j]<s);
            if (i>=j) break;
            t=h[i]; h[i]=h[j]; h[j]=t;
        }

        quick(h,left,i-1);
        quick(h,j+1,right);
    }
}

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

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

signed main() {
  int n;
  cin >> n;
  vi p(n);
  rep (i, n) cin >> p[i];

  int cnt = 0;
  rep1 (i, n - 2) {
    if (p[i - 1] < p[i] and p[i] < p[i + 1]) cnt++;
    if (p[i - 1] > p[i] and p[i] > p[i + 1]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
struct V {
  double x, y;
  V(double x=0, double y=0) : x(x), y(y) {}
  V operator+(const V& p) const { return V(x+p.x, y+p.y);}
  V operator-(const V& p) const { return V(x-p.x, y-p.y);}
  V operator*(const V& p) const { return V(x*p.x - y*p.y, x*p.y + y*p.x);}
  double sqrNorm() const { return x*x+y*y;}
  double norm() const { return sqrt(sqrNorm());}
};

const double eps = 1e-9;
struct Circle {
  V o; double r;
  Circle(V o=V(), double r=0) : o(o), r(r) {}
  vector<V> xv(const Circle& c) {
    V v = c.o-o;
    double d = v.norm();
    if ( abs(d) < eps ) {
      return {};
    }
    double rc = (d*d + r*r - c.r*c.r)/(2*d);
    if ( r < rc ) {
      return {};
    }
    double rs = sqrt(r*r - rc*rc);
    v.x /= d;
    v.y /= d;
    if (rs < eps) {
      return { o + v * V(rc, 0 ) } ;
    }
    return { o + v * V(rc,rs), o + v * V(rc,-rs) };
  }
  bool isInside(const V& p) {
    return (p-o).norm() < r+eps;
  }
};

int main() {
  int n,k;
  cin >> n >> k;
  vector<Circle> c(n);
  rep(i,n){
    cin >> c[i].o.x >> c[i].o.y >> c[i].r;
  }
  if ( k == 0 ){
    cout << 0 << endl;
    return 0;
  }
  double r = 0, l = 200000;
  rep(xxx,100){
    double x = (r+l)/2;

    vector<V> p;
    rep(i,n) p.push_back(c[i].o);
    rep(i,n)rep(j,i){
      Circle a = c[i], b = c[j];
      a.r = x/a.r;
      b.r = x/b.r;
      auto v = a.xv(b);
      p.insert(p.end(),v.begin(),v.end());
    }
    
    int cnt = 0;
    for ( auto pi : p ){
      cnt = 0;
      rep(i,n){
        auto ci = Circle( c[i].o,c[i].r);
        ci.r = x/ci.r;
        if (ci.isInside(pi)) {
          ++cnt;
        }
      }
      if (cnt >= k) {
        break;
      }
    }
    if ( cnt >= k ) l = x;
    else r = x;
  }
  printf("%.10f\n",r);  
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    const ll N (50000);
    ll n, m;
    cin >>n>>m;
    vector<ll> c(m);
    rep(i,0,m) cin >> c[i];

    vector<ll> dp(N+10, LL_MAX);

    dp[0] = 0;

    rep(j,0,N+1)
        rep(i,0,m)
        {
            if (j+c[i] > N) break;
            //cout << dp[j] << ' ' << c[i] << endl;
            dp[j+c[i]] = min(dp[j]+1, dp[j+c[i]]);
        }

    cout << dp[n] << endl;

    return 0;
}



Measured memory_bytes: 3364
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

ll INF = 1LL << 60;

int N, M;
ll L[202020], R[202020], D[202020];

vector<vector<pair<int, ll>>> graph;

ll pos[101010];

bool dfs(int v) {
    for (auto p : graph[v]) {
        int w = p.first;
        ll d = p.second;

        if (pos[w] == -INF) {
            pos[w] = pos[v] + d;
            bool t = dfs(w);
            if (!t) return false;
        }

        if (pos[v] + d != pos[w]) {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> N >> M;
    graph.resize(N);
    fill(pos, pos+N, -INF);
    for (int j = 0; j < M; ++j) {
        cin >> L[j] >> R[j] >> D[j];
        --L[j]; --R[j];
        graph[L[j]].emplace_back(R[j], D[j]);
        graph[R[j]].emplace_back(L[j], -D[j]);
    }

    bool ok = true;
    for (int j = 0; j < N; ++j) {
        if (pos[j] == -INF) {
            pos[j] = 0;
            ok &= dfs(j);
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 21248
#include<bits/stdc++.h>
using namespace std; 
#define ll long long
void solve(int T){
	int n;
	scanf("%d",&n);
	if(n>=30)puts("Yes");
	else puts("No"); 
}
signed main(){
	int t=1;
	//scanf("%d",&t);
	for(int i=1;i<=t;i++){
		solve(i);
	}
}




Measured memory_bytes: 3680
import java.math.BigInteger

fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    val a = readLine()!!.split(' ').map { it.toLong() }

    val sum = a.sum()
    val mod = 1000000007L
    var ans = BigInteger.valueOf(0L)
    a.forEach {
        ans = ans.add(BigInteger.valueOf(it).multiply(BigInteger.valueOf(sum - it)))
    }
    ans = ans.divide(BigInteger.TWO)
    ans = ans.mod(BigInteger.valueOf(mod))
    println(ans)
}

Measured memory_bytes: 74596
def fibonacci(n, l):
  if n <= 1:
    l[n] = 1
    return l[n]
  elif l[n] != 0:
    return l[n]
  else:
    l[n] = fibonacci(n-1, l) + fibonacci(n-2, l)
    return l[n]


n = int(input())
l = [0] * (n+1)
print(fibonacci(n, l))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	ll n; cin>>n;
	ll m=0;
	vl v(n);
	rep(i,0,n){
		ll a; cin>>a;
		v[i]=a;
		m^=a;
	}
	rep(i,0,n){
		ll p=m xor v[i];
		cout<<p<<" ";
	}
}

Measured memory_bytes: 4644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,a,b) for (int i = a; (i)<=(b);i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int main(){
  ll n;
  ll r = 0;
  scanf("%lld",&n);
  if (n == 1){
    r = 0;
  }
  else{
    rep(i,n){
      r += i;
    }
  }
  cout << r;
  return 0;
}

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int K_MAX = 1e5+5;
bool to(int &x,int y){
  if(x>y){
    x = y;
    return true;
  }
  return false;
}

int solve(){
  int K;cin >> K;
  deque<int> dq(1,1);
  vector<int> dp(K,1e9);
  dp[1] = 1;
  while(!dq.empty()){
    //cout << dq.front().first SP dq.front().second << endl;
    int u = dq.front(); dq.pop_front();
    if(u==0) return dp[0];
    if(to(dp[u*10%K], dp[u])) dq.push_front(u*10%K);
    if(to(dp[(u+1)%K], dp[u]+1)) dq.push_back((u+1)%K);
  }
  return dp[0];
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 896
import java.util.Arrays;
import java.util.Scanner;

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

        for(int i = 0; i < 4; i++){
            num[i] = sc.nextInt();
        }

        if(num[0] <= num[2] && num[2] <= num[1] && num[1] <= num[3]){
            System.out.print(num[1] -num[2]);
        } else if(num[0] <= num[2] && num[2] <= num[3] && num[3] <= num[1]){
            System.out.print(num[3] - num[2]);
        } else if(num[2] <= num[0] && num[0] <= num[3] && num[3] <= num[1]){
            System.out.print(num[3] - num[0]);
        } else if(num[2] <= num[0] && num[0] <= num[1] && num[1] <= num[3]){
            System.out.print(num[1] - num[0]);
        } else{
            System.out.print(0);
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);



int main() {


    ll s;
    cin>>s;

    ll x1=0,y1=0;

    ll x2,y2,x3,y3;
    y2=1;
    x2=1000000000;


    x3=(x2-s%x2)%x2;

    y3 = (s+x3)/x2;



    cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    const size_t L = 1000000000 + 7;

    size_t N;
    vector<size_t> A;

    cin >> N;
    A.resize(N);
    for (size_t i = 0; i < N; ++i) { cin >> A[i]; }

    size_t sum = 0;
    size_t sq_sum = 0;

    for (size_t i = 0; i < N; ++i)
    {
        sum = (sum + A[i]) % L;
        size_t temp = (A[i] * A[i]) % L;
        sq_sum = (sq_sum + temp) % L;
    }

    size_t tmp = (sum * sum) % L;
    if (tmp < sq_sum) { tmp += L; }
    tmp -= sq_sum;

    const size_t Inv = (1000000000 + 8) / 2;   // 2 の逆数 mod L
    cout << (tmp * Inv) % L << endl;


    // cout << (sum * sum - sq_sum) / 2 << endl;


    return 0;
}


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

using namespace std;

int mv[4][2] = {{0,-1},{0,1},{-1,0},{1,0}};

int main(){
    int H,W,answer=0;
    cin >> H >> W;
    vector<string> A(H);
    queue <pair<int,int>> Q;
    pair<int,int> P;
    int ans[H][W];
    memset(ans,-1,sizeof(ans));
    for(int i=0;i<H;i++){
        cin >> A[i];
    }

    for(int y=0;y<H;y++){
        for(int x=0;x<W;x++){
            if(A[y][x]=='#'){
                ans[y][x] = 0;
                Q.push({y,x});
            }
        }
    }

    while(!Q.empty()){
        P = Q.front();
        Q.pop();
        for(int i=0;i<4;i++){
            if(0<=P.first+mv[i][0] && P.first+mv[i][0]<H && 0<=P.second+mv[i][1] && P.second+mv[i][1]<W && ans[P.first+mv[i][0]][P.second+mv[i][1]]==-1){
                ans[P.first+mv[i][0]][P.second+mv[i][1]] = ans[P.first][P.second]+1;
                Q.push({P.first+mv[i][0],P.second+mv[i][1]});
            }
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            answer = max(answer,ans[i][j]);
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 13456
import java.io.*;
import java.util.*;

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve() {
        int k = in.nextInt();
        int s = in.nextInt();
        int cnt =0;
        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                int a = s-i-j;
                if(a<=k && a>=0) cnt++;
            }
        }
        out.print(cnt);
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 23124
def resolve():
    '''
    code here
    '''
    import collections
    SA = collections.deque([item for item in input()])
    SB = collections.deque([item for item in input()])
    SC = collections.deque([item for item in input()])
    
    is_flag = True
    que = collections.deque(['a'])
    # print(SA,SB,SC)
    while is_flag:
        temp = que.popleft()
        # print(temp)
        if temp == 'a':
            if len(SA) == 0:
                print('A')
                is_flag = False
            else:
                que.append(SA.popleft())
 
        elif temp == 'b':
            if len(SB) == 0:
                print('B')
                is_flag = False
            else:
                que.append(SB.popleft())

        else:
            if len(SC) == 0:
                print('C')
                is_flag = False
            else:
                que.append(SC.popleft())


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3436
#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 x;
    cin >> x;
    if (x>=30) cout<<"Yes\n";
    else cout <<"No\n";
    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cout.tie(0)

// a -> 0, b -> 1, c -> 2
// dp[i][j] := i日目にjをしたときのmax
int N, a[1 << 17], b[1 << 17], c[1 << 17], dp[1 << 17][3];

int main()
{
    fast();

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

    dp[1][0] = a[1], dp[1][1] = b[1], dp[1][2] = c[1];

    for (int i = 2; i <= N; i++)
    {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }

    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define vi vector<int>
#define iii pair<int,pair<int,int>>
#define INF 1<<30

using namespace std;

int main(){
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll A[n];
	for (ll i = 0; i < n; ++i) {
		cin>>A[i];
	}
	ll threshold = 0;
	ll count = 0;
	bool ok = true;
	for (ll i = n-1; i >= 0; --i) {
		if(threshold == A[i]) {
			threshold--;
		}
		else if(threshold < A[i]) {
			threshold = A[i]-1;
			count += (A[i]);
		}
		else {
			ok = false;
		}
	}
	if(A[0] != 0) {
		ok = false;
	}
	if(!ok) {
		cout<<"-1";
	}
	else {
		cout<<count;
	}
}



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

using namespace std;

int main()	{
  string a, b, c;
  cin >> a >> b >> c;
  cout << char(a[0] - 'a' + 'A') << char(b[0] - 'b' + 'B') << char(c[0] - 'c' + 'C') << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define INF 1<<64
#define rep(a,b,c) for(int a=b;a<c;a++)
#define pb push_back
#define int long long int
#define str string
using namespace std;
int n,m,a=0;
vector<int> v,ans;
signed main(){
    cin >> n;
    rep(i,0,n*2){
       cin >> m;
        v.pb(m);
    }
    sort(v.begin(), v.end() );
    for(int i=0;i<n*2;i+=2){
        a+=v[i];
    }
    cout << a << endl;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if (x >= r && x <= (W - r) && y >= r && y <= (H - r)) {
        puts("Yes");
    } else {
        puts("No");
    }
}


Measured memory_bytes: 2108
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        t: f32, a: f32,
        h: [f32; n],
    }

    let mut number = 0;
    let mut min: f32 = 1000000.0;

    for (i, &v) in h.iter().enumerate() {
        let tmp = t - v*0.006;
        let comp = (a - tmp).abs();
        if min > comp {
            min = comp;
            number = i + 1;
        }
    }
    println!("{}", number);
}


Measured memory_bytes: 4352
def sol():
    h,w=map(int,input().split())
    l=[]
    x=[[0]*w for i in range(h)]
    y=[[0]*w for i in range(h)]
    for i in range(h):
        s=input()
        l.append(s)
    for i in range(h):
        for j in range(w):
            if j==0 and l[i][j]==".":
                x[i][j]=1
            elif l[i][j]==".":
                x[i][j]=x[i][j-1]+1
            if i==0 and l[i][j]==".":
                y[i][j]=1
            elif l[i][j]==".":
                y[i][j]=y[i-1][j]+1
    for i in range(h):
        for j in range(w):
            a=-1*(i+1)
            b=-1*(j+1)
            if i==j==0: continue
            if l[a][b]=="#": continue
            x[a][b]=max(x[a][b],x[a][b+1])
            if i>0: y[a][b]=max(y[a][b],y[a+1][b])

    ans=chk=0
    for i in range(h):
        for j in range(w):
            ans=max(ans,x[i][j]+y[i][j]-1)
    print(ans)

if __name__=="__main__":
    sol()


Measured memory_bytes: 124892
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if(a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3084
implicit none

  integer::a,b,c,x
  integer::count
  integer::i,j,k
  
  read(*,*)a
  read(*,*)b
  read(*,*)c
  read(*,*)x

  count=0
  do i=0,a
     do j=0,b
        do k=0,c
           if(x==i*500+j*100+k*50)count=count+1
        end do
     end do
  end do

  write(*,*)count
  
end program

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll bit[100010]; int n0;
 
ll sum(int i){
	ll s=0;
	while(i>0){
		s+=bit[i];
      s%=MOD;
		i-=(i&(-i));
	}
	return s;
}
 
void add(int i, ll x){
	while(i<=n0){
		bit[i]+=x;
      bit[i]%=MOD;
		i+=(i&(-i));
	}
}
int main()
{
	int n, m;
  cin>>n>>m;
  map<int, vector<int> > mp;
  int x[100000], y[100000];
  set<int> st;
  map<int, int> mpy;
  for(int i=0; i<n; i++) cin>>x[i];
  for(int i=0; i<m; i++) cin>>y[i];
  for(int i=0; i<n; i++){
    int i1=lower_bound(y, y+m, x[i])-y;
    if(i1==0 || i1==m) continue;
    mp[x[i]-y[i1-1]].push_back(y[i1]-x[i]);
    st.insert(y[i1]-x[i]);
  }
  n0=1;
  for(auto itr=st.begin(); itr!=st.end(); ++itr){
    mpy[*itr]=n0;
    n0++;
  }
  for(auto itr=mp.begin(); itr!=mp.end(); itr++){
    vector<int> v=itr->second;
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for(int i=v.size()-1; i>=0; i--){
      //cout<<v[i]<<" ";
      int t=mpy[v[i]];
      add(t, (sum(t-1)+1)%MOD);
    }
    //cout<<endl;
    //cout<<sum(n0)+1<<endl;
  }
  cout<<(sum(n0)+1)%MOD<<endl;
    return 0;
}

Measured memory_bytes: 21504
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	ar := []int{}
	for i := 0; i < m; i++ {
		var a int
		fmt.Scan(&a)
		ar = append(ar, a)
	}
	sort.Ints(ar)
	br := []int{}
	for i := 1; i < m; i++ {
		v := ar[i] - ar[i-1]
		br = append(br, v)
	}
	sort.Ints(br)
	if len(br) <= n-1 {
		fmt.Println(0)
		return
	}
	br = br[:len(br)-n+1]
	sum := 0
	for _, v := range br {
		sum += v
	}
	fmt.Println(sum)
}


Measured memory_bytes: 7552
from itertools import combinations
n, k = [int(x) for x in input().split()]

L = [ x for x in range(n)]

p =[]
for l in (combinations(L, k)):
    num = 0
    for i in l:
        num |= 1<<i
    p.append((num,l))

p.sort()
for i, l in p:
    print("{}: ".format(i), end="")
    print( *l)



Measured memory_bytes: 17176