akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    map<ll, int, greater<ll>> mp;
    mp[0] = 4;

    rep(i, n)
    {
        int a;
        cin >> a;
        mp[a]++;
    }

    ll ans[2];
    int i = 0;

    for (auto e : mp)
    {
        if (e.second >= 2)
        {
            ans[i] = e.first, i++;
            if (e.second >= 4)
                ans[i] = e.first, i++;
        }
        if (i >= 2)
            break;
    }

    OP(ans[0] * ans[1]);

    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <atcoder/all>
#include <vector>
using ll=long long;
using namespace std;
using namespace atcoder;

int main(){
    int N,M;
    cin>>N>>M;
    dsu d(N);

    int a,b;
    for(int i=0;i<M;i++){
        cin>>a>>b;
        a--;b--;
        d.merge(a,b);
    }

    auto group=d.groups();

    cout<<group.size()-1<<endl;

    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

tuple<int, int> Solve() {
  string s;
  cin >> s;
  int n = s.length();
  for (int i = 0; i + 1 < n; i++) {
    if (s[i] == s[i + 1]) {
      return make_tuple(i + 1, i + 2);
    }
  }
  for (int i = 0; i + 2 < n; i++) {
    if (s[i] == s[i + 2]) {
      return make_tuple(i + 1, i + 3);
    }
  }
  return make_tuple(-1, -1);
}

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

  int a, b;
  tie(a, b) = Solve();
  cout << a << " " << b << endl;
}

Measured memory_bytes: 512
//22
#include<iostream>
#include<algorithm>
#include<utility>

using namespace std;

int main(){
  for(int m;cin>>m,m;){
    pair<int,int> co[200];
    for(int i=0;i<m;i++){
      cin>>co[i].first>>co[i].second;
    }
    int n;
    cin>>n;
    pair<int,int> st[1000];
    for(int i=0;i<n;i++){
      cin>>st[i].first>>st[i].second;
    }
    sort(st,st+n);
    for(int i=0;;i++){
      int x=st[i].first-co[0].first;
      int y=st[i].second-co[0].second;
      int j;
      for(j=1;j<m;j++){
	if(!binary_search(st,st+n,make_pair(co[j].first+x,co[j].second+y)))break;
      }
      if(!(j<m)){
	cout<<x<<' '<<y<<endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
use std::cmp;
use std::io::*;
use std::str::FromStr;

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

fn read_str() -> Vec<char> {
    return read::<String>().chars().collect();
}

fn solve1(b: &Vec<char>) -> usize {
    let mut max_len = 0;
    for begin in 0..b.len() {
        for end in begin..b.len() + 1 {
            //b[begin..end].iter().all(|c1| "ATGC".chars().any(|c2| c1 == c2));
            if b[begin..end]
                .iter()
                .all(|c| "ATGC".chars().collect::<Vec<char>>().contains(c))
            {
                let len = end - begin;
                max_len = cmp::max(max_len, len);
            }
        }
    }
    max_len
}

#[allow(non_snake_case)]
fn is_ATGC_str(b: &Vec<char>) -> bool {
    b.iter()
        .all(|c| "ATGC".chars().collect::<Vec<char>>().contains(c))
}

fn solve2(b: &Vec<char>) -> usize {
    // ..=非対応
    (0..b.len())
        .flat_map(|begin| (begin..b.len() + 1).map(move |end| b[begin..end].to_vec()))
        .filter(|s| is_ATGC_str(s))
        .map(|s| s.len())
        .max()
        .unwrap()
}

pub fn main() {
    let b = read_str();
    println!("{}", solve2(&b));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  int n;
  cin >> n;
  vector<P> r,l;
  rep(i,n) {
      string s;
      cin >> s;
      int r1=0,l1=0;
      int a=s.size();
      rep(j,a) {
          if(s[j]=='(') r1++;
          else {
              if(r1>0) r1--;
              else l1++;
          }
      }
      if(r1>=l1) {
          l.emplace_back(l1,r1-l1);
      }
      else {
          r.emplace_back(r1,l1-r1);
      } 
      
  }
  sort(l.begin(),l.end());
  sort(r.begin(),r.end());
  int ls=0,rs=0;
  bool ok=true;
  rep(i,l.size()) {
      if(ls<l[i].first) ok=false;
      ls+=l[i].second;
  }
  rep(i,r.size()) {
      if(rs<r[i].first) ok=false;
      rs+=r[i].second;
  }
  if(rs!=ls) ok=false;
  YesNo(ok);
  return 0;
}


Measured memory_bytes: 19064
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define int LL
#define eps 1e-8
#define fi first
#define se second
#define endl '\12'
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
constexpr int mod = 1e9+7;
constexpr int Erica = 998244353;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ex_gcd(ll a, ll b, ll& x, ll& y){if(!b){x=1;y=0;return a;}int ret=ex_gcd(b,a%b,y,x);y-=a/b*x;return ret;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
int norm(int x) { return x >= mod ? (x - mod) : x; }
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
inline ll get_inv(ll a) { ll x, y; ex_gcd(a, mod, x, y); return norm(x + mod);}
template<class T>inline void umin(T &x, T y) {x = x > y ? y : x;}
template<class T>inline void umax(T &x, T y) {x = x < y ? y : x;}
template<class T>inline void dec(T &x, T y) {x -= y; if(x < 0) x += mod;}
template<class T>inline void add(T &x, T y) {x += y; if(x >= mod) x -= mod;}
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260817, P_2=999998639;
int32_t main()
{
    int n , k;
    cin >> n >> k;
    if(k == 0) {
        cout << 1ll * n * n << endl;return 0;
    }
    ll ans = 0;
    for(int i = k + 1; i <= n; i++){
        int now = i-k, num = n / i;
        int xx = num * i;
        int kk = n - xx;
        int tp = 0;
        if(kk >= k) tp = kk-k+1;
        ans += tp;
        ans += now * num;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
<?php

class Scanner
{
  private $arr = [];
  private $count = 0;
  private $pointer = 0;

  public function next()
  {
    if ($this->pointer >= $this->count) {
      $str = trim(fgets(STDIN));
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    ++$this->pointer;

    return $result;
  }

  public function hasNext()
  {
    return $this->pointer < $this->count;
  }

  public function nextInt()
  {
    return (int) $this->next();
  }

  public function nextDouble()
  {
    return (float) $this->next();
  }
}

$sc = new Scanner();
$n = $sc->nextInt();
$k = $sc->nextInt();

$array = [];
for($i=0;$i<$k;$i++){
  $array[] = $sc->nextInt();
}

function confirm($price){
  global $array;
  $flag = true;
  foreach($array as $key=>$value){
    if(strpos("a".(string)$price, (string)$value) > 0){
      $flag = false;
    }
  }
  return $flag;
}

for($i=$n;$i<$n*100;$i++){
  if(confirm($i) == true){
    $answer = $i;
    break;
  } else {
    continue;
  }
}

echo $answer . PHP_EOL;

Measured memory_bytes: 16272
n=int(input())

t=list(map(int,input().split()))
a=list(map(int,input().split()))
#nは10**5以下

kakute=[0]*n
kakute[0]=1

if n==1:
    if t[0]!=a[0]:
        print(0)
        exit()

for i in range(1,n):
    if t[i]>t[i-1]:
        kakute[i]=1

a=a[::-1]
ans=1

for i in range(1,n):
    index=n-i-1
    #青木が確定したとき
    if a[i]>a[i-1]:
        #矛盾ないか
        if a[i]>t[index]:
            print(0)
            exit()
        #青木＆高橋確定
        elif kakute[index]==1:
            if a[i] != t[index]:
                print(0)
                exit()
    #青木は確定じゃない
    else:
        #高橋確定
        if kakute[index]==1:
            if t[index]>a[i]:
                print(0)
                exit()
        #誰も確定していない
        else:
            ans=ans*min(a[i],t[index])%(10**9+7)

print(ans%(10**9+7))


            

        









Measured memory_bytes: 82148
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy
from functools import reduce



def main():
    n = int(input())
    x_list = []
    for i in range(n):
        x = int(input())
        x_list.append(x)

    l = list(set(x_list))
    print(len(l))


if __name__ == "__main__":
    main()


Measured memory_bytes: 69540
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
using namespace std;
using ll = long long;
using ld = long double;
const int mxn = 1e6;
const int mx = 110;
int a[mxn];

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

	for(int x=1; x<mx; x++) for(int y=1; y<mx; y++) for(int z=1; z<mx; z++) {
		int val = x*x+y*y+z*z+x*y+y*z+z*x;
		a[val]++;
	}

	int n; cin>>n;
	for(int i=1; i<=n; i++) cout << a[i] << '\n';

	return 0;
}


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

#define MAX 100
static const int WHITE = 0; // not visit
static const int GRAY = 1; // visited
static const int BLACK = 2; // searched

int n;
int M[MAX][MAX] = { 0 };
int distance[MAX] = { 0 }; // ?????????????§??????????????????¢
int v_states[MAX] = { WHITE };


void breadthFirstSearch() {
	queue<int> vertices;

	vertices.push(0); // ?§????
	while (!vertices.empty()) {
		int u = vertices.front();
		v_states[u] = GRAY;
		vertices.pop();
		bool is_connected = false;
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 1 && v_states[v] == WHITE) {
				::distance[v] = ::distance[u] + 1;
				vertices.push(v);
				v_states[v] = GRAY;
			}
		}
	}
	return;
}

int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		int k, u;
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	breadthFirstSearch();
	for (int i = 0; i < n; i++) {
		if (i && v_states[i] == WHITE) {
			::distance[i] = -1;
		}
		cout << i + 1 << ' ' << ::distance[i] << endl;
	}

	return 0;

}

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

#define fi first
#define se second

const int N = 110;

using namespace std;

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        string s;
        cin >> s;
        int A = 0, B = 0;
        for(char c: s){
                if(c == 'N') A |= 1;
                else if(c == 'W') B |= 1;
                else if(c == 'S') A |= 2;
                else B |= 2;
        }
        if(A % 3 || B % 3){
                cout << "No" << "\n";
        } else{
                cout << "Yes" << "\n";
        }
}


Measured memory_bytes: 256
-- Try AtCoder
-- author: Leonardone @ NEETSDKASU

import qualified Data.IntSet as S

main = printAns . solve . map (map read . words) . lines =<< getContents

printAns c = putStrLn $ if c then "IMPOSSIBLE" else "POSSIBLE"

solve ((n:_):xs) = ans where
    ans = S.null $ uncurry S.intersection $ foldl f (S.empty, S.empty) xs
    f s@(s1, sN) [x,y] 
        | x == 1    = (S.insert y s1, sN)
        | y == n    = (s1, S.insert x sN)
        | otherwise = s



Measured memory_bytes: 50556
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    vector<int> strs(N);
    for (int i = 0; i < N; ++i)
    {
        if (S[i] == 'R') strs[i] = 0;
        else if (S[i] == 'G') strs[i] = 1;
        else strs[i] = 2;
    }
    // 全探索は 4000C3 = 10^9 で間に合わない
    // N^2 で抑えられる？
    vector<vector<int>> rgbNums(3, vector<int>(N + 1, 0));
    for (int i = 1; i <= N; ++i)
    {
        for (int rgb = 0; rgb < 3; ++rgb)
        {
            rgbNums[rgb][i] = rgbNums[rgb][i - 1];
        }
        ++rgbNums[strs[i - 1]][i];
    }
    LLONG ans = 0;
    for (int i = 1; i <= N; ++i)
    {
        int si = strs[i - 1];
        for (int j = i + 1; j <= N; ++j)
        {
            int sj = strs[j - 1];
            if (si != sj)
            {
                int sk = (si == 0) ? ((sj == 1) ? 2 : 1)
                    : ((si == 1) ? ((sj == 0) ? 2 : 0) : ((sj == 0) ? 1 : 0));
                // j+1番目 ~ N番目 の範囲で sk になる物の数
                ans += rgbNums[sk][N] - rgbNums[sk][j];
                int ngK = j + j - i;
                if (ngK <= N && strs[ngK - 1] == sk)
                {
                    --ans;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;

ll e, o, ans;
 
int main(){
	cin >> e >> o;
	e--;
	o--;
	ans += (e * (e + 1)) / 2;
	ans += (o * (o + 1)) / 2;
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, q;
int INF = 1e6;
vector<vector<int>> graph;
vector<long long> ans;
vector<bool> used;
 
int main() {
    cin >> n >> q;
    graph = vector<vector<int>>(n);
    ans = vector<long long>(n, 0);
    used = vector<bool>(n, false);
    for(int i = 0; i < n-1; ++i) {
        long long a, b;
        cin >> a >> b;
        a--; b--;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);
    }

    queue<long long> que;
 
    for(int i = 0; i < q; ++i) {
        long long p, x;
        cin >> p >> x;
        p--;
        ans.at(p) += x;
    }

    que.push(0);
    used.at(0) = true;
 
    while(!que.empty()) {
        long long first = que.front();
        que.pop();
        int len = graph.at(first).size();
        for(int j = 0; j < len; ++j) {
            int next = graph.at(first).at(j);
            if(!used.at(next)) {
                ans.at(next) += ans.at(first);
                used.at(next) = true;
                que.push(next);
            }
        }
    }
 
    for(int i = 0; i < n; ++i) {
        cout << ans.at(i) << " ";
    }
 
}

Measured memory_bytes: 17140
import sys
N,A,B = map(int,input().split())

if not ( 1 <= N <= 10**18 and 0 <= A and 0 <= B and 0 < A + B <= 10**18 ): sys.exit()
if not ( isinstance(N,int) and isinstance(A,int) and isinstance(B,int) ): sys.exit()

count = N // (A+B)
remind = N % (A+B) if N % (A+B) <= A else A
    
print(count * A + remind)

Measured memory_bytes: 9104
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

m,k = list(map(int, input().split()))
a = list(map(int, input().split()))

a.sort()
ans1 = 0
ans2 = 0
for h in range(m-k+1):

    n = (m-h-1)
    r = (k-1)
    cmb1 = cmb(n, r, mod)
    ans1 += (a[m - h - 1]) * cmb1 % mod
    ans2 += (a[h]) * cmb1 % mod

ans = (ans1 - ans2) % mod

print(ans)



Measured memory_bytes: 26648
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
map<string, bool> mark;
int n, ans;
string s;
int main() {
	cin >> n;
	while (n--) {
		cin >> s;
		if (mark[s] == 0) {
			ans++;
			mark[s] = 1;
		}
	}
	cout << ans;
	return 0;
}

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


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

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

sort(v.begin(), v.end());
int c = 0;

if(sum % (4 * m) == 0){
  c = sum / (4 * m);
}
else{
  c = sum / (4 * m) + 1;
}

bool f = true;
for(int i = n - 1; i >= n - m ; i--){
  if(v[i] < c){
    f = false;
    break;
  }
}
if(f){
  cout << "Yes" << endl;
}
else
{
  cout << "No" << endl;
}

}

Measured memory_bytes: 256
a,b,c,d,e,f = map(int, input().split())

per = 0
ans = []

for i in range(f//(100*a) + 1):
    for j in range(f//(100*b) + 1):
        w = i * a * 100 + j * b * 100
        if w > f or w == 0:
            break
        for k in range((e * w//100)//c + 1):
            for l in range((e * w//100)//d + 1):
                if e * w//100 < c * k + d * l or w + c * k + d * l > f:
                    break
                now = 100 * (c*k+d*l) / (w+c*k+d*l)
                if per < now:
                    per = now
                    ans = [w+c*k+d*l, c*k+d*l]
if ans == []:
    print(100*a, 0)
else:
    print(ans[0], ans[1])



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

using namespace std;

int main(){
int n,k,x,y;
cin>>n>>k>>x>>y;
int sum=0;
if(n>k){
for(int i=0;i<k;i++){
     sum+=x;
}
for(int i = 0;i<(n-k);i++){
     sum+=y;
}
}
else {
     for(int i = 0 ;i<n;i++){
         sum+=x;
     }
}
cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 256
N, K = gets.split.map &:to_i
max = (N - 2) * (N - 1) / 2
if K > max
  p -1
  exit
end

cnt = 0
ans = []
(1...N).each{|i|
  ans << [0, i]
}
(1...N).each{|i|
  break if cnt >= max - K
  (i+1...N).each{|j|
    break if cnt >= max - K
    ans << [i, j]
    cnt += 1
  }
}
p ans.size
ans.each{|from, to|
  puts [from+1, to+1]* " "
}


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

int getSum(int n)
{
    int res = 0;
    for (; n; n /= 10)
        res += n % 10;
    return res;
}

int main()
{
    //freopen("input.txt", "r", stdin);


    int n;
    scanf("%d", &n);

    int ans = 1e8;
    for (int a = 1; a < n; ++a)
        ans = min(ans, getSum(a) + getSum(n - a));

    printf("%d", ans);

}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
#define VMAX 100
static const long long INFTY = (1LL<<32);

long long D[VMAX][VMAX];
int n;

void warshallFloyd() {
    for (int k=0; k<n; k++) {
        for (int i=0; i<n; i++) {
            if (D[i][k]==INFTY) continue;
            for (int j=0; j<n; j++) {
                if (D[k][j]==INFTY) continue;
                D[i][j] = min(D[i][j], D[i][k]+D[k][j]);
            }
        }
    }
}

int main() {
    int s, t, E;
    long long d;

    scanf("%d %d", &n, &E);

    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            D[i][j] = INFTY;
        }
        D[i][i] = 0;
    }

    for (int i=0; i<E; i++) {
        scanf("%d %d %lld", &s, &t, &d);
        D[s][t] = d;
    }

    warshallFloyd();

    for (int i=0; i<n; i++) {
        if (D[i][i]<0) {
            printf("NEGATIVE CYCLE\n");
            return 0;
        }
    }

    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            if (j==0) {
                if (D[i][j]>=INFTY) printf("INF");
                else printf("%lld", D[i][j]);
            } else {
                if (D[i][j]>=INFTY) printf(" INF");
                else printf(" %lld", D[i][j]);
            }
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2812
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

	int A, B;
	cin >> A >> B;
	cout << A * B << endl;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)<<endl;
    return 0;
}


Measured memory_bytes: 3640
MOD = 10**9+7
h,w = map(int,input().split())
grid = [list(input()) for _ in range(h)]

dp = [[0]*w for _ in range(h)]
dp[0][0] = 1
for i in range(h):
  for j in range(w):
    if grid[i][j]=='#':
      continue
    if i>0:
      dp[i][j] += dp[i-1][j]
    if j>0:
      dp[i][j] += dp[i][j-1] 

print(dp[-1][-1] % MOD)      

Measured memory_bytes: 165336
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (b / a >= c) {
		cout << c << endl;
	}
	else {
		cout << b / a << endl;
	}
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll x,y,z,a=0,b=0,c=0,d=0,sum,ans,total,cnt,n,m,k,p,kase,i;
string s1,s2;
#define N 100001
#define MX 1000000001



int main()
{

       T{
           cin>>s1;
           if(s1=="AC")a++;
           else if (s1=="TLE")b++;
           else if (s1=="WA")c++;
           else d++;

       }
       ans=4;
       cout<<"AC x "<<a<<endl;
       cout<<"WA x "<<c<<endl;
       cout<<"TLE x "<<b<<endl;
       cout<<"RE x "<<d<<endl;



    return 0;
}
// Happy Coding  (:


Measured memory_bytes: 3688
N = int(input())
p = list(map(int, input().split()))

A = [0] * N
B = [N * (N + 1) // 2] * N

for i in range(N):
  A[p[i] - 1] += i + 1

cnt = A[0]
A[0] = 1
for i in range(1, N):
  B[i] -= cnt
  cnt += A[i]
  A[i] += A[i - 1]

print(" ".join(list(map(str, A))))
print(" ".join(list(map(str, B))))


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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;

//atcoder 
//begineer 140
//a

int main()
{
	int n;
	cin>>n;
	cout<<n*n*n<<endl;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn readv<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn readvv<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| readv()).collect()
}

// #[derive(Debug)]
// enum Query {
//     Reverse,
//     Add(usize, String),
// }

fn main() {
    let s: String = read();
    let qn: usize = read();
    // let mut qq: Vec<Query> = vec![];

    let mut head: String = "".into();
    let mut tail: String = "".into();
    let mut reversed = false;
    for _ in 0..qn {
        // get query
        let tmp: String = read();
        let mut it = tmp.split_whitespace();
        let qtype: u64 = it.next().map(|v| v.parse().ok().unwrap()).unwrap();
        if qtype == 1 {
            reversed = !reversed;
        } else {
            let add_to_head = it.next().map(|v| v.parse::<u8>().ok().unwrap()).unwrap() == 1;
            let s = it.next().unwrap().to_string();
            let s = if reversed {
                s.chars().rev().collect()
            } else {
                s
            };

            match (reversed, add_to_head) {
                (false, true) => {
                    head = s + &head;
                },
                (true, true) => {
                    tail = tail + &s;
                },
                (false, false) => {
                    tail = tail + &s;
                },
                (true, false) => {
                    head = s + &head;
                }
            }
        }
        // qq.push(query);
    }

    let rtmp = head + &s + &tail;
    let result = if reversed {
        rtmp.chars().rev().collect()
    } else {
        rtmp
    };
    println!("{}", result);
    // println!("{:?}", qq);

}
        // let tmp: String = read();
        // let mut it = tmp.split_whitespace();
        // let qtype: u64 = it.next().map(|v| v.parse().ok().unwrap()).unwrap();
        // let query = if qtype == 1 {
        //     Query::Reverse
        // } else {
        //     let orient: usize = it.next().map(|v| v.parse().ok().unwrap()).unwrap();
        //     Query::Add(orient, it.next().unwrap().to_string())
        // };


Measured memory_bytes: 4604
import java.io.*;
import java.util.*;
import static java.lang.System.in;

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    // no self-loop or multiple edges
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        for(int i=1;i<=n;i++){
            ans += i-1;
        }
        return ans;
    }
}



Measured memory_bytes: 21844
#include <cstdio>

int W, a, b;
int res;

int main()
{
	scanf("%d %d %d", &W, &a, &b);
	if(a <= b){
		res = b-(a+W);
		if(res < 0)
			res = 0;
	}
	else{
		res = a-(b+W);
		if(res < 0)
			res = 0;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  string s;
  cin>>s;
  if(s[1] == 'B'){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3720
#include <cstdio>

int main() {
  int N;
  scanf("%d", &N);

  char s;

  puts("0");
  fflush(stdout);

  scanf(" %c%*s", &s);
  if (s == 'V') return 0;  

  int lb=0, ub=N;
  while (ub-lb > 1) {
    int mid=(lb+ub)>>1;
    printf("%d\n", mid);
    fflush(stdout);

    char t;
    scanf(" %c%*s", &t);
    if (t == 'V') return 0;
    ((mid&1)^(s==t)? lb:ub) = mid;
  }
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long N)
{
    queue<int> a;
    int sum = 0;
    if (N != 1)
    {

        for (int i = 1; i <= N; i++)
        {
            sum += i;
            a.push(i);
            if (sum - i < N && N <= sum)
            {
                break;
            }
        }

        while (!a.empty())
        {
            int pop = a.front();
            a.pop();
            if (pop != (sum - N))
            {
                cout << pop << endl;
            }
        }
    }else{
        cout << 1 << endl;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s[0]=='S' && s[1]=='S' && s[2]=='S')
     cout<<0<<endl;
    else if((s[0]=='R' && s[1]=='R' && s[2]=='S') || (s[0]=='S' && s[1]=='R' && s[2]=='R'))
     cout<<2<<endl;
     else if((s[0]=='R' && s[1]=='S' && s[2]=='S') || (s[0]=='S' && s[1]=='R' && s[2]=='S') || (s[0]=='S' && s[1]=='S' && s[2]=='R') || (s[0]=='R' && s[1]=='S' && s[2]=='R'))
     cout<<1<<endl;
     else
     cout<<3<<endl;
     }

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, temp,cnt = 0;
    cin >> n;
    vector<int> vec,vec2;
    for(int i= 0; i < n ; ++i){
        cin >> temp;
        vec.push_back(temp);
    }
    vec2 = vec;
    sort(vec.begin(), vec.end());
    for(int j = 0; j < n; ++j){
        if(vec[j]!=vec2[j]){
            ++cnt;
        }
    }
    if(cnt==2 || cnt == 0){
        cout<< "YES";
    }
    else
    {
        cout<< "NO";
    }
    
}

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

const int N=500005;
int n,bt[60];
long long a[N],sum,b;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]),sum^=a[i];
	sum^=a[1]^a[2];
	b=a[1]+a[2]-sum;
	if(b<0||b%2||b>a[1]*2||((b/2)&sum))
	{
		printf("-1\n");
		return 0;
	}
	b/=2;
	if(sum==0)
	{
		printf("%lld\n",a[1]-b);
		return 0;
	}
//	cout<<b<<' '<<sum<<endl;
	for(int i=0;i<50;i++) if(((1ll<<i)&sum)) bt[++bt[0]]=i;
//	for(int i=0;i<50;i++) cout<<(1ll<<i)<<' '<<((1ll<<i)&sum)<<endl;
	long long L=0,R=(1ll<<bt[0])-1,res=-1;
//	cout<<R<<endl;
	while(L<=R)
	{
		long long mid=(L+R)>>1,x=0,y=0;
		for(int i=0;i<50;i++) if(((1ll<<i)&mid)) x+=1ll<<bt[i+1];
		y=sum-x;
		if(x>=a[1]-b) R=mid-1;
		else res=a[1]-b-x,L=mid+1;
	}
//	cout<<a[1]-res-b<<endl;
	if(res==a[1]) res=-1;
	printf("%lld\n",res);
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int q = 0; q < n; q++){
        cin >> a[q];
    }
    vector<vector<int>> d(n);
    for (int q = 0; q < m; q++){
        int x, y;
        cin >> x >> y;
        d[x-1].push_back(y-1);
        d[y-1].push_back(x-1);
    }
    int ans = 0;
    for (int q = 0; q < n; q++){
        bool flag = true;
        for (int q1: d[q]){
            if (a[q1] >= a[q]){
                flag = false;
                break;
            }
        }
        ans += flag;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9796
C = [list(map(int,input().split())) for _ in range(3)]
if C[0][0]-C[0][1]==C[1][0]-C[1][1]==C[2][0]-C[2][1] and C[0][1]-C[0][2]==C[1][1]-C[1][2]==C[2][1]-C[2][2] \
    and C[1][0]-C[0][0]==C[1][1]-C[0][1]==C[1][2]-C[0][2] and C[2][0]-C[1][0]==C[2][1]-C[1][1]==C[2][2]-C[1][2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
import java.util.Arrays;

public class Main {
  private static void solve() {
    int n = ni();
    int a = ni();
    int[] x = na(n);
    int sum = Arrays.stream(x).sum();
    long[][][] dp = new long[n + 1][n + 1][sum + 1];
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i ++) {
      for (int j = 0; j < n; j ++) {
        for (int v = 0; v + x[i] <= sum; v ++) {
          dp[i + 1][j + 1][v + x[i]] += dp[i][j][v];
        }
      }
      for (int j = 0; j <= n; j ++) {
        for (int v = 0; v <= sum; v ++) {
          dp[i + 1][j][v] += dp[i][j][v];
        }
      }
    }
    
    long ret = 0;
    for (int j = 1; j <= n; j ++) {
      if (j * a > sum) break;
      ret += dp[n][j][j * a];
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




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

int main(){
        int n;
        int v[30],c[30];
        int ans=0;
        cin>>n;
        for(int i=0;i<n;i++){
                cin>>v[i];
        }
        for(int i=0;i<n;i++){
                cin>>c[i];
        }
        for(int i=0;i<n;i++){
                if(v[i]>c[i]){
                        ans+=v[i]-c[i];
                }
        }
        cout<<ans<<"\n";
        return 0;
}


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


main(){
   ll x;
   cin >> x;

   for(ll i=1;i<=953;i++){
      if(100*i<=x && x<=105*i){
         cout << 1 << endl;
         exit(0);
      }
   }

   cout << 0 << endl;
}

Measured memory_bytes: 256
/* Murad Eynizade */

#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define SIZE 300001
#define INF INT_MAX
#define F first
#define S second
#define in(a) scanf("%d",&a);
#define outn(a) printf("%d\n",&a);
#define outs(a) printf("%d ",&a);


using namespace std;

int n , k;
intt h[SIZE] , dp[SIZE];

int main()
{
    FAST_READ;
    cin>>n>>k;
    for (int i = 1;i<=n;i++) cin>>h[i];
    dp[1] = 0;
    for (int i = 2;i<=n;i++) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        for (int j = max(1 , i - k); j < i - 1;j++) dp[i] = min(dp[i] , dp[j] + abs(h[i] - h[j]));
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 3072
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef float f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
const int mod=998244353;
//const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

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

int fact[6005],ifact[6005],p2[6005];
inline int ncr(int n, int r) {
	if(n<r||r<0)
		return 0;
	return (((fact[n]*ifact[r])%mod)*ifact[n-r])%mod;
}
void solve() {
	fact[0]=1;
	fr(i,1,6000)
		fact[i]=(fact[i-1]*i)%mod;
	ifact[6000]=powm(fact[6000],mod-2);
	for(int i=5999; i>=0; i--)
		ifact[i]=(ifact[i+1]*(i+1))%mod;
	p2[0]=1;
	fr(i,1,6000)
		p2[i]=(p2[i-1]*2)%mod;
	int n,k;
	cin>>k>>n;
	fr(i,2,2*k) {
		if(i&1) {
			int ans=0;
			int tol=(min(k,i-1)-max(1LL,i-k)+2)/2;
			int rem=k-2*tol;
			fr(j,0,tol) {
				int var=rem+j;
				int lol=n-j;
				ans=(ans+p2[j]*((ncr(var+lol-1,lol)*ncr(tol,j))%mod))%mod;
			}
			cout<<ans<<endl;
		}
		else {
			int ans=0;
			int tol=min(i/2-1,k-i/2);
			int rem=k-2*tol-1;
			fr(j,0,tol) {
				int var=rem+j;
				int lol=n-j;
				ans=(ans+p2[j]*((ncr(var+lol-1,lol)*ncr(tol,j))%mod))%mod;
			}
			fr(j,0,tol) {
				int var=rem+j;
				int lol=n-j-1;
				ans=(ans+p2[j]*((ncr(var+lol-1,lol)*ncr(tol,j))%mod))%mod;
			}
			cout<<ans<<endl;
		}
	}


}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  bool check = true;
  
  for (int i = 0; i < N; i++) {
    if ((A[i] % 2 == 0 && A[i] % 3 != 0) && (A[i] % 2 == 0 && A[i] % 5 != 0)) {
      check = false;
      break;
    }
  }
  
  if (check) {
    cout << "APPROVED" << endl;
  }
  else {
    cout << "DENIED" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var v, w, t int64
	var a, b float64
	_, _ = fmt.Scan(&a, &v)
	_, _ = fmt.Scan(&b, &w)
	_, _ = fmt.Scan(&t)
	l := math.Abs(b - a)
	i := v - w

	if int64(l) <= t*i {
		fmt.Println("YES")
	}else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 1820
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e12)
#define PI (acos(-1))

int main(){
    int a, b, c, x, y;
    ll ans = INF;
    cin >> a >> b >> c >> x >> y;
    int C = 2*c;
    rep(i,max(x,y)+1){
        ll res = 0;
        res += C * i;
        res += a * max(0,x-i);
        res += b * max(0,y-i);
        ans = min(ans,res);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int a, b; string s;
    cin >> a >> b >> s;
    bool left = true, mid = false, right = true;
    FOR(i,0,a)
        if (s[i] == '-')
            left = false;
    if (s[a] == '-')
        mid = true;
    FOR(j,a+1, a+b)
        if (s[j] == '-')
            right = false;
    if (left && mid && right)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    int A, B, ans;
    cin >> A >> B;

    ans = A + B;
    if (ans < A - B) ans = A - B;
    if (ans < A * B) ans = A * B;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
p=str(input())

def ans171(N:int, K:int, p:str):
    p_list=sorted(map(int,p.split()))
    price=0
    for i in range(0,K):
        price=price+p_list[i]
    return(price)

print(ans171(N,K,p))

Measured memory_bytes: 9188
N,K,Q = map(int, input().split())
ary = [0] * (N+1)

for i in range(Q):
  A = int(input())
  ary[A] += 1

i = 1
for i in range(1, N+1):
  print('Yes' if ((K + ary[i] - Q) > 0) else 'No')


Measured memory_bytes: 9836