akhauriyash/Code-Regression huggingface dataset:
// abc130_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int X, A;
    cin >> X >> A;
    
    if (X < A){
        print(0);
    } else {
        print(10);
    }

    return 0;
}


Measured memory_bytes: 256
/*..........mango is luv..........*/
#include<bits/stdc++.h>
using namespace std;
#define fk(i,start,end) for(ll i=start;i<ll(end);i++)
typedef long long int ll;
string A="YES";
string B="NO";
int main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
     string s,t;
     cin>>s>>t;
     ll m=t.size(),ans=0;
     fk(i,0,s.size()-t.size()+1)
     {  
     	ans=0;
     	fk(j,0,t.size())
     	{
     		if(t[j]!=s[i+j])
     		{
     			ans++;
     		}
     	}
     	m=min(ans,m);
     }
     cout<<m<<endl;


  
  return 0;

}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define loop_from_to(from, to, i) for(int i=from;i<=to;i++)
#define repeat(n) for(int i__=0;i__<n;i__++)
#define multi_cin(n, array) loop(n,i){cin>>array[i];}
#define assign_if_smaller(var, val) if(var>val)var=val;
#define assign_if_larger(var, val) if(var<val)var=val;
#define each(itr, c) for(__typeof((c).begin()) itr=(c).begin(); itr!=(c).end(); itr++)
#define r_each(itr, c) for(__typeof((c).rbegin()) itr=(c).rbegin(); itr!=(c).rend(); itr++)

using namespace std;

double calc(int x1,int y1,int x2,int y2) {
  return (double)(x2-x1)*(y1+y2)/2;
}

int main(int argc, char const* argv[])
{
  int count=0;
  while (true) {
    int n;cin>>n;
    if(!n) break;
    int px,py;cin>>px>>py;
    int xzero=px,yzero=py;
    double area=0;
    n--;
    while(n--) {
      int x,y;cin>>x>>y;
      area+=calc(px,py,x,y);
      px=x;py=y;
    }
    area+=calc(px,py,xzero,yzero);
    cout<<++count<<" ";
    cout<<fixed<<setprecision(1)<<area<<endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	int c[]={0,0,0};
	int d[]={0,0,0};
	cin>>c[0]>>c[1]>>c[2];
	d[0]=abs(c[2]-c[1])+abs(c[0]-c[1]);
	d[1]=abs(c[0]-c[2])+abs(c[1]-c[2]);
	d[2]=abs(c[2]-c[0])+abs(c[1]-c[0]);
	sort(d+0,d+3);
	cout<<d[0];
	return 0;
}

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


int main() {
  long long a, b, n;
  scanf("%lld %lld %lld", &a, &b, &n);

//  for(long long i=0;i<=n;i++){
//    long long val = floor((double)a*(double)i/(double)b) - a*floor((double)i/(double)b);
//    printf("x=%lld | %lld\n", i, val);
//  }
  long long val;
  if(n>b-1){
    val = floor((double)a*(double)(b-1)/(double)b) - a*floor((double)(b-1)/(double)b);
  }
  else{
    val = floor((double)a*(double)(n)/(double)b) - a*floor((double)(n)/(double)b);
  }
  printf("%lld", val);
  return 0;
} 

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  
  int ans = 0;
  for (int hi : h) {
    if (hi >= k) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
process.stdin.resume();
process.stdin.setEncoding('utf8');

const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

reader.on('line', s => {
  const RLs = s.split('LR').map(RL => `R${RL}L`);

  RLs[0] = RLs[0].slice(1);
  RLs[RLs.length - 1] = RLs[RLs.length - 1].slice(0, -1);

  const numbers = RLs.map(RL => {
    const n  = RL.length;
    const nR = RL.match(/(R+)/).pop().length;

    const [ R,  L  ] = [ nR, RL.length - nR ];
    const [ pR, pL ] = [ R % 2, L % 2 ];

    const result = [ ...new Array(n) ].map(_ => 0);

    switch (pR + pL) {
      case 0:
      case 2: {
        result[R - 1] = result[R] = n / 2;

        break; 
      }

      case 1: {
        result[R - 1] = Math.floor(n / 2) + 1 * pR;
        result[R]     = Math.floor(n / 2) + 1 * pL;

        break;
      }
    }

    return result;
  }).flatMap(xs => xs).join(' ');

  console.log(numbers);

  process.exit(0);
});


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

int main(){
    long long n, k;
    cin >> n >> k;
    long long ans = (n/k)*(n/k)*(n/k);
    if(k%2==0){
        long long t = n/(k/2) - n/k;
        ans += t*t*t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: i64 = sc.cin();
    let k: i64 = sc.cin();
    let mut ans: f64 = 0.0;
    for m in 1..n + 1 {
        let mut m = m;
        let mut p: f64 = 1.0;
        while m < k {
            p /= 2.0;
            m *= 2;
        }
        // trace!(m, p);
        ans += p;
    }
    put!(ans / n as f64);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#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);
	ll n,w;
	cin>>n>>w;
	vector<vector<ll>> g(4),sum(4,vector<ll>(200,0));
	ll st;
	rep(i,n){
		ll w,v;
		cin>>w>>v;
		if(i==0){
			st=w;
		}
		w-=st;
		g[w].push_back(v);
	}
	rep(i,4){
		sort(begin(g[i]),end(g[i]),greater<ll>());
	}
	rep(i,4){
		rep(j,g[i].size()){
			sum[i][j+1]=sum[i][j]+g[i][j];
		}
	}
	ll ans=0;
	rep(i,g[0].size()+1)rep(j,g[1].size()+1)rep(k,g[2].size()+1)rep(l,g[3].size()+1){
		ll now=st*(i+j+k+l);
		now+=(j+k+l);
		now+=(k+l);
		now+=(l);
		if(now<=w) chmax(ans,sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l]);
	}
	cout<<ans<<endl;
}

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

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

    int n, m;
    cin >> n >> m;

    if (m & 1) {
        cout << -1 << endl;
        return 0;
    }

    vector<vector<int>> adj(n), ans(n);
    set<pair<int, int>> es;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
        es.insert({min(a, b), max(a, b)});
    }

    vector<bool> visited(n);
    function<void(int)> dfs = [&](int v) {
        for (int s : adj[v]) {
            if (!visited[s]) {
                visited[s] = true;
                dfs(s);
                es.erase({min(s, v), max(s, v)});
            }
        }
    };
    visited[0] = true;
    dfs(0);
    for (auto &e : es) {
        ans[e.first].push_back(e.second);
    }
    visited.assign(n, false);
    function<void(int)> dfs2 = [&](int v) {
        for (int s : adj[v]) {
            if (!visited[s]) {
                visited[s] = true;
                dfs2(s);
                if (ans[s].size() & 1) {
                    ans[s].push_back(v);
                } else {
                    ans[v].push_back(s);
                }
            }
        }
    };
    visited[0] = true;
    dfs2(0);
    for (int i = 0; i < n; i++) {
        assert(ans[i].size() % 2 == 0);
    }
    for (int i = 0; i < n; i++) {
        for (int a : ans[i]) {
            cout << i + 1 << ' ' << a + 1 << '\n';
        }
    }
}

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

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	std::vector<int64_t> V(N + 1);
	std::vector<std::pair<int64_t, int>> nega;
	for (int i{1}; i <= N; i++)
	{
		scanf("%lld", &V[i]);
		if (V[i] < 0) nega.push_back({V[i], i});
		V[i] += V[i - 1];
	}
	std::sort(nega.begin(), nega.end());

	int64_t max{};
	for (int left{}; left <= N; left++)
		for (int right{N}; right >= left; right--)
		{
			int num{left + (N - right)};
			if (num > K) continue;
			int64_t sum{V[left] + (V[N] - V[right])};
			int rest{K - num};
			for (auto& e: nega)
			{
				if (!rest) break;
				if (left < e.second && e.second <= right)
					continue;
				rest--;
				sum -= e.first;
			}

			max = std::max(max, sum);
		}
	printf("%lld\n", max);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int M, D;
  cin >> M >> D;

  int ans = 0;
  auto check = [](int m, int d) {
    if (d/10 < 2 || d%10 < 2) return false;
    return ((d/10) * (d % 10)) == m;
  };
  for (int m = 1; m <= M; m++) {
    for (int d = 1; d <= D; d++) {
      if (check(m, d)) {
        cerr << m << ' ' << d << endl;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){ 
    string s;
    cin>>s;
    int a=0;
    int b=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'||s[i]=='G'||s[i]=='C'||s[i]=='T'){
            a++;
        }else{
            b=max(a,b);
            a=0;
        }
    }
  b=max(a,b);
    cout<<b;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		int dp[][];
		int max;

		n = sc.nextInt();
		while (n != 0) {
			max = 0;
			dp = new int[n][n];

			for (int i = 0; i < n; i++) {
				String st = sc.next();
				for (int j = 0; j < n; j++) {
					if (st.charAt(j) == '.') {
						if (1 <= i && 1 <= j) {
							dp[i][j] = Math.min(dp[i - 1][j - 1], Math.min(dp[i - 1][j], dp[i][j - 1])) + 1;
						} else {
							dp[i][j] = 1;
						}
						if (max < dp[i][j]) {
							max = dp[i][j];
						}
					}
				}
			}

			System.out.println(max);

			n = sc.nextInt();
		}
	}
}

Measured memory_bytes: 20000
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;

vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  for( ll i = 2; i * i <= n; ++i){
    if(n % i) continue;
    res.emplace_back(i, 0);
    while(n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if(n != 1) res.emplace_back(n, 1);
  return res;
}

int main() {
  ll n, p;
  cin >> n >> p;
  auto primes = factorize(p);
  ll ans = 1;
  for (auto p : primes) {
    ll prime = p.first;
    int nums = p.second;
    while (nums >= n) {
      nums -= n;
      ans *= prime;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string s; cin >> s;
	int n = s.size();
	string pre;
	string tmp;
	int ans1 = 0;
	for(int i = 0; i < n; ++i) {
		char c = s[i];
		tmp += c;
		if(pre != tmp) {
			pre = tmp;
			tmp = "";
			ans1++;
		}
	}
	int ans2 = 0;
	pre = "";
	tmp = "";
	for(int i = n - 1; i >= 0; --i) {
		char c = s[i];
		tmp = c + tmp;
		if(pre != tmp) {
			pre = tmp;
			tmp = "";
			ans2++;
		}
	}
	cout << max(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 644
#include <cstdio>

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int t[10], d;
		for (d = 0; n; ++d, n /= 8)
			t[d] = n % 8;
		for (int i = d-1; i >= 0; --i)
			printf("%d", t[i] >= 5 ? t[i]+2 : t[i] == 4 ? t[i]+1 : t[i]);
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
using namespace std;

int n,m;
char s[125][125];
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};
int ans;

bool dfs(int ss,int ts, char p){
    if(p=='.'){
        return false;
    }
    s[ss][ts] = '.';
    for(int i=0;i<4;i++){
        int xx = ss+dx[i];
        int yy = ts+dy[i];
        if(xx>=0&&xx<n&&yy>=0&&yy<m&&s[xx][yy]==p){
            dfs(xx,yy,p);
        }
    }
    return true;
}
int main(){
    while(~scanf("%d%d",&n,&m)){
        if(!n&&!m)break;
        for(int i=0;i<n;i++){
            scanf("%s",s[i]);
        }
        ans=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(dfs(i,j,s[i][j])){
                    ans++;
                }
            }
        }
        printf("%d\n",ans);
        }
    return 0;
}


Measured memory_bytes: 3648
package main

import (
	"fmt"
)

func main() {
	var s string
	var k int64
	fmt.Scan(&s, &k)
	for i := int64(0); i < k; i++ {
		if s[i] != '1' {
			fmt.Println(string(s[i]))
			return
		}
	}
	fmt.Println("1")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = pow(10, 5)+1;//+1しないとREになる(out of rangeになるんかな?? )

int main(){
  int N;
  cin >> N;
  
  map<P, int> num_mp;
  for(int i=1; i<=N; i++){
    int bottom = i % 10;
    
    int i_tmp1 = i;
    int i_tmp2 = i;
    int num_digit = 0;
    while(i_tmp1){
      i_tmp1 /= 10;
      num_digit++;
    }
    int top = i_tmp2 / pow(10, num_digit-1);
    //cout<<" i: "<<i<<" top: "<<top<<" bottom: "<<bottom<<" num_digit: "<<num_digit<<endl;
    num_mp[P(top, bottom)]++;
    
  }
  
  int ans = 0;
  for(int i=1; i<=9; i++){
    for(int j=1; j<=9; j++){
      ans += num_mp[P(i,j)] * num_mp[P(j,i)];
      //cout<<"i: "<<i<<" j: "<<j<<" num_mp[P(i,j)]: "<<num_mp[P(i,j)]<<" num_mp[P(j,i)]: "<<num_mp[P(j,i)]<<endl;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

    int x = 2 * b;

    if(x >= a) {
      System.out.println(0);
    } else {
      System.out.println(a-x);
    }
  }

}


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

string s;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	int n = s.size();
	int m = count(s.begin(), s.end(), 'o');
	if(m + 15 - n >= 8) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a, t;
  cin >> n >> a;
 
  t = n % 500 - a;
  if (t <= 0) {
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 384
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

struct rec{
    vector<char> v;
    bool reversed;
};

void print(rec r){
    if (!r.reversed){
        for (int i = 0;i < r.v.size();i++) cout << r.v[i];
    }
    else{
        for (int i = r.v.size()-1;i >= 0;i--) cout << r.v[i];
    }
}

int main(int argc, const char * argv[]) {
    string str;
    bool reversed = false;
    rec* all_begin = new rec;
    all_begin->reversed = true;
    (all_begin->v).clear();
    rec* all_end = new rec;
    all_end->reversed = false;
    (all_end->v).clear();
    
    cin >> str;
    int q;
    cin >> q;
    while (q--){
        int op;
        cin >> op;
        if (op == 1){
            reversed ^= 1;
            swap(all_begin,all_end);
            all_begin->reversed ^= 1;
            all_end->reversed ^= 1;
        }
        else{
            int f;
            string c;
            cin >> f >> c;
            char ch = c[0];
            if (f == 1) (all_begin->v).push_back(ch);
            else (all_end->v).push_back(ch);
        }
    }
    if (!reversed){
        print(*all_begin);
        cout << str;
        print(*all_end);
    }
    else{
        print(*all_begin);
        reverse(str.begin(),str.end());
        cout << str;
        print(*all_end);
    }
    return 0;
}


Measured memory_bytes: 1024
// #includes {{{
#include <bits/stdc++.h>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

Int ai,ao,at,aj,al,as,az;

int main(){
	cin>>ai>>ao>>at>>aj>>al>>as>>az;
	Int ans = 0;
	REP(lji,2){
		Int al0 = al,aj0=aj,ai0=ai;
		Int ans0 = 0;
		if(lji){
			if(not (al0>0 and aj0>0 and ai0>0))continue;
			Int m = 1;
			al0-=m;aj0-=m;ai0-=m;
			ans0 += m*6;
		}
		ans0+=(aj0/2)*4;
		ans0+=(al0/2)*4;
		ans0+=(ai0/2)*4;
		ans0+=ao*2;
		ans0/=2;
		ans = max(ans0,ans);
	}
	cout<<ans<<endl;
	return 0;
}


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

#define ff       first
#define ss       second
#define vpop     pop_back
#define pb       push_back
#define mp       make_pair
#define ll       long long int
#define umap	 unordered_map
#define pii	 pair<int, int>
#define clz(x)   __builtin_clz(x)       
#define ctz(x)   __builtin_ctz(x)      
#define all(v)   v.begin(), v.end() 
#define sbts(x)  __builtin_popcount(x) 
#define ull      unsigned long long int
#define ms(a,v)  memset(a, v, sizeof(a))
#define ps(x, y) fixed << setprecision(y) << x
const int MOD  = 1e9 + 7;
const ll  INF  = 1e12;
const int   N  = 1e5 + 1;
int cnt[1000001];

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  cout.tie(NULL);
//  *-------------------------------*
    int n; cin >> n; int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }   
    int res = 1, i = 0, g = arr[0];
    for ( ; res && i < n; i++) {
        g = __gcd(g, arr[i]); cnt[arr[i]] += 1;
        for (int j = 2; j * j <= arr[i]; j++) {
            if (arr[i] % j == 0) {
                cnt[j] += 1;
                int d = arr[i] / j;
                if (d != j)
                    cnt[d] += 1; 
                if (cnt[j] > 1 || cnt[d] > 1) {
                    res = 0;
                    break;
                }
            }
        }
        if (arr[i] != 1 && cnt[arr[i]] > 1) {
            res = 0;
            break;
        }
    }
    for (; i < n; i++) {
        g = __gcd(g, arr[i]);
    }
    if (res) cout << "pairwise coprime";
    else if (g == 1) cout << "setwise coprime";
    else cout << "not coprime";
    return 0;
}

Measured memory_bytes: 7868
//My life was going great until I stumble upon this question ); ):

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

long long MOD = 1000000007; //1e9+7
long long INF = 1e18;
typedef long long ll;
typedef long double ld;
#define pii		pair<int, int>
#define pll		pair<long long, long long>
#define fi 		first
#define se 		second
#define fr(i,a,b) 	for(int i=a;i<b;i++)
#define out2(a,b) 	cout<<a<<" "<<b<<"\n";
#define all(v) 		v.begin(), v.end()
#define pb          	emplace_back

void solve()
{
    int n, x, y;
    bool ans=false;
    cin>>n;
    int cnt=0;
    while(n--){
        cin>>x>>y;
        if(x==y) cnt++;
        else cnt=0;
        if(cnt==3){
            ans=true;
        }
    }
    if(ans) cout<<"Yes";
    else cout<<"No";
}

int main() {
	FIO;
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int test;
	//cin>>test;
	test=1;
	for(int t=1;t<=test;t++){
        //cout<<"Case #"<<t<<": ";
        solve();
        //cout<<ans<<"\n";
	}
	return 0;
}


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

using namespace std;

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

    int N,K; cin>>N>>K;
    string S; cin>>S;

    auto& t = S[K-1];
    if (t == 'A')
        t = 'a';
    if (t == 'B')
        t = 'b';
    if (t == 'C')
        t = 'c';
    cout << S << endl;
    
    return 0;
}



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

using namespace std;
typedef long long ll;
const int N=1e9+10;
int main()
{
	ll n;
	cin>>n;
	ll ans=0; 
	for(int i=1;i<=n-1;i++)
		ans+=i;
	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 256
import math
from collections import deque

# -----------------
# 素数列挙
def make_prime_list(num):
    if num < 2:
        return []

    prime_list = [i for i in range(num+1)]
    prime_list[1] = 0
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0 :
            continue
        if prime > num_sqrt:
            break

    for non_prime in range(2*prime, num, prime):
        prime_list[non_prime] = 0
    
    return [prime for prime in prime_list if prime != 0]
# -----------------

# -----------------
# 素因数分解
def prime_factorization(num):
    if num <= 1:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list(num_sqrt)

        dict_counter = {}
        for prime in prime_list:
            while num % prime == 0:
                if prime in dict_counter:
                    dict_counter[prime] += 1
                else:
                    dict_counter[prime] = 1
                num //= prime
        
        if num != 1:
            if num in dict_counter:
                dict_counter[num] += 1
            else:
                dict_counter[num] = 1

        return dict_counter
# -----------------

# -----------------
# 約数の個数
def search_divisor_num(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        divisor_num = 1
        dict_fact = prime_factorization(num)
        for value in dict_fact.values():
            divisor_num *= (value + 1)
        return divisor_num
# -----------------

n = int(input())
res = [num for num in range(1,n+1,2) if search_divisor_num(num) == 8]
print(len(res))

Measured memory_bytes: 3444
N = int(input())
A_list = list(map(int, input().split()))
limit = 10**18
sum = 1

if 0 in A_list:
    print(0)
else:
    for i in  A_list:
        sum = sum * i
        if sum > limit:
            sum = -1
            break
    print(sum)


Measured memory_bytes: 21708
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,a;cin>>s;
  if(s.at(0)=='B')a="";
  else a=s.at(0);
  if(s.size()>1){
    for(int i=1;i<s.size();i++){
      if(s.at(i)=='B'){
        if(a.size()!=0)a=a.substr(0,a.size()-1);
      }
      else a=a+s.at(i);
    }
  }
  cout<<a<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define maxn 20005
#define ls x<<1
#define rs x<<1|1
#define mid (l+r>>1)
using namespace std;
int read(){
    int rt=0;
    char c=getchar();
    while(c<'0'||c>'9')
        c=getchar();
    while(c>='0'&&c<='9'){
        rt=rt*10+c-'0';
        c=getchar();
    }
    return rt;
}


struct Edge{
    int to,next;
    Edge(){}
    Edge(int to,int next):to(to),next(next){}
}ed[maxn*40];
int head[maxn*8],cnt;
void add(int a,int b){
    ed[++cnt]=Edge(b,head[a]);
    head[a]=cnt;
}

struct node{
    int val,pos;
    node(){}
    node(int val,int pos):val(val),pos(pos){}
}nd[maxn*2];
bool cmp(node a,node b){
    if(a.val==b.val)
        return a.pos<b.pos;
    return a.val<b.val;
}


int tr[maxn*8],tot;
void build(int l,int r,int x){
    if(l==r){
        tr[x]=nd[l].pos;
        return;
    }
    tr[x]=++tot;
    build(l,mid,ls);
    build(mid+1,r,rs);
    add(tr[x],tr[ls]);
    add(tr[x],tr[rs]);
}
void Add(int l,int r,int x,int L,int R,int u){
    if(L<=l&&r<=R){
        add(u,tr[x]);
        return;
    }
    if(L<=mid)
        Add(l,mid,ls,L,R,u);
    if(R>mid)
        Add(mid+1,r,rs,L,R,u);
}

int dfn[maxn*8],low[maxn*8],sta[maxn*8],col[maxn*8];
int num,dfs,top;
bool vis[maxn*8];
void tarjan(int x){
    vis[x]=1;
    sta[++top]=x;
    dfn[x]=low[x]=++dfs;
    for(int i=head[x];i;i=ed[i].next){
        int to=ed[i].to;
        if(!dfn[to]){
            tarjan(to);
            low[x]=min(low[x],low[to]);
        }
        else if(vis[to])
            low[x]=min(low[x],dfn[to]);
    }
    if(low[x]==dfn[x]){
        vis[x]=0;
        col[x]=++num;
        while(sta[top]!=x){
            col[sta[top]]=num;
            vis[sta[top--]]=0;
        }
        top--;
    }
}

int n;
int val[maxn][2];
bool check(int x){
    memset(head,0,sizeof(head));
    memset(dfn,0,sizeof(dfn));
    cnt=0;tot=2*n;dfs=num=top=0;
    build(1,2*n,1);
    for(int i=1;i<=n;i++){
        for(int j=0;j<=1;j++){
            int l=lower_bound(nd+1,nd+1+2*n,node(val[i][j]-x+1,0),cmp)-nd;
            int r=upper_bound(nd+1,nd+1+n*2,node(val[i][j]+x-1,2*n+1),cmp)-nd-1;
            int m=lower_bound(nd+1,nd+1+n*2,node(val[i][j],i+(j^1)*n),cmp)-nd;
            if(l<m)
                Add(1,2*n,1,l,m-1,i+j*n);
            if(r>m)
                Add(1,2*n,1,m+1,r,i+j*n);
        }
    }
    for(int i=1;i<=tot;i++){
        if(!dfn[i])
            tarjan(i);
    }
    for(int i=1;i<=n;i++)
        if(col[i]==col[i+n])    
            return 0;
    return 1;
}
int main(){
    n=read();
    int maxx=0;
    for(int i=1;i<=n;i++){
        val[i][0]=nd[i*2-1].val=read();nd[i*2-1].pos=i+n;   //存反点
        val[i][1]=nd[i*2].val=read();nd[i*2].pos=i;
        maxx=max(nd[i*2].val,max(maxx,nd[i*2-1].val));
    }
    sort(nd+1,nd+1+2*n,cmp);
    int l=0,r=maxx,ans;
    while(l<=r){
        if(check(mid)){
            ans=mid; 
            l=mid+1;
        }
        else
            r=mid-1;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}


int main(){
    int n=in();
    string s=stin();
    vec a(n);
    rep(i,n){
        if(s[i]=='R')a[i]=0;
        else if(s[i]=='G')a[i]=1;
        else a[i]=2;
    }
    vector<vec> b(3,vec(n+1));
    b[0][0]=b[1][0]=b[2][0]=0;
    rep(i,n){
        rep(j,3){
            b[j][i+1]=b[j][i];
            if(a[i]==j)b[j][i+1]++;
        }
    }
    ll ans=0;
    rep(i,n){
        int tmp=0;
        tmp+=b[(a[i]+1)%3][i] * (b[(a[i]+2)%3][n]-b[(a[i]+2)%3][i]);
        tmp+=b[(a[i]+2)%3][i] * (b[(a[i]+1)%3][n]-b[(a[i]+1)%3][i]);
        for(int k=1;k<=min(i,n-i-1);k++){
            if(a[i-k]!=a[i] && a[i]!=a[i+k] && a[i+k]!=a[i-k])tmp--;
        }
        ans += tmp;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include <map>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main()
{
    int n;
    cin >> n;
    int m = 1;
    for (m; m * (m + 1) / 2 < n; m++){
        continue;
    }
    int ex = m * (m + 1) / 2-n;
    for (int i = 1; i <= m;i++){
        if(i!=ex){
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  N %= 1000;
  if(N == 0){
    cout << 0 << "\n";
    return 0;
  }
  cout << 1000 - N << "\n";
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;

	vector<int> x(N), y(M);
	for(int i=0; i<N; i++)
		cin >> x[i];
	for(int i=0; i<M; i++)
		cin >> y[i];

	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	int l = x.back();
	int r = y.front();
	string ret = "War";
	for(int i=X+1; i<=Y; i++){
		if(i > l && i <= r){
			ret = "No War";
			break;
		}
	}
	
	cout << ret << endl;

	return 0;
}


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

using ll = long long;
constexpr ll INF = 1LL<<60;

void chmin(ll &a, ll b){
    a = min(a, b);
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> h(N+2);
    for(int i=0;i<N;i++){
        cin >> h[i+1];
    }
    vector<vector<ll> > dp(N+2, vector<ll>(K+1,INF));
    dp[0][0] = 0;
    for(int i=0;i<N+1;i++){
        for(int j=0;j<=K;j++){
            chmin(dp[i+1][j], dp[i][j] + max(h[i+1]-h[i], 0LL));
            for(int k=1;j+k<=K&&i+k<=N;k++){
                chmin(dp[i+k+1][j+k], dp[i][j] + max(h[i+k+1]-h[i],0LL));
            }
        }
    }
    cout << dp[N+1][K] << endl;
    return 0;
}


Measured memory_bytes: 1024
#E - Red and Green Apples
X,Y,A,B,C= map(int, input().split())
a =sorted(list(map(int, input().split())),reverse=True)
b =sorted(list(map(int, input().split())),reverse=True)
c =sorted(list(map(int, input().split())),reverse=True)
DP_a =a[:X]
DP_b =b[:Y]
DP_a.extend(DP_b)
DP_a.extend(c)
ans = sorted(DP_a,reverse=True)
print(sum(ans[:X+Y]))

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

int h, w, ans = 0;	char vis[50][50] = {0};
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};

int bfs(int x, int y) {
	int dist[h][w], mx = 0;		memset(dist, -1, sizeof(dist));
	queue <pair <int, int>> q;
	q.push({x, y});		dist[x][y] = 0;
	while (!q.empty()) {
		pair<int, int> z = q.front();
		int u = z.first;	int v = z.second;
		q.pop();
		for (int i = 0; i < 4; i++) {
			int nu = u + dx[i], nv = v + dy[i];
			if (0 <= nu && nu < h && 0 <= nv && nv < w) {	
				if (vis[nu][nv] == '.' && dist[nu][nv] == -1) {
					dist[nu][nv] = dist[u][v] + 1;
					q.push({nu, nv});
				}
			}
		}
	}
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			mx = max(mx, dist[i][j]);
	return mx;
}

int main() {
	cin >> h >> w;
	char temp;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> vis[i][j];
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (vis[i][j] == '.')
				ans = max(ans, bfs(i, j));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++)cin >> d.at(i);
  int sum=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      sum += (d.at(i)*d.at(j));
    }
  }
  cout << sum << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
	#endif
	ios_base::sync_with_stdio(0), cin.tie(0);

	map<char, char> mp =
	{
			{'A', 'T'},
			{'T', 'A'},
			{'C', 'G'},
			{'G', 'C'}
	};

	string s;
	cin >> s;

	int n = s.length(), ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = 1; i+j <= n; ++j)
		{
			auto s2 = s.substr(i, j);
			int c = 0;
			for (auto k : s2)
				c += mp.find(k) != mp.end();

			if (c == s2.length())
				ans = max(ans, c);
		}

	cout << ans << "\n";

	return 0;
}


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

using namespace std;

int main() {
    int n;

    cin >> n;

    vector<int> a(n);

    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }

    map<int, int> l;

    for(int i = 0; i < n; ++i) {
        l[i + a.at(i)]++;
    }

    int_fast64_t c = 0;

    for(int i = 0; i < n; ++i) {
        c += l[i - a.at(i)];
    }

    printf("%ld\n", c);

    return 0;
}

Measured memory_bytes: 21108
#include <stdio.h>

int main(void)
{
	int n, i;
	int s[200010];
	int b[200010]={0};

	scanf("%d", &n);
	for (i = 2; i <= n; i++) scanf("%d", &s[i]);
	for (i = 2; i <= n; i++) b[s[i]]++;
	for (i = 1; i <= n; i++) printf("%d\n", b[i]);
	return 0;
}

Measured memory_bytes: 3244
#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*100 + 11;

int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
int dp[NMAX][101];
int w[NMAX], v[NMAX];
void solve()
{
    cin>>n>>m;

    for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
    }

    // memset(dp,1e12,sizeof(dp));

    dp[0][0] = 0;
    int ans = 0;
    for(int i=0;i<=100000;i++){
        for(int j=0;j<=n;j++){
            if(i == 0){
                dp[i][j] = 0;
                continue;
            }
            if(j == 0){
                dp[i][j] = 1e13;
                continue;
            }
            dp[i][j] = dp[i][j-1];

            if(v[j] <= i){
                dp[i][j] = min(dp[i][j],w[j] + dp[i-v[j]][j-1]);
                // tr(i,j,dp[i][j]);
            }

            if(dp[i][j] <= m){
                // tr(i,m);
                ans = max(ans,i);
            }
        }
    }
    cout<<ans;
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 79232
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    Scanner scnr = new Scanner(System.in);
    ArrayList<Integer> list = new ArrayList<Integer>();
    
    int len = scnr.nextInt();
    int numHouse = scnr.nextInt();
    for (int i = 0; i < numHouse; i++) {
      list.add(scnr.nextInt());
    }
    
    int betweenLen = 0;
    int maxBetweenLen = list.get(0);
    
    for (int i = 0; i < list.size(); i++) {
      if (i == list.size() - 1) {
        betweenLen = len - list.get(i) + list.get(0);
      }
      else {
        betweenLen = list.get(i + 1) - list.get(i);
      }
      
      // System.out.println(betweenLen);
      
      if (maxBetweenLen < betweenLen) {
        maxBetweenLen = betweenLen;
      }
    }
    
    // System.out.println(len);
    // System.out.println(numHouse);
    // System.out.println(list);
    System.out.println(len - maxBetweenLen);
  }
}

Measured memory_bytes: 94676
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
        String ss1 = s1.substring(0, 1).toUpperCase();
        String ss2 = s2.substring(0, 1).toUpperCase();
        String ss3 = s3.substring(0, 1).toUpperCase();
        System.out.print(ss1 + ss2 + ss3);
    }
}

Measured memory_bytes: 39328
#include<bits/stdc++.h>
using namespace std;
const long long INFdesu=2E10;

int absol(int a){
    if(a>0) return a;
    else return -a;
}

int main(){
   int N;
   vector<int> A;
   cin >> N;
   int tmp;
   for(int i=0;i<N;i++){
       cin >> tmp;
       A.push_back(tmp-i-1);
   }
   sort(A.begin(),A.end());
   int med=A[N/2];
   long long sum=0;
   for(int i=0;i<N;i++){
       sum+=absol(A[i]-med);
   }
   cout << sum << endl;
}


Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

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

	int ans = 0;

	for (int i = 1; i <= N; i++){
		ans += i;
	}

	
	cout << ans << endl;

	return 0;
}

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

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

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

	ll n; cin >> n;
	ll a[200005];
	map<ll,ll> cnt;

	for (int i = 0;i < n;i++){
		cin >> a[i];
		cnt[a[i]]++;
	}

	sort(a,a+n);
	reverse(a,a+n);

	ll ans = 0;

	for (int i = 0;i < n;i++){
		if(cnt[a[i]] != 0){
			ll t = 1;
			for (int j = 0;j < 40;j++){
				if(a[i] < t){
					ll nex = t-a[i];
					if(cnt[nex] != 0){
						if(nex == a[i]){
							if(cnt[nex] >= 2){
								cnt[a[i]] -= 2;
								ans++;
							}else{
								break;
							}
						}else{
							cnt[nex]--; cnt[a[i]]--;
							ans++;
						}
					}
					break;
				}
				t *= 2;
			}
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
#define mp make_pair
#define fs first
#define sc second
#define pb push_back
#define mod 998244353
using namespace std;

int arr[100005];

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

	int nyak = 0;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
		if(i == 1 || arr[i] == arr[i - 1]){
			nyak++;
		}else{
			ans = ans + nyak / 2;
			nyak = 1;
		}
	}
	ans = ans + nyak / 2;
	cout << ans << "\n";
}

Measured memory_bytes: 256
N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for i in range(N)]

if M == 0:
    print(0)
    quit()
else:
    s1 = sorted(map(lambda c: c[0] + c[1] + c[2], XYZ))
    s1max1 = sum(s1[-M:])
    s1max2 = -sum(s1[:M])
    s2 = sorted(map(lambda c: c[0] + c[1] - c[2], XYZ))
    s2max1 = sum(s2[-M:])
    s2max2 = -sum(s2[:M])
    s3 = sorted(map(lambda c: c[0] - c[1] + c[2], XYZ))
    s3max1 = sum(s3[-M:])
    s3max2 = -sum(s3[:M])
    s4 = sorted(map(lambda c: c[0] - c[1] - c[2], XYZ))
    s4max1 = sum(s4[-M:])
    s4max2 = -sum(s4[:M])
    print(max(s1max1, s1max2, s2max1, s2max2, s3max1, s3max2, s4max1, s4max2))

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

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    int findRoot(int x) {
        return data[x] < 0 ? x : data[x] = findRoot(data[x]);
    }
    void uniteSet(int x, int y) {
        x = findRoot(x), y = findRoot(y);
        if (x != y) {
            if (data[x] < data[y]) swap(x,y);
            data[x] += data[y];
            data[y] = x;
        }
    }
    int size(int x) {
        return -data[findRoot(x)];
    }
    bool same(int x, int y) {
        return findRoot(x) == findRoot(y);
    }
};

// 頂点u, vを繋ぐ重みweightの無向辺
struct Edge {
    int u;
    int v;
    int weight;
    bool operator< (const Edge& a) const {
        return weight != a.weight ? weight < a.weight :
            u != a.u ? u < a.u : v < a.v;
    }
};

int kruskal(int n, vector<Edge>& edges) {
    UnionFind uf(n);
    sort(edges.begin(), edges.end());

    int min_cost = 0;
    for (auto e: edges) {
        if (!uf.same(e.u, e.v)) {
            min_cost += e.weight;
            uf.uniteSet(e.u, e.v);
        }
    }
    return min_cost;
}

struct point {
    int x;
    int y;
    int id;
};

bool cmpx(const point& l, const point& r) {
    return l.x < r.x;
}
bool cmpy(const point& l, const point& r) {
    return l.y < r.y;
}

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

    vector<point> v;
    for (int i=0; i<N; i++) {
        int x,y;
        cin >> x >> y;
        v.push_back( point{x,y,i} );
    }

    vector<Edge> edges;

    // x軸で移動するとき
    sort(v.begin(), v.end(), cmpx);
    for (int i=1; i<v.size(); i++) {
        int c = abs(v[i].x - v[i-1].x);
        edges.push_back( Edge{v[i-1].id, v[i].id, c} );
    }

    // y軸で移動するとき
    sort(v.begin(), v.end(), cmpy);
    for (int i=1; i<v.size(); i++) {
        int c = abs(v[i].y - v[i-1].y);
        edges.push_back( Edge{v[i-1].id, v[i].id, c} );
    }

    cout << kruskal(N+1, edges) << endl;

    return 0;
}


Measured memory_bytes: 6132
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    string a,b;
    cin>>a>>b;
    for(int i=0;i<b.size();i++){
        cout<<a[i]<<b[i];
    }
    if(a.size()>b.size()){
        cout<<a[a.size()-1]<<endl;
    }else{
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import itertools
N, M, X = map(int, input().split())
C = []
A = dict()
for i in range(N):
    CA = list(map(int, input().split()))
    C.append(CA[0])
    for j in range(1, M+1):
        if j in A:
            A[j].append(CA[j])
        else:
            A[j] = [CA[j]]

cost = float("inf")

for i in range(1, N+1):
    for pm in itertools.combinations(list(range(1, N+1)), r=i):
        c = 0
        k = dict()
        for p in pm:
            c += C[p-1]

            for m in range(1, M+1):
                if m in k:
                    k[m] += A[m][p - 1]
                else:
                    k[m] = A[m][p - 1]

        if min(k.values()) >= X:
            cost = min(cost, c)


if cost == float("inf"):
    print(-1)
else:
    print(cost)

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

public class Main {
    public static void main(String[] args) throws IOException {
        final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String s = br.readLine();
        bw.write(s);
        if (s.charAt(s.length() - 1) == 's') {
            bw.write('e');
        }
        bw.write('s');
        bw.newLine();

        bw.close();
        br.close();
    }
}


Measured memory_bytes: 32620