akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Text;

public class AtCoder_154_A
{
    public static void Main()
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        string[] line1 = Console.ReadLine().Split(' ').ToArray();
        int[] line2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        string u = Console.ReadLine();

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < line1.Length; i++)
        {
            sb.Append((line1[i] == u) ? line2[i] - 1 : line2[i]);
            if (i != line1.Length - 1)
            {
                sb.Append(" ");
            }
        }

        Console.WriteLine(sb.ToString());
    }
}


Measured memory_bytes: 13396
#include<iostream>

int main(void)
{
	int i,j,max,tmp,high[10];

	for(i=0;i<10;i++){
		std::cin >> high[i];
	}

	for(i=0;i<3;i++){
		for(j=1,tmp=0,max=high[0];j<10;j++){
			if(max<high[j]){
				max=high[j];
				tmp=j;
			}
		}
		high[tmp]=0;
		std::cout << max << std::endl;
	}
	return 0;
}

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

int main(){
  int n;string s;cin>>n>>s;long long ans=0;
  vector<vector<int>> c(3,vector<int>(n+1,0));
  REP(i,n){
    REP(j,3) c.at(j).at(i+1)=c.at(j).at(i);
    if(s.at(i)=='R') c.at(0).at(i+1)++;
    else if(s.at(i)=='G') c.at(1).at(i+1)++;
    else c.at(2).at(i+1)++;
  }

  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      if(s.at(i)!=s.at(j)){
        string tmp=s.substr(i,1)+s.substr(j,1),RGB="RGB";
        REP(k,3){
          string t1=RGB.substr(k,1),t2=RGB.substr((k+1)%3,1);
          if(tmp==t1+t2||tmp==t2+t1){
            ans+=(long long)c.at((k+2)%3).at(n)-c.at((k+2)%3).at(j+1);
            if(2*j-i<n&&s.at(2*j-i)==RGB.at((k+2)%3)) ans--;
          }
        }
      }
    }
  }

  cout<<ans;
}

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

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, r = 0; cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = i - 1; j >= 1; j--) {
            if (a[j] == a[i]) {
                continue;
            }
            for (int k = j - 1; k >= 0; k--) {
                if (a[k] == a[i] || a[k] == a[j]) {
                    continue;
                }
                if (a[i] + a[j] + a[k] > 2 * max(a[i], max(a[j], a[k]))) {
                    r++;
                }
            }
        }
    }
    cout << r << endl;
    return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if(a+b>=24){
        cout << a+b-24 << endl;
    }else{
        cout << a+b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

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

const int inf = 999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

///////////////////////////////////////////////////////////////////////////

int main(){
	int a,b;
    cin >> a >> b;

    if(a <= 0 && 0 <= b){
        cout << "Zero" << endl;
    }else if(0 < a){
        cout << "Positive" << endl;
    }else{
        if((abs(a) - abs(b)+1)%2 == 0)cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
	return  0;
}

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

int main(){
    int series[3];
    cin >> series[0] >> series[1] >> series[2];

    if( series[2] < series[1] )swap(series[2],series[1]);
    if( series[1] < series[0] )swap(series[1],series[0]);
    if( series[2] < series[1] )swap(series[1],series[2]);

    cout <<  series[0] <<" " << series[1] << " " << series[2] << endl;

    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
char s[1000000];
long long f[1000];
int n;
long long ans;
const long long mod=1e9+7;
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	int l=0;
	for (int i=1;i<=n;i++) f[s[i]-'a']++;
	ans=1;
	for (int i=0;i<=26;i++) ans=(ans*(f[i]+1)%mod);
	cout << (ans+mod-1)%mod << endl;
} 

Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
)

func f(x int) int {
	ret := 0
	for 0 < x {
		x /= 10
		ret++
	}
	return ret
}

func main() {
	var n float64
	fmt.Scan(&n)
	wareru := 0
	for i := 1.0; i <= math.Sqrt(n); i += 1.0 {
		if int(n)%int(i) == 0 {
			wareru = int(i)
		}
	}
	b := int(n) / wareru
	// それぞれの桁数を比較して大きい方
	aketa, bketa := f(wareru), f(b)
	fmt.Println(int(math.Max(float64(aketa), float64(bketa))))
}



Measured memory_bytes: 512
N , M , X = map(int,input().split())
CA_list = [list(map(int,input().split())) for _ in range(N)]
c = [CA_list[i][0] for i in range(N)]
a = [CA_list[i][1:] for i in range(N)]

cost = sum(c)
ans = 0

#べき乗
for i in range(2**N):
   temp = 0
   skill = [0] * M
   
   for j in range(N):
     if (i >> j) & 1:
        temp += c[j] 
        skill = [y + z for (y,z) in zip(skill,a[j])]
   if all([z >= X for z in skill ]):
        cost= min(cost,temp)
        ans += 1
        
if ans == 0:
    print(-1)
else:
    print(cost)

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

using namespace std;

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

signed main () {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  a[2] -= a[0];
  a[1] -= a[0];
  a[0] = 0;
  if(a[1] % 2 == 0 && a[2] % 2 == 0) {
    cout << (a[2] * 2 - a[1]) / 2 << endl;
  } else if (a[1] % 2 == 0 && a[2] % 2 == 1) {
    cout << ((a[2]-1) * 2 - a[1]) / 2 + 1 << endl;
  } else if (a[1] % 2 == 1 && a[2] % 2 == 0) {
    cout << (a[2] * 2 - (a[1] - 1)) / 2 + 1 << endl;
  } else if (a[1] % 2 == 1 && a[2] % 2 == 1) {
    cout << (a[2] * 2  - a[1] + 2) / 2 + 1 << endl;
  }
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807
#define MAX_N 100000

int n,m,x,y,memo[100000],ans;
bool bm[100000] = {true};

signed main() {
    cin >> n >> m;
    rep(i,n) memo[i] = 1;
    rep(i,m) {
        cin >> x >> y;
        x--;y--;
        memo[x]--;
        memo[y]++;
        if (bm[x]) bm[y] = true;
        if (!memo[x]) bm[x] = false;
    }
    rep(i,n) if (bm[i]) ans++;
    cout << ans << endl;
}



Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	if(s.size()<=n)cout<<s<<endl;
	else{
		for(int i=0;i<n;i++){
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
	return 0;
}

Measured memory_bytes: 3596
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  std::string s; std::cin >> s;
  std::string day[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  int index;
  REP(i,7) {
    if (s == day[i]) index = i;
  }
  // std::cout << index << '\n';
  std::cout << 7-index << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        v.emplace_back(a,b);
    }
    sort(v.begin(),v.end(),[](pair<int,int> x,pair<int,int> y){
        return x.second<y.second;
    });
    ll cnt=0;
    for (auto p:v){
        cnt+=p.first;
        if (cnt>ll(p.second)) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    
    return 0;
}


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

using namespace std;

#define int long long

const int N = 2e3 + 5;
int n, x, y;
vector <int> ad[N];
int f[N], cnt[N];
void c(int u) {
  memset(f, 0, sizeof(f));
  f[u] = 1;
  queue <int> q;
  q.push(u);
  while(q.size()) {
    int a = q.front();
    q.pop();
    for(int v : ad[a]) {
      if(!f[v]) {
        f[v] = f[a] + 1;
        q.push(v);
      }
    }
  }
}
main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter

h, w, n = map(int, sys.stdin.readline().split())
ab = map(int, sys.stdin.read().split())
ab = zip(ab, ab)

def main():
    c = defaultdict(int)
    for a, b in ab:
        for da in range(-2, 1):
            for db in range(-2, 1):
                # 今見ているマスを含むrectangularの左上
                i = a + da
                j = b + db
                if 1 <= i <= h - 2 and 1 <= j <= w - 2:
                    c[(i, j)] += 1
    
    res = Counter(c.values())
    cnt_0 = (h - 2) * (w - 2) - sum(res.values())
    yield cnt_0
    for i in range(1, 10):
        if i in res:
            yield res[i]
        else:
            yield 0

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 184040
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)

alice = 0
bob = 0

for x in range(n):
    if x % 2 == 0:
        alice += a[x]
    else:
        bob += a[x]

res = alice - bob
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[222222];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int a,b,c,d;
int ans=0;
signed main(){
	cin>>a>>b>>c>>d;
	int e=lcm(c,d);
	int f=(e/c)+(e/d)-1;
	f=e-f;
	ans+=(b/e)*f;
	int g=(b%e);
	int memo=g/c+g/d;
	g-=memo;
	ans+=g;
	b=a-1;
	ans-=(b/e)*f;
	g=(b%e);
	memo=g/c+g/d;
	g-=memo;
	ans-=g;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
nn=[2,5,5,4,5,6,3,7,6]
n,m=map(int,input().split())
a=input().split()
b=[]
for i in range(m):
  a[i]=int(a[i])
  
if 5 in a:
  if 2 in a:
    a.remove(2)
  if 3 in a:
    a.remove(3)
elif 3 in a:
  if 2 in a:
    a.remove(2)
if 9 in a:
  if 6 in a:
    a.remove(6)
    
a.sort(reverse=True)
for i in range(len(a)):
  b.append(nn[a[i]-1])
  
dp=[-10*18 for _ in range(n+1)]
dp[0]=0
for i in range(n):
  for j in range(len(b)):
    if i+b[j]>n:
      continue
    dp[i+b[j]]=max(dp[i+b[j]],dp[i]+1)
    
k=dp[n]
ans=""
for i in range(k):
  for j in range(len(b)):
    if n-b[j]<0:
      continue
    if dp[n-b[j]]==dp[n]-1:
      ans+=str(a[j])
      n-=b[j]
      break
      
print(ans)



Measured memory_bytes: 3432
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, d, X = 0;

  cin >> N >> K;

  vector<int> x(N);
  vector<int> vec(N);

  for(int i = 0; i < N; i++){
    cin >> x.at(i);

    d = K - x.at(i);

    if(d <= x.at(i)){
      vec.at(i) = d;
    }
    else if(d > x.at(i)){
      vec.at(i) = x.at(i);
    }

  }

  for(int i = 0; i < N; i++){
      X = X + vec.at(i);
  }


  cout << 2*X << endl;

}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    pair<string,P> p[200];
    REP(i,n){
      cin >> p[i].first >> p[i].second.first;
      p[i].second.first *= -1;
      p[i].second.second = i+1;
    }
    sort(p,p+n);
    REP(i,n)cout << p[i].second.second << endl;
}

Measured memory_bytes: 256
#include <algorithm>

#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<int, int> ipair;
// typedef tuple<int, int, int> ituple;

// const int INF = (int)2e9;
// const int MOD = (int)1e9 + 7;
// const double EPS = 1e-10;

#define MAX_N 300000 + 2

void exec(){
  int a[MAX_N], n;
  cin >> n;
  for(int i = 0; i < 3 * n; i++){
    scanf("%d", &a[i]);
  }

  sort(a, a + 3 * n);
  ll ans = 0;
  int count = 0;
  int pos = 3 * n  -2;
  while(count < n){
    ans += a[pos];
    // printf("a[%d] = %d¥n", pos, a[pos]);
      pos -= 2;
    count++;
  }

  cout <<ans << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

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


Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}

int atcoder(){
    ll n;
    cin >> n;
    vector<ll> a(5);
    REP(i,0,5) cin >> a[i];

    ll minimum = min({a[0],a[1],a[2],a[3],a[4]});
    cout << RUP(n,minimum) +4 << ENT;
    return 0;
}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


string s;
bool used[26];
ll cnt = 0, ans = 0;
int main() {
	cin >> s;
	REP(i, s.size()) {
		used[s[i] - 'a'] = true;
	}
	REP(i, 26) {
		if (used[i]) cnt++;
	}
	if (cnt == 2) {
		cnt = 1;
		REP(i, s.size() - 1) {
			if (s[i] == s[i + 1])cnt++;
			else {
				ans += cnt - 1;
				cnt = 1;
			}
		}
		ans += cnt - 1;
		cout << (ans % 2 == 1 ? "First" : "Second") << endl;
	}
	else {
		ans = s.size();
		if (s[0] == s[s.size() - 1])ans++;
		cout << (cnt >= 3 and ans % 2 == 1 ? "First" : "Second") << endl;
	}
}



Measured memory_bytes: 512
H,W = map(int,input().split())
S = [input() for i in range(H)]

dxy = [(0,1),(1,0),(0,-1),(-1,0)]
for y in range(H):
    for x in range(W):
        if S[y][x]=='.': continue
        for dx,dy in dxy:
            nx,ny = x+dx,y+dy
            if not 0 <= nx < W: continue
            if not 0 <= ny < H: continue
            if S[ny][nx]=='#':
                break
        else:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define lint long long int
#define sudo std::
#define girdi freopen("motor.gir", "r", stdin);
#define cikti freopen("motor.cik", "w", stdout);
#define faster ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
#define cend << "\n";
#define cspace << " ";
#define space << " " <<
#define modal  %= 1000000007
#define P system("PAUSE");
using namespace std;
//vector <string> nec; 300milyon
//vector <int> mec;5545036815
//vector <bool> visited(1000000,0);
//map <lint,char> eksi;
//map <int,vector <int>> yollar;
//map <char,vector <pair<char,int> > > yollar;
//priority_queue <int> pq;
//set <int> ster;
//return cout << 0,0;
//multiset <int> mst;
//memset(arr, 0, sizeof arr);
//priority_queue <int, vector<int>, greater<int> > pq; 
//variable = (condition) ? expressionTrue : expressionFalse;
//sort(vec.begin(), vec.end());
//for (int i = 0; n > i; i++){
///////////////////////////////////////////////

bool bol = false;
//pair <int,int> target;
vector <pair <lint,lint> > yollar[100007];
//vector <bool> visited(200007,0);
//vector <pair <lint, lint> > vec;
//int kassen[2007][2007];
bool visited[100007];
vector <lint> vec(100007,1000007);
//lint vec[1000007];
//map <char,lint> mp;
///**************///**************///
char fe,fa,fu,fi;
lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
lint mis = 1000000007,mas = -1000000007,ans,bas,mid,son,st,en,temp,sum,prd,now;
string aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll,mm,nn,oo,pp,qq,rr,ss,tt,uu,vv,ww,xx,yy,zz;
///////////////////////////////////////////////

int main (void){
    faster
    //girdi
    //cikti
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
  	cin >> k >> a >> b;
    if (a % k == 0) return cout << "OK",0;
    if (((lint)(a / k) + 1) * k <= b) return cout << "OK",0;
    cout << "NG" cend
}


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

int main(){ 
  int N;
  vector<int> x(100010,0), y(100010,0), t(1000100);

  cin >> N;
  for(int i=1; i<=N; i++) cin >> t[i] >> x[i] >> y[i];

  bool flag = true;
  for(int i=1; i<=N; i++){
    int d = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]), dt = t[i] - t[i-1];

    if(d > dt || d % 2 != dt % 2){
      flag = false;
    }
  }

  if(flag){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){
    long long k;
    cin >> k;
    long long a=k;
    bool t =true;
    int count=0;
    int ans=0;
    while(a>9){
        if(a%10!=9)t=false;
        a/=10;
        count++;
    }
    if(t)ans+=1;
    ans+=count*9+a-1;
    cout << ans << endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

main {
  int x, y;
  while (cin >> x >> y, x || y) cout << min(x, y) << ' ' << max(x, y) << endl;
}

Measured memory_bytes: 3100
#include <cstdio>

int main()
{
  int n;
  int t[100];
  int T = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", t + i);
    T += t[i];
  }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; ++i)
  {
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", T - t[a - 1] + b);
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define maxn 100005
#define INF 0x3f3f3f3f
using namespace std;
vector<int> V[maxn];
int dp[maxn];
int minn[maxn];
int x[maxn];
void dfs(int u, int f) {
	if(u == 0) return;
	for(int i=0; i<V[u].size(); i++) {
		int v = V[u][i];
		if(v == u) continue;
		if(v == 0) continue;
		dfs(v, u);
	}
	memset(dp,INF,sizeof(dp));
	dp[0] = 0;
	for(int i=0; i<V[u].size(); i++) {
		int v = V[u][i];
		for(int j=x[u];j>=0;j--) {
			int tmp = INF;
			if(j>=x[v]) tmp = min(tmp, dp[j-x[v]]+minn[v]);
			if(j>=minn[v]) tmp = min(tmp, dp[j-minn[v]]+x[v]);
			dp[j] = tmp;
		}
	}
	for(int i=0; i<=x[u]; i++)
		minn[u] = min(minn[u], dp[i]);
}
signed main() {
	int n;
	cin >> n;
	for(int i=2; i<=n; i++) {
		int fa;
		scanf("%d",&fa);
		V[fa].push_back(i);
	}
	memset(minn,INF,sizeof(minn));
	for(int i=1; i<=n; i++) scanf("%d",&x[i]);
	dfs(1, 0);
	if(minn[1]<INF) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 6952
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

#define rep(i, n) for (long long i = 0; i < n; i++)

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

bool is_bridge(int N, vector<vector<bool>>& edges, int from, int to) {
    if (!edges[from][to]) return false;
    edges[from][to] = edges[to][from] = false;

    vector<bool> visited(N, false);
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        auto v = que.front(); que.pop();
        if (visited[v]) continue;
        visited[v] = true;

        rep(next, N) {
            if (edges[v][next])
                que.push(next);
        }
    }

    bool connected = true;
    rep(i, N) connected = connected && visited[i];

    edges[from][to] = edges[to][from] = true;
    return !connected;
}

void solve() {
    ini(N, M);
    vector<vector<bool>> edges(N, vector<bool>(N, false));
    rep(i, M) {
        ini(a, b);
        a--, b--;
        edges[a][b] = edges[b][a] = true;
    }

    ll ret = 0;
    rep(from, N) {
        for (ll to = from + 1; to < N; to++)
            if (is_bridge(N, edges, from, to)) {
                ret++;
            }
    }
    out(ret);
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    var(string, a, b, c);

    cout <<char(toupper(a[0])) <<char( toupper(b[0])) <<char( toupper(c[0])) << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int N = 5;
vector<int> tyouriTime(5);

int main(){
//    REP(i, N){
//        cin >> tyouriTime.at(i);
//    }

    string S;
    cin >> S;

    char A, C, G, T;
    int ans = 0;
    int topAns = 0;
    REP(i, S.size()){
        if(S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T'){
            ans++;
            if(topAns < ans) topAns = ans;
        }else{
            ans = 0;
        }
    }

    cout << topAns;
//    int yojo = 9;
//    int lastOrder = 0;
//    REP(i, N){
//        int nowYojo = tyouriTime.at(i) % 10;
//        if(yojo >= nowYojo && nowYojo != 0){
//            yojo = nowYojo;
//            lastOrder = i;
//        }
//    }
//
//    int ans = 0;
//    REP(i, N){
//        if(tyouriTime.at(i) % 10){
//            ans += tyouriTime.at(i) + (10 - tyouriTime.at(i) % 10);
//        }else{
//            ans += (10 - tyouriTime.at(i) % 10);
//        }
//    }
//
//    cout << ans;
}

Measured memory_bytes: 256
using System;

class Program {
    static void Main( string[] args )
    {
        Console.ReadLine();

        string[] numbers = Console.ReadLine().Split();

        int i = numbers.Length - 1;

        Console.Write( numbers[ i ] );

        while ( i > 0 ) {
            --i;
            Console.Write( " " + numbers[ i ] );
        }

        Console.WriteLine();
    }
}

Measured memory_bytes: 8904
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll N,X;
ll res;
ll y;

ll rec(ll s,ll t){
	ll a = max(s,t);
	ll b = min(s,t);
	if(b==0){
		y = a;
		return 0;
	}else{
		return ((a/b)*2)*b + rec(b,a%b);
	}
}

int main()
{
	scanf("%lld%lld",&N,&X);
	printf("%lld\n",N+rec(X,N-X)-y);
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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 int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    int l = s.size();
    rep(i, 0, l) { cout << 'x'; }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

void solve(int t, int d, int l)
{
    VI x(t);
    rep(i, t) cin >> x[i];
    int ans = -1;
    int cur = 0;
    int remain = 0;
    rep(i, t)
    {
        if (x[i] >= l)
        {
            cur++;
            remain = d - 1;
        }
        else
        {
            if (remain > 0)
            {
                cur++;
            }
            remain--;
        }
        chmax(ans, cur);
    }
    if (ans > 0)
        ans--;
    cout << ans << endl;
}

int main()
{
    int t, d, l;
    while (cin >> t >> d >> l, t)
    {
        solve(t, d, l);
    }

    return 0;
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL ans=0;int n;
int calc(int l,int r){
	if(l==0)return 0;
	int w=0,i,d,fi=n,la=n%10;
	while(fi/10)fi/=10;
	if(l==r&&n>=10)w++;
	for(i=2,d=100;d<=n;d*=10,i++)w+=d/100;
	if(fi>l)w+=d/100;
	else if(fi==l){
		w+=(n-fi*d/10)/10+(la>=r);
	}
	return w;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x=i;while(x/10)x/=10;
		ans+=calc(i%10,x);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 1e6 + 5;
const int oo = 1e9 + 5;

void solve() {
    int x;
    cin >> x;
    cout << (360) / __gcd(360, x) << '\n';
} 

int main() {
    FASTIO;
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M;
std::vector<std::vector<ll>> G( 100010, std::vector<ll>() );
bool used[100010];
ll prv[100010], dprv[100010], d[100010];

int main()
{
  std::cin >> N >> M;

  rep( i, M )
  {
    ll A, B;
    std::cin >> A >> B;
    --A; --B;

    G[A].emplace_back( B );
    G[B].emplace_back( A );
  }

  std::queue<P> que;
  que.emplace( 0, 0 );

  rep( i, N+5 )
    prv[i] = -1, d[i] = -1;

  rep( i, N+5 )
    used[i] = false;

  d[0] = 0;

  while( !que.empty() )
  {
    P p = que.front(); que.pop();
    ll v = p.first, dist = p.second;

    //std::cout << p << std::endl;

    for( auto u : G[v] ) if( d[u] == -1 )
    {
      d[u] = d[v]+1;
      que.emplace( u, dist+1 );

      if( prv[u] == -1 )
        prv[u] = v, dprv[u] = dist;
    }
  }

  repi( i, 1, N ) if( prv[i] == -1 )
  {
    std::cout << "No" << std::endl;

    return 0;
  }

  std::cout << "Yes" << std::endl;

  repi( i, 1, N )
    std::cout << prv[i]+1 << std::endl;

  return 0;
}

Measured memory_bytes: 14672
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    count = 0

    for i in range(n):
        if a[i] >= b[i]:
            a[i] -= b[i]
            count += b[i]
        else:
            count += a[i]
            b[i] -= a[i]
            a[i] = 0
            if a[i + 1] >= b[i]:
                a[i + 1] -= b[i]
                count += b[i]
            else:
                count += a[i + 1]
                b[i] -= a[i + 1]
                a[i + 1] = 0
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19004
#include<stdio.h>
#include<math.h>
#define O 0
#define I 1
#define W 2
#define T 3
#define H 100

struct Point{
  double x;
  double y;
};

void koch(int,struct Point,struct Point);

int main(){
  struct Point p1,p2;
  int n;

  scanf("%d",&n);
  p1.x=O;
  p1.y=O;
  p2.x=H;
  p2.y=O;
 printf("%.8f %.8f\n",p1.x,p1.y);
 koch(n,p1,p2);
 printf("%.8f %.8f\n",p2.x,p2.y);
 return 0;
}
void koch(int d,struct Point p1,struct Point p2){
  struct Point s,t,u;
  double k;

  if(d==O){
      return;
    }

  k=M_PI*60/180;

  s.x=(W*p1.x+1.0*p2.x)/T;
  s.y=(W* p1.y+I*p2.y)/T;
  t.x=(I*p1.x+W*p2.x)/T;
  t.y=(I*p1.y+W*p2.y)/T;
  u.x=(t.x-s.x)*cos(k)-(t.y-s.y)*sin(k)+s.x;
  u.y=(t.x-s.x)*sin(k)+(t.y-s.y)*cos(k)+s.y;

  koch(d-I,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(d-I,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(d-I,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(d-I,t,p2);
}



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

price=0


Li = []
for i in range(N):
	ABi = list(map(int,input().split()))
	Li.append(ABi)

Li.sort()
# print(Li)

i=0

while M>0:
	if Li[i][1] > M:
		price=price+Li[i][0]*M
		M=M-M
		i=i+1
	else:
		price=price+Li[i][0]*Li[i][1]
		M=M-Li[i][1]
		i=i+1

print(price)

Measured memory_bytes: 27760
import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static Node[] node;
	public static int[][] cost;
	public static int n;
	public static Scanner in = new Scanner(System.in);
	public static void main(String[] args){
		while(true){
			n = in.nextInt();
			if(n == 0) break;
			long sum = init();
			long res = remove();
			long longest = longest();
			System.out.println(res + longest*2 + (sum - res - longest)*3);
		}
	}
	
	public static long longest(){
		used = new BitSet(n);
		pathId = 0;
		path = -1;
		for(int i=0; i<n; i++){
			if(node[i] == null) continue;
			dfs(node[i], 0);
			path = 0;
			used.clear();
			if(pathId >= 0) dfs(node[pathId], 0);
			break;
		}
		return path;
	}
	
	public static long path;
	public static int pathId;
	public static BitSet used;
	public static void dfs(Node nd, long dist){
		used.set(nd.id);
		long res = dist;
		boolean update = false;
		for(Node v: nd.edge){
			if(used.get(v.id)) continue;
			update = true;
			used.set(v.id);
			dfs(v, dist + cost[nd.id][v.id]);
		}
		if(!update && path < res){
			path = res;
			pathId = nd.id;
		}
	}
	
	public static long init(){
		node = new Node[n];
		for(int i=0; i<n; i++){
			node[i] = new Node(i);
		}
		cost = new int[n][n];
		int[] map = new int[n];
		for(int i=1; i<n; i++){
			int p = in.nextInt()-1;
			node[p].createEdge(node[i]);
			node[i].createEdge(node[p]);
			map[i] = p;
		}
		long sum = 0;
		for(int i=1; i<n; i++){
			int d = in.nextInt();
			cost[i][map[i]] = d;
			cost[map[i]][i] = d;
			sum += d;
		}
		return sum;
	}
	
	public static long remove(){
		long res = 0;
		BitSet bs = new BitSet(n);
		for(int i=0; i<n; i++){
			if(node[i].edge.size() > 1) continue;
			bs.set(i);
		}
		for(int i=bs.nextSetBit(0); i!=-1; i=bs.nextSetBit(i+1)){
			Node next = node[i].edge.get(0);
			res += cost[i][next.id];
			next.edge.remove(node[i]);
			node[i].edge.remove(next);
			node[i] = null;
		}
		return res;
	}
}

class Node{
	int id;
	List<Node> edge = new ArrayList<Node>();
	public Node(int id){
		this.id = id;
	}
	public void createEdge(Node n){
		edge.add(n);
	}
}

Measured memory_bytes: 101488
#pragma optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int h, w, n;
int x, y;
string s, t;
int balR, balL, balU, balD;
void bad() {
    cout << "NO";
    exit(0);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
  //  freopen("input.txt", "r", stdin);
    cin >> h >> w >> n >> x >> y;
    cin >> s >> t;
    for (int i = 0; i < n; i++) {
        if (t[i] == 'L' || t[i] == 'R') {
            t[i] = 'R' + 'L' - t[i];
        }
        else {
            t[i] = 'U' + 'D' - t[i];
        }
    }
    balR = y - w - 1;
    balL = -y;
    balD = x - h - 1;
    balU = -x;
    for (int i = 0; i < 2 * n; i++) {
        char c;
        if (i % 2 == 0) c = s[i / 2];
        else c = t[i / 2];
        int sgn = 1;
        if (i % 2 == 1) sgn = -1;
        if (c == 'R') {
            balR += sgn;
        }
        else if (c == 'L') {
            balL += sgn;
        }
        else if (c == 'D') {
            balD += sgn;
        }
        else {
            balU += sgn;
        }
        if (balR >= 0 || balL >= 0 || balU >= 0 || balD >= 0) bad();
        balR = max(balR, -w);
        balL = max(balL, -w);
        balU = max(balU, -h);
        balD = max(balD, -h);

    }
    cout << "YES" << '\n';
    return 0;
}

Measured memory_bytes: 920
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

std::vector<size_t> make_vector(size_t n, size_t x) {
  return std::vector<size_t>(n, x);
}

template <class Tp>
std::vector<Tp> make_vector(size_t n, const Tp& x) {
  return std::vector<Tp>(n, x);
}

template <class... Ts>
auto make_vector(size_t n, size_t m, const Ts&... x) {
  return std::vector<decltype(make_vector(m, x...))>(n, make_vector(m, x...));
}

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  std::vector<size_t> a(N);
  for (auto& ai: a) scanf("%zu", &ai);

  constexpr intmax_t mod = 1e9+7;
  auto dp = make_vector(N+1, K+1, intmax_t(0));

  dp[0][0] = 1;
  for (size_t i = 0; i < N; ++i) {
    for (size_t j = 1; j <= K; ++j)
      (dp[i][j] += dp[i][j-1]) %= mod;

    for (size_t j = 0; j <= K; ++j) {
      intmax_t cur = dp[i][j];
      if (j > a[i])
        (cur += mod - dp[i][j-a[i]-1]) %= mod;

      (dp[i+1][j] += cur) %= mod;
    }
  }

  printf("%jd\n", dp[N][K]);
}


Measured memory_bytes: 80256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

    int right[26] = {0};
    rep(i, s.size())right[s[i]-'a']++;
    int left[26] = {0};
    int maxim  = 0;
    rep(i, s.size()){
        right[s[i]-'a']--;
        left[s[i]-'a']++;
        int sum = 0;
        rep(j, 26)if(min(right[j], left[j]) > 0)sum++;
        maxim = max(maxim, sum);
    }
    cout << maxim << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int n, k; string s;
    cin >> n >> s >> k;
    char c = s[k-1];
    rep(i, 0, n) if(s[i] != c) s[i] = '*';
    cout << s << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,cnt=0;
    cin>>n;
    for(int i=1;i<=n;i+=2)
        cnt++;
    double ans=(double)cnt/(double)n;
    cout<<setprecision(10)<<fixed<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3804