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

template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  using P = function<E(E,size_t)>;
  Int n;
  F f;
  G g;
  H h;
  T ti;
  E ei;
  P p;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(Int n_,F f,G g,H h,T ti,E ei,
	      P p=[](E a,size_t b){b++;return a;}):
    f(f),g(g),h(h),ti(ti),ei(ei),p(p){
    init(n_);
  }
  void init(Int n_){
    n=1;
    while(n<n_) n*=2;
    dat.assign(2*n-1,ti);
    laz.assign(2*n-1,ei);
  }
  void build(Int n_, vector<T> v){
    for(Int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(Int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  inline void eval(Int len,Int k){
    if(laz[k]==ei) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=h(laz[k*2+1],laz[k]);
      laz[k*2+2]=h(laz[k*2+2],laz[k]);
    }
    dat[k]=g(dat[k],p(laz[k],len));
    laz[k]=ei;
  }
  T update(Int a,Int b,E x,Int k,Int l,Int r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return g(dat[k],p(laz[k],r-l));
    }
    return dat[k]=f(update(a,b,x,k*2+1,l,(l+r)/2),
		    update(a,b,x,k*2+2,(l+r)/2,r));
  }
  T update(Int a,Int b,E x){
    return update(a,b,x,0,0,n);
  }
  T query(Int a,Int b,Int k,Int l,Int r){
    eval(r-l,k);
    if(r<=a||b<=l) return ti;
    if(a<=l&&r<=b) return dat[k];
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  T query(Int a,Int b){
    return query(a,b,0,0,n);
  }
  void update(Int k,T x){
    query(k,k+1);//evaluate
    k+=n-1;
    dat[k]=x;
    while(k){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,a,b;
  cin>>n>>a>>b;
  vector<Int> s(n+1);
  for(Int i=1;i<=n;i++) cin>>s[i];
  auto ok=[&](Int i,Int j,Int d){
    return !i || s[j]-s[i]>=d;
  };
  const Int MOD = 1e9+7;

  SegmentTree<Int, Int>::F f=[](Int a,Int b){return (a+b)%MOD;};
  SegmentTree<Int, Int>::G g=[](Int a,Int b){return b<0?a:b;};
  SegmentTree<Int, Int>::H h=[](Int a,Int b){return b<0?a:b;};
  SegmentTree<Int, Int>::P p=[](Int a,Int b){return a*b;};
  
  SegmentTree<Int, Int> dp1(n,f,g,h,0,-1,p);
  SegmentTree<Int, Int> dp2(n,f,g,h,0,-1,p);
  dp1.update(0,1);
  dp2.update(0,1);
  
  Int p1=0,p2=0;
  for(Int i=2;i<=n;i++){
    while(p1<i-1&&ok(p1,i,a)) p1++;
    while(p2<i-1&&ok(p2,i,b)) p2++;
    dp1.update(i-1,dp2.query(0,p1));
    dp2.update(i-1,dp1.query(0,p2));
    
    if(!ok(i-1,i,a)) dp1.update(0,i-1,0);
    if(!ok(i-1,i,b)) dp2.update(0,i-1,0);
  }
  
  Int ans=dp1.query(0,n)+dp2.query(0,n);
  cout<<ans%MOD<<endl;
  return 0;
}


Measured memory_bytes: 9216
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    in >> N;
    
    pair < pair<string, int>, int> res[N];


    REP(i, N){
        string s;
        int p;
        in >> s >> p;
        res[i].first.first = s;
        res[i].first.second = -1 * p;
        res[i].second = i;
    }

    /*
    out << endl;

    REP(i, N){
        out << res[i].first.first <<" "<< res[i].first.second <<" "<< res[i].second+1 << endl;
    }
    out << endl;
    */

    sort(res,res+N);
    REP(i, N){
        out << res[i].second+1 << endl;
    }


}

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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<string> v(n);
    for(auto &x: v) cin >> x;
    for(auto &x: v) sort(x.begin(), x.end());

    map<string,long> m;
    for(auto &x: v) {
        if(m.find(x) == m.end())
            m[x] = 1;
        else
            m[x]++;
    }

    long r = 0;
    for(auto &x: m) {
        r += x.second * (x.second-1) / 2;
    }

    cout << r << endl;
}

Measured memory_bytes: 18176
import sys
input = sys.stdin.readline
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque

def main(): 
    n = int(input())
    a = [int(input()) for _ in range(n)]
    a.sort()

    q = deque()
    q.append(a[0])
    l = 1
    r = n-1
    left = True
    high = True
    ans = 0
    while r - l > 0:
        if high:
            if left:
                ans += abs(a[r] - q[0])
                q.appendleft(a[r])
                r -= 1
                left = False
            else:
                ans += abs(a[r] - q[-1])
                q.append(a[r])
                r -= 1
                left = True
                high = False
        else:
            if left:
                ans += abs(a[l] - q[0])
                q.appendleft(a[l])
                l += 1
                left = False
            else:
                ans += abs(a[l] - q[-1])
                q.append(a[l])
                l += 1
                left = True
                high = True
    
    ans += max(abs(a[l] - q[0]), abs(a[l] - q[-1]))
    print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 8072
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <numeric>
#include <iomanip>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    long K, A, B;
    cin >> K >> A >> B;
    K++;
    if(K <= A){
        cout << K << endl;
        return 0;
    }
    K -= A;
    if(A + 2 <= B){
        cout << A + (K / 2) * (B - A) + (K % 2) << endl;
    }else{
        cout << A + K << endl;
    }
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let k: usize = input();
    let v: Vec<i32> = (0..n).map(|_| input()).collect();

    let mut ans = i32::min_value();
    for i in 0..k + 1 {
        for j in 0..k + 1 {
            if i + j > k || i + j > n {
                break;
            }
            let mut now = 0;
            let mut temp = vec![];
            for i in 0..i {
                now += v[i];
                temp.push(v[i]);
            }
            for j in 0..j {
                now += v[n - 1 - j];
                temp.push(v[n - 1 - j]);
            }
            temp.sort();
            for k in 0..k - i - j {
                if k >= temp.len() || temp[k] >= 0 {
                    break;
                }
                now -= temp[k];
            }
            ans = std::cmp::max(ans, now);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
n = int(input())
cnt = 0
for i in range(n):
    a, b = map(int, input().split())
    if a == b: 
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        print("Yes")
        break
    if cnt < 3 and i == n-1:
        print("No")

Measured memory_bytes: 9120
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 55;

int n,m,u[N],v[N],used[N];
set<int>g[N];

void dfs(int x){
	used[x]=1;
	for(auto i:g[x]){
		if(!used[i])
			dfs(i);
	}
}

void solve(){
	cin>>n>>m;
	rep(i,m){
		cin>>u[i]>>v[i];
		g[u[i]].insert(v[i]);
		g[v[i]].insert(u[i]);
	}
	int ans=0;
	rep(i,m){
		g[u[i]].erase(v[i]);
		g[v[i]].erase(u[i]);
		for(int i=1;i<=n;++i)used[i]=0;
		int cnt=0;
		for(int i=1;i<=n;++i){
			if(!used[i]){
				dfs(i);
				cnt++;
			}
		}
		if(cnt>1){
			ans++;
			//cout<<u[i]<<' '<<v[i]<<'\n';
		}
		g[u[i]].insert(v[i]);
		g[v[i]].insert(u[i]);
	}
	cout<<ans;

}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3648
# coding: utf-8
import re
import math
import fractions
import random
from heapq import heappop,heappush
import time
import sys
input = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
 

 
#main
N,Q=map(int,input().split())
E=[]
for a in range(N):
    s,t,x=map(int,input().split())
    E.append((s-x,1,x))
    E.append((t-x,0,x))

for a in range(Q):
    E.append((int(input()),2,0))
E.sort()
 
S=set()
H=[]
for time_,type_,x in E:
    if type_==1:
        S.add(x)
        heappush(H,x)
    elif type_==0:
        S.remove(x)
    else:
        while H and H[0] not in S:
            heappop(H)
        print(H[0] if H else -1)


Measured memory_bytes: 91980
#pragma GCC optimize("O3")

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define For(i, a, b)    for(int i = (a); (i) < (b) ; ++(i))
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

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



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    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};
    int k; cin >> k;
    cout << ans[k - 1] << endl;

return 0;
}

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

int main(void){
    int a, b, n, m, i, j, l, ans=0, kai=1, ok, popo;
    scanf("%d %d", &n, &m);
    int k[m], s[10][n], po, p[10];
    for(i=0; i<10; i++){
        p[i] = 0;
        for(j=0; j<n; j++) s[i][j] = 0;
    }
    for(i=0; i<m; i++){
        scanf("%d", &k[i]);
        for(j=0; j<k[i]; j++){
            scanf("%d", &po);
            s[i][po-1] = 1;
        }
    }
    for(i=0; i<m; i++) scanf("%d", &p[i]);

    for(i=0; i<n; i++) kai = kai*2;
    int ss[10];

    for(i=0; i<kai; i++){
        ok = 0;
        ss[0] = i%2;
        ss[1] = (i/2)%2;
        ss[2] = (i/4)%2;
        ss[3] = (i/8)%2;
        ss[4] = (i/16)%2;
        ss[5] = (i/32)%2;
        ss[6] = (i/64)%2;
        ss[7] = (i/128)%2;
        ss[8] = (i/256)%2;
        ss[9] = (i/512)%2;
        for(j=0; j<m; j++){
            popo = 0;
            for(l=0; l<10; l++){
                popo += s[j][l]*ss[l];
            }
            if(popo%2 != p[j]) ok = 1;
        }
        if(ok == 0) ans++;
    }
    printf("%d", ans);
    /*
    printf("%d %d\n", n, m);
    for(i=0; i<m; i++){
        printf("%d ", k[i]);
        for(j=0; j<m; j++) printf("%d ", s[i][j]);
        printf("\n");
    }
    for(i=0; i<m; i++) printf("%d ", p[i]);
    */
}

Measured memory_bytes: 128
import heapq

N, M = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))
heapq.heapify(A)

for _ in range(M):
    a = heapq.heappop(A) * (-1)
    heapq.heappush(A, (a//2)*(-1))

print(-sum(A))

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

using namespace std;

template<typename T1, typename T2>
bool pairCompare(const pair<T1,T2>& firstElof, const pair<T1,T2>& secondElof)
{
    return firstElof.second > secondElof.second;
}

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
typedef vector<int>vi;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


int main(void){
    int a,p;
    cin >> a >> p;
    cout << (a*3+p)/2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cctype>

int main(){
    char ch;
    
    while(1){
        scanf("%c", &ch);
        if( isalpha(ch)){
            if(islower(ch)) printf("%c", toupper(ch));
            else printf("%c", tolower(ch));
        }   else printf("%c",ch);
        
        if( ch == '\n') break;
        
    }
    return 0;
}



Measured memory_bytes: 2568
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int h, n;
	cin >> h >> n;
	vi a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	const int H = 1e4;
	const int inf = 1e9 + 228;
	vi dp(2 * H + 1, inf);
	dp[0] = 0;
	for (int i = 1; i < 2 * H + 1; i++) {
		for (int j = 0; j < n; j++) {
			if (i >= a[j]) {
				dp[i] = min(dp[i], dp[i - a[j]] + b[j]);
			}
		}
	}
	int ans = inf;
	for (int i = h; i < 2 * H + 1; i++) {
		ans = min(ans, dp[i]);
	}
	cout << ans;
}


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

signed main(){
  int s;
  cin>>s;
  int ans=0;
  for(int i=1;i*i<=s;i++){
    if(s%i)continue;
    int p=s/i,q=i;
    int l=1,r=1,sum=0,cnt1=0,cnt2=0;
    for(;l<=p;l++){
      for(;;r++){
	if(sum>=p)break;
	sum+=r;
      }
      if(sum==p)cnt1++;
      sum-=l;
    }
    l=1,r=1,sum=0;
    for(;l<=q;l++){
      for(;;r++){
	if(sum>=q)break;
	sum+=r;
      }
      if(sum==q)cnt2++;
      sum-=l;
    }
    ans+=cnt1*cnt2*(i*i==s?1:2);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3088
s = input()
l,r = 0, len(s)-1
res = 0
if s==s[::-1]:
    print(res)
    exit()

while l<r:
    if s[l]==s[r]:
        l += 1
        r -= 1
    else:
        if l==r:
            print(res)
            break
        elif s[l]!='x' and s[r]!='x':
            print(-1)
            break
        elif s[l]=='x':
            l += 1
            res += 1
        elif s[r]=='x':
            r -= 1
            res += 1
else:
    print(res)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  string ans = "Yes";
  
  if( s[3-1] != s[4-1] ) ans = "No" ;
  if( s[5-1] != s[6-1] ) ans = "No" ;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N, M = [int(v) for v in input().split(' ')]
A = [int(v) for v in input().split(' ')]

from heapq import heappush, heappop

h = []

for a in A:
    heappush(h, -a);

for i in range(0, M):
    p = (-heappop(h)) // 2
    heappush(h, -p)

s = 0
for p in h:
    s += p
    
print(-s)

Measured memory_bytes: 14224
import heapq
def dijkstra(s):
    # 始点sから各頂点への最短距離
    d = [float('inf')]*n
    d[s] = 0
    # 各頂点が訪問済みかどうか
    used = [False]*n
    used[s] = True
    # 仮の距離を記録するヒープ
    que = []
    for e in g[s]:
        heapq.heappush(que, e)
    while que:
        minedge = heapq.heappop(que)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in g[v]:
            if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
    return d

##############################
n, w, r = [int(x) for x in input().split()] # n:頂点数 w:辺の数
g = [[] for _ in range(n)]
# g[i]:iから出る辺の[コスト,行先]
for _ in range(w):
    x, y, z = [int(x) for x in input().split()]
    g[x].append([z, y])
    # g[y].append([z, x])
for i in dijkstra(r):
    if i == float("inf"):
        print("INF")
    else:
        print(i)


Measured memory_bytes: 106808
while True:
    W,H=map(int,input().split())
    if(H==0 and W==0):
        break
    for i in range(W):
        for j in range(H):
            if(i%2 == 0):
                if(j%2 == 0):
                    print("#",end="")
                else:
                    print(".",end="")
            else:
                if(j%2 == 0):
                    print(".",end="")
                else:
                    print("#",end="")
        print()
    print()


Measured memory_bytes: 7000
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
int c;
int d[52];
int item[]={2,3,5,10,12,15};
int price[]={380,550,850,380*5*0.8,550*4*0.85,850*3*0.88};

void dp(int i){
  for(int j=0;j<6;j++){
    if(i+item[j]<51){
      d[i+item[j]]=min(d[i+item[j]],d[i]+price[j]);
      dp(i+item[j]);
    }
  }
  return;
}

int main(void){
  int n;
  for(int i=0;i<52;i++){
    d[i]=1000000;
  }
  d[0]=0;
  dp(0);
  while(cin>>n,n!=0){
    cout<<d[n/100]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
	"sort"
)

const MaxN = 100005
const MaxH = 1000000005

// 2018-07-29T21:25:28+0800
// 2018-07-29T21:41:10+0800
// 2018-07-29T21:57:03+0800
func main() {
	var N, H int
	fmt.Scanf("%d%d", &N, &H)
	var a [MaxN]int
	var b [MaxN]int
	maxa := 0
	for i := 0; i < N; i++ {
		fmt.Scanf("%d%d", &a[i], &b[i])
		if maxa < a[i] {
			maxa = a[i]
		}
	}
	n := 0
	sort.Sort(sort.Reverse(sort.IntSlice(b[0:N])))
	for i := 0; i < N; i++ {
		if i == N-1 {
			if H-b[i] <= 0 {
				n++
				break
			}
			H -= b[i]
			n++
			if H%maxa == 0 {
				n += H / maxa
			} else {
				n += H/maxa + 1
			}
			break
		} else if b[i] > maxa {
			H -= b[i]
			n++
			if H <= 0 {
				break
			}
		} else {
			if H%maxa == 0 {
				n += H / maxa
			} else {
				n += H/maxa + 1
			}
			break
		}
	}
	fmt.Println(n)
}

Measured memory_bytes: 7552
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	w := make([]string, N)
	for i := range w {
		fmt.Scan(&w[i])
	}
	m := make(map[string]int)
	last := w[0]
	m[last]++
	for i := 1; i < N; i++ {
		t := w[i]
		m[t]++
		if t[0] != last[len(last)-1] || m[t] > 1 {
			fmt.Println("No")
			return
		}
		last = w[i]
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=(int)n;i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        #undef INF
        #define INF INFLL
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    cout<<(n/15)*11800+(n%15)*800<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <iomanip>

using namespace std;
int main(){
    int n;
    cin >> n;

    long x_btc = 0;
    long x_jpy = 0;
    string s;
    string s2;
    for (int i = 0; i < n; i++){
        cin >> s >> s2;
        if (s2 == "BTC"){
            x_btc += (stod(s) * (long)100000000);
        } else{
            x_jpy += (long)stoi(s);
        }
    }
    double ret = x_btc * (double)0.00380000 + x_jpy;
    cout << setprecision(9) << ret << endl;
    return 0;
}

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

using namespace std;

int gt[200005];
int mod=1000000007;

void prep()
{
	gt[0]=1;
	for(int i=1; i<=200000; i++)
	{
		gt[i]=(gt[i-1]*i)%mod;
	}
}

int binpow(int n, int k)
{
	int cac=1;
	int take=n;
	int ans=1;
	while(cac<=k)
	{
		if((k&cac)>0)
		{
			ans*=take;
			ans%=mod;
		}
		take=(take*take)%mod;
		cac<<=1;
	}
	return ans;
}

int rmod(int n)
{
	return binpow(n, mod-2);
}

int C(int k, int n)
{
	return gt[n]*rmod(gt[k])%mod*rmod(gt[n-k])%mod;
}

signed main()
{
	prep();
	int h, w, a, b;
	cin>>h>>w>>a>>b;
	int ans=0;
	for(int i=1; i<=h-a; i++)
	{
		ans+=C(i-1,b-1+i-1)*C(h-i,h-i+w-b-1)%mod;
		ans%=mod;
	}
	cout<<ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll x, a;
	std::cin >> x >> a;
	if (x < a) {
		outn(0);
	}
	else {
		outn(10);
	}

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
#define N (int)1e5
#define INF (int)1e9
#define mod (int)1e9 + 7
#define LL long long
LL n, a[N], c, d, cnt, cnt2, gyo;
map<LL, LL> b;
int main()
{
	cin >> n;
	gyo = (n + 1) * (n / 2);
	if (n % 2)
		gyo += n / 2 + 1;
	for (int i = 0; i < n; i++)
	{
		scanf("%ld", a + i);
		cnt += a[i];
		cnt2 += cnt / gyo;
		cnt %= gyo;
		if (i)
			b[a[i] - a[i - 1]] = 1;
	}
	if (cnt)
	{
		cout << "NO" << endl;
		return 0;
	}
	for (auto i = b.begin(); i != b.end(); i++)
	{
		d = i->first;
		if ((cnt2 - d) % n || d > cnt2)
		{
			cout << "NO" << endl;
			return 0;
		}
	}


	cout << "YES" << endl;
}

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

int main(){
  int a,b,c;
  cin >> a>>b>>c;
  if(a==b && b==c && c==a) cout << "No";
  else if(a!=b&&b!=c&&c!=a) cout << "No";
  else cout << "Yes";
  
}


Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,A = ilint()
c = [0]*3
for a in A:
    if a%4==0:
        c[2] += 1
    elif a%2==0:
        c[1] += 1
    else:
        c[0] += 1

judge(c[0]<=c[2] or (c[0]==c[2]+1 and c[1]==0))

Measured memory_bytes: 82292
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

	int N, K;
	double ACC = 0.0;

	cin >> N >> K;

	FOR(i, 1, N + 1)
	{
		double temp = 1.0 / N;
		int now = i;

		while (now < K)
		{
			now = now * 2;
			temp = temp / 2;
		}
		ACC += temp;
	}

	cout << setprecision(12) << ACC << endl;

	return 0;
}

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


const int N = 123;

char s[N];
int main() {
	int n;
	cin >> n;
	scanf("%s", s);
	int x = 0;
	int y = 0;
	for(int i = 0; i < n; i ++) {
		if(s[i] == 'R') x ++;
		else if(s[i] == 'B') y ++;
	}
	if(x > y) puts("Yes");
	else puts("No");

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#define ff first
#define ss second
#define M 1000000007
typedef long long int ll;
using namespace std;
ll power(ll a,ll b){
    ll ans = 1;
    while(b>0){
        if(b%2!=0){
            ans = ((ans)*(a));
        }
        a = ((a)*(a));
        b=b/2;
    }
    return ans;
}
vector <vector <ll>> dp;
ll solve(const vector <vector <ll>> &a,ll n,ll m){
    if(n==0 && m==0){
        return 1;
    }
    if(n<0 || m<0){
        return 0;
    }
    if(a[n][m]==1){
        return 0;
    }
    if(dp[n][m]!=-1){
        return dp[n][m];
    }
    dp[n][m] = (solve(a,n-1,m)%M+solve(a,n,m-1)%M)%M;
    return dp[n][m];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    dp.assign(n,vector <ll> (m,-1));
    vector <vector <ll>> a(n,vector <ll> (m));
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            char b;
            cin>>b;
            if(b=='.'){
                a[i][j]=0;
            }
            else{
                a[i][j]=1;
            }
        }
    }
    cout<<solve(a,n-1,m-1)<<endl;
    return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    int n;cin>>n;
    vector<int>p(n);
    rep(i,n){
        cin>>p[i];
    }
    int count=0;
    for (int i = 1; i < n-1; i++)
    {
        /* code */
        if (p[i]<p[i+1]&&p[i]>p[i-1])
        {
            /* code */
            count++;
        }
        if (p[i]>p[i+1]&&p[i]<p[i-1])
        {
            /* code */
            count++;
        }
        
    }
    cout<<count<<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<(int)(n);i++)
#define inf 1001001001

ll kaijo(ll x ,ll y){
    if(x/y==0) return 0;
    else return x/y + kaijo(x/y,y);
}
int main()
{
    ll n;
    ll ans2;
    ll ans5;
    cin >> n;
    if(n%2==1){
        cout << 0 << endl;
        return 0;
    }
    else{
        ll m=n/2;
        ans5=kaijo(m,5);

    }
    cout << ans5 << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    println!("{}", solve(&input));
}

fn solve(input: &str) -> String {
    let c = input.bytes().next().unwrap();
    format!("{}\n", (c + 1) as char)
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;
  vi h(n),b(n);
  REP(i,n){
    cin>>h[i];
  }
  if (k>=n){
    cout<<0<<endl;
    return 0;
  }

  sort(h.begin(), h.end());
  REP(i,n-k)
    ans+=h[i];

cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(void){
    int in;
    cin >> in;
    
    long X=0;
    
    for(int i=1;i<=in;i++){
        if(i%3==0||i%5==0){
            
        }else{
            X+=i;
        }
    }
    cout << X << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef unsigned long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;cin>>n;
	int a[alength]={};
	fori(n){
		int hoge;
		cin>>hoge;
		++a[hoge];
	}
	int q;cin>>q;
	int b[alength],c[alength];
	fori(q){cin>>b[i]>>c[i];}
	ll ans=0;
	fori(alength){
		ans+=a[i]*i;
	}
	fori(q){
		ans+=a[b[i]]*(c[i]-b[i]);
		a[c[i]]+=a[b[i]];
		a[b[i]]=0;
		cout<<ans<<endl;;
	}
}

Measured memory_bytes: 4716
/*
我的心脏怦怦跳，监管者就在附近
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int n,i;
	cin>>n;
	double s=0;
	for(i=1;i<=n;i++){
		if(i%2==1) s++;
	}
	cout<<fixed<<setprecision(10)<<s/double(n);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[3] = {500,100,50};
int ans;
int main() {
    int b,c,d,x;
    cin >> b >> c >> d >> x;
    for (int i = 0; i <= b; i++) {
      for (int j = 0; j <= c; j++) {
        for (int k = 0; k <= d; k++) {
          if (i * a[0] + j * a[1] + k * a[2] == x) {
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		if(N == 1 && M == 1){
			System.out.println(0);
		}else if((N == 1 && M == 2) || (N == 2 && M == 1)){
			System.out.println(1);
		}else{
		int n = N * (N - 1) / 2;
		int m = M * (M - 1) / 2;

		System.out.println(n + m);
		}
	}
}

Measured memory_bytes: 35404
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   998244353
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}

//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    int n, w;
    cin>>n>>w;
    vi wg(n), val(n);
    for(int i = 0; i< n;i++)
        cin>>wg[i] >> val[i];
    ll dp[110][100009];
    for(int i = 0; i<= n; i++)
        dp[i][0] = 0;
    for(int i = 0; i < 100009;i ++)
        dp[n][i] = 0;
    for(int i = n-1; i >= 0; i--)
    {
        for(int j = 1; j <= w; j++)
        {
            dp[i][j] = dp[i+1][j];
            if(j - wg[i] >= 0)
                dp[i][j] = max(dp[i][j], val[i] + dp[i+1][j-wg[i]]);
        }
    }
    cout<<dp[0][w];
    return 0;
}

Measured memory_bytes: 82528
#include <bits/stdc++.h>
#include <cmath>
#include <regex>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ba back
#define ppb pop_back
#define eb emplace_back
#define eps 1e-6
#define vll vector<long long int>
#define sz(x) (int((x.size())))
#define all(x) (x).begin(),(x).end()
#define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,n) for(int i=1;i<n;i++)
using namespace std;
typedef long long int ll;
ll M=1000000007;
ll mod(ll x){
    return ((x%M + M)%M);
}
ll mod_minus(ll a, ll b){
    // ll ans= (a%M - b%M);
    // // cout<<ans<<endl;
    // if(ans<0){
    //     ans+=M;
    //     ans=ans%M;
    // }
    // return ans;
    return mod(mod(a)-mod(b));
}
ll mod_mul(ll a,ll b){
    return mod(mod(a)*mod(b));
}
ll mod_add(ll a,ll b){
    return mod(mod(a)+mod(b));
}
ll power(ll a,ll n){
    if(n==0) return 1;
    else if(n==1) return a;
    ll R=power(a,n/2)%M;
    if(n%2==0) {  return mod(mod_mul(R,R)); }
    
     else { return mod(mod_mul(mod_mul(R,a),mod(R)));  }
}


void solve() {
    ll n;
    cin>>n;
 
    if(n<2) cout<<0;
    else {
        ll a=mod_add(power(10LL,n),power(8LL,n));
        // cout<<a<<endl;
        ll b=mod_mul(power(9LL,n),2LL);
        // cout<<b<<endl;
cout<<mod_minus(a,b);
          }

}
int main(){
    FAST;

solve();


}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    int a;
    cin >> a;
    cout << a * (1 + a * (1 + a)) << endl;

    return 0;
}

Measured memory_bytes: 3604
n, k = map(int, input().split())

def Base_10_to_n(X, n):
	if (int(X/n)):
		return Base_10_to_n(int(X/n), n) + str(X%n)
	return str(X%n)


# print(Base_10_to_n(n, k))
print(len(Base_10_to_n(n,k)))

Measured memory_bytes: 2940
def main():
    n = int(input())
    ss = sorted([int(input()) for _ in range(n)])
    ans = sum(ss)
    Count = 0
    if ans % 10 == 0:
        for i in range(n):
            if ss[i] % 10 != 0:
                ans -= ss[i]
                break
            else:
                Count += 1

    if Count == n:
        ans = 0
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9144
#include <stdio.h>
int s[100000],n;
int binarysearch(int );
int main(){
  int i,j,k,c=0,q=0,t;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&t);
    if(binarysearch(t))c++;
  }
  printf("%d\n",c);
  return 0;
}
int binarysearch(int key)
{
  int l = 0,r = n,mid;
  while(l < r){
    mid = (l + r)/2;
    if(s[mid]==key)return 1;
    else if (key < s[mid])r = mid;
    else l=mid+1; 
  }
  return 0;
}

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

void print_digits(vector<int>& digits, int leading) {
	for(int i = leading; i >= 0; i--) {
		cout << digits[i];
	}
	cout << endl;
}

int main() {

	int k;
	cin >> k;

	vector<int> digits(12, 0);
	digits[0] = 1;
	int leading = 0;

	for(; k > 1; k--) {
		//cout << "Number is "; print_digits(digits, leading);
		//cout << "Adding 1 at last digit" << endl;
		digits[0]++;
		int changed = -1;
		for(int i = 1; i <= leading; i++) {
			if(digits[i - 1] == digits[i] + 2 || digits[i - 1] == 10) {
				//cout << "Adding 1 at " << i << "-th digit" << endl;
				digits[i]++;
				changed = i;
			} else {
				break;
			}
		}
		//cout << "Digits until " << changed << "-th changed" << endl;
		//cout << "Before propagating the digits are "; print_digits(digits, leading);
		if(digits[leading] >= 10) {
			digits[leading] = 0;
			digits[++leading] = 1;
		}
		for(int i = min(leading - 1, changed - 1); i >= 0; i--) {
			digits[i] = max(0, digits[i + 1] - 1);	
		}
	}

	print_digits(digits, leading);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 1 << 17;
const int MM = 1000000007;

struct Tree{
	ll t[MX*2];
	void update(int x, ll v){
		x += MX; t[x] = v;
		while(x > 1){
			x /= 2;
			t[x] = min(t[x*2], t[x*2+1]);
		}
	}
	ll read(int s, int e){
		s += MX, e += MX;
		ll r = 1e18;
		while(s <= e){
			if( s&1 ) r = min(t[s++], r);
			if(~e&1 ) r = min(t[e--], r);
			s /= 2, e /= 2;
		}
		return r;
	}
}t1, t2;

ll D[MX];
int X[MX];
int N, T, E;

int main()
{
	scanf("%d%d%d", &N, &E, &T);
	for(int i = 1; i <= N; i++) scanf("%d", X+i);
	int k = 0;
	t1.update(0, -X[1]*2);
	for(int i = 1; i <= N; i++){
		while(2*(X[i] - X[k]) >= T) k++;
		// 0~k-1 : 2*(X[i] - X[k]) > T
		D[i] = min(t1.read(0, k-2) + 3ll*X[i], t2.read(k-1, i-1) + X[i] + T);
		t1.update(i, D[i] - X[i] - X[i+1]*2);
		t2.update(i, D[i] - X[i]);
	}
	printf("%lld\n", D[N] + (E-X[N]));
}


Measured memory_bytes: 5120
while True:
    n, k = map(int, input().split())
    if n == 0 and k == 0:
        break
    a = [int(input()) for _ in range(n)]
    s = [0] * (n+1)
    
    for i in range(n):
        s[i+1] = s[i] + a[i]
    
    ans = -float('inf')
    for i in range(n-k+1):
        tmp = s[k+i] - s[i]
        if tmp > ans:
            ans = tmp
    
    print(ans)


Measured memory_bytes: 13432
#include <stdio.h>

int main(void)
{
  int i, num;
  int x[1000];

  scanf("%d", &num);

  for ( i = 0; i < num; i++) 
    scanf("%d", &x[i]);

  // for ( i = 0; i < (num / 2); i++) {
  //   int tmp = x[i];
  //   x[i] = x[num - i];
  //   x[num - i] = tmp;
  // }

  for (i = 1; i <= num; i++) {
    printf("%d", x[num - i]);
    if (i == num) putchar('\n');
      else putchar(' ');
  }
  
  return 0;
}


Measured memory_bytes: 2028
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

const int MAXN = 5;
int segmentTree[4 * MAXN + 1];

void buildSegmentTree(vector<int>& nums, int tl, int tr, int index) {
	if (tl == tr) {
		segmentTree[index] = nums[tl];
		return;
	}
	else {
		int tm = tl + (tr - tl) / 2;
		buildSegmentTree(nums, tl, tm, index * 2 + 1);
		buildSegmentTree(nums, tm + 1, tr, index * 2 + 2);
		segmentTree[index] = segmentTree[index * 2 + 1] + segmentTree[index * 2 + 2];
	}
}

int rangeSum(int index, int tl, int tr, int l, int r) {
	if (l > r) return 0;

	if (tl == l && tr == r) return segmentTree[index];
	
	int tm = tl + (tr - tl) / 2;

	return rangeSum(index * 2 + 1, tl, tm, l, min(tm, r)) + rangeSum(index * 2 + 2, tm + 1, tr, max(l, tm + 1), r);
}

void update(int index, int tl, int tr, int pos, int val) {
	if (tl == tr) {
		segmentTree[index] = val;
		return;
	}

	int tm = tl + (tr - tl) / 2;
	if (pos <= tm) {
		update(index * 2 + 1, tl, tm, pos, val);
	}
	else update(index * 2 + 2, tm + 1, tr, pos, val);

	segmentTree[index] = segmentTree[index * 2 + 1] + segmentTree[index * 2 + 2];
}

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

	cout << n * n;
}



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

int main(){long N, M;
cin >> N >> M;
long ans = (100 * N + 1800 * M) * pow(2, M);


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

Measured memory_bytes: 256
import math

def factoring(x):
    ans = []
    for i in range(1, int(math.sqrt(x))+1):
        if x%i == 0:
            ans.append(i)
            ans.append(x // i)
    return sorted(ans)

n, m = map(int, input().split())

facts = factoring(m)
ans = 1
for i in facts[::-1]:
    if i <= int(m/n):
        print(i)
        exit()
print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())
d1 = [] * n
d2 = [] * n

for i in range(n):
    x, y = map(int, input().split())
    d1.append(x+y)
    d2.append(x-y)

print(max(max(d1) - min(d1), max(d2)-min(d2)))


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int W,H,N;
double X[222],Y[222];

double f(double y){
    vector<pair<double,int>>vec;
    rep(i,2*N){
        double dx=X[i],dy=Y[i]-y;
        double a=atan2(dy,dx);
        vec.pb({a,i});
    }
    sort(all(vec));
    double y1,y2;
    int i=vec[N-1].se,j=vec[N].se;
    if(X[i]==0)y1=0;
    else y1=min(1.0*H,max(0.0,y+(Y[i]-y)/X[i]*W));
    if(X[j]==0)y2=H;
    else y2=min(1.0*H,max(0.0,y+(Y[j]-y)/X[j]*W));
    return y2-y1;
}

void solve(){
    rep(i,2)rep(j,2)X[2*N+i*2+j]=i*W,Y[2*N+i*2+j]=j*H;
    vector<double>ys;

    for(int i=0;i<2*N+4;i++){
        for(int j=0;j<2*N+4;j++){
            if(X[i]==X[j])continue;
            double y=Y[i]-(Y[j]-Y[i])/(X[j]-X[i])*X[i];
            if(0<=y&&y<=H)ys.pb(y);
        }
    }
    sort(all(ys));
    double ans=0.0;
    for(int i=0;i+1<ys.size();i++){
        double y=(ys[i]+ys[i+1])/2;
        ans+=(ys[i+1]-ys[i])*f(y);
    }
    printf("%.20f\n",ans/H/H);
}
signed main(){
    while(cin>>W>>H>>N,W||H||N){
        rep(i,2*N)cin>>X[i]>>Y[i];
        solve();
    }
}

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	string a,b,c;
	cin >> a >> b >> c;
	cout << a[0] <<b[0]  << c[0] << "\n";	
	return 0;
}

Measured memory_bytes: 256