akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int sum (int num) {
  int total = 0;
  for(int i=0;i<7;i++) {
    total += num%10;
    num -= num%10;
    num = num/10;
  }
  return total;
}

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int answer=0;
  for(int i=0;i<N;i++) {
    if(A<=sum(i+1)&&sum(i+1)<=B) {
      answer+=i+1;
    }
  }
  cout << answer << endl;
}

    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void upd(vector<int> &t,int l,int r,int v,int x,int q){
  if(x+1<=l||x>=r)
    return;
  if(l==x&&r==x+1){
    t.at(v)=q;
    return;
  }
  int h=(l+r)/2;
  upd(t,l,h,v*2,x,q);
  upd(t,h,r,v*2+1,x,q);
  t.at(v)=max(t.at(v*2),t.at(v*2+1));
  return;
}
int que(vector<int> &t,int l,int r,int v,int lq,int rq){
  if(rq<=l||lq>=r)
    return 0;
  if(lq<=l&&rq>=r)
    return t.at(v);
  int h=(l+r)/2;
  return max(que(t,l,h,v*2,lq,rq),que(t,h,r,v*2+1,lq,rq));
}
int main(){
  int n;
  cin>>n;
  vector<vector<int>> ai(n);
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    ai.at(i)={a,i};
  }
  sort(ai.begin(),ai.end());
  vector<int> c(n);
  c.at(ai.at(0).at(1))=0;
  int m=0;
  for(int i=1;i<n;i++){
    m+=(ai.at(i).at(0)>ai.at(i-1).at(0)?1:0);
    c.at(ai.at(i).at(1))=m;
  }
  m++;
  vector<int> t(m*4,0);
  int a=0;
  for(int i=0;i<n;i++){
    int q=que(t,0,m,1,c.at(i),m);
    a=max(a,q+1);
    upd(t,0,m,1,c.at(i),q+1);
  }
  cout<<a<<endl;
}

Measured memory_bytes: 10428
#include<stdio.h>
#include<string.h>
int main(){
  char s[26];
  char c[10];
  int n,i,j,k,l;
  char w;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",c,s);
    l=strlen(s);
    for(j=strlen(c)-1;j>-1;j--){
      if(c[j]=='C'){
	w=s[0];
	for(k=1;k<l;k++)s[k-1]=s[k];
	s[l-1]=w;
      }
       if(c[j]=='J'){
	w=s[l-1];
	for(k=l-1;k;k--)s[k]=s[k-1];
	s[0]=w;
      }
       if(c[j]=='E'){
	 for(k=0;2*k<l-1;k++){
	   w=s[k];
	   s[k]=s[(l+1)/2+k];
	   s[(l+1)/2+k]=w;
	 }
       }	 
       if(c[j]=='A'){
	 for(k=0;2*k<l-1;k++){
	   w=s[k];
	   s[k]=s[l-k-1];
	   s[l-k-1]=w;
	 }
       }
       if(c[j]=='M'){
	 for(k=0;k<l;k++){
	   if('0'<=s[k]&&s[k]<'9')s[k]++;
	   else if(s[k]=='9')     s[k]='0';
	 }
       }
       if(c[j]=='P'){
	 for(k=0;k<l;k++){
	   if('0'<s[k]&&s[k]<='9')s[k]--;
	   else if(s[k]=='0')     s[k]='9';
	 }
       }
       // printf("%s\n",s);
    }
    printf("%s\n",s);
  }
  return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define inf (1<<29)
#define MAX 80
using namespace std;

bool dp[MAX][MAX][2];
 
int main()
{
  int T;
  while(cin >> T)
    {
      while(T--)
	{
	  rep(i,MAX)rep(j,MAX)rep(l,2)dp[i][j][l] = false;
	  int N;
	  cin >> N;
	  int input[N];
	  rep(i,N) cin >> input[i];
       
	  if(N <= 2)
	    {
	      cout << input[N-1] << endl;
	      continue;
	    }
       
	  int ans = input[N-1];
 
	  REP(cur,1,N-1)
	    {
	      dp[input[cur-1]][input[cur]][cur&1] = true;
	      int R = input[cur+1];
	      rep(L,MAX)
		{
		  rep(M,MAX)
		    {
		      if(!dp[L][M][cur&1])continue;
		      //cout << cur << " cur(" << L << "," << M << "," << R << ")\n";
		      if(M == 0)
			{
			  if(cur+2 < N)
			    {
			      dp[M][R][(cur+1)&1] = true;
			      //cout << cur << " next ( " << M << "," << R << "," << input[cur+2] << ")\n";
			    }
			  else       ans = max(ans,R);
			}
		      else
			{
			  if(cur+2 < N)
			    {
			      dp[M][R][(cur+1)&1] = true;
			      //cout << cur << " next ( " << M << "," << R << "," << input[cur+2] << ")\n";
			      dp[M-1][R+L][(cur+1)&1] = true;
			      //cout << cur << " next ( " << M-1 << "," << R+L << "," << input[cur+2] << ")\n";
			    }
			  else 
			    {
			      ans = max(ans,R+L);
			      //cout << cur << " ans : " << R << "+" << L << "=" << R+L <<  " (" << L << "," << M << "," << R << ")" <<  endl;
			    }
			}
		    }
		}
	      rep(i,MAX)rep(j,MAX)dp[i][j][cur&1] = false;
	    }
	  
	  cout << ans << endl;      
	}
    }
  return 0;
}

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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;


int main(){ _

	int n; cin >> n;
	vector<int> v(n);
	for(int& i : v) cin >> i;

	ll ans = 1000;
	vector<pair<ll,ll>> vaux;
	pair<int,int> pnow = {v[0],v[0]};
	for(int i=0; i < n; i++) {
		pnow.s = max(pnow.s, v[i]);
		if(i < n-1 and v[i] > v[i+1]) {
			vaux.push_back(pnow);
			pnow = {v[i+1],v[i+1]};
		}
	}
	vaux.push_back(pnow);
	for(auto u : vaux) {
		ll times = ans/u.f;
		ans = ans % u.f;
		ans += times*u.s;
	}

	cout << ans << endl;

	return 0;
}


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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<pair<string,ll> > svp;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define PI         2*acos(0.0);
#define lb         lower_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define spc(x)     cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=1,cnt1=0;
    bool flag = false;   /*vector<long long> v,v1;*/
    
    string s,s1;
    cin>>s>>s1;
    x = inf;
    n = s.size()-1, m = s1.size()-1;
    for ( i=0; i<=(n-m); i++){
         cnt = 0;
        for ( j=0; j<=m; j++) cnt += (s[i+j]!=s1[j]);
        x = min(x, cnt);
    }
    cout<<x<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

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

    // ll tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 998244353;
const int INF = 2e18;

int ans[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

signed main() {
    int K;
    cin >> K;
    cout << ans[K - 1] << endl;
}


Measured memory_bytes: 256
const MOD: usize = 1e9 as usize + 7;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let blue_ball: usize = sc.read();
    let c = Combination::new(n * 2 + 1, MOD);

    let red_ball = n - blue_ball;
    for seg in 1..(blue_ball + 1) {
        if seg > blue_ball || seg - 1 > red_ball {
            println!("0");
            continue;
        }
        let free_blue = blue_ball - seg;
        let free_red = red_ball - (seg - 1);
        let ans = c.get(free_blue + seg - 1, free_blue) * c.get(free_red + seg + 1 - 1, free_red);
        println!("{}", ans % MOD);
    }
}

pub struct Combination {
    fact: Vec<usize>,
    inv_fact: Vec<usize>,
    modulo: usize,
}

impl Combination {
    pub fn new(max: usize, modulo: usize) -> Combination {
        let mut inv = vec![0; max + 1];
        let mut fact = vec![0; max + 1];
        let mut inv_fact = vec![0; max + 1];
        inv[1] = 1;
        for i in 2..(max + 1) {
            inv[i] = inv[modulo % i] * (modulo - modulo / i) % modulo;
        }
        fact[0] = 1;
        inv_fact[0] = 1;
        for i in 0..max {
            fact[i + 1] = fact[i] * (i + 1) % modulo;
        }
        for i in 0..max {
            inv_fact[i + 1] = inv_fact[i] * inv[i + 1] % modulo;
        }
        Combination {
            fact: fact,
            inv_fact: inv_fact,
            modulo: modulo,
        }
    }

    pub fn get(&self, x: usize, y: usize) -> usize {
        assert!(x >= y);
        self.fact[x] * self.inv_fact[y] % self.modulo * self.inv_fact[x - y] % self.modulo
    }

    pub fn h(&self, n: usize, r: usize) -> usize {
        self.get(n + r - 1, r)
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
import java.util.*;
class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String str = scan.next();
      	int num_1 = Integer.parseInt(str);
      	str = scan.next();
      	int num_2 = Integer.parseInt(str);
      	str = scan.next();
      	int num_3 = Integer.parseInt(str);
      	if (num_1 == 7){
        	if (num_2 == 5 && num_3 == 5){
            	System.out.println("YES");
            }else{
            	System.out.println("NO");
            }
        }else if (num_2 == 7){
        	if (num_1 == 5 && num_3 == 5){
            	System.out.println("YES");
            }else{
            	System.out.println("NO");
            }
        }else if (num_3 == 7){
        	if (num_2 == 5 && num_1 == 5){
            	System.out.println("YES");
            }else{
            	System.out.println("NO");
            }
        }
    }
}

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

typedef long long ll;
using namespace std;

int n;
ll m, v, p;
vector<ll> a;

bool bin(int i) {
    ll sm = 0;
    ll k = a[i] + m;
    if (k < a[p - 1]) {
        return false;
    }
    sm += (p - 1) * m + (n - i) * m;
    for (int x = p - 1; x < i; x++) {
        sm += max(ll(0), k - a[x]);
    }
    return sm >= m * v;
}

int main() {
    cin >> n >> m >> v >> p;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int l = p - 1;
    int r = n;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (bin(mid)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    cout << l + 1 << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(500*500)
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[] for _ in range(N+1)]

for edge in edges:
    A[edge[0]].append([edge[1],edge[2]])
    A[edge[1]].append([edge[0],edge[2]])

depth = [-1] * (N+1)
depth[1] = 0

def dfs(A,s):
    for v in A[s]:
        if depth[v[0]] == -1:
            depth[v[0]] = depth[s] + v[1]
            dfs(A,v[0])    
dfs(A,1)
for d in depth[1:]:
    if d % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 102104
n=int(input())
a=list(map(int,input().split()))
if min(a)>=0:
    print(n-1)
    for i in range(1,n):
        print(i,i+1)
elif max(a)<0:
    print(n-1)
    for i in range(1,n)[::-1]:
        print(i+1,i)
else:
    m=min(a)
    M=max(a)
    if abs(M)>=abs(m):
        idx=a.index(M)
        cnt=0
        print(2*n-2)
        for i in range(2):
            print(idx+1,2)
        for i in range(2,n):
            print(i,i+1)
            print(i,i+1)
    else:
        idx=a.index(m)
        print(2*n-2)
        for i in range(2):
            print(idx+1,n-1)
        for i in range(2,n)[::-1]:
            print(i,i-1)
            print(i,i-1)


Measured memory_bytes: 3064
/*...........................
.........tank.jpg............
...........................*/

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
 
ll power(ll x, ll y); 
#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 rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_dedges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define in_wedges(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C), v[B].pb(A, C);}
#define in_dwedges(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C);}
#define endl "\n"

const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 18;
const int inf = 2e9;
 
#include <atcoder/segtree>
using namespace atcoder;
int op(int a, int b) { return max(a, b); }
int e() { return 0; }
segtree<int, op, e> seg(300005);

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio

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

    rep(i, 0, n){
        int x;
        cin >> x;

        int l = max(0, x - k);
        int r = min(x + k, 300000);

        int mx = seg.prod(l, r + 1);
        seg.set(x, mx + 1);        
    }

    cout << seg.all_prod();
}   

ll power(ll x, ll y){ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 8344
#include <stdio.h>

int A_l, A_r;
int B_l, B_r;
int C_l, C_r;
int D_l, D_r; 

void Judge(float val, int lr);

int main(void)
{
	float l, r;
	
	while (scanf("%f %f", &l, &r) != EOF){
		Judge(l, 0);
		Judge(r, 1);
	}
	
	printf("%d %d\n%d %d\n%d %d\n%d %d\n", A_l, A_r, B_l, B_r, C_l, C_r, D_l, D_r);
	
	return (0);
}

void Judge(float val, int lr)
{
	if (val >= 1.1){
		(lr == 0) ? A_l++ : A_r++;
	}
	else if (val >= 0.6){
		(lr == 0) ? B_l++ : B_r++;
	}
	else if (val >= 0.2){
		(lr == 0) ? C_l++ : C_r++;
	}
	else {
		(lr == 0) ? D_l++ : D_r++;
	}
}

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

int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	
	unordered_map<ll,ll> mp(N);
	
	bool ok = true;
	
	rep(i,N){
		cin >> A[i];
		auto itr = mp.find(A[i]);
		if(itr != mp.end()){
			ok = false;
		}else{
			mp[A[i]]++;
		}
	}
	
	if(ok){
		cout << "YES" <<  endl;
	}else{
		cout << "NO" << endl;
	}
	
	
	
	
	
	
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <iomanip>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)
#define rad_to_deg(rad) (((rad)/2.0/M_PI)*360.0)
typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N, M, R; cin >> N >> M >> R;
    vector<int> r(R); repp(i, 0, R) cin >> r[i];
    sort(r.begin(), r.end());
    ll d[N+1][N+1];

    const ll INF = 1LL << 60;
    repp(i,0,N+1) {
        repp(j,0,N+1) {
            if (i == j) d[i][j] = 0;
            else d[i][j] = INF;
        }
    }
    repp(i,0,M) {
        int A, B, C; cin >> A >> B >> C;
        d[A][B] = C;
        d[B][A] = C;
    }

    repp(k,0,N+1) {
        repp(i,0,N+1) {
            repp(j,0,N+1) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }

    ll res = 0; repp(i, 1, R) res += d[r[i-1]][r[i]];
    while(next_permutation(r.begin(), r.end())) {
        ll tmp = 0; repp(i, 1, R) tmp += d[r[i-1]][r[i]];
        res = min(res, tmp);
    }
    cout << res << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

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

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

  z=(Node*)malloc(sizeof(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->parent = 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 ) return;
    inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if( u== NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  string com;

  scanf("%d",&n);

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

  return 0;
}


Measured memory_bytes: 22080
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <iostream>
#include <cstdio>

using namespace std;

int main(){

    int N, K;

    scanf("%d%d", &N, &K);

    long long ans = 0;
    long long big = 1;
    while(big < K){
        big *= 2;
    }
    big *= 2;

    ans = max(N - K + 1, 0) * big;

    for(int i = min(N, K - 1); i >= 1; i--){
        int temp = i;
        int count = 1;
        while(temp < K){
            temp *= 2;
            count *= 2;
        }
        ans += (big / count);
    }
    double output = (double)ans / N;
    output /= (double)big;

    printf("%.12lf\n", output);

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long walk = sc.nextInt();
		long teleport = sc.nextInt();
		int arr[] = new int[n+1];
		for(int i=1 ; i<=n ; i++){
			arr[i] = sc.nextInt();	
		}
		long ans = 0;
		for(int i=1 ; i<n ; i++){
			if((arr[i+1]-arr[i])*walk<teleport){
				ans += (arr[i+1]-arr[i])*walk;
			}else{
				ans += teleport;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 50768
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#define lli long long int
#define mod 998244353
using namespace std;
int main(){
	int n;
	cin>>n;
	n%=10;
	if(n==2||n==5||n==4||n==7||n==9)
	cout<<"hon";
	else if(n==0||n==1||n==6|n==8)
	cout<<"pon";
	else
	cout<<"bon";
	
}


Measured memory_bytes: 3636
#include<iostream>
#include <cstdio>
#include<cctype>
#include <algorithm>
#include<string>

using namespace std;

int main(){
	string card,ans;
	int m,h,total_h,act_h;
	
	while(1){
		cin >> card;
		
		if(card == "-") break;
		
		cin >> m;
		total_h = 0;
		
		for(int i = 0; i < m; i++){
			cin >> h;
			total_h += h;
		}

		int n = card.length();		
		
		act_h = 0;
		
		act_h = total_h % n;
		card += card;
		ans = card.substr(act_h,n);
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
package main

import (
	"fmt"
	"math"
)

type group struct {
	stat string
	l, r int
}

func intMax(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	var (
		N, K int
		S    string
	)
	fmt.Scan(&N, &K, &S)

	G := make([]group, N)
	M := 0
	G[0].stat = string(S[0])
	G[0].l = 0
	for i := 1; i < N; i++ {
		if string(S[i]) != string(S[i-1]) {
			G[M].r = i - 1
			M++
			G[M].stat = string(S[i])
			G[M].l = i
		}
	}
	G[M].r = N - 1
	M++

	ans := 0
	for i := 0; i < M; i++ {
		if G[i].stat == "0" {
			end := intMin(i+2*(K-1)+1, M-1)
			ans = intMax(ans, G[end].r-G[i].l+1)
		} else {
			end := intMin(i+2*K, M-1)
			ans = intMax(ans, G[end].r-G[i].l+1)
		}
	}

	fmt.Println(ans)
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N;
ll a[2001];
vector<ll> g[2001];
ll ans;
ll sz[2001];
ll tot[2001],mx[2001];

void dfs(ll v,ll pre){
  ll mxnv=0;
  sz[v]=a[v];
  for(ll nv : g[v]){
    if(nv==pre)continue;
    dfs(nv,v);
    sz[v]+=sz[nv];
    tot[v]+=tot[nv]+sz[nv];
    maxch(mxnv,tot[nv]+sz[nv]);
  }
  for(ll nv : g[v]){
    if(nv==pre)continue;
    if(mxnv==tot[nv]+sz[nv]){
      ll crtsum=tot[v]-2*mx[nv],crtmx=mxnv-2*mx[nv];
      if(2*crtmx<=crtsum) maxch(mx[v],tot[v]/2);
      else maxch(mx[v],crtsum-crtmx+mx[nv]);
    }
  }
  return ;
}

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

  cin>>N;
  {
    string input;
    cin>>input;
    rep(i,input.size())a[i]=input[i]-'0';
  }
  rep(i,N-1){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ll res=1e18;
  rep(r,N){
    rep(i,N)sz[i]=mx[i]=tot[i]=0;
    dfs(r,-1);
    if(2*mx[r]==tot[r]&&tot[r]%2==0){
      minch(res,tot[r]/2);
    }
  }

  if(res==1e18)cout<<-1<<endl;
  else cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列


    if N>=30:
        print('Yes')
    else:
        print('No')



if __name__ == "__main__":
    main()


Measured memory_bytes: 77472
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }



int main(){
  char c;
  cin >> c;
  bool flag = false;
  char vowals[5] = {'a','e','i','o','u'};
  rep(i,5)if(vowals[i] == c)flag = true;
  cout << (flag?"vowel":"consonant") << endl;
}


Measured memory_bytes: 256
<?php
  list($n, $d) = explode(" ", trim(fgets(STDIN)));

  $ans = 0;
  for ($i=0; $i<$n; $i++) {
    list($x, $y) = explode(" ", trim(fgets(STDIN)));
    if($x*$x + $y*$y <= $d*$d) $ans++;
  }

  echo $ans;

Measured memory_bytes: 16204
def main():
    n, m = map(int, raw_input().split())
    min_id = 1
    max_id = n
    for _ in xrange(m):
        l, r = map(int, raw_input().split())
        min_id = max(min_id, l)
        max_id = min(max_id, r)
    print max(0, max_id - min_id + 1)


if __name__ == '__main__':
    main()


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

int main(){
    int n, m, p;
    string s;
    
    cin>>n >>m;
    vector<int> a(n, 0), w(n, 0);
    
    for(int i=0;i<m;i++){
        cin>>p;
        cin>>s;
        
        p--;
        if(!a[p]){
            if(s=="WA"){
                w[p]++;
            }else{
                a[p]=1;
            }
        }
    }
    
    int ans_ac=0, ans_wa=0;
    
    for(int i=0;i<n;i++){
        if(a[i]){
            ans_ac++;
            ans_wa+=w[i];
        }
    }
    
    cout<<ans_ac<<" "<<ans_wa<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
int main() {

	int a, b, c;

	cin >> a >> b >> c;

	if (a == b&&b == c)cout << 1 << endl;
	else if ((a == b&&b != c) || (a == c&&a != b) || (b == c&&b != a))cout << 2 << endl;
	else cout << 3 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define be(v) v.begin(), v.end()
#define ll long long
ll INF = 1e9;
ll mod = 1e9+7;

ll dp[10001];
int main() {
  int a,b,c; cin >> a >> b >> c;
  cout << c-min(c,a-b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
using namespace std;
int main() {
	
	 long long int N, M;
	cin >> N >> M;
	if (N == 1 || M == 1)cout << 1 << endl;
	else if (N * M % 2 == 1)cout << N * M / 2 + 1 << endl;
	else cout << N * M / 2 << endl;
	return 0;
}


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

int main(){
  char a,b;
  cin>>a>>b;
  int x,y;
  if(a=='H'){
    a=1;
  }else{
    a=-1;
  }
  if(b=='H'){
    b=1;
  }else{
    b=-1;
  }
  
  if(a*b==1){
    cout<<'H'<<endl;
  }else{
    cout<<'D'<<endl;
  }
}

Measured memory_bytes: 256
def Q4(x):
    N = x[0][0]  # 木の頂点数
    edge = x[1:N][:]  # 辺とその距離
    Q = x[N][0]  # クエリ数
    K = x[N][1]  # 経由すべき頂点の番号
    query = x[N + 1:][:]  # クエリの内容

    # 木の初期化
    tree = list(range(N))  # adjacent(隣接)のほうがいいかな？
    for idx in range(N):
        tree[idx] = []

    for idx in range(len(edge)):
        # i番目の要素は、節点iに接続されている節点
        # これ以降、-1を足すのは、頂点の添字が1スタートに対しリストは0スタートのため
        a = edge[idx][0] - 1
        b = edge[idx][1] - 1
        c = edge[idx][2]
        tree[a].append([b, c])
        tree[b].append([a, c])

    # Kから各節点への距離を求める
    dist = [0 for i in range(N)]  # 頂点Kからの距離
    isVisit = [False for i in range(N)]  # ある頂点が探索済か
    queue = [K - 1] #幅探索用キュー
    isVisit[K - 1] = True

    while queue:
        u = queue.pop()
        for p in tree[u]:
            v, w = map(int, p)
            if not isVisit[v]:
                isVisit[v] = True
                dist[v] = dist[u] + w
                queue.append(v)

    for q in query:
        print(dist[q[0] - 1] + dist[q[1] - 1])
        
N=int(input())
edge = [[int(i) for i in input().split()] for i in range(N-1)]
Q , K = (int(i) for i in input().split())
query = [[int(i) for i in input().split()] for i in range(Q)]
l = [[N]]+edge+[[Q,K]]+query
Q4(l)

Measured memory_bytes: 89924
_,A,B,C=$<.map{|s|s.split.map(&:to_i).sort};f=->a,b{i=0;b.map{|n|i+=1while a[i]&&a[i]<n;i}};c=[s=0]+f[A,B].map{|n|s+=n};p eval f[B,C].map{|n|c[n]}*?+

Measured memory_bytes: 131880
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>

#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;
int dp[1001][1001];//dp[y][x];
//??????????????????
string x,y;
void solve(){
		cin >> x >> y ;
		memset(dp,10000,1001*1001);
		REP(i,x.size()+1){
			  dp[0][i] = i;
		}
		REP(i,y.size()+1){
			  dp[i][0] = i;
		}
		FOR(i,1,x.size()+1){
			FOR(j,1,y.size()+1){
				if(x[i-1]==y[j-1]){
					dp[j][i] = dp[j-1][i-1];
				}
				else {
					dp[j][i] = min ( 1 + min(dp[j-1][i],dp[j][i-1]),dp[j-1][i-1]+1);
				}

			}
		}
		/*REP(i,y.size()+1){
			REP(j,x.size()+1){
				cout << dp[i][j] << " ";
			}
			cout << endl;
		}
		*/
		cout << dp[y.size()][x.size()] << endl;
}


int main(){
solve();
}

Measured memory_bytes: 5104
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
#１行に数値一つならparseInt(readline())
#１行に数値複数ならparseMap(split(readline()))を行数分。
# 例：n,k = readline() |> split |> parseMap
#      a = readline() |> split |> parseMap
function main()
  #a = parseInt(readline())
  X,N = parseMap(split(readline()))
  p = parseMap(split(readline()))
  #println("$X,$N,$p")
  All = [i for i in -100:1:200]
  for i in 1:N
    #println(findall(isequal(p[i],All)))
    #println(findall(All .== p[i])[1])
    splice!(All,findall(All .== p[i])[1])
  end
  #println("$All")
  q = All .- X
  q = abs.(q)
  #println("$q")
  #println("AnsLoc:",findall(isequal(minimum(q)),q))
  #println("Ans:",All[findall(isequal(minimum(q)),q)])
  #println(size(All[findall(isequal(minimum(q)),q)]))
  if size(All[findall(isequal(minimum(q)),q)])[1] > 1
    println(minimum(All[findall(isequal(minimum(q)),q)]))
  else
    println(All[findall(isequal(minimum(q)),q)][1])
  end
  #=
      if x0==0 && y0 > 0
        println("Yes")
      elseif y0==0 && x0 > 0
        println("Yes")

      else
        println("No")
      end
  =#
end
main()

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

int main(void){
	int n; cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];

	int ans = 0;
	while(1){
		int f = 0;
		for (int i = 0; i < n - 1; ++i)
		{
			if(v[i] > v[i + 1]){
				swap(v[i], v[i + 1]);
				ans++;
				f = 1;
			}
		}
		if(f == 0) break;
	}
	
	rep(i, v.size() - 1){
		cout << v[i] << " ";
	}
	cout << v[n - 1] << endl;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int INF=-2000000000;
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.rbegin(),h.rend());
  int start=k;
  ll sum=0;
  for(int i=start; i<n; i++){
    sum+=h[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
  static int a, b, c;

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

    a = sc.nextInt();
    b = sc.nextInt();
    c = sc.nextInt();

    for(int i = 1; i <= 100; i++){
      if(a * i % b == c){
        System.out.println("YES");
        return;
      }
    }
    System.out.println("NO");
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



int main() {
	cout << fixed << setprecision(18);
	long long int N,H,W;
	cin>>H>>W>>N;
	cout<<(N+max(H,W)-1)/max(H,W)<<endl;
	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(n*a, b);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define maxi INT_MAX
#define mini INT_MIN
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};

vector<vector<int>> g;
vector<int> parent, depth, subsize;

ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // cout<<fixed;
    // cout<<setprecision(18);
    ll k;
    cin>>k;
    ll ans = 0;
    for(int i = 1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            for(int l=1;l<=k;l++)
            ans += __gcd(i,__gcd(j,l));
        }
    }
    cout<<ans<<endl;
    
} 

Measured memory_bytes: 3644
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));
    double sum = a[0];
    FOR(i, 1, n-1) {
        sum = (sum+a[i]) / 2.0;
    }
    cout << sum << endl;
    return 0;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

template<typename T>
struct sparsetable {
    vector<vector<T>> st;
    vector<i32> lookup;
    
    sparsetable(const vector<T> &v) {
        i32 n = v.size();
        st.assign(log2(n) + 1, vector<T>());
        st[0].assign(begin(v), end(v));
        for (i32 i = 1; (1 << i) <= n; i++) {
            st[i].assign(n - (1 << i) + 1, 0);
            for (i32 j = 0; j + (1 << i) <= n; j++) {
                st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
            }
        }

        lookup.assign(n + 1, 0);
        for (i32 i = 2; i < n + 1; i++) {
            lookup[i] = lookup[i >> 1] + 1;
        }
    }

    inline T rmq(i32 l, i32 r) {
        i32 b = lookup[r - l];
        return min(st[b][l], st[b][r - (1 << b)]);
    }
};

int main() {
    i32 n, m;
    cin >> n >> m;
    string s;
    cin >> s;

    vector<i32> idx(n+1);
    for (i32 i = 0; i < n+1; i++) idx[i] = s[i] == '0' ? i : INT32_MAX;
    
    sparsetable<i32> st(idx);
    deque<i32> ans;
    for (i32 i = n, j; i > 0; i = j) {
        j = st.rmq(max(0l, i - m), i);
        if (j == INT32_MAX) {
            cout << -1 << endl;
            return 0;
        }
        ans.push_front(i - j);
    }

    for (i32 i = 0; i < ans.size(); i++) cout << (i == 0 ? "" : " ") << ans[i];
    cout << endl;
}


Measured memory_bytes: 15232
N=int(input())
A=map(int,input().split())
A=list(A)
B=map(int,input().split())
B=list(B)
C=map(int,input().split())
C=list(C)

Answer=sum(B)

for i in range(0,N):
    if i!=(N-1):
        if A[i]+1==A[i+1]:
            Answer+=C[A[i]-1]

print(Answer)
    

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int max(const void *a, const void *b){return *(int*)b - *(int*)a;}


int main(void)
{
    int n;
    scanf("%d",&n);

    if(n == 100000)
    {
        printf("%d\n", 9+ 900+ 90000);
    }else if( n >= 10000)
    {
        printf("%d\n", 9+ 900+ (n-10000+1));
    }else if( n >= 1000)
    {
        printf("%d\n", 9+ 900);
    }else if( n >= 100)
    {
        printf("%d\n", 9+ (n-100+1));
    }else if( n >= 10)
    {
        printf("%d\n",9);
    }else 
    {
        printf("%d\n", n);
    }

    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <vector>
#include <utility>
#include <map>
#include<set>
#include <algorithm>
#include <string>
#include <string.h>
#include <iomanip>
#include <cmath>
#define ll long long
#define PI 3.14159265358979323846
#define lp(i, n) for (long long i = 0; i < n; i++)
#define rep(i, v) for (int i = 0; i < int(v.size()); i++)
using namespace std;
int main(){
	ll a,min_ans=10000,b;
	cin>>a>>b;
	if(b-a>=2018)
		cout<<0;	
	else
	{
		for(ll  i=a;i<b;i++)
		{
			for(ll j=i;j<=b;j++)
				if(j!=i)min_ans=min(min_ans,(i*j)%2019);
		}
		cout<<min_ans;
	}			
	return 0;
}

Measured memory_bytes: 256
import math
N = int(input())

T = []
for a in range(1, int(math.sqrt(N))+1):
  if N % a == 0:
    b = N // a
    T.append((a, b))

ans = float("inf")
for (a, b) in T:
  a = len(str(a))
  b = len(str(b))
  ans = min(ans, max(a, b))

print(ans)

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

long long int N;
int A[107];

int main(){
    cin >> N;

    int ans = 0;
    for(int i = 1; i < N+1;i++){
        cin >> A[i];
        if(A[i] % 2 == 1 && i % 2 == 1) ans++;
    } 

    cout << ans << endl;
}

Measured memory_bytes: 3616
# -*- coding: utf-8 -*-

[W, H, x, y] = [int(i) for i in input().split()]

area = W * H
half_area = area / 2

if x == W/2 and y == H/2:
    method_number = 1
else:
    method_number = 0

print("{} {}".format(half_area, method_number))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
const int mod=1e9+7;
const int inf=1e17+10;
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define si(a) a.size()
#define pii pair<int,int>
using namespace std;




int32_t main() {
   std::ios::sync_with_stdio(false);cin.tie(NULL);
   int a,b;
   cin>>a>>b;
   for(int i=1;i<=1001;i++)
   {
	   ld x=i*0.08;
	   ld y=i*0.10;
	   x=(int)x;y=(int)y;
	   //if(i==100){cout<<x<<" "<<y<<endl;}
	   if(x==a && y==b)
	   {
		   cout<<i<<endl;return 0;
	   }
   }
   cout<<-1<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 2048
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
typedef long double ld;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;
ll X[maxn], Y[maxn];
ll dp[maxn][maxn][2][2];
ll n, m;

ll solve(ll i, ll j, bool p, bool q)
{
    if(i == n || j  == m) return (!p && !q);
    ll &ans = dp[i][j][p][q];
    //cout << ans << " "<< (~ans)<<endl;
    if(~ans) return ans;
    ans = 0;
    if(X[i] == Y[j]) ans = solve(i+1, j+1, 0, 0);
    if(!p && !q) ans = (ans + solve(i+1, j+1, 0, 0)) % mod;
    if(p)ans = (ans + solve(i, j+1, 1, 0));
    if(q) ans = (ans + solve(i+1, j, 0, 1)) % mod;
    if(!p && !q) ans = (ans + ll(solve(i+1, j, 0, 1)) + solve(i, j+1, 1, 0)) % mod;
    return ans;
}

int main()
{
    FASTIO
     /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    cin >> n >> m;
    for(ll i = 0; i < n; i++) cin >> X[i];

    for(ll i = 0; i < m; i++) cin >> Y[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0,0,0,0)<<endl;
    //double end_time = clock();
    //prllf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 131584
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int A, B;
	cin >> A >> B;
	if (A + B >= 10)cout << "error" << endl;
	else cout << A + B << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a + b > c + d) cout << "Left" << endl;
    else if(a + b == c + d) cout << "Balanced" << endl;
    else cout << "Right" << endl;
    
}

Measured memory_bytes: 256
# N個の改行のある文字列を取得
N = int(input())
W = []
for i in range(N):
    W.append(str(input()))
#print(len(W))

if len(W) != len(set(W)):
    print('No')
    exit()

for i in range(N-1):
    #print(W[i], W[i+1])
    if W[i][-1] != W[i+1][0]:
        print('No')
        exit()

print('Yes')




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

N = int(input().rstrip())

V_list = list(map(int, input().rstrip().split()))
C_list = list(map(int, input().rstrip().split()))
ans_V = []
ans_C = []

for i in range(N):
  if V_list[i] > C_list[i]:
    ans_V.append(V_list[i])
    ans_C.append(C_list[i])

print(sum(ans_V) - sum(ans_C))


Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll K, A, B; cin >> K >> A >> B;
    if(B - A <= 2){
        cout << K+1 << endl; return 0;
    }
    if(K <= A){
        cout << K+1 << endl; return 0;
    }
    ll cnt = A-1 + 2*((K-(A-1))/2);
    ll ans = (K-(A-1))/2 * (B-A) + A;
    ll remcnt = K - cnt;
    cout << ans + remcnt << endl;
    return 0;
}


Measured memory_bytes: 256
s = gets.chomp
n = s.size
((n+1)/2).times do |i|
    if !((s[i] == "b" && s[n-i-1] == "d") || (s[i] == "d" && s[n-i-1] == "b") || (s[i] == "p" && s[n-i-1] == "q") || (s[i] == "q" && s[n-i-1] == "p"))
        puts "No"
        exit
    end
end
puts "Yes"

Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
#include <cstdlib>

int main() {
    int n{};
    std::cin >> n;
    std::vector<int> v(n,0);
    for(auto& x : v) { std::cin >> x; }
    for(auto& x : v) { int y{}; std::cin >> y; x = abs(x-y); }
    double d1{}, d2{}, d3{}, di{std::numeric_limits<int>::min()};
    for(auto x : v) {
        d1 += double(x);
        d2 += pow(double(x), 2.0);
        d3 += pow(double(x), 3.0);
        di = (x>di) ? x : di;
    }
    d2 = pow(d2, 0.5);
    d3 = pow(d3, 1/3.0);
    printf("%.6lf\n%.6lf\n%.6lf\n%.6lf\n", d1, d2, d3, di);
}



Measured memory_bytes: 3344
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,n,sr,sc;
  cin>>h>>w>>n>>sr>>sc;
  vector<int> sx(n);
  vector<int> sy(n);
  for(int i=0;i<n;i++){
    char c;
    cin>>c;
    sx.at(i)=(c=='L'?-1:(c=='R'?1:0));
    sy.at(i)=(c=='U'?-1:(c=='D'?1:0));
  }
  vector<int> tx(n);
  vector<int> ty(n);
  for(int i=0;i<n;i++){
    char c;
    cin>>c;
    tx.at(i)=(c=='L'?-1:(c=='R'?1:0));
    ty.at(i)=(c=='U'?-1:(c=='D'?1:0));
  }
  int l=0;
  int r=w+1;
  int u=0;
  int d=h+1;
  for(int i=n-1;i>=0;i--){
    if(tx.at(i)==-1)
      r=min(r+1,w+1);
    if(tx.at(i)==1)
      l=max(l-1,0);
    if(ty.at(i)==-1)
      d=min(d+1,h+1);
    if(ty.at(i)==1)
      u=max(u-1,0);
    if(sx.at(i)==-1)
      l++;
    if(sx.at(i)==1)
      r--;
    if(sy.at(i)==-1)
      u++;
    if(sy.at(i)==1)
      d--;
    if(l+1>=r||u+1>=d)
      break;
  }
  cout<<(u<sr&&d>sr&&l<sc&&r>sc?"YES":"NO")<<endl;
}

Measured memory_bytes: 6412