akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int n, G[110][110], d[110], Q[110], c[110];
int t = 0, h, x;

void enQ(int u){
    if(x == 110) x = 0;
    Q[x] = u;
    x++;
}

int deQ(void){
    if(h == 110) h = 0;
    return Q[h++];
}

void bfs(int s){
    
    int i, u, e = 0;
    
    for(u = 1; u <= n; u++){
        c[u] = 0;
        d[u] = 1000;
    }
    
    c[s] = -1;
    d[s] = 0;
   
    enQ(s);
    e++;
    
    while(e != 0){
        u = deQ();
        e--;
        for(i = 1; i <= n; i++){
            if(c[i] == 0 && G[u][i] == 1){
                c[i] = -1;
                d[i] = d[u] + 1;
                enQ(i);
                e++;
            }
        }
        c[u] = 1;
    }
}

int main(){
    
    int i, j, k, u, v;
    
    scanf("%d", &n);
    
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            G[i][j] = 0;
        }
    }
    
    t = 0;
    
    for(i = 1; i <= n; i++){
        scanf("%d%d", &u, &k);
        for(j = 1; j <= k; j++){
            scanf("%d", &v);
            G[u][v] = 1;
        }
    }
    
    bfs(1);
    
    for(i = 1; i <= n; i++){
        if(d[i] == 1000) d[i] = -1;
        printf("%d %d\n", i, d[i]);
    }
    
    return 0;
    
}

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

int main() {
	int n, t, a; cin >> n >> t >> a;
	double aa = 2000000000;
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		int h; cin >> h;
		if(aa >= abs(a - (t-h*0.006))) {
			aa = abs(a - (t-h*0.006));
			ans = i;
		}
	}
	cout << ans << endl;
}


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

int n, m;
vector<int> a;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m;
	vector<int> b(n+1, 0);
	for(int i=0; i<m; ++i){
		int t;
		cin >> t;
		a.push_back(t);
		b[t] = i+1;
	}
	vector<pair<int, int>> c;
	for(int i=1; i<=n; ++i)
		if(b[i] > 0)
			c.push_back(make_pair(m-b[i]+1, i));
	sort(c.begin(), c.end());
	for(int i=0; i<c.size(); ++i)
		cout << c[i].second << "\n";
	for(int i=1; i<=n; ++i)
		if(b[i] == 0) cout << i << "\n";
}


Measured memory_bytes: 5128
"use strict";
    
const main = arg => {
  let Num = arg.split(" ")[0]*1;
  let tasteBase = arg.split(" ")[1]*1;
  let tastes = tasteBase;
  // 食べてない時の足し合わせ
  for(let i = 1; i < Num; i++){
  	tastes += (tasteBase+i);
  }
  if( tasteBase >= 0 ) {
    tastes -= tasteBase;
  } else if( (tasteBase < 0) && (tasteBase + Num > 0)){
    // 便宜的に
	tastes = tastes;  
  } else if( (tasteBase < 0) && (tasteBase + Num <= 0)){
    tastes -= (tasteBase + Num - 1);  
  }
  
  console.log(tastes);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <stdio.h>
#include <string.h>

#define TRUE 1
#define FALSE 0
#define SUIT 4
#define RANK 13

int main(){
int n;
int rank;
int i,j;
char mark;
char *sp = "SHCD";

int cards[SUIT][RANK] = {FALSE};

scanf("%d", &n);

if(n > 52){
return 0;
}

for(i = 0;i < n;i++){
scanf("%s %d", &mark, &rank);
if(rank >= 1 && rank <= RANK){
for(j = 0;j < SUIT;j++){
if(mark == *(sp + j)){
cards[j][rank - 1] = TRUE;
break;
}
}
}else{
return 0;
}
}

for(i = 0;i < SUIT;i++){
for(j = 0;j < RANK;j++){
if(cards[i][j] == FALSE){
printf("%c %d\n", *(sp + i), j + 1);
}
}
}

return 0;
}

Measured memory_bytes: 596
#include <vector>
#include <functional>

template<class T>
struct dual_segment_tree {
	using value_type = T;
	using size_type = std::size_t;
	using Binary_Operation = std::function<T(T, T)>;
private : 
	size_type n;
	const Binary_Operation op;
	const value_type identity;
	std::vector<value_type> node;

	void propagate (size_type i) noexcept {
		if (node[i] == identity) return;
		node[i << 1 | 0] = op(node[i << 1 | 0], node[i]);
		node[i << 1 | 1] = op(node[i << 1 | 1], node[i]);
		node[i] = identity;
	}

	void topdown_update (size_type i) noexcept {
		if (i == 0) return;
		const size_type ctz = __builtin_ctz(i);
		for (size_type h = 31 - __builtin_clz(i); h != ctz; h--) {
			propagate(i >> h);
		}
	}

public : 
	explicit constexpr dual_segment_tree (const value_type &identity, const Binary_Operation &op) noexcept : identity(identity), op(op) { }

	void assign (size_type _size) noexcept {
		n = _size;
		node.assign(n << 1, identity);
	}

	void assign (size_type _size, const value_type &value) noexcept {
		assign(_size);
		for (size_type i = n; i < (n << 1); i++) {
			node[i] = value;
		}
	}

	template<class InputIterator>
	void assign (InputIterator first, InputIterator last) noexcept {
		assign(last - first);
		for (size_type i = n; first != last; i++, first++) {
			node[i] = (*first);
		}
	}

	void update (size_type l, size_type r, const value_type &value) noexcept {
		topdown_update(l + n); topdown_update(r + n);
		for (l += n, r += n; l != r; l >>= 1, r >>= 1) {
			if (l & 1) { node[l] = op(node[l], value); l++; }
			if (r & 1) { r--; node[r] = op(node[r], value); }
		}
	}

	value_type fold (size_type i) noexcept {
		value_type value = node[(i += n)];
		for (i >>= 1; i > 0; i >>= 1) {
			value = op(value, node[i]);
		}
		return value;
	}

	value_type operator[] (size_type i) noexcept {
		return fold(i);
	}

	value_type at (size_type i) noexcept {
		return fold(i);
	}

};

template<class InputIterator, class T, class Binary_Operation>
dual_segment_tree<T> make_dualsegtree (InputIterator first, InputIterator last, const T &identity, const Binary_Operation &op) {
	dual_segment_tree<T> segtree(identity, op);
	segtree.assign(first, last);
	return segtree;
}



#include <iostream>
#include <limits>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	std::size_t n;
	int q;
	std::cin >> n >> q;
	
	std::vector<int> v(n, std::numeric_limits<int>::max());
	
	auto seg = make_dualsegtree(v.begin(), v.end(), -1, [](int a, int b) { return (b == -1 ? a : b); });
	
	while (q--) {
		int type;
		std::cin >> type;
		if (type == 0) {
			std::size_t l, r;
			int x;
			std::cin >> l >> r >> x;
			seg.update(l, r + 1, x);
		} else {
			std::size_t i;
			std::cin >> i;
			std::cout << seg[i] << '\n';
		}
	}
	
	return 0;
}


Measured memory_bytes: 4144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s =sc.nextLine().toCharArray();
		sc.close();

		int upper = (s[0] - '0')*10 + (s[1] - '0');
		int lower = (s[2] - '0')*10 + (s[3] - '0');
		boolean upperMonthCandidate = (1 <= upper && upper <= 12);
		boolean lowerMonthCandidate = (1 <= lower && lower <= 12);
		if (upperMonthCandidate && lowerMonthCandidate) {
			System.out.println("AMBIGUOUS");
		} else if (upperMonthCandidate && ! lowerMonthCandidate) {
			System.out.println("MMYY");
		} else if (! upperMonthCandidate && lowerMonthCandidate){
			System.out.println("YYMM");
		} else {
			System.out.println("NA");
		}
	}
}


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

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

bool is_palindrome(string s){
	string rev = s;
	reverse(all(s));
	return s == rev;
}


int main()
{
	string s;
	cin>>s;
	int n=s.size();
	if(is_palindrome(s) && is_palindrome(s.substr(0,n/2)) && is_palindrome(s.substr((n+2)/2,n/2))){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import copy
import sys
import numpy as np
import heapq

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

class node_cost:
    def __init__(self, point, cost):
        self.point = point
        self.cost = cost

    def __lt__(self, other):
        return self.cost < other.cost

class Dijkstra:
    def __init__(self):
        self.table = {}

    def execute(self, adj_list, start):
        confirm_set = set()
        cost_dict = {}
        cost_dict[start] = 0
        #heapq.heapify

        n = node_cost(start, 0)
        node_list = [n]
        while len(node_list) > 0:
            n = heapq.heappop(node_list)
            if n.point in confirm_set:
                continue;
            confirm_set.add(n.point)
            self.table[(start, n.point)] = n.cost
            #self.table[(n.point, start)] = n.cost
            for v in adj_list[n.point]:
                if v[0] not in confirm_set:
                    if v[0] not in cost_dict:
                        cost_dict[v[0]] = n.cost + v[1]
                        heapq.heappush(node_list, node_cost(v[0], cost_dict[v[0]]))
                    else:
                        if n.cost + v[1] < cost_dict[v[0]]:
                            cost_dict[v[0]] = n.cost + v[1]
                            heapq.heappush(node_list, node_cost(v[0], cost_dict[v[0]]))

class DFS:
    def __init__(self, visitable_list, cost_table):
        self.visitable_list = visitable_list
        self.cost_table = cost_table
        self.done_list = set([])
        self.min_cost = sys.maxint

    def execute(self, now_cost, now_v):
        if len(self.done_list) == len(self.visitable_list):
            if now_cost < self.min_cost:
                self.min_cost = now_cost
            return

        for v in self.visitable_list:
            if v not in self.done_list:
                self.done_list.add(v)
                if now_v == 0:
                    self.execute(0, v)
                else:
                    self.execute(now_cost + self.cost_table[(now_v, v)], v)
                self.done_list.remove(v)




def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M, R] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    input_raw = read_func()
    input_str = input_raw.strip().split()
    visit_list = []
    for i in range(R):
        visit_list.append(int(input_str[i]))

    adj_list = {}
    for i in range(M):
        input_raw = read_func().strip().split()
        [A, B, C] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        if A not in adj_list:
            adj_list[A] = []
        if B not in adj_list:
            adj_list[B] = []
        adj_list[A].append((B, C))
        adj_list[B].append((A, C))


    D = Dijkstra()
    for v in visit_list:
        D.execute(adj_list, v)
    #print D.table

    dfs = DFS(visit_list, D.table)
    dfs.execute(0, 0)
    print dfs.min_cost

if __name__ == '__main__':
    main()

Measured memory_bytes: 15844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <cmath>
#include<iomanip>
using namespace std;
static const long long MOD = 1000000007LL;
typedef long long ll;

int main()
{
	int a,b;
	cin>>a>>b;
	int c=a+b;
	int d=a*b;
	int e=a-b;
	int f=max(c,d);
	int g=max(f,e);
	cout<<g<<endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
int fun(string s){
    reverse(all(s));
    int res = 0;
    for(auto x:s)
    {
        res += (x-'0');
    }
    return res;
}
int fun2(int x){
    int res = 0;
    while(x){
        res += x%10;
        x /= 10;
    }
    return res;
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        string s; cin >> s;
        int x = fun(s);
        while(x > 9){
            x = fun2(x);
        }
        if(x % 9 == 0)
            cout << "Yes";
        else cout << "No";
    }    
}

Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
using namespace std;

int main(){
    int a,b,ans=1;
    cin >> a >> b;
    for(int i=0;i<a;i++){
        if(ans<b){
            ans *=2;
        }else{
            ans +=b;
        }
    }
    cout << ans << endl;
}

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

int main() {
    string S;
    cin >> S;
    int cnt = S.size();
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'A') {
            break;
        }
        cnt--;
    }
    for(int i = S.size()-1; i >= 0; i--) {
        if(S[i] == 'Z') {
            break;
        }
        cnt--;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 640
import java.util.*;

class Main {
    static final long A=1000000001;
    static final long I=(1L<<59)-1;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        long[]hp=new long[n];
        for(int i=0;i<n;++i){
            long h=Integer.parseInt(scan.next());
            long p=Integer.parseInt(scan.next());
            hp[i]=(h+p)*A+h;
        }
        Arrays.sort(hp);
        long[][]dp=new long[2][n+1];
        for(int i=0;i<2;++i)Arrays.fill(dp[i],I);
        dp[0][0]=0;
        for(int i=0;i<n;++i){
            long p=hp[i]/A;
            long h=hp[i]%A;
            p-=h;
            int a=i%2;
            System.arraycopy(dp[a],0,dp[1-a],0,n+1);
            for(int j=0;j<=i;++j){
                if(dp[a][j]<=h)
                    dp[1-a][j+1]=Math.min(dp[1-a][j+1],dp[a][j]+p);
            }
        }
        int m=0;
        for(int i=0;i<=n;++i)
            if(dp[n%2][i]<I)m=i;
        System.out.println(m);
    }
}


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

template <class T> struct ford_fulkerson {
  struct Edge { int to, rev; T cap; };
  const T inf = numeric_limits<T>::max();
  const int n;
  vector<vector<Edge>> g;
  vector<bool> used;
  ford_fulkerson(int _n) : n(_n), g(n), used(n) {}
  void add_edge(int from, int to, T cap) {
    assert(from != to);
    assert(cap >= 0);
    if (!cap) return;
    g[from].emplace_back(Edge{to, (int)g[to].size(), cap});
    g[to].emplace_back(Edge{from, (int)g[from].size() - 1, 0});
  }
  T dfs(int v, int t, T f) {
    if (v == t) return f;
    used[v] = true;
    for (auto&& e : g[v]) {
      if (used[e.to] or !e.cap) continue;
      T d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
    return 0;
  }
  T max_flow(int s, int t) {
    assert(s != t);
    T res = 0;
    while (true) {
      fill(begin(used), end(used), false);
      T f = dfs(s, t, inf);
      if (f == 0) return res;
      res += f;
    }
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  for (auto&& v : a) {
    for (auto&& e : v) {
      cin >> e;
      --e;
    }
  }
  for (int c = 0; c < m; ++c) {
    int s = 2 * n, t = s + 1;
    ford_fulkerson<int> ff(t + 1);
    for (int i = 0; i < n; ++i) {
      ff.add_edge(s, i, 1);
      ff.add_edge(n + i, t, 1);
    }
    for (int i = 0; i < n; ++i) {
      vector<bool> be(n);
      for (int j = c; j < m; ++j) {
        be[a[i][j] / m] = true;
      }
      for (int x = 0; x < n; ++x) {
        if (be[x]) {
          ff.add_edge(i, n + x, 1);
        }
      }
    }
    int f = ff.max_flow(s, t);
    assert(f == n);
    for (int i = 0; i < n; ++i) {
      for (auto e : ff.g[i]) {
        if (e.cap == 0) {
          int j = find_if(begin(a[i]) + c, end(a[i]), [&](int x) {
            return x / m == e.to - n;
          }) - begin(a[i]);
          swap(a[i][c], a[i][j]);
          break;
        }
      }
    }
  }
  for (auto e : a) {
    for (int j = 0; j < m; ++j) {
      cout << e[j] + 1 << " \n"[j == m - 1];
    }
  }
  for (int j = 0; j < m; ++j) {
    vector<int> v;
    for (int i = 0; i < n; ++i) {
      v.push_back(a[i][j]);
    }
    sort(begin(v), end(v));
    for (int i = 0; i < n; ++i) {
      a[i][j] = v[i];
    }
  }
  for (auto e : a) {
    for (int j = 0; j < m; ++j) {
      cout << e[j] + 1 << " \n"[j == m - 1];
    }
  }
}


Measured memory_bytes: 704
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    
    double n,a,b;
    cin>>n>>a>>b;
    vector<double> v;
    rep(i,n){
        ll vv;cin>>vv;
        v.push_back(vv);
    }
    sort(v.rbegin(),v.rend());
    double ave=0;
    rep(i,a){
        ave+=v[i];
    }
    ave=ave/a;
    //cout<<ave<<endl;
    printf("%f\n",ave);
    
    
    if(n==1){cout<<v[0]<<endl;return 0;}
    
    
    if(v[0]==v[a-1]&&v[a-1]==v[a]){
        ll h=a;
        while(true){
            if(v[a-1]==v[h]&&h<v.size()){
                h++;
            }else{
                break;
            }
        }
        ll zentai=h;
        
        double ans=0;
        // cout<<"a"<<a<<h<<endl;
        for(int aa=a;aa<=b;aa++){
            cout<<setprecision(16);
            double cc=1,rr=1;
            for(int i=0;i<aa;i++){
                cc*=(zentai-i);
            }
            for(int i=0;i<aa;i++){
                rr*=(aa-i);
            }
            //  cout<<zentai<<" "<<aa<<" "<<cc/rr<<endl;
            ans+=cc/rr;
        }
        
        //ll anss=ans;
        //  printf("%f\n",ans);
       // cout<<anss<<endl;
       
        cout<<ans<<endl;
        
    }else{
        ll csum=1;
        ll o=a-2;
        while(true){
            if(v[a-1]==v[o]&&o>=0){
                csum++;
                o--;
            }else{
                break;
            }
        }
        o=a;
        ll tsum=0;
        while(true){
            if(v[a-1]==v[o]&&o<v.size()){
                o++;
                tsum++;
            }else{
                break;
            }
        }
        tsum+=csum;
        long double c=1,r=1;
        for(int i=0;i<csum;i++){
            c*=(tsum-i);
        }
        for(int i=0;i<csum;i++){
            r*=(csum-i);
        }
        // cout<<"b"<<endl;
        ll ansm=c/r;
        cout<<ansm<<endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 256
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define ll long long
#define fir first
#define sz(a) int((a).size())

int fa[200005];
int cntf[200005];
int ans=0;
int get(int x)
{
	if(x==fa[x])
		return x;
	return fa[x]=get(fa[x]);
}

void _merge(int a,int b)
{
	int x=get(a),y=get(b);
	if(x==y)
		return ;
	fa[x]=y;
	cntf[y]+=cntf[x];
	cntf[x]=0;
	ans=max(ans,cntf[y]);
}

signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<=n+1;i++)
	{
		fa[i]=i;
		cntf[i]=1;
	}
	int a,b;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		_merge(a,b);
	}
	if(ans==0)
		ans=1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5092
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N = int(readline())
    ok = 10 ** 3
    ng = 0
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if N <= mid * (mid - 1) // 2:
            ok = mid
        else:
            ng = mid
    K = ok
    if not N == K * (K - 1) // 2:
        print('No')
        return

    num = 1
    ans = [[0] * (K - 1) for _ in range(K - 1)]
    for i in range(K - 1):
        for j in range(i + 1):
            ans[i][j] = ans[j][i] = num
            num += 1

    ans.append([ans[i][i] for i in range(K - 1)])
    ans = ["{} {}".format(K - 1, ' '.join(map(str, row))) for row in ans]

    print('Yes')
    print(K)
    print('\n'.join(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9588
fun judge(ret: Boolean, ok: String, ng: String) = if (ret) println(ok) else println(ng)
fun isProductEven(a: Int, b: Int) = if (a % 2 == 0 || b % 2 == 0) true else false

fun main(args: Array<String>) {
  val (a,b) = readLine()!!.split(" ").map(String::toInt)
  val ret = isProductEven(a,b)
  judge(ret, "Even", "Odd")
}


Measured memory_bytes: 37736
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<queue>
long long  INF=1'0000'0000'0000'0000'00;
using namespace std;

int main(){


int N,M;
cin>>N>>M;

multimap<int,int>work;
int a,b;
for(int i=0;i<N;i++){
cin>>a>>b;
work.insert(make_pair(a,b));
}

long long ans=0;
priority_queue<int>Q;
auto iter=work.begin();

for(int i=1;i<=M;i++){

    while(iter->first<=i && iter!=work.end()){
    Q.push(iter->second);
    iter++;
    }
    if(!Q.empty()){
    ans+=Q.top();
    Q.pop();
    }
    
}
cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 5628
N=int(input())
p=list(map(int,input().split()))
answer = []
diff = 0
diff_1 = -1
diff_2 = -1

index = 0

for i in p:
    if index == 0:
        index += 1
        continue
    
    if p[index] < p[index-1]:
        if diff >= 2:
            print ("NO")
            exit()
        diff += 1

        if diff == 1:
            diff_1 = index-1
        else:
            diff_2 = index

    index += 1

if diff_1 == -1:
    print("YES")
    exit()

if diff_1 != -1 and diff_2 == -1:
    print("NO")
    exit()

diff_1_1 = p[diff_1]
p[diff_1] = p[diff_2]
p[diff_2] = diff_1_1

index = 0

for i in p:
    if index == 0:
        index += 1
        continue
    
    if p[index] < p[index-1]:
        print ("NO")    
        exit()

    index += 1

print("YES") 

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

int func(int x,vector<int> &b,vector<int> &v,int G,int num,vector<bool> &index){
  if(G <= 0){
    return num;
  }

  int min_ans = 1001;
  
  if(x < 0){
    int cnt = 0;
    for(int k=b.size()-1;k>=0;k--){
      if(!index.at(k)){
      for(int j=1;j<b.at(k);j++){
          G -= 100*(k+1);
          cnt++;
        if(G <= 0) return (num + cnt);
      }
      }
    }
    return min_ans;
  }

  for(int i=0;i<2;i++){
    if(i == 1){
      index.at(x) = true;
      int save = func(x-1,b,v,G-(100*(x+1))*b.at(x)-v.at(x),num+b.at(x),index);
      min_ans = min(save,min_ans);
    }
    else{
      index.at(x) = false;
      int save = func(x-1,b,v,G,num+i,index);
      min_ans = min(save,min_ans);
    }
  }
  
  return min_ans;
}

int main(){
  int N,G;
  cin >> N >> G;
  vector<int> b(N),v(N);
  vector<bool> index(N,false);
  for(int i=0;i<N;i++){
   cin >> b.at(i) >> v.at(i);
  }
  int num = 0;
  cout << func(N-1,b,v,G,num,index) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  bool num[1000000]={false};
  for(int i=2; i<=1000; i++)
    if(!num[i])
      for(int j=i*i; j<1000000; j+=i)
	num[j] = true;
  int n;
  while(cin >>n){
    for(int i=n-1;;i--){if(!num[i]){cout <<i<<" ";break;}}
    for(int i=n+1;;i++){if(!num[i]){cout <<i<<endl;break;}}

  }
  return 0;
}

Measured memory_bytes: 2144
n = int(input())
testimony = []  # 各iの証言
for i in range(n):
    t = []
    for _ in range(int(input())):
        x, y = map(int, input().split())
        t.append((x - 1, y))
    testimony.append(t)
best = 0  # 正直者の最大人数
for honest in range(1 << n):  # 正直者をあらかじめ仮定して破綻を確認する
    tmp = 0
    for i in range(n):  # 証言者i
        if not (honest >> i) & 1:  # iが不親切な人なら証言を聞かない
            continue
        tmp += 1
        for j, t in testimony[i]:  # iによるjに対する証言t
            if (honest >> j) & 1 ^ t:  # jに対する仮定とtが食い違えば破綻
                break
        else:
            continue
        break
    else:  # 全ての正直者に話を聞いて破綻が無ければ更新
        best = max(best, tmp)
print(best)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long n,ans=0,a,b;
string s;
int main(){
  cin >> n >> a >> b;
  long long c[n];
  ans+=n+b;
  for(int i=0;i<n;i++){
    cin >> c[i];
    ans+=(a-1)/c[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::max;

static int
solve(int A, int B, int C)
{
  int mx = max({A, B, C});
  int ac = (mx - A) / 2;
  int bc = (mx - B) / 2;
  int cc = (mx - C) / 2;
  int a = A + 2 * ac;
  int b = B + 2 * bc;
  int c = C + 2 * cc;
  int rest = mx * 3 - (a + b + c);
  return ac + bc + cc + (rest == 0 ? 0 : rest == 1 ? 2 : 1);
}

int
main()
{
  int A, B, C;
  cin >> A >> B >> C;
  cout << solve(A, B, C) << endl;
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n, m;
  cin >> n >> m;
  int ans = (n-1) * (m-1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 1000005
#define P 1000000007
#define LL long long
using namespace std;
int A[M],B[M],n;
char str[M];
int main(){  
	scanf("%d %s",&n,str);
	if(n>=3200)puts(str);
	else puts("red");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int n,cnt=0,cntmi=1000;
signed main()
{
	cin>>n;
	rep(i,n-1){
		string s=to_string(i+1);
		string sa=to_string(n-i-1);
		rep(j,s.size()){
			int b=s[j]-48;
			cnt+=b;
		}
		rep(j,sa.size()){
			int b=sa[j]-48;
			cnt+=b;
		}
		cntmi=min(cntmi,cnt);
		cnt=0;
	}
	cout<<cntmi;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int H, W;
    cin >> H >> W;

    map<int, int> candidates;
    map<int, int> moves;

    rep(i, W) {
        candidates[i] = i;
    }
    moves[0] = W;

    rep(i, H) {
        int A, B;
        cin >> A >> B;
        A--;

        int r = -1;
        while (true) {
            auto it = candidates.lower_bound(A);
            if (it == candidates.end() || it->first > B) break;

            r = max(r, it->second);
            int t = it->first - it->second;
            moves[t]--;
            if (moves[t] == 0) {
                moves.erase(t);
            }
            candidates.erase(it);
        }
        if (r != -1 && B != W) {
            moves[B - r]++;
            candidates[B] = r;
        }

        if (moves.size() == 0) {
            cout << -1 << endl;
        } else {
            cout << moves.begin()->first + (i + 1) << endl;
        }
    }

    return 0;
}


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

using namespace std;

#define height first
#define power second
typedef pair<int, int> person;

const int INF = 1e9 + 200;

bool ord (person p, person q) {
  return p.height + p.power < q.height + q.power;
}

const int MAX_N = 5e3 + 5;

person people [MAX_N];
int dp [MAX_N][MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> people[i].height >> people[i].power;
  }
  sort(people, people + n, ord);

  for (int i = 0; i < n; i++) {
    dp[1][i] = people[i].power;
  }

  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < n; j++) {
      dp[i][j] = INF;
    }
  }

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

    for (int j = 1; j < n; j++) {
      if (dp[i - 1][j - 1] > people[j].height) {
        dp[i][j] = INF;
      } else {
        ans = max(ans, i);
        dp[i][j] = dp[i - 1][j - 1] + people[j].power;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 101452
//BISMILLAHHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
using namespace std;
typedef long long int            ll;
typedef unsigned long long int   ull;
#define min3(a,b,c)              min(a,min(b,c))
#define F                        first
#define S                        second
#define PB                       push_back
#define MP                       make_pair
#define PI                       2*acos(0.0)
#define REP(i,a,b)               for(int i = a; i<=b; i++)
#include<stdio.h>
int main()
{
   int n,ans;
   cin>>n;
   ans=ceil(n/2.0);
   cout<<ans<<endl;
   return 0;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		pl(N-K+1);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;

int main() {
    int A,B,ans;
    cin >> A >> B;
    if(A >= 13) ans = B;
    else if(A >= 6) ans = B / 2;
    else ans = 0;
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n,m;
    cin >> n>>m;
    if(n%2==1){
        rep(i,m){
            int a = n/2;
            cout << (a-i) << " " << n-(a-i) << endl;
        }
    }else{
        int a = n/2;
        if(m<=n/4){
            rep(i,m){
                cout << (a-i) << " " << n+1-(a-i) << endl;
            }
        }else{
            rep(i,n/4){
                cout << (a-i) << " " << n+1-(a-i) << endl;
            }
            rep(j,m-n/4){
                cout << (j+1) << " " << n-(j+1) << endl;
            }
        }
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    double d, t, s;
    //int d, t, s;
    cin >> d >> t >> s;
    if(d/s > t){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    long long N, M; cin >> N >> M;
    vector<long long> A(M); repp(i,0,M) cin >> A[i];
    long long sum_ = 0;
    repp(i,0,M) sum_ += A[i];
    cout << max(-1LL, N - sum_) << endl;
}


Measured memory_bytes: 3676
#include<iostream>
#include <algorithm>
using namespace std;
int N_MAX = 10;
int main()
{
  int n,m,res=0;
  int p[N_MAX];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> p[i];
    res+=p[i];
  }
  m=*max_element(p,p+n);
  res-=m/2;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,cnt[20],ok[1<<17],dp[1<<17],val[N];
typedef pair<int,int> pii;
vector<pii> e[N];
void dfs(int x,int fa){
	for (auto i:e[x]){
		int v=i.first;
		if (v==fa) continue;
		val[v]=i.second;
		val[x]^=val[v];
		dfs(v,x);
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int u,v,l;
		scanf("%d%d%d",&u,&v,&l);u++;v++;
		e[u].push_back(pii(v,l));
		e[v].push_back(pii(u,l));
	}
	dfs(1,0);
	for (int i=2;i<=n;i++) cnt[val[i]]++;
	int ans=0;
	for (int i=1;i<=15;i++) ans+=cnt[i]/2,cnt[i]%=2;
	for (int i=1;i<=15;i++) ans+=cnt[i];
	cnt[0]=0;
	int U=1<<16;
	for (int i=0;i<U;i++){
		int s=0;
		for (int j=0;j<16;j++)
		if (i>>j&1) s^=j;
		if (!s) ok[i]=1;
	}
	for (int i=0;i<U;i++)
	for (int j=i;j;j=(j-1)&i){
		if (ok[j]) dp[i]=max(dp[i],dp[i^j]+1);
		dp[i]=max(dp[i],dp[i^j]);
	}
	int tmp=0;
	for (int i=0;i<16;i++) tmp^=cnt[i]<<i;
	printf("%d\n",ans-dp[tmp]);
	return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <string>
using namespace std;
using ull = unsigned long long;

int main(){
    int n,k,q,idx;
    cin>>n>>k>>q;
    vector<int> ans(n,k-q);
    for(int i=0;i<q;i++){
        cin>>idx;
        ans[idx-1]++;
    }
    for(int i=0;i<n;i++){
        if(ans[i]>0){
            cout<<"Yes\n";
        }else{
            cout<<"No\n";
        }
    }
    return 0;
}


Measured memory_bytes: 1024
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        s: Chars,
    }
    print!("{}", s[0]);
    print!("{}", s.len()-2);
    println!("{}", s[s.len()-1]);
}


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

typedef long long ll;

int N, Q;
ll X[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    ll sum = 0;
    for (int i=0; i<N; i++){
        int x; cin >> x;
        X[x]++;
        sum += x;
    }
    cin >> Q;
    while (Q--){
        int b, c;
        cin >> b >> c;
        sum -= b * X[b];
        sum += X[b] * c;
        X[c] += X[b];
        X[b] = 0;
        cout << sum << '\n';
    }
}

Measured memory_bytes: 4336
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[1010][1010];

int main() {
  ll h,w;
  cin>>h>>w;
  vector<string> vs;
  rep(i,0,h){
    string s;
    cin>>s;
    vs.pb(s);
  }
  clr(dp,0);
  dp[0][0] = 1;
  rep(y,0,h){
    rep(x,0,w){
      if(vs[y][x]=='.'){
        if(x-1>=0)dp[y][x] += dp[y][x-1];
        if(y-1>=0)dp[y][x] += dp[y-1][x];
        dp[y][x] %= MOD;
      }
    }
  }
  cout << dp[h-1][w-1] << endl;
	return 0;
}

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main
{
	public static void main ( String[] args ) {
		Scanner sc = new Scanner ( System.in );
		
		int m = 0;
		int f = 0;
		int r = 0;
		
		while ( true ) {
			m = sc.nextInt ();
			f = sc.nextInt ();
			r = sc.nextInt ();
			
			if ( m < 0 && f < 0 && r < 0 ) {
				break;
			}
			
			int sum = m + f;
			
			if ( m == -1 || f == -1 ) {
				System.out.println ( "F" );
			} else if ( 80 <= sum ) {
				System.out.println ( "A" );
			} else if ( 65 <= sum && sum < 80 ) {
				System.out.println ( "B" );
			} else if ( 50 <= sum && sum < 65 ) {
				System.out.println ( "C" );
			} else if ( 30 <= sum && sum < 50 ) {
				if ( 50 <= r ) {
					System.out.println ( "C" );
				} else {
					System.out.println ( "D" );
				}
			} else if ( 0 <= sum && sum < 30 ) {
				System.out.println ( "F" );
			}
		}
	}
}

Measured memory_bytes: 26208
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,d,x;
	cin>>n>>d>>x;
	rep(i,n){
		int a;cin>>a;
		x+=(d-1)/a+1;
	}
	cout<<x<<endl;
}










Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,l[100],max=0,sum=0;
    cin >>n;
    for(int i=0;i<n;i++){
        cin>>l[i];
        if(l[i]>max)max = l[i];
        sum+=l[i];
    }
    if(sum > max*2){
        cout <<"Yes"<<endl;   
    }
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll dp[3001];

int main(){
  ll N,S,A,ANS=0;
  cin >> N >> S;
  rep(i,N){
    cin >> A;
    rRep(j,S+1,A){
      dp[j]+=dp[j-A];
      dp[j]%=MOD2;
    }
    dp[A]++;
    dp[0]++;
    ANS+=dp[S];
  }
  cout << ANS%MOD2;
}


Measured memory_bytes: 3624
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    return a*b // gcd(a, b)


def good(A, N):
    # A = sorted(A)
    ans = A[0]
    # for i in range(1, N):
    #     ans = fractions.gcd(A[i], ans)
    for i in range(1, N):
        ans = lcm(ans, A[i])
    return ans


def main():
    N, M = MI()
    a = LI()

    if any([i % 2 for i in a]):
        print(0)
        return

    # ha = [x//2 for x in a]
    # n = good([x//2 for x in a], N)
    # # print(n)

    # if not all([(n // x) % 2 for x in ha]):
    #     print(0)
    #     return

    n = good(a, N)
    n = n // 2
    # n = n * 2

    if not all([(2 * n // x) % 2 for x in a]):
        print(0)
        return

    if n > M:
        print(0)
    else:
        t = M // n
        if t % 2 == 0:
            t -= 1
        print(t // 2 + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64236
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int [] arr=new int [n];
		int [] a=new int [n];
		for(int i=0;i<n;i++)
		{
			arr[i]=i+1;
			a[i]=in.nextInt();
		}
		int j=0;
		int ans=0;
		for(int i=0;i<n;i++)
		{
			if(a[i]!=arr[j])
			{
				ans++;
			}
			else
			{
				j++;
			}
		}
		if(ans==n)
		{
			ans=-1;
		}
		System.out.println(ans);
	}
}
	

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

int main(){
    int s;
    cin>> s;
    
    set<int> st;
    st.insert(s);

    int cnt = 2;
    while(1){
        if(s%2 == 0){
            //cout<<"偶数"<<endl;
            s = s/2;
            //cout<<s<<endl;
        }else{
            //cout<<"奇数"<<endl;
            s = 3*s + 1;
            //cout<<s<<endl;
        }
        if(st.find(s) != st.end()){
            cout<<cnt<<endl;
            return 0;
        }else{
            st.insert(s);
            cnt++;
        }
        
    }

}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int s = (a + b + c) / 2;
    cout << sqrt(s * (s - a) * (s - b) * (s - c)) << endl;
    return 0;
}

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

using namespace std;
int N;

vector<long long> A;

int main()
{
	cin >> N;

	A = vector<long long>(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	sort(A.begin(), A.end(), greater<long long>());

	long long ans = A[0];

	for (int i = 2; i < N; i++) {
		ans += A[i/2];
	}

	cout << ans << endl;
	

	return 0;
}



Measured memory_bytes: 4412
#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = 0;
  if ((B - A) % 2 != 0){
    ll front = A - 1;
    ll rear = N - B;
    ll ans_front = 1 + front + (B - 1 - front) / 2;
    ll ans_rear = 1 + rear + (N - A - 1 - rear) / 2;
    ans = min(min(min(ans_front, ans_rear), B), N - A);
  }
  else{
    ll mid = (B - A) / 2;
    ans = min(min(mid, B), N - A);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  int ans=0;
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(i!=minj){
      swap(A[i],A[minj]);
      ans++;
    }
  }
  for(int i=0;i<n;i++) cout<<A[i]<<" \n"[i==n-1];
  cout<<ans<<endl;
  return 0;
}






Measured memory_bytes: 3088
using System;

class SumOfgcdEasy
{   
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());
        var ans = 0;

        for(int a = 1;a <= input; a++)
        {
            for(int b = 1; b <= input; b++)
            {
                for(int c = 1;c <= input; c++)
                {
                    var g = Gcd(a, b);
                    g = Gcd(g, c);
                    ans += g;

                }
            }
        }
        Console.WriteLine(ans);
    }

    static int Gcd(int a, int b)
    {
        if (b == 0) return a;
        return Gcd(b, a % b);
    }

}

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

int main()
{
    int n;
    cin>>n;
    int counter=1;
    for(int i=2;i<=n;i++)
    {
        int j=i;
        while(j*i<=n)
        {
            counter=max(j*i,counter);
          j*=i;
        }
    }
    cout<<counter<<endl;
}


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

int main() {
  int k;
  cin >> k;
  
  
  long long ans=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int s=1;s<=k;s++){
        ans += gcd(i, gcd(j, s) );
      }
    }
  }
  cout << ans << endl;
    
}
  


Measured memory_bytes: 3548
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,a[maxn];

int main()
{
	n=read(); rep(i,1,n) a[i]=read();
	int ans=0;
	rep(i,1,n)
	{
		rep(j,i+1,n)
		{
			if(a[i]==a[j]) continue;
			rep(k,j+1,n)
			{
				if(a[k]==a[i]||a[k]==a[j]) continue;
				if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]) ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620