akhauriyash/Code-Regression huggingface dataset:
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  int h, a;
  ci(h, a);
  h % a == 0 ? co(h / a) : co(h / a + 1);
}

Measured memory_bytes: 256
use proconio::*;

fn main() {
    input! {
        n: usize,
    };
    let mut ans = [0; 10001];

    for x in 1..100 {
        for y in 1..100 {
            for z in 1..100 {
                let t = x * x + y * y + z * z + x * y + y * z + x * z;
                if t <= n {
                    ans[t] += 1;
                }
            }
        }
    }

    for a in &ans[1..=n] {
        println!("{}", a);
    }
}


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

using namespace std;

int main(){
    int n,e;
    cin >> n;
    vector<int> a(n,0);
    for(auto &e:a) cin >>e;

    std::sort(a.begin(),a.end());

    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            cout << "NO"<<endl;
            return 0;
        }
    }
    cout << "YES" <<endl;

}

Measured memory_bytes: 1024
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            int[] D = Console.ReadLine().Split().Select(i => Convert.ToInt32(i)).ToArray();
            Array.Sort(D);
            int middle = (N - 1) / 2;
            int ans = D[middle + 1] - D[middle];
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 20192
(_,K),*T=[map(int,t.split())for t in open(0)]
A,B=map(sorted,T)
d=[0,2**40]
exec("i=sum(d)//2;d[-sum(min(0,i//b-a) for a,b in zip(A,B[::-1]))<=K]=i;"*41)
print(d[1])

Measured memory_bytes: 123168
#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5+5;
vector<int> adj[mxN];
vector<bool> vis(mxN, false);
void dfs(int i) {
	if(!vis[i]) {
		vis[i] = true;
		for(auto v : adj[i])
			dfs(v);
	}
}
int main() {
	int n, m; cin >> n >> m;
	for(int i = 0; i < m; ++i) {
		int x, y; cin >> x >> y, --x, --y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int ans(-1);
	for(int i = 0; i < n; ++i) {
		if(!vis[i]) {
			ans++;
			dfs(i);
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 9596
#include <iostream>

using namespace std;

int main(){
  int N, K, X, Y;
  int result = 0;
  cin >> N;
  cin >> K;
  cin >> X;
  cin >> Y;

  for(int i = 0; i < N; i++){
    if(i < K){
      result += X;
    }
    else{
      result += Y;
    }
  }

  cout << result << endl;
}


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

inline int max (int p, int q) {return p > q ? p : q;}

int a, b, c;

int main () {
	scanf ("%d %d %d", &a, &b, &c);
	printf ("%d\n", max (0, c - a + b));
	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main app = new Main();
		String string;
		
		int n, r, p, c;
		while(true){
			string = reader.readLine();
			n = Integer.valueOf(string.split(" ")[0]);
			r = Integer.valueOf(string.split(" ")[1]);
			if((n | r) == 0) break;
			
			int card[] = new int[n];
			for(int i = 0; i < n; i++) card[i] = n - i;
			
			for(int i = 0; i < r; i++){
				string = reader.readLine();
				p = Integer.valueOf(string.split(" ")[0]) - 1;
				c = Integer.valueOf(string.split(" ")[1]);
				
				card = app.shuffle(card, p, c);
			}
			System.out.println(card[0]);
		}
		reader.close();
	}
	
	public int[] shuffle(int card[], int p, int c){
		int n = card.length;
		int res[] = new int[n];
		
		for(int i = 0; i < c; i++){
			res[i] = card[p + i];
		}
		for(int i = 0; i < p; i++){
			res[c + i] = card[i];
		}
		for(int i = p + c; i < n; i++){
			res[i] = card[i];
		}
		
		return res;
	}
}

Measured memory_bytes: 29476
def main():
    """
    2 <= N <= 10^5
    1 <= M <= 10^5
    p: 順列

    1 <= xi, yi <= N
    xi != yj
    if i != j then {xi, yi} != {xj, yj}
    """
    N, M = map(int, input().split())
    *p, = map(int, input().split())
    xy = [
        list(map(int, input().split()))
        for _ in range(M)
    ]

    editorial(N, M, p, xy)


class UnionFind:
    def __init__(self, par):
        self.par = par

    def root(self, x):
        if self.par[x] == x:
            return x
        # 経路圧縮
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x != y:
            self.par[y] = x


def editorial(N, M, p, xy):
    par = list(range(N+1))
    uf = UnionFind(par)
    for x, y in xy:
        uf.unite(x, y)

    _p = [0] + p
    ans = 0
    for i in range(1, N+1):
        if uf.root(i) == uf.root(_p[i]):
            ans += 1

    print(ans)


def f(N, M, p, xy):
    """
    (1, 2): 1,2を入れ替える
    (2, 3): 2,3を入れ替える
        default: 123
            1,2: 213
            2,3: 231
        defaultからの移動: (1,3), (1,2)
        (1,2),(2,3) -> (1,3),(1,2)
        入れ替えると2番目xが1番目xになる？

    入力例1より、j=1,2,1の順で入れ替え
        j1=(1,2),j2=(2,3) => (1,3)
    """
    d_xy = {x: y for x, y in xy}
    d_yx = {y: x for x, y in xy}
    extra = []
    for x, y in xy:
        if y in d_xy:
            extra.append((x, d_xy[y]))

    print(xy)
    print("---")
    print(extra)


if __name__ == '__main__':
    main()


Measured memory_bytes: 36032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// const int d = 365;
int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }

  for (int i = 0; i < d; i++) {
    cout << i % 26 + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3680
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

func main() {
	a := readInt()
	b := readInt()

	ans := []int{a, b, a - 1, b - 1}
	sort.Ints(ans)

	fmt.Println(ans[3] + ans[2])
}


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

int main(){
  int cnt=0,a[3];
  for(int i=0;i<3;i++)
    cin >> a[i];
  sort(a,a+3);
  for(int i=0;i<3;i++){
    cnt += a[2]-a[i];
  }
  if(cnt%2==1)
    cnt += 3;
  cout << cnt /2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, n;
  cin >> n;
  pair< pair<string, ll>, ll> a[n];
  for(i = 0; i < n; ++i) 
    cin >> a[i].first.first >> a[i].first.second, a[i].first.second *= -1, a[i].second = i + 1;
  sort(a, a + n);
  for(i = 0; i < n; ++i) printf("%lld\n", a[i].second);
  return 0;
}

Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

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

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
int v[100001][3];
ll dp[100001][3];

void init()
{
}

void solve()
{
    REP(i, 3){
        dp[1][i] = v[1][i];
    }
    FOR(i, 2, N+1){
        REP(j, 3){
            dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + v[i][j];
        }
    }
    ll ans = 0;
    REP(i, 3) ans = max(ans, dp[N][i]);
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 1, N+1){
        cin >> v[i][0] >> v[i][1] >> v[i][2];
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, X;

void solve() {
	cin >> N >> X;
	for(int i = X - N + 1; i <= X + N - 1; i++) {
		cout << i << " ";
	}
	cout << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<VI> c(10, VI(10));
  REP(i, 0, 10) {
    REP(j, 0, 10) {
      cin >> c[i][j];
    }
  }
  REP(k, 0, 10) {
    REP(i, 0, 10) {
      REP(j, 0, 10) {
	c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
  int tot = 0;
  REP(i, 0, h) {
    REP(j, 0, w) {
      int a;
      cin >> a;
      if (a >= 0) {
	tot += c[a][1];
      }
    }
  }
  cout << tot << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	long long n, m; cin >> n >> m;
	if (n == 1 || m == 1) {
		printf("1\n");
		return 0;
	}
	cout << (n / 2) * m + (n & 1) * (m + 1 >> 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
  int x, y;
  cin >> x >> y;
  int count = 0;
  for (int i = x; i <= y; i *= 2) {
    count++;
  }
  cout << count << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

vector<pair<int, int >> factorize(int n) {
    vector<pair<int, int >> res;

    for (int i = 2; i * i <= n; i++) {
        if (n % i != 0) {
            continue;
        }
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }

    if (n != 1) res.emplace_back(n, 1);
    return res;

}

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

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

    map<int, int> count;

    for (int i = 2; i <= n; i++) {
        auto v = factorize(i);
        for (pair<int, int> p : v) {
            count[p.first] += p.second;
        }
    }

    mint ans = 1;

    for (auto e : count) {
        ans *= (e.second + 1);
    }

    cout << ans.x << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    int count=0;
    int arr[t];
    for(int i=0;i<t;i++){
        cin>>arr[i];
    }
    for(int i=0;i<t;i++){
        int k=i+1;
        while(k<t){
            count=count+(arr[i]*arr[k]);
            k=k+1;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
 
const int N = int(2e5) + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e18; 
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

string s;
ll dp[N][14];
int main (){
    cin >> s;
    dp[0][0] = 1;
    for (int i = 0; i < sz(s); ++i){
        for (int j = 0; j < 13; ++j){
            for (int k = 0; k <= 9; ++k){
                if (s[i] == '?' || (s[i] - '0') == k){
                    (dp[i + 1][(j * 10 + k) % 13] += dp[i][j]) %= mod;
                }
            }
        }
    }
    return !printf ("%lld\n", dp[sz(s)][5]);
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    long long int h;
    long long int w;
    cin>>n;
    cin>>h;
    cin>>w;
    long long int a[n],b[n],cnt=0;
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
        cin>>b[i];
        if(a[i]>=h && b[i]>=w)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int n;
  char s[100001];
  scanf("%d%s", &n, s);
  int ans = 0;
  for (char *p = s; *p;)
  {
    char *q = p;
    while (*q == *p)
    {
      ++q;
    }
    p = q;
    ++ans;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
# 参考にさせていただいたもの
# https://atcoder.jp/contests/abc158/submissions/10620169
# mulをpow(10,桁数,P)ではなく、ループ中に10倍ずつする方法
# counterに収められたある剰余をとる集合の大きさからnC2でペア数を求める方法

def main():
    N, P = map(int, input().split())
    S = [int(c) for c in input()]

    ret = 0
    if P in {2, 5}:
        for i, x in enumerate(S, 1):
            if x % P == 0:
                ret += i
        print(ret)
        return

    else:
        curr_num = 0
        counter = [0] * P
        counter[0] = 1
        mul = 1
        for i, x in enumerate(reversed(S)):
            curr_num = (curr_num + x * mul) % P
            counter[curr_num] += 1
            mul = (mul * 10) % P

        def choose_2(x):
            return x * (x - 1) // 2

        ret = sum(choose_2(cnt) for cnt in counter)
        print(ret)
        return


if __name__ == '__main__':
    main()


Measured memory_bytes: 5096
#include <cstdio>

int main()
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	if(a+b==c)
	{
		printf("Yes");
	}
	else if(b+c==a)
	{
		printf("Yes");
	}
	else if(a+c==b)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	
}
	

Measured memory_bytes: 1724
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


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

	int ans = 0;
	for (int i = 1; i<n; i++) {
		int cnt = 0;

		for (char c = 'a'; c <= 'z'; c++) {
			bool left = false, right = false;

			for (int j = 0; j<i; j++)
				if (s[j] == c)
					left = true;

			for (int j = i; j<n; j++)
				if (s[j] == c)
					right = true;

			if (left&&right)
				cnt++;
		}

		if (ans<cnt)
			ans = cnt;
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
N = int(input())

ans = [0]*(10**5)
for x in range(1,110):
    for y in range(1,110):
        for z in range(1,110):
            cnt = x**2 + y**2 + z**2 + x*y + y*z + z*x
            ans[cnt] += 1
        
for i in range(1,N+1):
    print(ans[i])


Measured memory_bytes: 9896
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define int 		long long
#define vi 			vector<int>
#define vec(x) 		vector<x>
#define matrix 		vector<vector<int>>
#define pii 		pair<int,int>
#define rep(i,s,e)  for(int i=s;i<e;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define MOD			1000000007
#define pb 			push_back
#define ff 			first
#define ss 			second		
#define w(x)		int x; cin>>x; while(x--)
const int INF=1e18;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1)  returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set

vector<int> get_divisors(int num){
	vector<int> div;
	for(int i=2;i*i<=num;i++){
		if(num%i==0){
			if(i*i==num)
				div.pb(i);
			else{
				div.pb(i),div.pb(num/i);
			}
		}
	}
	return div;
}


void solve(){
	int n;
	cin>>n;
	// trace(n);
	if(n==2){
		cout<<1<<'\n';return;
	}

	vector<int> div=get_divisors(n-1);
	set<int> s;
	for(auto c:div){
		s.insert(c);
	}
	int ans=2+div.size();
	//trace(ans);

	div=get_divisors(n);

	//trace(ans);

	for(auto c:div){
		int num=n;
		//trace(num,c);
		if(s.find(c)!=s.end())continue;
		while(num%c==0 && num>=c){
			num=num/c;
		}
		if(num%c==1) ans++;
	}

	cout<<ans<<endl;
	
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
// #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}


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

const int N=1e5+10;
char s[N],a[N];

bool ok(char s[],char a[],int n)
{
    for (int i=1;i<n-1;i++) {
        if (a[i]=='S'&&s[i]=='o' || a[i]=='W'&&s[i]=='x') {
            a[i+1]=a[i-1];
        } else {
            a[i+1]=(a[i-1]=='W')?'S':'W';
        }
    }
    if (a[n-1]=='S'&&s[n-1]=='o' || a[n-1]=='W'&&s[n-1]=='x') {
        if (a[n-2]!=a[0]) return false;
    } else {
        if (a[n-2]==a[0]) return false;
    }
    if (a[0]=='S'&&s[0]=='o' || a[0]=='W'&&s[0]=='x') {
        if (a[n-1]!=a[1]) return false;
    } else {
        if (a[n-1]==a[1]) return false;
    }
    return true;
}

int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",s);
    bool good=false;
    for (int i=0;i<2;i++) {
        for (int j=0;j<2;j++) {
            a[0]=i?'S':'W';
            a[1]=j?'S':'W';
            if (ok(s,a,n)) {
                puts(a);
                good=true;
                break;
            }
        }
        if (good) break;
    }
    if (!good) {
        puts("-1");
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>
#include <set>
#include <deque>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {

	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}

		out << "\n";
	}
		
    return out;

}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	for (int i = 1; i <= 9; ++i) {
		for (int j = 1; j <= 9; ++j) {
			if (i * j == n) {
				cout << "Yes\n";
				return 0;
			}
		}
	}

	cout << "No\n";

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    char c1[3]; cin >> c1;
    char c2[3]; cin >> c2;

    if (c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0]) cout << "YES" << endl;
    else cout << "NO" << endl;

    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define REV_INF (1 << 31)

int main(void)
{
	int data[100000];
	int n;
	int k;
	int sum;
	int sum_max;
	int i;
	
	while (1){
		scanf("%d%d", &n, &k);
		
		if (n == 0){
			break;
		}
		
		for (int i = 0; i < n; i++){
			scanf("%d", &data[i]);
		}
		
		sum = 0;
		
		for (i = 0; i < k; i++){
			sum += data[i];
		}
		
		sum_max = sum;
		for (; i < n; i++){
			sum += data[i];
			sum -= data[i - k];
			if (sum_max < sum){
				sum_max = sum;
			}
		}
		
		printf("%d\n", sum_max);
	}
	
	return (0);
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string S;
    cin>>S;
    reverse(S.begin(),S.end());
    for(int i=0;i<4;i++)reverse(divide[i].begin(),divide[i].end());
    bool can=true;
    for(int i=0;i<S.size();){
        bool can2=false;
        for(int j=0;j<4;j++){
            string d=divide[j];
            if(S.substr(i,d.size())==d){
                can2=true;
                i+=d.size();
            }
        }
        if(!can2){
            can=false;
            break;
        }
    }
    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 512
N = int(input())
lis = []
six = 6
nine = 9
while six<=100000:
    lis.append(six)
    six *= 6
while nine<=100000:
    lis.append(nine)
    nine *= 9
lis.sort()
dp = [0]
for i in range(1,N+1):
    tmp = dp[i-1]+1
    for l in lis:
        if i-l<0:
            break
        tmp = min(tmp,dp[i-l]+1)
    dp.append(tmp)
print(dp[N])



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

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

    vector<vector<int>> F(n);
    rep(i, n) {
        rep(j, 10) {
            int tmp; cin >> tmp;
            F[i].push_back(tmp);
        }
    }
    vector<vector<int>> P(n);
    rep(i, n) {
        rep(j, 11) {
            int tmp; cin >> tmp;
            P[i].push_back(tmp);
        }
    }


    int res = -1000000005;
    for (int i = 0; i < (1<<10); i++) {
        if (i == 0) continue;
        int sum_p = 0;

        // 店
        for (int j = 0; j < n; j++) {

            int cnt = 0;
            for (int k = 0; k < 10; k++) {
                if (i & (1<<k)) {
                    if (F[j][k] == 1) {
                        ++cnt;
                    }
                }
            }

            sum_p += P[j][cnt];
        }

        res = max(res, sum_p);
    }

    cout << res << endl;
}

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

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

    int n; cin >> n;
    vector<int> h(n), dp(n);
    for (int i = 0; i < n; ++i) cin >> h[i];

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; ++i) {
        dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]));
    }

    cout << dp[n-1] << endl;
    return 0;
}

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

int		main(void)
{
	int		a, b;

	cin >> a >> b;
	if (a == b)
		cout << "Draw" << endl;
	else
	{
		if (a == 1 || b == 1)
			cout << (a == 1 ? "Alice" : "Bob") << endl;
		else
			cout << (a > b ? "Alice" : "Bob") << endl;
	}
}

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

#define ll long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0)
#define infl 1e18+9
#define sz(a) ((int)a.size())
ll mod=1e9+7;

void solve(){
  int n; cin>>n; 
  string s; cin>>s; 
  s="*"+s; 
  vector<vector<ll>> dp(n+10,vector<ll>(n+10)); 
  vector<vector<ll>> sum(n+10,vector<ll>(n+10)); 
  dp[0][1]=1; 
  sum[0][1]=1; 
  ll ans=0; 
  for(int i=1;i<=n-1;i++){
    ans=0; 
    for(int j=1;j<=i+1;j++){
      if(s[i]=='<'){
        dp[i][j]+=sum[i-1][j-1]; 
      }
      else {
        dp[i][j]+=sum[i-1][i]-sum[i-1][j-1]; 
      }
      dp[i][j]%=mod; 
      ans+=dp[i][j]; 
      ans%=mod; 
    }
    for(int j=1;j<=i+1;j++){
      sum[i][j]+=sum[i][j-1]+dp[i][j]; 
    }
  }
  cout<<ans<<endl;  
}

int main(){
	fast_io;
	clock_t beg=clock();
  int t;
  t=1;
  while(t--){
	  solve();
  }
	clock_t end=clock();
	fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 142080
N = int(input())
A_array = list(map(int, input().split()))

ans = 0

sum_dic = {}

for i in range(N-1):
    s = i + A_array[i]
    if s in sum_dic:
        sum_dic[s] += 1
    else:
        sum_dic[s] = 1
    t = A_array[i+1] - (i+1)
    if -t in sum_dic:
        ans += sum_dic[-t]


print(ans)

Measured memory_bytes: 111768
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>

using namespace std;

#define int_ int64_t
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define lb long double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

ll n,a,b;

ll solve(ll a,ll b) {
    ll c=a*b;
    if (c<=3) {
        if (c==1||c==2) return 0;
        else return 1;
    } else {
        ll r=sqrt(c);
        if (r*r==c) {
            if (r==a) return 2*r-2;
            else return 2*r-3;
        } else if (r*r<c&&c<=r*(r+1)) {
            return 2*r-2;
        } else {
            return 2*r-1;
        }
    }
}

int main()
{
    scanf("%lld",&n);
    for (ll i=1;i<=n;i++) {
        scanf("%lld%lld",&a,&b);
        printf("%lld\n",solve(a,b));
    }
}

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

int N, A, B, C, D;
string s;

signed main() {
  cin >> N >> A >> B >> C >> D >> s;

  if (C < D) {
    int cnt = 0;
    for (int i = B - 1; i <= D - 1; i++) {
      if (s[i] == '#') {
        cnt++;
        if (cnt >= 2) {
          cout << "No" << endl;
          return 0;
        }
      } else {
        cnt = 0;
      }
    }

    cnt = 0;
    for (int i = A - 1; i <= C - 1; i++) {
      if (s[i] == '#') {
        cnt++;
        if (cnt >= 2) {
          cout << "No" << endl;
          return 0;
        }
      } else {
        cnt = 0;
      }
    }

  } else if (C > D) {

    int pla;
    bool flag = false;
    for (int i = B - 1; i <= D - 1; i++) {
      if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
        flag = true;
        pla = i;
        break;
      }
    }

    if (!flag) {
      cout << "No" << endl;
      return 0;
    }

    int cnt = 0;
    for (int i = B - 1; i <= D - 1; i++) {
      if (s[i] == '#') {
        cnt++;
        if (cnt >= 2) {
          cout << "No" << endl;
          return 0;
        }
      } else {
        cnt = 0;
      }
    }

    cnt = 0;
    for (int i = A - 1; i <= C - 1; i++) {
      if (s[i] == '#') {
        cnt++;
        if (cnt >= 2) {
          cout << "No" << endl;
          return 0;
        }
      } else {
        cnt = 0;
      }
    }
  }

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


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cmath>
using namespace std;
int main(){
    int i,j;
    double sn[1000];
    double n,s,sum1=0,sum2=0,ave,po,dispersion,standard;
    
    cin>>n;
    while(n!=0){
        for(i=1;i<=n;i++){
            cin>>s;
            sn[i-1]=s;
            sum1+=s;
            
        }
        ave=1.0*sum1/n;
        for(j=1;j<=n;j++){
            po=pow(sn[j-1]-ave,2);
            sum2+=po;
        }
       
        dispersion=1.0*sum2/n;
        standard=sqrt(dispersion);
        cout<<fixed<<standard<<endl;
        sum1=0;
        sum2=0;
        ave=0;
        po=0;
        dispersion=0;
        standard=0;
        cin>>n;
        
    }
    
    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define rev_all( x ) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int mod = 1e9 + 7;
const int inf = 1e12 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int& x:a)cin >> x;
  for(int i = k; i < n; i++){
    cout << (a[i] > a[i-k] ? "Yes" : "No") << endl;
  }
}
signed main(){
  fast;
  int t = 1;
  //cin >> t;
  for(int i = 1; i <= t; i++){
    solve();
  }
}

Measured memory_bytes: 4760
/**
*    author:  souzai32
*    created: 21.08.2020 23:53:29
**/

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;
typedef long long ll;
using namespace std;

int main() {

    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h+2,vector<char>(w+2,'#'));
    vector<vector<int>> d(h+2,vector<int>(w+2));
    vector<vector<bool>> t(h+2,vector<bool>(w+2));
    queue<tuple<int,int,int>> que;
    rep2(i,h){
        rep2(j,w) cin >> s[i][j];
    }
    int ans=0;

    int tate[4]={1,-1,0,0};
    int yoko[4]={0,0,1,-1};
    tuple<int,int,int> p;
    int x,y;

    rep2(i,h){
        rep2(j,w){
            if(s[i][j]=='#') continue;
            t[i][j]=true;
            que.push(tuple<int,int,int>(i,j,0));
            while(!que.empty()){
                p=que.front();
                que.pop();
                x=get<0>(p); y=get<1>(p);
                d[x][y]=get<2>(p);
                rep(k,4){
                    if(t[x+tate[k]][y+yoko[k]]) continue;
                    if(s[x+tate[k]][y+yoko[k]]=='#') continue;
                    que.push(tuple<int,int,int>(x+tate[k],y+yoko[k],d[x][y]+1));
                    t[x+tate[k]][y+yoko[k]]=true;
                }
            }
            rep2(k,h){
                rep2(l,w){
                    ans=max(ans,d[k][l]);
                    // cout << d[k][l];
                    // d[k][l]=0;
                    t[k][l]=false;
                }
                // cout << endl;
            }
            // cout << endl;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import heapq
from operator import itemgetter

# なんこか入力
n,m = map(int, input().split())

# n行の複数列ある数値を二次元配列へ。x[n][?]
x = [[int(i) for i in input().split()] for i in range(n)] 

x = sorted(x,key=itemgetter(1),reverse = True)
x = sorted(x,key=itemgetter(0))

work = []
j = 0
answer = 0
for i in range(1,m+1,1):
    while j < n and x[j][0] == i:
        heapq.heappush(work,-x[j][1])
#        print(work)
        j += 1
    if work:
        answer -= heapq.heappop(work)

print(answer)






Measured memory_bytes: 84568
#include<iostream>
#include<cstring>
#include<climits>
using namespace std;
int n,m;
int a[100005],b[100005];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	b[0]=b[1]=0;
	for(int i=2;i<=n;i++){
		b[i]=INT_MAX;
		for(int j=1;j<=m&&j!=i;j++){
			b[i]=min(b[i],b[i-j]+abs(a[i-j]-a[i]));
		}
	}
	cout<<b[n];
	return 0;
}

Measured memory_bytes: 1024
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0, p; char f[7];
	while (x) {
		p = x; x /= 10;
		f[s++] = p - (x << 1) - (x << 3);
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
//#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003];
int h1[100003], h2[100003], h3[100003], h4[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int Q1[110000], Q1L, Q1R;
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	Q1[0] = 1; Q1R = 1;
	while (Q1R > Q1L) {
		int a1 = Q1[Q1L]; Q1L++;
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1[Q1R] = i; Q1R++;
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) h1[a[i]]++;
		if (dist[b[i]] > dist[a[i]]) h1[b[i]]++;
	}
	for (int i = 1; i <= n; i++)z[i].resize(h1[i]);
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) { z[a[i]][h2[a[i]]] = make_pair(b[i], d[i]); h2[a[i]]++; }
		if (dist[b[i]] > dist[a[i]]) { z[b[i]][h2[b[i]]] = make_pair(a[i], d[i]); h2[b[i]]++; }
	}
	for (int i = 1; i <= n; i++) h3[dist[i]]++;
	for (int i = 0; i <= n; i++) D[i].resize(h3[i]);
	for (int i = 1; i <= n; i++) D[dist[i]][h4[dist[i]]] = i, h4[dist[i]]++;
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 25052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
string to_bin_string(int n){
    stringstream ss;
    ss << bitset<10>(n);
    string s = ss.str();
    reverse(all(s));
    return s;
}
int main(){
    string s, t;
    cin >> s >> t;
    if(s.size() < t.size())return 0;
    rep(i,s.size() - t.size() + 1){
        string sub = s.substr(i, t.size());
        if(t == sub)cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 3212
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s, t;
    cin >> n >> s >> t;
    for(int i = 0; i < n; ++i){
        bool ok = true;
        for(int j = i; j < n; ++j){
            if(s[j] != t[j-i]) ok = false;
        }
        if(ok){
            cout << 2*n - (n-i) << endl;
            return 0;
        }
    }
    cout << 2*n << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n0 = 2e5 + 123, p = 200003;
int pw[p], f[p], cnt[p];

typedef complex <double> cd;
const int K = 19;
const double PI = acos(-1);
vector <cd> w[K + 1];
int lg[(1 << K) + 1];

void fft(vector <cd> & a, int inv) {
	int n = a.size();
	int j = 0;
	for (int i = 1; i < n; i++) {
		int k = n >> 1;
		for (; j & k; k >>= 1)
			j ^= k;
		j ^= k;
		if (i < j)
			swap(a[i], a[j]);
	}
	cd even, odd;
	for (int len = 2; len <= n; len <<= 1) {
		int m = lg[len];
		for (int i = 0; i < n; i += len) {
			for (int j = 0; j < len / 2; j++) {
				even = a[i + j], odd = a[i + j + len / 2];
				if (inv) {
					even /= 2, odd /= 2;
					odd *= w[m][j == 0 ? 0 : len - j];
				}	else
					odd *= w[m][j];
				a[i + j] = even + odd;
				a[i + j + len / 2] = even - odd;
			}
		}
	}
}

vector <ll> mul(const vector <int> & a, const vector <int> & b) {
	vector <cd> fa(all(a)), fb(all(b));
	int n = 1, need = a.size() + b.size();
	while (n < need)
		n <<= 1;
	fa.resize(n);
	fb.resize(n);
	fft(fa, 0);
	fft(fb, 0);
	for (int i = 0; i < n; i++)
		fa[i] *= fb[i];
	fft(fa, 1);
	vector <ll> res(need - 1);
	for (int i = 0; i < need - 1; i++)
		res[i] = llround(fa[i].real());
	return res;
}

void pre_fft() {
	for (int i = 2; i <= 1 << K; i++) {
		lg[i] = lg[i / 2] + 1;
	}
	for (int i = 0; i <= K; i++) {
		w[i].resize(1 << i);
		double ang = 2 * PI / (1 << i);
		for (int j = 0; j < 1 << i; j++) {
			w[i][j] = cd(cos(j * ang), sin(j * ang));
		}
	}
}

int bp(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1)
			res = (ll)res * x % p;
		x = (ll)x * x % p;
		y /= 2;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	pre_fft();
	pw[0] = 1;
	f[1] = 0;
	for (int i = 1; i < p; i++) {
		pw[i] = pw[i - 1] * 2 % p;
		f[pw[i]] = i;
	}
	int n;
	cin >> n;
	vector <int> a(n), cnt(p);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0) continue;
		cnt[f[a[i]]]++;
	}
	vector <int> b = cnt;
	vector <ll> c = mul(cnt, b);
	ll ans = 0;
	for (int i = 0; i < SZ(c); i++)
		ans += (ll)c[i] * bp(2, i);
	for (int i = 0; i < n; i++)
		ans -= (ll)a[i] * a[i] % p;
	cout << ans / 2;
}


Measured memory_bytes: 45668
N = int(input())
w_list = input().split()
for i in range(len(w_list)):
    w_list[i] = int(w_list[i])    

res = [0]*N
for T in range(N):
    #S1 = W1+W2+...WT
    #S2 = WT+1 +...+WN
    S1 = sum(w_list[:T])
    S2 = sum(w_list[T:])
    res[T] = abs(S1-S2)
print(min(res))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())

int main() {
  string correct="CODEFESTIVAL2016";
  string wrong; cin>>wrong;

  int count=0;

  rep(i,correct.size()){
    if(wrong.at(i)!=correct.at(i)){
      count++;
    }
  }

  cout<<count<<endl;
}
  


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

int main()
{
    std::vector<std::string> v(3);
    std::vector<std::vector<int>> t(3);
    std::cin >> v[0] >> v[1] >> v[2];
    for(int i = 0; i < 3; i++){
        for(char j : v[i]){
        if(j == 'a')t[i].push_back(0); // a -> 0
        if(j == 'b')t[i].push_back(1); // b -> 1
        if(j == 'c')t[i].push_back(2); // c -> 2
        }
    }
    for(int i = 0; i < 3; i++)std::reverse(t[i].begin(),t[i].end());

    int cur = 0;
    char ans;
    while(true){
        if(t[0].empty() && cur == 0){ans = 'A';break;}
        if(t[1].empty() && cur == 1){ans = 'B';break;}
        if(t[2].empty() && cur == 2){ans = 'C';break;}
        int tmp = t[cur].back();
        t[cur].pop_back();
        cur = tmp;
        /*
        for(int i = 0; i < 3; i++){
            for(auto j : t[i])std::cout << (char)('a' + j);
            std::cout << std::endl;
        }
        std::cout << "--------------------------------------------------"<< std::endl;*/
    }
    std::cout << ans << std::endl;

}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder.BC081
{
    public class B
    {
        public static void Main()
        {
            Console.ReadLine();
            var c = 0;
            var nums = Console.ReadLine().Split(" ").Select(n => int.Parse(n)).ToArray();

            while (nums.All(n => n % 2 == 0))
            {
                c++;
                for (int i = 0; i < nums.Length; i++)
                {
                    nums[i] /= 2;
                }
            }
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            sw.Write(c);
            sw.Flush();
        }
    }
}

Measured memory_bytes: 28384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		v.emplace_back(a);
	}
	sort(v.begin(), v.end(), greater<int>());
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += v[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256