akhauriyash/Code-Regression huggingface dataset:
/*
 * atcoder/abc113/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template <class T>
int numDigits(T number)
{
    int digits = 0;
    if (number < 0) digits = 1;
    while (number) {
        number /= 10;
        digits++;
    }
    return digits;
}

struct City {
  ll n, p, y;
  string id = "";
  void setid(ll m) {
    ll numP = numDigits<ll>(p);
    ll numM = numDigits<ll>(m);
    id += string(6-numP, '0').append(to_string(p));
    id += string(6-numM, '0').append(to_string(m));
  }
  bool operator<(const City& o)const{
    return p == o.p ? y < o.y : p < o.p;
  }
};

bool n_asc(const City& lh, const City& rh) {
    return lh.n < rh.n;
}

int N, M;
vector<City> C;

void solve() {
  cin >> N >> M;
  ll p, y;
  loop(n,0,M) {
    cin >> p >> y;
    C.push_back((City){ n, p, y, "" });
  }
  sort(C.begin(), C.end());
  ll ord = 1;
  loop(m,0,M) {
    if (m == 0 or C[m].p != C[m-1].p)  ord = 1;
    else ord++;
    C[m].setid(ord);
  }

  sort(C.begin(), C.end(), n_asc);
  for (auto &&c: C) {
    cout << c.id << endl;
  }
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 10092
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

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

bool check(vector<int>& H, int idx)
{
  REP(i, idx) {
    if (H[i] > H[idx]) return false;
  }
  return true;
}

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  int ans = 0;
  REP(i, N) cin >> H[i];
  REP(i, N) {
    if (check(H, i)) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////	
	string s;
	cin >> s;
	int e=2;
	int ans=s.size();
	if(s.size()%2==1) e=1;
	bool bb=1;
	while(1){
		//cout << ans << endl;
		bb=1;
		ans-=e;
		REP(i,ans/2){
			if(s[i]!=s[(ans/2)+i]) bb=0;
		}
		if(e==1) e=2;
		if(bb) break;
	}
	cout << ans << endl;
//////////////////////////////////////////////
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<string> a;
  vector<vector<int>> cnt;
  map<string, vector<int>> memo;
  Solver(LL n) : n(n), a(n), cnt(n, vector<int>(26)){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      reverse(a[i].begin(), a[i].end());
    }
    sort(a.begin(), a.end(), [&](string x, string y) -> bool {
      return x.length() < y.length() || (x.length() == y.length() && x < y);
    });
    DBG(a)

    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < a[i].length(); ++j) {
        cnt[i][a[i][j] - 'a']++;
      }
    }
    LL ans = 0;
    for (int i = 0; i < a.size(); ++i) {
      string tmp = "";
      for (int j = 0; j < (int)a[i].length() - 1; ++j) {
        DBG(tmp,memo.count(tmp))
        if (memo.count(tmp) == 0) {
          tmp += a[i][j];
          cnt[i][a[i][j] - 'a']--;
          continue;
        }
        auto M = memo[tmp];
        DBG(tmp, M)
        for (int k = 0; k < 26; ++k) {
          if (cnt[i][k] > 0) {
            ans += M[k];
          }
        }
        tmp += a[i][j];
        cnt[i][a[i][j] - 'a']--;
      }
      string b = a[i];
      b.pop_back();
      if (memo.count(b) == 0) {
        memo[b] = vector<int>(26);
      }
      memo[b][a[i].back() - 'a']++;
      DBG(ans)
      DBG(memo)
    }
    cout << ans << endl;
  }
};  // namespace Problem

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


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

int main(){
  int n, count=0;
  vector<int> vc;
  cin >> n;
  while(n--){
    int a;
    cin >> a;
    if (a % 2 == 0){
      count ++;
      if (a % 3 == 0 || a % 5 == 0){
        vc.push_back(a);
      }
    }
  }

  n = vc.size();
  if (n == count){
    cout << "APPROVED" << endl;
  }else {
    cout << "DENIED" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


//nCr,nPr,modの逆元
class Combination {
public:
	Array fact;//n！
	Array inv;//n!の逆元
	ll mod;
	Combination(ll n, ll _mod) {
		mod = _mod;
		fact.resize(n + 1);
		fact[0] = 1;
		REP(i, n) {
			fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
		}
		inv.resize(n + 1);
		inv[n] = mod_inv(fact[n]);
		for (int i = n; i > 0; i--) {
			inv[i - 1] = inv[i] * i % mod;
		}
	}
	//modの逆元
	ll mod_inv(ll x) {
		ll n = mod - 2;
		ll res = 1LL;
		while (n > 0) {
			if (n & 1) res = res * x % mod;
			x = x * x % mod;
			n >>= 1;
		}
		return res;
	}
	ll nCr(ll n, ll r) {
		return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
	}
	ll nPr(ll n, ll r) {
		return (fact[n] * inv[n - r]) % mod;
	}
	ll nHr(ll n, ll r) {
		//重複組み合わせ：n種類のものからr個取り出す組み合わせ
		return nCr(r + n - 1, r);
	}
};

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

	ll n;
	cin >> n;
	Array a(n+1, 0);
	Array b(n, -1);
	ll l, r;
	REP(i, n+1) {
		cin >> a[i];
		if (b[a[i]-1] != -1) {
			l = b[a[i] - 1];
			r = i;
		}
		else {
			b[a[i] - 1] = i;
		}
	}
	Combination com(n+1, MOD);
	//cout << l << " " << r << endl;

	for (int k = 1; k <= n + 1;k++) {
		ll ans = com.nCr(n+1, k);
		if (l + n - r >= k - 1) {
			ans -= com.nCr(l + n - r, k - 1);
			ans += MOD;
			ans %= MOD;
		}
		cout << ans<< endl;
	}



	return 0;
}

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

int main()
{
    int n=0;
    cin>>n;
    vector<double> v(n+1);
    for(int i=1;i<=n;i++) cin>>v[i];
    
    vector<vector<double>> dp(n+1,vector<double>(n+1,0));
    
    dp[1][0]=1.00-v[1];
    dp[1][1]=v[1];
    for(int i=2;i<=n;i++) dp[1][i]=0;
    
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(j==0) dp[i][0]=dp[i-1][0]*(1.00-v[i]);
            else
            {
                dp[i][j]+=dp[i-1][j]*(1.00-v[i]);
                dp[i][j]+=dp[i-1][j-1]*v[i];
            }
        }
    }
    
    
    double res=0.00;
    for(int i=(n/2)+1;i<=n;i++) res+=dp[n][i];
    cout<<fixed<<setprecision(10)<<res;
    return 0;
}

Measured memory_bytes: 70656
#include<stdio.h>
int main()
{
  int p,q,r,t1,t2,t3,min;
  scanf("%d%d%d", &p, &q, &r);
  t1 = p+q; min = t1;
  t2 = q+r; if (min>t2) min = t2;
  t3 = r+p; if (min>t3) min = t3;
  printf("%d", min);
  return 0;
}

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

int main()
{
	int Dice[6];
	int q;
	int up;
	int forward;
	int tmp;
	int i, j, k;
	
	for(i=0;i<6;i++){
		cin >> Dice[i];
	}
	cin >> q;
	
	for(i=0;i<q;i++){
		cin >> up >> forward;
		
		for(j=0;j<4;j++){
			tmp=Dice[0];
			Dice[0]=Dice[1];
			Dice[1]=Dice[5];
			Dice[5]=Dice[4];
			Dice[4]=tmp;
			if(Dice[1]==forward)
					break;

			else{
				for(k=0;k<4;k++){
					tmp=Dice[0];
					Dice[0]=Dice[3];
					Dice[3]=Dice[5];
					Dice[5]=Dice[2];
					Dice[2]=tmp;
					if(Dice[0]==forward){
						tmp=Dice[0];
						Dice[0]=Dice[4];
						Dice[4]=Dice[5];
						Dice[5]=Dice[1];
						Dice[1]=tmp;
						break;
					}
				}
			}
		}
		for(j=0;j<4;j++){
			tmp=Dice[0];
			Dice[0]=Dice[3];
			Dice[3]=Dice[5];
			Dice[5]=Dice[2];
			Dice[2]=tmp;
			if(Dice[0]==up)
				break;
		}
		
		cout << Dice[2] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

class Main{

	public static void main(String[] args){

		Scanner sc =new Scanner(System.in);

		int n=sc.nextInt();
		int a[];
		a=new int [n];

		for(int i=0;i<n;i++)
			a[i]=sc.nextInt();

		int count=bubbleSort(a,n);

		for(int i=0;i<n-1;i++)
			System.out.print(a[i]+" ");
		System.out.println(a[n-1]);
		System.out.println(count);


	}

	private static int  bubbleSort(int a[],int n) {
		int flag = 1;
		int  i = 0,temp=0,count=0;
		while (flag==1) {
			flag = 0;
			for (int j=n-1;i+1<=j;j--) {
				if (a[j] < a[j-1]) {
					temp=a[j];
					a[j]=a[j-1];
					a[j-1]=temp;
					count++;
				}
				flag=1;
			}
			i++;
		}

		return count;
	}
	
}


Measured memory_bytes: 26384
s = gets.chomp.gsub!("BC", "D")
if s.nil?
  puts 0
  exit
end
ans = 0
cntA = 0
s.chars do |c|
  if c == "A"
    cntA += 1
  elsif c == "D"
    ans += cntA
  else
    cntA = 0
  end
end
p ans

Measured memory_bytes: 2300
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr bool isPrime(const int &n) {
  if (n == 1) return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}

void solve() {
  int a, d, n;
  while (cin >> a >> d >> n, a && d && n) {
    int c = 0;
    a -= d;
    while (c < n) {
      a += d;
      if (isPrime(a)) c++;
    }
    cout << a << endl;
  }
}

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

const int maxn = 100010;
int n, m, fa[maxn], p[maxn];
vector<int> G[maxn];

int find(int x) {
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &p[i]), fa[i] = i;
    }
    for (int i = 1, x, y; i <= m; i++) {
        scanf("%d %d", &x, &y);
        fa[find(x)] = find(y);
    }
    for (int i = 1; i <= n; i++) {
        G[find(i)].push_back(i);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) if (G[i].size()) {
        vector<int> V;
        for (int j : G[i]) V.push_back(p[j]);
        sort(V.begin(), V.end());
        for (int j : G[i]) if (binary_search(V.begin(), V.end(), j)) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 6528
def resolve():
    N = int(input())
    a_list = list(map(int, input().split()))
    if len(set(a_list)) == 1:
        print(0)
    else:
        # コストは最大でも10**6
        min_cost = 10 ** 6 + 1
        for x in range(-100, 101):
            cost = sum([(a -x)**2 for a in a_list])
            if cost < min_cost:
                min_cost = cost
        print(min_cost)

resolve()

Measured memory_bytes: 9124
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	k, q    int
	d, md   [5000]int
	n, x, m int
)

func readVariables() {
	k, q = nextInt(), nextInt()
	for i := 0; i < k; i++ {
		d[i] = nextInt()
	}
}

func readQParam() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func query(n, x, m int) int {
	// fmt.Println(n, x, m)
	x %= m
	calcMod(m)
	sum := calcPeriodSum(k)
	q := (n - 1) / k
	r := (n - 1) % k
	last := x + q*sum
	for i := 0; i < r; i++ {
		last += md[i]
	}
	// fmt.Println(sum)
	// fmt.Println(md[0:k])
	return n - 1 - last/m
}

func calcMod(m int) {
	for i := 0; i < k; i++ {
		md[i] = d[i] % m
		if md[i] == 0 {
			md[i] = m
		}
	}
}

func calcPeriodSum(k int) int {
	result := 0
	for i := 0; i < k; i++ {
		result += md[i]
	}
	return result
}

func main() {
	readVariables()
	for i := 0; i < q; i++ {
		n, x, m = readQParam()
		fmt.Println(query(n, x, m))
	}
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt は、2つの整数を受け取り、最小値を返します。
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 1280
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let s = util::chars();
    if s.windows(2).any(|w| w[0] == w[1]) {
        println!("Bad");
    } else {
        println!("Good");
    }
}


Measured memory_bytes: 8572
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
int a[maxn],n,k,b[maxn];
bool check(int x){
	for(int i=0;i<n;i++) b[i]=a[i]%x;
	sort(b,b+n);
	int w=0,i;
	for(i=0;i<n;i++){
		w+=b[i];
		if(w>k) break;
	}
	for(w=0;i<n;i++){
		w+=x-b[i];
		if(w>k) return 0;
	}
	return 1;
}
int main(){
	ios_base::sync_with_stdio(false);
	int sum=0,x;cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i],sum+=a[i];x=sqrt(sum);//求和，+1-1和不变 
	for(int i=1;i<=x;i++)
		if(sum%i==0)
			if(check(sum/i)){
				cout<<sum/i;
				return 0;
			}
	for(int i=sqrt(sum);i>=1;i--)
		if(sum%i==0)
			if(check(i)){
				cout<<i;
				return 0;
			}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  string str;
  str="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  for(int i=0;i<S.size();++i){
  int count=0;  
  while(str.at(count)!=S.at(i)){
  ++count;
  }
  S.at(i)=str.at((count+N)%26);
  }
  
  cout<<S<<endl;
}

Measured memory_bytes: 256
_ = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(_[K-1])

Measured memory_bytes: 3060
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static int[] ans;
//	 static int mod = 998244353;
   public static void main(String[] args) {
	   

	   Scanner sc = new Scanner(System.in);
       int  N = sc.nextInt();
       String S = sc.next();
       char[] c = S.toCharArray();       
       BIT[] M = new BIT[27];
       for(int i=0;i<27;i++) {
    	   M[i]=new BIT(N+1);
       }
       for(int i=0;i<N;i++) {
    	   M[(int)c[i]-'a'].add(i, 1);
       }
       
       int  Q = sc.nextInt();
       long[][] a = new long[Q][3];
       char[] s = new char[Q];
       for (int i=0 ; i<Q; i++) {
           a[i][0] = Long.parseLong(sc.next());
           a[i][1] = Long.parseLong(sc.next());
           if(a[i][0]==2)a[i][2] = Long.parseLong(sc.next());
           else s[i]= sc.next().charAt(0);
           
       }
       
       for(int i=0;i<Q;i++) {
    	   if(a[i][0]==1) {
    		   int tmp=(int)c[(int)a[i][1]-1]-'a';
        	   M[(int)c[(int)a[i][1]-1]-'a'].add((int)a[i][1]-1, -1);
        	   c[(int) a[i][1]-1]=s[i];
        	   M[(int)s[i]-'a'].add((int)a[i][1]-1, 1); 		   
    	   } else {
    		   int cnt=0;
    		   int tmp=0;
    		   for(int j=0;j<26;j++) {
    			   tmp=M[j].sum2((int)a[i][1]-2, (int)a[i][2]-1);
    			   if(tmp>0)cnt++;
    		   }
    		   System.out.println(cnt);
    	   }
       }

   }
   
}


class BIT{
	int[] m;
	int N;
	public BIT(int n) {
		m=new int[n+1];
		N=n;
	}
	
	public void add(int idx, int value) {
		for(int i=idx+1;i<N;i+=(i&-i)) {
			m[i]=m[i]+value;
		}
	}
	public int sum(int idx) {
		int x=0;
		for(int i=idx+1;i>0;i=i-(i&-i)) {
			x=x+m[i];
		}
		return x;
	}
	public int sum2(int a,int b) {
		int tmp=sum(a);
		int tmp2=sum(b);
		return sum(b)-sum(a);
	}
	
	
}

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

#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)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

ll dp[101][1000010];

int main() {
    ll N, W;
    cin >> N >> W;
    ll MAX_V = N * 1001;

    rep(i, 101) rep(j, MAX_V) dp[i][j] = W + 1;
    dp[0][0] = 0;

    ll w, v;
    for (int i = 1; i <= N; i++) {
        cin >> w >> v;

        rep(j, MAX_V) {
            chmin(dp[i][j], dp[i - 1][j]);
            if (j - v >= 0) chmin(dp[i][j], dp[i - 1][j - v] + w);
        }
    }

    for (ll v = N * 1000; v >= 0; v--) {
        if (dp[N][v] <= W) {
            cout << v << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 287744
#include<iostream>
using namespace std; 
long long N;
    long long f2;    
    long long f0,f1;
int main()
{
   
    cin>>N;

    f0=2;f1=1;
    for(int i=2;i<=N;i++)
    {f2=f0+f1;
    f0=f1;
    f1=f2;
	}
	 
	cout<<f1;
}

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

int main() {
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  
  vector<long long> p(a);
  vector<long long> q(b);
  vector<long long> r(c);
  for(int i=0; i<a; i++) cin >> p[i];
  for(int i=0; i<b; i++) cin >> q[i];
  for(int i=0; i<c; i++) cin >> r[i];
  
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  sort(r.begin(),r.end());
  reverse(p.begin(),p.end());
  reverse(q.begin(),q.end());
  reverse(r.begin(),r.end());
  
  int countx=0;
  int county=0;
  
  long long ans=0;
  
  for(int i=0; i<x; i++) ans += p[i];
  for(int i=0; i<y; i++) ans += q[i];
  
  for(int i=0; i<max(a+b,c); i++){
    long long M=0;
    int flag_x=0;
    int flag_y=0;
    
    if(countx < x && county < y){
      M = max(r[i]-p[x-1-countx],r[i]-q[y-1-county]);
      if(M<=0) break;
      if(r[i]-p[x-1-countx]>=r[i]-q[y-1-county]) flag_x++;
      else flag_y++;
    }
    else if(countx >= x && county < y){
      M = max(0LL,r[i]-q[y-1-county]);
      if(M>=1) flag_y++;
    }
    else{
      M = max(r[i]-p[x-1-countx],0LL);
      if(M>=1) flag_x++;
    }
    
    if(flag_x == 1){
      ans += r[i]-p[x-1-countx];
      countx++;
    }
    else if(flag_y == 1){
      ans += r[i]-q[y-1-county];
      county++;
    }
    else break;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n;
    long long sum = 0;
    cin >> n;
    vector<long long> a(n), b(n+1, 0);
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        b[a[i]]++;
    }
    for(int i = 0; i <= n; i++){
        sum += b[i]*(b[i]-1)/2;
    }
    for(int i = 0; i < n; i++) {
        printf("%lld\n", sum - (b[a[i]] - (b[a[i]] - 2))*(b[a[i]] - 1)/2);
    }
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int N,X;
	cin>>N>>X;
	
	vector<int> m(N);
	int s = 0;
	
	for(int i=0;i<N;i++){
		cin>>m[i];
		s+=m[i];
	}
	
	sort(m.begin(),m.end());
	
	X -= s;
	
	int ans = N + X/m.front();
	
	cout<<ans<<endl;
		
    return 0;
}


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

void solve(std::string S, std::string T) {
    ll ans = 0;
    rep(i, S.length()) {
        if (S[i] != T[i]) ans++;
    }
    cout << ans << endl;
}

int main() {
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


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

using namespace std;

#define pb push_back
#define ull unsigned long long
#define ll long long

// LETS KEEP IT SIMPLE AND ROBUST

int solve() {

	return 0;
}


int main() {
	set<string> s;
	int n;
	cin>>n;
	while (n--) {
		string k;
		cin>>k;
		s.insert(k);
	}

	cout<<s.size()<<endl;
}









Measured memory_bytes: 19256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e5+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

int dx[4]={-1,0,0,1}, dy[4]={0,1,-1,0};

// ---- コーディングはここから！ ('-')7

void solve(){
	int n; lli t; cin>>n>>t;
	vl w(n),v(n); fore(i,0,n)cin>>w[i]>>v[i];
	vl dp(N+1,INF);
	dp[0]=0;
	fore(i,0,n)for(int j=N;j>=v[i];j--)if((dp[j-v[i]]!=INF and dp[j-v[i]]+w[i]<=t)  or j==v[i])dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
	for(int j=N;j>=0;j--)if(dp[j]!=INF){
		cout<<j<<ENDL; return;
	}

}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 3948
import sys
sys.setrecursionlimit(10000000)
import math
import bisect
from collections import deque
def input():
    return sys.stdin.readline()[:-1]

n,m = map(int,input().split())
mod = 10**9+7
ans =0
mpk = [0 for i in range(n+1)]
mpk[0] = 1
for i in range(1,n+1):
    mpk[i] = mpk[i-1]*(m+1-i)
    mpk[i] %= mod

mkpnk = [0 for i in range(n+1)]
mkpnk[0] = 1
for i in range(1,n+1):
    mkpnk[i] = mkpnk[i-1]*(m-n+i)
    mkpnk[i] %= mod

lis = [1 for i in range(n+1)]
lis_r = [1 for i in range(n+1)]
for i in range(1,n+1):
    lis[i] = lis[i-1]*i
    lis[i] %= mod
    lis_r[i] = lis_r[i-1]*pow(i,mod-2,mod)
    lis_r[i] %= mod

for k in range(n+1):
    ans += (-1)**k*lis[n]*lis_r[n-k]*lis_r[k]*mpk[k]*(mkpnk[n-k])**2
    ans %= mod
print(ans)


Measured memory_bytes: 166304
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
    This Question is Similoar to Philosophers stone in SPOJ
    1)Testcase to prove why Greedy fails
      A)3
        7  5  5
        100  1  1
        1  1   1
        
        as per greedy answer 7+1+1,but actually 5+100+1
      Greedy approach of choosing at each step(locally) the maximum one fails
     
    
     If you try out different paths under given conditions you can observe,
     Overlapping Subproblems as well as Optimal substructure so Definitely Dynamic Programming
    
    State consist of   position as well which one you consider to start of a or b or c
    position indicates if I start from this position what is the optimal Answer
*/

/*
 *   ITERATIVE SOLUTION
 */
//
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
int N,i,j;
ll dp[100005][3];//long long since sum can surpass limits of int
ll vacation[100005][3];
void solve()//Bottom - Top Approach
{
    cin>>N;
    fo(i,0,N)
    fo(j,0,3)
    cin>>vacation[i][j];
    
    for(i=N-1;i>=0;i--)
    for(j=0;j<3;j++)
    dp[i][j]=vacation[i][j]+max(dp[i+1][(j+1)%3],dp[i+1][(j+2)%3]);

    cout<<max(dp[0][0],max(dp[0][1],dp[0][2]))<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
	int N,C,K; cin >> N >> C >> K;
	vector<int> T(N);
	rep(i,N) cin >> T[i];
	sort(T.begin(),T.end());
	int ans = 0;
	int firsttime = 0;
	int now = 0;
	int cnt = 0;
	if(C == 1){
		cout << N << endl;
		return 0;
	}
	rep(i,N){
		if(now == 0){
			firsttime = T[i];
			now = 1;
			cnt++;
		}
		else{
			cnt++;
			if(T[i] > firsttime+K){
				ans++;
				firsttime = T[i];
				cnt = 1;
			}
			else{
				if(cnt == C){
					ans++;
					now = 0;
					cnt = 0;
				}
			}
		}
	}
	if(cnt > 0) ans++;
	cout << ans << endl;
}



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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  string ans = "Yes";
  for (int i=0; i<N; i++) {
    if (S.at(i) != S.at(N-1-i)) {
      ans = "No";
      break;
    }
  }
  
  for (int i=0; i<(N-1)/2; i++) {
    if (S.at(i) != S.at((N-1)/2-1-i)) {
      ans = "No";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3568
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

int N;
ll A[200000];
int r=0;
ll val=0;
ll ans=0;
int main()
{
  cin>>N;
  rep(i,N){
    cin>>A[i];
  }
  val = A[0];
  for(int l=0;l<N;l++){
    while(r < N-1 && (val+A[r+1] == (val ^ A[r+1]) ) ){
        r++;
        val+=A[r];
    }
    ans+= r-l+1;
    val-=A[l];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<=b){
		c=b-a;
		printf("%d\n",c);
	}
	else if(a>b){
		c=a-b;
		printf("%d\n",c);
	}
	return 0;
}


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A==B && B!=C){
    cout << "Yes" << endl;
  }
  else if(B==C && C!=A){
    cout << "Yes" << endl;
  }
  else if(C==A && A!=B){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << 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 <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int func(int N)
{
        if (N < 10)
                return N;
        return func(N / 10) + N % 10;
}

int main()
{
        int N, K;
        cin >> N>>K;
        vector<int> l(N);
        rep(i, N) cin >> l[i];
        int ans = 0;

        sort(l.begin(), l.end());
        reverse(all(l));
        rep(i, K) ans += l[i];

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int main(){
	int n,k;
	cin>>n>>k;
	long long ans=1;
	lp(i,n) ans*=k,ans%=(1000000007);
	cout<<ans<<endl;
	return 0;		
}


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

using namespace std;

int makecombi(int i, int n, vector<int> &s, vector<vector<int>> &ss, int &counter) {

	if (i == n) {
		for (int j = 0; j < n; j++) {
//			cout << s[j];
			ss[counter][j] = s[j];
		}
//		cout << endl;
		counter++;
		return 0;
	}

	makecombi(i + 1, n, s, ss, counter);
	s[i] = 1;
	makecombi(i + 1, n, s, ss, counter);
	s[i] = 0;
	return 0;
}

int main() {

	string st;
	cin >> st;

	//01の組み合わせを作る
	//n：桁数
	//s：組み合わせの各桁
	//ss:組み合わせ結果の配列
	//counter:配列格納のためのカウンタ

	int n;
//	cin >> n;
	n = st.size()-1;

	vector<int> s(n, 0);
	vector<vector<int>> ss(pow(2, n), vector<int>(n, 0)); //組み合わせは2^n個ある
	int counter = 0;;

	makecombi(0, n, s, ss, counter);

	//cout << endl << endl;
	//for (int i = 0; i < counter; i++) {
	//	for (int j = 0; j < n; j++) {
	//		cout << ss[i][j];
	//	}
	//	cout << endl;
	//}

	vector<string> numm(st.size());
	long long summ = 0;
	for (int i = 0; i < counter; i++) {
		int stcount = 0;
		for (int j = 0; j < numm.size(); j++) { numm[j] = ""; }

		for (int j = 0; j < st.size(); j++) {
			numm[stcount].push_back(st[j]);
			if (j != st.size() - 1) {
				if (ss[i][j] == 1) {
					stcount++;
				}
			}
		}

		for (int j = 0; j <= stcount; j++) {
			summ += stoll(numm[j]);
		}
	}
	cout << summ << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef unsigned long long ll;
const int N = 2e5+7,MOD = 998244353;
int n,m,k;
ll fact[N],infact[N];
ll qpow(ll a,ll b,int p)
{
    ll res = 1 % p;
    while(b)
    {
        if(b & 1)   res = (ll)res * a % p;
        a = (ll)a * a % p;
        b >>= 1;
    }
    return res;
}
void init()
{
    fact[0] = infact[0] = 1;
    for (int i = 1; i < N; i ++ )
    {
        fact[i] = ((ll)fact[i - 1] * i) % MOD;
        infact[i] = ((ll)infact[i - 1] * qpow(i, MOD - 2, MOD)) % MOD;
    }
}
ll C(ll a,ll b)
{
	return ((ll)fact[a]*infact[b]%MOD*infact[a-b]%MOD)% MOD;
}
int main()
{
 	init();
 	cin >> n >> m >> k;
 	ll res = 0;
 	for(int i = 0;i <= k;++i)
 	{
 		ll t = (m * qpow(m - 1,n - i - 1,MOD)) % MOD;
 		res += (t * C(n - 1,i)) % MOD;
 	}
    cout << res % MOD;
    return 0;
}


Measured memory_bytes: 6300
#include<stdio.h>
long long a[2]={5312,4710};
long long M[2]={1e9+7,1e9+9};
long long d[2][300010],k[2][300010];
int R=1,C=1,H[2000010],N[2000010],h[300010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]||N[H[a]]==N[H[b]]&&h[H[a]]<h[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
void init(char *s){//!
  int i,j;
  for(i=0;i<2;i++){
    k[i][0]=1;
    for(j=d[i][0]=0;s[j];j++){
      d[i][j+1]=(d[i][j]*a[i]+(s[j]-'a'+1))%M[i];
      k[i][j+1]=(k[i][j]*a[i])%M[i];
    }
  }
}
int getlr(int l,int r,int i){return (M[i]*M[i]+d[i][r]-d[i][l]*k[i][r-l])%M[i];}
void gets(char *s,int *h){
  int i,j;
  for(i=0;i<2;i++){
    for(j=h[i]=0;s[j];j++)h[i]+=k[i][j]*(s[j]-'0');
  }
}
int match(int l,int r,int *h){
  int i,j=1;
  for(i=0;i<2;i++)j*=getlr(l,r,i)-h[i]?1:0;
  return j;
}
int main(){
  int n=0,m,a,b,i,j,l=0,r=1;
  char s[300010],q[5];
  scanf("%*d %d %s",&m,s);
  init(s);//printf("%s\n",s);
  //for(i=0;s[i];i++)printf("%lld ",k[0][i+1]);printf("\n");
  //printf("%lld %lld %lld\n",d[0][3],d[0][4],k[0][2]);return 0;
  //printf("%lld %lld\n",getlr(0,2,0),getlr(2,4,0));return 0;
  for(i=0;i<m;i++){
    scanf("%s",q);
    if(q[0]=='L')l+=q[1]-'-'?1:-1;
    else         r+=q[1]-'-'?1:-1;//printf("%d %d!",l,r);
    h[R]=getlr(l,r,0);
    hin(getlr(l,r,1));//printf("%lld %lld\n",h[R-1],N[R-1]);
  }
  a=hout();
  for(i=1;i<m;i++){
    b=hout();//printf("%lld %lld %lld %lld\n",N[a],N[b],h[a],h[b]);
    if(N[b]==N[a]&&h[b]==h[a])n++;
    a=b;
  }
  printf("%d\n",m-n);
  return 0;
}


Measured memory_bytes: 15032
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define re(s) reverse(s.begin(),s.end())
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2)%mod)%mod;
}
int fun(int s,vector<int>&dp)
{
  if(s<0)return 0;
  if(dp[s]!=-1)return dp[s];
  if(s==0)return dp[s]=1;
  int pp=0;
  for(int i=3;i<=s;i++)
  {
      pp+= fun(s-i,dp);
      pp%=mod;
  }
  return dp[s]=pp;
}
int32_t main()
{
 io
 int n;
 cin>>n;vector<int>dp(n+1,-1);
 cout<<fun(n,dp);


}


Measured memory_bytes: 3620
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var input_array =input.trim().split("\n");
var numbers = input_array[1].split(' ').map((n) => Number(n));

var value;

for (var i = 0; i < numbers.length; i++) {
  value = numbers[i];
  j = i - 1;
  while (j >= 0 && numbers[j] > value) {
    numbers[j+1] = numbers[j];
    j--;
  }
  numbers[j+1] = value;
  console.log(numbers.join(' '));
}



Measured memory_bytes: 16536
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

ll INF = 1LL << 60;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);

	ll s = 0, ar = 0;
	rep(i, n) {
		if (i == 0) {
			cin >> a[i];
			s += a[i];
		}
		else {
			cin >> a[i];
			ar += a[i];
		}
	}
	ll ans = INF;
    ans=min(ans,abs(ar-s));
	rep(i, n - 2) {
		s += a[i + 1];
		ar -= a[i + 1];
		ans = min(ans, abs(ar - s));
	}
	cout << ans << endl;
}


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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define LL              long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

LL dp[101][100005];

int main()
{
    int n,w;
    cin >> n >> w;
    pii arr[n+1];
    FOR(i,1,n) cin >> arr[i].ff >> arr[i].ss;
    int sum=0;
    FOR(i,1,n) sum+=arr[i].ss;
    MEM(dp,0x3f3f3f3f3f3f);
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=sum;j++){
            if(j-arr[i].ss>=0) dp[i][j]=min(dp[i][j],dp[i-1][j-arr[i].ss]+arr[i].ff);
            dp[i][j]=min(dp[i-1][j],dp[i][j]);
        }
    }
    int ans=0;
    for(int i=0;i<=sum;i++) if(dp[n][i]<=w) ans=i;
    cout << ans;
}


Measured memory_bytes: 79104
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      long A = sc.nextLong();
      long B = sc.nextLong();
      long K = sc.nextLong();
      
      if(A+B<=K){
       System.out.println(0+" "+0);
      }
      else if(A<=K && A+B>=K){
       System.out.println(0+" "+((A+B)-K));
      }
      else if(A>K && A+B>=K){
       System.out.println((A-K)+" "+B);
      }
      else{
      System.out.println(A+" "+B);
      }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};




int main() {

  ll N;
  string S;
  cin>>S;
  ll ans=0;
  ll ren=0;
  FOR(i,0,S.size()-1){
  if(S[i]=='A'){
    ren++;
  }
  else if(S[i]=='T'){
    ren++;
  }
  else if(S[i]=='C'){
    ren++;
  }
  else if(S[i]=='G'){
    ren++;
  }else{
    ren=0;
  }
  ans= max(ans,ren);
  //co

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long ans = 0;
string s;
map<string, int> m;
int main() {
    cin >> n;
    while(n--) {
        cin >> s;
        int a[26]={0};
        string t = "";
        for(int i = 0; i < 10; i++) {
            a[s[i]-'a']++;
        }
        for(int i = 0; i < 26; i++) {
            t += to_string(a[i]) + "-";
        }
        ans += m[t]++;
    }
    cout << ans;
}

Measured memory_bytes: 17408