akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define XOX
using namespace std;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

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

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int32_t main()
{
   int n;
  cin>>n;
  int a[n],b[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i]>>b[i];
  }
  sort(a,a+n);
  sort(b,b+n);
  int x,y;
  if(n%2)
  {
      x=a[n/2];
      y=b[n/2];
  }
  else
  {
    x=a[(n/2)-1]+a[n/2];
    y=b[(n/2)-1]+b[n/2];
  }
  cout<<(y-x+1)<<"\n";
  return 0;
}

Measured memory_bytes: 6764
#include <stdio.h>
int main(void){
    while(1){
    int H,W;
    scanf("%d %d", &H, &W);
        if(H == 0 && W == 0)break;
        else{
            for(int j=0; j<H; j++){
                for(int i =0; i<W; i++){
                    if((j+i+2)%2==0){
                        printf("#");
                    }
                    else {
                        printf(".");
                    }
                }
                printf("\n");
            }
        }
        printf("\n");
    }
}

Measured memory_bytes: 1752
#include <cstdio>
#include <algorithm>
#include <vector>
#define mp make_pair 
#define x first
#define y second
#define ll long long
using namespace std;

int n,h,w,num,num2;
int main(){
	scanf("%d%d%d",&n,&h,&w);
	num=n-h+1; num2=n-w+1;
	printf("%d\n",num*num2);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    long N,n=0;
    cin >> N;
    vector<long>a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    for(int i=0;i<N;i=i+2){
        if(a[i]%2==1){
            n++;
        }
    }
    cout <<n;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll C[200005];

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

    cin >> N;
    memset(C, 0, sizeof(C));
    REP(i, N - 1) {
        ll p;
        cin >> p;
        C[p - 1]++;
    }

    REP(i, N) {
        cout << C[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5212
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0 && m == 0){
            break;
        }
        vvi vec(n,vi(m));
        string s;
        rep(i,n){
            cin >> s;
            rep(j,m){
                vec[i][j] = s[j]-'0';
            }
        }
        int ans = 0;
        if(n <= 16){
            rep(i,(1 << n)){
                vi v(m,0);
                rep(j,n){
                    if((i >> j)&1){
                        rep(k,m){
                            v[k] ^= vec[j][k];
                        }
                    }
                }
                bool flag = true;
                rep(j,m){
                    if(v[j] != 0){
                        flag = false;
                        break;
                    }
                }
                if(flag){
                    cmx(ans,__builtin_popcount(i));
                }
            }
            cout << ans << "\n";
        }else{
            vl val(n);
            rep(i,n){
                // svec(vec[i]);
                rep(j,m){
                    val[i] += ((ll)vec[i][j] << j);
                }
            }
            // svec(val);
            map<ll,int> mp;
            mp[0] = 0;
            rep(i,n){
                map<ll,int> mp2;
                each(it,mp){
                    mp2[it.fi] = max(mp[it.fi],mp2[it.fi]);
                    mp2[it.fi^val[i]] = max(it.se+1,mp2[it.fi^val[i]]);
                }
                mp = mp2;
            }
            cout << mp[0] << "\n";
        }
    }
    return 0;
}



Measured memory_bytes: 133944
#include<cstdio>

int main(){
    char a[1001];
    while(true){
        scanf("%s",a);
        if(a[0] == 48){
            break;
        }
        int sum = 0;
        for(int i = 0; a[i] != '\0'; i++){
            sum += a[i] - 48;
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<ll > a(n,0),b(n,0),c(n,0);
  REP(i,n){
    cin >> a[i];
  }
  REP(i,n){
    cin >> b[i];
  }
  REP(i,n){
    cin >> c[i];
  }
  sort(all(a));
  sort(all(b));
  sort(all(c));
  // REP(i,n){
  //   cout <<setw(4)<< left << a[i] <<" " << b[i] << endl;
  // }

  vector<ll > ab(n,0),bc(n,0);
  /////////////////
  int j = 0;
  REP(i,n){
    while(j < n &&a[i] >= b[j]){
      j++;
    }
    ab[i] = n - j;
  }
  j = 0;
  REP(i,n){
    while(j < n &&b[i] >= c[j]){
      j++;
    }
    bc[i] = n - j;
  }
  /////////////////
  // REP(i,n){
  //   cout << ab[i] << endl;
  // }
  // cout << "##" << endl;
  // REP(i,n){
  //   cout << bc[i] << endl;
  // }


  vector<ll > numab(n,0),numbc(n,0);
  numbc[n - 1] = bc[n - 1];
  for(int i = n - 2; i >= 0; i--){
    numbc[i] = numbc[i + 1] + bc[i];
  }
  ll ans = 0;
  REP(i,n){
    int j = n - ab[i];
    ans += (ll)numbc[j];
  }
  cout << ans << endl;
}


Measured memory_bytes: 5760
open Batteries
open Printf
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a_l = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let l = List.mapi (fun i x -> x-i-1) a_l in

  let median l = 
    let l_s = List.sort compare l in
    let len = List.length l in

    if len mod 2 <> 0 then
      List.nth l_s (len/2)
    else
      (
        List.nth l_s (len/2) + List.nth l_s (len/2-1)
      )/2
  in
  let med = median l in

  let ans = 
    List.map (fun x -> abs(x-med)) l |>
    List.fold_left (+) 0
  in

  Printf.printf "%d\n" ans;


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

int main(){
  string S;
  cin>>S;
  //XX type
  int size = S.size();
  for(int i=0;i<size-1;i++){
    if(S[i] == S[i+1]){
      cout<<i+1<<" "<<i+2<<endl;
      return 0;
    }
  }
  //XYX type
  for(int i=0;i<size-2;i++){
    if(S[i] == S[i+2] && S[i] != S[i+1]){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  }
  cout<<"-1 -1"<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int MAXN = 1e6 + 10;



int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int M, K;
  cin >> M >> K;
  vector<bool> used(1<<M, false);
  if (K == 0) {
    for (int i = 0; i < (1<<M); ++i) cout << i << ' ' << i << " \n"[i == (1<<M) - 1];
    exit(0);
  }
  vector<int> ans;
  int a[2] = {-1, -1}, b[2] = {-1, -1};
  for (int i = 0; i < (1<<M); ++i) if (not used[i] and (i^K) < (1<<M)) {
    if (a[0] == -1) {
      a[0] = i;
      a[1] = i ^ K;
      used[i] = used[i ^ K] = true;
    }
    else {
      b[0] = i;
      b[1] = i ^ K;
      used[i] = used[i ^ K] = true;
      break;
    }
  }
  if (b[0] == -1) cout << -1 << '\n', exit(0);
  ans.push_back(b[0]);
  ans.push_back(a[0]);
  ans.push_back(a[1]);
  ans.push_back(b[0]);
  ans.push_back(b[1]);
  ans.push_back(a[1]);
  ans.push_back(a[0]);
  ans.push_back(b[1]);
  for (int i = 0; i < (1<<M); ++i) if (not used[i^b[0]]) {
    ans.push_back(b[0]^i);
    ans.push_back(a[0]^i);
    ans.push_back(a[1]^i);
    ans.push_back(b[0]^i);
    ans.push_back(b[1]^i);
    ans.push_back(a[1]^i);
    ans.push_back(a[0]^i);
    ans.push_back(b[1]^i);
    for (int c : a) used[c^i] = 1;
    for (int c : b) used[c^i] = 1;
  }
  for (int i = 0; i < (2<<M); ++i) {
    cout << ans[i] << " \n"[i == (2<<M) - 1];
  }
}


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <limits>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
#define ll long long
#define rep(i_, start, end) for(ll i_=(ll)start; i_<(ll)end; i_++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");

int main(){
  ll n, k, mindp;
  cin >> n >> k;
  ll h[100005];
  rep(i, 0, n) cin >> h[i];
  ll dp[100005] = {};
  
  dp[0] = 0;
  rep(i, 0, n-1){
    mindp = INF;
    rep(j, 0, k){
      if(i-j < 0) break;
      //cout << dp[i-j] << " " << h[i+1] << " "<<h[i-j]<<endl;
      mindp = min(dp[i-j] + abs(h[i+1] - h[i-j]), mindp);
    }
    dp[i+1] = mindp;
  }
  //printarray(dp, n);
  print(dp[n-1]);
  
  return 0;
}

Measured memory_bytes: 1792
import sys
from string import ascii_lowercase
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def getDigit(N):
    x = 26
    i = 1
    while N > x:
        i += 1
        x += 26**i

    return i


def main():
    N = int(input())
    S = ascii_lowercase
    if N < 27:
        print(S[N - 1])
        return
    xdigit = getDigit(N)
    # print(xdigit)
    tN = N
    for i in range(1, xdigit):
        tN -= 26**i
    # print(tN)
    tN -= 1
    ans = ''

    for _ in range(xdigit):
        ans = S[tN % 26] + ans
        tN //= 26

    print(ans)
    return


if __name__ == '__main__':
    main()


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

int main() {
  int N, K, Q; cin >> N >> K >> Q;
  vector<int> A(Q);
  rep(i, Q) cin >> A[i];
  
  vector<int> P(N, 0);
  
  rep(i, Q) P[A[i]-1]++;
  
  rep(i, N) {
    if(P[i]+K-Q <= 0) cout << "No" <<endl;
    else cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 1408
N = int(input())
ans = float('inf')
ls = []
l = [1]
tmp = 6
while tmp <= 100000:
    l += [tmp]
    tmp *= 6
tmp = 9
while tmp <= 100000:
    l += [tmp]
    tmp *= 9

dp = [float('inf')]*(N+1)
dp[0] = 0
dp[1] = 1
for i in range(N+1):
    for n in l:
        if i-n >= 0:
            dp[i] = min(dp[i],dp[i-n]+1)
print(dp[N])

Measured memory_bytes: 3828
#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <climits>

#define el '\n'
typedef long long ll;
using namespace std;

void sol(){
	int n;
	cin >>n;
	vector<int> h(n);
	for (int &i: h) cin >>i;
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for (int i = 2; i < n; i++){
		dp[i] = min({dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]), dp[i]});
	}
	cout << dp[n - 1]<<el;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t= 1;
	while(t--){
	//	cout << t<<el;
		sol();
	}
}

Measured memory_bytes: 3556
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <sstream> //C++
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)




int main()
{
	int x,y,z;
	cin >> x >> y >> z;
	
	cout << z <<" "<< x <<" "<< y;
	
}




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


#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;

const unsigned M = 1000000007;

pair<unsigned, unsigned> updm(unsigned m, unsigned mm) {
	if (mm == 1) return make_pair(0u, 1u);
	pair<unsigned, unsigned> buf = updm(mm, m % mm);
	pair<unsigned, unsigned> ans;
	ans.first = buf.second;
	ans.second = ((ULL)(M - m / mm) * buf.second + buf.first) % M;
	return ans;
}

unsigned updm(unsigned d) {
	d %= M;
	return updm(M, d).second;
}

unsigned mulm(unsigned a, unsigned b) {
	return ((ULL)a * b) % M;
}
unsigned divm(unsigned p, unsigned d) {
	return mulm(updm(d), p);
}

unsigned powa[100001], powb[100001], powc[100001];
unsigned fact[200001];

unsigned pp;

unsigned solve2(unsigned t, unsigned n) {
	unsigned pc =
		divm(fact[n + t - 1],
			mulm(fact[t], fact[n - 1]));

	unsigned ap = mulm(powa[n], powb[t]);
	unsigned bp = mulm(powb[n], powa[t]);

	unsigned ppc = mulm(pp, n + t);
	unsigned res = mulm(ppc, mulm((ap + bp) % M, pc));

	return res;
}

void solve() {
	unsigned n, a, b, c; cin >> n >> a >> b >> c;
	powa[0] = powb[0] = 1;
	unsigned pa = divm(a, a + b);
	unsigned pb = divm(b, a + b);
	pp = divm(1, (1 + M - divm(c, 100)) % M);
	for (unsigned i = 1; i <= n; i++) {
		powa[i] = mulm(powa[i - 1], pa);
		powb[i] = mulm(powb[i - 1], pb);
	}
	fact[0] = 1;
	for (int i = 1; i <= 200000; i++) { fact[i] = mulm(fact[i - 1], i); }

	unsigned ans = 0;
	for (unsigned i = 0; i < n; i++) {
		ans = (ans + solve2(i, n)) % M;
	}
	cout << ans << endl;
}

int main() {

	solve();

	return 0;
}

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

namespace Atcoder171
{
    class Program
    {
        static void Main(string[] args)
        {
            // 文字列の入力
            string s = Console.ReadLine();
            var cs = s.ToCharArray();
            if (cs.Length != 1) return;
            //出力
            if (Char.IsUpper(cs[0]))
            {
                Console.WriteLine("A");

            }
            else
            {
                Console.WriteLine("a");

            }

        }
    }
}


Measured memory_bytes: 25788
N, M, Q = map(int, input().split())

x = [[0 for j in range(N + 1)] for i in range(N + 1)]

for _ in range(M):
    L, R = map(int, input().split())
    x[N - L][R] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        x[i][j] += x[i][j - 1]

for j in range(1, N + 1):
    for i in range(1, N + 1):
        x[i][j] += x[i - 1][j]

for _ in range(Q):
    p, q = map(int, input().split())
    print(x[N - p][q])


Measured memory_bytes: 9460
#include <iostream>
#include <vector>
#include <queue>
#include <map>

using namespace std;

const int INF = 1145141919;
int n;
vector<map<int, vector<int>>> graph;
vector<map<int, int>> dis;
vector<bool> visited;

struct state {
    int vertex;
    int kind;
    int cost;
};

bool has_key(map<int, int> &m, int n) {
    return m.find(n) != m.end();
}

void bfs(int s) {
    deque<state> que;
    dis = vector<map<int, int>>(n);
    dis[s][-1] = 0;
    visited = vector<bool>(n);
    que.push_front(state{s, -1, 0});

    while (!que.empty()) {
        state now = que[0];
        que.pop_front();

        if (now.vertex == n - 1) break;
        if (has_key(dis[now.vertex], now.kind) && dis[now.vertex][now.kind] < now.cost)continue;

        if (visited[now.vertex]) {
            auto from = dis[now.vertex][now.kind];
            for (auto nextv:graph[now.vertex][now.kind]) {
                if (nextv == 0)continue;

                if (dis[nextv][now.kind] > from) {
                    dis[nextv][now.kind] = from;

                    state ret = {nextv, now.kind, dis[nextv][now.kind]};
                    que.emplace_front(ret);
                }
            }
        } else {
            for (auto maps:graph[now.vertex]) {
                for (auto nextv:maps.second) {
                    if (nextv == 0)continue;

                    bool changed = maps.first != now.kind;
                    auto from = dis[now.vertex][now.kind];

                    if (!has_key(dis[nextv], maps.first) ||
                        dis[nextv][maps.first] > from + changed) {
                        dis[nextv][maps.first] = from + changed;

                        state ret = {nextv, maps.first, dis[nextv][maps.first]};
                        if (changed) que.emplace_back(ret);
                        else que.emplace_front(ret);
                    }
                }
            }
            visited[now.vertex] = true;
        }
    }
}

int main() {
    int m;
    cin >> n >> m;
    graph = vector<map<int, vector<int>>>(n);
    for (int i = 0; i < m; i++) {
        int from, to, kind;
        cin >> from >> to >> kind;
        from--;
        to--;
        graph[from][kind].push_back(to);
        graph[to][kind].push_back(from);
    }

    bfs(0);

    int ret = INF;
    for (auto x:dis[n - 1])ret = min(ret, x.second);
    cout << (ret == INF ? -1 : ret) << endl;
    return 0;
}

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

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

    ll R, S ,P;
    cin>> R >> S >> P;

    string T;
    cin>> T;

    ll ans = 0;
    vector<bool> v(N, false);
    for(int i=0; i<N; i++){
       
        if(i-K>=0 && T[i]==T[i-K] && !v[i-K]){
            //cout<< i <<" : skip"<<endl;
            v[i] = true;
            continue;
        }
        if(T[i] == 'r'){
            ans += P;
        }else if(T[i] == 's'){
            ans += R;
        }else if(T[i] == 'p'){
            ans += S;
        }
        //cout<< i <<" : "<< ans <<endl;
    }

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

Measured memory_bytes: 3756
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<long long>> param(n, vector<long long>(3));
    for (int i = 0; i < n; i++) {
        cin >> param[i][0] >> param[i][1] >> param[i][2];
    }
    long long ans = -1;
    for (int x = -1; x <= 1; x += 2) {
        for (int y = -1; y <= 1; y += 2) {
            for (int z = -1; z <= 1; z += 2) {
                sort(param.begin(), param.end(), [&](vector<long long> &lhs, vector<long long> &rhs) {
                    return lhs[0] * x + lhs[1] * y + lhs[2] * z > rhs[0] * x + rhs[1] * y + rhs[2] * z;
                });
                long long kirei = 0, oisii = 0, ninki = 0;
                for (int i = 0; i < m; i++) {
                    kirei += param[i][0];
                    oisii += param[i][1];
                    ninki += param[i][2];
                }
                ans = max(ans, abs(kirei) + abs(oisii) + abs(ninki));
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。

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

      int q;
      cin>>q;
      bool board[8][8];
      rep0(i,8)rep0(j,8) board[i][j]=true;
      rep0(i,4)rep0(j,4) board[2*i][2*j+1]=false;
      /*rep0(i,8){
            rep0(j,8) cout<<board[i][j]<<" ";
            cout<<endl;
      }*/
      rep0(gieig,q){
            int a,b,c,d;
            cin>>a>>b>>c>>d;
            int ans=0;
            --a,--b,--c,--d;
            for(int h=a;h<=c;h++){
                  for(int w=b;w<=d;w++){
                        if(board[h][w]) ans++;
                  }
            }
            cout<<ans<<endl;
      }
      

      return 0;
}


Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct P{ P(int x, int y) : x(x), y(y) {} double x, y; };

int main()
{
    int w, h;
    while(cin >> w >> h && w)
    {
        vector<vector<char> > m(h, vector<char>(w));
        P s(0, 0);
        
        rep(y, h) rep(x, w)
        {
            cin >> m[y][x];
            if(m[y][x] == '@')
                s = P(x, y);
        }
        
        int res = 1;
        queue<P> que;
        for(que.push(s); !que.empty(); que.pop())
        {
            P p = que.front();
            
            int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
            rep(i, 4)
            {
                int nx = p.x + dx[i], ny = p.y + dy[i];
                
                if(0 <= nx && nx < w && 0 <= ny && ny < h && m[ny][nx] == '.')
                {
                    m[ny][nx] = '#';
                    res++;
                    
                    que.push(P(nx, ny));
                }
            }
        }
        
        cout << res << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int w[101];
int v[101];
vector<int> vw[4];

int main()
{
	int n,we;
	int wm[4];
	ll ans=0;
	
	cin>>n>>we;
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
	}
	vw[0].push_back(v[0]);
	for(int i=1;i<n;i++)
		vw[w[i]-w[0]].push_back(v[i]);
	wm[0]=we/w[0];
	wm[1]=we/(w[0]+1);
	wm[2]=we/(w[0]+2);
	wm[3]=we/(w[0]+3);
	for(int i=0;i<4;i++)
	{
		sort(vw[i].begin(),vw[i].end());
		reverse(vw[i].begin(),vw[i].end());
	}

	for(int a=0;a<min(wm[0]+1,(int)vw[0].size()+1);a++)
	{
		for(int b=0;b<min(wm[1]+1,(int)vw[1].size()+1);b++)
		{
			for(int c=0;c<min(wm[2]+1,(int)vw[2].size()+1);c++)
			{
				for(int d=0;d<min(wm[3]+1,(int)vw[3].size()+1);d++)
				{
					if(w[0]*(a+b+c+d)+(b+c+d)+(c+d)+d<=we)
					{
						//cerr<<"loop"<<endl;
						ll val=0;
						for(int i=0;i<a;i++)
							val+=vw[0][i];
						for(int i=0;i<b;i++)
							val+=vw[1][i];
						for(int i=0;i<c;i++)
							val+=vw[2][i];
						for(int i=0;i<d;i++)
							val+=vw[3][i];
						if(val>ans)
							ans=val;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        System.out.println( solve(N, S) );
    }

    private static int solve(int N, String S) {
        int max = 0;

        for (int i=1; i <= N-1; i++) {
            String a = S.substring(0, i);
            String b = S.substring(i);

            int cnt = 0;
            for (int c = 'a'; c <= 'z' ; c++) {
                if( a.indexOf(c) != -1 && b.indexOf(c) != -1 ) {
                    cnt++;
                }
            }
            max = Math.max(cnt, max);
        }
        return max;
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int N, M;
    cin >> N;
    vector<string> s(N);
    for(int i = 0; i < N; i++){
        cin >> s[i];
    }
    cin >> M;
    vector<string> t(M);
    for(int i = 0; i < M; i++){
        cin >> t[i];
    }
    
    vector<pair<string, bool>> S(N);
    for(int i = 0; i < N; i++){
        S[i] = make_pair(s[i], false);
    }
    
    int res = 0;
    for(int i = 0; i < N; i++){
        if(S[i].second)     continue;
        
        S[i].second = true;
        int s_cnt = 1, t_cnt = 0;
        
        for(int j = i + 1; j < N; j++){
            if(!S[j].second && S[j].first == s[i]){
                s_cnt++;
                S[j].second = true;
            }
        }
        for(int j = 0; j < M; j++){
            if(t[j] == s[i]){
                t_cnt++;
            }
        }
        
        res = max(res, s_cnt - t_cnt);
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using ll = long long;
using namespace std;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll C = A + B;
    ll ans = A * (N / C);
    ans += min(N % C, A);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

    long long sum=0;
    for(int i=0; i<=n; i++){
        if(i%3 != 0 && i%5 != 0)sum+=i;
    }

    cout << sum << endl;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define testcase int t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<long long int,long long int>
#define updiv(a,b) (ceil)((a)*(1.0)/(b))
typedef long long int ll;
typedef unsigned long long int ull;
#define M 1000000007
using namespace std;
int main()
{
int n;cin>>n;
cout<<updiv(n,2)<<endl;
return 0;
}







Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <tuple>
#include <vector>
#include <set>
using namespace std;

void input_int2(int &a, int &b) {
	cin >> a >> b;
	cin.ignore();
}

void input_int3(int &a, int &b, int &c) {
	cin >> a >> b >> c;	
	cin.ignore();
}

void input_int_array(int n,vector<int> &vec) {
	for (int i=0,tmp=0; i<n && cin >> tmp; i++) vec[i]=tmp;
}

void input_int_matrix(int n, int m, vector<vector<int>> &matrix) {
	int tmp;
	for(int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			cin >> tmp;
			matrix[i][j] = tmp;
		}
	}
}

void input_int_var_array(int n,vector<int> &vec) {
	for (int tmp=0; cin >> tmp;) {
		vec.push_back(tmp);
	}
}

void input_int_var_matrix(int n, int m, vector<vector<int>> &matrix) {
	int tmp;
	for(int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			cin >> tmp;
			matrix[i][j] = tmp;
		}
	}
}

void input_var_str(vector<string> & array) {
	string s;
	getline(cin, s);
	
	stringstream ss{s};
	while(getline(ss, s, ' ')) {
		array.push_back(s);
	}
}

void input_var_int(vector<int> &array) {
	string s;
	getline(cin, s);
	
	stringstream ss{s};
	while(getline(ss, s, ' ')) {
		array.push_back(stoi(s));
	}
}

void input_var_int(set<int> &array) {
	string s;
	getline(cin, s);
	
	stringstream ss{s};
	while(getline(ss, s, ' ')) {
		array.insert(stoi(s));
	}
}

template <typename T> void print_var_vector(vector<T> vec) {
	for(typename vector<T>::iterator i=begin(vec); i!=end(vec); i++) {
		cout << *i;
	}
	cout << endl;
}

void print_vector(int N, vector<int> vec) {
	for(int i=0; i<N; i++){
		cout << vec[i] << " ";
	}
	cout << endl;
}

const int MAX_N = 20;
const int MAX_M = 20;

int N, M;
vector<int> k;
vector<set<int>> A;

void input() {
	vector<int> array;
	input_int2(N, M);
	for(int i=0; i<N; i++){
		array = vector<int>();
		input_var_int(array);
		k.push_back(*array.begin());
		array.erase(array.begin());
		A.push_back(set<int>(array.begin(), array.end()));
	}
}

int solve() {
	set<int> result;
	set<int> tmp = A[0];
	for(int i=1; i<N; i++) {
		result = set<int>();
		//print_vector(A[i].size(),A[i]);
		//print_vector(tmp.size(),tmp);
		set_intersection(A[i].begin(), A[i].end(), tmp.begin(), tmp.end(), inserter(result, result.end()) );
		tmp = result;
		//print_vector(tmp.size(),tmp);
	}
	return tmp.size();
}

int main() {
	input();
	cout << solve() << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{

    int a, b, c , i;
    cin >> a >> b >> c;
    if (a>b ) {
        i = a;
        a = b;
        b = i;
    }
    if (b>c) {
        i = b;
        b = c;
        c = i;
    }
    if (a>b ) {
        i = a;
        a = b;
        b = i;
    }
  
    cout << a << " " << b << " " << c << endl;
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r,d,x;
    cin>>r>>d>>x;
    for(int i=0; i<=9; i++)
    {
        int temp=x;
        x=((r*x)-d);
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret
N,M,K = map(int,input().split())
MOD=998244353

F=FactMod(N,MOD)
ans=0
for k in range(K+1):
    ans+= M *pow(M-1,N-k-1,MOD)*F.comb(N-1,N-1-k)
    ans%=MOD
print(ans)


Measured memory_bytes: 82592
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if (a==b) {
		cout<<c<<endl;
	} else if (a==c) {
		cout<<b<<endl;
	} else if (b==c) {
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys


def resolve():
    readline = sys.stdin.readline    # 1行だけ文字列にする

    X, Y = map(int, readline().split())

    # Ai+1 = 2Aiとすればおｋ？
    A = X
    cnt = 1
    while 1:
        A = 2 * A
        if A <= Y:
            cnt += 1
        else:
            print(cnt)
            break


resolve()

Measured memory_bytes: 9012
#include<bits/stdc++.h>
#define itn int
#define REP(i,n) for(int i=0;i<(n);i++)
#define IREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(n);i++)
#define REPEACH(itr,k) for(auto&& itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;
typedef pair<double,int> P;

int main(){
  vector<vector<int>> v(3,vector<int>(3));
  REP(i,3){
    REP(j,3){
      cin >> v[i][j];
    }
  }
  if(v[0][0]-v[0][1]==v[1][0]-v[1][1]&&v[2][0]-v[2][1]==v[1][0]-v[1][1]){
    if(v[0][1]-v[0][2]==v[1][1]-v[1][2]&&v[2][1]-v[2][2]==v[1][1]-v[1][2]){
      if(v[0][0]-v[1][0]==v[0][1]-v[1][1]&&v[0][2]-v[1][2]==v[0][1]-v[1][1]){
        if(v[1][0]-v[2][0]==v[1][1]-v[2][1]&&v[1][2]-v[2][2]==v[1][1]-v[2][1]){
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	long mod=1000000000+7;
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s1=sc.next();
		String s2=sc.next();
		
		long ans=1;
		
		for(int i=0;i<n;i++){
			if(s1.charAt(i)==s2.charAt(i)){
				if(i==0)ans*=3;
				else if(s1.charAt(i-1)==s2.charAt(i-1)){
						ans*=2;
				}
				ans%=mod;
			}
			if(i<n-1 && s1.charAt(i)==s1.charAt(i+1)){
				if(i==0)ans*=6;
				else{
					if(s1.charAt(i-1)!=s2.charAt(i-1)){
						ans*=3;
					}else{
						ans*=2;
					}
				}
				ans%=mod;
			}
		}
		System.out.println(ans);
	}
	
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const int N = 2e5 + 5;
vi g[N];

int32_t main(){
   fast;
   int n,m;
   cin >> n >> m;
   vpi edge;
   f(i,0,m){
      int u,v;
      cin >> u >> v;
      edge.pb({u,v});
      g[u].pb(v);
      g[v].pb(u);
   }   

   vi dis(n+1 , INT_MAX);
   dis[1] = 0;
   queue<int>q;
   q.push(1);
   while(!q.empty()) {
      int u = q.front();
      q.pop();
      for(int v : g[u]){
         if(dis[v] == INT_MAX){
            dis[v] = dis[u] + 1;
            q.push(v);
         }
      }
   }
   f(i,1,n+1) {
      if(dis[i] == INT_MAX) {
         cout << "No";
         return 0;
      }
   }
   cout << "Yes\n";
   f(i,2,n+1){
      int val = inf;
      int id;
      for(int u : g[i]) if(dis[u] < val) val = dis[u] , id = u;
      cout << id << "\n";
   }

}

Measured memory_bytes: 18212
H,W=map(int,input().split())
a=[input() for _ in range(H)]

del_row="."*W

for i in range(len(a)):
    row=a.pop(0)
    if row!=del_row:
        a.append(row)

del_col="."*len(a)
del_list=[]
for w in range(W):
    string=""
    for h in range(len(a)):
        string+=str(a[h][w])
    if string==del_col:
        del_list.append(w)

ans_list=[]
for h in range(len(a)):
    string=""
    for w in range(W):
        if not w in del_list:
            string+=a[h][w]
    ans_list.append(string)

for i in ans_list:
    print(i)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
const int INF = 1e9;
int H, N;
int A[1100], B[1100];
int dp[20100];

int main() {
    cin >> H >> N;
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    for (int i = 0; i <= H; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= H; j++) {
            if (j < A[i]) {
                dp[j] = min(dp[j], B[i]);
            } else {
                dp[j] = min(dp[j], dp[j - A[i]] + B[i]);
            }
        }
    }
    cout << dp[H] << endl;
}

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

#define inRange(x,a,b) (a <= x && x <= b)

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

    int a[50][3][2];
    vector<int> v[3];

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 2; k++){
                int h, m;   cin >> h >> m;
                a[i][j][k] = 60*h+m;
                v[j].push_back(60*h+m);
            }
        }
    }

    int ans = 0;
    for(int x : v[0]){
        for(int y : v[1]){
            for(int z : v[2]){
                int tmp = 0;
                for(int k = 0; k < n; k++){
                    if(inRange(x, a[k][0][0], a[k][0][1]) && 
                       inRange(y, a[k][1][0], a[k][1][1]) &&
                       inRange(z, a[k][2][0], a[k][2][1])){
                           tmp++;
                    }
                }
                ans = max(ans, tmp);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3180
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
    string W;
    cin >> W;

    int ans = 0;

    string T;
    cin >> T;
    while (T != "END_OF_TEXT") {
        transform(T.begin(), T.end(), T.begin(), ::tolower);
        if (T == W) ans++;
        cin >> T;
    }

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



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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
  int a,b;
  cin >>a>>b;
  if (a>9||b>9) {
    cout<<-1<<endl;
  }
  else {
    cout <<a*b<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <regex>
using namespace std;

int main(void)
{
	string s;
	cin >> s;
	regex pt("\\.*A?KIHA?BA?RA?\\.*");
	cout << (regex_match(s, pt) ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

	int a, b, c, d;
	int n = 0;

	while(cin >> n){

	int count = 0;
	for(a=0; a<=9; a++){
		for(b=0; b<=9; b++){
			for(c=0; c<=9; c++){
				for(d=0; d<=9; d++){
					if(a+b+c+d == n){
						count = count +1;
					}
				}
			}
		}
	}

	cout << count << endl;
}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define INF 1000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll K;
  cin >> K;
  ll ans = 0;
  for (ll i = 1; i <= K; ++i)
  {
    for (ll j = i; j <= K; ++j)
    {
      for (ll k = j; k <= K; ++k)
      {
        ll temp = __gcd(__gcd(i, j), k);
        if (i == j && j == k)
        {
          ans += temp;
        }
        else if (i == j || j == k)
        {
          ans += temp * 3;
        }
        else
        {
          ans += temp * 6;
        }
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define int long long

void solve() {
    int n, m;
    cin >> n >> m;
    vector <int> g[n];
    for (int i = 0; i < m; ++i) {
        int v, u;
        cin >> v >> u;
        --v;
        --u;
        g[v].push_back(u);
        g[u].push_back(v);
    }
    vector <int> p(n, -1);
    queue <int> q;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto u : g[v]) {
            if (p[u] == -1 && u) {
                q.push(u);
                p[u] = v;
            }
        }
    }
    for (int i = 1; i < n; ++i) {
        if (p[i] == -1) {
            cout << "No";
            return;
        }
    }
    cout << "Yes\n";
    for (int i = 1; i < n; ++i) cout << p[i] + 1 << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 12868
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll n;
ll t[1111];
ll a[1111];
int main(void){
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> t[i] >> a[i];
  }
  
  ll x,y;
  x = y = 1;
  for(int i = 0; i < n; i++){
    ll k = max((x+t[i]-1)/t[i],(y+a[i]-1)/a[i]);
    x = t[i]*k;
    y = a[i]*k;
  }
  cout << x+y << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,num,sum,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
bool dp[10000];
char s[500005];

ll bitsum(ll i){
	ll s = 0;
	while(i>0){
		//p("hoi");
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void bitadd(ll b,ll x){
	while(b <= n){
		//p("hoi");
		bit[b] += x;
		b += b & -b;
	}
}

int main(){
	cin >> h >> w >> a >> b;
	c = 260;
	num = (h/a) * (w/b);
	ll pos,nega;
	pos = (h * w - num) * c;
	nega = ((a * b - 1) * c + 1) * num;
	if(pos > nega){
		p("Yes");
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if(i % a == 0 && j % b == 0){
					pe(-1 * (a * b - 1) * c - 1);
				}else{
					pe(c);
				}
			}
			el;
		}
	}else{
		p("No");
	}
	return 0;
}


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

long long a[(1 << 18) + 5];
long long b[(1 << 18) + 5];
long long c[(1 << 18) + 5];

void f(int x, int y) {
	long long p[4] = { b[x], c[x], b[y], c[y] };
	sort(p, p + 4);
	b[x] = p[3];
	c[x] = p[2];
}

int main() {
	int n;
	cin >> n;
	long long m;
	m = 1 << n;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		b[i] = a[i];
		c[i] = -1;
	}
	long long cnt = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (j&(1 << i)) {
				f(j, j ^ (1 << i));
			}
		}
	}
	long long ans = -1;
	for (int j = 1; j < m; j++) {
		ans = max(ans, b[j] + c[j]);
		cout << ans << endl;
	}


}

Measured memory_bytes: 9216
N=int(input())
L=list(map(int,input().split()))
A=[float("inf")]*(N+10)
A[0]=0
for i in range(1,N+1):
	A[i]=A[i-1]+L[i-1]
X=float("inf")
for i in range(len(A)):
	X=min(X,abs(A[N]-A[i]-A[i]))
print(X)

Measured memory_bytes: 26220
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
bool sortByWeight(pair<unsigned long long, unsigned int> &a, pair<unsigned long long, unsigned int> &b)
{
	return a.first < b.first;
}

int main(int argc, char*argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	unsigned int N; 
	unsigned long long W;
	cin >>N>>W;
	vector<pair<unsigned long long, unsigned int>> items;
	unsigned int total_v =0;
	unsigned int max_val = 0;// used to store result;
	for (int i =0; i < N; i++)
	{
		unsigned long long w;
		unsigned int v;
		cin >>w>>v;
		total_v += v;
		items.push_back(make_pair(w, v));
	}
	vector<vector<unsigned long long>> dp(2, vector<unsigned long long>(total_v+1, -1));
	
	//Sort the items by weights
	sort(items.begin(), items.end(), sortByWeight);
	
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= total_v; j++)
		{
			if( j >= items[i].second)
			{
				unsigned long long not_taken = dp[(i-1)&1][j]; // item is is not taken 
				unsigned long long taken = items[i].first;
				if(j > items[i].second) // Left over value after taking ith item
					if((dp[(i-1)&1][j-items[i].second]!=-1))
						taken += dp[(i-1)&1][j-items[i].second];
					else
					{dp[i&1][j] = not_taken ;continue;}
				
				if(taken> W)
					continue;
				dp[i&1][j] = taken;
				
				if(not_taken !=-1)
				    dp[i&1][j] = min(dp[i&1][j], not_taken);
				if(max_val < j)
					max_val = j;
			}
			else
				dp[i&1] [j] = dp[(i-1)&1][j];
		}
	}		
	cout << max_val;
}



Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
int a, b, c, d, e[500000][5], n, cnt;
    while (true) {
        cin >> n; cnt = 0; if (!n) { break; }
        for (int i = 0; i < n; i++) {
            cin >> e[i][0] >> e[i][1] >> e[i][2] >> e[i][3];
            e[i][4] = e[i][1] * 4 + e[i][2] * 9 + e[i][3] * 4;
        }
        cin >> a >> b >> c >> d;
        for (int i = 0; i < n; i++){
            if (a >= e[i][1] && b >= e[i][2] && c >= e[i][3] && d >= e[i][4]) {
                cout << e[i][0] << endl; cnt++;
            }
        }
        if (cnt == 0) { cout << "NA" << endl; }
    }
} 


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

typedef long long ll;

int main()
{
    string s;
    cin>>s;
    int ans=1e9;
    
    for(char c='a';c<='z';c++){
      int count=0;
      int maxi=0;
      
      rep(i,s.size()){
        if(s[i]==c){
          maxi=max(maxi,count);
          count=0;
        }
        else count++;
      }
      maxi=max(maxi,count);
      ans=min(ans,maxi);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N;
vector<ll> vec;

//解法
void solve() {

	ll sum = 0;
	rep(i, N) {
		sum += vec[i];
	}

	sum -= MAX(vec) / 2;

	cout << sum;

	return;
}

int main() {
	//入力

	cin >> N;
	vec.resize(N);
	rep(i, N) cin >> vec[i];

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256