akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	lld n;
	cin >> n;
	vector<vector<lld> > a(3,vector<lld>(n,0));
	for(int i = 0; i < 3; i++)
	{
		for(int j = 0; j < n; j++)
		{
			cin >> a[i][j];
		}
	}

	priority_queue<lld> back;
	priority_queue<lld,vector<lld> ,greater<lld> > front;

	for(int i = 0; i < n; i++)
	{
		front.push(a[0][i]);
	}
	for(int i = 0; i < n; i++)
	{
		back.push(a[2][i]);
	}

	lld A = accumulate(a[0].begin(),a[0].end(),(lld)0);
	lld C = accumulate(a[2].begin(),a[2].end(),(lld)0);
	// lld ans = A-C;
	lld AA = A,CC = C;

	vector<lld> f(n),b(n);
	for(int k = 0; k < n; k++)
	{
		front.push(a[1][k]);
		A += a[1][k];
		A -= front.top();
		front.pop();
		f[k] = A;
		//cout << k <<  "  A = " << A << endl;
	}

	for(int k = n-1; k >= 0; k--)
	{
		back.push(a[1][k]);
		C += a[1][k];
		C -= back.top();
		back.pop();
		b[k] = C;
		//cout <<  k << "  C = " << C << endl;
	}
	lld ans = max(AA-b[0],f[n-1]-CC);
	for(int i = 0; i < n-1; i++)
	{
		ans = max(ans,f[i] - b[i+1]);
	}
	cout << ans << endl;

	return 0;
}


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

int main() {
    std::string s;
    std::cin >> s;
    std::string ans;
    for (char c : s) {
        if (c == 'B') {
            ans = ans.substr(0, ans.length() - 1);
        }
        else {
            ans += c;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,jc[1000010],ny[1000100],ans,p=998244353;
ll C(ll x,ll y){
	return jc[x]*ny[y]%p*ny[x-y]%p;
}
ll ksm(ll x,ll y){
	ll xlh=1;
	while(y){
		if(y&1)xlh=xlh*x%p;
		x=x*x%p;
		y/=2;
	}
	return xlh;
}
int main(){
	ll i,xlh;
	scanf("%lld%lld",&n,&m);
	if(n>m)swap(n,m);
	jc[0]=ny[0]=1;
	for(i=1;i<=m;i++)jc[i]=jc[i-1]*i%p,ny[i]=ksm(jc[i],p-2);
	for(i=0;i<=n;i++){
		xlh=C(n,i)*C(m,i)%p*jc[i]%p*ksm(n+1,m-i)%p*ksm(m+1,n-i)%p;
		if(i%2)ans=(ans-xlh+p)%p;
		 else ans=(ans+xlh)%p;
	}
	printf("%lld",ans);
}
/*
仔细想想不难，但感觉这种容斥确实非常奇怪。 
*/

Measured memory_bytes: 10496
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		boolean bool;
		while(sc.hasNext()){
			bool=true;
			int m=sc.nextInt();
			for(int i=0;i<10;i++){
				if(m%2==1){
					if(!bool){System.out.printf(" %d",(int)Math.pow(2,i));}
					else {
						System.out.printf("%d",(int)Math.pow(2,i));
						bool=false;
					}
				}
				m=m/2;
			}
			System.out.println();
		}		
	}
}
// by tuvshee 12.05.2012
// Weight

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H, W, K;
    cin >> H >> W >> K;

    vector<vector<int>> S(H, vector<int>(W));
    vector<vector<int>> C(H + 1, vector<int>(W, 0));

    int ss = 0;
    rep(i, H) {
        rep(j, W) {
            char s;
            cin >> s;
            S[i][j] = (int)(s - '0');
            ss += S[i][j];
        }
    }

    if (ss <= K) {
        cout << 0 << endl;
        return 0;
    }

    rep(i, H) {
        rep(j, W) {
            C[i + 1][j] += C[i][j] + S[i][j]; 
        }
    }

    ll ans = INF;
    for (int bit = 1; bit < (1 << H - 1); bit++) {
        vector<int> R(H, 0);
        ll cnt = 0;
        for (int i = 0; i < H - 1; i++) {
            if (bit & (1 << i)) cnt++;
            R[i + 1] = cnt;
        }
        vector<int> one(cnt + 1, 0);
        bool check = true;
        rep(i, W) {
            bool flag = true;
            rep(j, H) {
                one[R[j]] += S[j][i];
                if (one[R[j]] > K) {
                    flag = false;
                    cnt++;
                    break;
                }
            }
            if (!flag) {
                rep(j, H) {
                    one[R[j]] = 0;       
                }
                rep(j, H) {
                    one[R[j]] += S[j][i];
                }
                rep(j, H) {
                    if (one[R[j]] > K) {
                        check = false;
                        break;
                    }
                }
            }
            if (!check) break;
        }
        if (check) chmin(ans, cnt);
    }

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

Measured memory_bytes: 384
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
*/
#include<bits/stdc++.h>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second

void solve()
{
  int a1,a2,a3;
  cin >> a1 >> a2 >> a3;
  if((a1+a2+a3)>=22)
  {
	  cout << "bust";
  }
  else
	cout << "win";
  return;
}
signed main()
{
  FAST;
	int T=1;
	// cin >> T;
	while(T--)
	{
		solve();
	}
    return 0;
}

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

using namespace std;

int N, K;
string S;

int main()
{
	int i, j, k = 0;
	int happy = 0;
	cin>>N>>K>>S;
	i = 0;
	j = i + 1;
	while(j < N)
	{
		if(S[i] == S[j])
		{
			j++;
			happy++;
		}
		else
		{
			i = j;
			j++;
		}
	}
	for(k = K; k > 0; k--)
	{
		happy += 2;
	}
	if(happy >= N-1)
		happy = N-1;
	cout<<happy;
	return 0;
}

Measured memory_bytes: 512
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    L = []

    for i in range(X):
        s =K//(i+1)
        for j in range(min(Y, s + 1)):
            t =A[i] +B[j]
            for k in range(min(Z, s // (j + 1) + 1)):
                L.append(t + C[k])

    L.sort(reverse=True)

    for i in range(K):
        print(L[i])


if __name__ == "__main__":
    main()


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n, m; cin >> n >> m;
	vector<vector<int> > s(m);
	REP(i, m) {
		int k; cin >> k;
		s[i].resize(k);
		REP(j, k) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	vector<int> p(m);
	REP(i, m) cin >> p[i];

	int res = 0;
	REP(bit, 1 << n) { // switch の on/off を bit 全探索
		bool ok = true;
		REP(i, m) { // switch の全部を確かめる
			int cnt = 0;
			for (int id : s[i])
				if ((bit >> id) & 1)
					cnt++;
			cnt %= 2;
			if (cnt != p[i])
				ok = false;
		}
		if (ok) res++;
	}

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


Measured memory_bytes: 3616
import math

a,b,x=map(int,input().split())

if a**2*b*0.5 >= x:
    h=x/a/b*2
    print(math.degrees(math.pi/2-math.atan(h/b)))
else:
    h=(a**2*b-x)/a/a*2
    print(math.degrees(math.atan(h/a)))

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

const int N = 500010;
using pii = std::pair <int, int>;

std::vector<int> vec[N];
int c[N], a[N];
std::vector<pii> event[N];

void add(int sit, int value){
    for (++ sit; sit < N; sit += sit & -sit){
        c[sit] += value;
    }
}

int query(int sit){
    int ret = 0;
    for (++ sit; sit; sit -= sit & -sit){
        ret += c[sit];
    }
    return ret;
}

int ans[N];

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++ i){
        scanf("%d", &a[i]);
        vec[a[i]].emplace_back(i);
    }
    for (int i = 0; i < m; ++ i){
        int l, r;
        scanf("%d%d", &l, &r);
        -- l, -- r;
        event[r].emplace_back(l, i);
    }
    for (int i = 0; i < N; ++ i){
        if (!vec[i].empty()){
            add(vec[i].back(), 1);
        }
    }
    for (int i = n - 1; i >= 0; -- i){
        for (auto p : event[i]){
            ans[p.second] = query(i) - query(p.first - 1);
        }
        vec[a[i]].pop_back();
        if (!vec[a[i]].empty()){
            add(vec[a[i]].back(), 1);
        }
    }
    for (int i = 0; i < m; ++ i){
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 58604
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    I vec;
    REP(a,N){
        CIN(b);
        vec.pb(b);
    }
    COUT(*max_element(ALL(vec))- *min_element(ALL(vec)));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

LL n;
LL a[100010];
LL sorted[100010];
int sum[100010];

void init() {

}

void input() {
	cin >> n;
	REP(i, n) cin >> a[i];
	REP(i, n) sorted[i] = a[i];
	sort(sorted, sorted+n);
}

pair <VI, LL> bu(int l, int r) {
	if (l == r) {
		vector<int> d{sum[l]};
		return make_pair(d, 0);
	}
	int m = (l+r) / 2;
	pair <VI, LL> L = bu(l, m);
	pair <VI, LL> R = bu(m+1, r);
	VI vl = L.first, vr = R.first;
	LL count = L.second + R.second;
	VI res;
	int pl = 0, pr = 0;
	while(1) {
		if (pl == SZ(vl) && pr == SZ(vr)) break;
		else if (pl == SZ(vl)) res.push_back(vr[pr++]);
		else if (pr == SZ(vr)) res.push_back(vl[pl++]);
		else {
			if (vl[pl] <= vr[pr]) res.push_back(vl[pl++]);
			else {
				res.push_back(vr[pr++]);
				count += SZ(vl)-pl;
			}
		}
	}
	return make_pair(res, count);
}

bool go(LL p) {
	sum[0] = 0;
	REP(i, n) {
		if(a[i] >= p) sum[i+1] = sum[i] + 1;
		else sum[i+1] = sum[i] - 1;
	}
	pair <VI, LL> B = bu(0, n);
	return (n*(n+1)/2+1)/2 >= B.second;
}

void solve() {
	int l = 0;
	int r = n;
	while(r > l+1) {
		int m = (l+r)/2;
		if (go(sorted[m])) l = m;
		else r = m;
	}
	cout << sorted[l] << endl;
}

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


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

int main(){
    int N,M,K;
    cin >> N >> M >> K;
    vector<int> A(N);
    vector<int> B(M);
    for (int i=0 ; i<N ; i++)
        cin >> A.at(i);
    for (int i=0 ; i<M ; i++)
        cin >> B.at(i);
    vector<long long> S_A(N+1);
    S_A.at(0) = 0;
    for (int i=1 ; i<N+1 ; i++)
        S_A.at(i) = S_A.at(i-1)+A.at(i-1);
    vector<long long> S_B(M+1);
    S_B.at(0) = 0;
    for (int i=1 ; i<M+1 ; i++)
        S_B.at(i) = S_B.at(i-1)+B.at(i-1);

    /**/
    vector<int> best_j;
    for (int i=0 ; i<N+1 ; i++){
        if (S_A.at(i)>K){
        break;
        }
        /*binary_search*/

        int x = K - S_A.at(i);
        
        int y_size = M;
        int left = 0,right = y_size;
        //cout << left << " " << right << endl;
        int mid = (left + right)/2;

        while(right - left > 1){
            if(S_B[mid] > x){
                right = mid;
            }
            else{
                left = mid;
            }
            mid = (left + right)/2;
            //cout << S_B[mid] << " ";
        }

        if(S_B[mid] > x) mid--;
        if(S_B[mid + 1] <= x) mid++;
        
        best_j.push_back(mid);

        
        /*
        for (int j=M ; j>=0 ; j--){ 
            if (S_A.at(i)+S_B.at(j) <= K){
                best_j.push_back(j);
                break;
            }
        }
        */
    } 

    int length = best_j.size();
    vector<int> answer(length);
    for (int i=0 ; i<length ; i++)
    answer.at(i) = i+best_j.at(i);
    sort(answer.begin(), answer.end());
    cout << answer.at(length-1) << endl;
}







Measured memory_bytes: 9448
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

int main() {
	int n;
	string str;
	cin >> n >> str;

	ll ans;
	bool flg;
	int now;

	if (str.size() == 1) {
		cout << 3 << endl;
		return 0;
	} else {
		if (str[0] == str[1]) {
			ans = 6;
			flg = false;
			now = 2;
		} else {
			ans = 3;
			flg = true;
			now = 1;
		}
	}

	while (now < str.size()) {
		//cout << now << " " << str.size() << endl;
		if (now + 1 >= str.size()) {
			if (flg) {
				ans *= 2;
			}
		} else {
			if (str[now] == str[now + 1]) {
				if (flg) {
					ans *= 2;
					flg = false;
					++now;
				} else {
					ans *= 3;
					flg = false;
					++now;
				}
			} else {
				if (flg) {
					ans *= 2;
					flg = true;
				} else {
					flg = true;
				}
			}
		}
		++now;
		ans %= 1000000007;
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main {

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s1=br.readLine().trim();
		String s2=br.readLine().trim();
		int count=0;
		for(int i=0;i<s1.length();i++)
			if(s1.charAt(i)!=s2.charAt(i))
				count++;
		System.out.println(count);
	}

}


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

int main() {
	int n;cin>>n;
	vector<int> p(n);
	int ans=0;
	int max=0;
	for(auto& x:p){
		cin>>x;
		ans+=x;
		if(max<x)max=x;
	}
	ans-=max/2;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
h = gets.split.map(&:to_i)

1.upto(N - 1) do |i|
  if h[i - 1] <= h[i] - 1
    h[i] -= 1
  end

  if h[i - 1] > h[i]
    puts 'No'
    exit
  end
end

puts 'Yes'



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

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
  {
    cin>>a[i];
  }
  int sum=0;
  for(auto &e: a) {
    sum+=e;
  }
  std::vector<int> div;
  for (int i = 1; i <= sqrt(sum); ++i)
  {
    if(sum%i==0) {
      div.emplace_back(i);
      div.emplace_back(sum/i);
    }
  }
  sort(div.begin(),div.end());
  int ans;
  for(auto &e: div) {
    std::vector<int> tmp;
    for(auto &f: a) {
      tmp.emplace_back(f%e);
    }
    int tmp_sum=0;
    for(auto &g: tmp) {
      tmp_sum+=g;
    }
    if(tmp_sum%e!=0) continue;
    sort(tmp.begin(), tmp.end(),greater<int>());
  
    tmp.erase(tmp.begin(),tmp.begin()+tmp_sum/e);
    int sum2=0;
    for(auto &h: tmp) {
      sum2+=h;
    }
    if(sum2<=k) ans=e;
  }
  cout<<ans;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif

    int h,w,n;
    cin>>h>>w>>n;
    int num=max(h,w);
    cout<<(n+num-1)/num;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
using namespace std;

// 最大公約数を求める関数
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) {
	return a * b / gcd(a, b);
}

int main() {

	long long A, B;
	long long C, D;
	cin >> A >> B >> C >> D;

	long long E = lcm(C, D);

	long long ini_AmodC = A % C;
	long long ini_AmodD = A % D;
	long long ini_AmodE = A % E;

	long long ini_AC = A / C;
	long long ini_BC = B / C;
	long long ini_AD = A / D;
	long long ini_BD = B / D;
	long long ini_AE = A / E;
	long long ini_BE = B / E;

	long long numC = ini_BC - ini_AC;
	if (ini_AmodC == 0) {
		numC += 1;
	}

	long long numD = ini_BD - ini_AD;
	if (ini_AmodD == 0) {
		numD += 1;
	}

	long long numE = ini_BE - ini_AE;
	if (ini_AmodE == 0) {
		numE += 1;
	}

	long long ans = B - A + 1 - numC - numD + numE;

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;


int main(void){
int n;
long long odd, even = 0;
std::cin >> n;

std::vector<long long> v(n);
for (int i = 0; i < n; i++) {
  std::cin >> v[i];
}

for (int i = 0; i < n; i++) {
  if (v[i] % 2 == 1) {
    odd++;
  }
}

if (odd == n) {
  std::cout << 0 << '\n';
  return 0;
}

for (int i = 0; i < n; i++) {
  while (v[i]%2 == 0) {
    even++;
    v[i] = v[i]/2;
  }
}

std::cout << even << '\n';

}


Measured memory_bytes: 384
//============================================================================
// Name        : ku.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include<iostream>
using namespace std;
#include<cstdio>
int main(){
	double x,y;
	for(;;){
	cin>>x>>y;
	if(x<y){
		cout<<x<<" "<<y<<endl;
	}
	else if(x>y){
		cout<<y<<" "<<x<<endl;
	}
	else if(x==y && x!=0){
		cout<<x<<" "<<y<<endl;
	}
	else if( x== 0 && y == 0){
		break;
	}
	}

	return 0;
}

Measured memory_bytes: 1276
def myAnswer(N:int,A:list) -> int:
   dic = {}
   counter = 0
   for a in A:
      if(a in dic.keys()):
         if(dic[a]==a):
            counter += 1
         else:
            dic[a]+= 1
      else:
         dic[a] = 1
   for key,value in dic.items():
      if(value < key):
         counter += value
   return counter

def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A))
if __name__ == '__main__':
   main()

Measured memory_bytes: 18168
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <bitset>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

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

int gcd(int a, int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

signed main() {
    int L, R; cin >> L >> R;
    int min = INF_INT;
    int loopmax = R + 1;
    FOR(i, L, loopmax) {

        FOR(j, i+1, loopmax) {
            int buf = i % 2019;
            buf = buf * (j % 2019);
            chmin(min, buf%2019);
            if (min == 0) {
                cout << 0 << endl;
                return 0;
            }
        }
    }


    cout << min << endl;
    
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
    ll H, W, N;
    cin >> H >> W >> N;
    vl as(N+1);
    FOR(i, 0, N) cin >> as[i];

    vvl res(H, vl(W, -1));
    ll cur = 0;
    ll cnt = 0;
    FOR(i, 0, H) {
	FOR(j, 0, W) {
	    ll w = j;
	    if (i % 2 == 1) {
		w = W - j - 1;
	    }
	    res[i][w] = cur+1;
	    cnt ++;
	    if (cnt >= as[cur]) {
		cur++;
		cnt = 0;
	    }
	}
    }

    FOR(i, 0, sz(res)) {
	FOR(j, 0, sz(res[i])) {
	    cout << res[i][j];
	    if (j != sz(res[i]) - 1) cout << " ";
	}
	cout << endl;
    }

} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    double d;
    scanf("%lf", &d);
    printf("%.12f\n", max(sqrt(2) * d, floor(d) + 1));
}

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

int movei[] = {0, 0, 1, -1};
int movej[] = {1, -1, 0, 0};
const int S = 1e6+1;

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

    map<string, string> next;
    next["Sunny"] = "Cloudy"; next["Cloudy"] = "Rainy"; next["Rainy"] = "Sunny";
    string str;
    cin >> str;
    cout << next[str];
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let length: i32 = buf.trim().parse().unwrap();

    let mut cards = vec![vec![], vec![], vec![], vec![]];

    for _ in 0..length {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.trim().split_whitespace();

        let mark = iter.next().unwrap();
        let num: i32 = iter.next().unwrap().parse().unwrap();

        match mark {
            mark if mark == "S" => cards[0].push(num),
            mark if mark == "H" => cards[1].push(num),
            mark if mark == "C" => cards[2].push(num),
            mark if mark == "D" => cards[3].push(num),
            _ => (),
        }
    }

    // println!("Start here");

    let mut results = [vec![], vec![], vec![], vec![]];
    for index in 0..4 {
        results[index] = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
        results[index].retain(|&value| !cards[index].contains(&value));
    }

    let marks = ["S", "H", "C", "D"];
    for mark_index in 0..marks.len() {
        for index in 0..results[mark_index].len(){
            println!("{} {}", marks[mark_index], results[mark_index].get(index).unwrap());
        }
    }
}



Measured memory_bytes: 5036
n, d = gets.chomp.split(" ").map(&:to_i)
ans = 0
count = 0
n.times do |i|
    x, y = gets.chomp.split(" ").map(&:to_i)
    ans = x ** 2 + y ** 2
    if ans <= d ** 2
        count += 1
    end
end
puts count



Measured memory_bytes: 14232
#include<bits/stdc++.h>
using namespace std;
int n,t,maxn,s;
int a[100005],p[100005];
int main(){
	scanf("%d%d",&n,&t);
	for(int i = 1; i <= n; i++)scanf("%d",&a[i]);
	for(int i = n; i >= 1; i--){
		p[i] = p[i + 1];
		p[i] = max(p[i],a[i]);
	}
	for(int i = 1; i <= n; i++)p[i] -= a[i];
	sort(p + 1,p + n + 1);
	maxn = p[n];
	for(int i = n; i >= 1; i--){
		if(p[i] != maxn) break;
		s++;
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 4520
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

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

    priority_queue<int> A;
    for(int i=0; i<N; i++){
        int t;
        cin >> t;
         A.push(t);
    }

    for(int i=0; i<M; i++){
        int t = A.top();
        A.pop();
        t /= 2;
        A.push(t);
    }

    long sum = 0;
    while(!A.empty()){
        sum += A.top();
        A.pop();
    }

    cout << sum << endl;

    return 0;

}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N, M;
  cin >> N >> M;
  vector<tuple<int, int, int>> lrc;
  rep(i, M) {
    int l, r, c;
    cin >> l >> r >> c;
    lrc.emplace_back(l, r, c);
  }
  vi64 dist(M);
  vector<vi32> adds(N);
  vector<vi32> rems(N);
  rep(i, M) {
    int l, r, c;
    tie(l, r, c) = lrc[i];
    l--, r--;
    adds[l].emplace_back(i);
    rems[r].emplace_back(i);
  }
  i64 ans = 0;
  set<pair<i64, int>> se;
  rep(i, N) {
    if (i != 0) {
      if (se.size() == 0) {
        cout << -1 << endl;
        return;
      }
      each(s, se) {
        ans = s.first;
        break;
      }
    }
    each(j, adds[i]) {
      int l, r, c;
      tie(l, r, c) = lrc[j];
      se.emplace(ans + c, j);
      dist[j] = ans + c;
    }
    each(j, rems[i]) {
      se.erase(make_pair(dist[j], j));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 13044
#include<iostream>
#include<stdio.h>
#include<algorithm>
#define ios ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int maxn=1e5+100;
int a[maxn],b[maxn];
int main()
{
	ios;
	int n,Max=0; cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]<=a[i-1]){
			b[i]++;
			b[i]+=b[i-1];
			Max=max(Max,b[i]);
		} 
	}
	cout<<Max<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int linearSearch(int[],int,int);

int main(){
  int i, n, q, key, number=0, S[10000];

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&key);
    if(linearSearch(S,n,key) != -1) number++;
  }

  printf("%d\n",number);

  return 0;
}

int linearSearch(int A[], int x, int y){
  int i;

  for(i = 0 ; i < x ; i++){
    if(A[i] == y){
      return i;
    }
  }
  return -1;
}
  



Measured memory_bytes: 2040
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<stdio.h>
#include<cstdlib>
#include<numeric>

using namespace std;

string operator*(string str, const int& n){
    if (n < 1) return "";
    string ans = "";
    for (int i = 0; i < n; i++)
        ans += str;
    return ans;
}

int count_diff(string s, string t){
    int n = s.size();
    int count = 0;
    for (int i = 0; i < n; i++){
        if (s[i] != t[i])
            count++;  
    }
    return count;
}

int main(){
    string s;
    cin >> s;
    int n = s.size();
    string str1 = "10"s * (n / 2);
    str1 += "1"s * (n % 2);
    string str2 = "01"s * (n / 2);
    str2 += "0"s * (n % 2);
    cout << min(count_diff(str1, s), count_diff(str2, s)) << endl;
}

Measured memory_bytes: 960
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int s,w;cin>>s>>w;
    if(w>=s)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}


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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;

string s, t;
string lcs;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    s+='.', t+='.';
    string stmp, ttmp;
    cin>>stmp>>ttmp;
    s+=stmp;
    t+=ttmp;
	int n1=s.size()-1;
	int n2=t.size()-1;
	vector<vector<int>> dp(n1+1, vector<int>(n2+1));
	vector<vector<pair<int, int>>> nx(n1+1, vector<pair<int, int>>(n2+1));
	
	for(int i=1; i<=n1; i++) {
		for(int j=1; j<=n2; j++) {
			int ans1=max((dp[i-1][j]), (dp[i][j-1]));
			bool flag=1;
			if(s[i]==t[j]) {
				int ans2=1+(dp[i-1][j-1]);
				if(ans2>ans1) {
					dp[i][j]=dp[i-1][j-1]+1;
					nx[i][j]={i-1, j-1};
					flag=0;
				}
			}
			if(flag) {
				dp[i][j]=(ans1==(dp[i-1][j])?dp[i-1][j]:dp[i][j-1]);
				if(ans1==dp[i-1][j]) {
					nx[i][j]={i-1, j};
				}
				else {
					nx[i][j]={i, j-1};
				}
			}
		}
	}
	function<void(int, int)> printlcs = [&](int x, int y)
	{
		if(x<=0 or y<=0) return;
		if(s[x]==t[y] and nx[x][y]==make_pair(x-1, y-1)) {
			lcs+=s[x];
		}
		int newx=nx[x][y].first;
		int newy=nx[x][y].second;
		printlcs(newx, newy);
	};
	printlcs(n1, n2);
	//~ for(int i=0; i<sz(nx); i++) {
		//~ for(int j=0; j<sz(nx[i]); j++) {
			//~ cout<<nx[i][j].first<<" "<<nx[i][j].second<<"\n";
		//~ }
	//~ }
	reverse(all(lcs));
	cout<<lcs<<"\n";
    return 0;
}



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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    ll r, c, k; cin >> r >> c >> k;
    int x = 0, y = 0;
    vector<vector<ll> > lis(r, vector<ll>(c, 0));
    vector<vector<vector<ll> > > dp(r+1, vector<vector<ll> >(c+1, vector<ll>(4, -1)));
    dp[0][0][0] = 0;
    REP(i, 0, k){
        ll r, c, v; cin >> r >> c >> v;
        r--; c--;
        lis[r][c] = v;
    }
    REP(i, 0, r){
        REP(l, 0, c){
            if(lis[i][l] != 0){
                for(int k = 2; k>= 0; k--){
                    chmax(dp[i][l][k+1], dp[i][l][k] + lis[i][l]);
                }
            }
            REP(k, 0, 4){
                chmax(dp[i][l+1][k], dp[i][l][k]);
            }
            dp[i+1][l][0] = max({dp[i+1][l][0], dp[i][l][0], dp[i][l][1], dp[i][l][2], dp[i][l][3]});
        }
    }
    ll ans = 0;
    REP(i, 0, c+1){
        chmax(ans, dp[r][i][0]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 707168
L = 1000000000000000000
r = 1
n = input()
A = list(map(int, input().split()))
A = sorted(A)
if A[0] == 0:
    print(0)
else:
    p = True
    while len(A) > 0:
        b = A.pop()
        r *= b
        if r > L:
            print(-1)
            p = False
            break
    if p: print(r)

Measured memory_bytes: 21616
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()	
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000000;
typedef pair<int,int> P;
int v[100010],p[100010],lb[100010],ub[100010];
vector<int> G[100010];
bool f=false;
int n;
void dfs(int i,int pre,int l,int r){//(頂点、前の頂点、ありうるmin、ありうるmax)
	if(p[i]!=-1){
		if(p[i]%2!=r%2||p[i]<l||p[i]>r){
    		f=true;
			return;
		}
		l=p[i];
		r=p[i];
	}
	lb[i]=l,ub[i]=r;
	for(auto &e:G[i]){
		if(e==pre)continue;
		dfs(e,i,l-1,r+1);
		lb[i]=max(lb[i],lb[e]-1);
		ub[i]=min(ub[i],ub[e]+1);
	}
}
void dfs2(int i,int pre,int l,int r){
	lb[i]=max(lb[i],l);
	ub[i]=min(ub[i],r);
	if(p[i]!=-1){
		if(p[i]<lb[i]||p[i]>ub[i]){
			f=true;
			return;
		}
	}
	for(auto &e:G[i]){
		if(e==pre)continue;
		dfs2(e,i,lb[i]-1,ub[i]+1);
	}
}
void dfs3(int i,int pre){
	if(p[i]==-1&&pre!=-1){
		if(lb[i]<=p[pre]+1&&p[pre]+1<=ub[i]){
			p[i]=p[pre]+1;
		}else if(lb[i]<=p[pre]-1&&p[pre]-1<=ub[i]){
			p[i]=p[pre]-1;
		}
	}
	for(auto &e:G[i]){
		if(e==pre)continue;
		dfs3(e,i);
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;cin>>a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int k;cin>>k;
	fill(p,p+n+1,-1);
	for(int i=0;i<k;i++){
		cin>>v[i];
		cin>>p[v[i]];
	}
	dfs(v[0],-1,p[v[0]],p[v[0]]);
	dfs2(v[0],-1,p[v[0]],p[v[0]]);
	if(f){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	dfs3(v[0],-1);
	for(int i=1;i<=n;i++){
		cout<<p[i]<<endl;
	}
}

Measured memory_bytes: 15488
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    string t;
    cin>>t;
    for(int i=0;i<t.size();i++){
        if(t[i]=='1'){
            t[i]='9';
        }else if(t[i]=='9'){
            t[i]='1';
        }
    }
    cout<<t<<endl;
 return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x = x2 - x1;
  int y = y2 - y1;

  cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

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

int h,w;
string a;
int cnt;

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

	cin>>h>>w;
	REP(i,h) {
		cin>>a;
		REP(j,w) if(a[j]=='#') cnt++;
	}
	if(cnt==h+w-1) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;

	return 0;
}


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

import static java.lang.Integer.parseInt;

/**
 * Make Purse Light
 */
public class Main {

	public static int[] values = {10, 50, 100, 500};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		boolean hasNext = false;
		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int price = parseInt(line);
			if (price == 0) break;

			int[] coins1 = new int[4];
			int[] coins2 = new int[4];

			StringTokenizer st = new StringTokenizer(br.readLine());
			coins1[0] = parseInt(st.nextToken());
			coins1[1] = parseInt(st.nextToken());
			coins1[2] = parseInt(st.nextToken());
			coins1[3] = parseInt(st.nextToken());

			int change = coins1[0] * values[0]
					+ coins1[1] * values[1]
					+ coins1[2] * values[2]
					+ coins1[3] * values[3]
					- price;

			for (int i = 3; i >= 0; i--) {
				coins2[i] = change / values[i];
				change %= values[i];
			}

			for (int i = 0; i < 4; i++) {
				coins2[i] = coins1[i] - coins2[i];
			}

			if (hasNext) System.out.println();
			for (int i = 0; i < 4; i++) {
				if (coins2[i] > 0)
					System.out.println(values[i] + " " + coins2[i]);
			}
			hasNext = true;

		} //end while
	} //end main
}

Measured memory_bytes: 31340
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
int main(){
	int n;
	cin>>n;
	vector<long long int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vector<long long int> dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(auto j:{i+1,i+2}){
			if(j<n)
				dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
		}
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;
int main() {
	long long sol=0;
	int a9=1;
	while(1) {
		int digmin=0;
		int digmax=9;
		if(sol==0) digmin=1;
		string res;
		while(digmin<digmax) {
			int hf=(digmin+digmax)/2;
			if(sol==0) {
				cout << "? " << sol*10+hf <<  "999999999" << endl;
			} else {
				cout << "? " << sol*10+hf <<  "99999999" << endl;
			}
			cin >> res;
			if(res[0]=='Y') {
				digmax=hf;
			} else {
				digmin=hf+1;
			}
		}
		if(digmin<9) a9=0;
		sol=sol*10+digmin;
		if(a9) {
			cout << "? " << (sol-1)*10 << endl;
			cin >> res;
			if(res[0]=='N') break;
		} else {
			cout << "? " << (sol+1) << endl;
			cin >> res;
			if(res[0]=='Y') break;
		}
	}
	cout << "! " << sol << endl;
	return 0;
}


Measured memory_bytes: 668
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	int n, m;
	long long int cnt=0;
	cin >> n >> m;

	int tmp;
	for (int i = 0; i < m; i++) {
		cin >> tmp;
		cnt += tmp;
	}

	if (n - cnt >= 0) {
		cout << n - cnt;
	}
	else {
		cout << -1;
	}

	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define INF 0x7fffffff
using namespace std;
string s,t;
vector<ll>mp[26];
ll dp[3002][3002];
bool ans[3002];
 
ll solve(ll i,ll j){
    if(i == s.size() || j == t.size())
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];
    if(s[i] == t[j]){
        return dp[i][j] = 1 + solve(i+1,j+1);
    }
    return dp[i][j] = max(solve(i+1,j),solve(i,j+1));
 
}
void print(ll i,ll j){
 
    if(i == s.size() || j == t.size())
        return;
    if(s[i] == t[j]){
        ans[i] = true;
        print(i+1,j+1);
        return;
    }
    if(dp[i][j+1] == dp[i][j]){
        print(i,j+1);
    }else{
        print(i+1,j);
    }
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    memset(dp,-1,sizeof dp);
    cin>>s>>t;
    solve(0,0);
    print(0,0);
    for(ll i = 0; i < 3002; i++){
        if(ans[i])
            cout<<s[i];
    }
    return 0;
}

Measured memory_bytes: 70912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string inn;
            inn = Console.ReadLine();
            if (inn[0] == inn[1] && inn [1] == inn[2])
            {
                Console.Write("Yes");
            }
            else if (inn[1] == inn[2] && inn[2] == inn[3])
            {
                Console.Write("Yes");
            }
            else
            {
                Console.Write("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
int main(void) {
	int a, b;

	cin >> a >> b;
	if ((b%a) == 0)
		cout<<a+b<<endl;
	else
		cout<<b-a << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    int n,m,a[10009],SUM=0;
    cin>>n>>m;
        for(int i=0;i<m;i++)
            cin>>a[i];
        for(int i=0;i<m;i++)
            SUM+=a[i];
            if(SUM>n)
                cout<<"-1";
            else
                cout<<n-SUM;
 }



Measured memory_bytes: 3632