akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=500010, Mod=1e9+7;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,m;
int res;
int siz[N],f[N];
inline int Find(int x) { return f[x]^x?f[x]=Find(f[x]):x; }
signed main()
{
    n=read(), m=read();
    for(ri int i=1;i<=n;i++) f[i]=i, siz[i]=1;
    for(ri int i=1;i<=m;i++)
    {
        int u,v;
        u=read(), v=read();
        int fx=Find(u), fy=Find(v);
        if(fx==fy) continue;
        f[fy]=fx, siz[fx]+=siz[fy];
    }
    for(ri int i=1;i<=n;i++) if(i==Find(i)) res=max(res,siz[Find(i)]);
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 6900
import numpy as np
N, M = list(map(int,input().split()))
A = np.zeros(N)
A = list(map(int,input().split()))
ans = 'Yes'
A = np.sort(A)[::-1]
su = np.sum(A)
if A[M-1] < su / (4*M):
    ans = 'No'
print(ans)

Measured memory_bytes: 14152
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)


struct Edge{
  int to, id;
};

using Edges = vector<Edge>;

void solve(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<Edges> e(n); 
  vector<int> ecol(n-1,0);
  FOR(i,0,n-1){
    int a, b;
    cin >> a >> b;
    --a; --b;
    e[a].push_back({b,i});
    e[b].push_back({a,i});
  }
  /*FOR(i,0,n){
    for(auto x:e[i]){
      cout << "(" <<x.to <<","<<x.id<<")"<<"  ";
    }
    cout << endl;
  }*/
  int smax=0;
  FOR(i,0,n){
    smax = max(smax,(int)e[i].size());
  }
  vector<int> checked(n,0);
  queue<int> Q;
  Q.push(0);
  while(!Q.empty()){
    int v = Q.front();
    int nowcol = 1;
    vector<int> chk(smax+1,0);
    chk[0] = 1; checked[v] = 1;
    for(auto x: e[v]) if(ecol[x.id] > 0) {chk[ecol[x.id]]=1;}
    for(auto x: e[v]){
      if(checked[x.to]==0) Q.push(x.to);
      if(ecol[x.id] > 0) {chk[ecol[x.id]]=1; continue;}
      //if(checked[x.to]==1) {continue;chk[ecol[x.id]]=1;continue;}
      while(chk[nowcol]==1){
        nowcol++;
        if(nowcol>smax) nowcol = 1;
      }
      if(ecol[x.id]==0) {ecol[x.id] = nowcol; chk[nowcol]=1;}
    }
    Q.pop();
    checked[v] = 1;
  }
  cout << smax << endl;
  FOR(i,0,n-1){
    cout << ecol[i] << endl;
  }
}

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


Measured memory_bytes: 7424
ns = int(input())
s = list(map(int, input().split()))

nt = int(input())
t = list(map(int, input().split()))

count = 0

for i in t:
    # 配列に番兵を追加
    s += [i]
    j = 0
    while s[j] != i:
        j += 1
    s.pop()
    if j == ns:
        continue
    count += 1

print(count)



Measured memory_bytes: 6324
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
 
int main() {
    int n;
    string s;
    cin>>n>>s;
    int m=s.length();

    rep(i,m) {
        if(s[i]+n>90)   s[i]-=26;
        cout<<char(s[i]+n);
    }
  
  
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[250001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size);
	data tmp;
	h->obj[i] = x;
	while (i > 1) {
		if (h->obj[i].key < h->obj[i>>1].key) {
			tmp = h->obj[i>>1];
			h->obj[i>>1] = h->obj[i];
			h->obj[i] = tmp;
			i >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j = i << 1;
		} else break;
	}
	return output;
}

int main()
{
	int i, N, x[501];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(x[i]));
	
	int j, M = N * N, ans[250001] = {};
	data d;
	min_heap h[2];
	h[0].size = 0;
	h[1].size = 0;
	for (i = 1; i <= N; i++) {
		ans[x[i]] = i;
		d.key = x[i];
		d.id = i;
		for (j = 1; j < i; j++) push(d, &(h[0]));
	}
	for (i = 1; i <= M; i++) {
		if (ans[i] == 0) {
			if (h[0].size > 0) {
				d = pop(&(h[0]));
				if (x[d.id] < i) break;
				else ans[i] = d.id;
			} else if (h[1].size > 0) ans[i] = pop(&(h[1])).id;
			else break;
		} else {
			d.key = i;
			d.id = ans[i];
			for (j = ans[i] + 1; j <= N; j++) push(d, &(h[1]));
		}
	}
	
	if (i <= M) printf("No\n");
	else {
		printf("Yes\n");
		for (i = 1; i < M; i++) printf("%d ", ans[i]);
		printf("%d\n", ans[M]);
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4668
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();

    if ((b >= (x - a)) && ((x - a) >= 0)) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }

  }
}

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

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


int fib(int n){
  
    if(n == 0 || n == 1){
        return 1;
    }
    
    int ans = 0;
    int fib_1, fib_2;
    fib_1 = 1;
    fib_2 = 1;
    
    for(int i = 2; i <= n; i++){
        ans = fib_1 + fib_2;
        fib_2 = fib_1;
        fib_1 = ans;
    }
    
    return ans;
}


int main(int argc, const char * argv[]) {
    
    //Input
    int n;
    scanf("%d", &n);
    
    printf("%d\n", fib(n));
           
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string s,t; cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    LL A,B,N;cin>>A>>B>>N;
    LL x=min(N,B-1);
    LL res=(LL)(A*x/B)-A*((LL)(x/B));
    cout<<res<<endl;
    return 0;
}

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

namespace AtCoder_Infinity {
    class Program {
        static void Main(string[] args) {
            string s = Console.ReadLine();
            ulong k = ulong.Parse(Console.ReadLine());
            var items = s.Select(x => int.Parse(x.ToString())).ToList();
            int ans;
            if(items[0] > 1) ans = items[0];    //最初の文字が1以外ならばそれが答え
            int p = items.Where(x => x > 1).FirstOrDefault();   //1以外の最初の値
            if(p == 0) ans = 1;                     //全部1の場合は答えは1
            else {
                int index = 0;
                for(int i = 0; i < items.Count; i++) {
                    if(items[i] == p) {
                        index = i; break;
                    }
                }
                if(k < (ulong)index + 1) ans = 1;
                else ans = p;
            }
            Console.WriteLine(ans);
        }
    }
}


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

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

    ll ans = 0;
    rep(i, 0, N){
        ll l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

map<int,map<int,int>> W;

ll dfs(ConnectNodeInfo& connect,int child,int parent,ll dist){
	ll ans=dist;
	for(auto& x:connect[child]){
		if(x.first==parent) continue;
		if(x.second<0){
			int u=child,v=x.first;
			if(u>v) swap(u,v);
			x.second = dfs(connect,x.first,child,dist)+W[u][v];
		}
		ans = max(ans,x.second);
	}
	return ans;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N=in();
	ConnectNodeInfo connect(N);
	REP(i,N-1){
		int u=in(),v=in(),w=in();
		connect.AddNonDirectionalConnection(u,v,-1);
		if(u>v) swap(u,v);
		W[u][v]=w;
	}
	
	vector<ll> H(N,0);
	REP(i,N){
		dfs(connect,i,-1,0);
	}

	REP(i,N){
		for(auto& x:connect[i]){
			H[i] = max(H[i],x.second);
		}
		out(H[i]);
	}
	return 0;
}



Measured memory_bytes: 6284
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = 10;
		int array[] = new int[N];
		for (int i = 0; i < 10; i++) {
			String line = br.readLine();
			array[i] = Integer.parseInt(line);
		}
		quickSort(0, N - 1, array);
		for (int j = N - 1; j > 6; j--) {
			System.out.println(array[j]);
		}
	}

	private static void quickSort(int bottom, int top, int[] data) {
		int lower, upper;
		if (bottom >= top)
			return;
		int div = data[bottom];
		for (lower = bottom, upper = top; lower < upper;) {
			while (lower <= upper && data[lower] <= div)
				lower++;
			while (lower <= upper && data[upper] > div)
				upper--;

			if (lower < upper) {
				int temp = data[lower];
				data[lower] = data[upper];
				data[upper] = temp;
			}
		}

		int temp = data[bottom];
		data[bottom] = data[upper];
		data[upper] = temp;

		quickSort(bottom, upper - 1, data);
		quickSort(upper + 1, top, data);

	}
}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int N=1e6+1;
#define inf 1e18+8
const int mod=1e9+7;
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define vpii vector<pair<int,int> > 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//vi arr[N];
int flag[N];
signed main()
{
    vi ans(1000001,1);
 
    int n;
    cin>>n;
    vi a(n);
    vi id(1000001,0);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(id[a[i]]==1) flag[a[i]]=1;
        id[a[i]]=1;
 
    }
    for(int i=0;i<n;i++)
    {
        for(int j=2;j<=sqrt(a[i]);j++)
        {
            if(a[i]%j==0)
            {
                if(id[j]==1) ans[i]=0;
                if(id[a[i]/j]==1) ans[i]=0;
               // arr[i].pb(j);
            }
        }
 
    }
    
    if(id[1]==1)
    {
        if(flag[1]) cout<<"0\n";
        else
        cout<<"1\n";
        return 0;
    }

    int cnt=0;
    for(int i=0;i<n;i++)
    {
       if(ans[i] && !flag[a[i]]) cnt++;
 
 
    }
    cout<<cnt<<"\n";
    
 
 
}
 
    

Measured memory_bytes: 28160
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
struct Process{
    int x;
    int y;
};
signed main(){
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int sum=0;
    vector<Process> p(n-1);
    rep(i,n){
        sum+=max(a[i],-a[i]);
    }  
    if(a[0]>0){
        sum-=2*a[0];
    }
    if(a[n-1]<0){
        sum+=2*a[n-1];
    }
    cout<<sum<<endl;
    rep1(i,n-2){
        if(a[i]>0){
            p[i-1].x=a[0];
            p[i-1].y=a[i];
            a[0]-=a[i];
        }
        else{
            p[i-1].x=a[n-1];
            p[i-1].y=a[i];
            a[n-1]-=a[i];
        }
    }
    p[n-2].x=a[n-1];
    p[n-2].y=a[0];
    rep(i,n-1){
        if(a[n-1]<0){
            p[i].x=a[0];
            p[i].y=a[i+1];
            a[0]-=a[i+1];
        }
        cout<<p[i].x<<" "<<p[i].y;
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 4224
import Data.Functor( (<$>))
import Data.List( foldl', delete)

main = do
    getLine
    cards <- lines <$> getContents
    let
	allcards = spades ++ hearts ++ clubs ++ diamonds
	  where
	    spades = ("S "++) <$> numbers
	    hearts = ("H "++) <$> numbers
	    clubs = ("C "++) <$> numbers
	    diamonds = ("D "++) <$> numbers
	    numbers = show <$> [1..13]

	remain = foldl' (flip delete) allcards cards

    putStrLn `mapM_` remain




Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int a, b;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d%d", &a, &b);
    if(a > b) swap(a, b);
    if(a > 1)
    {
        printf("%lld\n", 1ll * (a - 2) * (b - 2));
    }
    else if(a == 1)
    {
        if(b == 1) printf("1\n");
        else printf("%d\n", b - 2);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI acos(-1)
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 

 
typedef long long int ll;
 
using namespace std;

const int N = 1e5+5;

vector<int> Graph[N];
pair<int,int> minDist[N];
bool visited[N];

int bfs(int pos){
    int out = 1;
    visited[pos] = true;
    queue<int> q;
    q.push(pos);
    while (!q.empty())
    {
        int pt = q.front();q.pop();
        //cout<<pt<<" node \n";
        for(auto it : Graph[pt]){
            if(!visited[it]){
                q.push(it);
                visited[it] = true;
                //cout<<it<<" visiting\n";
                out++;
            }
            if(minDist[it].second > minDist[pt].second+1){
                minDist[it] = {pt,minDist[pt].second+1};
            }
        }
    }
    return out;
}
 
int main(){
    FIN;
    //freopen("../input.txt", "r", stdin);
    int n,M;cin>>n>>M;
    fore(i,0,n){
        minDist[i] = {-1,1e9};
        visited[i] = false;
    }
    minDist[0] = {0,0};
    fore(i,0,M){
        int a,b;cin>>a>>b;a--;b--;
        Graph[a].pb(b);
        Graph[b].pb(a);
    }   
    int vist = bfs(0);
    if(vist == n){
        cout<<"Yes\n";
        fore(i,1,n){
            cout<<minDist[i].first+1<<"\n";
        }
    }else{
        cout<<"No\n";
    }
    return 0;
}

// ============== Notes =============== //
// common bugs
// - remove reader 
// - fastio
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?, is MAXN correct?)
// - special cases (n=1, graph not connected?)
// - re-initialize efficiently between test cases

Measured memory_bytes: 11060
#include <stdio.h>

int selCnt(int, int);

int main(void)
{
    int n, t;
    while (scanf("%d %d", &n, &t) && n)
        printf("%d\n", selCnt(n, t));
    
    return 0;            
}

int selCnt(int max, int target)
{
    int i, j, k;
    int cnt = 0;
    for (i = 1; i <= max - 2; i++)
        for (j = i + 1; j <= max - 1; j++)
            for (k = j + 1; k <= max; k++)
                if (i + j + k == target)
                    cnt++;
    return cnt;
}


Measured memory_bytes: 2036
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..m)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut dp = vec!["unko".to_string(); n + 9];
    dp[0] = "".to_string();
    let maxs = |a: String, b: String| -> String {
        if a == "unko" || a.len() < b.len() {
            b
        } else if a.len() > b.len() {
            a
        } else {
            max(a, b)
        }
    };
    let b = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6].to_vec();
    for i in 0..n {
        for &j in a.iter() {
            if dp[i] == "unko".to_string() {
                continue;
            }
            dp[i + b[j]] = maxs(dp[i + b[j]].clone(), dp[i].clone() + &j.to_string());
        }
    }
    println!("{}", dp[n]);
}


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

using namespace std;

const int N = 4e5 + 5;
const long long infll = 1e18;
vector<pair<int, int>> g[N];
int num[N], n;

void build(int id = 1, int l = 0, int r = n) {
  if (r-l < 2) {
    num[l] = id;
    return;
  }
  int mid = (l + r) >> 1, il = id << 1, ir = il | 1;
  g[il].emplace_back(id, 0);
  g[ir].emplace_back(id, 0);
  build(il, l, mid);
  build(ir, mid, r);
}

void add(int x, int y, pair<int, int> v, int id = 1, int l = 0, int r = n) {
  if (x >= r || l >= y) return;
  if (x <= l && r <= y) {
    g[id].push_back(v);
    return;
  }
  int mid = (l + r) >> 1, il = id << 1, ir = il | 1;
  add(x, y, v, il, l, mid);
  add(x, y, v, ir, mid, r);
}

long long dist[N];

int main() {
  int m;
  scanf("%d %d", &n, &m);
  build();
  for (int i = 0; i < m; ++i) {
    int l, r, c;
    scanf("%d %d %d", &l, &r, &c);
    --l, --r;
    add(l, r, make_pair(num[r], c));
  }
  priority_queue<pair<long long, int> > pq;
  pq.emplace(0, num[0]);
  fill(dist, dist+N, infll);
  dist[num[0]] = 0;
  while (!pq.empty()) {
    long long d = -pq.top().first;
    int v = pq.top().second;
    pq.pop();
    if (dist[v] != d) continue;
    for (auto e : g[v]) {
      long long newd = d + e.second;
      if (newd < dist[e.first]) {
        dist[e.first] = newd;
        pq.emplace(-newd, e.first);
      }
    }
  }
  long long ans = dist[num[n-1]];
  if (ans >= infll)
    ans = -1;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 36852
H,W=map(int,input().split())

ans=0       # 裏の数

# 1*1
if H==1 and W==1:
    ans+=1

# 4隅以外の端
if W<2 and H>=3:
    ans+=(H-2)
if H<2 and W>=3:
    ans+=(W-2)

# 上記以外
if H>=3 and W>=3:
    ans+=(H-2)*(W-2)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
map<int, int> cnt;
vector<int> vec;
int n, a, sqare = 0;
int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a);
        if(cnt[a]) {
            vec.push_back(a);
        }
        cnt[a]++;
    }
    sort(vec.begin(), vec.end(), greater<int>());
    if(vec.size() > 0 && cnt[vec[0]] >= 4) {
        sqare = 1;
    }
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    if(vec.size() >= 2) {
        if(sqare) {
            printf("%lld\n", (long long) vec[0] * (long long ) vec[0]);
        }else {
            printf("%lld\n", (long long) vec[0] * (long long ) vec[1]);
        }
    }else {
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;

signed main()
{
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    std::ios::sync_with_stdio(false);
    int t = 1;
    // cin >> t;
    while (t--) {
        int k; string s;
        cin >> k >> s;
        if (s.size() <= k) {
            cout << s;
        } else {
            cout << s.substr(0, k) << "...";
        }
    }
    return 0;
}

Measured memory_bytes: 3648
let rec print_rect x =
  let (h,w) = Scanf.scanf "%d %d\n" (fun x y -> (x,y) )in
  match (h,w) with
    (0,0) -> ()
  | (h,w) ->
     for i=1 to h do
       for j=1 to w do
         print_string "#"
       done;
       print_newline ();
     done;
     print_newline ();
     print_rect x;;
 let () = print_rect ();;

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

int main(){
    string w;
    cin >> w;
    map<char, int> charmap;

    for(int i = 0; i < w.size(); ++i){

        charmap[w[i]]++;
    }

    bool flg = true;

    for(auto elem : charmap){
        
        if(elem.second % 2 == 1) flg = false;
    }
    
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char num[200010];
    long long count = 0;

    fgets(num, sizeof(num), stdin);

    for (int i=0; num[i]!='\n'; i++)
    {
        count += num[i] - '0';
        //printf("%d\n", count);
    }

    //printf("count = %d\n", count);

    if (count % 9 == 0) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 1676
C=[list(map(int,input().split())) for _ in range(3)]
if C[0][0]-C[0][1]==C[1][0]-C[1][1]==C[2][0]-C[2][1]and C[0][1]-C[0][2]==C[1][1]-C[1][2]==C[2][1]-C[2][2] \
and C[0][0]-C[1][0]==C[0][1]-C[1][1]==C[0][2]-C[1][2] and C[1][0]-C[2][0]==C[1][1]-C[2][1]==C[1][2]-C[2][2]:
    print('Yes')

else: print('No')

Measured memory_bytes: 3064
n = int(input())
l = [int(i) for i in input().split()]

total = 0
ct = 0
min_num = 10**9
for i in l:
    total += abs(i)
    ct += 1 if i < 0 else 0
    min_num = min(min_num,abs(i))

if ct%2:
    print(total - min_num*2)
else:
    print(total)

Measured memory_bytes: 14412
#include <iostream>

int main(void)
{
    char a, b;
    std::cin >> a >> b;
    if (a < b)
    {
        std::cout << '<';
    }
    else if (a > b)
    {
        std::cout << '>';
    }
    else
    {
        std::cout << '=';
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	ll N,K; cin >> N >> K;
	vector<pll> A(N);
	rep(i,N) cin >> A[i].second >> A[i].first;

	sort(all(A)); reverse(all(A));
	ll m = 0;
	ll val = 0;
	set<int> dic;
	vector<ll> B,C;
	B.emplace_back(0);
	C.emplace_back(0);
	rep(i,N) {
		if (i < K) {
			if (dic.count(A[i].second)) {
				B.emplace_back(A[i].first);
			} else {
				val += A[i].first;
				m++;
				dic.emplace(A[i].second);
			}
		} else {
			if (dic.count(A[i].second)) continue;
			C.emplace_back(A[i].first);
			dic.emplace(A[i].second);
		}
	}

	rep(i,B.size()-1) B[i+1] += B[i];
	rep(i,C.size()-1) C[i+1] += C[i];
	ll ans = 0;
	int g = min(K - m,ll(C.size()-1));
	rep(i,g+1) {
		ll p = 0;
		p += C[i];
		p += B[B.size()-1-i];
		chmax(ans,val +p+ (m+i)*(m+i));
	}

	cout << ans << ln;
}

Measured memory_bytes: 6904
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				int r = -1;
				for (int x = 0; x <= 9; x++)
				{
					var ns = s.Split(new char[] { '+', '=' });
					if (x == 0 &&
						((ns[0].Length >= 2 && ns[0].First() == 'X') ||
						(ns[1].Length >= 2 && ns[1].First() == 'X') ||
						(ns[2].Length >= 2 && ns[2].First() == 'X')))
						continue;
					ns = ns.Select(st => st.Replace("X", x.ToString())).ToArray();
					if (ns[2] == f(ns[0], ns[1]))
						r = x;
				}
				Console.WriteLine("{0}", r >= 0 ? r.ToString() : "NA");
			}
		}

		static string f(string n1, string n2)
		{
			var r = new List<int>();
			int f = 0;
			for (int i = 0; ; i++)
			{
				if (i >= n1.Length && i >= n2.Length && f != 1) break;
				int c = f;
				f = 0;
				if (i < n1.Length) c += n1[n1.Length - i - 1] - '0';
				if (i < n2.Length) c += n2[n2.Length - i - 1] - '0';
				if (c > 9) f = 1;
				r.Add(c % 10);
			}
			r.Reverse();
			return new string(r.Select(i => (char)('0' + i)).ToArray());
		}
	}
}

Measured memory_bytes: 6300
A,D = map(int,input().split())
X = list(map(int,input().split()))
C = [0]
q = 0
for i in range(A):
  if i == 0:
    p = X[0]
    C.append(p)
  else:
    p = p + X[i]
    C.append(p)
for i in C:
  if D >= i:
    q += 1

print(q)

Measured memory_bytes: 3060
n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

ans = 0

for i in range(n-1):
    diff = a[i] + a[i+1] - x
    if diff > 0:
        ans += diff
        if a[i+1] >= diff:
            a[i+1] -= diff
        else:
            a[i] -= diff - a[i+1]
            a[i+1] = 0

print(ans)


Measured memory_bytes: 14468
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;
static const int MAX_M = 100000;

int N, M;
int A[MAX_M], B[MAX_M];

int par[MAX_N];
int rnk[MAX_N];
int S[MAX_N];

void init(int N){
	for(int i = 0; i < N; i++){
		par[i] = i;
		rnk[i] = 0;
		S[i] = 1;
	}
}
int find(int x){
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}
void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(rnk[x] < rnk[y]){
		par[x] = y;
		S[y] += S[x];
	}else{
		par[y] = x;
		S[x] += S[y];
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
}
bool same(int x, int y){
	return find(x) == find(y);
}

int main(){
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
	}
	reverse(A, A + M);
	reverse(B, B + M);
	init(N);
	ll res = 0LL;
	vector<ll> va;
	for(int i = 0; i < M; i++){
		if(same(A[i], B[i])) va.push_back(0LL);
		else va.push_back((ll)S[find(A[i])] * (ll)S[find(B[i])]);
		if(i != 0) va[i] += va[i - 1];
		unite(A[i], B[i]);
	}
	reverse(va.begin(), va.end());
	for(int i = 0; i < M; i++){
		if(i == M - 1) cout << va[0] << endl;
		else cout << va[0] - va[i + 1] << endl;
	}
	return 0;
}



Measured memory_bytes: 4212
// https://atcoder.jp/contests/abc063/tasks/arc075_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int n, a, b;
vector<int> v;
bool check(ll x) {
    ll c = 0;
    auto it = lower_bound(ALL(v), b * x);
    while (it != v.end()) {
        // 全体にbダメージ * x回
        ll h = *it - x * b;
        if (h > 0) {
            // a - b の追加ダメージ
            c += ceil((double)h / (a - b));
        }
        it++;
    }
    return c <= x;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> a >> b;
    v.resize(n);
    REP(i, n) cin >> v[i];
    sort(ALL(v));
    int ng = 0, ok = v[n - 1] * 2;
    while (ng + 1 != ok) {
        int x = (ng + ok) / 2;
        if (check(x))
            ok = x;
        else
            ng = x;
    }
    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 640
using System;

namespace ABC_069_B_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int a = s.Length;
            int b = a - 2;
            Console.WriteLine(s[0] + b.ToString() + s[a - 1]);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 17484
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <iostream>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

int H, N;
vector<pair<int, int>> M(1001);
vector<ll> dp(10010, LLONG_MAX);

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

    cin >> H >> N;
    REP(i, N) { cin >> M[i].first >> M[i].second; }
    dp[0] = 0;
    FOR(h, 1, H + 1) {
        REP(i, N) {
            dp[h] = min(dp[h], dp[max(0, h - M[i].first)] + M[i].second);
        }
    }
    cout << dp[H] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll x,ans;
  cin >> x;
  ans = x/11;
  ans *= 2;
  x %= 11;
  if(x == 0);
  else if(x <= 6)ans++;
  else ans += 2; 
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine();
		long wa = 0;
		for(int i = 0; i < n.Length; i++)
		{
			if(n[i] == '1')
				wa++;
		}
		Console.WriteLine(wa);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11092
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
void fx(vector<int> &a,int n, int m){

}

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

int arr[3000000];
void input(int n){
	for(int i=0;i<n;++i)
	cin>>arr[i];
}

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



void q1(){
	int n;
	cin>>n;
	n*=(n+1);
	n/=2;
	cout<<n;
}
// -----------------------------------------------------------------------


void q2(){
	string s,t;
	cin>>s;
	t="";
	int skip=0;
	for(int i=(int)s.size()-1;i>=0;i--){
		if(s[i]=='B'){
			skip++;
		} else{
			if(skip>0){
				skip--;
			} else{
				t+=s[i];
			}
		}
	}
	for(int i=sz(t)-1;i>=0;--i)
	cout<<t[i];
}

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

void q3(){
	int n;
	input(n);
	ld sum=0;
	for(int i=0;i<n;++i){
		sum+=arr[i];
	}
	sum/=n;
	int l=sum;
	sum+=1;
	int u=sum;
	int pp,p;
	pp=0;
	for(int i=0;i<n;++i){
		pp+=((arr[i]-sum)*(arr[i]-sum));
	}p=0;
	for(int i=0;i<n;++i){
		p+=((arr[i]-sum)*(arr[i]-sum));
	}
	cout<<min(p,pp);
}


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

void q4(){
	string s;
	cin>>s;
	int xp=sz(s);
	for(int i=0;i<xp-2;++i){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2<<endl;
			return ;
		}
		if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3<<endl;
			return ;
		}
	}
	if(s[xp-1]==s[xp-2]){
		cout<<xp-1<<" "<<xp<<endl;
		return ;
	}
	cout<<"-1 -1\n";
	return ;
}

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


int32_t main()
{
	mod=1e+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	q2();
	return 0;
}


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

ll comb[51][51];

ll calc_comb(ll n, ll r){
  if(comb[n][r] != -1) return comb[n][r];
  if(n == r || r == 0) return comb[n][r] = 1;
  if(r == 1 || r == n-1) return comb[n][r] = n;
  
  return comb[n][r] = calc_comb(n-1, r-1) + calc_comb(n-1, r);
}

int main(){
  ll N, P; cin >> N >> P;
  pair<ll, ll> ma;
  ll ans = 0;
  
  for(ll i = 0; i <= 50; i++){
    for(ll j = 0; j <= 50; j++){
      comb[i][j] = -1;
    }
  }
  
  for(ll i = 0; i < N; i++){
    ll a; cin >> a;
    if(a % 2 == 0) ma.first++;
    else ma.second++;
  }
  
  ll st = P;
  while(st <= ma.second){
    ans += calc_comb(ma.second, st);
    st += 2;
  }
  cout << (ll)(ans * pow(2.0, ma.first))<< endl;
}

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

int main(){
    long long n,k,t,ans=0;
    vector <long long> h;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>t;
        h.push_back(t);
    }
    sort(h.begin(),h.end(),greater<>());
    if(n>k){
        for(int i=k;i<n;i++){
            ans+=h[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
typedef long long ll;
ll check(ll x){
    ll res=0;
    while(x) {
        res+=x%10;x/=10;
    }
    return res;
}
int main() {
    ll n;
    while(~scanf("%lld",&n)) {
        if(n<10) printf("%lld\n",n);
        else {
            ll ans=check(n);
            ll tmp=0;
            while(n) {
                if(!(n/10))tmp+=(n-1);
                else tmp+=9;
                n/=10;
            }
            printf("%lld\n",std::max(ans,tmp));
        }
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

const inf = math.MaxInt32

type link struct {
	from, to, cost int
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := getInt(), getInt()

	l := make([]link, M)
	for i := 0; i < M; i++ {
		l[i] = link{getInt() - 1, getInt() - 1, getInt()}
	}

	// 自分自身のコストを０に、それ以外を無限大に設定
	var dist [100][100]int
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if i == j {
				dist[i][j] = 0
			} else {
				dist[i][j] = inf
			}
		}
	}

	// 既知の経路を設定
	for i := 0; i < M; i++ {
		dist[l[i].from][l[i].to] = l[i].cost
		dist[l[i].to][l[i].from] = l[i].cost
	}

	// 経路を更新
	for x := 0; x < N; x++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if dist[i][j] > dist[i][x]+dist[x][j] {
					// 経由したほうが近い場合、更新
					dist[i][j] = dist[i][x] + dist[x][j]
				}
			}
		}
	}

	ans := 0
	for i := 0; i < M; i++ {
		if dist[l[i].from][l[i].to] < l[i].cost {
			ans++
		}
	}
	out(ans)
}


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

int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  for (auto &e : a) {
    cin >> e;
  }
  sort(begin(a), end(a));
  for (int i = 0; i < n - 1; i++) {
    a[i + 1] += a[i];
  }
  int r = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] <= x) {
      r = a[i] < x && i == n - 1 ? i : i + 1;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	while(cin>>n)
	{
		int a=(n+1)/2;
		double ans=a*1.0/n;
		printf("%.10lf\n",ans);
	}

	return 0;
}

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


int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i++){
		cin >> A.at(i);
	}
	bool even = true;
	int counter = 0;
	while(1){
		for(int i = 0; i < N; i++){
			if(A.at(i) % 2 == 0){
				A.at(i) /= 2;
			}
			else{
				even = false;
				break;
			}
		}
		if(!even){
			break;
		}
		counter++;
	}
	cout << counter << endl;
	return 0;
}

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

using namespace std;

int main(void){
	string S;
	//char S[10];
	cin >> S;
	//cout<<S<<endl;
	int week = 7;
	if(S == "SUN"){
		cout <<"7"<<endl;
	}
	else if(S == "MON"){
		cout<<"6"<<endl;
	}
	else if(S == "TUE"){
		cout<<"5"<<endl;
	}
	else if(S=="WED"){
		cout<<"4"<<endl;
	}
	else if(S=="THU"){
		cout<<"3"<<endl;
	}
	else if(S=="FRI"){
		cout<<"2"<<endl;
	}
	else if(S=="SAT"){
		cout<<"1"<<endl;
	}
	return 0;
}






Measured memory_bytes: 256
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << std::endl;
}

using namespace std;

int main(){
    int n, m; cin >> n>> m;
    vector<vector<int>> da(n, vector<int>(0));
    rip(i,m,0){
        int a,b; cin >> a >> b;
        --a;--b;
        da[a].push_back(b);
        da[b].push_back(a);
    }
    vector<int> ans(n,-1);
    queue<Pii> q;
    q.push({0,0});
    while(!q.empty()){
        auto now = q.front();q.pop();
        if(ans[now.first] != -1){
            continue;
        }
        ans[now.first] = now.second;
        rip(i,da[now.first].size(),0){
            q.push({da[now.first][i], now.first});
        }
    }
    bool ju = true;
    rip(i,n,0) {
        if(ans[i] == -1) ju = false;
    }
    if(ju){
        printf("Yes\n");
        rip(i,n,1){
            printf("%d\n", ans[i]+1);
        }
    }
    else{
        printf("No\n");
    }
}

Measured memory_bytes: 12232
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    k: i64,
    x: i64
    }
    for i in x - (k - 1)..x + k {
        print!("{} ", i)
    }
}


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

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int a[30];
    for(int i = 0; i < n; i++)cin >> a[i];
    int ans = 0;
    for(int i = 0; i < n-2; i++){
        int b[3];
        b[0] = a[i];
        b[1] = a[i+1];
        b[2] = a[i+2];
        sort(b, b+3);
        if(a[i+1] == b[1])ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import collections
def pf(N):
    res = []
    x = N
    y = 2
    while y*y <= x:
        while x % y == 0:
            res.append(y)
            x //= y
        y += 1
    if x > 1:
        res.append(x)
    return res

cnt = collections.Counter(pf(int(input())))
ans = 0
for x in cnt:
    tmp = 1
    while cnt[x] > 0:
        cnt[x] -= tmp
        if cnt[x] < 0:
            break
        tmp += 1
        ans += 1
print(ans)

Measured memory_bytes: 9468
#include <bits/stdc++.h>
#define int long long
#define inf 100005
using namespace std;

int n,m,num=0;
int a[105][105],dp[105][105]={0};

signed main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			char x;
			cin>>x;
			
			if (x=='.')  a[i][j]=1;
			else a[i][j]=0;
		}
	}
	for (int i=0;i<=n+1;i++)
	{
		for (int j=0;j<=m+1;j++)  dp[i][j]=inf;
	}
	dp[1][1]=1;
	
	for (int cnt=1;cnt<=n*m;cnt++)
	{
		for (int i=1;i<=n;i++)
		{
			for (int j=1;j<=m;j++)
			{
				if (dp[i][j]==inf)  continue;
				else
				{
					if (a[i-1][j]!=0)  dp[i-1][j]=min(dp[i-1][j],dp[i][j]+1);
					if (a[i+1][j]!=0)  dp[i+1][j]=min(dp[i+1][j],dp[i][j]+1);
					if (a[i][j-1]!=0)  dp[i][j-1]=min(dp[i][j-1],dp[i][j]+1);
					if (a[i][j+1]!=0)  dp[i][j+1]=min(dp[i][j+1],dp[i][j]+1);
				}
			}
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if (a[i][j]==0)  num++;
		}
	}
	if (dp[n][m]!=inf)  cout<<n*m-dp[n][m]-num<<endl;
	else cout<<-1<<endl;
	
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define lld long long

int main(){
    lld N,A,B;
    cin >> N >> A >> B;
    lld ans = N / (A+B) * A;
    if(N % (A+B) > A){
        ans += A;
    } else {
        ans += N % (A+B);
    }
    cout << ans << 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(){
  string s;
  cin >> s;
  int i,j;
  for(i = 0;;i++) if(s[i]=='A') break;
  for(j = s.size()-1;;j--) if(s[j]=='Z') break;
  cout << j-i+1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  string S; cin >> S;
  int n = S.length();

  //S[0:i], S[i+1:end]
  int ans = 0;
  for (int i = 1; i < n - 1; ++i){
    vector<vector<int>> que(2, vector<int>(26));
    for (int j = 0; j < i; ++j){
      que[0][S[j] - 'a']++;
    }
    for (int j = i; j < n; ++j){
      que[1][S[j] - 'a']++;
    }
    int tmp = 0;
    for (int j = 0; j < 26; ++j){
      if (que[0][j] != 0 && que[1][j] != 0) tmp++;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*  
    Everybody loves somebody sometime
    Everybody falls in love somehow
    Something in your kiss just told me
    My sometime is now
    _________________________
    _________________________
    624 Hours of Solitude
    Quarantine_Day : 26
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)
#define INF             10000009

ll n, w;
vl weight;
vl value;
ll dp[105][100005];
bool vis[105][100005];
ll go(ll idx, ll sum)
{
    if(idx >= n) return 0;
    if(vis[idx][sum]) return dp[idx][sum];
    vis[idx][sum] = true;

    ll nichi;
    ll nimuna;

    if(sum + weight[idx] <= w){
        nichi = value[idx] + go(idx + 1, sum + weight[idx]);
    }
    else nichi = 0;
    nimuna = go(idx + 1, sum);

    return dp[idx][sum] =  max(nichi, nimuna);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>w;
    weight.resize(n);
    value.resize(n);

    REP(i, n) cin>>weight[i]>>value[i];

    memset(vis, false, sizeof(vis));
    cout<<go(0, 0)<<"\n";

    return 0;
}   


Measured memory_bytes: 90368
from string import ascii_uppercase

N = int(input())
S = input()

num2alpha = {i: a for i, a in enumerate(ascii_uppercase)}
alpha2num = {a: i for i, a in enumerate(ascii_uppercase)}

ans = ""
for s in S:
    num = (alpha2num[s] + N) % 26
    ans += num2alpha[num]

print(ans)


Measured memory_bytes: 9944
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N;
  cin>>N;
  VL T(N),A(N);
  rep(i,N) cin>>T[i];
  rep(i,N) cin>>A[i];
  VL TT(N),AA(N);
  rep(i,N) TT[i]=-1;
  rep(i,N) AA[i]=-1;
  rep(i,N){
    if(i==0) TT[i]=T[i];
    else if(T[i]!=T[i-1]) TT[i]=T[i];
  }
  rep(i,N){
    if(i==0) AA[N-1-i]=A[N-1-i];
    else if(A[N-1-i]!=A[N-i]) AA[N-1-i]=A[N-1-i];
  }
  ll mod=1e9+7;
  ll ans=1;
  rep(i,N){
    if(TT[i]==-1 and AA[i]==-1) (ans*=min(T[i],A[i]))%=mod;
    else if(TT[i]==-1){
      if(T[i]<AA[i]) ans=0;
    }else if(AA[i]==-1){
      if(A[i]<TT[i]) ans=0;
    }else if(TT[i]!=AA[i]) ans=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
   
  int ans;
  if(a+b >= 24){
    ans = (a + b) % 24;
  }
  else{
    ans = a + b;
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 256