akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std; 
const int INF = 1e9;

struct octa {
    int face[8];
    void rotate_left(){
        rotate(face, face+1, face+4);
        rotate(face+4, face+5, face+8);
    }

    void rotate_up(){
        int t = face[0];
        face[0] = face[4];
        face[4] = face[7];
        face[7] = face[3];
        face[3] = t;
        t = face[1];
        face[1] = face[5];
        face[5] = face[6];
        face[6] = face[2];
        face[2] = t;
    }

    bool equals(octa o) const {
        if(check(o)) return true;
        o.rotate_up();
        if(check(o)) return true;
        o.rotate_up();
        if(check(o)) return true;
        o.rotate_up();
        if(check(o)) return true;
        o.rotate_up();
        o.rotate_left();
        o.rotate_up();
        if(check(o)) return true;
        o.rotate_up();
        o.rotate_up();
        if(check(o)) return true;
        return false;
    }

    bool check(octa &o) const {
        rep(i,4){
            if(equal(face, face+8, o.face)) return true;
            o.rotate_left();
        }
        return false;
    }
};

int main(){
    string s[8];
    while(cin >> s[0]){
        rep(i,7) cin >> s[i+1];
        map<string, int> m;
        int k = 0;
        rep(i,8) if(m.count(s[i]) == 0) m[s[i]] = k++;
        octa o;        
        rep(i,8) o.face[i] = m[s[i]];

        sort(o.face, o.face+8);
        vector<octa> s;
        s.push_back(o);
        do {
            bool add = true;
            for(auto &a : s){
                if(a.equals(o)){
                    add = false;
                    break;
                }
            }
            if(add) s.push_back(o);
        } while(next_permutation(o.face+1, o.face+8));
        cout << s.size() << endl;
    }
}

Measured memory_bytes: 3140
//  __/\\\\____________/\\\\______/\\\\\\\\\______/\\\________/\\\___/\\\\\\\\/\\____/\\\\\\\\\\_|
//   _\/\\\\\\________/\\\\\\____/\\\\\\\\\\\\\___\/\\\________/\\\__\/\\\____\/\\\__\////\\\///__|
//    _\/\\\//\\\____/\\\//\\\___/\\\/////////\\\__\/\\\________/\\\__\/\\\____\/\\\\____\/\\\_____|
//     _\/\\\\///\\\/\\\/_\/\\\__\/\\\_______\/\\\__\/\\\\\\\\\\\\\\\__\/\\\____\/\\\\____\/\\\_____|
//      _\/\\\__\///\\\/___\/\\\__\/\\\\\\\\\\\\\\\__\/\\\/////////\\\__\/\\\____\/\\\\____\/\\\_____|
//       _\/\\\____\///_____\/\\\__\/\\\/////////\\\__\/\\\_______\/\\\__\/\\\____\/\\\_____\/\\\_____|
//        _\/\\\_____________\/\\\__\/\\\_______\/\\\__\/\\\_______\/\\\__\/\\\___/\\\\______\/\\\_____|
//         _\/\\\_____________\/\\\__\/\\\_______\/\\\__\/\\\_______\/\\\__\/\\\\\\/\\_____/\\\\\\\\\\__|
//          _\///______________\///___\///________\///___\///________\///___\/////////_____\//////////___|
#include<bits/stdc++.h>
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef vector< int > vi;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< long long > vl;
typedef vector< pair< int , int > > vpi;
typedef pair< int , int > pii;
#define hurry ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define setp setprecision
#define popp pop_back()
#define pb push_back
#define mp make_pair
#define beg begin()
#define en end()
#define sc second
#define sz size()
#define fr first
#define endl '\n'
const int mod=1e9+7;
const long long INF=1e16+10;
const int Nn=1e8;
//=======================================================================================================================
//GLOBAL
//=======================================================================================================================
//FUNCTIONS
//=======================================================================================================================
//STRUCTS
//=======================================================================================================================
int main()
{
    ll n,k;
    cin>>n>>k;
    cout<<min((n%k),abs((n%k)-k));
}
//=======================================================================================================================
//ifstream tin("input.txt");
//ofstream tout("output.txt");


Measured memory_bytes: 256
a=list(map(int,input().split()))
b=list(map(int,input().split()))
no=1
for i in range(1,a[0]):
    b[i]+=b[i-1]
for i in range(0,a[0]):
    if(a[1]>=b[i]):
        no+=1
    else:
        break
print(no)        

Measured memory_bytes: 9000
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  iostreamBooster();

  int N, Q;
  string s;

  cin >> N >> Q;
  cin >> s;

  vector<int> p;
  for (int i = 0; i < s.length() - 1; ++i) {
    if (s[i] == 'A' && s[i+1] == 'C') {
      p.push_back(i + 1);
    }
  }

  for (int i = 0; i < Q; ++i) {
    int l, r;
    cin >> l >> r;

    int s = lower_bound(ALL(p), l) - p.begin();
    int t = upper_bound(ALL(p), r-1) - p.begin();

    cout << t - s << '\n';
  }

  return 0;
}



Measured memory_bytes: 1228
#include<stdio.h>
int main(){
long h,w,d,ans=1000000000,i,keep;
scanf("%ld%ld",&h,&w);
for(i=1;i<h;i++){
if((h-i)>1){
d=(w*i)-(((h-i)/2)*w);
if(d<=0){
if((h-i)%2==1)
d-=w;
d=-d;
}
if(d<ans)
ans=d;
}
d=(w*i)-(h-i)*(w/2);
if(d<=0){
if(w%2==1)
d-=(h-i);
d=-d;
}
if(d<ans)
ans=d;
}
keep=h;
h=w;
w=keep;
for(i=1;i<h;i++){
if((h-i)>1){
d=(w*i)-(((h-i)/2)*w);
if(d<=0){
if((h-i)%2==1)
d-=w;
d=-d;
}
if(d<ans)
ans=d;
}
d=(w*i)-(h-i)*(w/2);
if(d<=0){
if(w%2==1)
d-=(h-i);
d=-d;
}
if(d<ans)
ans=d;
}
printf("%ld\n",ans);
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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 <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll H, W, h, w;
  cin >> H >> W >> h >> w;

  ll ans = H * W;
  rep(i, h) {
    ans -= W;
    H--;
  }

  rep(i, w) {
    ans -= H;
  }

  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
  
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	bool prev = prev_permutation(a, a + n);
	if(prev){
		cout << a[0];
		for(int i = 1; i < n; i++)cout << ' ' << a[i];
		cout << '\n';
	}
	next_permutation(a, a + n);
	cout << a[0];
	for(int i = 1; i < n; i++)cout << ' ' << a[i];
	cout << '\n';
	bool next = next_permutation(a, a + n);
	if(next){	
		cout << a[0];
		for(int i = 1; i < n; i++)cout << ' ' << a[i];
		cout << '\n';
	}
    return 0;
}



Measured memory_bytes: 3200
/*
Rathin Bhargava
IIIT Bangalore

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 

int main()
{
  __;
  int n,k;
  cin >> n >> k;
  vector<ll> v(n);
  for(int i=0;i<n;i++) cin >> v[i];

  bool boo = false;
  for(int i=0;i<n-1;i++)
  {
    if(v[i] + v[i+1] >= k)
    {
      boo = true;
      cout << "Possible" << endl;
      // t(i);
      for(int j=0;j<i;j++) cout << j+1 << endl;
      for(int j=n-2;j>i;j--) cout << j+1 << endl;
      cout << i+1 << endl;
      break;
    }
  }

  if(!boo) cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ar array

   
int main()
{
   int x;
   cin >> x;
   if (x >= 30)
      cout << "Yes";
   else
      cout << "No";

   return 0;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <bitset>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pp;       // int aa = pp.first;
typedef tuple<int, int, int> tp; // int aa = get<0>(tp);

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

int all[100100];

class BIT {
public:
  vector<int> bit;
  int M;

  BIT(int M) : bit(vector<int>(M + 1, 0)), M(M) {}

  int get(int i) const {
    if (!i)
      return 0;
    return bit[i] + get(i - (i & -i));
  }

  void add(int i, int x) {
    if (i > M)
      return;
    bit[i] += x;
    add(i + (i & -i), x);
  }
};

void solve(long long N, long long M, vector<long long> &l,
           vector<long long> &r) {

  BIT bit(100010);
  vector<tp> vtp;
  REP(i, N) { vtp.push_back(tp(r[i] - l[i] + 1, l[i], r[i])); }
  sort(ALL(vtp));

  int pc = 0;
  FOR(m, 1, M + 1) {
    ll ans = 0;

    while (pc < N && get<0>(vtp[pc]) < m) {
      bit.add(get<1>(vtp[pc]), 1);
      bit.add(get<2>(vtp[pc]) + 1, -1);
      pc++;
    }

    ans += N - pc;

    for (int v = m; v <= M; v += m) {
      ans += bit.get(v);
    }

    cout << ans << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  long long M;
  cin >> N;
  vector<long long> r(N - 1 + 1);
  vector<long long> l(N - 1 + 1);
  cin >> M;
  for (int i = 0; i <= N - 1; i++) {
    cin >> l[i];
    cin >> r[i];
  }
  solve(N, M, l, r);
  return 0;
}


Measured memory_bytes: 11632
import math
n = int(input())

nf = math.factorial(n)

dic = {}
for i in range(2, nf + 1):
  counter = 0
  while nf % i == 0:
    nf //= i
    counter += 1
  if counter != 0:
    dic[i] = counter
  if nf == 1:
    break
ans = 1
for item in dic.values():
  ans *= (item + 1) % (10**9 + 7)
print(ans % (10**9 + 7))


Measured memory_bytes: 38768
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>
#include <queue>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    ll N;
    cin >> N;
    cout << N*(N-1)/2 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
const int N=15,M=1010;
int h,w,k,ans=1e9;
char s[N][M];
int main() {
	scanf("%d%d%d",&h,&w,&k);
	for(int i=0;i<h;i++){
		scanf("%s",s[i]);
	}
	for(int mask = 0; mask < (1 << (h + 1)); mask+=2) {
		int cnt[12] = {0}, here = 0, ok = 1;
		for(int j = 0; j < w; j++) {
			int p = 0;
			int add[12] = {0};
			for(int i = 0; i < h; i++) {
				if(i && (mask >> i & 1)) p++;
				add[p] += s[i][j] - '0';
			}
			bool split = false;
			for(int i = 0; i <= p; i++)
				if(cnt[i] + add[i] > k)
					split = true;
			if(split) {
				here++;
				for(int i = 0; i <= p; i++)
					cnt[i] = add[i];
			} else {
				for(int i = 0; i <= p; i++)
					cnt[i] += add[i];
			}
			for(int i = 0; i <= p; i++)
				if(cnt[i] > k) {
					ok = 0;
					break;
				}
			if(!ok) break;
		}
		if(ok) ans = min(ans, here + __builtin_popcount(mask));
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    fast_io
    ll i,j,n;
    cin>>n;
    (n>999)?cout<<"ABD":cout<<"ABC";



    return 0;
}





Measured memory_bytes: 3624
<?php
$p='';
while(1){
  list($a,$o,$b)=explode(' ',trim(fgets(STDIN)));
  if($o=='?')break;
  if($o=='+'){$p.=$a+$b;}
  elseif($o=='-'){$p.=$a-$b;}
  elseif($o=='*'){$p.=$a*$b;}
  elseif($o=='/'){$p.=floor($a/$b);}
  $p.="\n";
}
print $p;

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a >= 13) {
        ans = b;
    } else if (a >= 6) {
        ans = b / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> s(0);
  int ans = 0;
  rep(i,n){
    int x;
    cin >> x;
    ans += x;
    if (x%10 == 0) continue;
    s.push_back(x);
  }
  if(s.size() == 0){
    cout << 0 << endl;
    return 0;
  }
  sort(s);
  if(ans%10 == 0) cout << ans-s[0] << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())
A = list(input())
R = deque()
W = deque()
for i in range(N):
    if A[i] == "R":
        R.append(i)
    else:
        W.append(i)

        
ans = 0        
for i in range(N):
    if len(R) * len(W) == 0:
        print(0)
        break
    else:
        a = R.pop()
        b = W.popleft()
        if a < b:
            print(ans)
            break
        else:
            R.appendleft(b)
            W.append(a)  
            ans += 1

Measured memory_bytes: 18700
N, K, Q = list(map(int, input().split()))
A = [int(input()) for i in range(Q)]

answers = [0] * N
for Ai in A:
    index = Ai - 1
    answers[index] += 1

border = Q - K
results = ['Yes' if answer > border else 'No' for answer in answers]
results = "\n".join(results)

print(results)


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

int main()
{
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    for(int i = a; i <= b; i++){
        if(i / 10000 == i % 10 && (i / 1000) % 10 == (i / 10) % 10) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

void SelectionSort(vector<int> &a, int n){
    int swap_num = 0;
    int i = 1;
    while (i <= n){
        int j = i + 1;
        int min_index = i;
        while (j <= n){
            if(a[j] < a[min_index]){
                min_index = j;
            }
            j++;
        }
        swap(a[min_index], a[i]);
        if(i != min_index){
            swap_num++;
        }
        i++;
    }
    REP(i, n){
        if(i == 0){
            cout << a[1];
        }
        else {
            cout << " " << a[i+1];
        }
    }
    cout << endl;
    cout << swap_num << endl;
    return;
}

int main(){
    int n, tmp;
    cin >> n;
    vector<int> a(n+1);
    REP(i, n){
        cin >> a[i+1];
    }
    SelectionSort(a, n);
    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int H, W;
// 右, 左, 上, 下　右上, 左上, 右下, 左下
int dx[] = {1, -1,  0,  0, 1, -1, 1, -1};
int dy[] = {0,  0, -1,  1, 1,  1, -1, -1};
string s[50];
int ret[50][50];

void solve()
{
  REP (i, H) {
    REP(k, W) {
      if (s[i][k] == '#')
        continue;
      REP(m, 8) {
        if (i + dy[m] < 0 || k + dx[m] < 0 || i + dy[m] >= H || k + dx[m] >= W)
          continue;
        if (s[i + dy[m]][k + dx[m]] == '#') {
          ret[i][k]++;
        }
      }
    }
  }
  REP (i, H) {
    REP (k, W) {
      if (s[i][k] == '#')
        cout << "#";
      else
        cout << ret[i][k];
    }
    cout << endl;
  }
}

int main()
{
  cin >> H >> W;
  REP (i, H)
    cin >> s[i];
  solve();
}


Measured memory_bytes: 256
def main():
  [a, t, k] = [int(i) for i in input().split()]
  if a + t <= k:
    a = 0
    t = 0
  elif a <= k:
    t = t - (k - a)
    a = 0
  else:
    a = a - k
  print(a, t)

if __name__ == "__main__":
  main()
  


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

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e9)
// #define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

void solve(int &test) {
    int n, k;
    cin >> n >> k;
    int p[n];
    for(int i = 0; i < n; i++)
        cin >> p[i];
    sort(p, p+n);
    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += p[i];
    }
    cout << ans << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;

    start = clock(); 

    cout << fixed << setprecision(20);
    
   
   
    // cin >> t;
     
    for(int i = 1; i <= t; ++i){
        solve(i);
    }
    //cerr << time(start);
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int power(int x, int y, int p)  {  
    int res = 1; 
    x = x % p; 
    if (x == 0) return 0; 
  
    while (y > 0)  {  
        if (y & 1) res = (res * x) % p;  
        y = y >> 1; 
        x = (x * x) % p;  
    }  
    return res;  
}  
  
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int arr[n];
    map<int, int> fre;
    set<int> s;
    int check = 0;
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        if(arr[i] == 0) check++;
        s.insert(arr[i]);
        ++fre[arr[i]];
    }
    int po = n/2;
    if(n & 1){
        if(check == 1){
            for(auto it: fre){
                if(it.se != 2 && it.fi != 0){
                    cout << 0 << endl;
                    return 0;
                }
            }
            cout << power(2, po, mod) << endl;
        }
        else cout << 0 << endl;
    }
    else{
        for(auto it: fre){
            if(it.se != 2){
                cout << 0 << endl;
                return 0;
            }
        }
        cout << power(2, po, mod) << endl;
    }
}

Measured memory_bytes: 11288
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,l[100005],r[100005],a[100005],ans=0,x;
int main()
{
	scanf("%lld",&n);
	for(int i=0;i<=n;i++)scanf("%lld",&a[i]);
	ans=0;
	if(n==0)
	{
		if(a[0]==1)printf("1\n");
		else printf("-1\n");
		return 0;
	}
	l[n]=r[n]=a[n];
	for(int i=n-1;i>=0;i--)
	{
		l[i]=a[i]+(l[i+1]+1)/2;
		r[i]=a[i]+r[i+1];
	}
	if(l[0]>1||r[0]<1)
	{
		printf("-1\n");
		return 0;
	}
	x=1;
	for(int i=0;i<=n;i++)
	{
		ans+=x;
		x-=a[i];
		x=min(2ll*x,r[i+1]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9+7;


int main() {
	int N;
  	string S;
  	cin >> N;
   	cin >> S;
  	int sum = 0;
  	vi A(N+1);
  	rep(i,N){
    	if(S[i] == 'I') sum = sum+1;
      	else if (S[i] == 'D') sum = sum -1;
      	A[i] = sum;
    }
  	sort(A);
  	cout << A[N] << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include <stdio.h>
#include <functional>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

string x(string s, const string cs, const string se) {
	int pos = 0;
	while ((pos = s.find_first_of(se)) != string::npos) {
		s.replace(pos, 1, cs);
	}
	return s;
}

string y(string a) {
	int pos4 = 0, pos9 = 0;
	a = x(a, "3", "5");
	a = x(a, "5", "6");
	a = x(a, "6", "7");
	a = x(a, "7", "8");
	int pos = a.length();
	if ((pos4 = a.find_first_of("4")) != string::npos && (pos9 = a.find_first_of("9")) != string::npos)
	{
		if (pos4 > pos9) {//4>9
			a = a.replace(pos9, 1, "7");
			pos = pos9 + 1;
		}
		else {
			a = a.replace(pos4, 1, "3");
			pos = pos4 + 1;
		}
	}
	else if ((pos4 = a.find_first_of("4")) != string::npos) {
		a = a.replace(pos4, 1, "3");
		pos = pos4 + 1;
	}
	else if ((pos9 = a.find_first_of("9")) != string::npos) {
		a = a.replace(pos9, 1, "7");
		pos = pos9 + 1;
	}
	while (pos != a.length()) {
		a = a.replace(pos, 1, "7");
		pos++;
	}
	return a;
}

int n;
int m;
int aji[100000];

int saiki(){
	return 0;
}

int main(){
	vector<pair<int, int>> taikaku[50000];
	for (int i = 1; i <= 150; i++) { // i < j
		for (int j = i + 1; j <= 150; j++) {
			int num = i * i + j * j;
			taikaku[num].push_back(make_pair(i, j));
		}
	}
	/*for (int i = 0; i < 50000; i++) { // i < j
		sort(taikaku[i].begin(), taikaku[i].end());
	}*/
	int h, w;
	while (cin >> h >> w && !(h == 0 && w == 0)) {
		bool flag = false;
		bool flag2 = true;
		int num = h * h + w * w;
		while (flag2){
			for (int i = 0; i < taikaku[num].size(); i++) {
				if (h < taikaku[num][i].first || flag) {
					cout << taikaku[num][i].first << " " << taikaku[num][i].second << endl;
					flag2 = false;
					break;
				}
			}
			num++;
			flag = true;
		}
	}
	return 0;
}

Measured memory_bytes: 2620
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let line: Vec<char> = read_line().trim().chars().collect();
    let n = line.len();
    let mut memo = vec![0;n+1];
    for i in (0..n).rev() {
        memo[i] = memo[i+1];
        if line[i] == 'p' {
            memo[i] += 1;
        } else if memo[i] > 0 {
            memo[i]  = memo[i] - 1;
        }
    }

    let mut ans = 0;
    let mut stock = 0;
    for i in 0..n {
        if line[i] == 'p' {
            stock -= 1;
        } else if stock  > memo[i+1] {
            stock -= 1;
            ans += 1;
        } else {
            stock += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  
  val tracker = inputs(0).split(" ").map(_.toInt)
  val a = tracker(0)
  val v = tracker(1)
  val runaway = inputs(1).split(" ").map(_.toInt)
  val b = runaway(0)
  val w = runaway(1)
  val t = inputs(2).toInt

  println(solve(a, v, b, w, t))

  private def solve(a: Int, v: Int, b: Int, w: Int, t: Int): String = {
    val speedDiff = v - w
    val positionDiff = Math.abs(b - a)

    if(0 < speedDiff && (positionDiff / speedDiff.asInstanceOf[Double]) <= t) {
      return "YES"
    } else {
      return "NO"
    }
  }
}

Measured memory_bytes: 54872
// Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		int cnt[7] = {0};

		for(int i=0; i<n; i++){
			int age;
			cin >> age;

			if(age>=0&&age<10){
				cnt[0]++;
			}
			else if(age>=10&&age<20){
				cnt[1]++;
			}
			else if(age>=20&&age<30){
				cnt[2]++;
			}
			else if(age>=30&&age<40){
				cnt[3]++;
			}
			else if(age>=40&&age<50){
				cnt[4]++;
			}
			else if(age>=50&&age<60){
				cnt[5]++;
			}
			else if(age>=60){
				cnt[6]++;
			}
		}

		for(int i=0; i<7; i++){
			cout << cnt[i] << endl;
		}
	}

	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; int K; cin >> S >> K;
    int N=S.size();
    for (int i=0;i<N;++i) if (S[i]!='a'){
        int x=('z'-S[i])+1;
        if (K<x) continue;
        S[i]='a'; K-=x;
    }
    S[N-1]=(char)(((S[N-1]-'a')+K)%26+'a');
    cout << S << '\n';
}

Measured memory_bytes: 592
#include <iostream>

using namespace std;

int main()
{
    int  x,y;
    cin>>x>>y;
    while(!(x==0&&y==0))
    {

        if(x<y)  cout<<x<<" "<<y<<endl;
        else cout<<y<<" "<<x<<endl;
cin>>x>>y;
    }

    return 0;
}



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

int main(){
    int N;
    cin >> N;
    vector<int>xvec(N);
    vector<int>yvec(N);
    for(int i=0;i<N;i++){
        cin >> xvec[i] >>yvec[i];
    }
    double ans = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            ans += sqrt((xvec[j]-xvec[i])*(xvec[j]-xvec[i])+(yvec[j]-yvec[i])*(yvec[j]-yvec[i])); 
        }
    }
    ans =ans/N;
    cout << fixed << setprecision(15);
    cout << ans <<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string s;
    cin >> s;
    int ans = 1 << 30;
    rep(i, 0, 26)
    {
        const char c = 'a' + i;
        string t = s;
        int num = 0;
        while (!t.empty() && (count(t.begin(), t.end(), c) != t.length()))
        {
            string u;
            rep(j, 0, t.length() - 1)
            {
                if (t[j] == c || t[j + 1] == c)
                {
                    u += c;
                }
                else
                {
                    u += t[j];
                }
            }
            t = u;
            ++num;
        }
        chmin(ans, num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector


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

int H, N; cin>> H >> N;
VI A(N), B(N); rep(i, 0, N) cin >> A[i] >> B[i];

VI magic(H+1, INF);
magic[0] = 0;
rep(h, 1, H+1)
    rep(i, 0, N)
        magic[h] = min(magic[h], magic[max((i64)0, h - A[i])] + B[i]);

cout << magic[H] << "\n";
}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 384
#include <stdio.h>
 
int main(void){
 
  int h,w;
  scanf("%d %d", &h, &w);
  char a[h][w+1];
  for (int i = 0; i < h; i++) {
    scanf("%s", a[i]);
  }
  int row[h],column[w];
  int flag;
  for (int i = 0; i < h; i++) {
    flag = 0;
    for (int j = 0; j < w; j++) {
      if (a[i][j] != '.') {
        flag = 1;
        break;
      }
    }
    row[i] = flag;
  }
  for (int i = 0; i < w; i++) {
    flag = 0;
    for (int j = 0; j < h; j++) {
      if (a[j][i] != '.') {
        flag = 1;
        break;
      }
    }
    column[i] = flag;
  }
  for (int i = 0; i < h; i++) {
    if (row[i] == 1) {
      for (int j = 0; j < w; j++) {
        if (column[j] == 1) {
          printf("%c", a[i][j]);
        }
      }
      printf("\n");
    }
  }
 
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

vector<ll> fact(200010,0),ifact(200010,0);
ll mod = 1e9+7;

ll mpow(ll a, ll x){
    ll ret = 1;
    ll tmp = a;
    while(x > 0){
        if((x & 1) == 1){
            ret = (ret * tmp) % mod;
        }
        
        tmp = (tmp * tmp) % mod;
        x = x >> 1;
    }
    return ret;
}

ll comb(ll n, ll k){
    ll ret = 1;
    ret = (ret * fact[n]) % mod;
    ret = (ret * ifact[k]) % mod;
    ret = (ret * ifact[n-k]) % mod;
    
    return ret;
}

map<ll,ll> prime_factorize(ll n){
    map<ll,ll> ret;
    for(int i = 2; i * i <= n; i++){
        while(n % i == 0){
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main(){
    int n,m;
    cin >> n >> m;
    fact[0] = fact[1] = 1;
    ifact[0] = ifact[1] = 1;
    reps(i,2,200010){
        fact[i] = (fact[i-1] * i) % mod;
        ifact[i] = (ifact[i-1] * mpow(i,mod-2) ) % mod;
    }

    map<ll,ll> mp;
    mp = prime_factorize(m);
    ll ans = 1;
    for(auto e : mp){
        ans = (ans * comb(e.second + n - 1,e.second) ) % mod;
    }

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


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

int main() {
    string s, t; cin >> s >> t;
    vector<vector<int> > moji(30);
    for (int i = 0; i < s.length(); i++) {
        int k = s[i] - 'a';
        moji[k].push_back(i);
    }
    int ind = 0, k = 0;
    for (int i = 0; i < t.length(); i++) {
        int x = t[i] - 'a';
        if (moji[x].size() == 0) {
            cout << -1 << endl;
            return 0;
        } else {
            int n = moji[x].size() - 1;
            if (moji[x][n] < ind) {
                k++;
                ind = moji[x][0] + 1;
            } else {
                int ng = -1, ok = n;
                while (ok - ng != 1) {
                    int med = (ok + ng) / 2;
                    if (ind <= moji[x][med]) {
                        ok = med;
                    } else {
                        ng = med;
                    }
                }
                ind = moji[x][ok] + 1;
            }
        }
    }
    cout << (ll)k * s.length() + ind << endl;
}


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

Measured memory_bytes: 572
import java.util.*;
import java.io.*;

public class Main {

	static int[] a;
	static long[][] dp;
	static final int mod = 998244353;
	static long base;
	static long modInv;

	public static long dp(int idx, int rem) {
		if (rem < 0)
			return 0;
		if (rem == 0) {
			return base;
		}
		if (idx == a.length)
			return 0;
		if (dp[idx][rem] != -1)
			return dp[idx][rem];
		return dp[idx][rem] = (dp(idx + 1, rem) + modInv * dp(idx + 1, rem - a[idx])) % mod;

	}

	public static long modpow(int a, int e) {
		if (e == 0)
			return 1;
		long p = modpow(a, e / 2);
		if (e % 2 == 0)
			return (p * p) % mod;
		else
			return a * p % mod * p % mod;
	}

	public static long modInv(int a) {
		return modpow(a, mod - 2) % mod;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int s = sc.nextInt();
		a = sc.nextIntArr(n);
		dp = new long[n][s + 1];
		for (long[] x : dp)
			Arrays.fill(x, -1);
		base = modpow(2, a.length);
		modInv = modInv(2);
		pw.println(dp(0, s));
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}

	}

}


Measured memory_bytes: 97000
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>


using namespace std;


void security()
{
  string s;
  cin >> s;

  for (int i = 1; i < s.size(); ++i)
  {
    if (s[i - 1] == s[i])
    {
      cout << "Bad\n";
      return;
    }
  }
  cout << "Good\n";
}


void fifty_fify()
{
  string s;
  cin >> s;

  sort(s.begin(), s.end());

  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes\n";
  else cout << "No\n";
}


void dodecagon()
{
  int r;
  cin >> r;

  cout << 3 * r * r << "\n";
}


void harmony()
{
  int a, b;
  cin >> a >> b;

  if (a % 2 == b % 2) cout << (a + b) / 2 << "\n";
  else cout << "IMPOSSIBLE\n";
}


void transfer()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << max(0, c - (a - b)) << "\n";
}


void A_137()
{
  int a, b;
  cin >> a >> b;

  cout << max(a + b, max(a - b, a * b)) << "\n";
}


void red_or_not()
{
  int a;
  cin >> a;
  string s;
  cin >> s;

  if (a >= 3200) cout << s << "\n";
  else cout << "red\n";
}


void tenki()
{
  string s, t;
  cin >> s >> t;

  int cnt = 0;
  for (int i = 0; i < 3; ++i)
  {
    if (s[i] == t[i]) ++cnt;
  }
  cout << cnt << "\n";
}


void password()
{
  int n;
  cin >> n;

  cout << pow(n, 3) << "\n";
}





void buffet()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 0; i < n - 1; ++i) cin >> c[i];

  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    ans += b[a[i] - 1];
    if (i > 0 && a[i - 1] + 1 == a[i]) ans += c[a[i - 1] - 1];
  }
  cout << ans << "\n";
}


int main()
{
  //security();
  //fifty_fify();
  //dodecagon();
  //harmony();
  //transfer();
  //A_137();
  //red_or_not();
  //tenki();
  //password();


  buffet();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

	int n,a[51],b[51],m,u[21],v[21];
	vector<int> t[51];

	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		cin>>a[i]>>b[i];
		t[a[i]].push_back(b[i]);
		t[b[i]].push_back(a[i]);
	}

	cin>>m;
	for(int i=0;i<m;i++)
	{
		cin>>u[i]>>v[i];
	}

	int rnk[51];
	memset(rnk,-1,sizeof(rnk));
	rnk[1]=0;
	queue<int> q;
	q.push(1);

	vector<int> g[51];
	int par[51];
	par[1]=0;

	while(q.size())
	{
		int p=q.front();
		q.pop();

		for(int i:t[p])
		{
			if(rnk[i]!=-1) continue;
			rnk[i]=rnk[p]+1;
			g[p].push_back(i);
			par[i]=p;
			q.push(i);
		}
	}

	int lca[51][51];
	memset(lca,-1,sizeof(lca));

	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		{
			int l=i;
			int r=j;
			if(rnk[l]>rnk[r]) swap(l,r);
			while(rnk[l]!=rnk[r])
				r=par[r];

			while(l!=r)
				r=par[r],l=par[l];

			lca[i][j]=l;
		}


	ll res=1LL<<(n-1);

	priority_queue<P> qq;
	for(int i=0;i<=n;i++) if(g[i].size()==0) qq.push({rnk[i],i});

	for(int i=1;i<(1<<m);i++)
	{
		int pl[51];
		int su[51][51];
		memset(pl,0,sizeof(pl));
		memset(su,0,sizeof(su));

		int cnt=0;
		for(int j=0;j<m;j++)
		{
			if((i&(1<<j))==0) continue;
			int l=lca[u[j]][v[j]];
			pl[l]-=2;
			pl[u[j]]++;
			pl[v[j]]++;
			cnt++;
		}
		cnt%=2;

		priority_queue<P> q=qq;
		bool used[51];
		fill(used,used+n+1,false);

		while(q.size())
		{
			P pp=q.top();
			q.pop();
			int p=pp.second;
			if(used[p]) continue;
			used[p]=true;
			pl[par[p]]+=pl[p];
			su[p][par[p]]=pl[p];
			su[par[p]][p]=pl[p];
			if(p==1) continue;
			q.push({pp.first-1,par[p]});
		}

		int fcnt=0;
		for(int j=0;j<n-1;j++) fcnt+=su[a[j]][b[j]]==0;

		res+=(1-2*cnt)*(1LL<<fcnt);
	}

	cout<<res<<endl;

    return 0;
}

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

using namespace std;

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



int main(){

  int d,n;
  cin >> d >> n;
  if (n!=100) cout << pow(100,d)*n << endl;
  else cout << int(pow(100,d)*(n+1))<< endl;

  return 0;
}


Measured memory_bytes: 256