akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline vi32 plist(i32 n) { vi32 f(n, 1); f[0] = f[1] = 0; repi(i, 2, n) for (int j = i * 2; j < n; j += i) f[j] = 0; return f; }
inline bool isprime(i32 n) { if (n < 2) return 0; for (i32 i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; }
template<class T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<class T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<class T> inline bool amax(T &x, T y) { if (x >= y) return 0; x = y; return 1; }
template<class T> inline bool amin(T &x, T y) { if (x <= y) return 0; x = y; return 1; }
template<class T> inline i64 lbi(vector<T> &v, T e) { return lower_bound(all(v), e) - v.begin(); }
template<class T> inline i64 ubi(vector<T> &v, T e) { return upper_bound(all(v), e) - v.begin(); }
template<class T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }

int x[1010];
vector<int> children[1010];

int memo[1010];
int rec(int v) {
  if (memo[v] > 0) return memo[v];
  if (children[v].size() == 0) {
    return 0;
  }
  i32 sum = 0;
  vi32 dp(x[v] + 1, false);
  dp[0] = true;
  for (auto child : children[v]) {
    int r = rec(child);
    int l = x[child];
    if (r == -1) return -1;
    sum += r + l;
    rrep(i, x[v] + 1) {
      if (!dp[i]) continue;
      dp[i] = false;
      if (i + r <= x[v]) dp[i + r] = true;
      if (i + l <= x[v]) dp[i + l] = true;
    }
  }
  int idx = -1;
  rrep(i, x[v] + 1) {
    if (dp[i]) {
      idx = i;
      break;
    }
  }
  if (idx == -1) return -1;
  return memo[v] = sum - idx;
}

int main() {
  ioinit();
  int n;
  cin >> n;
  vi32 p(n);
  p[0] = -1;
  reps(i, n - 1) {
    cin >> p[i], p[i]--;
    children[p[i]].push_back(i);
  }
  rep(i, n) cin >> x[i];
  if (rec(0) != -1) {
    cout << "POSSIBLE" << '\n';
  } else {
    cout << "IMPOSSIBLE" << '\n';
  }
  return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n >> m;
  if (m == 1 || n == 1) {
    cout << "1\n";
    return;
  }
  int64 ans = ((n + 1) / 2 + n / 2) * 1ll * (m / 2);
  if (m & 1) {
    ans += (n + 1) / 2;
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 256
s=input()
sl=[]
ans=0
if len(s)==1:
  print(int(s))
else:
  for iii in range(2**(len(s)-1)):
    sind='{:0'+str(len(s)-1)+'b}'
    astr=sind.format(iii)
    astr=astr.replace("1","+")
    astr=astr.replace("0","x")
    lans=s[0]
    for jjj in range(len(astr)):
      lans+=astr[jjj]+s[jjj+1]
    lans=lans.replace("x","")
    ans+=int(eval(lans))
  print(ans)
      

Measured memory_bytes: 3064
/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
/// Macros
#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define ii pair<int,int>
#define fst first
#define scd second
#define vi vector<int>
#define vii vector<ii>
#define pb push_back
#define pf push_front
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///=====================================================================

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);

//    for(int i=1;i<=57;i++){
    int n;
//    n=i;
    cin>>n;
    string sol;

    sol+='a'-1+(n%26)+((n%26==0)?(26):(0));
    n-=26;

    if(sol[0]=='z'){
        n--;
    }
    int wr=26;
    while(n>0){
//        cout<<n<<" "<<wr<<" "<<(n/wr)%26<<fl;
        sol+='a'+((n/wr)%26);
        n-=wr*26;
        wr*=26;
    }


//    cout<<i<<" ";
    reverse(all(sol));
    cout<<sol<<fl;
//    }
return 0;}







Measured memory_bytes: 3560
module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let add a s =
  IntMap.add a (1 + try IntMap.find a s with Not_found -> 0) s
let remove a s =
  match IntMap.find a s with
  | exception Not_found -> s
  | 1 -> IntMap.remove a s
  | n -> IntMap.add a (n - 1) s

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d\n" @@ fun a -> a in
  Printf.printf "%d\n" @@
  IntMap.fold (fun _ -> ( + ))
    ( Array.fold_left (fun s a ->
        let l, _, _ = IntMap.split a s in
        if IntMap.is_empty l
        then add a s
        else add a @@ remove (fst (IntMap.max_binding l)) s) IntMap.empty as_ ) 0



Measured memory_bytes: 8192
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(s.charAt(s.length()-1)=='s'){
      System.out.println(s+"es");
    }
    else{
      System.out.println(s+"s");
    }
  }
}

Measured memory_bytes: 38412
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, t, a = in.next().toInt
  val tree = Array.fill[List[Int]](N+1)(Nil)
  for (_ <- 1 to N-1) {
    val A, B = in.next().toInt
    tree(A) = B :: tree(A)
    tree(B) = A :: tree(B)
  }

  //
  val fromA = Array.fill[Int](N+1)(-1)

  val q = new Queue[(Int, Int)] // (node, dist)
  q.enqueue((a, 0))

  while(!q.isEmpty) {
    val (now, dist) = q.dequeue()
    fromA(now) = dist
    for (e <- tree(now) if fromA(e) == -1) {
      q.enqueue((e, dist+1))
    }
  }

  // taka
  q.clear()
  var ans = fromA(t)

  val dp = new Array[Boolean](N+1)
  q.enqueue((t, 0))

  while(!q.isEmpty) {
    val (now, dist) = q.dequeue()

    if (!dp(now) && dist < fromA(now)) {
      dp(now) = true
      ans = Math.max(ans, fromA(now))
      for (e <- tree(now) if !dp(e)) {
        q.enqueue((e, dist+1))
      }
    }
  }

  println(ans - 1)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 65256
def main():
    S = input()
    if 1 <= int(S[:2]) <= 12 and 1 <= int(S[2:]) <= 12:
        print("AMBIGUOUS")
    elif 0 <= int(S[:2]) <= 99 and 1 <= int(S[2:]) <= 12:
        print("YYMM")
    elif   1 <= int(S[:2]) <= 12 and 0 <= int(S[2:]) <= 99 :
        print("MMYY")
    else:
        print("NA")
main()

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

int main(void){
	int ans = 0;
	int N, K; cin >> N >> K;
	vector<int> V(N);
	for(auto& _V: V) cin >> _V;

	for(int hold = 0; hold <= min(N, K); hold++){
		int return_num = K - hold;
		for(int left = 0; left <= hold; left++){
			int right = hold - left;
			vector<int> stones;
			for(int i = 0; i < left; i++){
				stones.push_back(V[i]);
			}
			for(int i = 0; i < right; i++){
				stones.push_back(V[N-1-i]);
			}
			sort(stones.begin(), stones.end());

			int begin_idx;
			for(begin_idx = 0; begin_idx < min(return_num, (int)stones.size()); begin_idx++){
				if(stones[begin_idx] >= 0) {
					break;
				}
			}

			int res = accumulate(stones.begin() + begin_idx, stones.end(), 0);
			ans = max(ans, res);
		}
	}

	cout << ans << endl;
}


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



int main() {
 int H,W;
  cin >> H >> W;
	vector<string> a(H);
  for(int i=0; i<H; i++){
    cin >> a.at(i);
  }
  for(int i = 0; i<W+2;i++)
  	cout << "#";
  cout << endl;
  for(int i=0; i<H; i++){
    cout << "#" << a.at(i) << "#" << endl;
  }
  for(int i = 0; i<W+2;i++)
  	cout << "#";
  cout<< endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize "Ofast,omit-frame-pointer,inline"
using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;

const int MAX = 2500000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

ll pow_mod(ll n, ll k, ll m) {
	ll r = 1;
	for (; k > 0; k >>= 1) {
		if (k & 1)r = (r*n) % m;
		n = (n*n) % m;
	}
	return r;
}//nのk乗をmで割った時のあまり


int main() {

	COMinit();

	/*
	ll sum = pow_mod(26, 8, mod);

	sum -= pow_mod(25, 8, mod);

	sum += mod;

	sum -= (8 * pow_mod(25, 7, mod)) % mod;
	sum += mod;

	sum -= (4*7 * pow_mod(25, 6, mod)) % mod;
	sum += mod;
	sum %= mod;
	*/

	ll k;
	string s;
	cin >> k >> s;
	ll n = s.size();

	ll sum = pow_mod(26, n + k, mod);

	REP(i, n) {
		sum -= (COM(n + k, i)*pow_mod(25, n + k - i, mod)) % mod;
		sum += mod;
		sum %= mod;
	}

	cout << sum << endl;

}

Measured memory_bytes: 63924
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (H, W) = Slice2<long>();
            var N = Sarray()[0];
            var Ai = Sarray();
            var masu = Enumerable.Repeat(0, (int)H).Select(_ => new long[W]).ToArray();
            var now = 0;
            for(int j=0;j<N;++j)
            {
                for (var i = 0; i < Ai[j]; ++i)
                {
                    masu[now / W][now % W] = j + 1;
                    ++now;
                }
            }
            for (var i = 1; i < H; i += 2)
                Array.Reverse(masu[i]);
            for (var i = 0; i < H; ++i)
                WriteLine(string.Join(" ", masu[i]));
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 29580
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_pack
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
string s,t;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>s>>t;
	cout<<t<<s;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<int>adj[1000001];
bool vis[1000001];
void dfs(int n)
{
    vis[n]=true;
    for(int a: adj[n])
    {
        if(vis[a]==0)
        dfs(a);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,e;
    cin>>n>>e;
    for(int i=0;i<e;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int ans=0;
    for(int i=0;i<=n;i++)
    vis[i]=0;
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0)
        {
            dfs(i);
            ans++;
        }
    }
    cout<<ans-1<<"\n";
    return 0;
    
}

Measured memory_bytes: 30780
#include<iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a;
	cin >> b;
	b = b - a;
	int sum = 0;
	for (int i = 0; i < b; i++) {
		sum = sum + i;
	}
	cout << sum - a;

	cin >> a;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static final int MAX = 1000000000;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ar[] = new int[n];
        for(int i = 0; i < n; i++) {
            ar[i] = sc.nextInt();
        }
        int dp[] = new int[n];
        Arrays.fill(dp, MAX);
        dp[n - 1] = 0;
        for(int i = n - 2; i >= 0; i--) {
            for(int k = 1; k <= 2; k++) {
                if(i + k < n) {
                    dp[i] = Math.min(dp[i], dp[i + k] + Math.abs(ar[i + k] - ar[i]));
                }
            }
        }
        System.out.println(dp[0]);
    }
}


Measured memory_bytes: 48908
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 110
#define mod 1000000007
#define ll long long
using namespace std;
ll f[2][N][N];
int num[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=2*n-1;i++) scanf("%d",&num[i]);
	sort(num+1,num+2*n);
	f[n&1][1][0]=1;
	for(int i=n-1;i;i--)
	{
		int u=i&1,pre=(i+1)&1;
		memset(f[u],0,sizeof(f[u]));
		for(int l=0;l<=2*n-1;l++)
			for(int r=0;r<=2*n-1-l;r++)
			if(f[pre][l][r])
			{
				int L=l+(num[i]!=num[i+1]),R=r+(num[2*n-i]!=num[2*n-i-1]);
				for(int p=1;p<=L;p++)
				if(p==1) f[u][L-p+1][R]=(f[u][L-p+1][R]+f[pre][l][r])%mod;
				else f[u][L-p+1][R+1]=(f[u][L-p+1][R+1]+f[pre][l][r])%mod;
				for(int p=1;p<=R;p++) f[u][L+1][R-p]=(f[u][L+1][R-p]+f[pre][l][r])%mod;
			}
	}
	ll ans=0;
	for(int l=0;l<=2*n-1;l++)
		for(int r=0;r<=2*n-1-l;r++) ans=(ans+f[1][l][r])%mod;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] arg) {
		int N = sc.nextInt();
		long c = 1;
		for (int i = 1;; ++i) {
			c *= 3;
			if (N <= c) {
				System.out.println(i);
				break;
			}
		}
	}

}

Measured memory_bytes: 17276
import java.io.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = Integer.parseInt(in.next());
            int A = Integer.parseInt(in.next());
            int B = Integer.parseInt(in.next());

            int sum = 0;
            for (int i = 1; i <= N; i++) {
                int n = i;
                int digSum = 0;
                while (n > 0) {
                    digSum += n % 10;
                    n /= 10;
                }
                if (digSum >= A && digSum <= B)
                    sum += i;
            }
            out.println(sum);
        }

    }
}



Measured memory_bytes: 35656
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 998244353LL;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<int> a(n), c(3);
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        a[i] = s[i] - '0';
    }
    for (int i = 0; i + 1 < n; i++) {
        a[i] = abs(a[i] - a[i + 1]);
        c[a[i]]++;
    }
    n--;
    if (!c[1] && c[2]) {
        for (int i = 0; i < n; i++) {
            a[i] = (a[i] > 0);
        }
    } else {
        for (int i = 0; i < n; i++) {
            a[i] = (a[i] % 2);
        }
    }
    V<ll> cnt(n + 1);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        int s = i;
        while (s % 2 == 0 && s > 0) {
            s /= 2;
            cnt[i]++;
        }
        sum += cnt[i];
    }
    int res = 0;
    ll sr = 0, snr = sum;
    for (int i = 0; i < n; i++) {
        sr += cnt[i];
        snr -= cnt[n - i];
        res += (sum - sr - snr == 0) * a[i];
        res %= 2LL;
        //   dump(sum, sr, snr);
    }
    if (!c[1] && c[2]) {
        if (res == 1) {
            cout << 2 << newl;
            return 0;
        }
    }
    cout << res << newl;
}

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

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

    int n;
    cin >> n;
    vector<pair<int, int>> as;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        as.emplace_back(a, b);
    }
    sort(as.begin(), as.end(), [](auto& a, auto& b) { return a.second < b.second; });
    int t = 0;
    for (int i = 0; i < n; i++) {
        t += as[i].first;
        if (t > as[i].second) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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


int main() {
    string day;
    cin >> day;

    vector<string> Day = {"SUN", "SAT", "FRI", "THU", "WED", "TUE", "MON"};

    for(int i = 0; i < 7; i++){
        if(Day.at(i) == day){
            if(i == 0){
                cout << 7 << endl;
            }
            else{
                cout << i << endl;
            }
        }
    }

    return 0;
}

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

int n, v;
int x[100][100], y[100][100], a[100], p[100];
int maxn;

int check() {
	for(int i = 1; i <= n; i++) {//i表示现在枚举到哪个人 
		if(!p[i]) continue;
		for(int j = 1; j <= a[i]; j++) {//j表示这个人说的每句话 (这个人每句话都是实话) 
			if(y[i][x[i][j]] != p[x[i][j]]) return 0;//y[i][x[i][j]]表示第i个人认为第x[i][j]个人的状态 //如果发现他有一句不是实话，则矛盾 
		}
	}
	return 1;
}

int dfs(int now, int current) {
	if(now == n + 1) {
		if(check()) {
			maxn = max(maxn, current);
		}
		return 0;
	}
	for(int l = 1; l >= 0; l--) {
		p[now] = l;
		dfs(now + 1, current + p[now]);
	}
	return 0;
}

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		for(int j = 1; j <= a[i]; j++) {
			cin >> x[i][j];
			cin >> y[i][x[i][j]]; 
		}
	}
	dfs(1, 0);
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    ll s;
    cin >> s;
    ll ax, ay, bx, by;
    ax = ay = bx = by = 0;
    while (s - ax * by > 0)
    {
        if (ax > by)
        {
            by++;
        }
        else
        {
            ax++;
        }
    }
    ay = 1;
    bx = -(s - ax * by);
    assert(ax <= 1e9);
    assert(ay <= 1e9);
    assert(bx <= 1e9);
    assert(by <= 1e9);
    //assert(cx <= 1e18);
    //assert(cy <= 1e18);
    cout << "0 0 " << ax << " " << ay << " " << bx << " " << by << endl;
    ;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
#import math
# from itertools import product, accumulate, combinations, product
#import bisect
# import numpy as np
# from copy import deepcopy
from collections import deque
# from decimal import Decimal
# from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 998244353


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())

def run():
     K = intread()
     print('ACL' * K)

if __name__ == "__main__":
    run()


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

G = [[] * N for _ in range(N)]
for _ in range(N - 1):
  a, b, c = map(int, input().split())
  G[a - 1].append((b - 1, c))
  G[b - 1].append((a - 1, c))

Q, K = map(int, input().split())

D = [-1] * N
s = [(K - 1, 0)]
while s:
  v, c = s.pop()
  D[v] = c
  for vv, cc in G[v]:
    if D[vv] < 0:
      s.append((vv, cc + c))

for _ in range(Q):
  x, y = map(int, input().split())
  print(D[x - 1] + D[y - 1])

Measured memory_bytes: 46124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll N;
    cin>>N;
    ll H[N+1];
    rep(0,i,N)cin>>H[i+1];
    ll ans=0,INF=1e9,x=0;
    H[0]=INF;
    rep(1,i,N){
        if(H[i]>=H[i+1])++x;
        else{
            ans=max(x,ans);
            x=0;
        }
    }
    ans=max(x,ans);
    cout<<ans<<endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int a,b,c,d;

signed main() {
    cin >> a >> b >> c >> d;
    int hoge = (a+c-1)/c*c, huga = (a+d-1)/d*d;
    int hogehoge = b/c*c, hugahuga = b/d*d;
    int sum = (hogehoge-hoge)/c + (hugahuga-huga)/d + 2;
    int aa = c*d/__gcd(c,d);
    int piyo = (a+aa-1)/aa*aa;
    int piyopiyo = b/aa*aa;
    int sumsum = max(0LL,(piyopiyo-piyo)/aa + 1);
    cout << b-a+1-sum+sumsum << endl;

}






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

int main() {
    int n, l;
    cin >> n >> l;
    int min = INT32_MAX;
    int flavor = 0;
    for (int i = 1; i <= n; ++i) {
        if (abs(i + l - 1) < abs(min)) {
            min = i + l - 1;
        }
        flavor += i + l - 1;
    }
    flavor -= min;
    cout << flavor << '\n';
}

Measured memory_bytes: 3536
#include <stdio.h>
int main()
{
 int lineup[100];
 int M=0;
 int N=0;
 int i=0;
 int j=0;
 int k=0;
 int add=0;
  
 scanf("%d %d",&N,&M);
  for(i=0;i<N;i++)
  {
    scanf("%d",&lineup[i]);
    add+=lineup[i];
  }
  for(j=0;j<N;j++){
    if(lineup[j]*4*M>=add){
      k++;
    }
  }
          if(k>=M){
            printf("Yes");
          }
          else{
            printf("No");
          }
          return 0;
          }
     

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

int main() {
	int n,a=0,b=0;
	cin >> n;
	set<int> ary;

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

	cout << ary.size() << endl;


}

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

int main(){
  vector<int> S(4);
  for(int i=0;i<4;i++){
    cin >> S[i];
  }
  sort(S.begin(),S.end());
  if(S.size()==4 && S[0]==1 && S[1]==4 && S[2]==7 && S[3]==9){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <immintrin.h>
#include <omp.h>

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x)(x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
  ll n;
  cin >> n;
  vector<ll> d(n);
  rep(i, n) cin >> d[i];
  ll mod = 998244353;


  if(d[0] != 0){
    cout << 0 << endl;
    return 0;
  }
  rep(i, n){
    if(i == 0) continue;
    if(d[i] == 0){
    cout << 0 << endl;
    return 0;
  }
  }

  vector<ll> memo(n+5, 0);
  rep(i, n) memo[d[i]]++;
  memo[0] = 1;

  ll res = 1;
  rep1(i, n){
    rep(t, memo[i]) res *= memo[i-1], res %= mod;
  }

  cout << res << endl;



  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
#define mpp(t1, t2, t3, t4) mp(mp(t1, t2), mp(t3, t4))

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

int dp[3005][3005];

int main() {
	int n, t, s;
	cin >> n >> t >> s;

	vector<P> v(n);
	rep(i, n) {
		cin >> v[i].first >> v[i].second;
	}

	memset(dp, 0, sizeof(dp));

	REP(i, 0, n) {
		rep(j, t + 1) {
			if(j - v[i].second < 0) {
				dp[i+1][j] = dp[i][j];
			} else {
				if(j - v[i].second < s && s < j) {
					dp[i+1][j] = dp[i][j];
				} else {
					dp[i+1][j] = max(dp[i][j], dp[i][j-v[i].second] + v[i].first);
				}
			}
		}
	}

	int ans = 0;
	rep(i, n + 1 ) {
		rep(j, t + 1) {
			ans = max(ans, dp[i][j]);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 36496
n, a, b = map(int, input().split())
mod = 10**9 + 7

ans = pow(2, n, mod)-1
product = 1
div = 1

# 全く分からん
for i in range(1, b+1):
    product = product * (n-i+1) % mod
    div = div*i % mod
    if i == a or i == b:
        ans -= product * pow(div, mod-2, mod)

print(ans % mod)


Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
int n,a,i,ii,y,s[2048];
scanf("%d",&n);
for(i=1;i<=n;i++){
    scanf("%d",&a);
    s[i] = a;
}
for(i=0;i<=9;i++){
    y=0;
    for(ii=1;ii<=n;ii++){ 
        if(s[ii]==i){
            y=1;
            break;
        }
    }
    if(y==0){
        printf("%d\n",i);
        return 0;
    }
}
for(i=10;i<=99;i++){
    y=0;
    for(ii=1;ii<=n-1;ii++){ 
        if(s[ii]==i/10 &&s[ii+1]==i%10){
            y=1;
            break;
        }
    }
    if(y==0){
        printf("%d\n",i);
        return 0;
    }
}
for(i=100;i<=999;i++){
    y=0;
    for(ii=1;ii<=n-2;ii++){ 
        if(s[ii]==i/100 &&s[ii+1]==(i/10)%10 &&s[ii+2]==i%10){
            y=1;
            break;
        }
    }
    if(y==0){
        printf("%d\n",i);
        return 0;
    }
}
return 0;
}

Measured memory_bytes: 608
#include<cstdio>
#include<iostream>
using namespace std;
int f[4][4];
int main()
{
    int a,b,c;
    scanf("%d%d%d",&f[1][1],&f[1][2],&f[2][2]);//先把位置都放好
    a=f[2][2]*3;//a记录行，列，斜线的和。我们知道，这种3*3的方格填数每一行，每一列，每一斜线的和都等于中间数的3倍
    f[1][3]=a-f[1][1]-f[1][2];
    f[3][1]=a-f[1][3]-f[2][2];
    f[3][3]=a-f[1][1]-f[2][2];
    f[2][1]=a-f[1][1]-f[3][1];
    f[2][3]=a-f[2][1]-f[2][2];
    f[3][2]=a-f[1][2]-f[2][2];//这一大段是计算，顺序很重要
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
        {
            printf("%d ",f[i][j]);//矩阵输出
        }
        printf("\n");
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    int A, B, K;
    cin >> A >> B >> K;

    if (B - A < K) {
        FOR(i, A, B + 1) cout << i << '\n';
        return 0;
    }

    FOR(i, A, A + K) cout << i << '\n';

    if (A + K <= B - K + 1) {
        FOR(i, B - K + 1, B + 1) cout << i << '\n';
    } else {
        FOR(i, A + K, B + 1) cout << i << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

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

	vector<long long> a(n, 0LL);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	long long ans = 0;
	while (1) {
		sort(a.begin(), a.end(), greater<long long>());
		if (a[0] < n) {
			break;
		}

		long long ops = a[0] / n;
		a[0] %= n;
		ans += ops;

		for (int i = 1; i < n; i++) {
			a[i] += ops;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[810];
int b[810];
signed main(){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int l=0;l<m;l++){
        cin>>b[l];
    }
    sort(a,a+n);
    sort(b,b+m);
    for(int j=x+1;j<y+1;j++){
        if(j>a[n-1]&&j<=b[0]){
            cout<<"No War"<<endl;
            return 0;
        }
    }
    cout<<"War"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int64)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}


int main(){
	//in_o();
	int w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<0.5*w*h<<" "<<(x*2==w && y*2==h)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {
	ll K, X;
	cin >> K >> X;

	for (ll i = -1000000; i < 1000001; i++) {
		if (abs(i - X) < K) cout << i << " ";
	}

}

int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
l = sorted(map(int, input().split()))
ans = 0
# print(l)
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            # print(i, j, k)
            if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                if l[i]+l[j] > l[k]:
                    ans += 1

print(ans)


Measured memory_bytes: 9120
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
#import queue
from copy import copy, deepcopy
from operator import itemgetter

import bisect#2分探索
#bisect_left(l,x), bisect(l,x)
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#q=heapq.heapify(l),heappush(q,a),heappop(q)

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s): return sorted(range(len(s)), key=lambda k: s[k])

#mod = 10**9+7

#N = int(input())
N, P = map(int, input().split())
S=input()
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [inputl() for i in range(H)]
#q = queue.Queue() #q.put(i) #q.get() 
#q = queue.LifoQueue() #q.put(i) #q.get() 

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b=copy.deepcopy(a)  #2次元配列はこうコピーする
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#素数リスト
# n = 100
# primes = set(range(2, n+1))
# for i in range(2, int(n**0.5+1)):
#     primes.difference_update(range(i*2, n+1, i))
# primes=list(primes)

#bisect.bisect_left(a, 4)#aはソート済みである必要あり。aの中から4未満の位置を返す。rightだと以下
#bisect.insort_left(a, 4)#挿入
if P!=2 and P!=5:
    pc=[0]*P
    pc[0]=1
    count=0
    ans=0
    p10=1
    for i in range(1,N+1):
        count+=int(S[N-i])*p10
        count%=P
        ans+=pc[count]
        pc[count]+=1
        p10*=10
        p10%=P

    print(ans)
else:
    ans=0
    for i in range(1,N+1):
        if int(S[N-i])%P==0:
            ans+=N-i+1
    print(ans)


Measured memory_bytes: 41308
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



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

    int n, K;
    cin >> n >> K;
    vector<int> T(n);
    vector<int> D(n);
    for (int i = 0; i < n; ++i) {
        cin >> T[i] >> D[i];
        --T[i];
    }

    vector<int> maxs(n, 0);
    vector<int> cnts(n, 0);

    for (int i = 0; i < n; ++i) {
        maxs[T[i]] = max(maxs[T[i]], D[i]);
    }

    vector<int> ord(n, 0);
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(), [&](int l, int r) { return D[l] > D[r]; });

    long long res = 0;

    long long ans = 0;
    int cnt = 0;
    for (int i = 0; i < K; ++i) {
        ans += D[ord[i]];
        if (cnts[T[ord[i]]]++ == 0) {
            ++cnt;
        }
    }
    res = max(res, ans + cnt * 1LL * cnt);

    vector<int> M;
    for (int i = 0; i < n; ++i) {
        if (cnts[i] == 0 && maxs[i] > 0) {
            M.push_back(maxs[i]);
        }
    }
    sort(M.begin(), M.end(), greater<int>());

    for (int i = K - 1, j = 0; i >= 0 && j < M.size(); --i) {
        if (--cnts[T[ord[i]]] > 0) {
            cnt += 1;
            ans -= D[ord[i]];
            ans += M[j++];
            res = max(res, ans + cnt * 1LL * cnt);
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 2560
using System;

namespace ITP
{
    class ITP_1_1_B
    {
        static void Main(string[] args)
        {
            while (true) {
                string line = Console.ReadLine();

                if (line == null) {
                    break;
                }

                int num = int.Parse(line);
                Console.WriteLine((int)Math.Pow(num, 3));
            }
        }
    }
}

Measured memory_bytes: 9324
Ns,Ms=input().split()
N=int(Ns)
M=int(Ms)
lists=[]
ansmins,ansmaxs=input().split()
ansmin=int(ansmins)
ansmax=int(ansmaxs)
for i in range(M-1):
	tmpmin,tmpmax=input().split()
	if int(tmpmin)>ansmin:
		ansmin=int(tmpmin)
	if int(tmpmax)<ansmax:
		ansmax=int(tmpmax)

if (ansmax-ansmin+1)<0:
	ans=0
else:
	ans=ansmax-ansmin+1
print(ans)


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

using namespace std;

int n,cont;
string str;

int main(){
    cin >> n >> str;
    for(int i=0;i<n-2;i++){
        if(str[i] == 'A' && str[i+1] == 'B' && str[i+2] == 'C') cont++;
    }

    cout << cont << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)         cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)      cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)   cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 1000000000000000000;
const int N = 300000 , mod = 1000000007;
double eps = 1e-9;
int main()
{
    fastio;
    ll a;
    double b;
    cin>>a>>b;
    b = b*100;
    int n;
    for(int i=0;i<=1000;i++)
    {
        if(abs(i-b)<=eps)
        {
            n = i;
            break;
        }
    }
    ll ans = 1LL*a*n;
    ans/=100;
    cout<<ans<<endl;
    return 0;
}

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


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

	vector<string> v[15];
	v[1].push_back("a");
	for(int i=2;i<=10;i++){
		for(int j=0;j<v[i-1].size();j++){
			string s=v[i-1][j];
			bool f[30]={};
			ll cnt=0;
			for(int k=0;k<s.size();k++){
				ll x=s[k]-'a';
				f[x]=1;
			}
			for(int k=0;k<26;k++)if(f[k])cnt++;
			for(int k=0;k<=cnt;k++){
				char c='a'+k;
				string yan=s+c;
				v[i].push_back(yan);
			}
		}
	}
	for(int i=0;i<v[n].size();i++)cout<<v[n][i]<<endl;
	return 0;
}


Measured memory_bytes: 11380
#include<bits/stdc++.h>
using namespace std;
long long int dp[100001];
int h[100001];

int solve(int n){
      if(dp[n]!=-1)return dp[n];
      dp[n]=min(solve(n-1)+abs(h[n]-h[n-1]), solve(n-2)+abs(h[n]-h[n-2]));
      //cout<<n<<' '<<dp[n]<<'\n';
      return dp[n];
}

int main(){
      int n;
      cin>>n;
      for(int i=0; i<n; i++){
            cin>>h[i];
            dp[i]=-1;
      }
      dp[0]=0;
      dp[1]=abs(h[1]-h[0]);
      cout<<solve(n-1);
}

Measured memory_bytes: 7104
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	int w, a, b;
	cin >> w >> a >> b;
	if (b + w < a || a + w < b)
		cout << min(abs(b - (a + w)), abs(a - (b + w))) << endl;
	else
		cout << 0 << endl;

	return 0;
}




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

int ans;
int a,b,ab;

signed main(){

  int n; cin >> n;
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    for(int j = 0; j < (int)s.size()-1; j++){
      if(s[j] == 'A' && s[j+1] == 'B') ans++;
    }
    if(s[0] == 'B') b++;
    if(s[(int)s.size()-1] == 'A') a++;
    if(s[0] == 'B' && s[s.size()-1] == 'A') ab++;
  }

  ans += min(a,b);
  if(ab*2 == a+b && ab > 0) ans--;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict as dd
N, K = map(int, input().split())
A = list(map(int, input().split()))
S = [0]*(N+1)
# 累積和
for i in range(1, N + 1):
    S[i] = S[i - 1] + A[i - 1] - 1
    S[i] %= K
        
B = dd(int)  # ここで範囲内のS[i]-iの個数を数えていく。
cnt = 0
for j in range(1, N + 1):
    B[S[j - 1]] += 1
    if j - K >= 0:
        B[S[j - K]] -= 1
    cnt += B[S[j]]

print(cnt)

Measured memory_bytes: 111564
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

ll INF = LONG_LONG_MAX / 2;

int main(void) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = -INF;
    chmax(ans, a * c);
    chmax(ans, a * d);
    chmax(ans, b * c);
    chmax(ans, b * d);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3572
X, K, D = map(int, input().split())

if abs(X) >= K * D:
    print(abs(X) - (K * D))
else:
    k = abs(X) // D
    Y = abs(X) % D
    if (K - k) % 2 == 0:
        print(Y)
    else:
        print(abs(Y - D))


Measured memory_bytes: 9204