akhauriyash/Code-Regression huggingface dataset:
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool is_valid(uint64_t val) {
  bool valid = true;
  string num = to_string(val);
  for (uint32_t i = 0; i < num.size() - 1; i++) {
    if (num[i + 1] - num[i] != 1) {
      valid = false;
    }
  }
  return valid;
}

int32_t main() {
  uint32_t N;
  cin >> N;

  vector<int64_t> arr;

  for (uint32_t i = 0; i < N; i++) {
    int64_t val;
    cin >> val;
    arr.push_back(val);
  }

  int64_t max_val = -1;
  for (uint32_t i = 0; i < N; i++) {
    for (uint32_t j = i + 1; j < N; j++) {
      if (is_valid(arr[i] * arr[j])) {
        max_val = max(max_val, arr[i] * arr[j]);
      }
    }
  }

  cout << max_val << endl;

  return 0;
}

Measured memory_bytes: 3292
import sys
input = sys.stdin.readline

s = input()[:-1]
ans = 10**18

for a in 'abcdefghijklmnopqrstuvwxyz':
    t = s
    cnt = 0
    
    while t!=a*len(t):
        nt = ''
        
        for i in range(len(t)-1):
            if t[i]==a or t[i+1]==a:
                nt += a
            else:
                nt += t[i]
        
        t = nt
        cnt += 1
    
    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 73448
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    rep(i, b-a) ans += i ;
    cout << ans - a << endl;


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  char c;
  cin >> c;
  if (c >= 'a' && c <= 'z')
    cout << 'a' << endl;
  else
    cout << 'A' << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3600
package main

import (
    "fmt"
)

func main() {
    cs := make([][]int, 3)
    for i := 0; i < 3; i++ {
        cs[i] = make([]int, 3)
        for j := 0; j < 3; j++ {
            fmt.Scan(&cs[i][j])
        }
    }
    var ng = false
    for i := 0; i < 2; i++ {
        d1 := cs[i+1][0] - cs[i][0]
        d2 := cs[i+1][1] - cs[i][1]
        d3 := cs[i+1][2] - cs[i][2]
        if d1 != d2 || d2 != d3 {
            ng = true
        }
        d1 = cs[0][i+1] - cs[0][i]
        d2 = cs[1][i+1] - cs[1][i]
        d3 = cs[2][i+1] - cs[2][i]
        if d1 != d2 || d2 != d3 {
            ng = true
        }
    }
    if ng {
        fmt.Println("No")
    } else {
        fmt.Println("Yes")
    }
}


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

int n;
int a[200000];

bool valid() {
  if (a[0] != 0) return false;
  for (int i = 1; i < n; ++i) {
    if (a[i] > a[i - 1] + 1) return false;
  }
  return true;
}

long cat() {
  long sum = 0;
  int prev = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (a[i] != prev - 1) {
      sum += a[i];
    }
    prev = a[i];
  }
  return sum;
}

long sub() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  
  if (!valid()) return -1;
  return cat();
}

int main() {
  cout << sub() << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(ALL(h));
  ll ans = 0;
  rep(i, n - k) ans += h[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    map<ll,ll> m;
    rep(i,n){
        m[-a[i]-i]++;
    }
    ll ans = 0;
    rep(i,n){
        ans+=m[a[i]-i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 27384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
ll power(ll a,ll b)
{ll result=1;
while(b>0)
{if(b%2==1)
 result*=a;
 a*=a;
 b/=2;
}
return result;
}
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll n,count=0;
cin>>n;
for(ll i=1;i<n;i++)
{ll temp=n/i;
 if(n%i==0)
 temp--;
 count+=temp;
}
cout<<count;
}


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

b_data = list(map(int,input().split()))
res = 0
for i in range(N):
  ans = sum([x*y for x, y in zip(b_data,list(map(int,input().split())))])
  if ans+C > 0:
    res += 1
print(res)

Measured memory_bytes: 3060
N = int(input())
A = [int(x) for x in input().split()]
count = [0]*(N+1)
for i in range(N):
    count[A[i]] += 1

s = sum([x*(x-1)/2 for x in count])

for k in range(N):
    print(int(s-count[A[k]]+1))

Measured memory_bytes: 24744
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int n;
    cin>>n;
    map<pair<int,int>,int> mp;
    int x[n],y[n];
    rep(i,n){
        int w;
        cin>>x[i]>>y[i]>>w;
        mp[{x[i],y[i]}]+=w;
    }
    int ans=0;
    rep(i,n){
        for(int j=-1;j<=1;j+=2)for(int k=-1;k<=1;k+=2){
            int ret=mp[{x[i],y[i]}]+mp[{x[i]+j,y[i]}]+mp[{x[i]+j,y[i]+k}]+mp[{x[i],y[i]+k}];
            ans=max(ans,ret);
        }
    }
    cout<<ans<<" / 1"<<endl;
    return 0;
}


Measured memory_bytes: 60116
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(){
	int K,N;
	scanf("%d %d",&K,&N);
	int A[N];
	for(int i=0; i<N; i++){
		scanf("%d",&A[i]);
	}
	
	int min = K;
	for(int i=0; i<N-1; i++){
		if(K - (A[i+1] - A[i]) < min){
			min = K - (A[i+1] - A[i]);
		}
	}
	if(min > A[N-1] -A[0]){
		min = A[N-1] -A[0];
	}

	printf("%d\n",min);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;

int n, m, s, t;
VVI g;
vector<set<int>> ng;

int dijkstra()
{
    deque<pair<int, int>> dq;
    VI done(n * 3, -3);
    dq.push_back({s, 0});
    done[s] = 0;
    while (!dq.empty()) {
        int cplace = dq.front().e1;
        int ctime = dq.front().e2;
        dq.pop_front();
        //cout<<cplace/3<<"_"<<cplace%3<<" "<<ctime/3<<"_"<<ctime%3<<endl;

        REPITR(itr, ng[cplace]) {
            if (done[*itr] == -3) {
                done[*itr] = ctime + 1;
                dq.push_back({*itr, ctime + 1});

                //if (*itr == t)
                    //break;
            }
        }
    }
    //REP(i, 3 * n) cout<<done[i]<<" "; nextline;

    return done[t] / 3;
}

int main()
{
    cin>>n>>m;
    g.resize(n); ng.resize(n * 3);
    REP(i,m) {
        int u, v;
        cin>>u>>v;
        g[u-1].push_back(v-1);
    }
    cin>>s>>t;
    s--; t--;
    s *= 3; t *= 3;

    //create new graph
    REP(i,n) {
        REPALL(j,g[i]) {
            ng[i * 3].insert(g[i][j] * 3 + 1);
            ng[i * 3 + 1].insert(g[i][j] * 3 + 2);
            ng[i * 3 + 2].insert(g[i][j] * 3);
        }
    }

    cout<<dijkstra()<<endl;

    return 0;
}


Measured memory_bytes: 34944
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,m; cin >> n >> m;
  map<int,int> mp;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    mp[a]++; mp[b]++;
  }
  for(auto c:mp){
    if(c.second%2==1){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif
struct UnionFind{
	vector<int> par,rank;
	V<ll> best,bsum;
	UnionFind(int N){
		par.assign(N,0);
		rank.assign(N,0);
		rep(i,N) par[i]=i;
	}
	int find(int x){
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]) swap(x,y);

		//x becomes root
		par[y]=x;
		if(rank[x]==rank[y]) rank[x]++;
	}
};
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N,M; cin >> N >> M;
	V<ll> A(N),B(N);
	rep(i,N) cin >> A[i] >> B[i];
	VV<int> G(N);
	rep(i,M){
		int x,y; cin >> x >> y; x--,y--;
		G[x].pb(y);G[y].pb(x);
	}
	V<int> idx(N); iota(all(idx),0);
	sort(all(idx),[&](int l,int r){return A[l]-B[l]<A[r]-B[r];});
	UnionFind UF(N);
	rep(i,N){
		UF.best.pb(max(A[i],B[i]));
		UF.bsum.pb(B[i]);
	}
	V<bool> done(N);
	for(int v: idx){
		V<int> cs;
		for(int u: G[v]) if(done[u]){
			cs.pb(UF.find(u));
		}
		mkuni(cs);
		ll bsum = 0;
		for(int c: cs){
			bsum += UF.bsum[c];
		}
		ll res = max(A[v],B[v]) + bsum;
		for(int c: cs){
			ll tmp = max(UF.best[c]+B[v],A[v]) + bsum - UF.bsum[c];
			chmin(res,tmp);
		}
		for(int u: G[v]) if(done[u]){
			UF.unite(v,u);
		}
		int r = UF.find(v);
		UF.best[r] = res;
		UF.bsum[r] = B[v] + bsum;
		done[v] = true;
	}
	cout << UF.best[UF.find(0)] << endl;
}


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

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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;

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

int main() {
  int N,M,X;
  cin>>N>>M>>X;
  vector<vector<int>> book(N,vector<int>(M+1));
  rep(i,N){
    rep(j,M+1){
      cin>>book[i][j];
    }
  }
  bool can = false;
  int ans = INF;
  for(int i = 0; i < (1<<N);i++){
    bool over = true;
    vector<int> skill(M,0);
    int money=0;
    rep(j,N){
      if(i&(1<<j)){
        money+=book[j][0];
        rep(k,M) skill[k]+=book[j][k+1];
      }
    }
    rep(j,M){
      if(skill[j]<X) over=false;
    }
    if(over){
      can=true;
      chmin(ans,money);
    }
  }
  if(!can) cout<<-1<<endl;
  if(can) cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,k;
  string s;
  cin >> n >> k >> s;
  s[k-1] = s[k-1] + 32;
  pri(s);

  return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> b(n);
  rep(i, n) cin >> b[i];
  vector<ll> c(n-1);
  rep(i, n-1) cin >> c[i];

  rep(i, n) a[i]--;


  ll sum = 0;
  rep(i, n) sum += b[a[i]];
  rep(i, n-1){
    if(a[i+1] - a[i] == 1) sum += c[a[i]];
  }
  
  cout << sum << endl;



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <array>
#include <limits>
#include <memory>
#include <numeric>
#include <functional>
#include <cstdlib>

using namespace std;

int N;
int K;
list<int> DS;


int calc() {

  set<int> availables {0,1,2,3,4,5,6,7,8,9};
  for (auto d : DS) {
    availables.erase(d);
  }

  vector<int> ns;
  int n = N;
  while (0 < n) {
    ns.push_back(n % 10);
    n /= 10;
  }
  reverse(ns.begin(), ns.end());

  int candidate = 0;
  int smallest = *availables.cbegin();

  if (smallest == 0) {
    auto second = ++(availables.cbegin());
    candidate = *second;
  }
  else {
    candidate = smallest;
  }

  for (uint i=0; i<ns.size(); ++i) {
    candidate = candidate * 10 + smallest;
  }


  int halfway = 0;
  for (uint i=0; i<ns.size(); ++i) {

    auto it = availables.lower_bound(ns[i]);

    if (it == availables.end())
      return candidate;

    if (ns[i] < *it) {

      halfway = halfway * 10 + *it;
      for (uint j=i+1; j<ns.size(); ++j)
        halfway = halfway * 10 + smallest;

      return halfway;
    }

    if (++it != availables.end()) {
      candidate = halfway * 10 + *it;
      for (uint j=i+1; j<ns.size(); ++j)
        candidate = candidate * 10 + smallest;
    }

    halfway = halfway * 10 + ns[i];
  }

  return halfway;
}

int main() {

  cin >> N >> K;
  for (int i=0; i<K; ++i) {
    int d;
    cin >> d;
    DS.push_back(d);
  }

  cout << calc() << endl;

  return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

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

#include <bits/stdc++.h>
using namespace std;

template<typename T>
void cmpmax(T& reference, T value) {
	reference = max(reference, value);
}

template<typename T>
void cmpmin(T& reference, T value) {
	reference = min(reference, value);
}

const ll mod = 1000000007;

static const ll INF = 1e15;

int main() {
	int n, k;
	cin >> n >> k;
	vector<ll> vs(n);
	rep(i, n) cin >> vs[i];
	//dp[i][j]...i人まででj個を分け合う場合の数
	//dp[i][j] = dp[i-1][j-vs[i]] + dp[i-1][j-vs[i]+1] + ... + dp[i-1][j]
	//累積和
	//mdp[i][j] = dp[i][0] + dp[i][1] +... + dp[i][j]
	//dp[i][j] = mdp[i-1][j] - mdp[i-1][j-vs[i]-1] 
	vector<vector<ll>> dp(n, vector<ll>(k + 1, 0));
	vector<vector<ll>> mdp(n, vector<ll>(k + 1, 0));
	for (int i = 0; i <= vs[0]; i++) {
		dp[0][i] = 1;
	}
	mdp[0][0] = 1;
	for (int i = 1; i <= k; i++) {
		mdp[0][i] = dp[0][i] + mdp[0][i-1];
	}
	for (int i = 1; i < n; i++) {
		mdp[i][0] = dp[i][0] = mdp[i - 1][0];
		for (int j = 1; j <= k; j++) {
			int right = j - vs[i] - 1;
			dp[i][j] = mdp[i - 1][j];
			if (right >= 0) {
				dp[i][j] += mod - mdp[i - 1][right];
			}
			dp[i][j] %= mod;
			mdp[i][j] = mdp[i][j - 1] + dp[i][j];
			mdp[i][j] %= mod;
		}
	}
	cout << dp[n-1][k] << endl;
	return 0;
}



Measured memory_bytes: 157552
import java.util.Scanner;

public class Main {


    public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int hei, wid, cnt_wid;

		while(true){
			hei = scan.nextInt();//??????????????????
			wid = scan.nextInt();//?¨????????????????
			if(hei == 0 && wid == 0){//???????????????0???0????????\???????????????????????????
				break;
			}
			for(cnt_wid = 0; cnt_wid < wid; cnt_wid++){//????????????????????????
				System.out.print("#");
			}
			System.out.println();
			for(int cnt_hei = 0; cnt_hei < hei - 2; cnt_hei++){//???????????¨???????????\??????????????????¨???????????????????
				System.out.print("#");//???????????????
				for(cnt_wid = 0; cnt_wid < wid - 2; cnt_wid++){//?¨????-?????????????????????
					System.out.print(".");
				}
				System.out.print("#");//???????????????
				System.out.println();
			}
			for(cnt_wid = 0; cnt_wid < wid; cnt_wid++){//????????????????????????
				System.out.print("#");
			}
			System.out.println("\n");
		}
        scan.close();
    }
}

Measured memory_bytes: 34180
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int tab[n];
    long long mini[n];
    for(int i =0; i < n; i++){
        cin >> tab[i];

    }
    mini[0] = 0;
    mini[1] = abs(tab[1]-tab[0]);
    for(int i = 2; i < n; i++){
        mini[i] = min(mini[i-1]+abs(tab[i]-tab[i-1]),mini[i-2]+abs(tab[i]-tab[i-2]));
    }

    cout << mini[n-1];
    return 0;
}



Measured memory_bytes: 1408
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if ( T[u].p == NIL ) cout << "root, ";
  else if ( T[u].l == NIL ) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for (  i = 0, c = T[u].l; c != NIL; i++, c = T[c].r ) {
    if ( i ) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

// 再帰的に深さを求める
void rec(int u, int p) {
  D[u] = p;
  if ( T[u].r != NIL ) rec(T[u].r, p);  // 右の兄弟に同じ深さを設定
  if ( T[u].l != NIL ) rec(T[u].l, p + 1);  // 最も左の子に自分の深さ+1を設定
}

int main() {
  int i, j, d, v, c, l, r;
  cin >> n;
  for ( i = 0; i < n; i++ ) T[i].p = T[i].l = T[i].r = NIL;

  for ( i = 0; i < n; i++ ) {
    cin >> v >> d;
    for ( j = 0; j < d; j++ ) {
      cin >> c;
      if ( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for ( i = 0; i < n; i++ )
    if ( T[i].p == NIL ) r = i;

  rec(r, 0);

  for ( i = 0; i < n; i++ ) print(i);

  return 0;
}


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

using namespace std;

int main()
{
	int a; 
	int i,j,k;
	int b[8]={1,2,4,8,16,32,64,128};
	
	cin>>a;
	
	for(i=0;i<=7;i++)
	{
		if(b[i]>a)
		{
			cout<<b[i-1];
			break;
		}
	}
	
}

Measured memory_bytes: 256
import sys,math
from collections import deque,defaultdict
import operator as op
from functools import reduce

sys.setrecursionlimit(10**6) 

I=sys.stdin.readline

 #s="abcdefghijklmnopqrstuvwxyz"

"""
x_move=[-1,0,1,0,-1,1,1,-1]
y_move=[0,1,0,-1,1,1,-1,-1]
"""
def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))
def mi():
	return map(int,I().strip().split())

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x




	
def main():
	n=ii()
	arr=sorted(li())
	ss=[arr[-1]]
	for i in range(n-2,-1,-1):
		ss.append(ss[-1]+arr[i])
	ss.reverse()
	ans=0
	for i in range(n-1):
		ans+=arr[i]*ss[i+1]
	print(ans%(10**9+7))
			


	

























	
	
	





if __name__ == '__main__':
	main()

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

int main(){
  ll N, C, K; cin>>N>>C>>K;
  vector<ll> T(N);
  for(ll i=0; i<N; i++) cin>>T[i];
  sort(T.begin(), T.end());
  ll t=T[0]+K;
  ll b=1;
  ll ans=0;
  for(ll i=1; i<N; i++){
    if(T[i]>t || b==C){
      ans++;
      b=1;
      t=T[i]+K;
      continue;
    }
    b++;
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  string s;
  char bf ;
  int ans = 0;

  cin >> s;

  for(int i = 0; i < s.size(); i++){
    if(i > 0){

      if(s[i] == bf){
        ans++;
        //cout << "ans++; i = " << i << endl;
        if(bf == '0'){
          bf = '1';
        }else{
          bf = '0';
        }

      }else{
        bf = s[i];
      }

    }else{
      bf = s[i];
    }
    
    //cout << " i = " << i  << ", bf = " << bf << endl;
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
char itoa(int n) { return n + '0';}
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 n = in();
  vi cnt(n+1);
  rep(i,n-1) {
    cnt[in()]++;
  }
  rrep(i,n) {
    printf("%d\n", cnt[i]);
  }
  return 0;
}

Measured memory_bytes: 4072
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let h = input
        .split("\n")
        .nth(0)
        .unwrap()
        .split_whitespace()
        .nth(1)
        .unwrap()
        .parse::<i64>()
        .unwrap();

    let list = input
        .split("\n")
        .skip(1)
        .map(|x| {
            let vec = x.split_whitespace().collect::<Vec<_>>();
            (
                vec[0].parse::<i64>().unwrap(),
                vec[1].parse::<i64>().unwrap(),
            )
        })
        .collect::<Vec<_>>();

    let max = list.clone().iter().map(|&(x, _)| x).max().unwrap();

    let (sum, len) = {
        let mut l2 = list.clone()
            .iter()
            .map(|&(_, x)| x)
            .filter(|&x| x > max)
            .collect::<Vec<_>>();
        let only = l2.iter().sum::<i64>();
        if only >= h {
            l2.sort();
            l2.reverse();
            let mut s = 0;
            for (i, &x) in l2.iter().enumerate() {
                s += x;
                if s >= h {
                    return (i + 1).to_string();
                }
            }
            return "".to_string();
        } else {
            //投げのみで与えられるダメージ
            (only, l2.len())
        }
    };

    //残り
    let diff = h - sum;

    //攻撃回数
    let c = ((diff as f64) / (max as f64)).ceil() as usize;

    (len + c).to_string()
}

#[test]
fn test() {
    let tests = vec![
        ("1 10\n3 5", "3"),
        ("2 10\n3 5\n2 6", "2"),
        (
            "4 1000000000\n1 1\n1 10000000\n1 30000000\n1 99999999",
            "860000004",
        ),
        ("5 500\n5 44\n28 83\n46 62\n31 79\n40 43", "9"),
    ];
    for (i, (input, output)) in tests.into_iter().enumerate() {
        println!("test:{}", i);
        assert_eq!(run(input.to_string()), output.to_string());
    }
}


Measured memory_bytes: 17432
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long A,B,V,W,T;
    cin >> A >> V >> B >> W >> T;
    if(W >= V) cout << "NO" << endl;
    else if(A < B){
        if(B + W*T > A + V*T) cout << "NO" << endl;
        else cout << "YES" << endl;
    } 
    else{
        if(B - W*T < A - V*T) cout << "NO" << endl;
        else cout << "YES" << endl;
    }
}


Measured memory_bytes: 3608
X = int(input())

if X >= 400 and X <= 599:
    print('8')
elif X >= 600 and X <= 799:
    print('7')
elif X >= 800 and X <= 999:
    print('6')
elif X >= 1000 and X <= 1199:
    print('5')
elif X >= 1200 and X <= 1399:
    print('4')
elif X >= 1400 and X <= 1599:
    print('3')
elif X >= 1600 and X <= 1799:
    print('2')
elif X >= 1800 and X <= 1999:
    print('1')

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

int main(){
  int N, D, X;
  cin >> N >> D >> X;

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

  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    int b=1;
    int c=1;
    while (b<=D) {
      B.at(i)++;
      b=A.at(i)*c+1;
      c++;
    }
  }
  cout << X+accumulate(B.begin(),B.end(),0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
const int inf = 10e9 + 7;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,m,n) for(int i=m;i<n;i++)
#define endre getchar(); getchar();return 0;
bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p%i == 0) return false;
	}
	return true;
}
signed main() {
	int n,i=0,sum=11;
	cin >> n;
	while (i < n) {
		if (isprime(sum)) {
			i++;
			cout << sum << ' ';
		}
		sum += 10;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{

	long a, b, c, d, tmp;
	while (scanf("%ld %ld", &a, &b) != EOF) {
    		d = a * b;
		if(a < b) {
			tmp = a;
			a = b;
			b = tmp;
		}

	c = a % b;
	while(c != 0) {
		a = b;
		b = c;
		c = a % b;
	}

	printf("%ld %ld\n", b, d / b);
	}
   
       return 0;
}


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

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    double d,t,s,x;
    cin >> d >> t >> s;
    if(d/s <= t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a[10];
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    if(a[1]&1&&a[2]&1&&a[3]&1)cout<<a[1]*a[2];
    else cout<<0;
}

Measured memory_bytes: 256
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
    fre("");
    ACCELERATE;
    
    int a, b;
    cin >> a >> b;
    if(a > 9 || b > 9) return cout << -1, 0;
    cout << a * b;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=1e5+10;

int N;
vector<int> G[MAX_N];

int dfs(int v,int p){
    int res=0,zero=0;
    for (int u:G[v]){
        if (u==p) continue;
        int ch=dfs(u,v);
        res+=ch;
        if (!ch) ++zero;
    }
    res+=max(0,zero-1);
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i=0;i<N-1;++i){
        int a,b; cin >> a >> b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    for (int i=0;i<N;++i) if (2<G[i].size()){
        cout << dfs(i,-1) << '\n';
        return 0;
    }
    cout << 1 << '\n';
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, x[109];
int main() {
	cin >> n >> a >> b >> c;
	for(int i = 0; i < n; i++) cin >> x[i];
	sort(x, x + n, greater<int>());
	int ret = 0, sum = 0;
	for(int i = 1; i <= n; i++) {
		sum += x[i - 1];
		ret = max(ret, (c + sum) / (a + i * b));
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3176
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */
 
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <unordered_map>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
#define out(x) cout<<x<<'\n';
inline char gc(){char op[2];scanf("%s",op);return op[0];}
const int N =5e5+10;
const double eps = 0.00000001;
const ll mod = 1e9 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
    string s;
    cin >> s;
    if(s.find('7')!=string::npos) puts("Yes");
    else puts("No");
}

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

using namespace std;

#define N 300005
#define int long long


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    cin>>s;

    if(s[0]== s[s.length()-1])
    {
        int x = s.length();
        if( x%2==0)
        {
            cout<<"First"<<endl;
        }
        else
        {
            cout<<"Second"<<endl;
        }
    }
    else 
    {
        int x = s.length();
        if( x%2==0)
        {
            cout<<"Second"<<endl;
        }
        else
        {
            cout<<"First"<<endl;
        }
    }


    return 0;
}


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

vector<pair<int, int> > g[123450];
bool visit[123450];
int  dist[123450];
bool ok = true;

void dfs(int node)
{
    if (ok == false)
        return;
    if (visit[node])
        return;

    visit[node] = true;

    for (auto i: g[node]) {
        if (!visit[i.first]) {
            dist[i.first] = dist[node] + i.second;
            dfs(i.first);
        }
        else{
            if(dist[i.first] != dist[node] + i.second)
                ok = false;
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;


    int l, r, d;
    for (int i = 0; i < m; i++) {
        cin >> l >> r >> d;
        g[l].push_back(make_pair(r, d));
        g[r].push_back(make_pair(l, -1*d));
    }

    for (int i = 1; i<= n; i++) {
        if (!visit[i]) {
            dfs(i);
        }
    }
   
    if (ok)
        cout << "Yes\n";
    else
        cout << "No\n";



}


Measured memory_bytes: 11776
#include<stdio.h>
int main(){
  int a=0,i;
  char s[4];
  char t[4];
  scanf("%s", s);
  scanf("%s", t);
  for(i=0; i<3; i++){
  if(s[i]==t[i]){
    a++;
  }
  }
  printf("%d\n", a);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n; cin >> n;
  rep(i,n) {
    ll a; cin >> a;
    if(a%2) continue;
    if(a%3 == 0 || a%5 == 0) continue;
    cout << "DENIED\n";
    return;
  }
  cout << "APPROVED\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

using ll=long long;
using ld=long double;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int x,y;
	cin>>x>>y;
	int a=(y-(2*x))/2;
	int b=((4*x)-y)/2;
	//cout<<a<<" "<<b;
	if(y>=(2*x) && (4*x)>=y && ((a+b)==x) && ((4*a)+(2*b)==y)){
		cout<<"Yes"<<"\n";
	}else{
		cout<<"No"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3612
#094_D
n = int(input())
a = sorted(list(map(int, input().split())))
m = a[-1]
mid = m / 2
l = 10 ** 10
for i in range(n-1):
    if abs(a[i] - mid) < abs(l - mid):
        l = a[i]
print(m, l)

Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; a < b; i++);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " -> " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" ->";rep(i,v.size())cerr<<" "<<v[i];cerr << endl
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 = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

struct Paren {
    int idx;
    int r;
    int l;
};


void solve() {
    int n;
    cin >> n;
    vector<Paren> X(n);
    vector<string> S(n);
    rep(i, n) {
        int r = 0, l = 0;
        string s;
        cin >> s;
        rep(j, s.size()) {
            if (s[j] == '(') r++;
            else r--;
            if (r < 0) {
                l++;
                r = 0;
            }
        }
        S[i] = s;
        X[i] = {i, r, l};
    }
    auto compare = [&] (Paren a, Paren b) {
        if (a.r - a.l >= 0 && b.r - b.l < 0) return true;
        else if (a.r - a.l >= 0 && b.r - b.l >= 0) return a.l < b.l;
        else if (a.r - a.l < 0 && b.r - b.l < 0) return a.r > b.r;
        else return false;
    };
    sort(all(X), compare);
    string s = "";
    for(auto &x : X) {
        int i = x.idx;
        s += S[i];
    }
    int r = 0;
    rep(i, s.size()) {
        if (s[i] == '(') r++;
        else r--;
        if (r < 0) {
            cout << "No" << endl;
            return;
        }
    }
    if (r == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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



Measured memory_bytes: 48284
#include <iostream>
#include <vector>
#include <string.h>
#include <stdio.h>
#include <cstring>
#include <cmath>
using namespace std;
#define rep(i, b) for( int i = 0; i < b; i++ )
int n, m, p;
/*int dx[17] = {-1,0,1, -1,1, -1,0,1,
              -1,0,1, -1,0,1, -1,0,1};
int dy[17] = {-1,-1,-1, 0,0, 1,1,1,
              -1,-1,-1, 0,0,0, 1,1,1};
int dz[17] = {0,0,0, 0,0, 0,0,0,
              1,1,1, 1,1,1, 1,1,1};*/
int dx[13] = {-1,0,1,1, -1,0,1,1, -1,0,1,1, 0};
int dy[13] = {1,1,1,0, 1,1,1,0, 1,1,1,0, 0};
int dz[13] = {-1,-1,-1,-1, 0,0,0,0, 1,1,1,1, 1};

string t[7][7][7];
int exist[7][7];
string c;

int search( int x, int y, int z, int d ){
    //bool res = false;
    //if( x >= n || y >= n || z >= exist[x][y] ) return 0;
    if( 0 <= x && x < n && 0 <= y && y < n && 0 <= z && z < exist[x][y] && t[x][y][z] == c ){
        //if( cnt == m ) return true;
        int nx = x + dx[d];
        int ny = y + dy[d];
        int nz = z + dz[d];
        //res = search(nx,ny,nz,cnt+1);
        //cout << x << ' ' << y << ' ' << z << endl;
        return search(nx,ny,nz,d)+1;
    }
    return 0;
}
int search2( int x, int y, int z, int d ){
    //bool res = false;
    //if( x >= n || y >= n || z >= exist[x][y] ) return 0;
    if( 0 <= x && x < n && 0 <= y && y < n && 0 <= z && z < exist[x][y] && t[x][y][z] == c ){
        //if( cnt == m ) return true;
        int nx = x - dx[d];
        int ny = y - dy[d];
        int nz = z - dz[d];
        //res = search(nx,ny,nz,cnt+1);
        return search2(nx,ny,nz,d)+1;
    }
    return 0;
}

int main(){
    while( cin >> n >> m >> p, n ){
        string ans = "Draw";
        int ans_t;
        memset( exist, 0, sizeof(exist) );
        /*rep(i, n){
            rep(j, n){
                cout << exist[i][j] << '\t';
            }
            cout << endl;
        }*/
        rep(a, p){
            int x, y, z;
            cin >> x >> y;
            z = ++exist[x-1][y-1];
            //cout << z << endl;
            if(a%2 == 0 ) t[x-1][y-1][z-1] = c = "Black";
            else t[x-1][y-1][z-1] = c = "White";
            if( ans == "Draw" ){
                /*rep(i, n) rep(j, n) rep(k, exist[i][j]) rep(l, 7){
                    d = l;
                    if( search(i,j,k,1) ){
                        ans = c;
                        ans_t = a+1;
                    }
                }*/
                rep(i, 13){
                    int cnt = search(x-1,y-1,z-1,i);
                    cnt += search2(x-1,y-1,z-1,i)-1;
                    //cout << i << ' ' << cnt << endl;
                    if( cnt >= m ){
                        ans = c;
                        ans_t = a+1;
                    }
                }
            }
        }
        /*rep(i, n){
            rep(j, n){
                cout << t[i][j][0] << '\t';
                //cout << "(" << i << "," << j << ")" << ": ";
            }
            cout << endl;
        }*/
        //cout << 'c';
        if( ans == "Draw" ){
            cout << ans << endl;
        }else{
            cout << ans << ' ' << ans_t << endl;
        }
    }
    return 0;
}

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

int main(){
	int a,b,c;
  
  	cin >> a >> b;
  	
  	c = a * b % 2;
  
  	if(c == 0){
    	cout << "Even" << endl;
    }else{
    	cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main () {
  int n, k;
  cin >> n >> k;
  vector <int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int L = 1;
  int R = 1e9;
  while (L != R) {
  	int M = (L + R) / 2;
  	ll cnt = 0;
  	for (int i = 0; i < n; i++)
  	  cnt += (a[i] + M - 1) / M - 1;
  	if (cnt > k) L = M + 1;
  	else R = M;
  	}
  cout << L;
  return 0;
}

Measured memory_bytes: 4040