akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::collections::{HashSet,HashMap};
#[allow(unused_imports)]
use std::cmp::{min,max};

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin 
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input!(s:String);
    let s = s.chars().collect::<Vec<char>>();
    if s[0] == 'R' {
        println!("Sunny");
    }
    else if s[0] == 'S' {
        println!("Cloudy");
    }
    else {
        println!("Rainy");
    }
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  cin >> n;
  map<string,int> count;
  string s;
  for(int i=0;i<n;i++){
    cin >> s;
    count[s]++;
  }
  cout << "AC x " << count["AC"] << endl;
  cout << "WA x " << count["WA"] << endl;
  cout << "TLE x " << count["TLE"] << endl;
  cout << "RE x " << count["RE"] << endl;
  
  return 0;
}




Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	static class Reader {
		BufferedReader br;
		StringTokenizer st;
 
		public Reader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	
	// static int min = Integer.MAX_VALUE;
	static int[] dp, a;

	public static void main(String[] args) {
		Reader r = new Reader();
		
		int n = r.nextInt();
		a = new int[n];
		dp = new int[n];
		
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		for (int i = 0; i < n; i++) {
			a[i] = r.nextInt();
		}
		
		System.out.println(recur(n - 1));
	}
	
	static int recur(int i) {
		if (i == 0) {
			return 0;
		} else if (dp[i] != Integer.MAX_VALUE) {
			return dp[i];
		} else {
			int x = Integer.MAX_VALUE;
			int y = recur(i - 1) + Math.abs(a[i] - a[i - 1]);
			if (i - 2 > -1) {
				x = recur(i - 2) + Math.abs(a[i] - a[i - 2]);
			}
			
			dp[i] = Integer.min(x, y);
			
			return dp[i];
		}
	}

}


Measured memory_bytes: 46232
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            String n;

            n = Console.ReadLine();

            if (n[0] == '9' || n[1] == '9')
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

const int N = 2e5 + 7;

pair < int, int > v[N];

bool fc(pair < int, int > a, pair < int, int > b) {
    if (a.second == b.second)
        return a.first < b.first;
    return a.second < b.second;
}

int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    for (int i = 0; i < n; ++i)
        cin >> v[i].first >> v[i].second;
    v[n++] = {h + 1, 1};
    sort(v, v + n, fc);
    int x(1), ans(v[0].first), p(0);
    for (int i = 2; i <= w; ++i) {
        ++x;
        while (p < n && fc(v[p], {x, i}))
            ++p;
        if (p < n && v[p] == (pair < int, int >){x, i}) {
            while (p < n && v[p + 1].second == i && v[p + 1].first == v[p].first + 1)
                ++p;
            x = v[p++].first + 1;
        }
        if (x >= ans)
            return cout << ans - 1, 0;
        if (p < n && v[p].second == i)
            ans = min(ans, v[p].first);
    }
    cout << ans- 1;
    return 0;
}


Measured memory_bytes: 1792
N, M = map(int, input().split())
#SC = [list(map(int, input().split())) for i in range(M)]
define = [0] * N
ans = [0] * N
if M == 0:
  if N == 1:
    ans = 0
    print(ans)
    quit()
  else:
    ans[0] = 1
    for i in range(N):
      print(ans[i], end = "")
    quit()
  
if N == 1:
  ans = 0
  define = 0
  for i in range(M):
    s, c = map(int, input().split())
    if s == 1:
      if define == 1:
        if c != ans:
          print("-1")
          quit()
      else:
        ans = c
        define = 1
  print(ans)      
  quit()  
  
for i in range(M):
  s, c = map(int, input().split())
  if define[s - 1] == 1:
    #print("y")
    if c != ans[s - 1]:
      print("-1")
      quit()
  else:
    define[s - 1] = 1
    ans[s - 1] = c

if ans[0] == 0:
  if define[0] == 1:
    print("-1")
    quit()
  else:
    ans[0] = 1
  
for i in range(N):
  print(ans[i], end = "")

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

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

LL N, H;
V<PLL> v;

int main(){
    INIT;
    cin >> N; cin >> H;
    REP(i,N) {
        int a, b; cin >> a >> b;
        v.push_back(PII(b,a));
    }

    std::sort(ALL(v));

    LL max_ai = v[0].second;
    LL max_bi = v[0].first;
    LL ai_idx = 0;
    for(int i = 1; i < N; i++) {
        if(max_ai < v[i].second) {
            ai_idx = i; max_ai = v[i].second; max_bi = v[i].first;
        } else
        if(max_ai == v[i].second && max_bi < v[i].first) {
            ai_idx = i; max_ai = v[i].second; max_bi = v[i].first;
        }
    }

    LL cnt = 0;
    for(int i = N-1; i >= 0; i--) {
        if(H <= 0) break;
        if(max_ai < v[i].first) {
            H -= v[i].first;
            cnt++;
        }
    }

    if(0 < H) cnt += (H+max_ai-1)/max_ai;

    cout << cnt << "\n";
}

Measured memory_bytes: 2420
#include <iostream>
#include <map>
using namespace std;
void inclination(int sx,int sy,int& x, int& y){
  x -= sx;
  y -= sy;
  if(x ==0){
    x = 0;
    y = 1;
    return;
  }
  if(y == 0){
    x = 1;
    y = 0;
    return;
  }
  int maxt = y;
  int tx = x;
  int ty;
  while(tx%maxt !=0){
    ty = tx % maxt;
    
    tx = maxt;
    maxt = ty;
  }
  x /= maxt;
  y /= maxt;
  if(x < 0){
    x*=-1;
    y*=-1;
  }
}
int main(){
  int N,K;
  cin >> N >> K;
  if(K > N){
    cout << "0" << endl;
    return 0;
  }
  int nx[N];
  int ny[N];
  for(int i = 0; i < N; i++){
    cin >> nx[i] >> ny[i];
  }

  map<pair<int,int>,int>hmp;
  
  for(int i = 0;i < N; i++){
    hmp.clear();
    int sx = nx[i];
    int sy = ny[i];
    for(int j = i+1; j < N; j++){
      int x = nx[j];
      int y = ny[j];
      inclination(sx,sy,x,y);
      if(hmp.count(make_pair(x,y))){
	hmp[make_pair(x,y)] += 1;
      }else{
	hmp[make_pair(x,y)] = 2;
      }
      if(hmp[make_pair(x,y)] >= K){
	cout << "1" << endl;
	return 0;
      }
    }
  }
  cout << "0" << endl;
  return 0;        	  
}



Measured memory_bytes: 3308
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
 
int main() {
  int n,x;
  int a[100];
  cin>>n>>x;
  for(int i=0; i<n; i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int j=0;
  while(x>0 && j<n){
    x-=a[j];
    j++;
  }
  if(x!=0)j--;
  cout<<j<<endl;
}

Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/13
// Problem:Traveling Atcoder Problem d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;

static const int MOD = 1000000007;

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

  int N;
  cin >> N;
  vector< int > A(N);
  REP(i, N) {
    cin >> A[i];
  }

  sort(ALL(A));

  int ans = A[A.size() - 1] - A[0];
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
int n,m,i,j,k,count1=0,count2=0;
using namespace std;
void ABC120(void);
void ABC121(void);
void ABC122(void);
void ABC123(void);
void ABC124(void);
void ABC125(void);
void ABC126(void);
void ABC127(void);
void ABC128(void);
void ABC129(void);

int main(void){
    ABC120();
}

void ABC120(){
    int a,b;
    cin>>a>>b>>k;
    for(i=min(a,b);i>=0;i--){
        if(a%i==0&&b%i==0)count1++;
        if(count1==k)break;
    }
    cout<<i<<endl;
}

Measured memory_bytes: 256
n = int(input())
dict_str = {}

for count in range(n):
    txt = input()
    if(txt in dict_str):
        dict_str[txt] += 1
    else:
        dict_str[txt] = 1
# print(dict_str)

max = max(dict_str.values())

ans = []
ans = [k for k, v in dict_str.items() if v == max]

ans.sort()
for txt in ans:
    # print(end='---')
    print(txt)

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

using namespace std;

typedef int64_t i64;

int main() {
  i64 N, K;
  cin >> N >> K;
  vector<i64> R(N, 1);
  for (i64 i = 0; i < K; i++) {
    i64 d;
    cin >> d;
    for (i64 j = 0; j < d; j++) {
      i64 u;
      cin >> u;
      R[u - 1] = 0;
    }
  }
  i64 r = accumulate(R.begin(), R.end(), 0);
  cout << r << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ff first
#define ss second
#define int long long
#define all(x) (x).begin(), (x).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define eb emplace_back
#define inf INT64_MAX;
#define pii pair<int, int>

using namespace std;

const int mxn = 1e5 + 5;
int n;
vector<vector<int>> h(mxn, vector<int>(3));
int dp[mxn][3] = {};
int recurse(int idx, int last)
{
    if (idx == n)
        return 0;
    if (dp[idx][last])
        return dp[idx][last];
    int ans = -inf;
    if (last != 0)
        ans = max(ans, recurse(idx + 1, 0) + h[idx][0]);
    if (last != 1)
        ans = max(ans, recurse(idx + 1, 1) + h[idx][1]);
    if (last != 2)
        ans = max(ans, recurse(idx + 1, 2) + h[idx][2]);
    return dp[idx][last] = ans;
}

void solve()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> h[i][0] >> h[i][1] >> h[i][2];
    cout << recurse(0, -1);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // int t;
    // cin >> t;
    // while (t--)
    solve();
    return 0;
}

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

using namespace std;

int N;
long long arr[100005];
vector<pair<long long, long long>> ans;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N;
    long long mini = INT_MAX, maxi = INT_MIN, idxmini = 0, idxmaxi = 0;
    for(int i = 1; i<=N; i++){
        cin >> arr[i];
        if(arr[i] < mini){
            mini = arr[i];
            idxmini = i;
        }
        if(arr[i] >= maxi){
            maxi = arr[i];
            idxmaxi = i;
        }
    }
    if(maxi == 0 && mini == 0){
        for(int i = 1; i<N; i++){
            ans.push_back({0, 0});
        }
    }
    else if(maxi <= 0){
        for(int i = 1; i<=N; i++){
            if(i != idxmaxi){
                ans.push_back({maxi, arr[i]});
                maxi -= arr[i];
            }
        }
    }
    else if(mini >= 0){
        for(int i= 1; i<=N; i++){
            if(i != idxmini && i != idxmaxi){
                ans.push_back({mini, arr[i]});
                mini -= arr[i];
            }
        }
        ans.push_back({maxi, mini});
        maxi -= mini;
    }
    else{
        for(int i = 1; i<=N; i++){
            if(i != idxmaxi && arr[i] >= 0){
                ans.push_back({mini, arr[i]});
                mini -= arr[i];
            }
            if(i != idxmini && arr[i] < 0){
                ans.push_back({maxi, arr[i]});
                maxi -= arr[i];
            }
        }
        ans.push_back({maxi, mini});
        maxi -= mini;
    }
    cout << maxi << "\n";
    for(auto p : ans){
        cout << p.first << " " << p.second << "\n";
    }
}


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

const int MAXN = 80;
int X[MAXN][MAXN]; // Xij = Aij - Bij
int H, W;
int cache[MAXN][MAXN][2 * MAXN * MAXN];

int solve(int h, int w, int sub) {
    int &ret = cache[h][w][sub];
    if(ret != -1) return ret;
    ret = INT_MAX;
    if(h == H - 1 && w == W - 1) return ret = min(abs(sub - X[h][w]),abs(sub + X[h][w]));
    if(h < H - 1) ret = min(ret, min(solve(h + 1, w, abs(sub + X[h][w])), solve(h + 1, w, abs(sub - X[h][w]))));
    if(w < W - 1) ret = min(ret, min(solve(h, w + 1, abs(sub + X[h][w])), solve(h, w + 1, abs(sub - X[h][w]))));
    return ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> H >> W;
    rep(i, H) rep(j, W) {
        cin >> X[i][j];
    }
    rep(i, H) rep(j, W) {
        int x; cin >> x;
        X[i][j] -= x;
    }
    memset(cache, -1, sizeof(cache));
    cout << solve(0, 0, 0) << "\n";
}

Measured memory_bytes: 320384
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N;
  cin>>N;
  int M;
  cin>>M;
  vector<int> a(M);
  for(int i = 0;i<M;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  vector <int> b(M-1);
  for(int i = 0;i<M-1;i++){
    b[i] = a[i+1]-a[i];
  }
  sort(b.begin(),b.end());
  if(N>=M){
    cout << 0 << endl;
  }
  else{
    int ans = 0;
    for(int i = 0;i<(M-N);i++){
      ans += b[i];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  string s;
  cin >> s;

  if(s.size() <= N){
    cout << s << "\n";
  }else{
    cout << s.substr(0, N) << "..." << "\n";
}

  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

vector<int> RollingHash(string S){
    long long B[5]={114514,1919,810,893,364364};
    long long M[5]={1000000007,1000000009,999999937,998244353,2147483647};
    
    vector<int> R;
    for(int i=0;i<5;i++){
        int h=0;
        int b=1;
        for(int j=0;j<S.size();j++){
            h=(h+((int)S[j]*b)%MOD)%MOD;
            b=(b*B[i])%M[i];
        }
        R.push_back(h);
    }
    return R;
}

signed main(void){
    int N;
    string s;
    cin >> N;
    cin >> s;
    string S=s.substr(0,N);
    string T=s.substr(N,N);
    reverse(T.begin(),T.end());
    
    map<pair<vector<int>,vector<int>>,int> R; 
    for(int j=0;j<(1<<N);j++){
        string P,Q;
        REP(i,N){
            if((j>>i)%2==1){
                P.push_back(S[i]);
            }else{
                Q.push_back(S[i]);
            }
        }
        R[{RollingHash(P),RollingHash(Q)}]++;
    }
    int Ans=0;
    for(int j=0;j<(1<<N);j++){
        string P,Q;
        REP(i,N){
            if((j>>i)%2==1){
                P.push_back(T[i]);
            }else{
                Q.push_back(T[i]);
            }
        }
        Ans+=R[{RollingHash(P),RollingHash(Q)}];
    }

    cout << Ans << endl;
    
    return 0;
}



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

vector<int> tree[200005];
vector<int> ans;

void dfs(int p, int u=-1) {
    for (int t : tree[p]) {
        if (t == u) continue;
        ans[t] += ans[p];
        dfs(t, p);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    ans.resize(n);
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 23424
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(x,y) (x+y-1)/y

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

int main() {
	FAST;

	char c;
	int s=700;
	rep(i,3) {
		cin >> c;
		if (c=='o') s += 100;
	}

	cout << s << "\n";
	return 0;

}

Measured memory_bytes: 256
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

// バケット使った問題
const ll int MAX = 100010;

template<class T> T Sum(vector<T> t){
    T sum=0;
    ll int t_size = t.size();
    for(ll int i=0; i<t_size;i++){
        sum += i*t[i];
    }
    return sum;
}

// 0で初期化 バケット
vector<ll int> bucket(MAX,0);

int main (){
    ll int n; cin >> n;
    vector<ll int> a(n);
    ll int ans =0;
    for(ll int i=0; i<n; i++){
        cin >> a[i];
        bucket[a[i]]++;
        ans += a[i];
    }

    ll int q; cin >> q;
    vector<ll int> b(q);
    vector<ll int> c(q);
    for(ll int i=0; i<q; i++){
        cin >> b[i] >> c[i];
    }

    for(ll int i=0; i<q; i++){
        ans += bucket[b[i]]*(c[i]-b[i]);
        bucket[c[i]] += bucket[b[i]];
        bucket[b[i]] = 0;
        cout << ans << endl;
    }

}

    // for(int i=0; i<q; i++){
    //     // sort(a.begin(),a.end());
    //     // auto pos1 = lower_bound(a.begin(),a.end(),b[i]);
    //     // auto pos2 = upper_bound(a.begin(),a.end(),b[i]);
    //     // replace(pos1,pos2,b[i],c[i]);
    //     replace(a.begin(),b.end(),b[i],c[i]);
    //     cout << Sum<int>(a) << endl;
    // }

Measured memory_bytes: 6416
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	printf("%lld",n+m/2);
}

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

int main() {
  string a, b;
  cin >> a >> b;
  int ab = stoi(a + b);
  double rt = sqrt((double)ab);
  if (abs(rt - round(rt)) > 0) {
    cout << "No";
  } else {
    cout << "Yes";
  }
}


Measured memory_bytes: 3520
L = input()
modulo = 10**9+7

dp = [[0] * (len(L)+1) for i in range(2)]
dp[1][0] = 1
  
for i in range(len(L)):
  if L[i] == "1":
    dp[0][i+1] = dp[1][i] % modulo
    dp[1][i+1] = (dp[1][i] * 2) % modulo
  else:
    dp[1][i+1] = dp[1][i] % modulo

  dp[0][i+1] += (3 * dp[0][i]) % modulo

#1 -> 1
#10 -> 5
#11 -> 9
#print(dp)
print((dp[0][-1]+dp[1][-1]) % modulo)

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

int main() {
	unsigned long long a, b, x;
	cin >> a >> b >> x;
	if(a == 0) cout << b / x + 1 << endl;
	else cout << (b / x + 1) - ((a - 1) / x + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll q;
ll b;
priority_queue<ll> px;
priority_queue< ll ,vector<ll>,greater<ll>> pm;
int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>q;
	b = 0;
	ll mid = 0;
	ll sf=0;
	ll sb =0;
	rep(i,q){
		ll in;
		cin>>in;
		if(in==2){
			ll ans = b;
			princ(mid);
			ans += mid*px.size()-sf;
			ans += sb-mid*pm.size();
			print(ans);
		}else{
			ll ina,inb;
			cin>>ina>>inb;
			b += inb;
			if(px.empty()){
				px.push(ina);
				sf += ina;
			}else if(ina<px.top()){
				px.push(ina);
				sf += ina;
			}else{
				sb += ina;
				pm.push(ina);
			}
			if(pm.size()>px.size()+1){
				ll tp = pm.top();
				sb -= tp;
				sf += tp;
				pm.pop();
				px.push(tp);
			}else if(pm.size()+1<px.size()){
				ll tp = px.top();
				sb += tp;
				sf -= tp;
				px.pop();
				pm.push(tp);
			}
			if(pm.size()<px.size()){
				mid = px.top();
			}else if(pm.size()>px.size()){
				mid = pm.top();
			}else{
				mid = px.top();
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main(){
long long l=-1000000;
  long long u=1000000;
  int k,x;
  cin>>k>>x;
//long long s=m+x-1;
  long long s=x-k+1;
  long long e=x+k-1;
  if(s<l){
      s=l;
  }
  if(e>u){
  e=u;
  }
  
  while(s<=e){
  cout<<s<<" ";
    s++;
  }
  return 0;
  
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for (int i = n; i > 0; i--) {
    int temp = i;
    int sum = 0;
    while (temp != 0) {
      sum += temp % 10;
      temp /= 10;
    }
    if (a <= sum && sum <= b) {
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    
    int ans=10000;
    for(char c='a';c<='z';c++){
        int tmp=0;
        int cnt=0;
        rep(i,0,n){
            if(s.at(i)==c){
                tmp=max(tmp,cnt);
                cnt=0;
            }
            else cnt++;
        }
        tmp=max(tmp,cnt);
        ans=min(ans,tmp);
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

string caesar(string s, int n){
    string res = s;
    rep(i, 0, s.size()){
        if('a' <= s[i] && s[i] <= 'z'){
            if(s[i] - 'a' + n < 26){
                res[i] += n;
            }else{
                res[i] += n - 26;
            }
        }
    }
    return res;
}

bool find(string s, string t){
    return s.find(t) != string::npos;
}

signed main(){
    string s;
    string str[3] = {"the", "this", "that"};
    while(getline(cin, s)){
        string t;
        bool f = false;
        rep(i, 0, 26){
            t = caesar(s, i);
            // cout << t << endl;
            rep(j, 0, 3){
                if(find(t, str[j])){
                    f = true;
                    i = 26;
                    break;
                }
            }
        }
        cout << t << endl;
    }
}

Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,d;cin>>n>>d;print((n+2*d)/(2*d+1));
  return 0;
}

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

int main(){
  int a,b,d=0;
  cin>>a>>b;
  vector<int> c(a);
  for(int i=0;i<a;i++)
    cin>>c.at(i);
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  for(int i=0;i<b;i++)
    d+=c.at(i);
  cout<<d<<endl;
}

Measured memory_bytes: 256
# import numpy as np
# import scipy as sp
# import sys
# input = sys.stdin.readline
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=list(map(int, input().split()))  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# a=[int(input()) for _ in range (n)]  #リスト入力  改行でa1 ... anのとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#　

import itertools
import bisect
n, m = list(map(int, input().split()))
al = list(map(int, input().split()))
al.sort()
ub = al[-1]*3
lb = -1
while lb + 1 < ub:
    target = (ub+lb)//2
    tmp = 0
    for a in al:
        sa = target - a
        # リストAに値xを入れ、xが複数になるとき、一番左の値xのインデックスを返す
        i = bisect.bisect_left(al, sa)
        tmp += (n-i)
    if (tmp >= m):
        lb = target
    else:
        ub = target


rui_al = [0] + list(itertools.accumulate(al))
ans = 0
tmp = 0
target = lb
for a in al:
    sa = target - a
    # リストAに値xを入れ、xが複数になるとき、一番左の値xのインデックスを返す
    i = bisect.bisect_left(al, sa)
    tmp += (n-i)
    ans += (rui_al[-1] - rui_al[i])
    ans += a*(n-i)

if tmp > m:
    ans -= (tmp-m)*target
print(ans)


Measured memory_bytes: 63140
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		LinkedList<String> sList = new LinkedList<>();
		LinkedList<String> tList = new LinkedList<>();
		String s = "";
		String t = "";

		String input1 = scan.next();
		int len1 = input1.length();
		String input2 = scan.next();
		int len2 = input2.length();


		for(int i = 0; i < len1; i++){
			String temp = input1.substring(0, 1);
			sList.add(temp);
			if(i < len1 - 1) {
				input1 = input1.substring(1);
			}
		}
		for(int i = 0; i < len2; i++){
			String temp = input2.substring(0, 1);
			tList.add(temp);
			if(i < len2 - 1) {
				input2 = input2.substring(1);
			}
		}

		Collections.sort(sList);
		Collections.sort(tList, Comparator.reverseOrder());

		while(sList.size() > 0){
			s = s.concat(sList.poll());
		}
		while(tList.size() > 0){
			t = t.concat(tList.poll());
		}

		if(s.compareTo(t) < 0){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}





	}
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define sz(x) ((int)x.size())

struct segmentTree
{
    struct node
    {
        int val;
        void setLeaf(int idx) { val = 0; }
        friend node operator+(const node &lhs, const node &rhs)
        {
            node res;
            res.val = max(lhs.val, rhs.val);
            return res;
        }
        void applyUpdate(int upd) { val = upd; }
        int query() { return val; }
    };

    int N;
    vector<node> st;
    segmentTree(int n) : N(n), st(4*N+5) {}

    void buildHelper(int u, int l, int r)
    {
        if(l == r)
        {
            st[u].setLeaf(l);
            return;
        }
        int m = (l+r)/2;
        buildHelper(2*u, l, m);
        buildHelper(2*u+1, m+1, r);
        st[u] = st[2*u] + st[2*u+1];
    }
    void build() { buildHelper(1, 1, N); }

    node queryHelper(int u, int l, int r, int i, int j)
    {
        if(l >= i && r <= j)
            return st[u];
        int m = (l+r)/2;
        if(j <= m)
            return queryHelper(2*u, l, m, i, j);
        else if(i >= m+1)
            return queryHelper(2*u+1, m+1, r, i, j);
        else
            return queryHelper(2*u, l, m, i, j) + queryHelper(2*u+1, m+1, r, i, j);
    }
    int query(int i, int j) { return queryHelper(1, 1, N, i, j).query(); }

    void updateHelper(int u, int l, int r, int pos, int upd)
    {
        if(l == r)
        {
            st[u].applyUpdate(upd);
            return;
        }
        int m = (l+r)/2;
        if(pos <= m)
            updateHelper(2*u, l, m, pos, upd);
        else
            updateHelper(2*u+1, m+1, r, pos, upd);
        st[u] = st[2*u] + st[2*u+1];
    }
    void update(int pos, int upd) { updateHelper(1, 1, N, pos, upd); }
};

segmentTree st(200005);
int h[200005], a[200005];
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= n; i++)
    {
        int bmax = a[i];
        if(h[i] > 1)
            bmax += st.query(1, h[i]-1);
        st.update(h[i], bmax);
    }
    cout << st.query(1, n) << endl;
}

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

inline int read()
{
	int x=0; int 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;
}

const int MAXN = 115;
int mp[MAXN][MAXN],f[MAXN][MAXN];
int n,m;

int main(int argc, char const *argv[])
{
	n=read(),m=read();
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
			mp[i][j]=read();
	for(int i=0; i<=100; ++i)
		for(int j=0; j<=100; ++j)
			for(int p=1; p<=n; ++p)
				for(int q=1; q<=m; ++q)
					f[i][j]=max(f[i][j],mp[p][q]-i*p-j*q);
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
		{
			int mn=1e9;
			for(int p=0; p<=100; ++p)
				for(int q=0; q<=100; ++q)
					mn=min(mn,f[p][q]+p*i+q*j);
			if(mn!=mp[i][j])
			{puts("Impossible"); return 0;}
		}
	puts("Possible");
	puts("202 10401");
	for(int i=1; i<=100; ++i)
		printf("%d %d X\n",i,i + 1);
	for(int i=102; i < 202; ++i)
		printf("%d %d Y\n",i,i + 1);
	for(int i=0; i<=100; ++i)
		for(int j=0; j<=100; ++j)
			printf("%d %d %d\n",1+i,202-j,f[i][j]);
	puts("1 202");
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}


/*
メモ化再起が効く
今回はa,bに相当するが，
Nからfloor((N+-1)/2)に遷移するような状況を考える．
この時，取りうる値がfloor(N/2^k)+-1しかない．
N->N/2or(N-1)/2に遷移しうる状況を考える
この時，メモ化再起がバチバチに効く
110101
↓
11010
↓
1101,1100
↓
110，101
↓
11,10
...
このように1桁減らした先で2個(floor(N/2^k)or floor(N/2^k)-1)しか取りうる値がないことがちょっと考えるとわかる

この問題では
a<-a-y,b<-a+y
としてa^b=xとしたいんだけどまず1桁目がかなりどうしようもない
a=0 b=1 x=0とかならもう絶対無理．悲しいね
逆にa^b=xの1桁目があってるならa<-a-1，b<-b+1としたところで合うので，
その2つで再起．
終点はx=0．こうなったらaとbを等分するしかない．等分できないときは再起の2個目のifで死んでる

知見
遷移先が少ないおかげでメモ化再起がバチバチに効く時がある．
    f(n)->f(n/2),f((n+-1)/2)が今回

桁DPの有力な方針として，1位で場合分け->上位桁で同じ問題を解く再起．みたいなのがある．
*/


using tp=tuple<ll,ll,ll>;
map<tp,ll> memo;

ll f(ll a,ll b,ll x){
    if(memo.count(tp(a,b,x))){
        return memo[tp(a,b,x)];
    }
    // 不可能
    if(((a&1)^(b&1))!=(x&1)){
        return LINF;
    }
    if(x==0){
        if(a>=b) return (a-b)/2;
        else return LINF;
    }
    ll ret=2*f(a/2,b/2,x/2);
    chmin(ret,2*f((a-1)/2,(b+1)/2,x/2)+1);
    return memo[tp(a,b,x)]=ret;
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    ll a,b,x=0;
    cin>>a>>b;
    rep(i,n-2){
        ll t;cin>>t;
        x^=t;
    }
    ll res=f(a,b,x);
    if(res>=a) cout<<-1<<endl;
    else cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;

#define pi 3.141592653589


int main(){
	int n;
	int *a;

	cin >> n;
	a = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = n - 1; i >= 0; i--)
	{
		cout << a[i] ;
		if (i != 0) cout << " ";
	}
	cout << endl;
	return 0;
}

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

int main()
{
    vector<int> time1(5, -1);
    vector<int> time2(5, -1);
    int sum = 0;
    for(int i = 0; i < 5; i++){
        cin >> time1.at(i);
        if(time1.at(i) %10 ==0){
            sum+= time1.at(i);
        }
        else {
            time2.at(i) = time1.at(i) % 10;
        }
    }
    int k;
    int i;
    for(i = 0; i < 5; i++){
        int max = *max_element(time2.begin(), time2.end());
        if(max == -1)break;
        for(int j = 0; j < 5; j++){
            if(time2.at(j) == max){
                sum+= time1.at(j);
                sum += (10 - time2.at(j));
                k = time2.at(j);
                time2.at(j) = -1;
            }
        }
    }
    if(i == 0);
    else sum -= (10 - k);
    cout << sum;
    return 0;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     std::begin(_obj), std::end(_obj)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define ceilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define has(_obj, _val)               ((_obj).find(_val) != (_obj).end())
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
int arr[100000][3];
int dp[101005][3];

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    loop(n) {
        for (int j = 0; j < 3; ++j) {
            cin >> arr[i][j];
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (k == j) {
                    continue;
                }
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + arr[i - 1][j]);
            }
        }
    }
    cout << *max_element(dp[n], dp[n] + 3) << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


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

string s[2];

int main() {
	cin >> s[0] >> s[1];

	bool flag = true;
	for (int i = 0; i < 3; i++) {
		if (s[0][i] != s[1][2 - i]) {
			flag = false;
		}
	}

	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	long long h;
	cin >> n >> h;
	priority_queue<pair<long long, bool>> q;
	for (int i = 0; i < n; i++) {
		long long a, b;
		cin >> a >> b;
		q.push(make_pair(a, false));
		q.push(make_pair(b, true));
	}
	long long count = 0;
	while (h > 0) {
		auto t = q.top();
		if (t.second == true) {
			q.pop();
		}
		h -= t.first;
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 7404
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;


int main(){
    int N; cin >> N;
    vector<int> b(N);
    b.assign(N,0);
    rep(i,N){
        cin >> b[i];
        b[i]--;
    } 

    vector<int> a;

    rep(i,N){
        int index = -1;
        rrep(j,b.size()){
            if (b[j] == j){
                index = j;
                break;
            }
        }

        if (index == -1){
            cout << -1 << endl;
            return 0;
        }

        a.push_back(index+1);
        b.erase(b.begin() + index);
    }

    reverse(a.begin(), a.end());
    rep(i,a.size())
    {
        cout << a[i] << endl;
    }


}

    

Measured memory_bytes: 3596
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[]args){
	int ans=0;
        Scanner sc = new Scanner(System.in);
        String N=sc.next();
	int sum=0;
	for(int i=0; i<N.length(); i++){
	    sum+=Integer.parseInt(N.substring(i,i+1));
	}
	//N.charAt(i)
        if(sum%9==0){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}


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

using namespace std;


/*---------------------------------------------------*/
// 0 : pushBack
// 1 : randomAccess
// 2 : popBack
/*---------------------------------------------------*/
int main()
{
  int n;
  cin >> n;

  int query;
  int num;
  std::vector<int> A;

  for(int i=0; i<n; ++i){
    cin >> query;

    if(query == 0){
      cin >> num;
      A.push_back(num);        // 末尾にnumを追加
    }
    else if(query == 1){
      cin >> num;
      cout << A[num] << endl;  // num番目の要素を参照
    }
    else{
      A.pop_back();            // 末尾から要素を削除
    }
  }
  return 0;
}



Measured memory_bytes: 3932
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;


const int MAX = 20005;
const ll INF = 1000000000;
ll dp[MAX];
ll a[1005],b[1005];

// dp[i]:=ダメージがi以上になるときの消費MPの最小値

int main(){
  int h,n; cin >> h >> n;
  for(int i=0;i<n;i++) cin >> a[i] >> b[i];
  for(int i=0;i<MAX;i++) dp[i] = INF;
  dp[0] = 0;
  for(int i=0;i<MAX;i++){
    for(int j=0;j<n;j++){
      if(i < a[j]) dp[i] = min(dp[i],b[j]);
      else dp[i] = min(dp[i], dp[i-a[j]] + b[j]);
    }
  }
  cout << dp[h] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //__gnu_pbds::gp_hash_table<int, int> table;
//priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;  //min heap

typedef int OwO;
typedef double UwU;

#define int long long
#define double long double
#define INF 1000000000
#define PI 3.14159265358979323846
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vi vector<int>

using namespace std;

int GCD(int a, int b){
  if(!b)
    return a;
  return GCD(b, a%b);
}

OwO main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int a1;
  int a2;
  int tempA=A/C*C;
  a1 = B/C;
  if(A%C==0)
    a1 -= (A/C-1);
  else
    a1 -= A/C;

  a2 = B/D;
  if(A%D==0)
    a2 -= (A/D-1);
  else
    a2 -= A/D;

  int E = C*D/GCD(C,D);
  int a3 = B/E;
  if(A%E==0)
    a3 -= (A/E-1);
  else
    a3 -= A/E;

  cout << B-A+1+a3-a1-a2 << endl;

  return 0;
}

Measured memory_bytes: 256
a = gets.split(" ").map(&:to_s)
b = gets.split(" ").map(&:to_s)
if (a[0][0]==b[0][2])&&(a[0][1]==b[0][1])&&(a[0][2]==b[0][0])
  puts 'YES'
else
  puts 'NO'
end

Measured memory_bytes: 3836