akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    vector<ll> x(n), y(n), h(n);
    rep(i, n){
        cin >> x[i] >> y[i] >> h[i];
    } 
    vector<ll> ord(n);
    iota(ALL(ord), 0);
    sort(ALL(ord), [&](ll a, ll b){
        return h[a] > h[b];
    });

    if(h[ord[0]] == 0){
        ll ans = INF;
        rep(i, n){
            ans = min(ans, x[i] + y[i]);
        }

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

    rep(cx, 101)rep(cy, 101){
        ll res = abs(x[ord[0]] - cx) + abs(y[ord[0]] - cy) + h[ord[0]]; 
        bool isok = true;
        rep(i, n){
            ll high = abs(x[i] - cx) + abs(y[i] - cy) + h[i]; 

            if(high == res)continue;
            else if(h[i] == 0 && high > res)continue;

            isok = false;
            break;   
        }

        if(isok){
            cout << cx << " " << cy << " " << res << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	c-=a,d-=b;
	cout<<-d+c+a<<' '<<c+d+b<<' '<<-d+a<<' '<<c+b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N; str S; cin>>N>>S;
    int cnt = 0; int ans=0;


    for(int i=1; i<N; i++){
      int alp[40];
      for(int k=0; k<40; k++){
        alp[k]=0;
      }
      for(int j=0; j<i; j++){
        for(int k=0; k<26; k++){
          if(S[j] == ('a'+k) && alp[k]==0) alp[k]++;
        }
      }

      for(int j=i; j<N; j++){
        for(int k=0; k<26; k++){
          if(S[j] == ('a'+k) && alp[k]==1) {cnt++; alp[k]=0;}
        }
      }
      ans = max(ans, cnt);
      cnt = 0;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n,m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
  return 0;     
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
using namespace std;

void solve(int test){
	string s,t;
	cin>>s>>t;
	ll ans = 1e11, cnt;
	for (int i = 0; i <= s.size() - t.size(); ++i)
	{
		cnt = 0;
		for (int j = 0; j < t.size(); ++j)
		{
			if (s[i + j] != t[j])
			{
				cnt++;
			}
		}
		ans = min(ans, cnt);
	}
	cout<<ans;
}
  
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t=1,k;
	//cin>>t;
	k = t;
	while(t--){
		solve(k - t);
	}
	cerr<<"Timpe elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " mps\n" ;
	return 0;
}

Measured memory_bytes: 3848
/**
     **author : _KMS_
     **created : 12-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =1e5+100,MOD=2e9;
typedef long long ll;
int arr[10];
set<int>st,st2;
string s,p;
int main() 
{ 
      
  ios::sync_with_stdio(false);
  cin.tie(0);
 int n,k;
 cin>>n>>k;
 for(int i=0;i<k;i++){int a; cin>>a;
 st.insert(a);
 }
 for(int i=0;i<=9;i++)
 {
       if(st.find(i)==st.end())
       {
             st2.insert(i);
       }
 }
 while(n>0)
 {
       s+=(n%10)+'0';
       n/=10;
 }
 reverse(s.begin(),s.end());
 //cout<<s<<endl;
 bool f=0;
 for(int i=0;i<s.size();i++)
 {
       if(f)
       {
             auto x=st2.begin();
             int l=*x;
             p+=l+'0';
             
       }
       else
       {
             for(auto x : st2)
             {
                   int l=x;
                 
                   if(l>=s[i]-'0')
                   {
                         if(l>s[i]-'0')
                         {
                         
                               p+=l+'0';
                               f=1;
                         }
                         else
                         {
                               p+=s[i];
                         }
                         break;
                   }
             }
       }
 }
 for(int i=0;i<s.size();i++)
 {
       if(s[i]>p[i]&&!f)
       {
             p="";
             for(auto x: st2)
             {
                   int l=x;
                   if(l!=0)
                   {
                         p+=l+'0';
                         break;
                   }
             }
             for(int i=0;i<s.size();i++)
             {
                   auto x=st2.begin();
                   int l=*x;
                   p+=l+'0';
             }
             break;
       }
 }
 cout<<p<<endl;
 
 
   
   
	return 0; 
} 

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

const int mx = 1e5 + 5;

vector<int> adj[mx];
bool visited[mx];
int dist[mx];
int in_degree[mx];

void dfs(int node)
{
    visited[node] = true;
    for (auto i : adj[node])
    {
        dist[i] = max(dist[i], 1 + dist[node]);
        --in_degree[i];
        if (in_degree[i] == 0)
        {
            dfs(i);
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    while (m--)
    {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        ++in_degree[b];
    }

    for (int i = 1; i <= n; i++)
    {
        if (!visited[i] && in_degree[i] == 0)
        {
            dfs(i);
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans = max(ans, dist[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 12628
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();

    int l = sc.nextInt();

    int min = Integer.MAX_VALUE;

    int sum = 0;
    for (int i = 1; i <= n; i++){
      int taste = l + i - 1;
      if (Math.abs(taste) < Math.abs(min)) {
        min = taste;
      }
      sum += taste;
    }
    os.println(sum - min);
  }
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    string s,t;
    cin >> s; cin >> t;
    vector<vector<int>>dp(s.length()+1,vector<int>(t.length()+1,0));
    for(int i = 1; i <= s.length(); i++){
        for(int j = 1; j<=t.length();j++){
            if(s[i-1]==t[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    string ns = "";
    int l=s.length(),r=t.length();
    while(l&&r){
        if(s[l-1] == t[r-1]){
            ns+=s[l-1]; l--; r--;
        }
        else if(dp[l-1][r] == dp[l][r]){
            l--;
        }
        else{
            r--;
        }
    }
    reverse(ns.begin(),ns.end());
    cout << ns << endl;
    return 0;
}

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

int H,W;
int S[22][22];

int gtx,gty;

int dfs(int x,int y,int num){
    if(num==10) return 20;

    int res=20;
    for(int i=x-1;i>=0;i--){
        if(S[i][y]==1){
            if(i!=x-1){
                S[i][y]=0;
                res=min(res,dfs(i+1,y,num+1));
                S[i][y]=1;
                break;
            }else break;
        }else if(S[i][y]==3) return num+1;
    }
    for(int i=x+1;i<H;i++){
        if(S[i][y]==1){
            if(i!=x+1){
                S[i][y]=0;
                res=min(res,dfs(i-1,y,num+1));
                S[i][y]=1;
                break;
            }else break;
        }else if(S[i][y]==3) return num+1;
    }
    for(int i=y-1;i>=0;i--){
        if(S[x][i]==1){
            if(i!=y-1){
                S[x][i]=0;
                res=min(res,dfs(x,i+1,num+1));
                S[x][i]=1;
                break;
            }else break;
        }else if(S[x][i]==3) return num+1;
    }
    for(int i=y+1;i<W;i++){
        if(S[x][i]==1){
            if(i!=y+1){
                S[x][i]=0;
                res=min(res,dfs(x,i-1,num+1));
                S[x][i]=1;
                break;
            }else break;
        }else if(S[x][i]==3) return num+1;
    }
    return res;
}

void solve(){
    int stx,sty;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>S[i][j];
            if(S[i][j]==2){
                stx=i;
                sty=j;
            }else if(S[i][j]==3){
                gtx=i;
                gty=j;
            }
        }
    }

    int ans=dfs(stx,sty,0);
    if(ans>10) cout<<-1<<endl;
    else cout<<ans<<endl;
    return;
}

int main(){
  while(1){
      cin>>W>>H;
      if(W==0) break;
      solve();
  }

  return 0;
}



Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
	vector<int> p(a), q(b), r(c);
	rep(i, a) cin >> p[i];
	rep(i, b) cin >> q[i];
	rep(i, c) cin >> r[i];
	sort(all(p),greater<int>());
	rep(i,a-x)p.pop_back();
	sort(all(q),greater<int>());
	rep(i,b-y)q.pop_back();
	sort(all(r),greater<int>());

	vector<ll> sum_r(c+1, 0);
	rep(i, c)sum_r[i+1] = sum_r[i]+r[i];

	vector<int> pq;
	rep(i, x)pq.push_back(p[i]);
	rep(i, y)pq.push_back(q[i]);
	sort(all(pq),greater<int>());
	vector<ll> sum_pq(x+y+1, 0);
	rep(i, x+y)sum_pq[i+1] = sum_pq[i]+pq[i];

	ll ans = 0;
	rep(i,min(c,x+y)+1)
	{
		chmax(ans,sum_pq[x+y-i]+sum_r[i]);
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 4468
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        w: usize,
        h: usize,
        n: usize,
        xya: [(usize, usize, usize); n]
    }
    let mut grid = vec![vec![1; w]; h];
    for (x, y, a) in xya {
        match a {
            1 => {
                for i in 0..x {
                    for j in 0..h {
                        grid[j][i] = 0;
                    }
                }
            },
            2 => {
                for i in x..w {
                    for j in 0..h {
                        grid[j][i] = 0;
                    }
                }
            },
            
            3 => {
                for i in 0..w {
                    for j in 0..y {
                        grid[j][i] = 0;
                    }
                }
            },
            4 => {
                for i in 0..w {
                    for j in y..h {
                        grid[j][i] = 0;
                    }
                }
            },
            _ => {},
        }
    }

    let mut result = 0;
    for i in 0..w {
        for j in 0..h {
            result += grid[j][i];
        }
    }
    //println!("{:?}", grid);
    
    println!("{}", result); 
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
void max_self(int& x, int y) {
	x = max(x, y);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n, T;
	cin >> n >> T;
	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end());
	vector<int> dp(T + 3500);
	for (int i = 0; i < n; ++i) {
		for (int t = T - 1; t >= 0; --t) {
			max_self(dp[t + a[i].first], dp[t] + a[i].second);
		}
	}
	cout << *max_element(dp.begin(), dp.end()) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=200010;
const ll mod=1e9+7;

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

  cout << (n+1)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

def main():
    N, A, B = map(int, input().split())
    print(counter(N, A, B))

def counter(N, A, B):
    total = 0
    for n in range(1, N+1):
        sum = 0
        nn = n
        while n!=0:
            sum += n % 10
            n = n // 10
        if A <= sum <= B: total += nn
    return total

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int main(void){
	double a,b,c,kakuC,S,L,h;
	scanf("%lf %lf %lf",&a,&b,&kakuC);
	S=0.5*a*b*sin(kakuC*3.14159265359/180);
	c=sqrt(a*a+b*b-2*a*b*cos(kakuC*3.14159265359/180));
	L=a+b+c;
	h=2*S/a;
	printf("%f\n %f\n %f\n",S,L,h);
	return 0;
}

Measured memory_bytes: 648
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ld inf = 1e15;

struct CHT{
    vec<pdd> line;
    vec<pdd> gr;

    CHT(){
        line.pb({0,0});
        gr.pb({-inf, inf});
    }

    ld gval(ld X){
        int l = -1, r = (int)(gr.size())-1;
        for(; l+1<r;){
            int md = (l+r)/2;
            if(X > gr[md].S) l = md;
            else r = md;
        }
        /*for(int q=0; q<gr.size(); q++){
            if(gr[q].F<=X && X<=gr[q].S){
                l = q;
            }
        }*/
        assert(gr[r].F<=X && X<=gr[r].S);
        return line[r].F*X+line[r].S;
    }

    void add_line(ld K, ld B){
        int l = -1, r = (int)(gr.size())-1;
        for(; l+1<r; ){
            int md = (l+r)/2;
            ld px = (B-line[md].S) / (line[md].F-K);
            if(px > gr[md].S) l = md;
            else r = md;
        }
        ld px = (B-line[r].S) / (line[r].F-K);
        /*for(int q=0; q<line.size(); q++){
            ld X = (B-line[l].S) / (line[l].F-K);
            if(gr[q].F<=X && X<=gr[q].S) l = q;
        }
        cout<<"NEED: "<<px<<endl;
        for(pdd p : line) cout<<"{"<<p.F<<" "<<p.S<<"} "; cout<<endl;
        for(int q=0; q<line.size(); q++) cout<<(B-line[q].S)/(line[q].F-K)<<"  "; cout<<endl;
        for(pdd p : gr) cout<<"{"<<p.F<<" "<<p.S<<"} "; cout<<endl;
        cout<<"RES: "<<r+1<<endl<<endl;*/
        assert(gr[r].F<=px && px<=gr[r].S);
        for(; line.size()>r+1;){
            line.pop_back();
            gr.pop_back();
        }
        gr[r].S = px;
        line.pb({K, B});
        gr.pb({px, inf});
    }
};

ll a,c;
vec<ll> m, dp;

int main() {
    fast;
    cout.precision(2);
    cout<<fixed;
    cin>>a>>c;
    m = vec<ll>(a);
    for(int q=0; q<a; q++) cin>>m[q];
    dp = vec<ll>(a);
    CHT cht;
    cht.add_line(-2*m[0], m[0]*m[0]+dp[0]);
    for(int q=1; q<a; q++){
        ll mn = 1e18;
        ld res = cht.gval(m[q]);
        //cout<<"VAL: "<<res<<endl;
        mn = res;
        /*for(int w=0; w<q; w++){
            ll tyt = -2*m[w]*m[q] + (dp[w]+m[w]*m[w]);
            mn = min(mn, tyt);
        }*/
        dp[q] = mn + m[q]*m[q]+c;
        cht.add_line(-2*m[q], m[q]*m[q]+dp[q]);
    }
    //for(ll i : dp) cout<<i<<" "; cout<<endl;
    cout<<dp[a-1];
}

Measured memory_bytes: 19160
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  set<ll> st;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    st.insert(a[i]);
  }
  vector<ll> cnt(n + 1);
  for (int i = 0; i < n; ++i) {
    cnt[a[i]]++;
  }
  ll sum = 0;
  for (int i = 1; i <= n; ++i) {
    sum += cnt[i] * (cnt[i] - 1) / 2;
  }
  vector<ll> sum1(n + 1), sum2(n + 1);
  for (int i = 1; i <= n; ++i) {
    sum1[i] = max(0ll, cnt[i] * (cnt[i] - 1) / 2);
    sum2[i] = max(0ll, (cnt[i] - 1) * (cnt[i] - 2) / 2);
  }
  for (int i = 0; i < n; ++i) {
    ll ans = sum;
    ans -= sum1[a[i]];
    ans += sum2[a[i]];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 13824
#include <stdio.h>
int main(){
	double a=100.000;
	long k;
	int n,i,swap_i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		a+=a*0.05;
		a+=0.999;
		swap_i=a;
		a=swap_i;
	}
	k=a*1000;
	printf("%ld\n",k);
	return 0;
}

Measured memory_bytes: 0
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int sum = 0;
	for(int i=0;i<k;i++){
		sum+=a[i];
	}

cout<<sum<<endl;

	

	return 0;
}

Measured memory_bytes: 3640
h,w = map(int,input().split())
s = [0] * h
for i in range(h):
    s[i] = [i for i in str(input())]
ans = [[0] * w for i in range(h)]

for i in range(h):
    box = []
    a = 0
    for j in range(w):
        if s[i][j] == '.':
            box.append(j)
            a += 1
            if j == w-1:
                for k in range(len(box)):
                    ans[i][box[k]] += a
                box = []
                a = 0
        else:
            if j != 0 and len(box) >= 1:
                for k in range(len(box)):
                    ans[i][box[k]] += a
                box = []
                a = 0

for i in range(w):
    box = []
    a = 0
    for j in range(h):
        if s[j][i] == '.':
            box.append(j)
            a += 1
            if j == h-1:
                for k in range(len(box)):
                    ans[box[k]][i] += a
                box = []
                a = 0
        else:
            if j != 0 and len(box) >= 1:
                for k in range(len(box)):
                    ans[box[k]][i] += a
                box = []
                a = 0
aans = 0
for i in range(h):
    aans = max(aans,max(ans[i]))
print(aans-1)



Measured memory_bytes: 220972
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
int main(){
    vector <char> S(4);
    for(int i=0;i<4;i++){
        cin>>S[i];
    }
    sort(S.begin(),S.end());
    if(S[0]==S[1]&&S[2]==S[3]&&S[1]!=S[2]){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
while True:
    H,W = [int(x) for x in input().split()]
    if H == 0 and W == 0:
        break
    for i in range(H):
        if i == 0 or i == H-1:
            for j in range(W):
                print('#',end='')
        else:
            for j in range(W):
                if j == 0 or j == W-1:
                    print('#',end='')
                else:
                    print('.',end='')
        print('')
    print('')



Measured memory_bytes: 7016
#include <iostream>
#include <string>
#include <algorithm>

int main(void){
  std::string s;
  std::string s_rev;
  std::cin >> s;
  s_rev = s;
  std::reverse(s_rev.begin(), s_rev.end());
  
  int n = s.size();
  
  bool e = true;
  if(s != s_rev) e = false;
  
  std::string s_f = s.substr(0, ((n-1)/2));
  std::string s_f_rev = s_f;
  std::reverse(s_f_rev.begin(), s_f_rev.end());
  
  if(s_f != s_f_rev)  e = false;
  
  std::string s_b = s.substr(((n+3)/2)-1, n);
  std::string s_b_rev = s_b;
  std::reverse(s_b_rev.begin(), s_b_rev.end());
  
  if(s_b != s_b_rev)  e = false;
  
  std::string ret = e ? "Yes" : "No";
  
  std::cout << ret << std::endl;
  
  return 0;
}
  
  
  

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

string s[maxn];
int n,ch[maxn][26],cnt,siz[maxn][26],tmp[maxn][26];

inline void ins(int u,int x,int p)
{
	if(p<0) return;
	int q=s[x][p]-'a'; tmp[u][q]++;
	if(!ch[u][q]) ch[u][q]=++cnt;
	ins(ch[u][q],x,p-1);
	rep(i,0,25)
	{
		tmp[u][i]+=tmp[ch[u][q]][i];
		if(tmp[u][i]) tmp[u][i]=1; siz[u][i]+=tmp[u][i];
	}
}

inline void cl(int u,int x,int p)
{
	if(p<0) return;
	int q=s[x][p]-'a'; rep(i,0,25) tmp[u][i]=0;
	cl(ch[u][q],x,p-1);
}

inline ll Q(int u,int x,int p)
{
	if(p==0) return siz[u][s[x][0]-'a']-1;
	int q=s[x][p]-'a';
	if(!ch[u][q]) return 0;
	return Q(ch[u][q],x,p-1);
}

int main()
{
	n=read(); cnt=1;
	rep(i,1,n)
	{
		cin>>s[i],ins(1,i,s[i].length()-1);
		cl(1,i,s[i].length()-1);
	}
	ll ans=0;
	rep(i,1,n) ans+=Q(1,i,s[i].length()-1); cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 413264
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

int r,s,p;
char win(const char c){
  if(c=='r') return 'p';
  if(c=='s') return 'r';
  else return 's';
}
int point(const char c){
  if(c=='r') return r;
  if(c=='s') return s;
  else return p;
}

void solve() {
  int n,k;
  string t;
  cin>>n>>k>>r>>s>>p>>t;
  vector<string> sub(k,"");
  rep(i,n){
    sub[i%k]+=t[i];
  }
  ll ans=0;
  rep(i,k){
    string f=sub[i];
    int a=f.size();
    if(a==0) continue;
    string memo="";
    rep(j,a){
      char c=win(f[j]);
      if(j==0){
        ans+=point(c); memo+=c;
      }
      else if(memo[j-1]!=c){
        ans+=point(c);
        memo+=c;
      }
      else{
        if(j==a-1) continue;
        memo+='d'; //無関係
      }
    }
  }
  out(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
ll dp[100005][2];
vector<int> adj[100005];

ll f(int u, bool c, int pr)
{
    if(dp[u][c]!=-1)
        return dp[u][c];

    ll ans = 0;
    ll w1 = 1;
    for (int child : adj[u])
    {
        if (child != pr)
        {
            w1 = (w1 * f(child, 0, u)) % MOD;
        }
    }
    ans += w1;

    if (!c)
    {
        ll w2 =1;
        for (int child : adj[u])
        {
            if (child != pr)
            {
                w2 = (w2 * f(child, 1, u)) % MOD;
            }
        }
        ans =(ans+ w2)%MOD;
    }

    return dp[u][c]=ans;
}
int main()
{
    int n;
    cin >> n;
    memset(dp,-1,sizeof dp);
    for (int i = 1; i < n; i++)
    {
        int x, y;
        cin >> x >> y;

        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    cout << f(1, 0, -1);
    return 0;
}

Measured memory_bytes: 18940
#include<stdio.h>
int main(void){
	int a;
	int b;
	int c;
	for(a=1;a<10;a++){
		for(b=1;b<10;b++){
			c=a*b;
			printf("%dx%d=%d\n",a,b,c);
		}
	}
	return(0);
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int w, h, x, y;
double totalArea;
double halfArea;

int main()
{
	scanf("%d%d%d%d", &w, &h, &x, &y);
	totalArea = (double)w * h;
	halfArea = totalArea / 2;
	
	if (w % 2 != 0 || h % 2 != 0)
	{
		printf("%.8lf 0\n", halfArea);
	}
	else
	{
		int hx, hy;
		
		hx = w / 2;
		hy = h / 2;
		if (x == hx && y == hy)
			printf("%.8lf 1\n", halfArea);
		else
			printf("%.8lf 0\n", halfArea);

			
	}

	
	
	return 0;
}



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

using namespace std;

int main()
{
	vector<int> v(5);
	int k;
	cin >> v.at(0);
	cin >> v.at(1);
	cin >> v.at(2);
	cin >> v.at(3);
	cin >> v.at(4);
	cin >> k;
		int max = *max_element(v.begin(), v.end());
	int min = *min_element(v.begin(), v.end());
	
	if (max - min <= k) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  int k;
  cin>>n>>k;
  int use[10];
  fill_n(use,10,1);
  for(int i=0;i<k;i++){
    int a;cin>>a;
    use[a]=0;
  }
  for(int i=n;i<=10*n;i++){
    int ii=i;
    int flag=1;
    while(ii!=0){
      int flag2=1;
      for(int j=0;j<10;j++){
	//	cout<<use[j]<<endl;
	if(use[ii%10]){
	  //cout<<ii<<endl;
	  flag2=0;
	  break;
	}
      }
      if(flag2){
	flag=0;
	break;
      }
      ii=ii/10;
    }
    if(flag){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;

const int N=2e5+100;
const int mod=1e9+7;

ll a[N*2];
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(!isdigit(ch))
    {
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
ll pre[3*N];
ll lat[3*N];
int main()
{
    //ios::sync_with_stdio(0);cin.tie(0);
    int n=read();
    for(int i=1; i<=3*n; i++)
    {
        a[i]=read();
    }
    ll ans=-1e18;
    priority_queue<ll>q1;
    priority_queue<ll,vector<ll>,greater<ll>>q2;
    for(int j=1; j<=n; j++)
    {
        q2.push(a[j]);
        pre[j]=pre[j-1]+a[j];
    }
    //cout<<pre[2]<<endl;
    for(int i=n+1;i<=2*n;i++){
        if(a[i]>q2.top()) {
            pre[i]=pre[i-1]-q2.top()+a[i];
            q2.pop();
            q2.push(a[i]);
        }
        else pre[i]=pre[i-1];
    }

    for(int j=3*n; j>=n*2+1; j--)
    {
         lat[j]=lat[j+1]+a[j];
         q1.push(a[j]);
    }
    for(int i=n*2;i>=n;i--){
        if(a[i]<q1.top()) {
            lat[i]=lat[i+1]-q1.top()+a[i];
            q1.pop();
            q1.push(a[i]);
        }
        else  lat[i]=lat[i+1];
    }
    for(int i=n;i<=2*n;i++){
           // cout<<pre[i]<<" "<<lat[i]<<endl;
         ans=max(pre[i]-lat[i+1],ans);
    }
  cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 10520
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T>
struct BIT{
    vector<T> s;
    int n;
    BIT(int n_) : n(n_+1), s(n_+1) {};
    T sum(int i) {
        ++i;
        T ret = 0;
        while(i > 0) {
            ret += s[i];
            i -= i & -i;
        }
        return ret;
    }
    // [l, r)
    T query(int l, int r) {
        return sum(r-1) - sum(l-1);
    }
    void add(int i, T x) {
        ++i;
        while(i <= n) {
            s[i] += x;
            i += i & -i;
        }
    }
    void update(int i, T x) {
        add(i, x-query(i, i+1));
    }
};

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    ll n, k;
    cin >> n >> k;
    vl a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i] -= k;
    vl s(n + 1);
    rep(i, n) s[i+1] = s[i] + a[i];
    map<ll, int> mp;
    rep(i, n+1) mp[s[i]] = 1;
    int cnt = 0;
    for(auto& p : mp) p.se = cnt++;
    BIT<ll> bit(cnt + 10);
    ll ans = 0LL;
    rep(i, n+1) {
        ll tmp = bit.query(0, mp[s[i]]+1);
        ans += tmp;
        bit.add(mp[s[i]], 1LL);
        // cerr <<i << " " <<  mp[s[i]] << " " << tmp << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17408
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:00:46 2020

@author: saito
"""

# %% import phase

# %% define phase
# %% input phase
n, x, t = list(map(int, input().split()))

# %% process phase
a = (n-1)//x + 1
ans = a * t

# %%output phase
print(ans)

Measured memory_bytes: 9156
function main(input) {
  var n = parseInt(input, 10);
  var result = "";
  const abcs = "abcdefghijklmnopqrstuvwxyz";
  while (0 < n) {
    var m = n % 26;
    if (m === 0) {
      m = 26;
    }
    result = abcs.substr(m - 1, 1) + result;
    n = (n - m) / 26;
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29504
num = list(map(int, input().split()))
if num[0] == num[1]:
    if num[0] == num[2]:
        print('No')
    else:
        print("Yes")
elif num[0] == num[2]:
    print('Yes')
elif num[1] == num[2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()

int main(){
    string s;
    int n,i,flag=0;
    cin>>s;
    n=s.length();
    for(i=0;i<(n-1)/2;i++){
        if(s[i]!=s[n-i-1]){ cout<<"No"<<endl; return 0; }
        if(s[i]!=s[(n-1)/2-i-1]){ cout<<"No"<<endl; return 0;}
        if(s[(n+3)/2+i-1]!=s[n-i-1]){ cout<<"No"<<endl; return 0;}
    }
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
from math import sqrt
n = int(input())
s = int(input())
def f(x,y):
	if y<x: return y
	else: return f(x,y//x)+(y%x)
if s==n: ans = n+1
elif n<s: ans = -1
else:
	ans = -1
	for i in range(2,int(sqrt(n))+1):
		if f(i,n)==s:
			ans = i
			break
	if ans==-1:
		for i in range(int(sqrt(n)),0,-1):
			b = (n-s)/i+1
			if b==int(b) and f(int(b),n)==s:
				ans = int(b)
				break
print(ans)

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

using namespace std;

int main(){
    int N; cin >> N;
    if(N==3){
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }
    int a[8][8] = {
        {6},
        {2, 4},
        {2, 4, 6},
        {2, 3, 4, 9},
        {2, 3, 4, 6, 9},
        {2, 3, 4, 6, 9, 12},
        {2, 3, 4, 6, 8, 9, 10},
        {2, 3, 4, 6, 8, 9, 10, 12}
    };

    for(int i=0;i<30000;i+=12){
        int p = min(N, 8);
        for(int j=0;j<p;j++) cout << i + a[p-1][j] << " ";
        N -= 8;
        if(N <= 0) break;
    }
    cout << endl;
}

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

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
const int inf = 1e9;

struct Edge {
  int to, cost;
  Edge(int to, int cost) : to(to), cost(cost) {}
  bool operator<(const Edge& rhs) const {
    if (cost != rhs.cost) return cost > rhs.cost;
    return to < rhs.to;
  }
};
using Graph = vector<vector<Edge>>;
int dist[1500][1500];

int main() {
  int N, R;
  cin >> N >> R;
  Graph G(N);
  REP(i, R) {
    int s, t, d;
    cin >> s >> t >> d;
    s--, t--;
    G[s].emplace_back(t, d);
    G[t].emplace_back(s, d);
  }
  REP(s, N) {
    int* di = dist[s];
    REP(i, N) di[i] = inf;
    di[s] = 0;
    priority_queue<Edge> pq;
    pq.emplace(s, 0);
    while (not pq.empty()) {
      auto e = pq.top();
      pq.pop();
      if (e.cost > di[e.to]) continue;
      for (auto&& ee : G[e.to]) {
        auto w = e.cost + ee.cost;
        if (di[ee.to] > w) {
          di[ee.to] = w;
          pq.emplace(ee.to, w);
        }
      }
    }
  }
  int diam = 0;
  REP(s, N) REP(t, N) {
    if (diam < dist[s][t]) diam = dist[s][t];
  }
  vector<pair<int, int>> cand;
  REP(s, N) FOR(t, s + 1, N) {
    if (dist[s][t] == diam) cand.emplace_back(s, t);
  }
  vector<int> town;
  REP(v, N) {
    bool quiet = true;
    for (auto&& st : cand) {
      int s = st.first, t = st.second;
      if (dist[s][v] + dist[v][t] == dist[s][t]) {
        quiet = false;
        break;
      }
    }
    if (quiet) town.push_back(v);
  }
  cout << town.size() << endl;
  for (int v : town) {
    cout << v + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 28184
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String o = sc.next();
        String e = sc.next();
        int n = o.length() + e.length();
        for(int i = 1; i <= n; i++){
            if(i % 2 == 1){
                System.out.print(o.charAt((i-1)/2));
            } else {
                System.out.print(e.charAt((i-1)/2));
            }
        }
    }
}

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

string s;
int n;

int main(){
	cin >> n;
	cin >> s;
	for(int i=0;i<s.size();i++){
		int tmp = s[i] - 'A';
		tmp = (tmp+n)%26;
		s[i] = tmp+'A';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

int main() {
    int n;
	cin >> n;
    ll a[n];
    ll sum=0;
    ll nosum=0;
    fr(i,n){
      cin >> a[i];
      sum+=a[i];
      if(i%2==1)nosum+=a[i];
    }
    ll ans = sum-nosum*2;
    
    cout << ans << " ";
    fro(i,1,n){
      ans = a[i-1]*2-ans;
      cout << ans << " ";
    }
}


Measured memory_bytes: 2048
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dfs(string s) {
	//cout << s << endl;
	s.erase(0, 1);
	s.erase(s.size()-1, 1);
	//cout << s << endl;
	if(s[0] != '[') return stoi(s)/2+1;

	VI a;
	int tmp = 0;
	string t = "";
	REP(i, s.size()) {
		if(s[i] == '[') tmp++;
		else if(s[i] == ']') tmp--;
		t += s[i];
		if(tmp == 0) {
			a.PB(dfs(t));
			t = "";
		}
	}

	sort(ALL(a));
	int ret = 0;
	REP(i, a.size()/2+1) ret += a[i];
	return ret;
}

signed main(void)
{
	int n;
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		cout << dfs(s) << endl;
	}

	return 0;
}

Measured memory_bytes: 3180
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

max_count = -9999
for i in range(len(s)):

    #print(s[i],s.count(s[i]),t.count(s[i]))

    if (s.count(s[i]) - t.count(s[i])) > max_count:
        max_count = s.count(s[i]) - t.count(s[i])

if max_count > 0:
    print(max_count)
else:
    print(0)

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

template<unsigned long maxsize, unsigned long MOD, unsigned long primesize>
class divisor_convolution_coefficients{
    unsigned long sieve[maxsize];
public:
    unsigned long prime[primesize];
    unsigned long coef[maxsize];
    constexpr divisor_convolution_coefficients() : coef(), sieve(), prime(){
        coef[1] = 1;
        for(unsigned long i = 2; i < maxsize; ++i){
            coef[i] = coef[MOD % i] * (MOD - MOD / i) % MOD;
            sieve[i] = 1;
        }
        for(unsigned long i = 2, c = 0; i < maxsize; ++i)if(sieve[i]){
            prime[c++] = i;
            for(unsigned long j = i; j < maxsize; j += i){
                sieve[j] = 0;
                (coef[j] *= MOD + 1 - i) %= MOD;
            }
        }
    }
};

constexpr unsigned long MOD = 998244353;
constexpr unsigned long mx = 1000001;
constexpr divisor_convolution_coefficients<mx, MOD, 78498> coef{divisor_convolution_coefficients<mx, MOD, 78498>()};

int main(){
    using namespace std;

    unsigned long N;
    cin >> N;

    unsigned long ans{0};
    vector<unsigned long> hoge(mx);
    for(unsigned long _ = 0, i; _ < N; ++_){
        cin >> i;
        hoge[i] += i;
        if(hoge[i] >= MOD)hoge[i] -= MOD;
    }

    for(const auto& i : coef.prime)for(unsigned long j = mx / i; j; --j){
        hoge[j] += hoge[j * i];
        if(hoge[j] >= MOD)hoge[j] -= MOD;
    }

    ans = MOD - hoge[1];
    for(unsigned long i = 1; i < mx; ++i)if(hoge[i])ans += hoge[i] * hoge[i] % MOD * coef.coef[i] % MOD;
    (ans += (ans & 1) * MOD) >>= 1;
    cout << ans % MOD << endl;

    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n; cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int m;
    cin>>m;
    int ans=0;
    rep(i,m){
        int t;
        cin>>t;
        int imax=n;
        int imin=-1;
        int mid;
        while(imax-imin>1){
            mid=(imax+imin)/2;
            if(v[mid]>t)imax=mid;
            else imin=mid;
        }
        if(v[imin]==t)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3544
//  #include <bits/stdc++.h>
//  #define fastcode  ios_base::sync_with_stdio(false);    cin.tie(NULL);
//   using namespace std;
//   /*  
//   - Our collaboration is a thing of beauty.
//   - And for those who fear Allah , He will make their path easy. 
//   */


//   int main()
//   {
//     fastcode
//     int n;
//     cin>>n;
//     int a[n+2];
//     int sum=0;
//     for(int i =1 ; i<=n ; i++ )
//     {
//       cin>>a[i];
//       sum+=a[i];
//     }
//     int t;
//     cin>>t;
//     int idx,neww;
//     while (t--)
//     {
//       cin>>idx>>neww;
//       cout<<sum+(neww-a[idx])<<endl;
//     }
    
//   }
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N,i=0,j=0,t=0,M;
cin>>N;
int T[N+5];
for(i=1;i<=N;i++)
{
cin>>T[i];
t+=T[i];
}
cin>>M;
int p[M+5],x[M+5];
for(j=1;j<=M;j++)
{
cin>>p[j]>>x[j];
cout<<t+(x[j]-T[p[j]])<<endl;
}}

Measured memory_bytes: 256
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ans=[]
for i in range(min(x,k+1)):
	for j in range(y):
		if (i+1)*(j+1)>k:
			break
		for l in range(z):
			if (i+1)*(j+1)*(l+1)<=k:
				ans.append(a[i]+b[j]+c[l])
			else:
				break
ans.sort()
for i in range(k):
	print(ans[-i-1])

Measured memory_bytes: 8708
#include<bits/stdc++.h>
using namespace std;
int main()
{
  double N,a,p;
  int count=0;
  cin>>N;
  for (int i=1;i<=N;i++)
{
    if (i%2==1)
    {
         a++;
    }
}
    p=a/N;
    cout<<p;
  return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  ll sum=0;
  while(true){
    if(k<=0)
      break;
    if(a<=0)
      break;
    sum++;
    a--;
    k--;
  }
  while(true){
    if(b<=0)
      break;
    if(k<=0)
      break;
    b--;
    k--;
  }
  while(true){
    if(k<=0)
      break;
    if(c<=0)
      break;
    sum--;
    c--;
    k--;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3632
N = input()
A = map(int, raw_input().split())
for i in range(len(A)):
    v = A[i]
    j = i - 1
    while (j >= 0) & (A[j] > v):
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print ' '.join(map(str, A))

Measured memory_bytes: 6412