akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1 and a[0]!=0:
    print(0)
else:
    if n%2==1 and a[0]==0:
        a.pop(0)
    d=(0 if n%2==1 else 1)
    for i in range(n//2):
        if a[2*i]!=2*(i+1)-d or a[2*i+1]!=2*(i+1)-d:
            print(0)
            break
    else:
        print(2**(n//2)%(10**9+7))

Measured memory_bytes: 14008
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

void solve() {
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll cnt = x / d;
	if (cnt >= k)
		cout << x - k * d;
	else {
		ll x1 = x - cnt * d;
		k -= cnt;
		if (k % 2)
			cout << abs(x1 - d);
		else
			cout << x1;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << endl;
	}
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  int TYPE[4] = {10,50,100,500};
  vector<int> vec;
  int firstFlag = 0;
  while(true){
    cin >> n;
    if(n == 0)break;
    if(firstFlag == 0){
      firstFlag = 1;
    }else{
      cout << endl;
    }
    vec = vector<int>(4,0);
    for(int i = 0;i < 4;i++){
      cin >> vec[i];
    }
    int ans = 0;
    int flag = -1;
    for(int i = 0;i < 4;i++){
      ans = ans + TYPE[i]*vec[i];
    }
    int otu = ans-n;
    int oturi[4];
    for(int i = 3;i >= 0;i--){
      int keep = otu%TYPE[i];
      oturi[i] = otu/TYPE[i];
      otu = keep;
    }
    for(int i = 0;i < 4;i++){
      if(oturi[i] < vec[i]){
	cout <<TYPE[i] << " " << vec[i] - oturi[i] << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1212
X,Y,A,B,C = [int(x) for x in input().split()]
R = sorted([int(x) for x in input().split()],reverse = True)[:X]
G = sorted([int(x) for x in input().split()],reverse = True)[:Y]
CL = sorted([int(x) for x in input().split()],reverse = True)[:X+Y]
total = sorted(R+G+CL, reverse=True)[:X+Y]
print(sum(total))

Measured memory_bytes: 22432
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

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

int main() {
    int r;
    cin >> r;
    cout << r * r << endl;
}


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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> h) {
  vector<ll> dp(N);
  dp.at(0) = 0;
  rep(i, N - 1) {
    ll a = abs(h.at(i + 1) - h.at(i)) + dp.at(i);
    ll b = i == 0 ? LINF : abs(h.at(i + 1) - h.at(i - 1)) + dp.at(i - 1);

    dp.at(i + 1) = min(a, b);
  }

  cout << dp.at(N - 1) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> h(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &h[i]);
  }
  solve(N, std::move(h));
  return 0;
}


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

int main ()
{
	string s,fro,lat;
	fro="",lat="";
	
	int t;
	int flag,pos;
	char c;
	int cnt=0; 
	cin>>s;
	cin>>t;
	while(t--){
		cin>>flag;
		if(flag==1)
			cnt++;
		else {
			cin>>pos>>c;
			if(pos==1)
				if(cnt&1)
					lat+=c;
				else 
					fro+=c;
			else
				if(cnt&1)
					fro+=c;
				else 
					lat+=c;
		}
	}
	
	
	if(cnt&1){
		reverse(lat.begin(),lat.end());
		reverse(s.begin(),s.end());
		cout<<lat<<s<<fro<<endl;
	}
	
	else{
		reverse(fro.begin(),fro.end());
		cout<<fro<<s<<lat<<endl;
	} 
		
	return 0;	
 } 

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

using namespace std;

int n,D;
int sq[1000010];
vector<int> vec[30];

int main(){
	int ans=0;
	scanf("%d%d",&n,&D);
	for(int i=0;i<=1000;i++)
		sq[i*i]=1;
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=D;j++){
			int x;
			scanf("%d",&x);
			vec[i].push_back(x);
		}
		for(int j=1;j<i;j++){
			int temp=0;
			for(int k=1;k<=D;k++){
				temp+=(vec[i][k-1]-vec[j][k-1])*(vec[i][k-1]-vec[j][k-1]);
			}
			if(sq[temp])ans++;
		}
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0; i<=(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){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; }

bool isprime(long long int val) {
 if (val <= 1)return false;
 for (long long int i = 2; i*i <= val; i++) {
   if (val%i == 0LL)return false;
 }
 return true;//素数
}

int main() {
  vector<ll> cnt(10000001,1);
  ll n;
  cin >> n;
  for (ll i = 2; i <= n; i++) {
    for (ll j = i; j <= n; j+=i){
      cnt[j]++;
    }
  }
  ll ans = 0;
  for (ll i = 0; i <= n; i++) ans += i * cnt[i];

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

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

typedef priority_queue<int> maxHeap;
typedef priority_queue<int, vector<int>, greater<int>> minHeap;
#define endl "\n"
#define int long long
#define MOD 1000000007
#define ump unordered_map
#define pb push_back
#define mp make_pair
#define pie acos(-1)
#define max(x, y) ((x > y) ? x : y)
#define min(x, y) ((x < y) ? x : y)
#define mid(s, e) ((s + (e - s) / 2))

bool test_cases;

struct precompute {
    void compute() {
    }
};

void init(bool k) {
    test_cases = k;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

struct test_cases {
    void test_case(int test) {
        string s;
        cin >> s;
        int i = 0;
        int cnt = 0;
        int mx = 0;
        while (i != s.length()) {
            if (s[i] == 'R')
                cnt++;
            else {
                mx = max(mx, cnt);
                cnt = 0;
            }
            i++;
        }
        if (s[s.length() - 1] == 'R') mx = max(cnt, mx);
        cout << mx << endl;
    }
};

int32_t main() {
    init(false);
    int tc;
    if (test_cases) {
        cin >> tc;
    } else {
        tc = 1;
    }
    struct precompute l;
    l.compute();
    for (int i = 0; i < tc; i++) {
        struct test_cases o;
        o.test_case(i + 1);
    }
    return 0;
};

Measured memory_bytes: 3560
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y

x = ini()
if x%1000 == 0:
        print(0)
else:   
        print(1000-(x%1000))


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

using namespace std;

const int N = 100000 + 77;
int n , k , a[N] , dp[N];
int main(){
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n >> k;
   for(int i = 1;i <= n;++ i)
      cin >> a[i];
   for(int i = 2;i <= n;++ i){
      int Mn = 2e9;
      dp[i] = Mn;
      for(int j = max(i - k , 1) ;j < i;++ j)
         dp[i] = min(dp[i] , dp[j] + abs(a[i] - a[j]));
   }


   cout << dp[n];
   return 0;
}


Measured memory_bytes: 1024
// atcoder/abc045/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string a, b, c;
  while (cin >> a >> b >> c) {
    string s[3];
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    reverse(c.begin(), c.end());
    s[0] = a;
    s[1] = b;
    s[2] = c;
    int idx = 0;
    while (s[idx].size()) {
      char c = s[idx].back();
      s[idx].pop_back();
      idx = c - 'a';
    }
    cout << (char)('A' + idx) << endl;
  }

  return 0;
}


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

using namespace std;

int n,k;

int gcd(int a, int b) {
  return a % b == 0 ? b : gcd(b,a % b);
}

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

  int d = 0;
  int m = 0;

  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    d = gcd(d,a);
    m = max(m,a);
  }

  if(k % d == 0 && m >= k) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}


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

int main(){
  
 
  int n,m;
  cin>>n;
  m=n%10;
  if(m == 2 || m== 4|| m== 5 || m== 7 || m==9 )
    cout<<"hon";
  else if( m==0 || m==1|| m==6|| m==8)
    cout<<"pon";
  else
    cout<<"bon";

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
typedef long long ll;
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 NMAX = 100010;
vector<ll> dp(NMAX, LLONG_MAX);
vector<ll> coins;

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

    coins.push_back(1);
    for (int i = 1; pow(6, i)<=N; i++){
        coins.push_back(pow(6,i));
    }
    for (int i = 1; pow(9, i)<=N; i++){
        coins.push_back(pow(9,i));
    }

    dp[0] = 0;

    for(int i=0; i<=N; i++){
        for(auto x: coins){
            if(i>=x){
                chmin(dp[i], dp[i-x]+1);
            }
        }
    }
    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 1152
// abc060_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int a,b,c;
  cin>>a>>b>>c;

  for(int i=1;i<=a*b;++i){
    if (a*i%b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

using namespace std;

struct Posx2 {
    int sy;
    int sx;
    int ey;
    int ex;

    Posx2(int sy, int sx, int ey, int ex) 
        : sy(sy)
        , sx(sx)
        , ey(ey)
        , ex(ex){}
};

bool should_move(vector<vector<int>> &board, Posx2 &p) {
    return board[p.sy][p.sx] % 2 == 1;
}

int main(){
    int h, w;
    cin >> h >> w;

    vector<vector<int>> vs(h);
    for (auto &v : vs) {
        v.resize(w);
    }

    for (auto &v : vs) {
        for (auto &vv : v) {
            cin >> vv;
        }
    }
    vector<Posx2> moves;

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w - 1; x++) {
            Posx2 p(y, x, y, x + 1);
            if (should_move(vs, p)) {
                moves.push_back(p);
                vs[p.sy][p.sx]--;
                vs[p.ey][p.ex]++;
            }
        }
        if (y + 1 < h){
            Posx2 p(y, w - 1, y + 1, w - 1);
            if (should_move(vs, p)) {
                moves.push_back(p);
                vs[p.sy][p.sx]--;
                vs[p.ey][p.ex]++;
            }
        }
        y++;

        if (y < h) {
            for (int x = w - 1; x > 0; x--) {
                Posx2 p(y, x, y, x - 1);
                if (should_move(vs, p)) {
                    moves.push_back(p);
                    vs[p.sy][p.sx]--;
                    vs[p.ey][p.ex]++;
                }
            }
        }
        if (y + 1 < h){
            Posx2 p(y, 0, y + 1, 0);
            if (should_move(vs, p)) {
                moves.push_back(p);
                vs[p.sy][p.sx]--;
                vs[p.ey][p.ex]++;
            }
        }
    }

    cout << moves.size() << endl;
    for (auto &p : moves) {
        p.sy++;
        p.ey++;
        p.sx++;
        p.ex++;
        cout << p.sy << " " << p.sx << " " << p.ey << " " << p.ex << endl;
    }

}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
long long frek[200003];
int main()
{
    long long i,n,x,ans=-1;
    cin>>n;
    for(i=0;i<n;++i)
    {
        cin>>x;
        frek[x-1]++;
        frek[x]++;
        frek[x+1]++;
        ans=max(ans,frek[x]);
         ans=max(ans,frek[x+1]);
          ans=max(ans,frek[x-1]);
    }
    cout<<ans<<endl;
}


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

int X[3];

int main() {
  scanf("%d%d%d", &X[0], &X[1], &X[2]);
  sort(X, X+3);

  int count = X[2] - X[1];
  X[0] += count;
  int div = (X[2] - X[0]) / 2;
  if (X[2] == X[0] + 2 * div) printf("%d\n", count + div);
  else printf("%d\n", count + div + 2);

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N,Q;
int par[10000];
int rank[10000];
int find(int x){
  if(par[x]==x)return x;
  else 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])par[x]=y;
  else {
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}

int main(){
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    rank[i]=0;
    par[i]=i;
  }
  scanf("%d",&Q);
  for(int i=0;i<Q;i++){
    int com,x,y;
    scanf("%d %d %d",&com,&x,&y);
    if(com==0)unite(x,y);
    else {
      if(same(x,y))puts("1");
      else puts("0");
    }
  }
  return 0;
}

Measured memory_bytes: 3236
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n;
int main() {
	while (cin >> n, n) {
		string s[55], t[55];
		REP(i, n) {
			cin >> s[i];
			t[i] = s[i][0];
			for (int j = 1; j < s[i].size(); j++) {
				char c = s[i][j - 1];
				if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')t[i] += s[i][j];
			}
		}
		int k;
		for (k = 1; k < 51; k++) {
			set<string> st;
			bool isok = 1;
			for (int i = 0; i < n; i++) {
				string r = t[i].substr(0, min((int)t[i].size(), k));
				if (st.count(r)) isok = 0;
				st.insert(r);
			}
			if (isok) break;
		}
		cout << (k < 51 ? k : -1) << endl;
	}
}


Measured memory_bytes: 3160
using System;
using System.Collections.Generic;
using System.Linq;

namespace WelcomeAtcordet
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int five_count = 0;
            int seven_count = 0;

            foreach (int i in input)
            {
                if (i == 5)
                {
                    five_count++;
                }
                else if (i == 7)
                {
                    seven_count++;
                }
            }

            if(five_count == 2&& seven_count == 1)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}


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

int main() {
    int n,k; cin>>n>>k;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a.begin(),a.end());
    int ans = 0;
    for(int i=0; i<k; i++) {
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int dx[4] = { 1,0,-1,0 }; int dy[4] = { 0,1,0,-1 };

int main()
{
	cout << fixed << setprecision(10);

	int h, w, k;
	cin >> h >> w >> k;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x1--;
	y1--;
	x2--;
	y2--;

	vector<string> m(h);
	REP(i, h)
	{
		cin >> m[i];
	}


	vector<vector<int>> dist(h, vector<int>(w, INF));

	queue <tuple<int, int, int>> q;
	q.emplace(0, x1, y1);

	dist[x1][y1] = 0;

	while (q.empty() == false)
	{
		auto [c, x, y] = q.front();
		if (dist[x][y] != c)continue;
		q.pop();

		REP(j, 4)
		{
			int nx = x;
			int ny = y;
			FOR(i, 1, k + 1)
			{
				nx += dx[j];
				ny += dy[j];
				if (nx < 0 || h <= nx || ny < 0 || w <= ny)break;
				if (m[nx][ny] == '@')break;

				if (dist[nx][ny] <= c)break;

				if (dist[nx][ny] > c + 1)
				{
					dist[nx][ny] = c + 1;
					q.emplace(c + 1, nx, ny);
				}
			}
		}
	}
	if (dist[x2][y2] == INF)
	{
		cout << -1;
		return 0;
	}
	cout << dist[x2][y2];
	return 0;
}


Measured memory_bytes: 12056
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M), p(M);
  vector<vector<int>> s(M);
  for (int i=0; i<M; i++) {
    cin >> k[i];
    for (int j=0; j<k[i]; j++) {
      int num;
      cin >> num;
      num--;
      s[i].push_back(num);
    }
  }
  for (int i=0; i<M; i++) cin >> p[i];
  // スイッチがonになっているとき1，そうでなければ0
  int res = 0;
  for (int tmp=0; tmp<(1<<10); tmp++) {
    bitset<10> b(tmp);
    bool OK = true;
    for (int i=0; i<M; i++) {
      int num2 = 0;
      for (int j=0; j<k[i]; j++) {
        if (b.test(s[i][j])) num2++;
      }
      if (num2%2!=p[i]) {
        OK = false;
        break;
      }
    }
    if (OK) res++;
  }
  res /= pow(2, 10-N);
  cout << res << endl;
  return 0;
}

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


int main() {
    string a, b,c;
    cin >> a >> b>>c;
    cout << (char)(a[0] -32) << (char)(b[0] -32) << (char)(c[0] -32) << endl;
  
 
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MP make_pair
#define pb push_back
#define ff first
#define ss second
#define sz(x) x.size()
#define all(c) c.begin(),c.end()
#define int long long
#define fr(i,j,x) for(int i=j;i<x;i++)
#define rep(i,j,x) for(int i=j;i<=x;i++)
#define mem(x,val) memset(x,val,sizeof(x))
//#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<int,pii>
 
const int mod=1e9+7;
const int N=1e5+10;
const int MAXN=2e6+10;
const int INF=1e18;

char grid[1010][1010];
int dis[1010][1010],h,w;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int val(int x,int y){
    if(x>=1 && y>=1 && x<=h && y<=w && grid[x][y]!='#'){
        return 1;
    }
    return 0;
}

void solve(){
    int s,e,fs,fe;
    cin>>h>>w>>s>>e>>fs>>fe;
    rep(i,1,h){
        rep(j,1,w){
            cin>>grid[i][j];
            dis[i][j]=-1;
        }   
    }
    deque<pii>q;
    q.push_back({s,e});
    dis[s][e]=0;
    while(!q.empty()){
        auto x=q.front().ff;
        auto y=q.front().ss;
        q.pop_front();
        // if(vis[x][y]){
        //     continue;
        // }
        // if(x==fs && y==es){
        //     break;
        // }
        rep(i,0,3){
            int nx=x+dx[i];
            int ny=y+dy[i];
            if(val(nx,ny)){
                int vl=dis[x][y];
                if(dis[nx][ny]==-1 || dis[nx][ny]>vl){
                    dis[nx][ny]=vl;
                    q.push_front({nx,ny});
                }
            }
        }
        rep(i,-2,2){
            rep(j,-2,2){
                int nx=x+i;
                int ny=y+j;
                if(val(nx,ny)){
                    int vl=dis[x][y]+1;
                    if(dis[nx][ny]==-1 || dis[nx][ny]>vl){
                        dis[nx][ny]=vl;
                        q.push_back({nx,ny});
                    }
                }
            }
        }
    }
    cout<<dis[fs][fe]<<endl;
}


int32_t main()
{
//     #ifndef ONLINE_JUDGE
//         freopen("inputf.in", "r", stdin);
//         //freopen("outputf.in", "w", stdout);
//     #endif
    SPEED;
    int T=1;
    //cin>>T;
    int t1=1;
    while(true)
    {  
        //cout<<"Case #"<<t1<<": ";
        solve();
        t1++;
        if(t1>T)
            break;
    }
}


Measured memory_bytes: 12660
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  while(true) {
    int n;
    int w[300];
    int dp[301][301] = {0};
    cin >> n;
    if(n == 0) break;
    rep(i, n) {
      cin >> w[i];
    }
    rep(i, n-1) {
      if(abs(w[i]-w[i+1]) <= 1) dp[i][i+1] = 2;
      else dp[i][i+1] = 0;
    }

    for(int l = 3; l <= n; l++) {
      for(int i = 0; i + l - 1 < n; i++) {
        int j = i + l - 1;
        if(dp[i+1][j-1] == j - i - 1) {
          if(abs(w[i]-w[j]) <= 1) dp[i][j] = j - i + 1;
          else dp[i][j] = j - i - 1;
        }
        for(int k = i; k <= j-1; k++) {
          dp[i][j] = max(dp[i][j], dp[i][k] + dp[k+1][j]);
        }
      }
    }

    cout << dp[0][n-1] << endl;

  }
  return 0;
}


Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
bool ok(int n){
  int m = n;
  int rev = 0;
  int digit = floor(log10(n));
  while(m>0){
    rev += (m%10)*pow(10,digit);
    m /= 10;
    digit --;
  }
  if(n == rev)return true;
  return false;
}
    
int main(){
  int a,b;
  int count = 0;
  cin >> a >> b;
  for(int i=a;i<=b;i++){
    if(ok(i)){
      count ++;
    }
  }
  cout << count << endl;
}
    
    

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	long double res=0;
	long double x;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		res+=(long double)1/x;
	}
	res=1/res;
	cout.precision(10);
	cout<<res<<endl;
	return 0;
}

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

using ll = long long;
using num = __int128_t;

const int MAXN = 3e5;
int N;
ll V;
ll X[MAXN];
num pref[MAXN];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(nullptr);
	cin >> N >> V;
	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}

	reverse(X, X + N);

	pref[0] = 0;
	for (int i = 0; i < N; i++) {
		pref[i+1] = pref[i] + X[i];
	}

	num ans = 8e18;
	for (int k = 1; k <= N; k++) {
		num v = k * V + N * V;
		for (int i = 0; i < N; i += k) {
			v += (pref[min(i + k, N)] - pref[i]) * max(5, 2 * (i / k) + 3);
		}
		ans = min(ans, v);
	}
	cout << ll(ans) << '\n';

	return 0;
}


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


int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans;
  if(b >= 0 && d >= 0 ) {
    if (a*c < b*d) ans = b*d;
    else ans = a*c;
  }
  if(b <= 0 && d <= 0) ans = a*c;
  if(b <= 0 && d >= 0) {
    if(c <= 0) ans = c*a;
    else ans = b*c;
  }
  if(b >= 0 && d <= 0) {
    if(a <= 0) ans = c*a;
    else ans = d*a;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
using namespace std;
signed main()
{
	cin.tie(0); ios::sync_with_stdio(0);
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int maxx = INT_MIN;
	int miny = INT_MAX;
	int tmp;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		if (tmp > maxx)maxx = tmp;
	}
	for (int i = 0; i < m; i++) {
		cin >> tmp;
		if (tmp < miny)miny = tmp;
	}
	if (min(miny,y)>max(x,maxx))cout << "No War";
	else cout << "War";
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll DP[200005];

int main() {
  int N;
  cin>>N;
  vector<int> C;
  int tmp;
  cin>>tmp;
  C.push_back(tmp);
  for(int i=1;i<N;++i) {
    cin>>tmp;
    if(C[C.size()-1]==tmp) continue;
    C.push_back(tmp);
  }
  map<int, int> amap, bmap;
  for(int i=1;i<=200000;++i) amap[i] = -1;
  for(int i=0;i<C.size();++i) {
    if(amap[C[i]]>-1) bmap[amap[C[i]]] = i;
    amap[C[i]] = i;
  }
  DP[0] = 1;
  if(bmap[0]>0) DP[bmap[0]] += DP[0];
  for(int i=1;i<N;++i) {
    DP[i] += DP[i-1];
    DP[i] %= mod;
    if(bmap[i]>0) {
      DP[bmap[i]] += DP[i];
      DP[bmap[i]] %= mod;
    }
  }
  cout<<DP[N-1]<<endl;
}



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

int main(){
  int n,m;
  cin >> n >> m;
  
  const int NMMAX =50;
  int A[NMMAX],B[NMMAX];
  
  for(int i=0;i<m;i++){
    cin >> A[i] >> B[i];
  }
  
  int road[NMMAX];
  for(int i=0;i<n;i++){
    road[i] =0;
  }
  
  for(int i=0;i<m;i++){
    road[A[i]-1] += 1;
    road[B[i]-1] += 1;
  }
  
  for(int i=0;i<n;i++){
    cout << road[i] << endl;
  }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define X first
#define Y second
#define sz(x) ((int)x.size())
#define CLR(x) memset(x,0,sizeof(x))
#define lson (root<<1)
#define rson (root<<1|1)
#define EM emplace
#define EM_back emplace_back
using namespace std;
typedef pair<int,int> pii;
int n;
int a[3020];
int dp[3020][3020];
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	int ct=1;
    if(n%2==0)ct=-1;
    for(int i=0;i<n;i++)dp[i][i]=ct*a[i];
    for(int i=2;i<=n;i++)
    {
        ct*=-1;
        if(ct==-1)//second
        {
            for(int j=0;j+i-1<n;j++)
            {
                dp[j][j+i-1]=min(dp[j][j+i-2]+ct*a[j+i-1],
                                 dp[j+1][j+i-1]+ct*a[j]);
            }
        }
        else//first
        {
            for(int j=0;j+i-1<n;j++)
            {
                dp[j][j+i-1]=max(dp[j][j+i-2]+ct*a[j+i-1],
                                 dp[j+1][j+i-1]+ct*a[j]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
	return 0;
}


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

const int N = (1e3) + 5;
int x, y, z, k;
ll a[N], b[N], c[N];
vector<ll> sum1, sum2;

// claudio van
int main() {
  scanf("%d %d %d", &x, &y, &z);
  scanf("%d", &k);
  for (int i = 0; i < x; ++i) {
    scanf("%lld", &a[i]);
  }
  for (int i = 0; i < y; ++i) {
    scanf("%lld", &b[i]);
  }
  for (int i = 0; i < z; ++i) {
    scanf("%lld", &c[i]);
  }
  for (int i = 0; i < x; ++i) {
    for (int j = 0; j < y; ++j) {
      sum1.emplace_back(a[i] + b[j]);
    }
  }
  sort(sum1.begin(), sum1.end(), greater<ll>());
  sort(c, c + z, greater<ll>());
  for (int i = 0; i < min(3000, (int) sum1.size()); ++i) {
    for (int j = 0; j < z; ++j) {
      sum2.emplace_back(sum1[i] + c[j]);
    }
  }
  sort(sum2.begin(), sum2.end(), greater<ll>());
  for (int i = 0; i < k; ++i) {
    printf("%lld\n", sum2[i]);
  }
  return 0;
}

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
int INF = numeric_limits<int>::max();
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

/* if in function
template <class T>
bool contain(vector<T> &vec, T find_it) {
  auto it = find(vec.begin(), vec.end(), find_it);
  return it != vec.end();
}

bool contain(string &str, char c) {
  return str.find(c) != string::npos;
}
*/

int main() {
  int n;
  cin >> n;
  vector<vector<int>> df(n, vector<int>(3));
  int xi = 0, yi = 0, hi = 0;
  rep(i, n) {
    cin >> df[i][0] >> df[i][1] >> df[i][2];
    if (df[i][2] != 0) {
      xi = df[i][0], yi = df[i][1], hi = df[i][2];
    }
  }

  rep(x, 101) {
    rep(y, 101) {
      int h = abs(x - xi) + abs(y - yi) + hi;
      bool found = true;
      for (auto& vec : df) {
        if (max(h - abs(x - vec[0]) - abs(y - vec[1]), 0) != vec[2]) found = false;
      }
      if (found) {
        cout << x << " " << y << " " << h << endl;
        exit(0);
      }
    }
  }
}


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

int main() {
    int N,K;
    int S = 1;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        if (S + K < 2 * S) {
        S = S + K;
        }
        else {
            S = 2 * S;
        }
    }cout << S << endl;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;

    Scd(n);

    n+=110;
    n = (n / 111 ) * 111;

    printf ("%d\n", n);

    return 0;
}



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

def main():
    n = int(input())
    d, x = map(int, input().split())
    a = [int(input()) for _ in range(n)]

    for i in a:
        if d % i == 0:
            x += d // i
        else:
            x += 1 + d // i
        
    print(x)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int h,a;
    cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <set>
#include <unordered_map>
using namespace std;

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

const int INF = 1e9;
const int MAX_V = 1e6+1;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

ll N;
ll n_x[200000];
ll s_x[200000];
int main() {
  cin >> N;
  ll a;
  rep(i, N) {
    scanf("%lld\n", &a);
    n_x[i] = a;
    s_x[i] = a;
  }
  sort(s_x, s_x + N);
  ll s, m;
  s = s_x[N/2-1]; m = s_x[N/2];
  rep(i, N) {
    if(n_x[i] <= s) printf("%lld\n", m);
    else printf("%lld\n", s);
  }
}


Measured memory_bytes: 5376
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
#define PI 3.1415926535897932384626433832795
using namespace std;

int main()
{
	int64 nn, ans = 0;
	cin >> nn;
	vector<int64> aa(nn + 1), bb(nn + 1), cc(nn);
	for(int64 ii = 1;ii <= nn;ii++)
	{
		cin >> aa[ii];
	}
	for(int64 ii = 1;ii <= nn;ii++)
	{
		cin >> bb[ii];
	}
	for(int64 ii = 1;ii <= nn - 1;ii++)
	{
		cin >> cc[ii];
	}
	ans += bb[aa[1]];
	for(int64 ii = 2;ii <= nn;ii++)
	{
		ans += bb[aa[ii]];
		if(aa[ii] - aa[ii - 1] == 1)
		{
			ans += cc[aa[ii - 1]];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3568
A = gets.strip.split.map(&:to_i)
A.sort!

if (A[2]-A[1]) % 2 == (A[2]-A[0]) % 2

    if  (A[2]-A[1]) % 2 == 0

        puts (A[2]-A[1]) / 2 + (A[2]-A[0]) / 2

    else

        puts (A[2]-A[1]) / 2 + (A[2]-A[0]) / 2 + 1

    end

else

    if (A[2]-A[1]) % 2 == 0

        puts (A[2]-A[1]) / 2 + (A[2]+1-A[0]) / 2 + 1

    else 

        puts  (A[2]+1-A[1]) / 2 + (A[2]-A[0]) / 2 + 1
        
    end

end


Measured memory_bytes: 1788
function main(input) {
  const args = input.split("\n");
  const N = args[0];
  const A = args[1].split(" ");
  const B = args[2].split(" ");
  const C = args[3].split(" ");
  var score = 0;
  for (var i = 0; i < Number(N); i++) {
    score = score + Number(B[Number(A[i])-1]);
    if(i !== Number(N)-1 && Number(A[i+1]) === Number(A[i]) +1) {
      score = score + Number(C[Number(A[i])-1]);
    }
  }
  console.log(score);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  int A;
  cin >> A;
  long long ans = 0;
  
  for(int i = 1;i <= A;i++){
  if(i % 3 != 0 && i % 5 != 0)ans += i;
  }
  cout << ans << endl;
}


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

int main()
{
	int d,i,s,c;
	while(cin>>d){
		s = 0;
		c = 600/d;
		for(i = 1; i < c; i++)
		{
			s += d * (d * i) * (d * i);
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from bisect import bisect
LONG_MIN = -9223372036854775808
LONG_MAX = 9223372036854775807

num_a,num_b,num_q = map(int, input().split(' '))
lsa = [int(input()) for _ in range(num_a)] + [LONG_MIN, LONG_MAX]
lsb = [int(input()) for _ in range(num_b)] + [LONG_MIN, LONG_MAX]
lsa.sort()
lsb.sort()
lsq = [int(input()) for _ in range(num_q)]

for ques in lsq:
    lower_bound_a = bisect(lsa, ques)
    lower_bound_b = bisect(lsb, ques)
    upper_bound_a = lower_bound_a - 1
    upper_bound_b = lower_bound_b - 1

    res = min(
        max(lsa[lower_bound_a], lsb[lower_bound_b]) - ques, 
        ques - min(lsa[upper_bound_a], lsb[upper_bound_b]),
        lsb[lower_bound_b] - ques + lsb[lower_bound_b] - lsa[upper_bound_a],
        ques - lsa[upper_bound_a] + lsb[lower_bound_b] - lsa[upper_bound_a],
        lsa[lower_bound_a] - ques + lsa[lower_bound_a] - lsb[upper_bound_b],
        ques - lsb[upper_bound_b] + lsa[lower_bound_a] - lsb[upper_bound_b],
    )
    
    print(res)


Measured memory_bytes: 16288
#include<iostream>

struct Point{
	double x, y;
};
typedef Point Vector;

double ExteriorProduct(Vector v1, Vector v2){
	return v1.x*v2.y-v2.x*v1.y;
}

int Abs(int i){
	return i>0?i:-i;
}


int main(){
	Point ps[3], p;
	while(true){
		for(int i=0;i<3;i++){
			std::cin >> ps[i].x >> ps[i].y;
		}
		if(std::cin.eof())break;

		std::cin >> p.x >> p.y;

		int count = 0;
		for(int i=0;i<3;i++){
			Vector pv, v; //点Pからのベクトル辺のベクトル
			Point first_p = ps[i], second_p = ps[(i+1)%3];
			pv = {p.x-first_p.x, p.y-first_p.y};
			v = {first_p.x-second_p.x, first_p.y-second_p.y};
			if(ExteriorProduct(pv, v) > 0){
				count++;
			}else{
				count--;
			}
		}

		if(Abs(count) == 3){
			std::cout << "YES\n";
		}else{
			std::cout << "NO\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1188
/*
    handle - pruvi007
    questionName - 
    Contest - 
    Topic - 
    Platform - 
*/
#include<bits/stdc++.h>
using namespace std;
#define ll          long long int
#define fast         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INF          1e18
#define MOD          1000000007
#define Vi           vector<ll> 
#define Vs           vector<string>
#define VI           vector<vector<ll> >
#define PII          pair<ll,ll> 
#define PSI          pair<string,ll>
#define PB           push_back


int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
int DX[] = {0,-1,-1,-1,0,1,1,1};
int DY[] = {-1,-1,0,1,1,1,0,-1};

int getPar(int x,int par[]){
    while(x!=par[x])
        x = par[x];
    return x;
}
int find(int x,int y,int par[])
{
    return getPar(x,par) == getPar(y,par);
}
int doUnion(int x,int y,int par[],int size[])
{
    if( find(x,y,par) )
        return -1;
    int p1 = getPar(x,par);
    int p2 = getPar(y,par);
    int s1 = size[p1];
    int s2 = size[p2];
    if( s1 > s2 )
    {
        par[p2] = p1;
        size[p1] += s2;
    }
    else
    {
        par[p1] = p2;
        size[p2] += s1;
    }
    return 1;
}

int main()
{
    fast;
    int n,m;
    cin >> n >> m;
    int par[n+1],size[n+1];
    for(int i=1;i<=n;i++)
    {
    	par[i] = i;
    	size[i] = 1;
    }
    for(int i=0;i<m;i++)
    {
    	int x,y;
    	cin >> x >> y;
    	int p = doUnion(x,y,par,size);
    }
    map<int,int> mp;
    for(int i=1;i<=n;i++)
    {
    	mp[getPar(i,par)]=1;
    }
    cout << mp.size() - 1 << '\n';
}

Measured memory_bytes: 8268
a, b = map(int, input().split())
if abs(a - b) >= 2:
    print(0)
else:
    c = 1
    for i in range(1, a + 1):
        c = (c * i) % (10 ** 9 + 7)
    for i in range(1, b + 1):
        c = (c * i) % (10 ** 9 + 7)
    if abs(a - b) == 1:
        print(c)
    else:
        print((c * 2) % (10 ** 9 + 7))


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

    

    class Program
    {
        
        
        static void Main(string[] args)
        {
            
            while(true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int m = int.Parse(input[0]);
                int n_min = int.Parse(input[1]);
                int n_max = int.Parse(input[2]);

                if (m == 0 && n_min == 0 && n_max == 0)
                {
                    break;
                }

                int[] points = new int[m];

                for(int i = 0; i < m; i++)
                {
                    points[i] = int.Parse(Console.ReadLine());
                }

                int gap_max = -1;
                int ans_n = 0;

                for(int n_ac = n_min; n_ac <= n_max; n_ac++)
                {
                    int gap = points[n_ac - 1] - points[n_ac];

                    if(gap >= gap_max)
                    {
                        gap_max = gap;
                        ans_n = n_ac;
                    }
                    
                }

                Console.WriteLine(ans_n);

            }
            
        }
    }
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}
 

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll N; cin >> N;
    ll ans = 1;
    REP(i, N) {
        ll T; cin >> T;
        ans = ans / gcd(ans, T) * T;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
s = str(input())
arr = []
count = 0
ans = 0

for i in s:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        arr.append(1)
    else:
        arr.append(0)

for i in range(0, len(arr)):
    if arr[i] == 0:
        count = 0
    else:
        count += 1
        ans = max(ans, count)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define endl "\n"

using namespace std;

void dout() {
    cerr << endl;
}

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}


typedef pair <int, int> pii;
int a;
string s;

void cleanup() {
    return;
}

void solve() {
    cin >> a >> s;
    if (a < 3200) {
        cout << "red";
    }   else {
        cout << s;
    }
    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
    int tc = 1;
//    cin >> tc;
    while (tc--) {
        solve();
        cleanup();
    }
}


Measured memory_bytes: 892