akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> P;

P a[2], b[2];

bool f() {
  if(a[1].real() < b[0].real()) return false;
  if(a[1].imag() < b[0].imag()) return false;
  if(b[1].real() < a[0].real()) return false;
  if(b[1].imag() < a[0].imag()) return false;
  return true;
}

int main() {
  while(1) {
    for(int i = 0; i < 2; ++i)
      if(cin >> a[i].real() >> a[i].imag()) ; else return 0;
    for(int i = 0; i < 2; ++i)
      if(cin >> b[i].real() >> b[i].imag()) ; else return 0;
    if(f()) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

v = [N, A, B, C, D, E]
m = min(v[1:])
index = v.index(m)
ans = N // m + index
if N % m == 0:
  ans -= 1


for i in range(index+1, len(v)):
  ans += 1

print(ans)


Measured memory_bytes: 3064
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List
import Control.Monad


solve :: [Int] -> Int
solve arr =
    l - f
    where
        sorted = sort arr
        f = head sorted
        l = head (reverse sorted)

main :: IO ()
main = do
    _ <- BS.getLine
    a <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    print $ solve a


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
	while(true) {
		int n, m;
		cin >> n >> m;
		if(!n && !m) break;

		vector<int> v(n+m);
		for(int i = 0; i < n; ++i) {
			cin >> v[i];
		}
		for(int i = n; i < m+n; ++i) {
			cin >> v[i];
		}
		v.push_back(0);
		sort(v.begin(), v.end());
		int ans = 0;
		for(int i = 0; i < m+n; ++i) {
			ans = max(ans, v[i+1]-v[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
char s[105][105];
int main()
{
    long long n,m,i,j,k,x=0,y,z=0;
    string s1;
    cin>>s1;
    if(s1[0]!='A')
    {
        cout<<"WA"<<endl;
        return 0;
    }
    if(s1[s1.size()-1]=='C')
    {
        cout<<"WA"<<endl;
        return 0;
    }
    for(i=1;i<s1.size();i++)
    {
        if(i>=2 && i<=s1.size()-2)
        {
            if(s1[i]=='C')
            {
                x=1;
                z++;
            }
        }
        if(s1[i]!='A' && s1[i]!='C' && s1[i]>='A' && s1[i]<='Z')
        {
            cout<<"WA"<<endl;
            return 0;
        }
    }
    if(x==0 || z>1)
    {
         cout<<"WA"<<endl;
    }
    else
    {
        cout<<"AC"<<endl;
    }
}


Measured memory_bytes: 256
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$A = $key->A[0];
$B = $key->A[1];
$C = $key->A[2];

if (($C >= $A) && ($C <= $B)) {
  printf("Yes\n");
}
else {
  printf("No\n");
}


Measured memory_bytes: 3828
def prime_factorize(n):
    a = set()
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a%b)
a,b=map(int,input().split())
print(len(prime_factorize(gcd(a,b)))+1)

Measured memory_bytes: 3064
"""
def gcd(a, b ):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
"""
import math as f


K = int(input())
result = 0
for i in range(1,K+1):
    for j in range(1,i+1):
        for k in range(1,j+1):
            if i == j == k:
                result += f.gcd(f.gcd(i, j), k)
            elif i == j or j == k or k == i:
                result += 3 * f.gcd(f.gcd(i, j), k)
            else:
                result += 6 * f.gcd(f.gcd(i, j), k)

print(result)

Measured memory_bytes: 9136
#include<stdio.h>

int main(void)
{
  int a[100],n,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d",&a[i]);

  for(j=0;j < n;j++){
    printf("%d",a[j]);
    if(j != n-1)
      printf(" ");
  }
  printf("\n");
  for(i=1;i<n;i++){
    v = a[i];
    j = i-1;     
    while(j >= 0 && a[j] > v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    
    for(j=0;j < n;j++){
      printf("%d",a[j]);
      if(j != n-1)
	printf(" ");
    }
    printf("\n");
      
  }
  return 0;
}



Measured memory_bytes: 2136
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n = II()
d, x = LI()
A = [II() for _ in range(n)]

ans = x
for a in A:
    for i in range(101):
        if a * i + 1 <= d:
            ans += 1

print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
  int sum,s1 = 0, s2 = 0,k; 
  
  scanf("%d",&sum);
  
    s1 = sum / 500;
    s2 = sum % 500 / 5;

  
  k = s1*1000 + s2*5;
  
  printf("%d", k);
  
   
  return 0;
}

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

using namespace std;

int main() {
	int a, b, c, k;

	cin >> a >> b >> c >> k;

	while (k > 0 && b <= a) {
		b *= 2;
		k--;
	}

	while (k > 0 && c <= b) {
		c *= 2;
		k--;
	}

	if (a < b && b < c) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    
    vector<int> S;
    int cnt = 0;
    rep(i, N) {
        if (p[i] == i + 1) {
            ++cnt;
        } else {
            if (cnt != 0) S.push_back(cnt);
            cnt = 0;
        }
    }
    if (cnt != 0) S.push_back(cnt);
    
    int ans = 0;
    for (int n : S) ans += (n + 1) / 2;
    cout << ans << endl;
    return 0;
}


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

int main(){
    int s;
    cin>>s;
    int b=0;
    if(s/100==1){
        b++;
        s-=100;
    }
    if(s/10==1){
        b++;
        s-=10;
    }
    if(s==1){
        b++;
    }
    cout<<b<<endl;
}

Measured memory_bytes: 256
def solve():
    n, k = map(int, input().split())
    a = tuple(map(int, input().split()))

    x = [[0] * 2 for _ in range(50)]
    # x[j][0]:=bit_jをxで立てない
    # x[j][1]:=bit_jをxで立てる

    for j in range(50):
        b = sum(1 for x in a if (x >> j) & 1)
        x[j][0] = b << j
        x[j][1] = (n - b) << j

    dp = [-1] * 2
    dp[False] = 0
    # dp[k>=x確定]:=最大値

    for j in reversed(range(50)):
        if (k >> j) & 1:
            # bitを立てられる
            if dp[True] == -1:
                dp[True] = dp[False] + x[j][0]
            else:
                dp[True] = max(dp[True] + max(x[j]), dp[False] + x[j][0])
            dp[False] += x[j][1]
        else:
            # bitを立てられない
            if dp[True] == -1:
                pass
            else:
                dp[True] += max(x[j])
            dp[False] += x[j][0]
    return max(dp)


print(solve())


Measured memory_bytes: 14836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int h, w;
    while(cin >> w >> h, h){
        vector<P> g[10005];
        ll n=0, gi, gj;
        REP(i,h)REP(j,w){
            string s;
            cin >> s;
            if(s=="."){
                continue;
            }
            else if(s=="S")g[0].push_back({i,j});
            else if(s=="G"){
                gi = i;
                gj = j;
            }
            else{
                ll num = stoi(s);
                g[num].push_back({i,j});
                n = max(n,num);
            }
        }
        n++;
        g[n].push_back({gi,gj});
        vector<vector<ll>> dp(n+1);
        REP(i,n+1) dp[i].resize(g[i].size(),LLINF/3);
        dp[0][0] = 0;
        REP(i,n){
            REP(j,g[i].size()){
                REP(k,g[i+1].size()){
                    ll d = abs(g[i][j].first-g[i+1][k].first) + abs(g[i][j].second-g[i+1][k].second);
                    dp[i+1][k] = min(dp[i+1][k],dp[i][j] + d);
                }
            }
        }
        cout << dp[n][0] << endl;
    }
    return 0;
}   



Measured memory_bytes: 3456
from collections import Counter

N, C = map(int, input().split())
d_grid = []
for i in range(C):
    d_grid.append(tuple(map(int, input().split())))
c_list = []
for i in range(N):
    c_list.append(tuple(map(int, input().split())))

m0 = []
m1 = []
m2 = []
for i in range(N):
    for j in range(N):
        m = i + j + 2
        tmp = c_list[i][j]
        if m % 3 == 0:
            m0.append(tmp)
        if m % 3 == 1:
            m1.append(tmp)
        if m % 3 == 2:
            m2.append(tmp)

m0_count = Counter(m0)
m1_count = Counter(m1)
m2_count = Counter(m2)

ans = float("inf")

m0_cost = [0 for _ in range(C)]
m1_cost = [0 for _ in range(C)]
m2_cost = [0 for _ in range(C)]

for c1 in range(C):
    for c2 in range(C):
        cost = d_grid[c1][c2]
        m0_cost[c2] += m0_count[c1 + 1] * cost
        m1_cost[c2] += m1_count[c1 + 1] * cost
        m2_cost[c2] += m2_count[c1 + 1] * cost
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i == j or i == k or j == k:
                continue
            ans = min(ans, m0_cost[i] + m1_cost[j] + m2_cost[k])
print(ans)


Measured memory_bytes: 7492
main :: IO ()                                                                                                              
main = do                                                                                                                  
  n <- readLn :: IO Int                                                                                                    
  putStrLn $ if elem n . concat . map (\x -> filter (<=100) $ take (x+1) $ iterate (+3) (4*x)) $ [1..25]                   
    then "Yes"                                                                                                             
    else "No"

Measured memory_bytes: 508
H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            if c[i][j] > c[i][k]+c[k][j]:
                c[i][j] = c[i][k] + c[k][j]

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += c[A[i][j]][1]
print(ans)


Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int main()
{

    cin.tie(0);
    ios::sync_with_stdio(false);

    int i = 0;

    int in;

    int n;

    cin >> n;

    for(int k = 0;k < n;++k)    
    {
        cin >> in;
        
        while(true)
        {
            if(in % 2 == 1)
            {
                break;
            }
            else
            {
                ++i;
                in = in / 2;
            }
        }
    }
    
    cout << i << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
min_x = 1000
for i in range(n):
	x = int(input())
	a.append(x)
	if x % 10 and x < min_x:
		min_x = x
if min_x == 1000:
	print(0)
elif sum(a) % 10 == 0:
	print(sum(a) - min_x)
else:
	print(sum(a))


Measured memory_bytes: 3060
n=int(input())
H=list(map(int,input().split()))
if n==1:
    print('Yes')
    exit()
if H[0]-H[1]>=2:
    print('No')
    exit()
if H[0]-H[1]==1:
    H[0]-=1
for i in range(1,n):
    if H[i]>H[i-1]:
        H[i]-=1
for i in range(n-1):
    if H[i]>H[i+1]:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 63856
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            var Nuv = Sarray();
            var N = Nuv[0];
            var u = Nuv[1] - 1;
            var v = Nuv[2] - 1;
            graph = Enumerable.Range(0, (int)N).Select(_ => new List<long>()).ToArray();
            for (var i = 0; i < N - 1; ++i)
            {
                var ab = Sarray();
                var a = ab[0] - 1;
                var b = ab[1] - 1;
                graph[a].Add(b);
                graph[b].Add(a);
            }
            var dstT = Enumerable.Repeat(-1L, (int)N).ToArray();
            var dstA = Enumerable.Repeat(-1L, (int)N).ToArray();
            wfs(u, dstT);
            wfs(v, dstA);
            var maxn = v;
            for (var i = 0; i < N; ++i)
            {
                if (dstT[i] < dstA[i])
                {
                    if (dstA[maxn] < dstA[i])
                        maxn = i;
                }
            }
            var diff = dstA[maxn] - dstT[maxn];
            WriteLine(dstT[maxn] + diff - 1);
        }
        static List<long>[] graph;
        static void wfs(long r, long[] dsts)
        {
            var q = new Queue<long>();
            q.Enqueue(r);
            dsts[r] = 0;
            while (q.Any())
            {
                var nr = q.Dequeue();
                 foreach(var g in graph[nr])
                {
                    if (-1 == dsts[g])
                    {
                        dsts[g] = dsts[nr] + 1;
                        q.Enqueue(g);
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 57108
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int32_t A[100000];
int32_t UP[100000];
int32_t DOWN[100000];
int32_t dp[100000];
int32_t func(int i)
{
	if (i == N) {
		return 0;
	}
	if (dp[i] != 0) {
		return dp[i];
	}
	return dp[i]= 1 + std::min(func(DOWN[i]), func(UP[i]));
}
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> A[i];
	}
	int32_t last = 0;
	for (int32_t i = 1; i < N; ++i)
	{
		if (A[i - 1] < A[i]) {
			for (; last < i; ++last)
			{
				DOWN[last] = i;
			}
		}
	}
	for (; last < N; ++last) {
		DOWN[last] = N;
	}
	last = 0;
	for (int32_t i = 1; i < N; ++i)
	{
		if (A[i - 1] > A[i]) {
			for (; last < i; ++last)
			{
				UP[last] = i;
			}
		}
	}
	for (; last < N; ++last) {
		UP[last] = N;
	}
	out << func(0) << endl;
	return 0;
}
#endif


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000001ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323

int main() 
{
    FAST;
    ll n,k;
    cin>>n>>k;
    ll h[n];
    ll ans=0;
    for(int i=0;i<n;i++)
    {
    	cin>>h[i];
    	if(h[i]>=k)
    		ans++;
    }
    cout<<ans;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
//
int main(){
    int n,q;cin>>n;
    vector<int> v;
    rep(i,n){
       int a;cin>>a;
       v.push_back(a);
    }
    cin>>q;
    vector<pair<int,int>> vv;
    rep(i,q){
       int a,b;cin>>a>>b;
       vv.push_back(pair<int,int> (a,b));
    }
    long long ans=0;
    map<int,int> p;
    for(auto e:v){ans=ans+e; p[e]++;}
    rep(i,q){
       int t=p[vv[i].first];
       ans=ans+t*(vv[i].second-vv[i].first);
       cout<<ans<<endl;
       p[vv[i].second]+=p[vv[i].first];
       p[vv[i].first]=0;
       
    }
}

Measured memory_bytes: 8840
a= int(input())
b= int(input())
c= int(input())
x= int(input())

ret = 0
for ia in range(0, a+1):
    for ib in range(0, b+1):
        for ic in range(0, c+1):
            if 500*ia + 100*ib + 50*ic == x:
                ret += 1
print(ret)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
signed main(){
  int k;
  string s;
  cin>>k>>s;
  if(s.size()<=k){
    cout<<s<<endl;
  }else{
    rep(i,k)cout<<s[i];
    cout<<"..."<<endl;
  }

  return 0;
}


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

int main(){
    using namespace std;
    string S;
    cin >> S;
    unsigned long N{S.size()}, M{N / 2};
    for(unsigned long i{1}; i < M; ++i)if(S[i - 1] != S[M - i] || S[M - i] != S[M + i] || S[M + i] != S[N - i])return 0 & puts("No");
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 2e9;
    int N;
    cin >> N;
    vec<int> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<=100;i++){
        int now = 0;
        for(int j=0;j<N;j++) now += (i-A[j])*(i-A[j]);
        ans = min(ans,now);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 998244353

//つねに10億7などの剰余をとる構造体
//参考: https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//参考: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod  = MODA;
struct modint {
	ll x;
	modint (ll x):x(x%mod){}
	modint& operator+=(const modint a){
		(x += a.x ) %= mod;
		return *this;
	}
	modint& operator-=(const modint a){
		(x -= a.x ) %= mod;
		if (x < 0) x += mod;
		return *this;
	}
	modint& operator*=(const modint a){
		(x *= a.x ) %= mod;
		return *this;
	}
	modint& operator/=(modint a){
		ll exp = mod - 2;
		while(exp > 0){
			if(exp & 1) *this *= a.x;
			a *= a.x;
			exp >>= 1;
		}
		return *this;
	}
	modint operator+(const modint a) const{
		modint res(*this);
		return res+=a;
	}
	modint operator-(const modint a) const{
		modint res(*this);
		return res-=a;
	}
	modint operator*(const modint a) const{
		modint res(*this);
		return res*=a;
	}
	modint operator/(const modint a) const{
		modint res(*this);
		return res/=a;
	}
};
modint modpow(modint x, ll n){
	modint res=1;
	while(n > 0){
		if(n & 1) res = res * x.x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

int main() {
	int ans = 0;
	int tmp;
	int n, s; 
	cin >> n >> s;
	vector<modint> dp;
	REP(i, 6001)dp.push_back(0);
	dp[0] = modpow((ll) 2, n);
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	ll inv = MODA - 1 * (MODA / 2) % MODA;
	REP(j, n){
		for(int i = s; i >= 0; i--){
			if(dp[i].x> 0 && i+a[j] <= s)dp[i+a[j]] += dp[i] * inv;
		}
	}
	cout << dp[s].x << endl;
}

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

int main(){
  string s,t; cin >> s >> t;
  int all = 0;
  for(int i=0;i<3;i++){
     if(s.at(i) == t.at(i))all++;
  }
  cout << all << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        String[] abt = sc.nextLine().split(" ");

        int a = Integer.parseInt(abt[0]); // creation sec
        int b = Integer.parseInt(abt[1]); // creation lot num
        int t = Integer.parseInt(abt[2]); // stop sec

        int creationCount = t / a;
        int created = creationCount * b;

        System.out.println(created);
    }
}

Measured memory_bytes: 23636
/************
*
*       Eostrix
*       ......an owl who loves weed & codes occasionally !!
*
************/
#include<bits/stdc++.h>
#define sc scanf()
#define ll long long
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)

using namespace std;
bool odd_digits(int n);
void FILE_IO()
{
    IN;
    OUT;
}

int main()
{
    ///FILE_IO();
    int n,c=0;
    cin>>n;
    for(int i=1;i<=n;i++)
        if(odd_digits(i))
            c++;
    cout<<c<<endl;
    return 0;
}
bool odd_digits(int n)
{
    int d=0;
    while(n>0)
    {
        d++;
        n = n/10;
    }
    if(d%2!=0)
        return true;
    return false;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}

const int MAX = 50;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){

    ll a,b;
    cin>>a>>b;

    cout<<lcm(a,b)<<endl;
}

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

int main() {
  int S, W;
  cin >> S >> W;

  if (S > W)
    cout << "safe" << endl;
  else
    cout << "unsafe" << endl;

  return 0;
}

Measured memory_bytes: 3604
class RectangleCutting:
    def __init__(self):
        W, H, x, y = map(int, input().split())
        self.W = W
        self.H = H
        self.x = x
        self.y = y

    def main(self):
        hs = self.H * self.W / 2

        if self.__is_center():
            print(hs, 1)
        else:
            print(hs, 0)

    def __is_center(self):
        if self.x * 2 == self.W and self.y * 2 == self.H:
            return True
        else:
            return False


rectangleCutting = RectangleCutting()
rectangleCutting.main()


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

int main() {
  int x, y; cin >> x >> y;
  int ans = 0;
  if (x == 1 && y == 1) {
    cout << 1000000 << endl;
    return 0;
  }
  if (x == 1) ans += 300000;
  if (x == 2) ans += 200000;
  if (x == 3) ans += 100000;
  if (y == 1) ans += 300000;
  if (y == 2) ans += 200000;
  if (y == 3) ans += 100000;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
ax = []

for i in range(N):
	if a[i] % 4 == 0:
		ax.append(2)
	elif a[i] % 2 == 0:
		ax.append(1)
	else:
		ax.append(0)

n2 = ax.count(2)
n1 = ax.count(1)
n0 = ax.count(0)
if n2 - n0 >= 0:
	print("Yes")
elif n2 - n0 == - 1:
	if n1 == 0:
		print("Yes")
	else:
		print("No")
else:
	print("No")

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v.at(i);
  int cnt = 0;
  rep(i,n) {
    if(v[i] != i+1)
      cnt ++;
  }
  if(cnt <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  int N,K;
  cin >> N >> K;
  vector<int>X(N);
  for(int i=0; i < N; i++)
    cin >> X[i];
  int ans = 0;
  for(int i=0; i < N; i++)
    ans += 2*min(X[i], abs(X[i]-K));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
typedef pair<int, pair<int, int> > P;

const int MAX_M = 20202;

void solve(int n, int m) {
    vector<P> v(m);
    for (int i = 0; i < m; i++) {
        cin >> v[i].first >> v[i].second.first >> v[i].second.second;
    }
    sort(v.begin(), v.end());
    vector<bool> is_infect(n, false);
    is_infect[0] = true;
    for (int i = 0; i < m; i++) {
        if (is_infect[v[i].second.first - 1]) {
            is_infect[v[i].second.second - 1] = true;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (is_infect[i]) ans++;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    while (true) {
        cin >> N >> M;
        if (N == 0 && M == 0) break;
        solve(N, M);
    }
    return 0;
}


Measured memory_bytes: 3352
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

while True:
    n = input()
    if n == 0:
        break
    Smax = 0
    Smin = 10 ** 9
    for i in range(n):
        S = sum(map(int, raw_input().split()))
        Smax = max(S, Smax)
        Smin = min(S, Smin)
    print Smax, Smin


Measured memory_bytes: 5036
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;



int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  string S;
  cin >> S;
  string T;
  reverse(ALL(S));
  while(sz(S) != 0) {
    T += S.back();
    S.pop_back();
    if (sz(T) >= 2) {
      if (T[sz(T)-2] == 'S' && 
          T[sz(T)-1] == 'T') {
        T.pop_back();
        T.pop_back();
      }
    }
  }
  cout << sz(T) << endl;


  return 0;
}



Measured memory_bytes: 916
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
#define vi vector<int>
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve() {
    int n;string s;cin>>n>>s;
    int cnt[26];
    fr(i,0,25)cnt[i]=1;
    fr(i,0,n-1)cnt[s[i]-'a']++;
    ll res=1;
    fr(i,0,25){
        res=(res*cnt[i])%mod;
    }
    res=(res+mod-1)%mod;
    cout<<res<<endl;
    return ;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = ~(1 << 31);

int maxQ = 100001;
vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    sieve(maxQ);
    vi t;
    for(int i = 1;i <= maxQ;i += 2){
        if(IsPrime[i] && IsPrime[(i + 1) / 2]){
            t.pb(i);
        }
    }
    int q;
    cin >> q;
    int l, r;
    int ans;
    int i;
    while(~scanf("%d %d",&l,&r)){
        ans = 0;
        rep(i, t.size()){
            if(t[i] > r) break;
            if(t[i] >= l){
                ans++;
            }
        }
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll dep(ll a,ll b){
	if(b==0){
		return a;
	}
	return dep(b,a%b);
}
int main() {
	ll s,e,a,b;
	cin>>s>>e>>a>>b;
	ll now=dep(max(a,b),min(a,b));
	now=a/now*b;
	s--;
	//cout <<now;
	cout << e-(e/a+e/b-e/now)-(s-(s/a+s/b-s/now));
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
//IIT Kanpur FacelessMen India
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

vector<pii> a;
set<int> S1,S2;
map<int,int> M; 
int main(){
  // freopen("product.in","r",stdin);
  // freopen("product.out","w",stdout);
  int n; scanf("%d",&n);
  REP(i,n){
    int x,y;
    scanf("%d%d",&x,&y);
    a.pb(mp(x,-(i+1)));
    a.pb(mp(y,(i+1)));
  }
  sort(all(a));
  int tp=0,lp=a.size()-1;
  while(S1.count(abs(a[tp].Y))==0) S1.insert(abs(a[tp].Y)),tp++;
  while(S2.count(abs(a[lp].Y))==0) S2.insert(abs(a[lp].Y)),lp--;
  ll ans=1ll*abs(a[lp].X-a[0].X)*abs(a.back().X-a[tp].X);
  if(abs(a[0].Y)!=abs(a.back().Y)){
    M[abs(a[0].Y)]=1;
    int zp=a.size()-1;
    while(M[abs(a[zp].Y)]<1) M[abs(a[zp].Y)]++,zp--;
    REPP(j,1,tp+1) if(zp<a.size()-1){
      ans=min(ans,1ll*(a.back().X-a[0].X)*(a[zp].X-a[j].X));
      M[abs(a[j].Y)]++;
      while(zp<a.size()-1&&M[abs(a[j].Y)]>1) ++zp,M[abs(a[zp].Y)]--; 
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 23148
#include<cstdio>
#include<algorithm>
int main(){
	int n;
	scanf("%d",&n);
	long long int b[n]={};
	long long int a[n]={};;
	long long int ans=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		if(i-a[i]<0){
			ans=-1;
		}else if(b[i-a[i]]<a[i]){
			b[i-a[i]]=a[i];
		}
	}
	if(ans==0){
		for(int i=0;i<n;i++){
			ans+=b[i];
		}
	}
	for(int i=0;i<n-1;i++){
		if(a[i+1]-a[i]>1)ans=-1;
	}
	printf("%lld\n",ans);
	return 0;
}
	


Measured memory_bytes: 3328
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

typedef struct{
	int a;
	int p;
} AP;

int ASC(const int *p,const int *q){
	return ( ((AP *)p)->a - ((AP *)q)->a );
}

int main(int argc, char const *argv[])
{
	int n;
	AP ap[100003];

	scanf("%d",&n);
	for (int i = 0; i < n; ++i)	scanf("%d",&ap[i].a);
	for (int i = 0; i < n; ++i)	ap[i].p = i + 1;
	
	qsort(ap,n,sizeof(AP),ASC);
	for (int i = 0; i < n - 1; ++i)	printf("%d ", ap[i].p);
	printf("%d\n", ap[n - 1].p);
	return 0;
}

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

ll INF = 1LL << 60;
using G = vector<map<int, int>>;

int 
main() {
  int N, K; cin >> N >> K;
  vector<double> arr(N);
  rep(i, 0, N) cin >> arr[i];
  vector<double> ex(1001);
  for(double i = 1; i < 1001; i++){
    ex[i] = (1 + i) / 2;
  }

  double comp = 0;
  rep(i, 0, K){
    comp += ex[arr[i]];
  }

  double ans = comp;
  for(int i = 1; i <= N - K; i++){
    comp = comp - ex[arr[i - 1]] + ex[arr[K + i - 1]];
    if(ans < comp) ans = comp;
  }

  cout << fixed << setprecision(10) << ans << endl;

}

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

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	int c1 = 0, c2 = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A') c1++;
		if(s[i] == 'B') c2++;
	}
	if(c1 != 0 && c2 != 0)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr, sort)
import Control.Monad (forM_)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  -- n >= 2
  xs <- U.fromListN n . sort . unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let (xs0, xs1) = U.span (< 0) xs
  let (r, zs)
        | U.length xs0 == 0 =
            let xs10 = U.head xs1
                xs11 = U.tail xs1
                loop 0 !y = (U.head xs11, y) : []
                loop i !y = let !z = xs11 U.! i
                            in (y, z) : loop (i - 1) (y - z)
            in (U.sum xs11 - xs10, loop (U.length xs11 - 1) xs10)
        | U.length xs1 == 0 =
            let xs00 = U.init xs0
                xs01 = U.last xs0
                loop i !y | i < 0 = []
                          | otherwise = let !z = xs00 U.! i
                                        in (y, z) : loop (i - 1) (y - z)
            in (xs01 - U.sum xs00, loop (U.length xs00 - 1) xs01)
        | otherwise =
            let xs00 = U.init xs0
                xs01 = U.last xs0
                xs10 = U.head xs1
                xs11 = U.tail xs1
                loopP i !y | i < 0 = (xs10, y) : loopN (U.length xs00 - 1) (xs10 - y)
                           | otherwise = let !z = xs11 U.! i
                                         in (y, z) : loopP (i - 1) (y - z)
                loopN i !y | i < 0 = []
                           | otherwise = let !z = xs00 U.! i
                                         in (y, z) : loopN (i - 1) (y - z)
            in (U.sum xs1 - U.sum xs0, loopP (U.length xs11 - 1) xs01)
  print r
  forM_ zs $ \(x,y) ->
    putStrLn $ concat [show x, " ", show y]


Measured memory_bytes: 19452
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
X = list(map(int, input().split()))
l = [(i, X[i]) for i in range(N)]
l.sort(key=lambda t: t[1])
ans = [-1]*N

for i in range(N):
    if i<N//2:
        ans[l[i][0]] = l[N//2][1]
    else:
        ans[l[i][0]] = l[N//2-1][1]

for ans_i in ans:
    print(ans_i)

Measured memory_bytes: 99796
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  int A, B, x, X = 0;
  std::string str;

  cin >> A >> B;

  for(int i = A; i <= B; i++){
     x = i;
     str = std::to_string(x);

     if(str.at(0) == str.at(4) && str.at(1) == str.at(3)){
       X++;
     }

  }

  cout << X << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    void output(ll x){
        cout<<x<<' ';
        return;
    }

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vl A(n);
        rep(i,n)cin>>A[i];
        ll x1=0;
        rep(i,n){
            if(i%2==0)x1+=A[i];
            else x1-=A[i];
        }
        output(x1);
        rep(i,n-1){
            x1=A[i]*2-x1;
            output(x1);
        }
        cout<<endl;
    }

Measured memory_bytes: 3944
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353
#define MAX 100000

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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




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

	ll r;
	cin >> r;

	cout << 3 * r * r << endl;

	return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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; }

int main () {
  int a, b;
  cin >> a >> b;
  int i = b - a;
  ll ans = (ll)i*(i+1)/2 - b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int N,P;
    cin >> N >> P;
    vector<int>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i]%2 == 1) {
            cout << (long long)pow(2LL,N-1) << endl;
            return 0;
        }
    }
    if(P == 1) {
        cout << 0 << endl;
    }
    else{
        cout << (long long)pow(2LL,N) << endl;
    }
}

Measured memory_bytes: 256