akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int n;
vector<ll> a(100010,0);
int main(){
    cin>>n;
    int negC=0;
    ll m=INF,sum=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]<=0){
            negC++;
        }
        sum+=abs(a[i]);
        m=min(m,abs(a[i]));
    }
    if((negC%2)==0){
        cout<<sum<<endl;
    }
    else{
        cout<<sum-2*m<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L[i];
  
  int ans = 0;
  rep(i, N) rep(j, N) rep(k, N) {
    if(i == j || j == k || k == i || L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
    if(abs(L[i]-L[j]) < L[k] && L[k] < L[i]+L[j]) ans++;
  }
  cout << ans / 6 << endl;

}


Measured memory_bytes: 3632
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
ll Y;
int main() {
	cin>>N>>Y;

	for(int i=0;i<N+1&&10000*i<=Y;i++){
		for(int j=0;i+j<N+1&&i*10000+j*5000<=Y;j++){
			for(int k=0;i+j+k<N+1&&i*10000+j*5000+k*1000<=Y;k++){
				if(N==i+j+k){
					if(i*10000+j*5000+k*1000==Y){
						cout<<i<<" "<<j<<" "<<k<<endl;
						return 0;
					}
				}
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;

	return 0;
}


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

int main() {
	ll ans=0,n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll z;
		cin>>z;
		while(z%2==0){
			ans++;
			z/=2;
		}
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

typedef pair<int, pair<int, int>> pi;

class Solver {
public:
	static void solve() {
		int l;
		cin >> l;
		int n;
		cin >> n;

		int xys[50][2];
		for (int i = 0; i < n; i++) {
			cin >> xys[i][0] >> xys[i][1];
		}

		cout << n << endl;
		for (int i = 0; i < n; i++) {
			cout << -xys[i][0] << " " << xys[i][1] << endl;
		}
	}
};

int main() {
	Solver::solve();
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int64_t a, b, ans;
    cin >> a >> b;
    if(a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
    } else if(0 < a || (b < 0 && (b - a + 1) % 2 == 0)) {
        cout << "Positive" << endl;
    } else if(b < 0 && (b - a + 1) % 2 == 1) {
        cout << "Negative" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.lang.Math

val MOD: Int = 1000000000 + 7
val MODL: Long = MOD.toLong()

fun main(args: Array<String>)
{
    val n = read().toLong()

    if (n % 2L == 1L) {
        println(0)
        return
    }

    val ans = f(n / 10L)
    println(ans)
}

fun f(n: Long): Long {
    val q = n / 5L
    if (q == 0L) {
        return n
    }

    return n + f(q)
}

fun read(): String = readLine()!!


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

typedef long long ll;
ll W,H,N;

typedef vector<ll> Vec;
typedef vector<Vec> Mat;
const ll MOD = 1000000009;

void add( ll &a, ll b ){
  a+=b;
  a%=MOD;
}

void view( const Mat& a ){
  cout << "view"<<endl;
  for(int i=0;i<a.size();i++ ){
    for(int j=0;j<a[i].size();j++) cout << a[i][j] << " ";
    cout << endl;
  }
}

Mat mult( const Mat& a, const Mat& b ){
  Mat res=Mat(a.size(), Vec(b[0].size(),0) );
  for(int i=0;i<(int)res.size();i++){
    for(int j=0;j<(int)res[i].size();j++){
      for(int k=0;k<(int)a[0].size();k++){
        add( res[i][j], (a[i][k] * b[k][j])%MOD );
      }
    }
  }
  return res;
}

// a * b^k
Mat pow_m( const Mat &a,const Mat& b,ll k ){
  Mat res = a;
  Mat x = b;
  while( k ){    
    if( k & 1 ){
      res = mult( res, x );
    }    
    x = mult( x, x );
    k>>=1;
  }
  return res;
}

ll X[100],Y[100];
ll fie[400];

Mat get_mat(int y){
  Mat ret=Mat(W,Vec(W,0));
  for(int j=0;j<W;j++)
    for(int i=max(0,j-1);i<min(j+2,(int)W);i++)
      ret[i][j] = 1;  
  if( y == -1 ) return ret;
  for(int i=0;i<N;i++){
    if( (int)Y[i] == y ){
      for(int j=0;j<W;j++)
        ret[j][X[i]]=0;
    }
  }
  return ret;
}

Mat solve(int h){
  Mat res = Mat(1,Vec(W,0));
  res[0][0] = 1;
  ll now_y=1;
  for(int i=0;i<h;i++){
    if( fie[i] <= 1 ) continue;    
    ll t=fie[i]-now_y;
    Mat next = get_mat( i );
    res = pow_m( res, next, t );
    now_y = fie[i];
  }
  return res;
}


int zatu(){
  vector<ll> v;
  v.push_back(1);
  v.push_back(H);
  for(int i=0;i<N;i++)
    for(int j=-1;j<1;j++)
      v.push_back( Y[i]+j );
  sort(v.begin(),v.end());
  v.erase( unique( v.begin(), v.end() ), v.end() );
  for(int i=0;i<(int)v.size();i++)
    fie[i] = v[i];    
  for(int i=0;i<N;i++)
    Y[i] = lower_bound( v.begin(), v.end() , Y[i] ) - v.begin();
  return v.size();
}


int main(){
  while( cin >> W >> H >> N && (W||H||N) ) {
    static int ttt=1;
    cout << "Case " << ttt++ << ": ";
    bool f = false;
    for(int i=0;i<N;i++){
      cin >> X[i] >> Y[i]; --X[i];
      if( X[i] == 0 && Y[i] == 1 ) f = true;
    }
    if( f ){
      cout << 0 << endl; break;
    }
    int h = zatu();
    Mat ans = solve( h );
    cout << ans[0][W-1] << endl;
  }  
}

Measured memory_bytes: 1364
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <map>
 
using namespace std;

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

    int a, b, c, d, e, k;
    
    cin >> a >> b >> c >> d >> e >> k;

    int max = a, min = a;

    if(b > max) {
        max = b;
    }

    if(b < min) {
        min = b;
    }

    if(c > max) {
        max = c;
    }

    if(c < min) {
        min = c;
    }

    if(d > max) {
        max = d;
    }

    if(d < min) {
        min = d;
    }

    if(e > max) {
        max = e;
    }

    if(e < min) {
        min = e;
    }

    if(max - min > k) { 
        cout << ":(";
    } else {
        cout << "Yay!";
    }
}

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

void swap(int &a,int &b){
    int c = a ;
    a = b ; b = c ;
}

int main(){
    int n ; cin >> n ; 
    vector<int> p(n) ;
    int ans = 0 ;
    for(int i=0;i<n;i++) cin >> p.at(i) ;
    for(int i=0;i<n-1;i++){
        if(p.at(i)==i+1){ 
            swap(p.at(i),p.at(i+1)) ;
            ans++ ;
        }
    }
    if(p.at(n-1)==n) ans++ ;
    cout << ans << endl ;
}

Measured memory_bytes: 640
// Binary_Search_Tree_I.cs

using System;
using System.Collections.Generic;

class Node {

	public int key { get; set; }
	public int? left { get; set; }
	public int? right { get; set; }

	public Node(int nk) {
		key = nk;
		left = right = null;
	}

	public Node(int nk, int l, int r) {
		key = nk;
		left = l;
		right = r;
	}
}

class Binary_Search_Tree_I {
	public static void Main() {

		var b = new Binary_Tree();

		int n = int.Parse(Console.ReadLine());
		for(int i = 0; i < n; i++) {
			string[] str = Console.ReadLine().Split(' ');
/*
			foreach(string s in str) {
				Console.WriteLine(s);
			}
*/
			if(str[0] == "print") {
				b.show();
			} else {
				b.Add_Node(int.Parse(str[1]));
			}
		}
	}
}

class Binary_Tree {

	List<Node> nodes;

	public Binary_Tree() {
		nodes = new List<Node>();
	}

	public void Add_Node(int k) {

		if(nodes.Count == 0) {
		nodes.Add(new Node(k));
		} else {
			nodes.Add(new Node(k));
			search_parent(nodes[0], k);
		}
	}

	void search_parent(Node node, int k) {

		if(node.left == null && node.key > k) {
			node.left = nodes.Count - 1;
			return;
		} else if(node.right == null && node.key < k) {
			node.right = nodes.Count - 1;
		//	Console.WriteLine(nodes.Count);
			return;
		}

		if(node.key > k) {
			search_parent(nodes[(int)node.left], k);
		} else {
			search_parent(nodes[(int)node.right], k);
		}
	}

	void inorder_walk(Node node) {

		if(node.left != null) {
			inorder_walk(nodes[(int)node.left]);
		}

		Console.Write(" {0}", node.key);

		if(node.right != null) {
			inorder_walk(nodes[(int)node.right]);
		}
	}

	void preoder_walk(Node node) {

		Console.Write(" {0}", node.key);

		if(node.left != null) {
			preoder_walk(nodes[(int)node.left]);
		}

		if(node.right != null) {
			preoder_walk(nodes[(int)node.right]);
		}
	}

	public void show() {
		inorder_walk(nodes[0]);
		Console.WriteLine();
		preoder_walk(nodes[0]);
		Console.WriteLine();
	}

}

Measured memory_bytes: 48352
#include <bits/stdc++.h>
using namespace std;
string s;
int n, k, dp[200][5];

int ways(int n, int r) {
  if (n < r)  return 0;
  int ret = 1, m = 1;
  for (int i = 0; i < r; ++i) {
    ret *= n-i;
    ret /= i+1;
    m *= 9;
  }
  return ret * m;
}

int solve(int x, int rem) {
  if (rem == 0) return 1;
  if (x == n) return 0;
  int &ret = dp[x][rem];
  if (ret != -1)  return ret;
  ret = 0;

  int d = s[x] - '0';
  if (d) ret += ways(n-x-1, rem); 
  for (int i = 1; i < d; ++i)
    ret += ways(n-x-1, rem-1);
  if (d) ret += solve(x+1, rem-1);
  if (!d) ret += solve(x+1, rem);

  return ret;
}

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  memset(dp, -1, sizeof dp);

  cin >> s >> k;
  n = (int)s.size();
  cout << solve(0, k) << '\n';
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seq = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var multiples = new HashSet<int>[seq.Length + 1];
        for (int i = 1; i < multiples.Length; i++)
        {
            var xs = E.Range(1, seq.Length).Select(x => x * i).TakeWhile(x => x < multiples.Length);
            multiples[i] = new HashSet<int>(xs);
        }

        var bs = new int[seq.Length];
        var contains = new List<int>();
        for (int i = seq.Length - 1; i >= 0; i--)
        {
            bs[i] = multiples[i + 1].Sum(x => bs[x - 1]) & 1 ^ seq[i];
            if (bs[i] != 0)
            {
                contains.Add(i + 1);
            }
        }
        Console.WriteLine(contains.Count);
        if (!contains.Any())
        {
            return;
        }
        Console.WriteLine(string.Join(" ", contains));
    }
}


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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
bool prime[1400000];
vector<int> primev;
int main(void)
{
  REP(i,1400000) prime[i]=true;
  prime[0]=false;
  prime[1]=false;
  REP(i,sqrt(1400000)+1) if(prime[i]) for(int j=i*i;j<1400000;j+=i) prime[j]=false;
  REP(i,1400000) if(prime[i]) primev.PB(i);
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    if(n<=2) cout << 0 << endl;
    else cout << *(lower_bound(primev.begin(),primev.end(),n))-*(upper_bound(primev.begin(),primev.end(),n)-1) << endl;
  }
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9+7;
const double PI = 3.14159265359;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	double r ;
	cin>>r;
	cout<<2*PI*r;
	
	
	
	return 0;
}
































Measured memory_bytes: 3808
N = int(input())
A = list(map(int, input().split()))
d = {}
for a in A:
    d[a-1] = d.setdefault(a-1,0) + 1
    d[a] = d.setdefault(a,0) + 1
    d[a+1] = d.setdefault(a+1,0) + 1
print(max(d.values()))

Measured memory_bytes: 18756
use proconio::input;

const M: u64 = 1000_000_007;

fn main() {
    input! { n: usize }

    let mut a = vec![0; n];
    for i in 0..n {
        for j in 0..n {
            input! { aij: usize };
            a[i] |= aij << j;
        }
    }

    println!("{}", DP::new(n, &a).calc(0));
}

struct DP<'a> {
    dp: Vec<Option<u64>>,
    b: usize,
    a: &'a Vec<usize>,
}

impl<'a> DP<'a> {
    fn new(n: usize, a: &'a Vec<usize>) -> DP<'a> {
        let mut b = 0;
        for i in 0..n {
            b |= 1 << i;
        }
        DP {
            dp: vec![None; 1 << n],
            b: b,
            a: a,
        }
    }

    fn calc(&mut self, p: usize) -> u64 {
        if let Some(v) = self.dp[p] {
            v
        } else {
            let v = if p == self.b {
                1
            } else {
                let rest = self.a[p.count_ones() as usize] & !p;
                let mut v = 0;
                let mut b = 1;
                while self.b & b != 0 {
                    if rest & b == b {
                        v = (v + self.calc(p | b)) % M;
                    }
                    b <<= 1;
                }
                v
            };
            self.dp[p] = Some(v);
            v
        }
    }
}


Measured memory_bytes: 34728
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

auto gcd(size_t l, size_t r) {
    if (r == 0)
        return l;
    return gcd(r, l % r);
}

auto gcd(size_t a, size_t b, size_t c) {
    return gcd(a, gcd(b, c));
}

int main() {
    string s = input();
    string t = input();
    if (s.size() + 1 == t.size()) {
        for (size_t i = 0; i < s.size(); ++i) {
            if (s[i] != t[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int count = 0;
  for(int i = s.size() - 1; i > -1; i--) {
    if(s.at(i) != t.at(i)) count++;
  }
  cout << count;
}


Measured memory_bytes: 3788
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn min(a: i32, b: i32) -> i32 {
    return if a > b { b } else { a };
}

fn main() {
    let mut S: String = read();
    let mut cnt0 = 0;
    let mut cnt1 = 0;
    for s in S.chars() {
        if s == '0' {
            cnt0 += 1;
        } else {
            cnt1 += 1;
        }
    }
    if cnt0 > cnt1 {
        println!("{}", cnt1 * 2)
    } else {
        println!("{}", cnt0 * 2)
    }
}


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

template <typename T, typename F>
class SegTree{
  int n; T uni; F f;
  vector<T> dat;
public:
  SegTree(int _n, F f, T uni) : f(f), uni(uni) {
    n = 1;
    while(n < _n) n *= 2;
    dat = vector<T>(2*n,uni);
  }
  void set(int k, const T x) {
    dat[k+n] = x;
  }
  void build() {
    for(int i = n-1; i >= 0; i--) {
      dat[i] = f(dat[2*i],dat[2*i+1]);
    }
  }
  void update(int k, T x) {
    k += n;
    dat[k] += x;
    while(k >>= 1){
      dat[k] = f(dat[2*k],dat[2*k+1]);
    }
  }
  T query(int a, int b) {
    T l = uni, r = uni;
    for(a += n, b += n; a < b; a >>= 1, b >>= 1) {
      if(a & 1) l = f(l,dat[a++]);
      if(b & 1) r = f(dat[--b],r);
    }
    return f(l,r);
  }
};

int main(){
  int n;
  cin >> n;
  auto f = [](int a, int b){return a + b;};
  SegTree<int,decltype(f)> st(2*n,f,0);
  vector<int> px;
  vector<P> qx;
  vector<int> qy;
  vector<P> event;
  int k = 0, l = 0;
  rep(i,n) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    px.push_back(x1); px.push_back(x2);
    if(y1 == y2) {
      event.push_back(P(y1,k++));
      if(x1 > x2) swap(x1,x2);
      qx.push_back(P(x1,x2));
    } else {
      if(y1 > y2) swap(y1,y2);
      event.push_back(P(y1,-flag-l));
      qy.push_back(x1);
      l++;
      event.push_back(P(y2,flag+l));
      qy.push_back(x1);
      l++;
    }
  }
  sort(px.begin(),px.end());
  map<int,int> m;
  rep(i,2*n) m[px[i]] = i;
  sort(event.begin(),event.end());
  int ans = 0;
  for(auto e : event) {
    if(e.second >= flag) {
      int a = e.second - flag;
      st.update(m[qy[a]],-1);
    } else if(e.second <= -flag) {
      int a = -e.second - flag;
      st.update(m[qy[a]],1);
    } else {
      int a = e.second;
      ans += st.query(m[qx[a].first],m[qx[a].second]+1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 10692
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int [] nx = inputval();
        int x = nx[1];
        int [] al = inputval();
        Arrays.sort(al);
        int ans = 0;
        for(int i=0;i<al.length;i++){
            if(i == al.length-1 && al[i] != x){
                break;
            }
            else if (x>=al[i]){
                ans++;
            }else{
                break;
            }
            x -= al[i];
        }

        System.out.println(ans);

    }

}



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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

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

  int cnt = 0;
  for(int i=1; i<=n; ++i){
    if(a[a[i]]==i) cnt++;
  }
  cout << cnt/2 << endl;
}

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

int main()
{
    int n;
    cin >> n;
    int p[20005], q[20005];
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
        q[p[i]] = i;
    }
    int a[20005], b[20005];
    for(int i = 0; i < n; i++){
        a[i] = (i + 1) * 40000;
        b[i] = 1000000000 + q[i] - a[i];
    }
    for(int i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;
    for(int i = 0; i < n; i++) cout << b[i] << " ";
    cout << endl;
}


Measured memory_bytes: 3912
from collections import Counter
from itertools import accumulate
import sys
M = 10**5 + 2
prime = [0]*M

for i in range(2, M):
    if prime[i]:
        continue
    for j in range(i, M, i):
        if not prime[j]:
            prime[j] = i

def pd(x):
    C = Counter()
    while x > 1:
        C[prime[x]] += 1
        x //= prime[x]
    return C

def check(x):
    C = pd(x)
    if len(C) > 2:
        return True
    if len(C) == 1:
        if list(C.values())[0] >= 4:
            return True
        return False
    if all(1 == a for a in C.values()):
        return False
    return True
M -= 1
table = [0, 0] + [check(x) for x in range(2, M)] 
table = list(accumulate(table))

for _ in range(int(input())):
    q = int(sys.stdin.readline())
    print(table[q])



Measured memory_bytes: 11596
#include<iostream>
#include<algorithm>
#include<iomanip>

using namespace std;

void Main(){
  string s,t;
  cin>>s;
  cin>>t;

  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());

  s<t ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  Main();
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    ll n;cin>>n;
    ll ans=0;
    rep(i,1,n){
        if(i%3==0)continue;
        if(i%5==0)continue;
        ans+=i;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
struct node
{
	int x,y,next;
}a[400010];int len,last[100010];
inline void ins(int x,int y)
{
	len++;
	a[len].x=x;a[len].y=y;
	a[len].next=last[x];last[x]=len;
}
int tot[100010],fa[100010];
inline int findfa(int x)
{
	if(fa[x]!=x)fa[x]=findfa(fa[x]);
	return fa[x];
}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),u=read(),v=read();
    for(int i=1;i<=n;i++)fa[i]=i,tot[i]=1;
    for(int i=1;i<=u;i++)
    {
    	int x=read(),y=read();ins(x,y),ins(y,x);
    	int fx=findfa(x),fy=findfa(y);
    	if(fx!=fy)fa[fy]=fx,tot[fx]+=tot[fy];
    }
    for(int i=1;i<=v;i++)
    {
    	int x=read(),y=read();
    	ins(x,y),ins(y,x);
    }
    for(int i=1;i<=n;i++)
    {
    	int ff=findfa(i),ans=tot[ff]-1;
    	for(int k=last[i];k;k=a[k].next)
    	{
    		int y=a[k].y;
    		if(findfa(y)==ff)ans--;
    	}pr1(ans);
    }
    return 0;
}

Measured memory_bytes: 6912
io = STDIN
$n=io.gets.to_i
$f=[]
$p=[]
$n.times do
  $f<<io.gets.split.join.to_i(2)
end
$n.times do
  $p<<io.gets.split.map(&:to_i)
end
ans=[]
(2**10).times do |sis|
  next if sis==0
  sum=0
  $f.each_with_index do |mask,j|
    cross=sis & mask
    sum+=$p[j][cross.to_s(2).count('1')]
  end
  ans << sum
end
p ans.max


Measured memory_bytes: 1788
#include <stdio.h>

int main() {
  int n, i, k, l;
  int map[25][2];
  int temp1, temp2, have, flag;

  while(1) {
    scanf("%d", &n);
    if(n == 0) break;
    for(i = 0; i < n; i++) {
      scanf("%d %d", &map[i][0], &map[i][1]);
    }

    have = 0;
    flag = 0;
    temp1 = 0;
    for(i = 0; i < n; i++) {
       if(map[i][1] > temp1) temp1 = map[i][1];
    }

    for(k = 1; k <= temp1; k++) {
      temp2 = 0;
      for(i = 0; i < n; i++) {
	if(map[i][1] == k) {
	  if(map[i][0] > temp2) temp2 = map[i][0];
	}
      }
      for(l = 1; l <= temp2; l++) {
	for(i = 0; i < n; i++) {
	  if(map[i][1] == k && map[i][0] == l) {
	    have += map[i][0];
	    if(have > map[i][1]) {
	      flag = 1;
	      break;
	    }
	  }
	}
	if(flag) break;
      }
      if(flag) break;
    }

    if(flag) {
      printf("No\n");
    } else {
      printf("Yes\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
	double a,b,r;
	scanf("%lf",&r);
	a=(double)r*r*3.1415926535897932384626433832795028841971693993751058209749;
	b=(double)r*2*3.1415926535897932384626433832795028841971693993751058209749;
	printf("%lf %lf\n",a,b);
	
	return 0;
}



Measured memory_bytes: 2620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var line0 = br.readLine().split(" ");
      final var k = Integer.parseInt(line0[1]);
      final var a = Arrays.stream(br.readLine().split(" "))
        .mapToInt(Integer::parseInt)
        .toArray();

      var mul = 1;
      for (int i = 0; i < a.length; i++) {
        if (i < k) {
          mul *= a[i];
          continue;
        }

        mul = mul * a[i] / a[i - k];
        if (i >= k) {
          System.out.println(a[i] > a[i - k] ? "Yes" : "No");
        }
      }
    }
  }
}


Measured memory_bytes: 66420
n,m = map(int, input().split())
h = list(map(int, input().split()))
ans = [1] * n
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))
for j in range(m):
    a = ab[j][0]-1
    b = ab[j][1]-1
    if h[a] > h[b]:
        ans[b] = 0
    elif h[a] == h[b]:
        ans[a] = 0
        ans[b] = 0
    else:
        ans[a] = 0
print(ans.count(1))

Measured memory_bytes: 31996
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};


__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


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

	ll a[N], b[N];
	ll sum_a = 0;
	ll sum_b = 0;
	ll diff[N];

	rep(i, N)
	{
		cin >> a[i];
		sum_a += a[i];
		
	}

	rep(i, N)
	{
		cin >> b[i];
		sum_b += b[i];
		diff[i] = a[i] - b[i];
	}

	if (sum_a < sum_b)
	{
		cout << -1 << endl;
	}

	else
	{
		sort(diff, diff+N, greater<ll>());
		int l = -1, r = N-1;
		ll sum = 0;

		while(diff[r] < 0)
		{
			sum += diff[r];
			while (sum < 0)
			{
				sum += diff[++l];
			}

			r--;
		}
		int n = l + 1 + (N-1 - r);
		cout << n << endl;
	}

	
	return 0;
}


Measured memory_bytes: 2560
// Optimise
#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 MULTI_TEST
#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#define pc(...)
#endif

#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int a, b;
        cin >> a >> b;
        string stra, strb;
        for (size_t i = 0; i < b; i++)
        {
            stra += a + '0';
        }
        for (size_t i = 0; i < a; i++)
        {
            strb += b + '0';
        }
        cout << min(stra, strb) << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc121b()
}

fun abc121b() {
    val (n, m, c) = readLine()!!.split(" ").map { it.toInt() }
    val bList = readLine()!!.split(" ").map { it.toInt() }
    val aList = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }

    val answer = aList.map {
        it.mapIndexed { index, i -> i * bList[index] }.sum() + c
    }.count { it > 0 }

    println(answer)
}


Measured memory_bytes: 37772
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int N,M,K,a[200000]={},pena[200009]={},p[200009],AC=0,PENA=0;
bool ac[200009]={};
char ch;
string str[200009];
int main() {
	cout<<setprecision(10);
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>p[i]>>str[i];
		if(str[i]=="WA"&&!ac[p[i]]){pena[p[i]]++;}
		else if(str[i]=="AC"&&!ac[p[i]]){
			AC++;
			PENA+=pena[p[i]];
			ac[p[i]]=true;
		}
	}
	cout<<AC<<" "<<PENA;
} 


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using v  = vector<int>;
const int INF = 1001001001;
int main(){
    int h,n;
    cin >>h>>n;
    
    v dp(h+1,INF);
    dp[0]=0;
    int a,b;
    rep(i,n){
        cin >> a >> b;
        rep(x,h){
            int nx = min(h,x+a);
            dp[nx] = min(dp[nx], dp[x]+b);
        }
    }
    
    cout << dp[h] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


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




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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  vector<int> vec(n) ;
  REP(i,n){
    cin >> vec.at(i) ;
  }
  
  sort(ALL(vec)) ;
  
  REP(i,n-1){
    if(vec.at(i)==vec.at(i+1)){
      cout << "NO" << endl ;
      return 0 ;
    }
  }
  cout <<"YES" <<endl ;
  
  
  
  return 0 ;
}

Measured memory_bytes: 1024
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
 
int main() {
  int n,r,b;
  string s;
  cin >> n >> s;
  r=0;
  b=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='R'){
      r++;
    }
    else{
      b++;
    }
  }
  if(r>b){
    cout <<"Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
  long long x, y;
  cin >> x >> y;
  
  if ((x > 0 && y > 0) || (x < 0 && y < 0)){
    if (x > y) cout << 2 + x - y << endl;
    else cout << y - x << endl;
  }
  if ((x > 0 && y < 0) || (x < 0 && y > 0)){
    cout << abs(y - (-x)) + 1 << endl;
  }
  if (x == 0 || y == 0){
    if (x > y) cout << x - y + 1 << endl;
    else cout << y - x << endl;
  }
}

Measured memory_bytes: 3604
N, M = map(int, input().split())
result = [0] * M

for i in range(N):
    s = list(map(int, input().split()))
    K = s[0]
    A = s[1:]
    for j in range(K):
        result[A[j]-1] = result[A[j]-1] + 1

print(result.count(N))


Measured memory_bytes: 3060
from fractions import gcd

A, B = map(int, input().split())
C = gcd(A, B)
ans = 1
i = 2
for i in range(2, int(-(-C**0.5//1))+1):
    if C % i == 0:
        ans += 1
        while C % i == 0:
            C //= i
    i += 1
if C != 1:
    ans += 1
print(ans)

Measured memory_bytes: 5176
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X, A):
    return 0 if X < A else 10


def main():
    X, A = read_int_n()
    print(slv(X, A))


if __name__ == '__main__':
    main()


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

int main()
{
    int n, k, input;
    cin >> n >> k;
    vector< int >num;

    for(int i = 0; i < 10; i++){
        num.push_back(i);
    }
    for(int i = 0; i < k; i++){
        cin >> input;
        num[input] = -1;
    }

    int nm1 = n;
    int chk = 1;
    while(chk){
        int cnt = 0, digit = 0, rem;
        int nm = nm1;
        vector< int >vec;
        while(nm > 0){
            rem = nm%10;
            vec.push_back(rem);
            nm = nm/10;
            digit++;
        }

        for(int i = 0; i < digit; i++){
            if(vec[i] == num[vec[i]])
                cnt++;
        }

        if(cnt == digit){
            chk = 0;
            break;
        }
        nm1++;
    }
    cout << nm1;

    return 0;
}


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

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

#define REP(i,n) for(LL i=0, i##_len=(n); i<i##_len; ++i)

LL gcd(LL a, LL b) {
  if( b == 0 ) { return a; }
  return gcd(b, a % b);
}

template <LL MOD=1000000007> class MODLL {
public:
  LL x;
  MODLL(const LL _x) : x(_x % MOD) {};
  MODLL operator+(const MODLL rhs) const { return MODLL(*this) += rhs; }
  MODLL operator-(const MODLL rhs) const { return MODLL(*this) -= rhs; }
  MODLL operator*(const MODLL rhs) const { return MODLL(*this) *= rhs; }
  MODLL operator/(const MODLL rhs) const { return MODLL(*this) /= rhs; }
  MODLL& operator+=(const MODLL rhs) { x += rhs.x; x %= MOD; return *this; }
  MODLL& operator-=(const MODLL rhs) { x -= rhs.x; x %= MOD; if(x<0) x += MOD; return *this; }
  MODLL& operator*=(const MODLL rhs) { x *= rhs.x; x %= MOD; return *this; }
  MODLL inv() const {
    if(x == 0) { throw "does not have inverse"; }
    LL a = x, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return MODLL(u);
  }
  MODLL& operator/=(const MODLL rhs) { (*this) *= rhs.inv(); return *this; }
  MODLL pow(ULL n) const {
    MODLL res = 1;
    MODLL a = x;
    while (n > 0) {
      if (n & 1) res *= a;
      a = a * a;
      n >>= 1;
    }
    return res;
  }
};

typedef MODLL<> ML;

void test() {
  {
    ML x = 3;
    assert(x.pow(45).x == 644897553);
  }
  {
    for(int i=1; i<13; i++) {
      MODLL<13> x = i;
      assert( (x.inv().x * i) % 13 == 1 );
    }
  }
}

std::vector<ML> fact;

ML num_cases(LL d) {
  ML ans = 0;
  for(LL n1 = d; n1 >= 0; n1 -= 2) {
    LL n2 = (d - n1) / 2;
    // (n1+n2)! / n1!n2!
    ML c = fact[n1+n2] / fact[n1] / fact[n2];
    ans += c;
  }
  return ans;
}

int main() {
  LL N,M;
  std::cin >> N >> M;

  fact.resize(N+1,1);
  for(LL i=1; i<=N; i++) {
    fact[i] = fact[i-1] * i;
  }

  std::vector<LL> A(M,0);
  for(LL i=0; i<M; i++) {
    cin >> A[i];
  }
  A.push_back(N+1);

  LL pos = 0;
  ML ans = 1;
  for(const LL a: A) {
    if( pos == a ) { ans = 0; break; }
    LL d = a - pos - 1;
    ans *= num_cases(d);
    pos = a + 1;
  }

  std::cout << ans.x << std::endl;

  return 0;
}



Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;

ll A, B;

int main(){
	scanf("%lld %lld", &A, &B);
	A = max(0LL, A - 1LL);
	ll res = 0LL;
	ll pow2 = 1LL;
	for(int i = 1; i <= 60; i++){
		ll cycle = pow2 * 2LL;
		ll num = ((B + 1) / cycle) * pow2 + max(0LL, (B + 1) % cycle - pow2);
		num -= ((A + 1) / cycle) * pow2 + max(0LL, (A + 1) % cycle - pow2);
		res += (num % 2LL) * pow2;
		pow2 *= 2LL;
	}
	printf("%lld\n", res);
	return 0;
}

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

int main(){
  ios::sync_with_stdio(0);
  int X, N, p;
  vector<int> list;
  cin >> X >> N;
  
  for (int i = 0; i < N; i++){
    cin >> p;
    list.push_back(p);
  }
  list.push_back(10100);
  for (int j = 0; j <= N + 1; j++){
    
    vector<int>::iterator itl = find(list.begin(), list.end(), X - j);
    vector<int>::iterator itp = find(list.begin(), list.end(), X + j);
    
    if (itl == list.end()){
      cout << X - j << endl;
      j = N + 2;
    }  else if (itp == list.end()){
      cout << X + j << endl;
      j = N + 2;
    }

  }   
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
int n,m,k,ans,inv[200001],invn[200001],an[200001];
int C(int x,int y)
{
	return an[y]*invn[x]%mod*invn[y-x]%mod;
}
int p(int x,int y)
{
	int z=1;
	while(y)
	{
		if(y&1)
		z=z*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return z;
}
signed main()
{
	inv[1]=an[1]=invn[1]=inv[0]=an[0]=invn[0]=1;
	for(int i=2;i<=200000;i++)
	{
		an[i]=an[i-1]*i%mod;
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
		invn[i]=invn[i-1]*inv[i]%mod;
	}
	scanf("%lld%lld%lld",&n,&m,&k);
	if(m==1)
	{
		if(k==n-1)
		printf("1");
		else
		printf("0");
		return 0;
	}
	for(int i=0;i<=k;i++)
	ans=(ans+p(m-1,n-i-1)*C(i,n-1)%mod)%mod;
	ans=ans*m%mod;
	printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 8424
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
s.append('X')
#print(s)

a = []
x = 1
for i in range(1,n+1):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
#print(a)
y = 0

for j in a:
    y += j*(j-1)/2

print(int(y))

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

int main() {
    int n,t;
    cin >> n >> t;
    int max1 = 1010;
    for(int i=0;i<n;i++){
        int c,n;
        cin >> c >> n;
        if(n<=t && max1>c) max1 = c;
    }
    if(max1!=1010) cout << max1 << endl;
    else cout << "TLE" << endl;
}



Measured memory_bytes: 384
import java.util.*;
public class Main {
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int N = Integer.parseInt(scan.next());
	int A = Integer.parseInt(scan.next());
	int B = Integer.parseInt(scan.next());
	String s = scan.next();
	for(int i=0;i<N;i++){
	    if(((A+B)==0)||(s.charAt(i)=='c'))
		System.out.println("No");
	    else if((s.charAt(i)=='a')&&((A+B)!=0)){
		if(A>0){
		    A--;
		    System.out.println("Yes");
		}
		else{
		    B--;
		    System.out.println("Yes");
		}
	    }
	    else if((s.charAt(i)=='b')&&(B!=0)){
		 B--;
		 System.out.println("Yes");
	    }
	    else
		System.out.println("No");
	}
    }
}

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

class Proc{
public:
  string nam;
  int tim;
  Proc(){ nam = ""; tim = 0; }
};

Proc Q[100001];

class Queue{
private:
  int fp;
  int rp;
public:
  Queue(){ fp = 0; rp = 0; }
  int next(int p) const{ return (p+1)%100001; }
  bool isFull() const{ return (next(rp)==fp); }
  bool isEmpty() const{ return (rp==fp);}
  void push(Proc d);
  Proc front();
  void pop();
};

void Queue::push(Proc d){
  if(isFull())
   return;
  Q[rp] = d;
  rp = next(rp);
}

Proc Queue::front(){
  if(isEmpty()){
   Proc er;
   er.tim = -1;
   return er;
 }
 return Q[fp];
}

void Queue::pop(){
  if(isEmpty())
   return;
  fp = next(fp);
}

int main(){
  Queue que;

  int n, q;
  cin >> n >> q;

  for(int i=0; i<n; i++){
    Proc p;
    cin >> p.nam >> p.tim;

    que.push(p);
  }

  int total_tim = 0;

  while(!que.isEmpty()){
    Proc p = que.front(); que.pop();
    if(p.tim<=q){
      total_tim += p.tim;

      cout << p.nam << ' ' << total_tim << endl;
    }
    else{
      total_tim += q;
      p.tim -= q;

      que.push(p);
    }
  }
  return 0;
}



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

int n, m, q;
vector<long long> a, b, c, d;

long long score(vector<int> &values) {
  long long res = 0;
  for (int i = 0; i < q; i++) {
    if (values[b[i]] - values[a[i]] == c[i]) {
      res += d[i];
    }
  }
  return res;
}

long long dfs(vector<int> &values) {
  if (values.size() == n) {
    return score(values);
  }

  long long res = 0;

  int last_value = (values.empty() ? 0 : values.back());

  for (int i = last_value; i < m; i++) {
    values.push_back(i);
    res = max(res, dfs(values));
    values.pop_back();
  }
  return res;
}

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);

  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i], --b[i];
  }

  vector<int> A;
  cout << dfs(A) << endl;

  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 200000 + 10;
char s[maxn];
int tot;
int main()
{
	scanf("%s", s + 1);
	for(int i = 1; s[i]; ++i)
		tot += s[i] - '0';
	if(tot % 9) puts("No");
	else puts("Yes");
	return 0;
}
	

Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[4];
	for(int i=0;i<4;i++)cin>>a[i];
	sort(a,a+4);
	if(a[0]!=1||a[1]!=4||a[2]!=7||a[3]!=9)cout<<"NO";else cout<<"YES";
}

Measured memory_bytes: 256