akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
using namespace std;
bool so[1000000]={};
int yomax,N;
int nmax;
int ryo[30];

void bfs(){
  queue <int> Q;
  bool visited[1000000]={};
  nmax=0;
  Q.push(0);
  while(Q.empty()==0){
    int u=Q.front();
    Q.pop();
    visited[u] = 1;
    if(so[u]==0 && nmax<u)
      nmax=u;
    for(int i=0;i<N;i++)
      if(u+ryo[i]<=yomax && visited[u+ryo[i]]==0){
	visited[u+ryo[i]] =1;
	Q.push(u+ryo[i]);
      }
  }
}


int main(){
  so[0] = 1;
  so[1] = 1;
  for(int i=2;i*i<=1000000;i++)
    if(so[i] == 0)
      for(int j=2;j*i<=1000000;j++)
	so[i*j] =1;

  while(cin>>N>>yomax){
    if(N==0 && yomax==0) break;
    for(int i=0;i<N;i++)
      cin>>ryo[i];
    bfs();
    if(so[nmax]==0) cout<<nmax<<endl;
    else cout<<"NA"<<endl;
  }

  return 0;
}

Measured memory_bytes: 3328
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

ans = []
for i, ai in enumerate(a):
  ans.extend([str(i+1)] * ai)
  
for i in range(h):
  l = ans[i * w : (i + 1) * w ]
  if i % 2:
    l.reverse()
  print(' '.join(l))

Measured memory_bytes: 9628
#include<stdio.h>
#include<stdlib.h>

#define N 10000
#define NIL -1

typedef struct Node{
  int parent;
  int right;
  int left;
}node;
  
node A[N];
int n, depth[N], height[N];

void setdepth(int, int);
int setheight(int);
int getsibling(int);

int main(){
  int left, right, num, root, i, degree, sibling;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    A[i].parent = NIL;
    A[i].left = NIL;
    A[i].right = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d%d", &num, &left, &right);

    A[num].left = left;
    A[num].right = right;
    
    if(left != NIL)
      A[left].parent = num;
    if(right != NIL)
      A[right].parent = num;
  }
  for(i = 0; i < n; i++)
    if(A[i].parent == NIL)
      root = i;

  setdepth(root, 0);
  setheight(root);

  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, sibling = %d, ", i, A[i].parent, getsibling(i));

    degree = 0;
    if(A[i].left != NIL)
      degree++;
    if(A[i].right != NIL)
      degree++;

    printf("degree = %d, depth = %d, height = %d, ", degree, depth[i], height[i]);

    if(A[i].parent == NIL)
      printf("root\n");
    else if(A[i].left == NIL && A[i].right == NIL)
      printf("leaf\n");
    else
      printf("internal node\n");
  }
  
  return 0;
}

void setdepth(int i, int d){
  if(i == NIL)
    return;

  depth[i] = d;

  setdepth(A[i].left, d + 1);
  setdepth(A[i].right, d + 1);
}

int setheight(int i){
  int h1 = 0, h2 = 0;

  if(A[i].left != NIL)
    h1 = setheight(A[i].left) + 1;
  if(A[i].right != NIL)
    h2 = setheight(A[i].right) + 1;

  if(h1 >= h2)
    return height[i] = h1;

  if(h2 > h1)
    return height[i] = h2;
}

int getsibling(int i){
  if(A[i].parent == NIL)
    return NIL;

  if(A[A[i].parent].left != i)
    return A[A[i].parent].left;

  if(A[A[i].parent].right != i)
    return A[A[i].parent].right;
}
  



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll N, W; cin >> N >> W;
    vector<pair<ll, ll>> a, b, c, d;

    ll w1;
    for(int i=0; i<N; i++){
        ll w, v; cin >> w >> v;
        if(i == 0) w1 = w;

        if(w == w1) a.push_back({v, w});
        else if(w == w1+1) b.push_back({v, w});
        else if(w == w1+2) c.push_back({v, w});
        else d.push_back({v, w});
    }


    sort(a.begin(), a.end(), greater<pair<ll, ll>>());
    sort(b.begin(), b.end(), greater<pair<ll, ll>>());
    sort(c.begin(), c.end(), greater<pair<ll, ll>>());
    sort(d.begin(), d.end(), greater<pair<ll, ll>>());

    ll ans = 0LL;
    for(int i=0; i<=a.size(); i++){
        for(int j=0; j<=b.size(); j++){
            for(int k=0; k<=c.size(); k++){
                for(int l=0; l<=d.size(); l++){
                    ll weight = 0LL;
                    ll value = 0LL;

                    for(int m=0; m<i; m++) weight += a[m].second, value += a[m].first;
                    for(int m=0; m<j; m++) weight += b[m].second, value += b[m].first;
                    for(int m=0; m<k; m++) weight += c[m].second, value += c[m].first;
                    for(int m=0; m<l; m++) weight += d[m].second, value += d[m].first;
                    
                    if(weight <= W) ans = max(ans, value);

                }
            }
        }
    }

    cout << ans << endl;
}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define n 1000000

int main(){
#define int ll
  int tmp = 1;
  vi a, b;
  while(1){
    int x = tmp * (tmp + 1) * (tmp + 2) / 6;
    if(x >= 1000000) break;
    a.pb(x);
    if(x & 1) b.pb(x);
    tmp++;
  }
  dump(a,b);
  
  vi dpa(n+1,inf),dpb(n+1,inf);
  dpa[0] = 0;
  dpb[0] = 0;
  rep(i,n){
    for(int j = 0; j < sz(a) and a[j] <= i + 1; ++j)
	dpa[i+1] = min(dpa[i+1], dpa[i + 1 - a[j]] + 1);
    for(int j = 0; j < sz(b) and b[j] <= i + 1; ++j)
	dpb[i+1] = min(dpb[i+1], dpb[i + 1 - b[j]] + 1);
  }
  while(1){
    int m;
    cin >> m;
    if(m == 0) break;

    cout << dpa[m] << " " << dpb[m] << endl;
  }
}


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



int main() {
	vector<int> L;
	vector<int> R;
	int n, m,bl,br;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> bl >> br;
		L.emplace_back(bl);
		R.emplace_back(br);
	}
	sort(L.begin(), L.end());
	sort(R.begin(), R.end());
	if (R[0] - L[L.size() - 1] + 1 > 0)
		cout << R[0] - L[L.size() - 1] + 1;
	else
		cout << 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define N 2001001
#define MAX 2001
#define re register
using namespace std;
typedef long long ll;
typedef double db;
const ll mod=1000000007; 
inline void read(re ll &ret)
{
    ret=0;re char c=getchar();re bool pd=false;
    while(!isdigit(c)){pd|=c=='-';c=getchar();}
    while(isdigit(c)){ret=(ret<<1)+(ret<<3)+(c&15);c=getchar();}
    ret=pd?-ret:ret;
    return;
}
ll n,x[N],y[N],a[N],w[N],cnt[N],ans,st,dp[N],sum[N];
signed main()
{
	read(n);
	for(re int i=1;i<n;i++)
	{
		read(x[i]);
		read(y[i]);
		read(a[i]);
		w[x[i]]^=a[i];
		w[y[i]]^=a[i];
	}
	for(re int i=0;i<n;i++)
		cnt[w[i]]++;
	for(re int i=1;i<=15;i++)
	{
		ans+=cnt[i]>>1;
		st|=(cnt[i]&1)<<(i-1);
	}
	for(re int i=1;i<(1<<15);i++)
		dp[i]=dp[i>>1]+(i&1);
	for(re int i=1;i<(1<<15);i++)
		dp[i]--;
	for(re int i=1;i<(1<<15);i++)
		for(re int j=0;j<15;j++)
			if(i&(1<<j))
				sum[i]^=j+1;
	for(re int i=1;i<(1<<15);i++)
	{
		if(sum[i])
			continue;
		for(re int j=(i-1)&i;j;j=((j-1)&i))
			if(!sum[j])
				dp[i]=min(dp[i],dp[j]+dp[i^j]);
	}
	printf("%lld\n",ans+dp[st]);
	exit(0);
}
/*
9 9
9 8 7 6 2 4 5 3 1
4 9 3 6
2 9 1 8
3 8 2 4
3 9 2 7
2 8 1 6
1 9 1 9
1 3 5 7
2 3 3 3
6 6 6 6
*/


Measured memory_bytes: 7408
a = gets.to_i
if a < 600
  p 8
elsif a < 800
  p 7
elsif a < 1000
  p 6
elsif a < 1200
  p 5
elsif a < 1400
  p 4
elsif a < 1600
  p 3
elsif a < 1800
  p 2
else 
  p 1
end

Measured memory_bytes: 14320
#include<bits/stdc++.h>
using namespace std;
int n,res;
multiset <int> Set;
int main() {
	int i,a;
	cin >> n;
	for(i = 0;i < n;i++) {
		cin >> a;
		Set.insert(a);
	}
	while(!Set.empty()) {
		multiset<int>::iterator it = Set.end();
		it--;
		int x = *it;
		Set.erase(it);
		for(i = 1;i <= x;i *= 2);
		if(Set.find(i-x) != Set.end()) {
			Set.erase(Set.find(i-x));
			res++;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define FO(x) {freopen(#x".in","r",stdin);\
				freopen(#x".out","w",stdout);}
#define fir first
#define sec second
using namespace std;
typedef long long ll;
template<typename T>inline bool cmin(T &a,const T &b){ return a>b?a=b,1:0;}
template<typename T>inline bool cmax(T &a,const T &b){ return a<b?a=b,1:0;}
int a[201234];
int main(){
	int i,n,f=0;scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",a+i);
	for(i=n;i>0;i-=2)
		printf("%d ",a[i]);
	for(i=(n&1?2:1);i<=n;i+=2){
		printf("%d ",a[i]);
	}
	return 0;
}


Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Cat Snuke and a Voyage
            var line = ReadLine();
            int n = line[0];
            int m = line[1];

            if (IsRegularService(n, m))
            {
                Console.WriteLine("POSSIBLE");
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
        }

        static bool IsRegularService(int n, int m)
        {
            var services = GetRegularServices(m);

            for(int i = 2; i < n; i++)
            {
                var route1 = String.Format("{0} {1}", 1, i);
                var route2 = String.Format("{0} {1}", i, n);

                if(services.ContainsKey(route1) && services.ContainsKey(route2))
                {
                    return true;
                }
            }

            return false;
        }

        static Dictionary<string,string> GetRegularServices(int m)
        {
            var dic = new Dictionary<string, string>();

            for(int i = 0; i < m; i++)
            {
                string line = Console.ReadLine();
                dic.Add(line, null);
            }

            return dic;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<int>();

            foreach (var s in array)
            {
                int num = int.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }
    }
}

Measured memory_bytes: 40028
#include <stdio.h>

int main(){
  int N;
  int i, j;
  int V[50] = {};
  int C[50] = {};
  int max = 0;
  
  scanf("%d", &N);
  
  for(i = 0; i < N; i++){
    scanf("%d", &V[i]);
  }

  for(i = 0; i < N; i++){
    scanf("%d", &C[i]);
    if(V[i] - C[i] > 0) max += V[i] - C[i];
  }

  printf("%d", max);

  return 0;
}
  


Measured memory_bytes: 128
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };


const int N=200005;

void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<k;i++)
        ans+=a[i];
    cout<<ans<<endl;
    
}
int32_t main()
{
    IOS;
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}






Measured memory_bytes: 3656
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll q, h, s, d, n; cin >> q >> h >> s >> d >> n;
	ll two[4] = { 8 * q,4 * h,2 * s,1 * d };
	sort(two, two + 4);
	ll one[4] = { 4 * q,2 * h,1 * s };
	sort(one, one + 3);

	cout << ((n & 1) ? one[0] : 0) + two[0] * (n / 2) << endl;

	return 0;
}

Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, M, Q = rl()
A, B, C, D = [], [], [], []
for i in range(Q):
	a, b, c, d = rl()
	A.append(a-1)
	B.append(b-1)
	C.append(c)
	D.append(d)

def check(nums):
	for i in range(len(nums)-1):
		if nums[i] > nums[i+1]:
			return False
	return True

def f(nums):
	s = 0
	for i in range(Q):
		if nums[B[i]]-nums[A[i]] == C[i]:
			s += D[i]
	return s

nums = [0] * N
def myiter(M, N, i=0):
	if i == N:
		yield nums
		return
	prev = 1
	if i > 0:
		prev = nums[i-1]
	for j in range(prev,M+1):
		nums[i] = j
		for y in myiter(M, N, i+1):
			yield y


ans = 0
for nums in myiter(M, N):
	if check(nums):
		n = f(nums)
		ans = max(ans, n)
print(ans)


Measured memory_bytes: 82628
#include <cstdio>
#include <cmath>
#include <limits>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdint>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;

const ll mod = 1000000000 + 7; //10^9

int main() {
    int N;
    cin >> N;
    
    vector<ll> L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    
    ll s=0,m=0,b=0;
    int ans = 0;
    
    if (N < 3)
    {
        cout << 0;
        return 0;
    }
    for (int i = 0; i < N-2; i++)
    {
        for (int j = i+1; j < N-1; j++)
        {
            for (int k = j+1; k < N; k++)
            {
                if(L[i] <= L[j] && L[j] <= L[k]) {
                    s = L[i];
                    m = L[j];
                    b = L[k];
                }
                else if(L[i] <= L[k] && L[k] <= L[j]) {
                    s = L[i];
                    b = L[j];
                    m = L[k];
                }
                else if(L[j] <= L[i] && L[i] <= L[k]) {
                    m = L[i];
                    s = L[j];
                    b = L[k];
                }
                else if(L[j] <= L[k] && L[k] <= L[i]) {
                    b = L[i];
                    s = L[j];
                    m = L[k];
                }
                else if(L[k] <= L[i] && L[i] <= L[j]) {
                    m = L[i];
                    b = L[j];
                    s = L[k];
                }
                else if(L[k] <= L[j] && L[j] <= L[i]
                ) {
                    b = L[i];
                    m = L[j];
                    s = L[k];
                }

                

                if (s + m > b)
                {
                    // cout << s << m << b << endl;
                    if (s != m && m != b)
                    {
                        ans ++;
                    }
                    
                }
                
            }
        }
        
        
    }
    
    cout << ans;
    
    
}

Measured memory_bytes: 3612
# encoding: utf-8


class Solution:
    @staticmethod
    def linear_search():
        array_length_1 = int(input())
        array_1 = [int(x) for x in input().split()]
        array_length_2 = int(input())
        array_2 = [int(x) for x in input().split()]

        # print(len(set(array_1).intersection(set(array_2))))
        count = 0
        for i in range(array_length_2):
            if array_2[i] in array_1:
                count += 1
        print(count)


if __name__ == '__main__':
    solution = Solution()
    solution.linear_search()

Measured memory_bytes: 8580
<?php
$input = explode(' ', trim(fgets(STDIN)));
$height = intval($input[0]);
$width = intval($input[1]);
$table = [];
$flag = [];
for ($i=0; $i < $height; $i++) { 
    $tmp = trim(fgets(STDIN));
    $len = strlen($tmp);
    for ($j=0; $j < $len; $j++) { 
        if ($tmp[$j] == '#') {
            $flag[$j] = true;
        }
    }
    if (($key = strpos($tmp, '#')) !== false) {
        $table[$i] = $tmp;
    }
}
$new = [];
for ($i=0; $i < $height; $i++) { 
    $new[$i] = false;
    for ($j=0; $j < $width; $j++) { 
        if (isset($flag[$j]) &&  $flag[$j] === true) {
            if (isset($table[$i][$j])) {
                echo $table[$i][$j];
                $new[$i] = true;
            }   
        }
    }
    if ($new[$i]) {
        echo "\n";
    } 
}


Measured memory_bytes: 4604
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[201010];
ll dpsum[201010];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll>l(k), r(k);
	rep(i, k) {
		cin >> l[i] >> r[i];
	}
	ll waru = 998244353;
	dp[1] = 1;
	dpsum[1] = 1;
	for (ll i = 2;i <= n;++i) {
		rep(j, k) {
			ll li = i - r[j];
			ll ri = i - l[j];
			if (ri < 0)continue;
			li = max(li, (ll)1);
			dp[i] += dpsum[ri] - dpsum[li - 1] + waru;
			dp[i] %= waru;
		}
		dpsum[i] = dpsum[i - 1] + dp[i];
		dpsum[i] %= waru;
	}
	cout << dp[n] << endl;
	return 0;
}


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

int main()
{
    string S, T;
    cin >> S >> T;
    if (S.size() + 1 != T.size())
    {
        cout << "No\n";
        return 0;
    }
    for (int i = 0; i < S.size(); ++i)
    {
        if (S[i] != T[i])
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}


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

int main(){
  int n,m;
  cin>>n>>m;
  char a[n][n+1],b[m][m+1];
  for(int i=0;i<n;i++)
      cin>>a[i];
  for(int i=0;i<m;i++)
      cin>>b[i];
  
  bool can=0;
  for(int i=0;i<n-m+1 &&!can;i++)
    for(int j=0;j<n-m+1&&!can;j++){
      bool still=1;
      for(int k=0;k<m&&still;k++)
        for(int l=0;l<m&& still;l++)
          if(a[i+k][j+l]!=b[k][l]) still=0;
      can=still;
    }
  cout<<(can?"Yes\n":"No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
	int n,i,x;
	bool fd=true;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>x;
		if(x%2==0&&x%3!=0&&x%5!=0)
		{
			fd=false;
		}
	}
	if(fd)
	{
		cout<<"APPROVED"<<endl;
	}
	else
	{
		cout<<"DENIED"<<endl; 
	}
	return 0;
}

Measured memory_bytes: 384
N = int(input())
a = [int(input()) for _ in range(N)]

lu = a[0] - 1
count = 0

for i in range(N):
    count += 1
    if lu == 1:
        print(count)
        exit()
    lu = a[lu] - 1

if lu == 1:
    print(count)
else:
    print(-1)


Measured memory_bytes: 7084
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define vel V<long long>
#define rep(i,n) for(int i=0;i<n;i++)
vel solve(V<vel>& ab, int ex) {
	if (ex == 0) { return { 1, 0 }; }
	V<V<vel>> qab(2);
	for (vel x : ab) {
		qab[x[1] & 1].push_back({ x[0] / 2,x[1] / 2 });
		if (x[0] & 1) { qab[(x[1] + 1) & 1].push_back({ x[0] / 2,(x[1] + 1) / 2 }); }
	}
	V<vel> c(3,vel(2));
	rep(i, 2) {
		for (vel x : qab[i]) {
			int qc = (3 - x[0] + x[1]) % 3; qc = (qc + 3) % 3;
			if (qc==0) { c[i][0] ^= 1; }
			if (qc==1) { c[i][1] ^= 1; }
			if (qc == 2) { c[i][0] ^= 1; c[i][1] ^= 1; }
		}
	}
	rep(i, 2) {
		if (c[1-i] == c[2]) {
			vel ans = solve(qab[i], ex - 1);
			ans[0] *= 2; ans[1] *= 2; ans[1] += i;
			return ans;
		}
	}
	rep(i, ab.size()) { ab[i][0]++; }
	vel ans = solve(ab, ex); ans[0]--;
	return ans;
}
int main() {
	long long inf = 2e17;
	int n; cin >> n;
	V<vel> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	vel ret = solve(ab, 70);
	cout << ret[0] - inf << " " << ret[1] - inf << "\n";
}

Measured memory_bytes: 37052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
int a[maxn];
int main() {
    ll h;
    ll s=0;
    scanf("%lld",&h);
    while(h){
        h/=2;
        s=s*2+1;
    }
    printf("%lld\n",s);
	return 0;
}


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

const ll INF = 1LL << 60;

ll N;

// 先頭と最後の桁を見つける
P f(ll x) {
    string tmp = to_string(x);

    return P(tmp[0], tmp[tmp.size() - 1]);
}
int main() {
    cin >> N;

    map<P, int> mp;
    for (ll i = 1; i <= N; i++) {
        P p = f(i);
        mp[P(p.first, p.second)]++;
    }

    int ans = 0;
    for (ll i = 1; i <= N; i++) {
        P p = f(i);
        ans += mp[P(p.second, p.first)];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
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);
        TaskAtCoder solver = new TaskAtCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskAtCoder
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int[] A = new int[3];
            A[0] = in.nextInt();
            A[1] = in.nextInt();
            A[2] = in.nextInt();
            Arrays.sort(A);
            if ((A[0] == A[1] && A[1] != A[2]) || (A[1] == A[2] && A[0] != A[1]))
            {
                out.print("Yes");
            } else
            {
                out.print("No");
            }
        }

    }
}



Measured memory_bytes: 21716
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (int i = 0; i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

i64 modpow(i64 n, i64 p, i64 MOD) {
    i64 ret = 1;
    for(; p > 0; p >>= 1) {
        if (p & 1) ret = (ret * n) % MOD;
        n = (n * n) % MOD;
    }
    return ret;
}

constexpr int MOD = int(1e9) + 7;

int N;
string s;
i64 dp[100010][15];

i64 slv(int idx, int sum)
{
    if (idx >= N) {
        return (sum % 13 == 5) ? 1 : 0;
    }
    if (~dp[idx][sum]) return dp[idx][sum];

    const int hoge = modpow(10, idx, 13);

    i64 ret = 0;
    if (s[idx] == '?') {
        rep(n, 10) {
            int val = (hoge * n) % 13;
            ret = (ret + slv(idx + 1, (sum + val) % 13)) % MOD;
        }
    } else {
        int val = (hoge * (s[idx]-'0')) % 13;
        ret = (ret + slv(idx+1, (sum + val) % 13)) % MOD;
    }

    return dp[idx][sum] = ret;
}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> s;
    N = s.size();

    reverse(ALL(s));

    memset(dp, -1, sizeof(dp));
    cout << slv(0, 0) << endl;

    return 0;
}



Measured memory_bytes: 19968
N,Q = map(int,input().split())
S = input()
X = []
x = 0
check = 0
for i in S:
    if check == 1 and i == 'C':
        x += 1
        check = 0
    if i == 'A':
        check = 1
    else:
        check = 0
    X.append(x)
#print(X)
A = []
for _ in range(Q):
    l,r = map(int,input().split())
    ans = X[r-1] - X[l-1]
    A.append(ans)
for i in A:
    print(i)

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

typedef long long ll;

const int MN = 102;

int N;
vector<int> adj[MN];
int dist[MN], par[MN], dmx[MN];

void dfs0(int u, int p) {
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        dist[v] = dist[u] + 1;
        par[v] = u;
        dfs0(v, u);
    }
}

void dfs1(int u, int p, int d) {
    dmx[d] = max(dmx[d], (int)adj[u].size() - (p != -1));
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        dfs1(v, u, d + 1);
    }
}

ll calc() {
    ll ret = 1;
    for(int i = 0; i < N; i++) {
        if(ret > 1e18 / dmx[i]) return 1e18;
        ret *= dmx[i];
    }
    return ret;
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N - 1; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    if(N == 2) {
        printf("1 2");
        return 0;
    }

    dfs0(0, -1);
    int p = 0;
    for(int i = 0; i < N; i++) if(dist[i] > dist[p]) p = i;
    dist[p] = 0;
    dfs0(p, -1);
    for(int i = 0; i < N; i++) if(dist[i] > dist[p]) p = i;
    int len = dist[p];
    while(len - dist[p] < len / 2) p = par[p];

    printf("%d ", len / 2 + 1);

    ll ans = 1e18;
    if(len % 2) {
        for(int i = 0; i < N; i++) dmx[i] = 1;
        dfs1(p, par[p], 0);
        dfs1(par[p], p, 0);
        ans = min(ans, 2 * calc());
    }
    else {
        for(int i = 0; i < N; i++) dmx[i] = 1;
        dfs1(p, -1, 0);
        ans = min(ans, calc());

        for(int i = 0; i < adj[p].size(); i++) {
            int v = adj[p][i];

            for(int j = 0; j < N; j++) dmx[j] = 1;
            dfs1(p, v, 0);
            dfs1(v, p, 0);
            ans = min(ans, 2 * calc());
        }
    }

    printf("%lld", ans);
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

bool cmp (pair<int,int>& a, pair<int,int> &b) {
	if(a.S==b.S)return a.F<b.F;
	return a.S<b.S;
}

void solve(int test_case) {//236
	int n;
	cin>>n;
	vpii arr(n);
	for(int i=0;i<n;i++)cin>>arr[i].F>>arr[i].S;
	sort(arr.begin(),arr.end(),cmp);
	int t=0;
	for(auto i:arr) {
		t+=i.F;
		if(t>i.S) {
			cout<<"No";
			return;
		}
	}
	cout<<"Yes";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

int main() {
  string S;
  cin >> S;
  if(S == "RRR")
  {
  	cout << 3 << endl;
  }
  else if(S == "SSS"){
    cout << 0 << endl;
  }
  else if(S == "RRS" || S == "SRR"){
  	cout << 2 << endl;
  }
  else {
  	cout << 1 << endl;
  }
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<63;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int N,X; cin >> N >> X;
    VI L(N); REP(i,N) cin >> L[i];

    int cur = 0, ans = 1;
    REP(i,N){
        cur += L[i];
        if(cur <= X) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,n,dato;
int sorted[2000000];
int main() {
 scanf("%d",&n);
 for(i=0;i<n;i++) {
   scanf("%d",sorted+i);
 } 
 sort(sorted, sorted+n);
 n--;
 for(i=0;i<n;i++) {
   printf("%d ",sorted[i]);
 } 
 printf("%d\n", sorted[i]);

 return 0;
}


Measured memory_bytes: 10992
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

h,w = inpl()
s = [input() for _ in range(h)]
di = [[1,0],[0,-1],[-1,0],[0,1]]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            continue
        ok = False
        for y,x in di:
            ny = i + y
            nx = j + x
            if 0 <= ny < h and 0 <= nx < w:
                if s[ny][nx] == '#':
                    ok = True
        if not ok:
            print('No')
            quit()
print('Yes')

Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

string pats[4] = {"WW","WS","SW","SS"};
int N;
string str;

char calc(char a, char b, char c){
  if(a=='W' && b=='W' && c=='x') return 'W';
  if(a=='W' && b=='W' && c=='o') return 'S';
  if(a=='S' && b=='W' && c=='x') return 'S';
  if(a=='S' && b=='W' && c=='o') return 'W';
  if(a=='W' && b=='S' && c=='x') return 'S';
  if(a=='W' && b=='S' && c=='o') return 'W';
  if(a=='S' && b=='S' && c=='x') return 'W';
  if(a=='S' && b=='S' && c=='o') return 'S';
}

string solve(string pat){
  string ret(N,'.');
  ret[0] = pat[0];
  ret[1] = pat[1];
  
  REP(i,1,N+5){
    int x = (i-1+N)%N;
    int y = (i-0+N)%N;
    int z = (i+1+N)%N;

    char c = calc(ret[x],ret[y],str[y]);
    if(ret[z] == '.'){
      ret[z] = c;
    }else{
      if(ret[z] != c) return "";
    }
  }
  return ret;
}

int main(){
  cin >> N;
  cin >> str;

  string ret = "";
  rep(k,4){
    if(ret.size() > 0) break;
    ret = solve(pats[k]);
  }  

  if(ret == ""){
    cout << -1 << endl;
  }else{
    cout << ret << endl;
  }
  
  return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K, ans = 0;
	vector<int> A, used, con;
	queue<pair<int,int>> Q;
	
	cin>>N>>K;
	
	A.resize(N+1);
	used.resize(N+1);
	con.resize(N+1);
	
	for(int i = 1; i <= N; i++){
		cin>>A[i];
		
		con[A[i]]++;
		
		if(!A[i]){
			used[i] = true;
			ans++;
		}
	}
	
	for(int i = 1; i <= N; i++){
		if(!con[i]){
			Q.push(make_pair(i,K));
			// cout<<i<<" Q "<<endl;
		}
	}
	// cout<<"ans -> "<<ans<<endl;
	
	while(!Q.empty()){
		pair<int,int> t = Q.front(); Q.pop();
		
		if(used[t.first] || t.second == 0) continue;
		
		used[t.first] = true;
		
		// cout<<t.first<<endl;
		
		ans++;
		Q.push(make_pair(A[t.first],t.second-1));
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 6860
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint n, m, k;
llint dp[4005][2005][2];
llint sum[2005];

int main(void)
{
	cin >> n >> m >> k;
	if(n == 0 || m == 0){
		cout << 1 << endl;
		return 0;
	}
	
	llint d = (n+m-1) / (k-1);
	dp[0][0][0] = 1;
	for(int i = 1; i <= d; i++){
		sum[0] = (dp[i-1][0][0] + dp[i-1][0][1]) % mod;
		for(int j = 1; j <= m; j++) sum[j] = (sum[j-1] + dp[i-1][j][0] + dp[i-1][j][1]) % mod, sum[j] %= mod;
		for(int j = 0; j <= m; j++){
			dp[i][j][0] += (dp[i-1][j][0] + dp[i-1][j][1]) % mod, dp[i][j][0] %= mod;
			if(j > 0){
				llint low = max(j-(k-1), 0LL), tmp = sum[j-1];
				if(low > 0) tmp += mod - sum[low-1], tmp %= mod;
				dp[i][j][1] += tmp, dp[i][j][1] %= mod;
			}
		}
	}
	
	llint ans = 0;
	for(int i = 1; i <= d; i++){
		for(int j = 1; j <= m; j++){
			int u = (k-1)*i-j+1;
			if(u <= 0 || u > n) continue;
			if((n-u)%(k-1) || (m-j)%(k-1)) continue;
			ans += dp[i][j][1], ans %= mod;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 125568
N = int(input())
loc = [list(map(int, input().split())) for i in range(N)]
t = 0
x = 0
y = 0
i = 0
def check(X,Y):
    k=0
    global x,y,t,i
    
    d = (loc[i][0] - t) - (abs(loc[i][1] - X) + abs(loc[i][2] - Y))
    if d %2 ==0 and d >= 0: #（x、y)からはじめに行く位置を探す
        t = loc[i][0]
        x = loc[i][1]
        y = loc[i][2]
        #loc.remove(loc[i])
        k =1 #フラグ
        i += 1
         
    if k ==0:
        t = -1  #不可能

while(i < N and t!= -1):
    check(x,y)
    

if t == -1:
    print('No')

else:
    print('Yes')

#print(loc)


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

int H;

void maxHeapify(vector<ll> &A, int i){
  int l = i*2;
  int r = i*2+1;
  int largest;
  if(l <= H && A[l] > A[i])
    largest = l;
  else
    largest = i;
  if(r <= H && A[r] > A[largest])
    largest = r;
  if(largest != i){
    swap(A[i], A[largest]);
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(vector<ll> &A){
  for(int i = H/2; i >= 1; i--){
    maxHeapify(A, i);
  }
}

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

  cin >> H;
  vector<ll> A(H+1);
  for(int i = 0; i < H; i++){
    cin >> A[i+1];
  }
  buildMaxHeap(A);
  for(int i  = 0; i < H; i++){
    cout << " " << A[i+1];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4896
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();
        char[] cs = s.toCharArray();
        List<Integer> iro = new ArrayList<>();
        int x = 0;
        iro.add(x);
        for(int i = 0; i < cs.length; i++){
            if(cs[i] == 'I'){
                int a = x + 1;
                x++;
                iro.add(a);
            }
            else if(cs[i] == 'D'){
                int a = x - 1;
                x--;
                iro.add(a);
            }
        }
        Collections.sort(iro, Collections.reverseOrder());
        System.out.println(iro.get(0));
    }
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> t(n, 0), v(n, 0);
    rep(i, n) cin >> t[i], t[i] *= 2;
    rep(i, n) cin >> v[i];
    ll tt = accumulate(all(t), 0LL);
    vector<double> speed(tt + 1, 0);
    ll idx = 0, sumt = 0;
    reps(i, 1, tt) {
        if (i > (sumt + t[idx])) {
            sumt += t[idx];
            idx++;
        }
        speed[i] = speed[i - 1] + 0.5;
        speed[i] = min(speed[i], (double)v[idx]);
    }
    speed[tt - 1] = 0.5;
    idx = n - 1, sumt = 0;
    rrep(i, tt - 1) {
        speed[i] = min(speed[i], speed[i + 1] + 0.5);
        speed[i] = min(speed[i], (double)v[idx]);
        if (i == (tt - sumt - t[idx])) {
            sumt += t[idx];
            idx--;
        }
    }
    // rep(i, tt) {
    //     printf("[%lld]%.5f%s", i, speed[i], (i == (tt - 1)) ? "\n" : " ");
    // }
    double ans = 0;
    rep(i, tt) {
        ans += (speed[i] + speed[i + 1]) * 0.5 / 2.0;
    }
    printf("%.10f\n", ans);
    return 0;
}


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

// 

public class Program_ABC113_B // ←Class名変更！！
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());


        var xy = ReadLine().Split(' ');
        var t = int.Parse(xy[0]);  //x,y なのか y,xなのか注意
        var a = int.Parse(xy[1]);

        var ha = Array.ConvertAll(ReadLine().Split(' '), int.Parse);

        //Array.Sort(ha);                                           //小さい順にソート sをソート

        var tempI = -1;
        var tempV = 10000D;
        for (int i = 0; i < ha.Length; i++)
        {
            var r = t - (ha[i] * 0.006D);
            r = Abs(a - r);
            if (r < tempV)
            {
                tempI = i + 1;
                tempV = r;
            }

        }

        var result = tempI;
        WriteLine($"{result}");
        return;

    } // Main

}     // Class


Measured memory_bytes: 11220
#include<stdio.h>

int main(){
		int n,k,i;
		long long ans=0;
		scanf("%d%d",&n,&k);
		for(i=k+1;i<=n;i++){
				ans+=((n/i)*(i-k));
				if(n%i-k+1>0&&k!=0)ans+=n%i-k+1;
				else if(n%i-k>0)ans+=n%i-k;
		}
		printf("%lld\n",ans);
		return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

void solve() {
	int n; cin >> n;
	vector<P> v(n);
	rep(i, n)cin >> v[i].second;
	rep(i, n)cin >> v[i].first;
	sort(v.begin(), v.end());
	vector<int> a(n), b(n);
	rep(i, n) {
		a[i] = v[i].second;
		b[i] = v[i].first;
	}
	vector<int> as;
	rep(i, n) {
		as.push_back(a[i]);
	}
	sort(as.begin(), as.end());
	rep(i, n) {
		if (as[i] > b[i]) {
			cout << "No" << endl; return;
		}
	}
	rep1(i, n - 1) {
		if (as[i] <= b[i - 1]) {
			cout << "Yes" << endl; return;
		}
	}
	vector<P> z;
	rep(i, n) {
		z.push_back({ a[i],i });
	}
	sort(z.begin(), z.end());
	vector<int> par(n);
	rep(i, z.size()) {
		par[z[i].second] = i;
	}
	int cur = 0; int tmp = 1;
	vector<bool> used(n, false);
	used[cur] = true;
	while (true) {
		int nex = par[cur];
		if (used[nex])break;
		cur = nex; used[cur] = true; tmp++;
	}
	if (tmp == n) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	solve();
	//stop
		return 0;
}



Measured memory_bytes: 3444
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	table = map[string]string{"A": "T", "T": "A", "C": "G", "G": "C"}
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	if !sc.Scan() {
		panic(nil)
	}

	b := sc.Text()

	fmt.Printf("%s\n", table[b])

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
//priority_queue<ll, vector<ll>, std::greater<ll> > q;
#define ull 		unsigned long long
#define ll 			long long
#define M 			1000000007
#define pb 			emplace_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) // gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define hell 		(ull)1e9
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
using namespace std;

void boost()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    cout.tie(NULL);
}



int main(void)
{
    boost();
    ll n , w1;
    cin>>n>>w1;
    vi v(n);
    rep(i,0,n)
        cin>>v[i];
    ll a[n+1][w1+1];
    rep(i,0,n+1)
        a[i][0] = 1;
    rep(i,1,w1+1)
        a[0][i] = 0;
    rep(i,1,n+1){
        rep(j,1,w1+1){
            a[i][j] = (a[i-1][j] + a[i][j-1])%M;
            if ((j - v[i-1] - 1) >= 0){
                a[i][j] = a[i][j] - a[i-1][j - v[i-1] - 1];
                if (a[i][j] < 0)
                    a[i][j] = a[i][j] + M;
            }
        }
    }
    // rep(i,0,n+1){
    //     rep(j,0,w1+1)
    //         cout<<a[i][j]<<" ";
    //     cout<<"\n";
    // }
    cout<<a[n][w1];
   
}   

Measured memory_bytes: 79104
#pragma GCC optimize ("Ofast")

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

using namespace __gnu_pbds;
using namespace std;

//smaller names
#define int long long
#define double long double
#define Int signed
#define vi vector<int>
#define vvi vector<vi>
#define vd vector<double>
#define vvd vector<vd>
#define pii pair<int, int>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define mii map<int, int>
#define unordered_map gp_hash_table

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, b) for(int i = a; i < b; i++)
#define repd2(i, a, b) for(int i = b - 1; i >= a; i--)
#define repd(i, n) for(int i = n-1; i >= 0; i--)

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(),v.end()

const int INF = 1e9;
const double EPS = 1e-9;
const double PI = acosl(-1);

//order_of_key(k) - number of elements e such that func(e, k) returns true, where func is less or less_equal
//find_by_order(k) - kth element in the set counting from 0

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

typedef tree <
    int,
    null_type,
    less_equal<int>,
    rb_tree_tag,
    tree_order_statistics_node_update
>
ordered_multiset;

const int mod = 1e9 + 7;
const int maxn = 5e5 + 5;
const int maxa = 1e6 + 5;
const int logmax = 25;

//fast exponentiation

template <typename T>
T power (T a, int n = 1, T id = 1) {
    T ans = id;
    while(n) {
        if(n & 1) ans *= a;
        a *= a;
        n >>= 1;
    }
    return ans;
}

//custom hash

struct custom_hash {
    // http://xorshift.di.unimi.it/splitmix64.c
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int sumdigs (int n) {
    int ans = 0;
    while (n) {
        ans += n % 10;
        n /= 10;
    }
    return ans;
}

vi a(10);

void solve() {
    int n;
    cin >> n;
    int k;
    cin >> k;
    rep(i, k){
        int x;
        cin >> x;
        a[x]++;
    }
    for(int i = n; i <= 10*n; i++){
        int c = i;
        bool works = true;
        while(c) {
            if(a[c % 10]) {
                works = false;
                break;
            }
            c = c / 10;
        }
        if(works) {
            cout << i << endl;
            break;
        }
    }
    return;
}

signed main(){
    fastio;
    cout << setprecision(6) << fixed;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    cin >> n;

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

    for (int i = 0; i < n; i++) {
        cout << (sum ^ a[i]) << " \n"[i + 1 == n];
    }

    return 0;
}

Measured memory_bytes: 4780