akhauriyash/Code-Regression huggingface dataset:
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())
lis_row = [[0 for j in range(w)] for i in range(h)]
lis_column = [[0 for j in range(w)] for i in range(h)]
for i in range(h):
    tmp = 0
    lis = []
    for j in range(w):
        if s[i][j] == "#":
            lis.append(0)
            tmp = 0
        else:
            tmp += 1
            lis.append(tmp)
    now = 0
    for j in range(w-1, -1, -1):
        if lis[j] != 0:
            now = max(lis[j], now)
            lis_row[i][j] = now
        else:
            now = 0

for j in range(w):
    tmp = 0
    lis = []
    for i in range(h):
        if s[i][j] == "#":
            lis.append(0)
            tmp = 0
        else:
            tmp += 1
            lis.append(tmp)
    now = 0
    for i in range(h-1, -1, -1):
        if lis[i] != 0:
            now = max(lis[i], now)
            lis_column[i][j] = now
        else:
            now = 0
ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            ans = max(ans, lis_row[i][j] + lis_column[i][j] -1)
print(ans)

Measured memory_bytes: 145540
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int K = sc.nextInt();
			
			System.out.println((N + 1) / 2 >= K ? "YES" : "NO");
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

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

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 6e3+9, M = 1e7, OO = 0x3f3f3f3f;
int n, k,taken[N],mem[N][N];
pair<int,int> knap[N];

int solve(int i = n-1, int rem = k){
	if(rem <= 0)	return 0;
	if(i == -1)	return 0;
	int & ret = mem[i][rem];
	if(~ret)	return ret;
	ret = solve(i-1, rem);
	ret = max(ret, solve(i-1, rem-knap[i].first)+knap[i].second);
	return ret;
}

int print(int i = n-1, int rem = k){
	if(i == -1)	return rem;
	int ret = solve(i, rem);
	if(ret == solve(i-1, rem-knap[i].first)+knap[i].second){
		taken[i]=1;
		return print(i-1, rem-knap[i].first);
		
	}
	return print(i-1, rem);
  
}


int main()
{
  
  scanf("%d%d",&n,&k);
  memset(mem,-1,sizeof mem);
  for(int i=0;i<n;++i) scanf("%d%d",&knap[i].first,&knap[i].second);
  
  sort(knap,knap+n,greater<pair<int,int>>());
  int ans = solve();
  int rem = print();
  int last = -OO;
  if(rem>0)
  {
    for(int i=0;i<n;++i)
    {
      if(taken[i]) continue;
     last=max(last,knap[i].second);
    }
  }
  printf("%d\n",ans+max(last,0));
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

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

int main()
{
    int N, X;
    cin >> N >> X;
    int L[100] = {0};
    int x = 0;
    int ans = 1;

    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    for (int j = 0; j < N; j++)
    {
        x += L[j];
        if (x <= X)
        {
            ans++;
            continue;
        }
    }

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

Measured memory_bytes: 256
n = int(input())
if n % 2 == 1:
    print(0)
    exit()
time_5 = 1
cnt = 0
while time_5 < n:
    cnt += 1
    time_5 *= 5    
ans = 0
for i in range(1, cnt):
    mod_10 = n // (5 ** i * 2)
    ans += mod_10
print(ans)    

Measured memory_bytes: 3060
#include <cstdio>

int cnt[100005];

int main(){
	int N, a;
	scanf("%d", &N);
	for(int i=0; i<N; ++i){
		scanf("%d", &a);
		++cnt[a];
	}
	for(int i=0; i<100005; ++i){
		if(cnt[i])
			N -= cnt[i] - 1;
	}
	if(!(N & 1))
		--N;
	printf("%d\n", N);
}


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

int main(){
    int n, k; cin >> n >> k;
    bool have[n];
    rep(i, n) have[i] = false;
    rep(i, k){
        int d; cin >> d;
        rep(j, d){
            int a; cin >> a;
            have[--a] = true;
        }
    }

    int ans = 0;
    rep(i, n) if(!have[i]) ans++;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3680
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string s, t; cin >> s >> t; reverse(ALL(t));
	cout << (s == t ? "YES" : "NO") << endl;
}

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

int main() {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> A(N), F(N);
    for (auto& v : A) cin >> v;
    for (auto& v : F) cin >> v;
    sort(begin(A), end(A));
    sort(begin(F), end(F), greater<int64_t>());
    auto r = boost::irange(0l, A[N-1] * F[0]);
    cout << *partition_point(begin(r), end(r), [&](int64_t x) {
        for (int64_t i = 0, k = 0; i < N; ++i) {
            k += max(0l, A[i] - x / F[i]);
            if (k > K) return true;
        }
        return false;
    }) << '\n';
}


Measured memory_bytes: 3328
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
using namespace std;

int main(){
  int s,w;
  cin>>s>>w;
  if(s>w){
    cout<<"safe";
  }else{
    cout<<"unsafe";
  }
}



Measured memory_bytes: 3640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int x[3000], y[3000];
		set<int> memo;
		for (int i = 0; i < n; ++i)
		{
			scanf("%d%d", x + i, y + i);
			memo.insert(x[i]*10000 + y[i]);
		}

		int res = 0;
		for (int i = 0; i < n; ++i)
		{
			for (int j = i+1; j < n; ++j)
			{
				int vx = y[j]-y[i], vy = -(x[j]-x[i]);
#define ex(xx, yy) (memo.count((xx)*10000 + yy) > 0)
				if (ex(x[i]+vx, y[i]+vy) && ex(x[j]+vx, y[j]+vy)
					|| ex(x[i]-vx, y[i]-vy) && ex(x[j]-vx, y[j]-vy))
				{
					int w = abs(vx), h = abs(vy);
					res = max(res, (w+h)*(w+h) - 2*w*h);
				}
			}
		}
		printf("%d\n", res);
	}
}

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

int Zellers_congruence(int y, int m, int d) {
	int num;
	if (m < 3)num= (y - 1) + (y - 1) / 4 - (y - 1) / 100 + (y - 1) / 400 + (13 * (m + 12) + 8) / 5 + d;
	else num= y + y / 4 + -y / 100 + y / 400 + (13 * m + 8) / 5 + d;
	return num % 7;
}
//?????§???????????¬??????year+year/4-year/100+year/400+(13*month+8)/5+day
//1??? or 2 ??????????????????????????´???????????????????????¨??????????¨?????????????

int main() {
	int  m, d;
	while (true) {
		cin >> m >> d;
		if (m == 0 && d == 0)break;
		switch (Zellers_congruence(2004, m, d)) {
		case 0:cout << "Sunday" << endl; break;
		case 1:cout << "Monday" << endl; break;
		case 2:cout << "Tuesday" << endl; break;
		case 3:cout << "Wednesday" << endl; break;
		case 4:cout << "Thursday" << endl; break;
		case 5:cout << "Friday" << endl; break;
		case 6:cout << "Saturday" << endl; break;
		default:cout << "error" << endl; break;
		}
	}
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
#define MXN 200005
/*
4+4*2+3+4
*/
int main(){
    int n;
    scanf("%d",&n);
    int a[200005];
    for(int i = 1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    vector<pii> stk;
    int l[200005];
    stk.pb(mp(0,0));
    for(int i = 1;i<=n;i++){
        while(stk.back().x>a[i])stk.pop_back();
        l[i]=stk.back().y;
        stk.pb(mp(a[i],i));
    }
    int r[200005];
    stk.clear();
    stk.pb(mp(0,n+1));
    for(int i = n;i>=1;i--){
        while(stk.back().x>a[i])stk.pop_back();
        r[i]=stk.back().y;
        stk.pb(mp(a[i],i));
    }
    LL ans=0;
    for(int i = 1;i<=n;i++){
        ans+=(LL)a[i]*(r[i]-i)*(i-l[i]);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 60;
int n;
ll a[maxn];
vector<pii> ans;
int main()
{
	scanf("%d", &n);
	int pos = 1;
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%lld", &a[i]);
		if(abs(a[i]) >= abs(a[pos]))
			pos = i;
	}
	for(int i = 1; i <= n; ++i)
		if(i != pos)
			ans.emplace_back(pos, i);
	if(a[pos] >= 0)
		for(int i = 2; i <= n; ++i)
			ans.emplace_back(i - 1, i);
	else
		for(int i = n - 1; i; --i)
			ans.emplace_back(i + 1, i);
	printf("%d\n", ans.size());
	for(auto v : ans) printf("%d %d\n", v.first, v.second);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>

int main() {
	int n,r;

	scanf("%d %d",&n,&r);

	if (n >= 10) {
		printf("%d", r);
	}
	else {
			printf("%d", 100 * (10 - n) + r);
	}
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    bool solve(vector<int>& A) {
        int n = A.size();
        for (int i = n - 2; i >= 0; --i) {
            if (A[i] > A[i + 1]) {
                --A[i];
            }
            if (A[i] > A[i + 1]) {
                return false;
            }
        }

        return true;
    }

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n;++i) {
        cin >> A[i];
    }
    Solution sol;
    if (sol.solve(A)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;

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

    ll N;
    cin >> N;
    vector<pll> robots;
    for(int i = 0; i < N; i++)
    {
        ll X, L;
        cin >> X >> L;
        robots.emplace_back(X, L);
    }
    sort(robots.begin(), robots.end());
    auto robot = robots.at(0);
    ll currentHandMax = robot.first + robot.second;
    ll currentMaxRobotAt = 0;
    vector<bool> used(N, false);
    used.at(0) = true;
    for(int i = 1; i < N; i++)
    {
        ll pos, arm;
        tie(pos, arm) = robots.at(i);
        if(currentHandMax > pos - arm){
            if(pos + arm < currentHandMax)
            {
                used.at(currentMaxRobotAt) = false;
                used.at(i) = true;
                currentMaxRobotAt = i;
                currentHandMax = pos + arm;
            }
        }else{
            used.at(i) = true;
            currentMaxRobotAt = i;
            currentHandMax = pos + arm;
        }
    }
    int answer = 0;
    for(int i = 0; i < N; i++)
    {
        if(used.at(i))
        {
            answer++;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

typedef long long ll; //64bit型
using namespace std;
const ll INF = 1LL << 20;

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

int main()
{
        int A, B;
        cin >> A >> B;
        if (A == B)
        {
                cout << A + B << endl;
        }
        else
        {
                int a = max(A, B);
                cout << 2 * a - 1 << endl;
        }

        return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(f.readLine());
        int[] freq = new int[n+1];
        StringTokenizer st = new StringTokenizer(f.readLine());
        for(int i = 0; i < n-1; i++){
            freq[Integer.parseInt(st.nextToken())]++;
        }
        for(int i = 1; i <= n; i++){
            out.println(freq[i]);
        }


        out.close();
    }
}


Measured memory_bytes: 57892
/**
    And in the end, the love you take is equal to the love you make.

        I LOVE YOU LAURA.
**/

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

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_DISABLE_PERFCRIT_LOCKS

#define findOrder find_by_order
#define orderKey order_of_key

#define isOn(mask, i) (mask & (1 << i))
#define turn(mask, i) (mask |= (1 << i))
#define switch(mask, i) (mask &= ~(1 << i))
#define change(mask, i) (mask ^= (1 << i))
#define lowbit(mask) (mask & (-mask))
#define turnAll(mask, n) (mask = (1 << n) - 1)
#define switchLastBit(mask) (mask & (mask - 1))
#define turnLastZero(mask) (mask | (mask + 1))
#define modulo(x, mod) ((x) & (mod - 1))
#define log2(x) (31 - __builtin_clz(x))

#define mkp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define rsz resize
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define debug(x) (cerr << x << " ")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdb;
typedef pair<int, ii> tri;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vdb;
typedef vector<cd> vcd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> matrix;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;

const ll mod = 1e9+7;
const int maxn = 2e5+2;
const int pi = 2 * acos(0.0);
const db eps = 1e-9;

matrix Identity (int n){
    matrix A(n, vll(n));

    for (int i = 0; i < n; i++) A[i][i] = 1LL;
    return A;
}

matrix mult (const matrix &A, const matrix &B){
    matrix C(sz(A), vll(sz(B[0])));
    for (int i = 0; i < sz(C); i++){
        for (int j = 0; j < sz(C[i]); j++){
            for (int k = 0; k < sz(A[i]); k++){
                ll tmp = (A[i][k] * B[k][j]) % mod;
                C[i][j] = (C[i][j] + tmp) % mod;
            }
        }
    }
    return C;
}

matrix qpow (const matrix &A, ll e){
    if (!e) return Identity(sz(A));
    if (e & 1) return mult(A, qpow(A, e - 1));
    return qpow(mult(A, A), e >> 1);
}

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

    ll n, k; cin >> n >> k;

    matrix graph(n, vll(n));

    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            cin >> graph[i][j];
        }
    }

    matrix ans = qpow(graph, k);

    ll a = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            a = (a +  ans[i][j]) % mod;
            //cout << ans[i][j] << " ";
        }//cout << "\n";
    }

    cout << a << "\n";

    return 0;
}


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

int main() {
    int m;
    cin >> m;
    map<string, set<int>> range;
    for(int i=0; i<m; ++i) {
        string name;
        int lb, ub;
        cin >> name >> lb >> ub;
        set<int>& s = range[name];
        for(int j=lb; j<=ub; ++j) {
            s.insert(j);
        }
    }

    int n;
    cin >> n;
    vector<string> e(n);
    for(int i=0; i<n; ++i) {
        cin >> e[i];
    }
    stack<set<int>> st;
    bool f = false;
    for(int i=0; i<n; ++i) {
        if(isdigit(e[i][0])) {
            int num = stoi(e[i]);
            set<int> s = {num};
            st.push(s);
        } else if(e[i][0] == '+') {
            set<int> s1 = st.top(); st.pop();
            set<int> s2 = st.top(); st.pop();
            set<int> s;
            for(auto y : s1) {
                for(auto x : s2) {
                    s.insert((x + y) % 256);
                }
            }
            st.push(s);
        } else if(e[i][0] == '-') {
            set<int> s1 = st.top(); st.pop();
            set<int> s2 = st.top(); st.pop();
            set<int> s;
            for(auto y : s1) {
                for(auto x : s2) {
                    s.insert((x - y + 256) % 256);
                }
            }
            st.push(s);
        } else if(e[i][0] == '/') {
            set<int> s1 = st.top(); st.pop();
            set<int> s2 = st.top(); st.pop();
            set<int> s;
            if(s1.count(0) == 1) {
                f = true;
                break;
            }
            for(auto y : s1) {
                for(auto x : s2) {
                    s.insert((x / y) % 256);
                }
            }
            st.push(s);
        } else if(e[i][0] == '*') {
            set<int> s1 = st.top(); st.pop();
            set<int> s2 = st.top(); st.pop();
            set<int> s;
            for(auto y : s1) {
                for(auto x : s2) {
                    s.insert((x * y) % 256);
                }
            }
            st.push(s);
        } else {
            st.push(range[e[i]]);
        }
    }

    if(f) {
        cout << "error" << endl;
    } else {
        cout << "correct" << endl;
    }
}


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

using namespace std;

int solveDp(vector<pair<int, int>> a, int t) {
    int n = a.size();
    sort(a.begin(), a.end());
    vector<vector<int>> mem(n, vector<int>(t, -1));
    function<int(int, int)> dp;
    dp = [&] (int i, int j) {
        if (i < 0) {
            return 0;
        }
        auto &ans = mem[i][j];
        if (ans == -1) {
            ans = dp(i-1, j);
            auto cur = a[i];
            if (cur.first <= j) {
                ans = max(ans, dp(i-1, j - cur.first) + cur.second);
            }
        }
        return ans;
    };
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, dp(i-1, t-1) + a[i].second);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    auto ans = solveDp(a, t);
    cout << ans << endl;
}


Measured memory_bytes: 38852
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

//書き出して、法則性に気づけるか、特に、これまでに登場した要素に何かを加えたものが複数登場する際にqueueが使える
int main() {

int K; cin>>K;

queue<ll> q;

numrep(i,9) q.push(i);

rep(i,K){
  ll x=q.front();
  q.pop();//先頭要素の取り出し
  if(x%10!=0) q.push(x*10+x%10-1);
  q.push(x*10+x%10);
  if(x%10!=9) q.push(x*10+x%10+1);

  if(i==K-1) cout << x << endl;
}

return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
using ll=long long;

int main(){
	int n,a,num[M]={};
	ll ans=1,tmp=0;
	cin>>n;
	rep(i,0,n){
		cin>>a;
		num[a]++;
	}
	rep(i,1,100001){
		if(num[i]==2){
			tmp++;
		} else if(num[i]==0){
			continue;
		} else {
			cout<<"0"<<endl;
			return 0;
		}
	}
	rep(i,0,tmp)ans=(ans*2)%(1000000007);
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
    for(int n; scanf("%d", &n),n;) {
        int sum=0,miv=1000,mav=0;
        for(int i = 0; i < n; i++) {
            int s; scanf("%d", &s);
            sum+=s;
            miv=min(miv,s);
            mav=max(mav,s);
        }
        printf("%d\n", (sum-miv-mav)/(n-2));
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
	int last = -1;
	for (int i = 0; i < 4; i++) {
		int cur;
		scanf("%1d", &cur);
		if (last == cur) {
			puts("Bad");
			return 0;
		}
		last = cur;
	}
	puts("Good");
}


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

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

  vector<string> v;
  set<string> st;
  for (int i = 1; i <= K; i++) {
    for (int j = 0; i + j <= s.size(); j++) {
      string sub = s.substr(j, i);
      if (st.count(sub) == 0) {
        st.insert(sub);
        v.push_back(sub);
      }
    }
  }

  sort(v.begin(), v.end());

  cout << v[K - 1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main(){
	int n,a,tmp;
	long long ans=0;
	long long dp[51][51][2501]={};
	dp[0][0][0]=1;
	vector<int> x;
	cin >> n >> a;
	for(int i=0;i<n;i++){
		cin >> tmp;
		x.push_back(tmp);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			for(int k=0;k<=2500;k++){
				if(k<x[i-1]){
					dp[i][j-1][k]=dp[i-1][j-1][k];
				}else{
					dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]];
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		ans +=dp[n][i][a*i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 51072
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    int n;
    cin >> n;
    vl H(n);
    rep(i,n){
        cin >> H[i];
    }
    bool judge = true;
    if(H.size() == 1){
        cout << "Yes" << endl;
        return 0;
    }
    for(int i = n-1; i > 0; i--){
        if(H[i] < H[i-1]-1){
            cout << "No" << endl;
            judge = false;
            break;  
        }else if(H[i] < H[i-1]) H[i-1]--;
    }
    if(judge){
        if(H[0]-1 <= H[1]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
}

Measured memory_bytes: 4056
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            out.print(48 - in.nextInt());
        }

    }
}



Measured memory_bytes: 21332
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        
        for (int s = 0; s < S.length(); s++) {
        	if(T.charAt(0) == S.charAt(s) && T.startsWith(S.substring(s))) {
        		System.out.println(N*2 - (S.length() - s));
        		return;
        	}
        }
        
        System.out.println(N*2);
    }
}

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

int main(){
  int n;
  cin >> n;
  vector<long long int> a(n), b(n);
  for(int i = 0; i < n; i++){
    cin >> a[i]; a[i]--;
    b[a[i]]++;
  }

  long long int sum = 0;

  for (int i = 0; i < n; i++) {
    sum += (b[i] * (b[i]-1)) / 2;
  }

  for (int i = 0; i < n; i++) {
    cout << sum - (b[a[i]] * (b[a[i]]-1)) / 2 + ((b[a[i]]-1) * (b[a[i]]-2)) / 2 << endl;
  }
}


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
std::vector<std::string> split(const std::string &str, const char delemiter) {std::vector<std::string> res;std::stringstream ss(str);std::string buffer; while( std::getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
int msb(int x) {return x?31-__builtin_clz(x):-1;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int f(void) {
    int N; cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    string S; cin >> S;
    vector<ll> base(1,0);
    for(int i = N-1; 0 <= i; --i) {
        ll x = A[i];
        sort(ALL(base),greater<>());
        if(S[i]=='0') {
            for(auto y:base) chmin(x,x^y);
            if(x) base.push_back(x);
        }
        else{
            for(auto y:base) chmin(x,x^y);
            if(x) return 1;
        }
    }
    return 0;
}

int main() {
    int T; cin >> T;
    while(T--){
        cout << f() << endl;
    }
    return 0;
}


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

long long segTree[1000000] = {};
int segSize;

void init(int n){
  segSize = 1;
  while(segSize < n) segSize *= 2;
  return;
}

void update(int i, long long val){
  i = segSize-1+i;
  segTree[i] = val;

  while(i > 0){
    i = (i - 1) / 2;
    segTree[i] = max(segTree[i*2+1],segTree[i*2+2]);
  }

  return;
}

long long getmax(int a, int b, int k = 0, int l = 0, int r = segSize){
  if(r <= a || b <= l) return 0;
  if(a <= l && r <= b) return segTree[k];

  long long vl = getmax(a,b,2*k+1,l,(l+r)/2);
  long long vr = getmax(a,b,2*k+2,(l+r)/2,r);
  return max(vl, vr);
}

int h[200010];
long long a[200010];

priority_queue<pair<int, int> > que;
int main(){
  int n;

  cin >> n;

  init(n);
  for(int i = 0;i < n;i++){
    cin >> h[i];
    que.push(make_pair(h[i], i));
  }

  for(int i = 0;i < n;i++){
    cin >> a[i];
  }

  long long ans = 0;

  while(!que.empty()){
    int i = que.top().second;
    que.pop();

    long long next = a[i] + getmax(i+1, n);
    update(i, next);
    ans = max(ans, next);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = s; i < b; i+=d)
#define lpsb(i, s, b) for(size_t i = s; i < b; i++)
#define lpn(i, n) for(size_t i = 0; i < n; i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;
using ull = unsigned long long;

const ull MOD = 1000000007;

int main(void)
{
    int N;
    cin >> N;
    auto a = vc(int, N + 1);
    for (int i = 1; i <= N; i++) cin >> a[i];
    auto ans = vc(int, N + 1);
    int sum;
    for (int i = N / 2 + 1; i <= N; i++) ans[i] = a[i];
    for (int i = N / 2; i >= 1; i--)
    {
        sum = 0;
        for (int j = i * 2; j <= N; j += i) sum += ans[j];
        ans[i] = (sum + a[i]) % 2;
    }
    int c = 0;
    for (int i = 1; i <= N; i++) if (ans[i]) c++;
    cout << c << endl;
    for (int i = 1; i <= N; i++) if (ans[i]) cout << i << endl;
    return 0;
}

Measured memory_bytes: 2432
import heapq
N, M = map(int,input().split())
A = list(map(lambda x: int(x)*(-1),input().split()))

heapq.heapify(A) #優先度付きキュー

for i in range(M):
  tmp_min = heapq.heappop(A)
  heapq.heappush(A, (-1)*(-tmp_min//2))
print(-sum(A))


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

#define int long long

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

	int n, k;
	cin >> n >> k;

	int a[n + 1];
	for (int i = 1; i <= n; ++i) cin >> a[i];

	int x = 1, d[n + 1];
	bool v[n + 1], exit = false;
	memset(v, 0, sizeof(v));
	v[1] = true;
	d[1] = 0;
	for (int i = 1;; ++i) {
		if (k == 0) {
			cout << x;
			return 0;
		}

		x = a[x];
		--k;

		if (k == 0) {
			cout << x;
			return 0;
		}

		if (v[x] && !exit) {
			k %= (i - d[x]);
			exit = true;
		}
		if (!v[x]) {
			v[x] = true;
			d[x] = i;
		}
	}
}


Measured memory_bytes: 6912
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int A[4];
    rep(i,4) cin >> A[i];
    int ans=INF;
    int sum=accumulate(A,A+4,0);
    for(int i=0;i<3;i++) for(int j=i+1;j<4;j++) ans=min(ans,(int)abs((A[i]+A[j])-(sum-A[i]-A[j])));
    cout << ans << endl;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pp pop_back



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




int main()
{   
   ll n;
   cin>>n;
   vector<int> v;
   for(int i=0;i<2*n;i++)
   {
   	int k;
   	cin>>k;
   	v.push_back(k);
   }
   sort(v.begin(),v.end());
   ll ans=0;
   for(int i=0;i<2*n;i+=2)
   {
   	ans+=min(v[i],v[i+1]);
   	
   	  
   }
   cout<<ans<<endl;




return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
	int N, M, dp[51][3] = { 0 }, W, B, R, Min=25000;
	char c[51];


	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		scanf("%s", &c);

		for (int j = 0; j < M; j++)
		{
			if (c[j] != 'W')
				dp[i][0]++;
			if (c[j] != 'B')
				dp[i][1]++;
			if (c[j] != 'R')
				dp[i][2]++;
		}
	}
	W = 0;
	for (int i = 0; i < N - 2; i++)
	{
		W += dp[i][0];
		B = 0;
		for(int j=i+1;j<N-1;j++)
		{
			B += dp[j][1];
			R = 0;
			for (int k = j + 1; k < N; k++)
			{
				R += dp[k][2];
				
			}
			Min = min(Min, W + B + R);
		}
	}
	cout << Min << endl;
	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    string s; cin >> s;
    string ans(s.length(),'x');
    cout << ans;
}


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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#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 NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;
#define debug3(x) rep(i, sizeof(x)) cout << x[i] << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

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

template <typename T = int, typename U = ll> class MaxFlow {
public:

    struct edge {
        T to;
        U cap, rev;
    };

    map<T, vector<edge> > G;
    map<T, bool> used;

    void add_edge(T from, T to, U cap) {
        G[from].push_back((edge){to, cap, G[to].size()});
        G[to].push_back((edge){from, 0, (U) G[from].size() - 1});
    }

    U dfs(T v, T t, U f) {
        if (v == t) return f;
        used[v] = true;
        for (auto&& e : G[v]) {
            if (!used[e.to] && e.cap > 0) {
                U d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    U max_flow(T s, T t) { //sからtへの最大流
        U flow = 0;
        while (1) {
            used.clear();
            U f = dfs(s, t, INF);
            if (f == 0) return flow;
            flow += f;
        }
    }
};

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

    ll n;
    cin >> n;
    ll p_sum = 0;
    MaxFlow<> mf;
    //s : -1  t : INF

    for (int i = 1; i <= n; ++i) {
        ll a;
        cin >> a;
        if (a <= 0) {
            mf.add_edge(i, INF, -a);
        } else {
            mf.add_edge(-1, i, a);
            p_sum += a;
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = i + i; j <= n; j += i) {
            mf.add_edge(j, i, 1e15);
        }
    }

    cout << p_sum - mf.max_flow(-1, INF) << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
char p[100011];
int s[100011],q[100011],n;
int main()
{
	cin >>n;
	cin >>p;
	for(int i=0;p[i];i++)
	{
		if(p[i]=='o')
		q[i+1]=0;
		else
		q[i+1]=1;
	}
	q[n+1]=q[1];
	for(int i=0;i<8;i++)
	{
		s[0]=i&1;
		s[1]=(i>>1)&1;
		s[2]=(i>>2)&1;
		for(int j=2;j<=n+1;j++)
		s[j+1]=s[j-2]^q[j];
		if(s[0]^s[n]^s[1]^s[n+1]||s[1]^s[n+1]^s[2]^s[n+2])
		continue;
		for(int j=1;j<=n;j++)
		cout <<(s[j]^s[j-1]?"W":"S");
		cout <<endl;
		return 0;
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

typedef unsigned long long LL;

const int N_MAX = 3 * 100000;
const LL MOD = 1000000007;


int main(){
    int N;
    LL A[N_MAX];
    LL ans = 0;

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

    for(int i = 0;i < 60;i++){
        int one = 0;
        int zero = 0;
        for(int j = 0;j < N;j++){
            if((A[j] >> i) & 1ULL)one++;
            else zero++;
        }

        ans = (ans + (1ULL << i) % MOD * one % MOD * zero % MOD) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
/* kadai4_2
   Saikyo_Kazune
*/
#include <stdio.h>
#include <math.h>
int main(void){
    //πを定数として宣言
    const double PI = 3.14159265358;
   //int型　hour_hand_length,min_hand_length,hour,min宣言
   int hour_hand_length,min_hand_length,hour,min;
   //標準入力から受け取り
   scanf("%d %d %d %d",&hour_hand_length,&min_hand_length,&hour,&min);
   //hour時min分のとき時針は度数法で(hour*30+min*0.5)分針は(min*6)度 真上より時計回りに動いている
   //余弦定理で時針分針の間の角の対辺の長さの二乗を求め、平方根を取る
   //ただしcosは偶関数であるから間の角度の正負は無視してよい
   printf("%.10lf\n",sqrt(pow(hour_hand_length,2.0)+pow(min_hand_length,2.0)-2*hour_hand_length*min_hand_length*cos(PI*(hour*30+min*0.5-min*6)/180)) );
   return 0;
}

Measured memory_bytes: 2588
n,k,s = map(int, input().split())
if s == 10 ** 9:
  ans = [10 ** 9] * (k) + [10 ** 9 - 1] * (n-k)
  print(*ans)
else:
  ans = [s] * k + [s+1] * (n-k)
  print(*ans)

Measured memory_bytes: 6524
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    a = Intl()
    cnt = [0,0,0,0]#aにおける1,2の倍数(4を除く),4の倍数,othersの数
    for i in a:
        if i % 4 == 0:cnt[2] += 1
        elif i % 2 == 0:cnt[1] += 1
        elif i == 1:cnt[0] += 1
        else:cnt[3] += 1
    #print(cnt)
    if cnt[2] >= cnt[0] + cnt[1] + cnt[3] - 1:print("Yes")
    elif cnt[2] >= cnt[0] + cnt[3]  and cnt[1] >= 2:print("Yes")
    else:print("No")

Measured memory_bytes: 20456
import sys
    
global nodes
nodes = {}

def shortest_path(GRAPH):
    global nodes
    
    p1 = 0
    nodes[p1][1] = 0;

    edge={}
    total = 0
    mini = 0
    while True:
        nodes[p1][0]=True
        for p2 in range(len(nodes)):
            if nodes[p2][0]==False and GRAPH.has_key((p1, p2)):
                tmp = nodes[p1][1] + GRAPH[(p1, p2)]
                if tmp < nodes[p2][1]:
                    nodes[p2][1] = tmp

        p1 = -1
        mini = 1000000
        for p2 in range(len(nodes)):
            if nodes[p2][0]==False and nodes[p2][1]<mini:
                p1 = p2
                mini = nodes[p2][1]
        if mini == 1000000:
            break
    return

def resultout():
    for i in range(len(nodes)):
        print "%d %d" %(i, nodes[i][1])
    return

n = int(raw_input())
x = {}
for i in range(n):
    seq = map(int,raw_input().split())
    i2 = seq.pop(0)
    n2 = seq.pop(0)
    for j in range(n2):
        j2 = seq.pop(0)
        weight = seq.pop(0)
        x[(i2, j2)] = weight
    nodes[i2] = [False, 1000000]

shortest_path(x)
resultout()

Measured memory_bytes: 4816
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[100];
    cin>>a;
  int  l=strlen(a);
  int i;
  for(i=0;i<l;i++)
  {
      cout<<"x";
      if(l-1==i)
      {
          cout<<endl;
      }
  }
    return 0;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            String[] input;

            input = in.readLine().split(" ");
            int r = Integer.parseInt(input[0]);
            int c = Integer.parseInt(input[1]);

            int[][] table = new int[r + 1][c + 1];

            for (int i = 0; i < r; i++) {
                String[] arr = in.readLine().split(" ");
                int[] tmp = new int[c + 1];
                for (int j = 0; j < c; j++) {
                    tmp[j] = Integer.parseInt(arr[j]);
                }
                tmp[c] = Arrays.stream(tmp).sum();
                table[i] = tmp;
            }

            int[] sumRow = new int[c + 1];
            Arrays.fill(sumRow, 0);
            for (int i = 0; i < r; i++) {
                for (int j = 0; j < c + 1; j++) {
                   int x = table[i][j];
                   sumRow[j] += x;
                }
            }
            table[r] = sumRow;

            StringBuilder out = new StringBuilder();
            for (int i = 0; i < r + 1; i++) {
                List<String> sarr = Arrays.stream(table[i]).mapToObj(String::valueOf).collect(Collectors.toList());
                out.append(String.join(" ", sarr));
                out.append("\n");
            }
            System.out.print(out);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.exit(0);
    }
}



Measured memory_bytes: 33404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,m,ans=0;
void Main(){
    cin>>n>>m;
    if(n==1) ans+=300000;
    if(n==2) ans+=200000;
    if(n==3) ans+=100000;
    if(m==1) ans+=300000;
    if(m==2) ans+=200000;
    if(m==3) ans+=100000;
    if(n==1&&m==1) ans+=400000;
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B && A != C) cout << "Yes" <<endl;
  else if (A == C && A != B) cout << "Yes" <<endl; 
  else if (B == C && A != B) cout << "Yes" <<endl; 
  else cout << "No" << endl;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

for delim1 in range(N + 1):
    for delim2 in range(delim1, N + 1):
        yukichi = delim1
        ichiyo = delim2 - delim1
        hideyo = N - delim2
        y = yukichi * 10000 + ichiyo * 5000 + hideyo * 1000
        if y > Y:
            break
        if y == Y:
            print(yukichi, ichiyo, hideyo)
            exit(0)
else:
    print(-1, -1, -1)


Measured memory_bytes: 3188