akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
	int n,b,f,r,v,i,j,k;
	int a[4][3][10];
	scanf("%d",&n);
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				a[i][j][k] = 0;
			}
		}
	}

	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		a[b - 1][f - 1][r - 1] = a[b -1][f - 1][r - 1] + v;
	}
	for(i=0;i<4;i++){
		for(j = 0;j<3;j++){
			for(k =0;k<10;k++){
				printf(" %d",a[i][j][k]);
			}
			printf("\n");
		}
		if(i<3) printf("####################\n");
	}
	return 0;
}

Measured memory_bytes: 612
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut v = get!([usize]);
    v.sort();
    v.reverse();
    let mut ans = 0;
    //eprintln!("n: {}", n);
    //eprintln!("{:?}", v);
    for i in 0..n {
        ans += v[(i * 2) + 1];
    }
    println!("{}", ans);
}


Measured memory_bytes: 13560
#include<iostream>
#include<algorithm>

using namespace std;

const int MAX = 101;
const int INF = (1<<20);

int cost[MAX][MAX];
int mincost[MAX];
bool used[MAX];
int V;

int prim(){
  mincost[0] = 0;
  int res = 0;

  while(1){

    int v = -1;
    for(int i = 0; i < V; i++)
      if(!used[i] && (v == -1 || mincost[i] < mincost[v])) v = i;

    if(v == -1) break;

    used[v] = true;
    res+=mincost[v]/100-1;
    for(int i = 0; i < V; i++)
      mincost[i] = min(mincost[i],cost[v][i]);

  }
  return res+1;
}

void init(){
  fill(mincost,mincost+MAX,INF);
  fill(used,used+MAX,false);
  for(int i = 0; i < MAX; i++)
    for(int j = 0; j < MAX; j++)
      cost[i][j] = INF;
}
int main(){
  while(cin >> V && V){
    init();
    int m;
    cin >> m;
    while(m--){
      char c;
      int f,t,cos;
      cin >> f >> c >> t >> c >> cos;
      cost[f][t] = cost[t][f] = cos;
    }
    cout << prim() << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int,int> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
int cnt[N]={};
bool f;
int main()
{

  int n,count(0);
  string s;
  cin>>n>>s;
  vector<char>vc;
rep(i,n)
{
    vc.pb(s[i]);
}
  rep(i,n-1)
  {
      if(vc[i]==vc[i+1])
        vc[i]='#';
  }
  rep(i,n)
  {
      if(vc[i]!='#')
        count++;
  }
  cout<<count;

go;
}


Measured memory_bytes: 640
/* author   : mpily :-()
title : Competing.cpp
time :Sun Oct  6 16:31:06 2019

*/
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3fff
int dp[1001][5000];
int costs[1001];
int opens[1001];
int N,M;
int fin;
void init(){
	for(int i =0; i < M;i++){
		for(int j = 0; j < 5000;j++)dp[i][j] = -1;
	}
	fin = (1<<N)-1;
}
int solve(int pos, int obtained){
	if(pos == M && obtained != fin)return  inf;
	if(pos == M && obtained == fin)return 0;
	if(dp[pos][obtained] != -1)return dp[pos][obtained];
	int a = solve(pos+1,obtained);
	int b = solve(pos+1,obtained | opens[pos])+costs[pos];
	int ans =  min(a,b);
	dp[pos][obtained] = ans;
	return ans;
}
int main(){	
	cin>>N>>M;
	init();
	for(int i = 0; i < M; i++){
		cin>>costs[i];
		int bi;
		cin>>bi;
		for(int j = 0;  j < bi; j++){
			int temp;
			cin>>temp;
			temp-=1;
			opens[i]|=1<<temp;
		}
	}
	int ans = solve(0,0);
	if(ans>= inf)cout<<-1<<"\n";
	else cout<<ans<<"\n";	
	return 0;
}


Measured memory_bytes: 19840
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int H, W;
int A, B;
const int MAX_HW = 110;
char board[MAX_HW][MAX_HW];
int main()
{
    cin >> A >> B;
    H = W = 100;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (i < H / 2)
            {
                board[i][j] = '.';
            }
            else
            {
                board[i][j] = '#';
            }
        }
    }
    int y, x;
    y = 1;
    x = 1;
    for (int i = 0; i < B - 1; i++)
    {
        board[y][x] = '#';
        x += 2;
        if (x >= W)
        {
            y += 2;
            x = 1;
        }
    }
    y = H - 2;
    x = W - 2;
    for (int i = 0; i < A - 1; i++)
    {
        board[y][x] = '.';
        x -= 2;
        if (x < 0)
        {
            y -= 2;
            x = W - 2;
        }
    }
    cout << H << " " << W << endl;
    rep(i, H)
    {
        rep(j, W)
        {
            cout << board[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll X;
  cin >> X;
  ll ans = 1;
  for (ll i = 2; i * i <= X; i++) {
    ll c = i;
    while (c * i <= X) {
      c *= i;
    }
    ans = max(ans, c);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
  char str[3];
  int i;
  for(i=0;i<3;i++)
    scanf("%s",&str[i]);
  
  if(str[0]==str[1]&&str[1]==str[2])
    printf("No");
  else
    printf("Yes");
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int n;
 cin>>n;
 if(n==0) cout<<"Yes"<<endl;
 else {
     bool flag=true;
     for (int i = 1; i <= 9; i++) {
         if (n % i == 0) {
             int b=n/i;
             if(b>=1&&b<=9) 
             { flag=false;
                 cout<<"Yes"<<endl;
                 break;
             }

         }

     }
     if(flag) cout<<"No"<<endl;
 }

}

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

int main()
{ 
  int n, ans = 10000, sum_w = 0, x = 0;
  vector<int> w(100);

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> w[i];
    sum_w += w[i];
  }
  for (int i = 0; i < n - 1; i++)
  {
    x += w[i];
    ans = min(ans, abs(2 * x - sum_w));
  }
  cout << ans << endl;
}

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

#define pb push_back

#define int ll
using i128 = __int128_t;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

template<typename T, typename U>
ostream& operator<<(ostream& o, const pair<T,U>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (const T& x : v)
    o << x << ",";
  return o << "]";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T>>& v) {
  o << "[";
  for (const vector<T>& x : v)
    o << x << ",\n";
  return o << "]";
}

const int INF = 1e18;

int a,b,c,d;
int solve(const int n) {
  const int divcost[] = {INF,INF,a,b,INF,c};

  int solution = 61*(a+d);  // can be done in 60*d + 59*a
  set<pii> pq;
  pq.insert({0,n});
  while (!pq.empty()) {
    int cost, curr;
    tie(cost, curr) = *pq.begin();
    pq.erase(pq.begin());
    if (cost >= solution)  // stop when we can't find a better solution anymore
      return solution;

    if ((solution-cost)/d >= curr)  // anti-overflow
      solution = min(solution, cost+curr*d);

    {
      const pii pd = {-(curr%5), 5};
      int next = (curr + pd.first)/pd.second;
      if (next >= 0 && next < curr)
        pq.insert({cost + abs(pd.first)*d + divcost[pd.second], next});
    }
    {
      const pii pd = {5-(curr%5), 5};
      if (pd.first < 5) {
        int next = (curr + pd.first)/pd.second;
        if (next >= 0 && next < curr)
          pq.insert({cost + abs(pd.first)*d + divcost[pd.second], next});
      }
    }
    {
      const pii pd = {-(curr%3), 3};
      int next = (curr + pd.first)/pd.second;
      if (next >= 0 && next < curr)
        pq.insert({cost + abs(pd.first)*d + divcost[pd.second], next});
    }
    {
      const pii pd = {3-(curr%3), 3};
      if (pd.first < 3) {
        int next = (curr + pd.first)/pd.second;
        if (next >= 0 && next < curr)
          pq.insert({cost + abs(pd.first)*d + divcost[pd.second], next});
      }
    }
    {
      const pii pd = {-(curr%2), 2};
      int next = (curr + pd.first)/pd.second;
      if (next >= 0 && next < curr)
        pq.insert({cost + abs(pd.first)*d + divcost[pd.second], next});
    }
    {
      const pii pd = {2-(curr%2), 2};
      if (pd.first < 2) {
        int next = (curr + pd.first)/pd.second;
        if (next >= 0 && next < curr)
          pq.insert({cost + abs(pd.first)*d + divcost[pd.second], next});
      }
    }
  }
  return solution;
}

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

  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    cin >> a >> b >> c >> d;
    cout << solve(n) << "\n";
    //cout << "DBG" << endl;
  }
}


Measured memory_bytes: 6200
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n, q;
  cin >> n >> q;
  vector<int> v[1000];
  rep(qi, q)
  {
    int type;
    cin >> type;
    if (type == 0)
    {
      int t, x;
      cin >> t >> x;
      v[t].push_back(x);
    }
    else if (type == 1)
    {
      int t;
      cin >> t;
      rep(i, v[t].size()) cout << v[t][i] << (i == (int)v[t].size() - 1 ? "\n" : " ");
      if (v[t].empty())
        cout << endl;
    }
    else
    {
      int t;
      cin >> t;
      v[t].clear();
    }
  }

  return 0;
}



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

string l;
void make_l(){
  l = "";
  for(char c = 'a';c<='z';c++)l+=c;
  for(char c = 'A';c<='Z';c++)l+=c;
}
vector<int> k;
string s;
void init(){
  k.clear();
}

bool input(){
  int n;
  cin>>n;
  if(n==0)return false;
  k.resize(n);
  for(int i=0;i<k.size();i++){
    cin>>k[i];
  }
  cin>>s;
  return true;
}

string solve(){
  string res = "";
  for(int i=0;i<s.size();i++){
    char c = s[i];
    const int n = i%k.size();
    int cc = 0;
    while(c!=l[cc])cc++;
    cc -= k[n];
    cc += l.size();
    cc %= l.size();

    res += l[cc];
  }
  return res;
}

int main(){
  make_l();
  while(init(),input()){
    cout<<solve()<<endl;
  }
}

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

using namespace std;

int main()
{
    string s;

    cin >> s;
    string rs = s;

    reverse(rs.begin(), rs.end());

    int ans = 0;
    const int n = (s.size() % 2 == 0) ? s.size() / 2 - 1 : s.size() / 2;

    for (int i = 0; i <= n; ++i) {
        if ((s[i] == '(' && rs[i] == ')') ||
            (s[i] == ')' && rs[i] == '('))
            continue;
        else if (s[i] != rs[i])
            ++ans;
        else if (s[i] == '(' || s[i] == ')')
            ++ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1192
from collections import deque
n,k=map(int,input().split())
edge=[[] for _ in range(n)]
visited=[-1]*n
def pmt(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    return g1[n]* g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
for _ in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
stack=deque([])
visited[0]=0
for e in edge[0]:
  stack.append(e)
  visited[e]=0
def dfs():
  ans=k*pmt(k-1,len(edge[0]),mod)%mod
  while stack:
    p=stack.pop()
    cnt=0
    for c in edge[p]:
      if visited[c]==-1:
        cnt+=1
        visited[c]=0
        stack.append(c)
    ans=ans*pmt(k-2,cnt,mod)%mod
  return ans%mod
print(dfs())

Measured memory_bytes: 35796
#include <vector>
#include <cstdio>
#include <iostream>
#include <tuple>
#include <stdexcept>
#include <map>
#include <set>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <numeric>
#include <unordered_map>
#include <bitset>
#include <queue>

#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long LL;
#define mod LL(1e9 + 7)

int a[2222222];

int main(){
    int n, k, x = -1;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        x = min(x, a[i]);
    }

    int p = 1, ans = 0;
    while (p < n) {
            ans++;
            p += k - 1;
    }
    cout << ans;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
using namespace std;
struct node{int n,a[110000];}p,q,A,r,ss;
node operator*(node x,node y)
{
	node z;z.n=x.n;
	for(int i=1;i<=z.n;i++)z.a[i]=y.a[x.a[i]];
	return z;
}
node operator-(node x)
{
	node y;y.n=x.n;
	for(int i=1;i<=y.n;i++)y.a[x.a[i]]=i;
	return y;
}
node operator^(node x,int k)
{
	node y;y.n=x.n;
	memset(y.a,-1,sizeof(y.a));
	for(int i=1;i<=y.n;i++)
	{
		if(y.a[i]==-1)
		{
			int j=x.a[i],ring=1;
			while(j!=i)j=x.a[j],ring++;
			int t=k%ring;
			y.a[i]=i;
			while(t--)y.a[i]=x.a[y.a[i]];
			while(x.a[j]!=i)y.a[x.a[j]]=x.a[y.a[j]],j=x.a[j];
		}
	}
	return y;
}
int main()
{
	int n,k;scanf("%d%d",&n,&k);
	p.n=q.n=n;
	for(int i=1;i<=n;i++)scanf("%d",&p.a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&q.a[i]);
	A=-q*p*q*-p;
	A=A^k/6;
	if(k%6==0)r=p*-q;
	else if(k%6==1)r=p;
	else if(k%6==2)r=q;
	else if(k%6==3)r=-p*q;
	else if(k%6==4)r=-q*-p*q;
	else if(k%6==5)r=-q*p*-q*-p*q;
	ss=A*r*-A;
	for(int i=1;i<n;i++)printf("%d ",ss.a[i]);
	printf("%d\n",ss.a[n]);
	return 0;
}

Measured memory_bytes: 10596
#include "bits/stdc++.h"
using namespace std;

struct edge {
	int From, To, Cost;
	edge(int A, int B, int C) : From(A), To(B), Cost(C) {}
};

int main() {
	int L;
	cin >> L;
	vector<edge> ANS;
	for (int i = 1; i <= 18; i++) {
		ANS.push_back(edge(i, i + 1, 0));
		ANS.push_back(edge(i, i + 1, 1 << (i - 1)));
	}
	int NOW = 0;
	if (L & (1 << 19)) {
		ANS.push_back(edge(19, 20, 0));
		ANS.push_back(edge(19, 20, 1 << 18));
		NOW = 1 << 19;
	}
	for (int i = 19; i >= 1; i--) {
		if (L & (1 << (i - 1))) ANS.push_back(edge(i, 20, NOW)), NOW += (1 << (i - 1));
	}
	cout << 20 << ' ' << ANS.size() << endl;
	for (edge E : ANS) cout << E.From << ' ' << E.To << ' ' << E.Cost << endl;
}

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

void solve(){
    ll n;
    cin>>n;
    vector<ll> array;
    for(ll i=0;i<n;i++){
        ll tem;
        cin>>tem; 
        array.push_back(tem); 
    }
    ll ans=0; 
    for(ll i=1;i<n;i++){
        if(array[i]<array[i-1]){
            ans+= array[i-1]-array[i];
            array[i]+=array[i-1]-array[i];
            
        }
    }
    cout<<ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}
                                                                

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

#define int              long long 
#define FOR( i, m, n )   for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )      FOR( i, 0, n )
#define ALL( a )         (a).begin(), (a).end()
#define fi               first
#define se               second

typedef pair<int, int> P;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
  int N, M; cin >> N;
  vector<int> s( N );
  REP( i, N ) cin >> s[i];
  sort( ALL( s ) );

  cin >> M;
  set<int> cnt;
  REP( i, M ){
    int t; cin >> t;
    if( binary_search( ALL( s ), t ) ){
      cnt.insert( t );
    }
  }

  cout << cnt.size() << endl;
  
}



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

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

    if (b[0]=='A'){
        cout << "T" << endl;
    }

    else if (b[0]=='T'){
        cout << "A" << endl;
    }

    else if (b[0]=='C'){
        cout << "G" << endl;
    }

    else if (b[0]=='G'){
        cout << "C" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/* ~ Programmer >> Tushar Mahajan */
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
#define ll long long int
#define ld long double
#define MOD 1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL); 

int main() {
	ios;
	ll n;
	cin>>n;
	if(n>=30)
	{
	    cout<<"Yes"<<endl;
	}
	else
	{
	    cout<<"No"<<endl;
	}
	return 0;
}


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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i, n-1) cin >> c[i];
    int ans=0;
    rep(i,n){
        ans += b[a[i]-1];
        if(a[i] == a[i+1]-1){
            ans += c[a[i]-1];
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

ll memo[101][4][4][4];

#define MOD ll(1e9+7)
int main()
{
    int N;
    cin >> N;

    memo[0][3][3][3] = 1;

    for (int index = 0; index < N; index++)
    {
        for (int c1 = 0; c1 < 4; c1++)
        {
            for (int c2 = 0; c2 < 4; c2++)
            {
                for (int c3 = 0; c3 < 4; c3++)
                {
                    if (memo[index][c1][c2][c3] == 0) continue;

                    for (int now = 0; now < 4; now++)
                    {
                        if (c2 == 0 and c3 == 1 and now == 2) continue;
                        if (c2 == 0 and c3 == 2 and now == 1) continue;
                        if (c2 == 1 and c3 == 0 and now == 2) continue;
                        if (c1 == 0 and c2 == 1 and now == 2) continue;
                        if (c1 == 0 and c3 == 1 and now == 2) continue;
                        memo[index+1][c2][c3][now] += memo[index][c1][c2][c3];
                        memo[index+1][c2][c3][now] %= MOD;
                    }
                }
            }
        }
    }

    ll sum = 0;
    for (int c1 = 0; c1 < 4; c1++)
    {
        for (int c2 = 0; c2 < 4; c2++)
        {
            for (int c3 = 0; c3 < 4; c3++)
            {
                sum += memo[N][c1][c2][c3];
                sum %= MOD;
            }
        }
    }

    cout << sum << endl;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll w,h,n; cin>>w>>h>>n;
  ll u=h,d=0,l=0,r=w;
  rep(i,n){
    ll x,y,a; cin>>x>>y>>a;
    if(a==1){
      chmax(l,x);
    }else if(a==2){
      chmin(r,x);
    }else if(a==3){
      chmax(d,y);
    }else{
      chmin(u,y);
    }
  }
  // cout<<u<<' '<<d<<' '<<l<<' '<<r<<endl;
  if(r<=l || u<=d) cout<<0<<endl;
  else cout<<(r-l)*(u-d)<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    priority_queue<int,vector<int>,less<int> > que;
    rep(i,N) que.push(A[i]);

    while(M){
      int num = que.top(); que.pop();
      num /= 2;
      que.push(num);
      M--;
    }

    ll ans = 0;
    while(!que.empty()){
      ans += que.top();
      que.pop();
    }
    cout << ans << endl;

}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

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

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  int64_t n;
  cin >> n;
  vector<int64_t> vec(n);
  int64_t f,s,t;
  f = INT_MIN;
  s = INT_MIN;
  t = INT_MIN;
  REP(i,n){
    cin >> vec.at(i);
  }
  SORT(vec);
  int64_t fc = 0;
  int64_t sc = 0;
  int64_t tc = 0;
  int64_t oc = 0;
  REP(i,n){
    if (f == INT_MIN){
      f = vec.at(i);
      fc++;
    }else if(vec.at(i) == f){
      fc++;
    }else if(s == INT_MIN){
      s = vec.at(i);
      sc++;
    }else if(vec.at(i) == s){
      sc++;
    }else if(t == INT_MIN){
      t = vec.at(i);
      tc++;
    }else if(vec.at(i) == t){
      tc++;
    }else{
      oc++;
    }
  }
  
  if (f == 0 && sc == 0 && tc == 0 && oc == 0){
    cout << "Yes" << endl;
    return 0;
  }
  if (f == 0 && fc * 2 == sc && tc == 0 && oc == 0){
    cout << "Yes" << endl;
    return 0;
  }
  if (((f ^ s) ^ t) == 0 && ((s ^ t) ^ f) == 0 && ((t ^ f) ^ s) == 0){
    if (fc == sc && sc == tc && oc == 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
// void fill(ll n, ll a[n], ll value){ rep(i,0,n) a[i] = value; }
void cin(ll *n){ scanf("%lld",&(*n)); }
void cin2(ll *a, ll *b){ scanf("%lld%lld",&(*a),&(*b)); }
void cin3(ll *a, ll *b, ll *c){ scanf("%lld%lld%lld",&(*a),&(*b),&(*c)); }
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,m;
    // ll ans=0;
    cin(&n);
    cin(&m);
    // cin2(&,&);
    // cin3(&,&,&);
    ll a[m];
    rep(i,0,m){
        cin(&a[i]);
    }
    ll dp[n+1];
    rep(i,0,n+1) dp[i] = 0;
    ll mark=0;
    dp[0] = 1;

    if(a[mark]==1){
        mark++;
    }else{
        dp[1] = dp[0];
    }

    // if(a[mark]==2){
    //     mark++;
    // }else{
    //     dp[2] = dp[0]+dp[1];
    // }

    rep(i,2,n+1){
        if(a[mark]==i){
            mark++;
            continue;
        }
        dp[i] = dp[i-1] + dp[i-2];
        dp[i]%=MOD1;
    }
    // rep(i,0,n+1) printf("%lld ",dp[i]);
    printf("%lld\n",mod_MOD1(dp[n]) );
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;
int a[12][12];
const int INF = 1001001001;
int main(){	
	string s,t;
	cin >> s >> t; 
	int ans = 0;
	rep(i,s.size()) ans += s[i]!=t[i];
	cout << ans << endl;
	return 0;


}





Measured memory_bytes: 3760
import re


def main():
    N = int(input())  # 10^4
    b__a = 0
    b___ = 0
    ___a = 0
    tmp = 0
    ans = 0
    for i in range(N):
        tmp = input()
        if (tmp[0] == 'B') and (tmp[-1] == 'A'):
            b__a += 1
        elif (tmp[0] == 'B'):
            b___ += 1
        elif (tmp[-1] == 'A'):
            ___a += 1

        ans += len(re.findall('AB', tmp))

    if b__a == 0:
        ans += min(b___, ___a)
    else:
        if (b___ + ___a) > 0:
            ans += b__a + min(b___, ___a)
        elif (b___ + ___a) == 0:
            ans += b__a - 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 48984
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl


namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	double t, x;
	cin >> t >> x;
	cout << t / x << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)

struct mint {
    typedef decay<decltype(MOD)>::type T; 
    T v; explicit operator T() const { return v; }
    mint() { v = 0; }
    mint(ll _v) { 
        v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
        if (v < 0) v += MOD;
    }
    friend bool operator==(const mint& a, const mint& b) { 
        return a.v == b.v; }
    friend bool operator!=(const mint& a, const mint& b) { 
        return !(a == b); }
    friend bool operator<(const mint& a, const mint& b) { 
        return a.v < b.v; }   
    mint& operator+=(const mint& m) { 
        if ((v += m.v) >= MOD) v -= MOD; 
        return *this; }
    mint& operator-=(const mint& m) { 
        if ((v -= m.v) < 0) v += MOD; 
        return *this; }
    mint& operator*=(const mint& m) { 
        v = (ll)v*m.v%MOD; return *this; }
    mint& operator/=(const mint& m) { return (*this) *= inv(m); }
    friend mint pow(mint a, ll p) {
        mint ans = 1; assert(p >= 0);
        for (; p; p /= 2, a *= a) if (p&1) ans *= a;
        return ans;
    }
    friend mint inv(const mint& a) { assert(a.v != 0); 
        return pow(a,MOD-2); }
        
    mint operator-() const { return mint(-v); }
    mint& operator++() { return *this += 1; }
    mint& operator--() { return *this -= 1; }
    friend mint operator+(mint a, const mint& b) { return a += b; }
    friend mint operator-(mint a, const mint& b) { return a -= b; }
    friend mint operator*(mint a, const mint& b) { return a *= b; }
    friend mint operator/(mint a, const mint& b) { return a /= b; }
};
const int nmax = 2e5+5;
mint fact[nmax];

mint ncr(ll x, ll y){
    return (fact[x]/(fact[x-y]*fact[y]));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z,h,w,a,b;
    mint res;
    fact[0] = 1;
    for(int i=1;i<nmax;i++){
        fact[i] = i*fact[i-1];
    }
    cin>>h>>w>>a>>b;
    res = ncr(h+w-2,h-1);
    for(ll i=h;i>h-a;i--){
        res = res - ncr(i+b-2,b-1)*ncr(h-i+w-b-1,h-i);
    }
    cout<<res.v;
    


    
    return 0;
}

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

int main(){
	int n=1;
	int a = 0;
	int f = 0;
	int quest[10000] = { 1 };
	double ans[10000];
	int checkc = 0;
	int i = 4;
	double check[3] = { 1, 2, 4 };
	
	do{
		cin >> quest[a];
		a++;
	} while (quest[a-1] != 0);
	while (a > f+1){
		switch (quest[f]){
		case 1:
			ans[f] = 1;
			break;
		case 2:
			ans[f] = 2;
			break;
		case 3:
			ans[f] = 4;
			break;
		default:
			while (quest[f] >= i){
				ans[f] = check[0] + check[1] + check[2];
				i++;
				check[0] = check[1];
				check[1] = check[2];
				check[2] = ans[f];
			}
		}

		ans[f] = ans[f] / 3650;
		checkc = (int)(ans[f]);

		if (ans[f] > (double)(checkc)){
			checkc++;
		}
		if (ans[f] != 0){
			cout << checkc << endl;
		}
		else{
			cout << endl;
		}
		f++;
	}
	return 0;
}

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

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int s;
    cin >> s;
    if (s < 3) {
        cout << 0 << endl;
        return 0;
    } else if ( s < 6) {
        cout << 1 << endl;
        return 0;
    }
    vector<mint> dp(s + 3);
    dp[3] = 1;
    dp[4] = 1;
    dp[5] = 1;
    for (int i = 6; i <= s; i++) {
        dp[i] = dp[i - 1] + dp[i - 3];
    }
    cout << dp[s] << endl;
    return 0;
}
/*
g++ -std=c++17 -Wall -Wextra -g -O0 -fsanitize=undefined,address main.cpp && oj t
*/

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

int main(){
  string s,t;
  cin>>s>>t;
  int c=0;
  for(int i=0;i<s.size();i++){
      if(s[i]==t[i]){
        c++;
      }
  }
  cout<<c<<endl;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
	char name1[15], name2[15], name3[15];
	int num1, num2;
	scanf("%s %s\n%d %d\n%s", &name1, &name2, &num1, &num2, &name3);

	if (strcmp(name1, name3) == 0){
		printf("%d %d", num1 - 1, num2);
	} else if (strcmp(name2, name3) == 0){
		printf("%d %d", num1, num2 -1);
	}
	return 0;
}

Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N;

ll gcd(ll a, ll b) {
  if (b == 0) return a;

  return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  cin >> N;
  vector<ll> a(N, 0);

  ll lc = 1;
  ll ans = 0;
  rep(i, 0, N) {
    cin >> a[i];
    ans += a[i] - 1;
    lc = lcm(lc, a[i]);
  }
  cout << ans << endl;
}


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

int segment[10][7] = {
	{0,1,1,1,1,1,1},
	{0,0,0,0,1,1,0},
	{1,0,1,1,0,1,1},
	{1,0,0,1,1,1,1},
	{1,1,0,0,1,1,0},
	{1,1,0,1,1,0,1},
	{1,1,1,1,1,0,1},
	{0,1,0,0,1,1,1},
	{1,1,1,1,1,1,1},
	{1,1,0,1,1,1,1}
} ;

main(){
	int n,m ;
	while( cin >> n , n ){
		if( n == -1 ) break ;
		
		int t[7] = {} ;
		for( int i=0 ; i<n ; i++ ){
			cin >> m ;
			for( int j=0 ; j<7 ; j++ ){
				if( segment[m][j] ){
					if( t[j] ) cout << 0 ;
					else cout << 1 ;
				}
				else{
					if( t[j] ) cout << 1 ;
					else cout << 0 ;
				}
				t[j] = segment[m][j] ;
			}
			cout << endl ;
		}
	}
}

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

int main(){
	
	int n,a,b,c,d; cin>>n>>a>>b>>c>>d;
	a--; b--; c--; d--;
	string s; cin>>s;
	for(int i=a; i<c; i++){
		if(s.at(i)=='#'&&s.at(i+1)=='#') {
			cout << "No" << endl;
			return 0;
		}
	}
	for(int i=b; i<d; i++){
		if(s.at(i)=='#'&&s.at(i+1)=='#') {
			cout << "No" << endl;
			return 0;
		}
	}
	if(d<c){
		bool flg{};
		for(int i=b-1; i<d; i++){
			if(s.at(i)=='.'&&s.at(i+1)=='.'&&s.at(i+2)=='.') flg = 1;
		}
		if(!flg) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	
}



Measured memory_bytes: 640
#include<stdio.h>

int main(void){
    char str[9];
    scanf("%c%c%c\n",&str[0],&str[1],&str[2]);
    scanf("%c%c%c\n",&str[3],&str[4],&str[5]);
    scanf("%c%c%c",&str[6],&str[7],&str[8]);
    printf("%c%c%c",str[0],str[4],str[8]);
    return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////



ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}
#define N 200004
ll kai[N];
ll kai2[N];
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n==0)return 1;
    return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}

int main(){fastio
    calc();
    ll b,w;cin>>b>>w;
    ll sumb=0,sumw=0;
    rep(i,0,b+w-1){
        ll ans=(1+sumw-sumb)*bunbo(2);
        cout<<mod(ans)<<endl;
        //mod_print(ans);
        if(i==b+w)break;
        if(i==b+w-2){
            Add(sumb,comb(i,b-1)*bunbo(po(2,i+1)));
            Add(sumw,comb(i,b-1)*bunbo(po(2,i+1)));
        }else{
            if(i>=b-1){
                Add(sumb,comb(i,b-1)*bunbo(po(2,i+1)));
            }
            if(i>=w-1){
                Add(sumw,comb(i,w-1)*bunbo(po(2,i+1)));
            }
        }
        //cout<<"sumb";mod_print(sumb);
        //cout<<"sumw";mod_print(sumw);
    }
    
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=400;
const int mod=1e9+7;
int n,c;
int a[maxn+5],b[maxn+5],sum[maxn+5][maxn+5];
struct mat
{
	int a[maxn+5];
	mat(){memset(a,0,sizeof(a));}
}s[maxn+5],ans;
mat mul(mat a,mat b)
{
	mat res;
	for(int i=0;i<=c;i++)
	{
		for(int j=0;j<=c;j++)
		{
			if(i+j>c) continue;
			res.a[i+j]+=a.a[i]*b.a[j];
			res.a[i+j]%=mod;
		}
	}
	return res;
}
int qpow(int a,int b)
{
	int res=1%mod;
	for(;b;b>>=1,a=(a*a)%mod) if(b&1) res=(res*a)%mod;
	return res;
}
signed main()
{
	scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
	for(int i=1;i<=maxn;i++) for(int j=0;j<=maxn;j++) sum[i][j]=(sum[i-1][j]+qpow(i,j))%mod;
	for(int i=1;i<=n;i++)
	{
		for(int k=0;k<=c;k++)
		{
			s[i].a[k]=sum[b[i]][k]-sum[a[i]-1][k];
			if(s[i].a[k]<0) s[i].a[k]+=mod;
		}
	}
	ans.a[0]=1;
	for(int i=1;i<=n;i++) ans=mul(ans,s[i]);
	printf("%lld\n",ans.a[c]);
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,M;
int d[105][105];
int a[1010],b[1010],c[1010];
int main(){
	scanf("%d %d",&N,&M);
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i==j)d[i][j]=0;
			else d[i][j]=INF;
		}
	}
	for(int i=0;i<M;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
		a[i]--;
		b[i]--;
		d[a[i]][b[i]]=c[i];
		d[b[i]][a[i]]=c[i];
	}
	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(d[i][j]>d[i][k]+d[k][j]){
					d[i][j]=d[i][k]+d[k][j];
				}
			}
		}
	}
	/*for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			printf("%d ",d[i][j]);
		}
		cout << endl;
	}*/
	int ans = 0;
	for(int i=0;i<M;i++){
		int f = a[i], t = b[i];
		bool flag = false;
		for(int j=0;j<N;j++){
			if(abs(d[f][j]-d[t][j])==c[i]){
				flag = true;
				break;
			}
		}
		if(!flag)ans++;
	}
	printf("%d\n",ans);
 	return 0;
}

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

using namespace std;

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

typedef long long LL;

template<typename Type>
inline bool chkmin(Type &x , const Type &y) { return x > y ? (x = y , 1) : 0; }
template<typename Type>
inline bool chkmax(Type &x , const Type &y) { return x < y ? (x = y , 1) : 0; }

template<typename Type>
inline Type read(Type &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c))
        x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c))
        (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 4000 + 5 , KCZ = 924844033;

int n , k , S , vis[N];

LL Ans , f[N][N] , fac[N];

void add(LL &x , const LL &y) { x += y ; if(x >= KCZ) x -= KCZ; }
void sub(LL &x , const LL &y) { x -= y ; if(x < 0) x += KCZ; }

void init()
{
	fac[0] = 1;
	rep(i , 1 , 2000)
		fac[i] = fac[i - 1] * i % KCZ;
}

int main()
{
    read(n) , read(k) , init();
    rep(i , 1 , k)
    {
    	S += (n - i) / k + 1 , vis[S] = 1;
    	S += (n - i) / k + 1 , vis[S] = 1;
    }
    rep(i , 0 , S) f[i][0] = 1;
    rep(i , 2 , S) rep(j , 1 , n)
    {
    	add(f[i][j] , f[i - 1][j]);
    	if(!vis[i - 1]) add(f[i][j] , f[i - 2][j - 1]);
    }
    rep(i , 0 , n)
    {
    	LL v = f[S][i] * fac[n - i] % KCZ;
    	i & 1 ? sub(Ans , v) : add(Ans , v);
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 124672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<bool> flag(8, false);

  int judge[] = {0, 399, 799, 1199, 1599, 1999, 2399, 2799, 3199};

  int max = 0, min = 0, freecolor = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 9; j++) {
      if (judge[j] + 1 <= a[i] && a[i] <= judge[j + 1]) {
        flag[j] = true;
        break;
      }
      if (a[i] >= 3200) {
        freecolor++;
        break;
      }
    }
  }
  int cc = count(flag.begin(), flag.end(), true);

  max = count(flag.begin(), flag.end(), true) + freecolor;
  min = count(flag.begin(), flag.end(), true)
            ? count(flag.begin(), flag.end(), true)
            : 1;

  cout << min << " " << max << endl;
}

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

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}

int main()
{
  int n;
  int x[100];
  int ret;
  int i,j;
  int cost[100];
  int count;
  int min,max;
  int min_sum;
  
  ret=scanf("%d", &n);
  for (i=0;i<n;++i){
    ret=scanf("%d", &x[i]);
  }
  qsort(x,n,sizeof(int),cmp);
/*
  for(i=0;i<n;++i){
    printf("%d ", x[i]);
  }
*/
  min=x[0];
  max=x[n-1];

//  printf("min=%d max=%d\n", min, max);
  count=-1;
  for(i=min;i<=max;++i){
    ++count;
    cost[count]=0;
    for(j=0;j<n;++j){
      cost[count]+=(x[j]-i)*(x[j]-i);
    }
//    printf("cost[%d]=%d\n", count, cost[count]);
  }


  min_sum=cost[0];
  for(i=1;i<count;++i){
    if (cost[i] < min_sum){
      min_sum=cost[i];
    }
  }
  
  printf("%d\n", min_sum);

  return 0;
}


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

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("ati.txt", "r", stdin);
	freopen("ato.txt", "w", stdout);
#endif

	int n, k;
	cin >> n >> k;

	cout << min(n % k, k - n % k) << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
const long long inf=0x3f3f3f3f3f3f3f3f;
long long n;
long long amove[5];
long long t;
long long least=inf;
int main()
{
    cin>>n;
    for(int i=0;i<5;i++)	cin>>amove[i];
    for(int i=0;i<5;i++)
    {
    	if(amove[i]<least)	least=amove[i];
	}
    t=n/least+5;
   if(n%least==0) t--;
    cout<<t;
    return 0;
}

Measured memory_bytes: 256