akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main()
{
char x, y;
	cin >> x >> y;
	if (x > y) {
		cout << '>' << endl;
	}
	 else if (x < y) {
		cout << '<' << endl;
    }
	else {
		cout << '=' << endl;
	}
}

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

char s[4];
string res;

int main(){
  cin >> s;
  int ans;
  for(int S = 0; S < 8; S++){
    int sum = s[0] - '0';
    for(int i = 0; i < 3; i++){
      if(S & (1 << (2 - i))){
        sum += s[i + 1] - '0';
      }else{
        sum -= s[i + 1] -'0';
      }
    }
    cerr << S << " " << sum << endl;
    if(sum == 7){
      ans = S;
      break;
    }
  }
  cout << s[0];
  rep(i, 3){
    if(ans & (1 << (2 - i))){
      cout << '+';
    }else{
      cout << '-';
    }
    cout << s[i + 1];
  } 
  cout << "=7" << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N, K = map(int, input().split())
A = [(int(c)%K)-1 for c in input().split()]
B = [0]
for c in A:
  B += [B[-1]+c]
dic = defaultdict(int)
ldic = defaultdict(int)
for i in range(min(K,N+1)):
  c = B[i]
  dic[c%K] += 1
ans = 0
#print(dic)
for i in range(1,N+1):
  x = B[i-1]
  ldic[x%K] += 1
  ans += dic[x%K]-ldic[x%K]
  if K+i-1<=N:
    dic[B[K+i-1]%K] += 1
  """
  print('###############')
  print(i,x, ans)
  print(dic)
  print(ldic)
  """
print(ans)

Measured memory_bytes: 120704
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return c-'0';}

void dfs(string s,int size){
  if(s.size() == size-1){
    if(size == 1){
      print('a');
      return;
    }
    int last = 0;
    rep(i,size)chmax(last,s[i]-'a');
    rep(i,last+2){
      string t = s + (char)('a'+i);
      print(t);
    }
    return;
  }
  int last = 0;
  rep(i,size)chmax(last,s[i]-'a');
  if(s.size() == 0)last--;
  rep(i,last+2){
    s = s + (char)('a'+i);
    if(s.size() < size)dfs(s,size);
    s.pop_back();
  }
}

// TODO: write
int main() {
  int n;cin>>n;
  string s;
  dfs(s,n);
  
  return 0;
}


Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
double solve(int r, int n) {
  vector<int> h(41);
  for (int i = 0; i < n; i++) {
    int xl, xr, hh;
    cin >> xl >> xr >> hh;
    xl += 20;
    xr += 20;
    for (int x = xl; x < xr; x++) {
      h[x] = max(h[x], hh);
    }
  }
  double ans = 1e9;
  for (int i = -r + 1; i < r; i++) {
    int x = i + 20;
    int hh = min(h[x - 1], h[x]);
    ans = min(ans, 1. * hh - sqrt(r * r - i * i) + r);
  }
  return ans;
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int r, n;
  while (cin >> r >> n) {
    if (r == 0) return 0;
    cout << setprecision(5) << fixed << solve(r, n) << '\n';
  }
  return 0;
}


Measured memory_bytes: 3316
from sys import setrecursionlimit, exit

n, m = map(int, input().split())
a = [int(x) // 2 for x in input().split()]

t = 0
while a[0] % 2 == 0:
    a[0] //= 2
    t += 1

for i in range(1, n):
    t2 = 0
    while a[i] % 2 == 0:
        a[i] //= 2
        t2 += 1
    if t2 != t:
        print(0)
        exit()

def gcd(x, y):
    return gcd(y, x%y) if y else x
def lcm(x, y):
    return x // gcd(x, y) * y

m >>= t
l = 1
for i in a:
    l = lcm(l, i)
    if l > m:
        print(0)
        exit()
print((m // l + 1) // 2)

Measured memory_bytes: 14244
#include<stdio.h>
int main(void)
{
	int a,b,c;
	int x=3;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b){
		x--;
	}
	if(b==c){
		x--;
	}
	if(a==c){
		x--;
	}
	if(a==b && b==c && a==c){
		x=1;
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <vector>
using namespace std;

const int MAX_N = 2e5 + 10, MOD = 1e9 + 7;
int n, L;
int sum, dis = MAX_N, ans;
int Arr[MAX_N];
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> L;
	for (int i = 0; i < n; i++) {
		Arr[i] = L + i;
		sum += Arr[i];
	}

	for (int i = 0; i < n; i++)
		if (abs(Arr[i]) < dis) {
			dis = abs(Arr[i]);
			ans = sum - Arr[i];
		}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	S := getString()
	Q := getInt()

	isReversed := false

	head := make([]byte, 0, pow(10, 6))
	tail := make([]byte, 0, pow(10, 6))

	for i := 0; i < Q; i++ {
		T := getInt()

		if T == 1 {
			isReversed = !isReversed
		} else {
			F := getInt()
			C := getString()

			if isReversed {
				if F == 1 {
					tail = append(tail, C[0])
				} else {
					head = append(head, C[0])
				}
			} else {
				if F == 1 {
					head = append(head, C[0])
				} else {
					tail = append(tail, C[0])
				}
			}
		}
	}

	if isReversed {
		S = Reverse(S)
		S = Reverse(string(tail)) + S + string(head)
	} else {
		S = Reverse(string(head)) + S + string(tail)
	}

	fmt.Println(S)
}

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return n * powMod(n, p-1)
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
int v, w, a, b, t;
int main() {
	a = read(); v = read(); b = read(); w = read(); t = read();
	if (v <= w)
		cout << "NO" << endl;
	else {
		v -= w;
		int des = abs(a - b);
		if ((ll)v * t >= (ll)des)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

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

#define sz(x) int(x.size())
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;


int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  int n; cin >> n;
  string s[2]; cin >> s[0] >> s[1];
  for (int i = 0; i < 2 * n; ++i){
    cout << s[i % 2][i / 2];
  }
}



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

public class Test
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		int[] x = new int[n];
		for (int i = 0; i < n; i++) x[i] = int.Parse(Console.ReadLine());
		long ret = 0;
		for (int z = 0; z < 2; z++)
		{
			int c = (n + z) / 2;
			Array.Sort(x);
			LinkedList<int> small = new LinkedList<int>();
			for (int i = 0; i < c; i++)
			{
				if (i % 2 == 0) small.AddFirst(x[i]);
				else small.AddLast(x[i]);
			}
			Array.Reverse(x);
			LinkedList<int> big = new LinkedList<int>();
			for (int i = 0; i < n - c; i++)
			{
				if (i % 2 == 0) big.AddLast(x[i]);
				else big.AddFirst(x[i]);
			}
			int[] sarr = small.ToArray(); int[] barr = big.ToArray();
			int[] arr = new int[n];
			for (int i = 0; i < n; i++)
			{
				if (z == 0)
				{
					if (i % 2 == 0) arr[i] = barr[i / 2];
					else arr[i] = sarr[i / 2];
				}
				else
				{
					if (i % 2 == 0) arr[i] = sarr[i / 2];
					else arr[i] = barr[i / 2];
				}
			}
			long sum = 0;
			for (int i = 1; i < n; i++) sum += Math.Abs(arr[i] - arr[i - 1]);
			ret = Math.Max(ret, sum);
		}
		Console.WriteLine(ret);
	}
}

Measured memory_bytes: 29524
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/


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

    if(n == 1){
        cout << "Hello World" << endl; 
    }else{
        int a, b; cin >> a >> b;
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
#ifdef BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED
  boost::for_each(vc, [&os](T value) {
#else
  std::for_each(vc.begin(), vc.end(), [&os](T value) {
#endif
    os << value << ' ';
    });
  return os;
    }

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;
  ui N{}; cin >> N;
  map<string, ull> res{};

  rep(0, N)
  {
    string str;
    cin >> str;
    vector<char> vc{};
    for (auto c : str) vc.push_back(c);
    boost::sort(vc);
    str.clear();
    rep_uj(0, vc.size()) str += vc[j];

    ++res[str];
  }

  auto calc = [](ull n) {
    return n * (n - 1) / 2;
  };

  auto ans = boost::accumulate(res, 0ULL, [&calc](auto res, pair<string, ull> p) {
    return res + (p.second > 1 ? calc(p.second) : 0);
    });

  using std::cout;
  cout << ans << '\n';
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll nmax = 100005;
int main() {
  ll n;
  cin >> n;
  
  for(ll i=ceil(sqrt(n));i>=1;i--){
    if(n%i == 0){
      ll p = i;
      ll q = n/i;
      cout << (p-1) + (q-1) << endl;
      return(0);
    }
  }
  
  return(0);
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
const int MAX_V = 200000;
typedef pair<int, int> P;
struct edge
{
    ll to;
    ll cost;
};
vector<vector<edge>> G(MAX_V);
vector<ll> dijkstra(ll s, ll N)
{
    vector<ll> value(N, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    value[s] = 0;
    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (value[v] < p.first)
        {
            continue;
        }
        rep(i, G[v].size())
        {
            edge e = G[v][i];
            if (value[e.to] > value[v] + e.cost)
            {
                value[e.to] = value[v] + e.cost;
                que.push(P(value[e.to], e.to));
            }
        }
    }

    return value;
}
int main()
{
    int N, u, v;
    cin >> N >> u >> v;
    u--; v--;

    rep(i, N - 1) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        G[A].push_back({B, 1});
        G[B].push_back({A, 1});
    }

    auto du = dijkstra(u, N);
    auto dv = dijkstra(v, N);
/*
    ll a1 = INF;
    rep(i, N) {
        if (du[i] == dv[i]) chmin(a1, du[i]);
    }
*/
    ll a2 = 0;
    rep(i, N) {
        if ((int)G[i].size() <= 1) continue;
        if (dv[i] >= du[i]) chmax(a2, dv[i]);
    }

    cout << a2 << endl;
    return 0;
}

Measured memory_bytes: 14800
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;

int n;

vector<vector<int> > path;

int main(void)
{
	/*
	A: 0
	X: 1
	Y: 2
	Z: 3
	W: 4
	B: 5
	*/
	path.resize(6);
	path[0].push_back(1); path[0].push_back(2);
	path[1].push_back(INF); path[1].push_back(3);
	path[2].push_back(1); path[2].push_back(INF);
	path[3].push_back(4); path[3].push_back(5);
	path[4].push_back(5); path[4].push_back(2);
	path[5].push_back(2); path[5].push_back(1);

	string p;
	while(cin >> p && p[0] != '#')
	{
		int size = p.size();
		int now = 0;
		for (int i = 0; i < size; i++)
		{
			int c = p[i] - '0';
			now = path[now][c];
			if(now == INF) break;
		}
		cout << (now == 5 ? "Yes" : "No") << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
//222/03/2020
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
struct OverloadedNode{
    ll val,pos;
    bool operator < (const OverloadedNode &rhs) const {
        if(val==rhs.val) return pos<rhs.pos;
        else return val<rhs.val;
    }
};

//template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//typedef tree<OverloadedNode,null_type,less<OverloadedNode>,rb_tree_tag,tree_order_statistics_node_update>OverloadedPbds;
//template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
//template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
//template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
//template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
//template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
//template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

/*Containers*/
//vector<ll>v;
//deque<ll>dq;
//stack<ll>stk;
//map<ll,ll>mp;
//unordered_map<ll,ll>ump;
//set<ll>st;
//multiset<ll>mst;
//unordered_set<ll>ust;
//unordered_multiset<ll>umst;
//priority_queue<ll,deque<ll>,greater<ll>>pq;
//Pbds<ll>ost;
/*OverLoaded Containers*/
//vector<OverloadedNode>v;
//deque<OverloadedNode>dq;
//stack<OverloadedNode>stk;
//map<OverloadedNode,OverloadedNode>mp;
//set<OverloadedNode>st;
//multiset<OverloadedNode>mst;
//priority_queue<OverloadedNode>pq;
//OverloadedPbds oost;
/*Global Variables*/

int main(){
    _fastio
    string s="",s1="",s3="",s4="",s5="",s6="";
    cin>>s;
    s1=s;
    reverse(s1.begin(),s1.end());

    ll len=s.length();
    ll x=(len-1)/2;
    ll y=(len+3)/2;

    for(ll i=0;i<x;i++){
        s3+=s[i];
    }
    s4=s3;
    reverse(s4.begin(),s4.end());

    for(ll i=y-1;i<len;i++){
        s5+=s[i];
    }
    s6=s5;
    reverse(s6.begin(),s6.end());

    if(s==s1&&s3==s4&&s5==s6) cout<<"Yes"<<en;
    else cout<<"No"<<en;


    return 0;
}


Measured memory_bytes: 256
def f(a, b, x):
    return (a*x)//b - a*(x//b)

a, b, n = map(int, input().split())

t1 = f(a, b, n)
t2 = f(a, b, max(1, n - n%b - 1))
t = max(t1, t2)

print(t)

Measured memory_bytes: 9116
N = int(input())
S = []
for i in range(N):
    S.append(input())

t_moji = ['M', 'A', 'R', 'C', 'H']
moji = {'M': 0, 'A': 1, 'R':2, 'C': 3, 'H': 4}
buff = [0 for i in range(5)]

for i in range(N):
    flag = False
    for j in range(5):
        if t_moji[j] == S[i][0]:
            flag = True
    if flag:
        buff[moji[S[i][0]]] += 1


# print(buff)
# k = [1, 1, 1, 1, 3, 6]
count = 0
for i in range(5):
    if buff[i] > 0:
        count += 1

if count < 3:
    print(0)
    exit()
else:
    # ans = cmb(count, 3)
    ans = 0
    for i in range(5):
        for j in range(5):
            if i != j:
                for k in range(5):
                    if i != k and j != k:
                        ans += buff[i] * buff[j] * buff[k]
    print(ans//6)

Measured memory_bytes: 57560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n;
  string s;
  cin>>n>>s;
  int ans=INF;
  vi w(n,0),e(n,0);
  rep(i,n){
    if(s[i]=='E') e[i]++;
    else w[i]++;
  }
  rep(i,n-1) e[i+1]+=e[i];
  rep(i,n-1) w[i+1]+=w[i];

  rep(i,n){
    int ams;
    int w_e=0,e_w;
    if(i>0) w_e=w[i-1];
    e_w=e[n-1]-e[i];
    ams=w_e+e_w;
    chmin(ans,ams);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5380
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

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

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];

int main() {
	int n;
	cin >> n;
	vector<int>a(n), b(n);
	int big = 0;
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b.begin(), b.end());
	rep(i, n) {
		if (a[i] == b[n - 1])cout << b[n - 2] << endl;
		else cout << b[n - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
long long maxValue(long long n, long long capacity, vector<long long> &weight, vector<long long> &value,vector<vector<long long> > &res) {
    if (n == 0 || capacity == 0)
        return 0LL;
    if (res[n][capacity] != -1)
        return res[n][capacity];
    long long excl = maxValue (n-1, capacity, weight, value, res);
    long long incl = 0;
    if (weight[n-1] <= capacity) {
        incl = value[n-1] + maxValue(n-1, capacity - weight[n-1], weight, value, res);
    }
    return res[n][capacity] = max (incl, excl);
}
int main() {
    long long n, capacity;
    cin>>n>>capacity;
    vector<long long> weight(n), value(n);
    for (long long index = 0; index < n; index++) {
        cin>>weight[index];
        cin>>value[index];
    }
    vector<vector<long long> > res(n+1, vector<long long> (capacity+1, -1)); // res[i][j] : maximum value that can be obtained with i items and a knapsack with capacity j
    cout<<maxValue(n, capacity, weight, value, res)<<"\n";
    return 0;
}


Measured memory_bytes: 83164
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int field[21][21];
int dp[2][1<<20];
int h,w;
//
//int dfs(int a,int s){
//	if(a==h*w)return 0;
//	if(dp[a][s]!=-1)return dp[a][s];
//	int res=0;
//	int curh=a/w;
//	int curw=a%w;
//	// ツ置ツつゥツづ按つ「
//	{
//		int ns=s;
//		ns&=~(1<<curw);
//		res=max(res,dfs(a+1,ns));
//	}
//	// ツ置ツつッツづゥツづ按づァツ置ツつュ
//	if((curw==0||!((s>>(curw-1))&1))&&(curh==0||!((s>>(curw))&1))){
//		int ns=s;
//		ns|=(1<<curw);
//		res=max(res,dfs(a+1,ns)+field[curh][curw]);
//	}
//	return dp[a][s]=res;
//}

int main(){

	int t;
	cin>>t;
	int cnt=0;
	while(cnt<t){
		cnt++;
		cin>>w>>h;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>field[i][j];
		if(w>h){
			int tf[21][21];
			for(int i=0;i<h;i++)
				for(int j=0;j<w;j++)
					tf[w-1-j][i]=field[i][j];
			swap(h,w);
			for(int i=0;i<h;i++)
				for(int j=0;j<w;j++)
					field[i][j]=tf[i][j];
		}
		memset(dp,0,sizeof(dp));
		for(int i=h*w-1;i>=0;i--){
			for(int j=0;j<(1<<w);j++){
				int s=j;
				int nxt=i%2;
				int cur=(i+1)%2;
				int curh=i/w;
				int curw=i%w;
				dp[nxt][s]=0;
				// ツ置ツつゥツづ按つ「
				{
					int ns=s;
					ns&=~(1<<curw);
					dp[nxt][s]=max(dp[nxt][s],dp[cur][ns]);
				}
				// ツ置ツつッツづゥツづ按づァツ置ツつュ
				if((curw==0||!((s>>(curw-1))&1))&&(curh==0||!((s>>(curw))&1))){
					int ns=s;
					ns|=(1<<curw);
					dp[nxt][s]=max(dp[nxt][s],dp[cur][ns]+field[curh][curw]);
				}
			}
		}
		int res=dp[0][0];
		cout<<"Case "<<cnt<<": "<<res<<endl;
	}

	return 0;
}

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

const int mod = 1e9 + 7;
int N;

int main(){
  ios_base::sync_with_stdio(false); 
  cin >> N;
  int pd[N+1];
  memset(pd, 0, sizeof(pd));
  for(int i=2; i<=N; ++i)
    for(int j=2*i; j<=N; j+=i)
      pd[j] = 1;
  long long res = 1;
  for(int i=2; i<=N; ++i){
    if(!pd[i]){
      int d = 0;
      for(int j=i; j<=N; j*=i)
        d += N/j;
      res = (res%mod * (d+1)%mod)%mod; 
    }
  }
  cout << res << "\n";
  return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong n, h;
    cin >> n >> h;
    vector<pair<llong, llong> > V;
    llong max_a = -1;
    rep(i, n) {
        llong a, b;
        cin >> a >> b;
        max_a = max(max_a, a);
        V.push_back(make_pair(b, a));
    }

    sort(V.begin(), V.end(), greater<pair<llong, llong> >());

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (V[i].first >= max_a) {
            h -= V[i].first;
            ++ans;
        } else {
            break;
        }
        if (h <= 0) {
            cout << ans << endl;
          return 0;
        }
    }

    ans += ceil((ldouble)h / max_a);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    ll sum = 0;
    vector<int> v(n);
    rep(i,n) {
        cin >> v[i];
        sum += v[i];
    }
    vector<bool> can(n,false);
    can[0] = true;
    sort(RALL(v));
    sum -= v[0];
    REP(i,1,n) {
        if(sum*2>=v[i-1] && can[i-1]) {
            sum -= v[i];
            can[i] = true;
        }
    }
    int ans = 0;
    rep(i,n) {
        if(can[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

n = int(input())
a = [int(input()) for i in range(n)]
w = sum(a)
mod =998244353

dp = [[0]*(w+1) for i in range(n)]

cnt = a[0]
dp[0][a[0]] = 1
dp[0][0] = 2
for i in range(1,n):
    cnt += a[i]
    for j in range(cnt+1):
        dp[i][j] = dp[i-1][j]*2
        if j >= a[i]:
            dp[i][j] += dp[i-1][j-a[i]]
        
        dp[i][j] = dp[i][j]%mod

#sより大きいのはブー
s = w//2+1
if w %2 == 0:
    d = [[0]*(s+1) for i in range(n)]
    d[0][0] = 1
    d[0][a[0]] = 1
    cnt = a[0]

    for i in range(1,n):
        cnt += a[i]
        for j in range(min(cnt+1,s+1)):
            d[i][j] = d[i-1][j]
            if j >= a[i]:
                d[i][j] += d[i-1][j-a[i]]
            d[i][j] = d[i][j]%mod
    mns = d[-1][w//2]
if w%2 == 0:
    s -= 1
cnt = 0
for i in range(s,w+1):
    cnt += dp[-1][i]
    cnt = cnt%mod

res = (pow(3,n,mod)-cnt*3)%mod

if w % 2 == 0:
    res = (res+mns*3)%mod
print(res)


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

int main() {
  int N;
  cin >> N;
  
  int V[N], C[N];
  
  for (int i = 0; i < N; i++) cin >> V[i];
  for (int i = 0; i < N; i++) cin >> C[i];
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (V[i] - C[i] > 0) ans += V[i] - C[i];
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 256
def main():
    n = int(input())
    D = map(int, input().split())
    m = int(input())
    T = map(int, input().split())
    dic = dict()
    
    # 辞書はDだけで十分.Counterより速い.
    for d in D:
        if dic.get(d):
            dic[d] += 1
        else:
            dic[d] = 1
            
    for t in T:
        if t not in dic or dic[t] == 0:
            print('NO')
            return
        else:
            dic[t] -= 1
    print('YES')
main()

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

int main() {
  int h, w;
  cin >> h >> w;
  string a[h];
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  int right = 0, down = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (j < w - 1 && a[i][j] == '#' && a[i][j + 1] == '#') {
        right++;
      }
      if (i < h - 1 && a[i][j] == '#' && a[i + 1][j] == '#') {
        down++;
      }
    }
  }
  cout << (right == w - 1 && down == h - 1 ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
S=input()
n=len(S)
l=0
r=n-1
ans=0
while l+1<=r:
    if S[l]=='x' and S[l]!=S[r]:
        ans+=1
        l+=1
    elif S[r]=='x' and S[l]!=S[r]:
        ans+=1
        r-=1
    elif S[l]==S[r]:
        r-=1
        l+=1
    else:
        ans=-1
        break
print(ans)


Measured memory_bytes: 3316
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cmath>
using namespace std;


int main(){
	

	long long a,b,n;
	cin>>a>>b>>n;
	long long c1=a/b;
	long long d1=a%b;
	long long d2=min(n,b-1);
	long long ans=c1*d2+(d1*d2)/b;
	cout<<ans<<endl;
	return 0;
}


	


Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include <numeric>
using namespace std;
string c; string str;
int main() {
    cin >> str;
    c = "CODEFESTIVAL2016";
    int cnt=0;
    for(int i=0; i<16; ++i){
        if(str[i] != c[i]) cnt++;
    }
    cout << cnt << endl;
    
    //CODEFESTIVAL2016
}

Measured memory_bytes: 256
from collections import*
n=input();G=[[]for d in[deque([1,-1])]*-~n]
for C in[[0,1]+[0]*(n-2)+[2]]*~-n:a,b=map(int,raw_input().split());G[a]+=b,;G[b]+=a,
while d:
 v=d.popleft()
 for t in G[v]:
  if C[t]<1:C[t]=C[v];d+=t,
print["Fennec","Snuke"][2*C.count(1)<=n]

Measured memory_bytes: 21736
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;

const int maxn = 1000005;
int A[maxn], n;
ll pre[maxn], suf[maxn];

int main(){
	scanf("%d", &n);
	for(int i = 1;i <= n;++i){
		scanf("%d", &A[i]);
		pre[i] = pre[i - 1] + A[i];
	}
	for(int i = n;i > 0;--i){
		suf[i] = suf[i + 1] + A[i];
	}
	ll ans = 1e18;
	for(int i = 1;i < n;++i){
		ans = min(ans, abs(pre[i] - suf[i + 1]));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

ll ans;
int N;
ll c[5];

int main(void) {
    scanf("%d", &N);
    rep(i, 0, N) {
        char S[15];
        scanf("%s", S);
        if (S[0] == 'M') c[0]++;
        else if (S[0] == 'A') c[1]++;
        else if (S[0] == 'R') c[2]++;
        else if (S[0] == 'C') c[3]++;
        else if (S[0] == 'H') c[4]++;  
    }

    rep(i, 0, 5) {
        rep(j, i+1, 5) {
            rep(k, j+1, 5) {
                ans += c[i]*c[j]*c[k];
            }
        }
    }


   

  
    printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
res = 753
for i in range(n-2):
  t = s[i] + s[i+1] + s[i+2] 
  t = int(t)
  t = t - 753
  t = max(t, -t)
  res = min(res, t)
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;
 
int n,m,vis[N],dp[N];
vector<int> g[N],v;

void dfs(int node){
   vis[node] = 1;
   for(auto i : g[node]){
      if(!vis[i]){
         dfs(i);
      }
   }
   v.pb(node);
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   cin >> n >> m;
   int u,vv;
   f(i,0,m){
      cin >> u >> vv;
      g[u].pb(vv);
   }
   f(i,1,n+1){
      if(!vis[i]){
         dfs(i);
      }
   }
   int ans = 0;
   for(auto i : v){
      for(auto &j : g[i]){
         dp[i] = max(dp[i],dp[j]+1);
      }
      ans = max(ans,dp[i]);
   }

   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 10228
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  long k,a,b;
  cin>>k>>a>>b;

  if((b-a) <= 1){dbg(1);
    cout << k+1 << endl;
  } else {
    if(a >= k){dbg(2);
      cout << k+ 1 << endl;
    } else {dbg(3,(k-a+1));
      long ans = a + (b-a)*((k-a+1)/2);
      if((k-a+1)%2 == 1) ans++;
      cout << ans << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
int a,b,c,i,x;
scanf("%d %d %d",&a,&b,&c);
x =0;

for(i=a; i<=b; i++){
 if( c % i == 0){
x++;
}
}
printf("%d\n",x);

return 0;

}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_K 110
#define MAX_ROOT_N 80010

ll N, K;
ll dp[MAX_K][MAX_ROOT_N];
ll sum[MAX_K][MAX_ROOT_N];
vector< pair<ll, ll> > pat;     // N / j を求めたときに、現れるユニークな数と、その回数

// [lb, ub) の範囲で val 以下の要素で最大のもののインデックスを返す
// なければ -1 を返す
// 同じ数が複数ある場合は一番小さいインデックスを返す
static inline ll bin_search4(const vector< pair<ll, ll> >& v, ll lb, ll ub, ll val) {
    lb--; ub--;
    while(ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        if(v[mid].first >= val) { ub = mid; }
        else { lb = mid; }
    }
    // この時点で lb + 1 = ub
    if(v[ub].first <= val) { return ub; }
    if(lb < 0 || v[lb].first > val) { return -1; }
    return lb;
}

// i まで見ていて、現在の値が pat[j].first のときのパターン数
ll dfs(ll i, ll j) {
    if(i >= K) { return 1; }

    //assert(i >= 0 && j >= 0);
    //assert(i < MAX_K);
    //assert(j < MAX_ROOT_N);

    ll& ret = dp[i][j];
    if(~ret) { return ret; }
    ret = 0;

    j = pat[j].first;

    ll next_j = N / j;
    // next_j が、 pat のインデックスでいうとどこにあたるか
    ll next_j_ind = bin_search4(pat, 0, pat.size(), next_j);
    // [1, next_j_ind] の和が答え
    //assert(next_j_ind >= 0);
    assert(next_j_ind < MAX_ROOT_N);

    DBG("i: %lld j: %lld next_j: %lld next_j_ind: %lld\n", i, j, next_j, next_j_ind);

    if(~sum[i][next_j_ind]) { return sum[i][next_j_ind]; }
    //ll& sum_ret = sum[i][next_j_ind];
    //if(~sum_ret) { return sum_ret; }
    //sum_ret = 0;

    // sum でもし有効なところまで終わっているなら、そこから続きだけ計算する

    for(int k = 0; k <= next_j_ind; ++k) {
        sum[i][k] = (dfs(i+1, k) * pat[k].second) % MOD;
        if(k != 0) {
            sum[i][k] += sum[i][k-1];
            sum[i][k] %= MOD;
        }

        //sum_ret += (dfs(i+1, k) * pat[k].second) % MOD;
        //sum_ret %= MOD;
    }

    ret = sum[i][next_j_ind];
    return ret;
}
ll solve() {
    for(ll j = 1; j <= N; ++j) {
        ll next_j = N / j;
        ll cnt = (N % j) / next_j;
        pat.push_back(make_pair(j, cnt + 1));
        DBG("j: %lld next_j: %lld cnt: %lld\n", j, next_j, cnt+1);
        j += cnt;
    }

    //printf("pat.size(): %zu\n", pat.size());

    DBG("---\n");

    MINUS(dp);
    MINUS(sum);
    return dfs(0, 0);
}

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

    ll ans = solve();
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 138868
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	int N;

	scanf("%d", &N);

	vector<string> W;
	map<string, int> ww;

	rep(i, N) {
		string S;
		cin >> S;
		W.push_back(S);
		if (ww[S]) {
			printf("No\n");
			return 0;
		}
		ww[S]++;
	}

	rep(i, N - 1) {
		if (*(W[i].end() - 1) != *W[i + 1].begin()) {
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    string s,t;
    cin >> s >> t;
    bool flag2=false;
    for(int i=s.size()-t.size();i>=0;i--){
        bool flag=true;
        for(int j=0;j<t.size();j++){
            if(s[i+j]!=t[j]&&s[i+j]!='?') flag=false;
        }
        if(flag){
            s.replace(i,t.size(),t);
            flag2=true;
            break;
        }
    }
    
    if(flag2){
        for(int i=0;i<s.size();i++){
            if(s[i]=='?') s[i]='a';
        }
        cout << s << endl;
    }else{
        puts("UNRESTORABLE");
    }

    return 0;
}









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

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n; cin >> n;
  ll cur = 1;
  vector<ll> a(n);
  bool f = false;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    f |= a[i] == 0;
  }
  if (f) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < n; ++i) {
    ll x = a[i];
    if (cur <= 1000000000000000000LL / x) {
      cur *= x;
    }
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << cur << endl;

  
  return 0;
}




Measured memory_bytes: 3996
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
import numpy as np
#decimal.getcontext().prec = 10

N, M, Q = MAP()
LR = [LIST() for _ in range(M)]
pq = [LIST() for _ in range(Q)]

x = np.array([[0]*(N+1) for _ in range(N+1)])

for L, R in LR:
	x[L][R] += 1

x = x.cumsum(axis=0).cumsum(axis=1)

for p, q in pq:
	print(x[q][q] - x[q][p-1] - x[p-1][q] + x[p-1][p-1])




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

namespace id_1624cs
{
    public class Income
    {
        int[] _income;
        public Income(int[] income)
        {
            _income = income;
        }
        public int NumberOfLowIncome()
        {
            return _income.Where(x => x <= _income.Average()).Count();
        }

    }
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                var income = new Income(Console.ReadLine().Split(' ').Select(int.Parse).ToArray());
                Console.WriteLine(income.NumberOfLowIncome());
            }
        }
    }
}



Measured memory_bytes: 11152
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int N[4][3][10] = { {0}, {0}, {0} };
	int b, f, r, v;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		N[b - 1][f - 1][r - 1] += v;
	}
	for (b = 0; b < 4; b++) {
		for (f = 0; f < 3; f++) {
			for (int j = 0; j <10; j++) {
				cout << ' ' << N[b][f][j];
			}
			cout << endl;
		}

		if (b != 3) {
			cout << "####################" << endl;
		}

	}
		
	
 	return 0;
}




Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define max		  1000000
#define pb		  push_back
#define pairs	  pair<int, int>
#define vi		  vector<int>
#define vb		  vector<bool>
#define vii		  vector<pairs>
#define lb		  lower_bound
#define ub		  upper_bound
#define lli		  long long int
#define endl	  '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases	  cout << "Case " << ++Case << ": ";
#define __test    \
	int tt;       \
	int Case = 0; \
	cin >> tt;    \
	while (tt--)
#define read(x)	 freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a, n)        \
	for (int i = 0; i < n; i++) \
		cin >> a[i];
#define CopyArray(a, temp, n)   \
	for (int i = 0; i < n; i++) \
		temp[i] = a[i];
#define PrintArray(a, n)        \
	for (int i = 0; i < n; i++) \
		cout << a[i] << " ";    \
	cout << endl;

#define PI 3.14159265358979323846L
using namespace std;

int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif
	int a, b, c;
	cin >> a >> b >> c;

	cout << c << " " << a << " " << b << "\n";

	cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
const int MAX_V=100010;
vector <int> G[MAX_V];
vector<int> E[MAX_V];
int V;

int color[MAX_V];
//頂点を１と−１で塗る
bool dfs(int v,int c){
    color[v] = c;
    bool t=true;
    for(auto &to :E[v]){
        if(color[to]==0) dfs(to,c);
    }
    rep(i, 0, G[v].size()){
        //隣接している頂点が同じ色ならfalse
        if (color[G[v][i]] == c) t=false;
        //隣接している頂点がまだ塗られていないなら-cで塗る
        if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) t=false;
    }
    //すべて塗れたらtrue
    return t;
}

void solve() {
    rep(i, 0, V){
        if (color[i] == 0){
            if (!dfs(i,1)){
                printf("No\n");
                return;
            }
        }
    }
    printf("Yes\n");
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>V;
    rep(i,0,V-1){
        int u,v,w;
        cin>>u>>v>>w;
        u--; v--;
        if(w%2){
            G[u].pb(v); G[v].pb(u);
        }
        else{
            E[u].pb(v); E[v].pb(u);
        }
    }
    rep(i,0,V){
        if(color[i]==0) dfs(i,1);
    }
    rep(i,0,V){
        cout <<(color[i]+1)/2<<"\n";
    }
}

Measured memory_bytes: 13696
#include<stdio.h>
#include<stdlib.h>

int main(){
	int N;
	scanf("%d", &N);
	int *a;
	a = (int *)malloc(sizeof(int)*(N+1));
	int i, b;
	for(i = 0; i < N-1; i++){
		scanf("%d", &b);
		a[b]++;
	}
	for(i = 1; i <= N; i++){
		printf("%d\n", a[i]);
	}
	return 0;
}

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

int n;
int a[55][2];

void solve()
{
    if((n&1)) n = n-1;         //奇数化成偶数
    for(int i = 1;i <= n/2;i++)
    {
        a[i][0] = i;
        a[i][1] = n+1-i;
    }
    for(int i = 1;i <= n/2;i++)
        for(int j = 0;j < 2;j++)
            for(int k = i+1;k <= n/2;k++)
                for(int t = 0;t < 2;t++)
                    printf("%d %d\n", a[i][j], a[k][t]);
}

int main()
{
    scanf("%d", &n);
    int m = 2 * (n/2) * (n/2 - 1);
    if(n & 1)
    {
        printf("%d\n", m + n - 1);
        for(int i = 1;i < n;i++)  printf("%d %d\n", n, i);
        solve();
    }
    else
    {
        printf("%d\n", m);
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;
 
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif
  LL a, b, c, k;
  cin >> a >> b >> c >> k;
  LL ans = 0;
  ans += min(k, a);
  k -= min(k, a);
  k -= min(k, b);
  ans -= min(k, c);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
signed main(){
    int N, K, i, j, box, sum;
    scanf("%d %d", &N, &K);
    sum=0;
    
    int p[10030];
    
    for(i=0; i<N; i++){
    scanf("%d", &p[i]);
    }

                

    for(i=0; i<N; i++){
        for(j=0; j<N; j++){
            if(p[i] < p[j]){
               box = p[i];
              p[i] = p[j];
              p[j] = box;
            }
        }
    }
     for(i=0; i<K; i++){
      sum = sum+p[i];
     }       
        
        printf("%d\n", sum);
       
}

Measured memory_bytes: 1672