akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << "," << el.second << "] "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll L,R;

int input(){
    #ifdef __LOCAL
        fs::path path_to_file = __FILE__;
        fs::path input,output;
        input = output = path_to_file.parent_path();
        input += string("/input/") + string(path_to_file.stem()) + string(".txt");
        output += string("/output/") + string(path_to_file.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> L >> R;
    return 0;
}

int solve(){
    if((R-L)>=2019) {cout << 0 << endl; return 0;}
    L%=2019;
    R%=2019;
    if(L>=R) {cout << 0 << endl; return 0;}
    int ans=2018*2018;
    for (int i = L; i < R; i++){
    for (int j = i+1; j <= R; j++) ans=min(ans,(i*j)%2019);
    }
    
    cout << ans%2019 << endl;
    return 0;
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

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

  vector<int> A(N+2);
  vector<int> B(N+1);
  vector<int> X(N+1);
  
  A[0] = 0;
  FORQ(i,1,N){
    cin>>A[i];
  }
  A[N+1] = 0;

  int XX=0;
  FORQ(i,0,N){
    B[i] = abs(A[i+1] - A[i]);
    XX+=B[i];
  }

  FORQ(i,1,N){
    X[i] = XX - (B[i-1] + B[i]) + abs(A[i+1] - A[i-1]);
    cout<<X[i]<<endl;
  }
  
  
  return 0;
}



Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	string arr[] = {"Sunny", "Cloudy", "Rainy"};
	string s;
	int i;
	cin >> s;
	fo(i, 0, 3){
		if(s == arr[i])
		break;
	}
	if(i == 2)
	cout << arr[0];
	else
	cout << arr[i + 1];
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S, T;
  cin >> S >> T;
  ll ans = 0;
  for (ll i = 0; i < S.size(); ++i) {
    if (S.at(i) != T.at(i)) {
      ans += 1;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int A[3][10], B[3][10], C[3][10], D[3][10];
int main() {
   int n;
   cin >> n;
   rep(i, n) {
      int b, f, r, v;
      cin >> b >> f >> r >> v;
      b--, r--, f--;
      if (b == 0) {
         A[f][r] += v;
      } else if (b == 1) {
         B[f][r] += v;
      } else if (b == 2) {
         C[f][r] += v;
      } else if (b == 3) {
         D[f][r] += v;
      }
   }
   rep(i, 3) {
      rep(j, 10) { printf(" %d", A[i][j]); }
      cout << endl;
   }
   printf("####################\n");
   rep(i, 3) {
      rep(j, 10) { printf(" %d", B[i][j]); }
      cout << endl;
   }
   printf("####################\n");
   rep(i, 3) {
      rep(j, 10) { printf(" %d", C[i][j]); }
      cout << endl;
   }
   printf("####################\n");
   rep(i, 3) {
      rep(j, 10) { printf(" %d", D[i][j]); }
      cout << endl;
   }

   return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<int(n);i++)
typedef pair<int,int> P;
#define fi first
#define se second
char maze[1000][1000];
int d[1000][1000];
int w,l,n,ans=0;
int sx,sy,ex,ey;
#define INF 100000
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
int bfs(int times){//return partial ans, assign coordinate
	queue<P> que;
	forn(i,l) forn(j,w) d[i][j]=INF;
	que.push(P(sx,sy));
	d[sx][sy]=0;
	while(que.size()){
		P p = que.front(); que.pop();
		if(maze[p.fi][p.se]=='1'+times){
			sx=p.fi;
			sy = p.se;
			maze[p.fi][p.se] = '.';
			return d[sx][sy];
		}
		forn(i,4){
			int tx = p.fi+dx[i],ty=p.se+dy[i];
			if(tx>=0&&tx<l&&ty>=0&&ty<w&&maze[tx][ty]!='X'&&d[tx][ty]==INF) {
				d[tx][ty] = d[p.fi][p.se]+1;
				que.push(P(tx,ty));
			}
		}
	}
}
int main(){
	cin>>l>>w>>n;//l is x, w is y
	forn(i,l)
		forn(j,w){
		cin>>maze[i][j];
		if(maze[i][j]=='S'){
			sx = i;
			sy = j;
			maze[i][j]= '.';
		}
		}
	forn(i,n){
		ans+=bfs(i);
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 7888
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): pass
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, w = LI()
wv = LIR(n)
vv = 10 ** 5
dp = [INF] * (vv + 1)
dp[0] = 0
for i in range(n):
    wi, vi = wv[i]
    for j in range(vv, vi - 1, -1):
        dp[j] = min(dp[j], dp[j - vi] + wi)

for i in range(vv, -1, -1):
    if dp[i] <= w:
        print(i)
        exit()


Measured memory_bytes: 92352
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
using namespace std;

int main(void){
  int N,M;
  cin >> N >> M;
  int l;
  vector<int> A(M);
  for(int i=0;i<M;i++){
    cin >> l;
    A[i] = l;
  }

  int sum=0;
  for(int i=0;i<M;i++){
    sum = sum+A[i];
  }
  int answer=0;
  if(sum>N) answer=-1;
  else answer=N-sum;
  printf("%d\n",answer);
  return 0;
}

Measured memory_bytes: 3728
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    /*long long*/ int h[n];
    for(int i=0; i<n; i++){
        cin >> h[i];
    }
    /*
    for(int i=0; i<(n-1); i++){
        cout << h[i] << ":" << h[i+1] << endl;
        if(h[i] >= h[i+1]+2){
            cout << "No" << endl;
            return 0;
        }else if(h[i] == h[i+1]+1){
            h[i] -= 1;
            if(i > 0){
                if(h[i] < h[i-1]){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    */
    int big = 0;
    for(int i=0; i<n; i++){
        big = max(big, h[i]);
        if(big >= (h[i]+2)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#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());

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

ll N, K;

vector<ll> d;
vector<vector<ll>> A;

void solve() {
  vector<int> s(N);

  for (auto vs : A) {
    for (auto v : vs) {
      s.at(v - 1)++;
    }
  }

  ll cnt = 0;
  for (auto v : s) {
    if (v == 0) {
      cnt++;
    }
  }

  cout << cnt << endl;
}

int main() {
  cin >> N >> K;
  d.resize(K);
  A.resize(K);
  for (int i = 0; i < K; i++) {
    cin >> d.at(i);
    for (int j = 0; j < d.at(i); j++) {
      ll v;
      cin >> v;
      A.at(i).push_back(v);
    }
  }

  solve();

  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;
	vector<int> A(N, 0);
	REP(i, N) {
		int a;
		cin >> a;
		A[a]++;
	}
	
	bool ret = true;
	int stVal = IsEven(N) ? 1 : 0;
	for (int i = stVal; i < N; i += 2) {
		if (i == 0) {
			if (A[i] != 1) {
				ret = false;
			}
		} else {
			if (A[i] != 2) {
				ret = false;
			}
		}
	}
	if (!ret) {
		cout << 0 << endl;
		return 0;
	}
	
	ll ans = 1;
	REP(i, N / 2) {
		ans *= 2;
		ans %= MOD;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    int A,B,K;
    scanf("%d %d %d",&A,&B,&K);

    for (int i = 0; i < K; i++)
    {
        switch (i % 2)
        {
        case 0:
            if ((A % 2) == 1){
                A--;
            }
            B += A / 2;
            A = A / 2;
            break;
        case 1:
            if ((B % 2) == 1){
                B--;
            }
            A += B / 2;
            B = B / 2;
            break;
        }
    }
    printf("%d %d",A,B);
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(ALL(p));
    int sum = 0;
    rep(i, n - 1) sum += p[i];
    sum += (p[n - 1] / 2);

    OP(sum);
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if(x->right != NIL) return treeMinimum(x->right);
  Node y;
  y = x->p;
  while(y !=NIL && x == y->right){
    x = y;
    y = y->p;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->p = y->p;

  if(y->p == NIL) root = x;
  else if(y == y->p->left) y->p->left = x;
  else y->p->right = x;

  if(y != z) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->p = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u)
{
  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
  else return;
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }
  else return;
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20452
import numpy as np

a,b,h,m = map(int,input().split())

cita = abs(((360/(12*60)) * (h*60+m)) - ((360/60) * m))
if(cita > 180):
	cita = abs(cita - 360)
cita = np.radians(cita)
ans = (a**2)+(b**2)-(2*a*b*(np.cos(cita)))
ans = np.sqrt(ans)

print(ans)

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

int main(){

  double xa,xb,c,a,b,h,m,z;;
    cin >>a>>b>>h>>m;
  z=h*60+m;
  if(xb>xa){c=a*a+b*b-2*a*b*cos(m*6*2/360*M_PI-z/360*M_PI);
    cout<<sqrt(c)<<endl;}
  else{c=a*a+b*b-2*a*b*cosl(z/360*M_PI-m*6*2/360*M_PI);
    cout<<fixed<<setprecision(20)<<sqrt(c)<<endl;}
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


ll ketasum(ll x) {
    ll sum  = 0;
    while (x > 0) {
        sum += x % 10;
        x = x / 10;
    }
    return sum;
}

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

    ll tmp = 1;
    ll tasu = 1;
    vll stk;
    stk.pb(1);
    ll x = 0;

    while (x <= k) {
        //cout << x << " " << stk.size() << endl;
        if (tmp * ketasum(tmp + tasu) <= (tmp + tasu) * ketasum(tmp)) {
            tmp += tasu;
            stk.pb(tmp);
            x++;
        }
        else {
            stk.pop_back();
            tmp = stk.back();
            tasu *= 10;
            tmp += tasu;
            stk.pb(tmp);
        }
    }


    rep(i, k) {
        cout << stk[i] << endl;
    }

}

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

int main(){
  int n;
  std::cin >> n;
  std::cout << n+n*n+n*n*n << '\n';


  return 0;
}


Measured memory_bytes: 3544
n, l = map(int,input().split())
ans = 0
pre = 0
up_acc = 0
down_acc = 0
for i in range(n):
  length = int(input())
  time = l - length
  if length > pre:
    up_acc += time
    if down_acc > ans:
      ans = down_acc
    down_acc = time
  else:
    down_acc += time
    if up_acc > ans:
      ans = up_acc
    up_acc = time
  pre = length
else:
  ans = max(ans, up_acc, down_acc)
print(ans)


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N;
    cin >> N;
    vector<pair<int, int>> D(N);
    REP(i, N) {
        int A;
        cin >> A;
        D[i] = make_pair(A, i+1);
    }
    sort(D.begin(), D.end());

    REP(i, N) {
        cout << D[i].second;
        if (i == N-1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

Vec v, w;
VecB fin;
Vec2<ll> dp;

ll f(ll m, ll l){
	// co({m, l});
	if (l < 0) return -LINF;
	if (m >= 1024) return max(f(m / 2, l), f(m / 2, l - w[m]) + v[m]);
	if (!fin[m / 2]) f(m / 2, l);
	if(!fin[m]){
		rep(i, 100005) dp[m][i] = dp[m / 2][i];
		rep(i, 100005) if(i - w[m] >= 0) chmax(dp[m][i], dp[m / 2][i - w[m]] + v[m]);
		fin[m] = true;
	}
	return dp[m][l];
}

int main(void){
	ll n;
	cin >> n;
	v.resize(n + 1);
	w.resize(n + 1);
	repn(i, n) cin >> v[i] >> w[i];

	fin.assign(1024, false);
	fin[0] = true;
	dp.resize(1024);
	rep(i, 1024) dp[i].assign(100005, 0);

	ll q;
	cin >> q;
	rep(i, q){
		ll m, l;
		cin >> m >> l;
		co(f(m, l));
	}

	return 0;
}


Measured memory_bytes: 810256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007

using namespace std;

void input() {
	string s;
	cin>>s;
	
	if(s[s.size()-1] == 's') {
		s += "es";
	}
	else {
		s += 's';
	}
	
	cout<<s;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	input();

	return 0;
}



Measured memory_bytes: 3664
K,A,B = map(int,input().split())

ans = K+1
if A+2 >= B:
    print(ans)
    exit()

K -= (A-1)
if K < 0:
    print(ans)
    exit()

b = A
b += (K//2) * (B-A)
b += K%2
print(max(ans, b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

class UnionFind {
  private:
    vector<int> parent;
    vector<int> rank;

  public:
    UnionFind(int size) : parent(size), rank(size, 0) {
      for (int i = 0; i < size; i++) {
        parent[i] = i;
      }
    }

    int find(int x) {
      if (parent[x] == x) {
        return x;
      } else {
        return parent[x] = find(parent[x]);
      }
    }

    void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x == y) return;

      if (rank[x] < rank[y]) {
        parent[x] = y;
      } else {
        parent[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
      }
    }

    bool same(int x, int y) {
      return find(x) == find(y);
    }
};

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

  ll n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
  }

  vector<ll> ans(m);
  ans[m-1] = n*(n-1)/2;

  UnionFind uf(n+1);
  vector<int> size(n+1, 1);


  for (int i = m-1; i > 0; i--) {
    ans[i-1] = ans[i];
    if (!uf.same(a[i], b[i])) {
      ll as = size[uf.find(a[i])];
      ll bs = size[uf.find(b[i])];
      ans[i-1] -= as*bs;
      uf.unite(a[i], b[i]);
      size[uf.find(a[i])] = as + bs;
    }
  }

  rep(i, m) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    int N; cin >> N;
    vector<string> s(N);
    rep(i, N) { cin >> s[i]; sort(s[i].begin(), s[i].end()); }
    sort(s.begin(), s.end());
    ll jj = 1, ans = 0;
    rep(i, N - 1) {
        if (s[i] == s[i + 1]) {
            ++jj;
        }
        else {
            ans += jj * (jj - 1) / 2;
            jj = 1;
        }
    }
    if (jj > 1) { ans += jj * (jj - 1) / 2; }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 99999999;

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

typedef long long ll;

using namespace std;



/*
class LightSwitchingPuzzle
{
public:
	int minFlips(string s)
	{

	}
}
*/


int main()
{
	int W, Q;
	
	while (cin >> W >> Q)
	{
		if (W == 0 && Q == 0) break;
		vector<bool> wall(W, true);
		map<int, pair<int, int> > cat;
		for (int i=0; i<Q; i++)
		{
			char t;
			int id, w;
			cin >> t;
			if (t == 's')
			{
				cin >> id >> w;
				bool can_sleep = false;
				for (int j=0; j<=W-w; j++)
				{
					bool found = true;
					for (int k=0; k<w; k++)
					{
						if (!wall[j+k])
						{
							found = false;
							break;
						}
					}
					if (found)
					{
						for (int k=0; k<w; k++)
						{
							wall[j+k] = false;
						}
						cat[id] = make_pair(j, j+w);
						cout << j << endl;
						can_sleep = true;
						break;
					}
				}
				if (!can_sleep)
				{
					cout << "impossible" << endl;
				}
			} else {
				cin >> id;
				int from = cat[id].first;
				int to = cat[id].second;
				for (int j=from; j<to; j++)
				{
					wall[j] = true;
				}
			}
		}
		cout << "END" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
import collections
N=int(input())
A=[int(x) for x in input().split()]
AA=sorted(A)
c=collections.Counter(A)
third=N//3
answer="No"

#文字が全部0
if all(a==0 for a in A):
  answer="Yes"

#0aa0aaという並びに出来る
#0がN/3個,aが2N/3個で数字は二種類
elif len(c)==2 and N%3==0:
  if all(a==0 for a in AA[:third]):
    answer="Yes"
     
#abc,abc...,abcという並びに出来る
#aがN/3個,bがN/3個,cがN/3個で数字は三種類
elif len(c)==3 and N%3==0:
  if A.count(AA[0])==third and \
  A.count(AA[third])==third and \
  A.count(AA[2*third])==third:
    if bin(AA[0]^AA[third])==bin(AA[2*third]) and \
    bin(AA[third]^AA[2*third])==bin(AA[0]) and \
    bin(AA[2*third]^AA[0])==bin(AA[third]):
      answer="Yes"
    
print(answer)

Measured memory_bytes: 14460
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,k,ans=0,tmp;
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n){
        cin >> tmp;
        ans+=min(tmp,abs(tmp-k));
    }
    cout << 2*ans << endl;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    long long h[n], a[n], ans[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        h[i]--;
    }
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) ans[i] = 0;
    set<int> ht;
    ht.insert(h[0]); ans[h[0]] = a[0];
    for (int i = 0; i < n; i++) {
        set<int>::iterator it = ht.lower_bound(h[i]);
        if (it == ht.begin()) {
            ht.insert(h[i]); ans[h[i]] = a[i];
        } else {
            --it;
            ht.insert(h[i]); ans[h[i]] = ans[*it] + a[i];
        }
        it = ht.upper_bound(h[i]);
        vector<int> to_erase;
        while (it != ht.end()) {
            if (ans[*it] <= ans[h[i]]) to_erase.push_back(*it);
            else break;
            ++it;
        }
        for (int j = 0; j < to_erase.size(); j++) ht.erase(to_erase[j]);
    }
    long long ansv = 0;
    for (int i = 0; i < n; i++) ansv = max(ansv, ans[i]);
    cout << ansv;
    return 0;
}


Measured memory_bytes: 14336
#include <stdio.h>
int	cnt = 0, a = 0, b = 0, c = 0;
int	tmp, A, B, C, X;

int	main(void)
{
if( tmp= scanf("%d", &A) == EOF )printf("faulure500(%d %d %d %d)\n", A,B,C,X );	//500
if( tmp= scanf("%d", &B) == EOF )printf("faulure100(%d %d %d %d)\n", A,B,C,X );	//100
if( tmp= scanf("%d", &C) == EOF )printf("faulure50(%d %d %d %d)\n", A,B,C,X );	//50
if( tmp= scanf("%d", &X) == EOF )printf("faulureP(%d %d %d %d)\n", A,B,C,X );	//PRICE
if(( A<0 || A>50 )||( B<0 || B>50 )||( C<0 || C>50 )
   ||( X<50 || X>20000 )
   ||( X % 50 != 0 )) printf("faulure(%d %d %d %d)\n", A,B,C,X );

  for( a = 0; a <= A; ++a )
  {
    //printf("a(%d %d %d) (%d) %d %d %d\n", A,B,C,X,(a*500),(b*100),(c*50) );
    if((a*500) > X) continue;

    for( b = 0; b <= B; ++b )
    {
      //printf("b(%d %d %d) (%d) %d %d %d\n", A,B,C,X,(a*500),(b*100),(c*50) );
      if((a*500)+(b*100) > X) continue;

      for( c = 0; c <= C; ++c )
      {
        //printf("c(%d %d %d) (%d) %d %d %d\n", A,B,C,X,(a*500),(b*100),(c*50) );
        if((a*500)+(b*100)+(c*50) > X) continue;

        //cnt += p500( a, b, c, X );
        if((a*500)+(b*100)+(c*50) == X)
        {
          ++cnt;
          //printf("%d (%d %d %d) (%d) %d %d %d\n", cnt, A,B,C,X,(a*500),(b*100),(c*50) );
        }
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;

int main() {
	
	int n;
	cin >> n;
	vector<int>p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	int ans = 0,x=0;
	for (int i = 1; i < n; i++) {
		if (p[i] <= p[i - 1]) {
			x++;
			ans = max(ans, x);
		}
		else x = 0;
	}
	cout << ans << endl;


	return 0;


}

Measured memory_bytes: 768
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		int count0=0,count1=0;
		for(int i=0;i<s.length();i++) {
			if(s.substring(i,i+1).equals("0"))count0++;
			else count1++;
		}
		System.out.println((int)Math.min(count0, count1)*2);
	}
}



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

//  a^b % m
long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

int main()
{
    long long N, M;
    cin>>N>>M;

    long long MOD = 1000000007LL;
    vector<long long> F(M+1);
    F[0] = 1;
    for (int i=1; i<=M; i++)
        F[i] = F[i-1]*i%MOD;

    auto C = [&](long long x, long long y)
    {
        return F[x]*powmod(F[y], MOD-2, MOD)%MOD*powmod(F[x-y], MOD-2, MOD)%MOD;
    };

    long long ans = 0;
    for (int i=0; i<=N; i++)
        ans = (ans+(1-i%2*2)*C(M, i)%MOD*C(M-i, N-i)%MOD*C(M-i, N-i)%MOD*C(N, i)%MOD*F[i]%MOD*F[N-i]%MOD*F[N-i]%MOD+MOD)%MOD;
    cout<<ans<<endl;
}


Measured memory_bytes: 6696
#include <iostream>

using namespace std;

int main(void){
  int N;
  int ans=0;
  cin>>N;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(i%2==0 && a%2==1){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0; 
}

Measured memory_bytes: 3620
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

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

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

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

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



int main(){
    int h,w,n;
    cin >> h >> w >> n;
    if(h < w)swap(h,w);

    P((n+h-1)/h);
    return  0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

using ll = long long;

ll c(ll x)
{
    return x * (x + 1) / 2;
}

int main()
{
    int N;
    cin >> N;
    while (N > 0) {
        int L = 0, R = N;
        while (R - L > 1) {
            int mid = (L + R) / 2;
            if (c(mid) < N) {
                L = mid;
            } else {
                R = mid;
            }
        }
        cout << R << endl;
        N -= R;
    }        
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
#define R register
#define MAXN 100010
using namespace std;
bool cmp(int u,int v)
{
	return u < v;
}
struct Heap{
	int a[MAXN];
	int size;
	Heap()
	{
		size = 0;
	}
	void push(int u)
	{
		a[++size] = u;
		push_heap(a+1,a+size+1,cmp);
	}
	int pop()
	{
		int tmp = a[1];
		pop_heap(a+1,a+size--+1,cmp);
		return tmp;
	}
	bool empty()
	{
		return size <= 1;
	}
}H;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for(R int i = 1; i <= n; i++) {
		int w; scanf("%d",&w); H.push(w);
	}
	for(R int i = 1; i <= m; i++){
		int w = H.pop(); w >>= 1; H.push(w);
	} long long ans = 0;
	for(R int i = 1; i <= n; i++) ans += H.pop();
	printf("%lld",ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
    
int main(){
	int x;
    cin>>x;
    int s=x%100;
    int i=0;
    int k=5;
    while(s>0){
        if(s>=k){
            s-=k;
            i++;
        }else{
            k--;
        }
    }
    int ans=1;
    if(x/100<i){
        ans=0;
    }
    OUT(ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(string, s);
	int ans = 0;
	bool ok = false;
	REP(i, (s.size() + 1) / 2) {
		ok = false;
		REP(j, i) {
			if (s[j] != s[i + j]) break;
			if (j == i - 1) ok = true;
		}
		if (ok) ans = i * 2;
	}
	OUT(ans)BR;
	
  
  return 0;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	string s;
	cin >> s;
	repp(i,0,s.size())
	{
		if(i%2==0 && s[i]=='L')
		{
			cout << "No" << endl;
			return 0;	
		}
		if(i%2==1 && s[i]=='R')
		{
			cout << "No" << endl;
			return 0;
		}
		
	}
	cout << "Yes" << endl;
}


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

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

#define dump(x) cout << #x << ":" << x << endl

#define MAX_R 10
#define MAX_C 10000

int r, c;
int brd[MAX_R][MAX_C];

void change_row(int j)
{
	rep(i, c)
		brd[j][i] = (brd[j][i] + 1) % 2;
}

void change_col(int i)
{
	rep(j, r)
		brd[j][i] = (brd[j][i] + 1) % 2;
}

void count_col(int i, int *b, int *w)
{
	rep(j, r) {
		if (brd[j][i]==1)
			(*b)++;
		else
			(*w)++;
	}
}

int main()
{
	while (cin >> r >> c, r|c) {
		rep(j, r) {
			rep(i, c) {
				cin >> brd[j][i];
			}
		}

		int buf[MAX_R][MAX_C];
		memcpy(buf, brd, sizeof(brd));
		int ans = 0;
		rep(b, 1<<r) {
			memcpy(brd, buf, sizeof(buf));

			rep(j, r) {
				if ((b>>j)&1)
					change_row(j);
			}

			rep(i, c) {
				int b, w;
				b = w = 0;
				count_col(i, &b, &w);
				if (b > w)
					change_col(i);
			}

			int local_ans = 0;
			rep(j, r) {
				rep(i, c) {
					if (brd[j][i] == 0)
						local_ans++;
				}
			}
			ans = max(ans, local_ans);
		}

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

Measured memory_bytes: 1936
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s, t;
    cin >> s >> t;

    for (int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

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

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

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

inline void print() { cout << "\n"; }

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

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

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(string, s);
    s.pop_back();
    while (s.size()) {
        if (s.length() & 1) {
            s.pop_back();
        }
        const string t = s.substr(0, s.length() / 2);
        if (t + t == s) {
            print(s.length());
            return 0;
        }
        s.pop_back();
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define vi vector<int>
#define pb push_back
using namespace std;
const int N=1e5+5;
const ll mod=1e9+7;
ll ans=1,jian=2;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		ans=ans*3%mod;
		if(s[i]=='0')
			ans=(ans-jian+mod)%mod;
		else
			jian=jian*2%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

r=n0()

print(2*r*3.141592)

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    //min(a + b + 1, c)
    if (a + b + 1 < c)
        cout << a + b + b + 1 << endl;
    else
        cout << b + c << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>	
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	int ans{},a{},b{},tem{},d{},dd{};
	cin>>a>>b;
	For(i,a,b+1)
	{
		tem=i;
		d=tem/10000;
		dd=(tem%10000)/1000;
		tem%=100;
		if(tem/10==dd && tem%10==d)ans++;
	}
	cout<<ans<<'\n';
	//system("pause");
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	int N, M, L;
	cin >> N >> M >> L;

	int adj[300][300];
	ini(adj, 0x3f);

	for (int a, b, c, i = 0; i < M; ++i) {
		cin >> a >> b >> c;
		--a, --b;
		adj[a][b] = adj[b][a] = c;
	}

	for (int k = 0; k < N; ++k)
		for (int i = 0; i < N; ++i) if (adj[i][k] != 0x3f3f3f3f)
			for (int j = 0; j < N; ++j)
				adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);

	for (int i = 0; i < N; ++i)
		for (int j = 0; j < N; ++j)
			adj[i][j] = adj[i][j] <= L ? 1 : 0x3f3f3f3f;

	for (int k = 0; k < N; ++k)
		for (int i = 0; i < N; ++i) if (adj[i][k] != 0x3f3f3f3f)
			for (int j = 0; j < N; ++j)
				adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);

	int Q;
	cin >> Q;

	for (int s, t; Q--; ) {
		cin >> s >> t;
		if (adj[--s][--t] == 0x3f3f3f3f) cout << -1 << endl;
		else cout << adj[s][t] - 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 896
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = sum(b)
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        ans += c[a[i] - 1]
print(ans)


Measured memory_bytes: 3060