akhauriyash/Code-Regression huggingface dataset:
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))


x = load()

c500 = 0
c5 = 0

while x >= 500:
    x -= 500
    c500 += 1

while x >= 5:
    x -= 5
    c5 += 1


print(c500 * 1000 + c5 * 5)

Measured memory_bytes: 3412
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int h, w;
  readf("%s %s\n", &h, &w);
  auto ss = new char[][](h, w);
  foreach (i; 0..h) {
    ss[i] = readln.chomp.to!(char[]);
  }

  auto res = true;
  foreach (i; 0..h) {
    foreach (j; 0..w) {
      if (ss[i][j] == '#') {
        bool f;
        if (i-1 >= 0 && ss[i-1][j] == '#') f = true;
        if (i+1 < h && ss[i+1][j] == '#') f = true;
        if (j-1 >= 0 && ss[i][j-1] == '#') f = true;
        if (j+1 < w && ss[i][j+1] == '#') f = true;
        if (!f) {
          res = false;
        }
      }
    }
  }

  if (res) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


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

    int sume = 0, sumw = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'W') sumw++;
        else sume++;
    }

    int e = 0, w = 0;
    int ans = 1e9;
    for(int i = 0; i < n; i++){
        if(s[i] == 'E') e++;
        ans = min(ans, w + sume - e);
        if(s[i] == 'W') w++;
    }
    cout << ans << endl;

    return 0;
}


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

signed main(void)
{
	int w, h, n;
	int sx, sy;

	cin >> w >> h >> n;
	sx = sy = 0;
	rep(i, n)
	{
		pair<int, int> p;
		int a;
		cin >> p.first >> p.second >> a;
		if (a == 1)
		{
			if (p.first > sx)
				sx = p.first;
		}
		else if (a == 2)
		{
			if (p.first < w)
				w = p.first; 
		}
		else if (a == 3)
		{
			if (p.second > sy)
				sy = p.second;
		}
		else if (a == 4)
		{
			if (p.second < h)
				h = p.second;
		}
	}
	if (w <= sx || h <= sy)
		cout << 0 << endl;
	else
		cout << (w - sx) * (h - sy) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

struct UnionFind{
  vector<ll> par;
  vector<ll> sizes;

  UnionFind(ll n) : par(n), sizes(n, 1) {
    for(ll i=0;i<n;i++) par[i] = i;
  }

  ll find(ll x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(ll x, ll y) {
    return find(x) == find(y);
  }

  ll size(ll x) {
    return sizes[find(x)];
  }
};

int main(){

  ll n,m;
  cin >> n >> m;
  UnionFind tree(n);
  for(ll i=0;i<m;i++){
    ll a,b;
    cin >> a >> b;
    tree.unite(a-1,b-1);
  }

  ll ans=0;
  for(ll i=0;i<n;i++){
    ll a=tree.size(i);
    ans=max(ans,a);
  }
  cout << ans << endl;

}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===




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

	Vi P(N);
	for (int i = 0; i < N; ++i) {
		cin >> P[i];
	}

	// [i,i+K)と[i+1,i+1+K)がequivalentであるための必要十分条件:
	//     [i, i+1+K)の最小値がP[i]であり最大値がP[i+K]である
	//  <=>[i, i+K)のどの要素に対してもP[i]は小さく、P[i+K]は大きい
	//
	// 上の事実より、
	// [i,i+K)と[i+1,i+1+K)がequivalent"でない"ための必要十分条件は
	// 上の条件を満たさないことである。
	//
	// まず、[i,i+K)と[i+1,i+1+K)がequivalentでないようなiの個数を数える
	int ans = 1;
	set<int> s;
	for (int i = 1; i < K; ++i) {
		s.insert(P[i]);
	}
	for (int i = 0; i + K < N; ++i) {
		if (!(P[i] < *s.begin() && *s.rbegin() < P[i + K])) ++ans;
		s.erase(P[i + 1]); s.insert(P[i + K]);
	}

	// 上の数え上げで得られたものをそのまま答えとすることはできない
	// これは、ソートする区間に重なりがない場合でもequivalentになることがあるため
	// 重なりがない場合にequivalentとなるのはソート区間が元々昇順に並んでいるとき
	// このような場合はまとめて「1つ」として数える必要があるが、
	// 上の数え上げではこれらは重複して数えられている
	// そのため、その分減算する必要がある
	int cnt = 1;
	int dup = 0;
	for (int i = 0; i < N - 1; ++i) {
		if (P[i] < P[i + 1]) ++cnt;
		else cnt = 1;
		if (cnt == K) ++dup;
	}

	if (dup > 0) ans -= dup - 1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10368
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        long x = sc.nextLong();
        long y = sc.nextLong();
        long xySum = x + y;

        long ans = 0;

        if ((xySum) % 3 == 0) {
            long mod = 1000000007;

            long b = (2 * x - y) / 3;
            long a = x - 2 * b;

            if (a >= 0 && b >= 0) {
                long bunshi = 1;
                for (long i = a + b; i > a + b - Math.min(a , b); i--) {
                    bunshi = bunshi * i % mod;
                }
                long bunbo = 1;
                for (long i = Math.min(a, b); i > 0; i--) {
                    bunbo = bunbo * i % mod;
                }
                BigInteger gyakugen = new BigInteger(String.valueOf(bunbo)).modInverse(new BigInteger(String.valueOf(mod)));
                BigInteger ansD = gyakugen.multiply(new BigInteger(String.valueOf(bunshi))).mod(new BigInteger(String.valueOf(mod)));
                ans = ansD.longValue();
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s1 = "Sunny";
		String s2 = "Cloudy";
		String s3 = "Rainy";
		String s = sc.next();
		String ans = "";
		if(s.equals(s1))
			ans = s2;
		else if(s.equals(s2))
			ans = s3;
		else if(s.equals(s3))
			ans = s1;
		sc.close();
		System.out.println(ans);

	}
}



Measured memory_bytes: 35552
class Lichaotree:
    #区間は1-indexed
    #min
    def __init__(self, X):
        self.N = len(X)
        self.N0 = 2**(self.N-1).bit_length()
        self.comp = {v : k for k, v in enumerate(X)}
        self.inf = 10**19
        self.X = X + [self.inf]*(self.N0 - self.N)
        self.data = [None]*(2*self.N0)
        self.size = [0]*self.N0 + [1]*self.N0
        for i in range(self.N0-1, 0, -1):
            self.size[i] = 2*self.size[2*i]
        
    def f(self, line, x):
        return line[0]*x + line[1]

    def _update(self, k, line):
        
        if self.data[k] is None:
            self.data[k] = line
            return
        
        l = k - (1 << (k.bit_length() - 1))
        r = l + self.size[k]

        
        while True:
            if self.data[k] is None:
                self.data[k] = line
                return
            
            m = (l+r)//2
            lx = self.X[l]
            mx = self.X[m]
            rx = self.X[r-1]
            gl = (self.f(self.data[k], lx) > self.f(line, lx))
            gm = (self.f(self.data[k], mx) > self.f(line, mx))
            gr = (self.f(self.data[k], rx) > self.f(line, rx))
            if gl and gr:
                self.data[k] = line
                return
            
            if not gl and not gr:
                return
            
            if gm:
                self.data[k], line = line, self.data[k]
                gl = not gl
                
            if gl:
                r = m
                k = 2*k
            else:
                l = m
                k = 2*k+1
    
    def query(self, x):
        k = self.comp[x] + self.N0
        s = self.inf
        while k > 0:
            if self.data[k]:
                s = min(s, self.f(self.data[k], x))
            k = k >> 1
        return s
            
    def addline(self, line):
        self._update(1, line)

N, C = map(int, input().split())
H = list(map(int, input().split()))

T = Lichaotree(H)
dp = [10**19]*N
dp[0] = 0
T.addline((-2*H[0], H[0]**2))
for i in range(1,N):
    mi = T.query(H[i])
    dp[i] = mi + C + H[i]**2
    T.addline((-2*H[i], H[i]**2+dp[i]))
print(dp[-1])


Measured memory_bytes: 124116
N = gets.to_i
ps = gets.split.map(&:to_i)
count = 0
0.upto(ps.size - 3) do |i|
  if (ps[i] < ps[i+1] && ps[i+1] < ps[i+2]) || (ps[i] > ps[i+1] && ps[i+1] > ps[i+2])
    count += 1
  end
end
puts count


Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
#define fr(a, b, c) for(int a = b; a >= c; a--)
using namespace std;


//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}

const ll mod = 1e9 + 7;
const ll N = 2e5 + 7;
const ll inf = 1e9 + 5;



ll n,m, a, b, ans = 0, c= 0;
vector<ll> adj[N];
bool visited[N] = {false};
ll dp[N] = {};
void dfs(ll node){


    visited[node] = true;
    for (auto elem: adj[node]){
        if (!visited[elem]) dfs(elem);
        dp[node] = max(dp[node], dp[elem] + 1);
        ans = max(ans, dp[node]);
    }


}

int main()
{
    MohamedMotaz;
    cin >> n >> m;
    f(i,0,m){
        cin >> a >> b;
        adj[a].push_back(b);
    }

    for (int i = 1; i <= n; i++) dfs(i);

    cout << ans;
}





Measured memory_bytes: 11008
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int tot[37];
int main(){
	int n,m;cin>>n>>m;
	int x=n;while(x--){
		int y;cin>>y;
		while(y--){
			int z;cin>>z;tot[z]++;
		}
	}
	int ans=0;
	for(int i=1;i<=m;i++){
		if(tot[i]==n) ans++; 
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
const long long INF = 1LL << 60;

// --------write my code!!!!!----------//

int main(){
    int N; cin >> N;
    double res = 0;
    rep(i,N){
        double A; cin >> A;
        string s; cin >> s;
        if(s=="JPY") res+=A;
        else res+=A*380000;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
template <typename X>
struct BellmanFord{
  int node;
  vector<vector<pair<int,X>>> edge;
  vector<vector<int>> rev;  
  vector<X> d;
  const X inf = 1e+13;
  vector<bool> visit;//visited flag
  vector<bool> f;//Can node 's' visit 'g' ?
  
  BellmanFord(int _n){
    node = _n;
    edge.resize(node);
    rev.resize(node);
  }
  
  void add_edge(int from,int to,X cost){
    edge[from].push_back(make_pair(to,cost));
  }
  
  void add_rev(int from,int to){
    rev[from].push_back(to);
  }

  void dfs(int v){
    visit[v] = true;
    f[v] = true;
    for(auto w:rev[v]){
      if(visit[w]){
	continue;
      }
      dfs(w);
    }
  }

  void run_dfs(int g){//check each node can reach goal
    visit.assign(node,false);
    f.assign(node,false);
    f[g] = true;
    dfs(g);
  }

  void check_f(){
    rep(i,node){
      cout << i << ":" << f[i] << "\n";
    }
  }
  
  bool bellmanford(int s){
    d.assign(node,inf);
    d[s] = 0;
    bool flag = true;
    rep(i,node){
      rep(v,node){
	if(d[v]==inf) continue;
	for(auto w:edge[v]){
	  if(d[w.first]>d[v] + w.second){
	    d[w.first] = d[v] + w.second;
	    if(i==node-1){
	      if(f[w.first]){
		flag = false;
	      }
	      //	      flag = false;
	    }
	  }
	}
      }
    }
    return flag;
  }

  X get_d(int v){
    return d[v];
  }
  
};

int main()
{
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m);
  vector<ll> c(m);
  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }

  BellmanFord<ll> bf(n);

  rep(i,m) bf.add_edge(a[i],b[i],-c[i]);
  rep(i,m){
    bf.add_rev(b[i],a[i]);
  }
  bf.run_dfs(n-1);
  //  bf.check_f();
  
  if(bf.bellmanford(0)){
    cout << -bf.get_d(n-1) << "\n";
  }
  else{
    cout << "inf" << "\n";
  }
  
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

const ll N_MAX = 300005;

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

ll combination(ll C, ll D){
    if(C<D||C<1) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

    ll N;
    cin >> N;
    vector<ll> x(N);
    REP(i, N) cin >> x[i];

    ll res1 = 0;
    
    for(int i=0;i<N-2;i++){
        //dump(i)
        //dump(N-i)
        ll tmp = (1 - inv[N-1-i] + mod)%mod;
        res1 -= (tmp * x[i])%mod;
        res1 += mod;
        res1 %= mod;
    }

    for(int i=1;i<N-1;i++){
        //dump(i)
        ll tmp = (1 - inv[i+1] + mod)%mod;
        res1 += (tmp * x[i])%mod;
        res1 %= mod;
    }

    res1 *= fac[N-1];
    res1 %= mod;
    //dump(res1)

    ll res2 = 0;
    REP(i, N-1){
    	ll tmp = combination(N-1, N-i-1) * fac[i] % mod;

    	tmp *= fac[N-i-2];
    	tmp %= mod;

    	tmp *= (x[N-1] - x[i]);
    	tmp %= mod;

    	res2 += tmp;
    	res2 %= mod;
    }

    //dump(res1)
    //dump(res2)

    cout << (res1+res2)%mod << endl;
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;
int s[200005], cal[400005], tot = 0;
int main() {
	int n; scanf("%d", &n);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int a; scanf("%d", &a);
		if (i%2==1 && a%2==1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,int>;
using T = tuple<string,int,int>;

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

ll lcm(ll a, ll b){
  return a*b/gcd(a,b);
}

ll cnt(ll a, ll b){
  ll c = a / b;
  return c;
}
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  a--;
  ll ans = b - cnt(b,c) - cnt(b,d) + cnt(b,lcm(c,d));
  ans -= a - cnt(a,c) - cnt(a,d) + cnt(a,lcm(c,d));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, M, r int
	fmt.Scan(&N, &M)
	var s [][]int
	s = make([][]int, M)
	k := make([]int, M)
	p := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&k[i])
		s[i] = make([]int, k[i])
		for j := 0; j < k[i]; j++ {
			fmt.Scan(&s[i][j])
		}
	}
	for i := 0; i < M; i++ {
		fmt.Scan(&p[i])
	}
	for j := 0; j < 1<<uint(N); j++ {

		q := make([]int, 0)
		for i := 0; i < N; i++ {
			if (j & (1 << uint(i))) > 0 {
				q = append(q, i)
			}
		}
		if calc(s, p, q) {
			r++
		}
	}
	fmt.Println(r)
}
func calc(s [][]int, p, q []int) bool {
	for i := 0; i < len(s); i++ {
		cnt := 0
		for j := 0; j < len(s[i]); j++ {
			x := s[i][j]
			for k := 0; k < len(q); k++ {
				if q[k] == x-1 {
					cnt++
					break
				}
			}
		}
		if cnt%2 != p[i] {
			return false
		}
	}
	return true
}


Measured memory_bytes: 640
using namespace std;
typedef long long ll;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
 
int main(){
    int N;
    cin >> N;
    vector<ll> ans;
    while (N!=0)
    {
        vector<ll> a;
        a.resize(N);
        for (int i = 0; i < N; i++) cin >> a[i];
        ll thismin = 1e10;
        for (int i = 0; i < N;i++) {
            for (int n = 0; n < N; n++) {
                if (n == i) continue;
                thismin = min(thismin, abs(a[i] - a[n]));
            }
        }
        ans.push_back(thismin);
        cin >> N;
    }
    for (auto i : ans) {
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
n = int(input())
s = int(input())
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)
for i in range(1,n):
    t = int(input())
    s = (s*t)//gcd_core(s,t)

print(s)

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

int main(void)
{
    long long int n, k;
    cin >> n >> k;
    long long int min_value;

    min_value = n % k;
    min_value = min(min_value, abs(min_value - k));

    cout << min_value << endl;
    
    return 0;
}



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

ll gcd(ll a, ll b) {
    if (a < b) return gcd(b, a);
    ll tmp;
    while (tmp = a % b) {
        a = b;
        b = tmp;
    }
    return b;
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

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

    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll AA = (A - 1) - (A - 1) / C - (A - 1) / D + (A - 1) / lcm(C, D);
    ll BB = B - B / C - B / D + B / lcm(C, D);

    cout << BB - AA << endl;

    return 0;
}


Measured memory_bytes: 256
# E - Three Substrings

a = list(input())
b = list(input())
c = list(input())

A, B, C = len(a), len(b), len(c)

M = max(A, B, C)
cons = 6*M
a_not_match_b = [False] * 2 * cons
b_not_match_c = [False] * 2 * cons
a_not_match_c = [False] * 2 * cons

def fill_match_list(d1, d2, l):
    for i in range(len(d1)): # d1のそれぞれの文字についてd2全体でチェック
        for j in range(len(d2)):
            if d1[i] != d2[j] and d1[i] != "?" and d2[j] != "?":
                l[i-j+cons] = True # d1始点から見たd2始点の相対位置に格納。d1の始点が原点(cons)にあり、かつd1[i]とd2[j]が同座標にある場合の、d2の始点の座標
    return l

a_not_match_b = fill_match_list(a, b, a_not_match_b)
b_not_match_c = fill_match_list(b, c, b_not_match_c)
a_not_match_c = fill_match_list(a, c, a_not_match_c)

ans = 3*M
for b_idx in range(-2*M, 2*M):
    for c_idx in range(-2*M, 2*M):
        if not a_not_match_b[b_idx + cons] and not a_not_match_c[c_idx + cons] and not b_not_match_c[c_idx - b_idx + cons]:
            ans = min(ans, max(A, B + b_idx, C + c_idx) - min(0, b_idx, c_idx))

print(ans)

Measured memory_bytes: 48796
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<typename T>
struct CumulativeSum{
private:
    vector<T> s;
public:
    void init(vector<T>& v){
        s.push_back(0);
        for(int i=0; i<v.size(); i++){
            s.push_back(s.back() + v[i]);
        }
    }
    T sum(int l, int r){
        l = (l < 0 ? 0 : l);
        r = (r >= s.size() ? s.size()-1 : r);
        return s[r] - s[l];
    }
};

int N, K;
int a[5000];

bool dpL[5000][5000] ={}, dpR[5000][5000] ={};
CumulativeSum<int> sumR[5000];

signed main(){
    scanf("%d%d", &N, &K);
    rep(i, N){
        scanf("%d", a+i);
        a[i] = min(a[i], K);
    }

    rep(i, N){
        if(i == 0){
            dpL[0][0] = true;
            if(a[i] < K) dpL[0][a[i]] = true;;
        }
        else{
            rep(j, K){
                dpL[i][j] = dpL[i-1][j];
                if(j-a[i] >= 0) dpL[i][j] |= dpL[i-1][j-a[i]];
            }
        }
    }

    for(int i=N-1; i>=0; i--){
        if(i == N-1){
            dpR[N-1][0] = true;
            if(a[i] < K) dpR[N-1][a[i]] = true;
        }
        else{
            rep(j, K){
                dpR[i][j] = dpR[i+1][j];
                if(j-a[i] >= 0) dpR[i][j] |= dpR[i+1][j-a[i]];
            }
        }
    }
    rep(i, N){
        vector<int> tmp(K, 0);
        rep(j, K) tmp[j] = dpR[i][j];
        sumR[i].init(tmp);
    }

    int ans = 0;
    rep(i, N){
        if(a[i] >= K) continue;
        if(i == 0){
            bool needed = false;
            for(int j=max(0, K-a[0]); j<K; j++){
                needed |= dpR[1][j];
            }
            if(!needed) ans++;
        }
        else if(i == N-1){
            bool needed = false;
            for(int j=max(0,K-a[N-1]); j<K; j++){
                needed |= dpL[N-2][j];
            }
            if(!needed) ans++;
        }
        else{
            bool needed = false;
            rep(j, K){
                if(!dpL[i-1][j]) continue;
                needed |= (sumR[i+1].sum(K-j-a[i], K-j) > 0);
            }
            if(!needed) ans++;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 170156
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
int main() {

    string s;
    cin>>s;
    if (s[s.length() - 1] == 's')cout << s << "es";
    else cout << s << "s";
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

main(){

int a,b,c,i,d,e;
e=0;

scanf("%d %d %d",&a,&b,&c);

for(i=a;i<=b;i++){
d=c%i;
if(d==0) e++;
}

printf("%d\n",e);

return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>

using namespace std;

int main() {
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;
namespace bst = boost;

int main() {
  int N,K;
  string S;

  cin >> N >> K >> S;
  
  long long L = 0, R = 0, turn = 0, mx = 0, r =  0;
  
  while (++R < N){
    if (S[L] == S[R])
      r++;
    else {
      L = R;
      turn++;
    }
  }

  cout << r + min(turn, K * 2LL) << endl;

  return 0;
}


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

int main(){
    int a,b,c;
    int count = 0;
    cin >> a >> b >> c;
    for(int i = a;i<=b;i++){
        if(c % i==0) count += 1;
    }
    cout << count << endl;
}


Measured memory_bytes: 3056
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 500005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<pl, ll>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
 
bool isp[mx];
 
void sv(){
 
	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void bta_de_yarr(){
    
	ll a, b, i,j;
    cin>>a>>b;
    ll ans= 6- (a+b);
    cout<<ans;
	
	cout<<endl;
}

int main(){
    fst
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#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(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;
    cin >> n;
    int x[n];
    REP(i,n) cin >> x[i];
    ll ans=INF;
    FOR(i,1,101){
        ll sum=0;
        REP(j,n){
            sum+=(x[j]-i)*(x[j]-i);
        }
        chmin(ans,sum);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define sd(a) scanf("%lld",&a)
#define int long long
using namespace std;
const int maxn=2e5+10;
struct node{
    int num,pos;
    bool operator<(const node a)const{
        return num==a.num?pos>a.pos:num<a.num;
    }
};
priority_queue<node>q;
int a[maxn],b[maxn];
main(){
    int n;
    sd(n);
    for(int i=1;i<=n;++i){
        sd(a[i]);
    }
    node tmp;
    for(int i=1;i<=n;++i){
        sd(b[i]);
        tmp.num=b[i];
        tmp.pos=i;
        q.push(tmp);
    }
    int ans=0;
    while(!q.empty()){
        node now=q.top();
        q.pop();
        int pos=now.pos;
        if(b[pos]==a[pos])continue;
        if(b[pos]<a[pos]){puts("-1");return 0;}
        int d=b[pos]-a[pos];
        int cnt=b[pos-1?pos-1:n]+b[pos+1==n+1?1:pos+1];
        if(d<cnt){puts("-1");return 0;}
        ans+=d/cnt;
        b[pos]-=d/cnt*cnt;
        tmp.num=b[pos];
        tmp.pos=pos;
        q.push(tmp);
    }
    printf("%lld\n",ans);
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;
const long long inf = 1e15;

struct Move {
  int l, r, c, ind;
};

vector<Move> v;
long long d[N];
pair<int, int> rs[N];

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int l, r, c, i = 0; i < m; ++i) {
    scanf("%d%d%d", &l, &r, &c);
    v.push_back({l-1, r-1, c, i});
    rs[i] = {r-1, i};
  }
  d[0] = 0;
  for (int i = 1; i < n; ++i) d[i] = inf;
  sort(v.begin(), v.end(), [](const Move &x, const Move &y){return x.l < y.l;});
  sort(rs, rs+m);
  int r = 0;
  set<pair<long long, int>> s;
  map<int, long long> mp;
  for (int l = 0, i = 0; i < n; ++i) {
    if (s.size() == 0 && d[i] == inf) {
      puts("-1");
      return;
    }
    if (s.size())
      d[i] = min(d[i], s.begin()->first);
    for (; l < m && v[l].l == i; ++l) {
      d[v[l].r] = min(d[v[l].r], d[i]+v[l].c);
      s.emplace(d[i]+v[l].c, v[l].r);
      mp[v[l].ind] = d[i]+v[l].c;
    }
    for (; r < m && rs[r].first == i; ++r) {
      s.erase({mp[rs[r].second], i});
    }
  }
  printf("%lld", d[n-1]);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 14300
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N, D, A; cin >> N >> D >> A;
    vector<pair<ll, ll>> XH(N);
    REP(i, 0, N) cin >> XH[i].first >> XH[i].second;
    sort(ALL(XH));

    ll ans = 0;
    vector<ll> damage(N + 2);
    REP(i, 0, N) {
        damage[i + 1] += damage[i];
        // cout << "# i : " << i << ", damage : " << damage[i + 1] << endl;
        if (XH[i].second - damage[i + 1] < 1) continue;
        ll cnt = (XH[i].second - damage[i + 1] + A - 1) / A;
        
        int idx = lower_bound(ALL(XH), make_pair(XH[i].first + (ll)2 * D + 1, 0LL)) - XH.begin();
        damage[i + 1] += cnt * A;
        damage[idx + 1] -= cnt * A;
        // cout << "# i : " << i << ", cnt : " << cnt << ", idx : " << idx << endl;
        ans += cnt;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    int suna,jikan,ans;
    cin>>suna>>jikan;

    
    if(suna<jikan){
        ans=0;
        
    }else{
        ans=suna-jikan;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
lmax, rmin = 0, N
for _ in range(M):
    l, r = map(int, input().split())
    lmax = max(lmax, l)
    rmin = min(rmin, r)

if lmax == rmin:
    print(1)
elif lmax > rmin:
    print(0)
else:
    print(rmin-lmax+1)


Measured memory_bytes: 3060
#include<iostream>
#include<string>

using namespace std;

int main() {
	string str, cmd;
	string p; int n = 0;
	int a, b, q;
	cin >> str >> q;
	for (int i = 0; i < q; i++) {
		cin >> cmd >> a >> b; 
		if (cmd == "print") {
			for (int j = a; j <= b; j++)
				cout << str[j]; cout << endl;
		}
		else if (cmd == "reverse") {
			for (int j = 0; j < (b - a + 1)/2; j++)
				swap(str[(a + j)], str[(b - j)]);
		}
		else if (cmd == "replace") {
			cin >> p;
			for (int k = a; k <= b; k++) {
				str[k] = p[n++];
			}n = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1212
import math

MOD = 10**9+7


def make_combination_table(n):
    fact = [1]
    for i in range(1, n+1):
        fact.append(fact[i-1] * i % MOD)

    ifact = [0] * (n+1)
    ifact[n] = pow(fact[n], MOD-2, MOD)
    for i in range(n, 0, -1):
        ifact[i-1] = ifact[i] * i % MOD
    return (fact, ifact)


def mod_combination(n, r, table):
    if r > n:
        return 0
    return table[0][n] * table[1][n - r] * table[1][r] % MOD


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    c_table = make_combination_table(n)

    a.sort()
    a_max = 0
    for i in range(n):
        a_max += a[i] * mod_combination(i, k-1, c_table) % MOD

    a.sort(reverse=True)
    a_min = 0
    for i in range(n):
        a_min += a[i] * mod_combination(i, k-1, c_table) % MOD

    print((a_max - a_min) % MOD)


main()


Measured memory_bytes: 15452
while formula = gets
	formulas = formula.split(' ').map(&:to_f)
	f_x = ((formulas[2] * formulas[4]) - (formulas[1] * formulas[5])) / ((formulas[0] * formulas[4]) - (formulas[1] * formulas[3]))
	f_y = ((formulas[0] * formulas[5]) - (formulas[2] * formulas[3])) / ((formulas[0] * formulas[4]) - (formulas[1] * formulas[3]))

	x = f_x.round(3)
	y = f_y.round(3)
	x = x != 0 ? x : 0
	y = y != 0 ? y : 0
	puts sprintf('%.3f %.3f', x, y)
end

Measured memory_bytes: 8832
#include <stdio.h>
int main()
{
    int r, g, b, n, ans = 0;
    int sr, sg, sb;
    scanf("%d%d%d%d", &r, &g, &b, &n);
    for (int i = 0; i <= n; i += r)
    {
        for (int j = i; j <= n; j += g)
        {
            if ((n - j) % b == 0)
            {
                ans++;
            }
        }
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
void insert_sort(int a[],int n)
{
    int i,j,k;
    int key;
    for (i=1;i<n;i++)
    {
        key=a[i];
        j=i-1;
        while(j>=0 && a[j]>key)
        {
            a[j+1]=a [j];
            j--;

        } a[j+1]=key;
        for(k=0;k<n;k++)
        {

            if(k!=n-1)
                printf("%d ",a[k]);
            else
                printf("%d\n",a[k]);
        }

    }
}
int main()
{
    int n;
    int i,j;
    int a[110];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)


   i<n-1? printf("%d ",a[i]): printf("%d\n",a[i]);

   insert_sort(a,n);

    return 0;
}



Measured memory_bytes: 2680
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;

int main(){

    int n;
    cin >> n;
    vector<int> v(n);
    REP(i,n){
        scanf("%d", &v[i]);
    }
    int now_where = 1,pre_where,result=0;
    while(v[now_where-1]!=-1&&now_where!=2){
        pre_where = now_where;
        now_where=v[now_where-1];
        v[pre_where-1] = -1;
        result++;
    }
    cout << ((now_where == 2) ? result : -1) << endl;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

#ifdef LOCAL
#include<prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, M;
    cin >> N >> M;

    vi a(M);
    REP(i, M) cin >> a[i];

    ll dp[N + 1];
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    int j = 0;
    REP(i, N + 1) {
        if (j < M) if (a[j] == i) {
            ++j;
            continue;
        }

        dp[i+1] = (dp[i+1] + dp[i]) % MOD;
        dp[i+2] = (dp[i+2] + dp[i]) % MOD;
    }

    cout << dp[N] << endl;
}


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

#define INF (1<<30)
#define MAX 100010

int dp[MAX];
int h[MAX];

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

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

	for(int i=1;i<MAX;i++) dp[i]=INF;
	dp[0]=0;

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

	cout<<dp[n-1]<<endl;


	return 0;
}


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

int main()
{
    char str[100];
    int a;
    char r;
    cin>>a;
    cin>>str;
    if(a>=3200){
        for(int i=0;str[i]!='\0';i++){

            cout<<str[i];

        }
    }else{
            cout<<"red"<<"\n";
        }
    
    return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

x = -1
y = -1
z = -1
if Y%1000 == 0:
  Y = Y//1000
  n = (Y-N)//9
  for i in range(n+1):
    if ((Y-N)-9*i)%4==0 and (Y-N)>=9*i and N>=i+((Y-N)-9*i)//4:
      x = i
      y = ((Y-N)-9*i)//4
      z = N-x-y
      break
print(x,y,z,sep=' ')
  

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int *tree[100001];

int main(void){

    int N;

    scanf("%d", &N);

    int tree_s[N+1];

    for(int i = 0; i <= N; i++){
        tree_s[i] = 0;
    }

    int a, b;

    for(int i = 0; i < N-1; i++){
        scanf("%d%d", &a, &b);
        tree[a] = realloc(tree[a], sizeof(int)*(tree_s[a]+1));
        tree[a][tree_s[a]] = b;
        tree_s[a]++;
        tree[b] = realloc(tree[b], sizeof(int)*(tree_s[b]+1));
        tree[b][tree_s[b]] = a;
        tree_s[b]++;
    }

    int parent[N+1], depth[N+1], color[N+1];

    for(int i = 0; i <= N; i++){
        parent[i] = -1, depth[i] = -1, color[i] = -1;
    }

    parent[1] = 0, depth[1] = 0, color[1] = 1, color[N] = 0;

    int queue[N];

    queue[0] = 1;

    int s = 0, e = 0, tail = 0;

    int cur, next;

    while(tail < N-1){
        for(int i = s; i <= e; i++){
            cur = queue[i];
            for(int j = 0; j < tree_s[cur]; j++){
                next = tree[cur][j];
                if(next == parent[cur]){
                    continue;
                }
                parent[next] = cur;
                depth[next] = depth[cur] + 1;
                tail++;
                queue[tail] = next;
            }
        }
        s = e + 1;
        e = tail;
    }

    cur = N;

    for(int i = depth[N]-1; i > depth[N] / 2; i--){
        cur = parent[cur];
        color[cur] = 0;
    }
    for(int i = depth[N] / 2; i > 0; i--){
        cur = parent[cur];
        color[cur] = 1;
    }

    for(int i = 1; i < N; i++){
        cur = queue[i];
        if(color[cur] == -1){
            color[cur] = color[parent[cur]];
        }
    }

    int black = 0, w = 0;

    for(int i = 2; i < N; i++){
        if(color[i] == 1){
            black++;
        }else{
            w++;
        }
    }

    if(black > w){
        printf("Fennec\n");
    }else{
        printf("Snuke\n");
    }

    return 0;
}

Measured memory_bytes: 7468
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long int 

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int n,m;

int factorial(int n) 
{ 
	int res = 1;
    for(int i=1;i<=n;i++){
    	res*=i;
    	res%=mod;
    } 
    return res;
}

int poi(int a,int b){
	int res = 1;
	while(b>0){
		if((b&1)){
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b = b>>1;
	}
	return res;
}


signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	cin>>n>>m;
	int A = 2*m - n;
	int B = 2*n - m;
	if(A>=0&&B>=0&&A%3==0&&B%3==0){
		A/=3;
		B/=3;
		int X = factorial(A);
		int Y = factorial(B);
		int N = factorial(A+B);
		int invX = poi(X,mod-2);
		int invY = poi(Y,mod-2);
		int output = N;
		output*=invX;
		output%=mod;
		output *=invY;
		output%=mod;
		cout<<output;
	}
	else cout<<0<<endl;
	return 0;
}


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

int N;
int A[100];

////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
void outline(void)
{
	int i;
	for ( i = 0 ; i < N ; i++ ) {
		if ( i > 0 ) {
			printf(" ");
		}
		printf("%d", A[i]);
	}
	printf("\n");
}
////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int main(void){
	int i;
	int j;
	int v;

	scanf("%d", &N);

	for ( i = 0 ; i < N ; i++ ) {
		scanf("%d", &A[i]);
	}

	outline();

	for ( i = 1 ; i < N ; i++ ) {

		v = A[i];
		j = i - 1;

		while (j >= 0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
			A[j+1] = v;
		}

		outline();
	}

	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {        
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    int num = *min_element(v.begin(), v.end());
    int index = 0;
    int res = 0;
    while (index < n) {
        if (v[index] == num) {
            index++;
            continue;
        }
        int begin = index;
        while (index < n && v[index] != num) {
            index++;
        }
        if (index == n) {
            cout << res + (n - begin) / (k - 1) + ((n - begin) % (k - 1) > 0 ? 1 : 0) << endl;
            return 0;
        } else {
            res = res + (index - begin) / (k - 1) + ((index - begin) % (k - 1) > 0 ? 1 : 0);
            if ((index - begin) % (k - 1) == 0) {
                index++;
            } else {
                index = (index - begin) / (k - 1) * (k - 1) + k;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3632
package main

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

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func strToInts(str string) []int {
	var res []int
	for _, s := range strings.Split(str, " ") {
		n, _ := strconv.Atoi(s)
		res = append(res, n)
	}
	return res
}

func main() {
	sc := bufio.NewScanner(os.Stdin)

	readLine(sc)
	hs := strToInts(readLine(sc))

	top := hs[0]
	cnt := 1
	for _, h := range hs[1:] {
		if h >= top {
			top = h
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 640
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, T = list(map(int, sys.stdin.readline().split()))

    ret = 1001
    for n in range(N):
        c, t = list(map(int, sys.stdin.readline().split()))
        if T >= t: ret = min(c, ret)

    print('TLE' if ret == 1001 else ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060