akhauriyash/Code-Regression huggingface dataset:
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

const ll mod = 1e9 + 7;

ll dp[302][302][302];

int main() {
    ll N, M;
    cin >> N >> M;
    dp[0][0][N - 1] = 1;

    for(ll day = 0; day < M; day++) for(ll road = 0; road <= min<ll>(day, N - 1); road++) {
        ll rest = N - road;
        for(ll iso = max<ll>(0, N - (day + 1)); iso < N && 0 <= rest - iso; iso++) {
            ll scc_size = rest - iso;
            DEBUG(make_tuple(day, road, iso));
        
            // go to isolatoin
            if(0 < iso) (dp[day + 1][road + 1][iso - 1] += iso * dp[day][road][iso] % mod) %= mod;
            
            // loop
            (dp[day + 1][road][iso] += road * dp[day][road][iso] % mod) %= mod;

            // return scc
            (dp[day + 1][0][iso] += scc_size * dp[day][road][iso] % mod) %= mod;
        }
    }

    cout << dp[M][0][0] << endl;
    return 0;
}


Measured memory_bytes: 213248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
const ll MOD=1e9+7;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b;cin>>a>>b;
    ll n=__gcd(a,b);
    ll cnt = 1;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        while(n%i==0)n/=i;
        cnt++;
    }
    if(n>1)cnt++;
    cout<<cnt;
}


Measured memory_bytes: 256
// AOJ 2613: Unordered Operators
// 2017.10.10 bal4u@uu

#include <stdio.h>
#include <ctype.h>

#define MAX 210

#define VAL   10
#define LEFT  -1
#define RIGHT -2
#define PLUS   0 
#define MINUS  1
#define MUL    2

typedef struct { long long v; char id; } T;
T stack[MAX+3], buf[MAX+3]; int top, end;

char str[MAX], *p;

int tbl[13][3] = {
	{1,2,3},{1,3,2},{2,1,3},{2,3,1},{3,1,2},{3,2,1},
	{1,1,1},{1,1,2},{2,2,1},{1,2,1},{2,1,2},{1,2,2},{2,1,1}}; int rid;

long long getInt(void)
{
	long long n = 0;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

int token(char c)
{
	if (c == '+') return PLUS;
	if (c == '-') return MINUS;
	return MUL;
}

int rank(int op)
{
	if (op == LEFT) return LEFT;
	return tbl[rid][op];
}

int main()
{
	int i, id, f;
	long long v1, v2, ans;

	scanf("%s", str); f = 1;
	for (rid = 0; rid < 13; rid++) {
		p = str, top = 0, end = 0;
		while (*p) {
			if (isdigit(*p)) buf[end].id = VAL, buf[end++].v = getInt();
			else if (*p == ')') {
				while (top > 0 && stack[top-1].id != LEFT) buf[end++] = stack[--top];
				p++, top--;
			} else if (*p == '(') stack[top++].id = LEFT, p++;
			else {
				id = token(*p++);
				while (top > 0) {
					if (rank(id) <= rank(stack[top-1].id))
						buf[end++] = stack[--top];
					else break;
				}
				stack[top++].id = id;
			}
		}
		while (top > 0) buf[end++] = stack[--top];

		for (top = i = 0; i < end; i++) {
			if ((id = buf[i].id) == VAL) stack[top++].v = buf[i].v;
			else {
				v1 = stack[--top].v, v2 = stack[--top].v;
				if      (id == PLUS)  v2 += v1;
				else if (id == MINUS) v2 -= v1;
				else if (id == MUL)   v2 *= v1;
				stack[top++].v = v2;
			}
		}
		if (f) ans = stack[--top].v, f = 0;
		else if (ans < stack[--top].v) ans = stack[top].v;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1832
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin >> s;
    bool arr['z'-'a'+1] = {};
    for(int i = 0; i < s.size(); i++){
        if(!arr[s[i]-'a']) arr[s[i]-'a'] = true;
        else{
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use  std::collections::BTreeMap;
use std::cmp::min;

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

fn main(){
    let n: usize = read();
    let m: usize = read();
    let mut a: Vec<u8> = (0..n).map(|_| 10).collect();
    for _ in 0..m {
        let s: usize = read::<usize>() - 1;
        let c: u8 = read();
        if a[s] != c && a[s] != 10 {
            println!("-1");
            return;
        }
        a[s] = c;
    }
    if n == 1 && a[0] == 10 {
        println!("0");
        return;
    } else if n != 1 && a[0] == 0 {
        println!("-1");
        return;
    } else if n != 1 && a[0] == 10 {
        a[0] = 1;
    }
    //a.reverse();

    for b in &a {
        print!("{}", if *b == 10 { 0 } else { *b });
    }
    println!("");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 100005;
int n, ans, w, h[MX];
int main(){
	scanf("%d", &n);
	rep(i,n) scanf("%d", h+i);
	rep(i,n-1){
		if(h[i] >= h[i+1]) w++;
		else w = 0;
		ans = max(ans, w);
	}
	printf("%d\n", ans);
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define INF 100000

int main()
{
  int h,w;cin>>h>>w;
  vector<vector<char>> s(h+2,vector<char>(w+2));
  int i,j;
  rep(i,h+2)rep(j,w+2)
  {
    if(i==0||i==h+1||j==0||j==w+1)s[i][j]='#';
    else cin>>s[i][j];
  }
  queue<pair<int,int>> q;
  vector<vector<int>> step(h+2,vector<int>(w+2,INF));
  step[1][1]=0;
  vector<vector<bool>> vd(h+2,vector<bool>(w+2,false));
  vector<int> dh={1,0,-1,0};
  vector<int> dw={0,1,0,-1};
  q.push(make_pair(1,1));
  vd[1][1]=true;
  while(!q.empty())
  {
    pair<int,int> pt=q.front();
    int a=pt.first;
    int b=pt.second;
    q.pop();
    rep(i,4)
    {
      if(!vd[a+dh[i]][b+dw[i]]&&s[a+dh[i]][b+dw[i]]=='.')
      {
        vd[a+dh[i]][b+dw[i]]=true;
        step[a+dh[i]][b+dw[i]]=step[a][b]+1;
        q.push(make_pair(a+dh[i],b+dw[i]));
      }
    }
  }
  if(step[h][w]==INF)cout<<-1<<endl;
  else
  {
    int count=0;
    rep(i,h+2)rep(j,w+2)if(s[i][j]=='.')count++;
    cout<<count-(step[h][w]+1)<<endl;
  }
}


Measured memory_bytes: 256
console.log((args=>{
  const [[N,M],...friend] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  const G = Array.from({length:N},_=>[]);
  for ( const [A,B] of friend ) {
    G[A-1].push(B-1);
    G[B-1].push(A-1);
  }
  const g = Array(N).fill(0);
  let n = 1;
  for ( let i = 0; i < N; i++ ) {
    if ( g[i] ) continue;
    let stack = [i], m = 0;
    while( stack.length ) {
      const p = stack.pop();
      if ( !g[p] ) {
        g[p] = i+1;
        m++;
        for ( const next of G[p] ) if ( !g[next] ) {
          stack.push(next);
        }
      }
    }
    if (m > n) n = m;
  }
  return n;
})(require('fs').readFileSync('/dev/stdin','utf8')));


Measured memory_bytes: 130840
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main(){
  int N, M;
  cin >> N >> M;

  ll A[N];
  P CB[M];

  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A,A+N);
  for(int j=0;j<M;j++){
    ll b, c;
    cin >> b >> c;
    CB[j] = make_pair(c,b);
  }
  sort(CB,CB+M);

  int i=0;
  int j=M-1;
  bool flag = true;

  while(i<N){
    while(j>=0){
      int k = CB[j].second;
      while(k>0){
        if(A[i] < CB[j].first){
          A[i] = CB[j].first;
          k--;
          i++;
        }else{
          flag = false;
          break;
        }
      }
      if(!flag) break;
      j--;
    }
    if(!flag) break;
    if(j==-1) break;
  }


  ll sum = 0;
  for(int i=0;i<N;i++){
    sum += A[i];
  }
  cout << sum <<endl;


  return 0;
}




Measured memory_bytes: 2560
# coding:utf-8
n = int(input())
ans = [0] * n

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            tmp = i**2 + j**2 + k**2 + i * j + j * k + k * i
            if tmp <= n:
                ans[tmp - 1] += 1

for item in ans:
    print(item)


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

using namespace std;

const vector<char> chars = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
                            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t N;
  cin >> N;
  string res = "";
  while (N > 0) {
    res += chars[(N - 1) % 26];
    N--;
    N /= 26;
  }
  reverse(res.begin(), res.end());
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
ll calc(P p1, P p2){
	ll ans = abs(p1.first -p2.first) + abs(p1.second - p2.second);
	return ans;
}
int main() {
	string s, ans="";
	cin >> s;
	rep(i,s.length()){
		if(s[i]=='0'){
			ans+='0';
		}else if(s[i]=='1'){
			ans+='1';
		}else{
			if(ans.length()==0) ;
			else ans.pop_back();
		}
	}
	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 3572
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(s: str):
    N = s.count('N')
    S = s.count('S')
    E = s.count('E')
    W = s.count('W')
    if (N == 0 and S != 0) or (N != 0 and S == 0) or (E == 0 and W != 0) or (E != 0 and W == 0):
        print('No')
    else:
        print('Yes')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

int main() {
  int64_t A,B;
  int temp;
  int64_t times;
  cin>>A>>B;
  times=A*B;
  if(A<=B){
    swap(A,B);
  }
  if(A % B==0){
    cout<<A;
  } else {
    while(A%B!=0){
      temp=A % B;
      A=temp;
      swap(B, A);
    }
  cout<<times/temp;
  }
}

Measured memory_bytes: 256
A,B = map(int,input().split())

def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

G = gcd(A,B)
if G == 1:
    print(1)
else:
    H = factorization(G)
    print(len(H)+1)

Measured memory_bytes: 3064
// javac Main.java && java _

import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) { new Main(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);


	
	Main() {
		int n = in.nextInt();
		int m = in.nextInt();
		char[] S = in.next().toCharArray();

		TreeSet<Integer> jump = new TreeSet<>();
		for (int i = 0; i <= n; i++)
			if (S[i] == '0')
				jump.add(i);

		int idx = 0;
		ArrayList<Integer> moves = new ArrayList<>();

		boolean lose = false;
		while (true) {
			if (idx == n)
				break;

			int to = jump.floor(idx + m);
			if (to == idx) {
				lose = true;
				break;
			}
			else {
				moves.add(to - idx);
				idx = to;
			}
		}

		if (lose)
			out.println(-1);
		else {
			idx = n;
			moves.clear();
			while (idx > 0) {
				int to = jump.ceiling(idx - m);
				moves.add(idx - to);
				idx = to;
			}
			int sz = moves.size();
			for (int i = sz - 1; i >= 0; i--)
				out.print(moves.get(i) + " ");
			out.println();
		}	

		out.close();
	}
	
	

	int min(int a, int b) { if (a < b) return a; return b; }	
	int max(int a, int b) { if (a > b) return a; return b; }	
	long min(long a, long b) { if (a < b) return a; return b; }	
	long max(long a, long b) { if (a > b) return a; return b; }	

	boolean z(int x) { if (x == 0) return true; return false; }
	boolean z(long x) { if (x == 0) return true; return false; }
	
	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }
	}
}



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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

    long long ans = 0l;
    rrep (a, 1, K) {
        rrep (b, 1, K) {
            rrep (c, 1, K) {
                ans += __gcd(a, __gcd(b, c));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    set<int> A;
    REP(i, N){
        int a;
        cin >> a;
        A.insert(a);
    }

    YES(A.size()==N);
}

Measured memory_bytes: 9600
import collections

N=int(input())
A=list(map(int,input().split()))
X=collections.Counter(A)
Q=int(input())

ans=sum(A)
for i in range(Q):
  B,C=map(int,input().split())
  ans+=(C-B)*X[B]
  print(ans)
  X[C]+=X[B]
  X[B]=0


Measured memory_bytes: 24184
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

void fsscan(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

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

struct node
{
  ll b;
  ll c;
};

bool fun(node p,node q)
{
    if(p.c==q.c)
    {
        if(p.b>q.b)
        return true;
        else
        return false;
    }
    else
    if(p.c>q.c)
    return true;
    
    return false;
}

int main()
{
    fsscan();
    
    ll n,m;
    cin>>n>>m;
    
    ll a[n];
    node q[m];
    
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    
    sort(a,a+n);
    
    for(int i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        q[i].b=x;
        q[i].c=y;
    }
    
    
    sort(q,q+m,fun);
    
    int index=0;
    ll sum=0;
    
    for(int i=0;i<n;i++)
    {
        //cout<<index<<" "<<q[index].b<<endl;
        if(index<m && q[index].b>0)
        {
            if(q[index].c>a[i])
            {
                a[i]=q[index].c;
                //cout<<a[i]<<endl;
                q[index].b-=1;
            }
            else
            break;
            
        }
        else
        if(index>=m)
        break;
        else
        {
            index++;
            i-=1;
        }
    }
    
    for(int i=0;i<n;i++)
    {
        //cout<<a[i]<<endl;
        sum+=a[i];
    }
    
    cout<<sum;
    return 0;
}


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

int main () {
  int n, m;
  cin >> n >> m;
  vector<int> c(m+1, 0);

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

  int ans = 0;
  rep(i,m+1) if(c[i] == n) ans++;
  cout << ans << endl;

  return 0;
}


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

inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

#define maxn 200100
#define maxm 5000
typedef long long ll;
ll mod=1000000007;
int a[maxn],b[maxn];
ll fac[maxn*2],inv[maxn*2];
ll w[maxm][maxm];
ll ans;
int n;

ll Pow(ll x,ll y)
{
	ll res=1,t=x;
	while (y)
	{
		if (y&1) res=res*t%mod;
		t=t*t%mod;
		y>>=1;
	}
	return res;
}

ll Inv(ll x)
{
	return Pow(x,mod-2);
}

int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();b[i]=read();
		w[2010-a[i]][2010-b[i]]++;
	}
	for(int i=1;i<=4100;i++)
		for(int j=1;j<=4100;j++)
			w[i][j]=(w[i][j]+w[i-1][j]+w[i][j-1])%mod;
	for(int i=1;i<=n;i++)
		ans=(ans+w[2010+a[i]][2010+b[i]])%mod;
	fac[0]=1;
	for(int i=1;i<=8100;i++)
		fac[i]=fac[i-1]*i%mod;
	for(int i=0;i<=8100;i++)
		inv[i]=Inv(fac[i]);
	for(int i=1;i<=n;i++)
	{
		ans=(ans-fac[(a[i]+b[i])*2]*inv[a[i]*2]%mod*inv[b[i]*2]%mod);
		ans=(ans%mod+mod)%mod;
	}
	ans=ans*inv[2]%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 168320
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/


signed main() {
	int n;
	cin >> n;
	if (n % 2) {
		printf("%.12lf\n", (double)(n / 2 + 1) / (double)n);
	}
	else {
		cout << "0.5" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

int n;

int dp[31][1000001]={};
int d[31][1000001]={};

const ll INF=100000000001;
int main() {
	int g,r;
	cin>>r>>g;
	cout<<2*g-r<<endl;
	return 0;
}


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


void warshall_floyd(vector<vector<long long>>& d, long long V){
    for(int k = 0; k < V; k++)
        for(int i = 0; i < V; i++)
            for(int j = 0; j < V; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

void warshall_floyd2(vector<vector<long long>>& d, vector<vector<long long>>& output_d,  long long V){
    for(int k = 0; k < V; k++)
        for(int i = 0; i < V; i++)
            for(int j = 0; j < V; j++)
                if(d[i][j] == d[i][k] + d[k][j] && i != k && j != k)
                    //d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                    output_d[i][j] = 0;
}

int main(void){
    long long N, H;
    cin >> N;
    vector<vector<long long>> input_d(N, vector<long long>(N));
    vector<vector<long long>> d(N, vector<long long>(N));
    vector<vector<long long>> output_d(N, vector<long long>(N));
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cin >> input_d[i][j];
            d[i][j] = input_d[i][j];
            output_d[i][j] = input_d[i][j];
        }
    }
    
    warshall_floyd(d, N);
    
    bool is_exist = true;
    for(int i = 0; i < N; i++)
        for(int j = i+1; j < N; j++)
            if(input_d[i][j] != d[i][j])
                is_exist = false;
    
    if(is_exist){
        warshall_floyd2(d, output_d, N);
        
        long long cost = 0;
        for(int i = 0; i < N; i++)
            for(int j = i + 1; j < N; j++)
                cost += output_d[i][j];
        
        cout << cost;
        
    }
    else
        cout << -1;
    
}


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

int main() {
        int N;
        cin >> N;
        
        char A[N];
        char B[N];
char C[N];
        
        int count;
count = 0;
        
        for (int i = 0; i < N; ++i) cin >> A[i] ;
        for (int i = 0; i < N; ++i) cin >> B[i] ;
        for (int i = 0; i < N; ++i) cin >> C[i] ;
        
        for (int i =0; i < N; ++i) {
            
            if (A[i]==B[i] && A[i]==C[i]) {
count = count + 0;
} else if (A[i]!=B[i] && A[i]!=C[i] && B[i]!=C[i]) {
count = count +2;
} else {
count = count + 1;
}

        }
cout << count;
cout << endl;


}

Measured memory_bytes: 256
import numpy as np
import sys

def main():
    input = sys.stdin.readline
    r, D, x2000 = map(int, input().split())
    dp = [0] * 11
    dp[0] = x2000
    for i in range(1, 11):
        dp[i] = r * dp[i-1] - D
        print(dp[i])


if __name__ == '__main__':
    main()


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

int a[100001];
int main() {
  int n, k;
  cin >> n >> k;
  
  for (int i = 0; i < n; ++i) {
    cin >> a[i + 1];
    a[i + 1] %= k;
  }
  
  for (int i = 0; i < n; ++i) {
    a[i + 1] += a[i];
    a[i + 1] %= k;
  }
  
  map<int, int> m;
  for (int i = 0; i <= n; ++i) {
    ++m[a[i]];
  }
  
  long s = 0;
  for (auto p : m) {
    s += (long)p.second * (p.second - 1) / 2;
  }
  cout << s << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main()
{
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(x<0 || y<0){
    printf("No\n");
    return 0;
  }

  if(x>=W || y>=H){
    printf("No\n");
    return 0;
  }

  if(x+r<=W && y+r<=H && x-r>=0 && y-r >=0){
    printf("Yes\n");
  }
  else
    printf("No\n");

  
  
  return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    string ans;
    if(a == 1 && b == 1){
        ans = "Draw";
    }
    else if(a == 1){
        ans = "Alice";
    }
    else if(b == 1){
        ans = "Bob";
    }
    else if(a<b){
        ans = "Bob";
    }
    else if(a == b)
        ans = "Draw";
    else if(a > b)
        ans = "Alice";

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx")
//おそるおそる
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
int to[200001], ne[200001], he[100001];
ll mod = 1e9 + 7;
pair<ll, ll> dfs(int A, int prev) {
	ll kuro = 1;
	ll siro = 1;
	for (int i = he[A]; i; i = ne[i]) {
		int To = to[i];
		if (To != prev) {
			auto k = dfs(To, A);
			kuro = (kuro * k.second) % mod;
			siro = (siro * k.first) % mod;
		}
	}
	return mp(kuro + siro, siro);
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	N = getint();
	int k = 1;
	rep(i, N - 1) {
		int x = getint(), y = getint();
		to[k] = y;
		ne[k] = he[x];
		he[x] = k++;
		to[k] = x;
		ne[k] = he[y];
		he[y] = k++;
	}

	auto M = dfs(1, 0);
	printf("%lld", M.first % mod);

	Would you please return 0;
}

Measured memory_bytes: 4992
import sys;
import heapq

def iterative(i,j):
    q = []
    heapq.heappush(q,(sumcost,(0,i,j,0,puz)))
    global finding

    while len(q):
        cost, items = heapq.heappop(q)
        c_depth = items[0]
        _i = items[1]
        _j = items[2]
        prev_move = items[3]
        c_puz = items[4]
        _sum_cost = cost - c_depth
        if(_sum_cost == 0):
            finding = 1
            print(c_depth)
            break
        if(cost > depth):
            continue

        c_cost = HS(_i,_j,c_puz[_i*3+_j])

        if(_i != 0 and prev_move != 1):
            swap_puz = swapPuz(c_puz[0:],_i,_j,_i-1,_j)
            n_cost = cost+1+checkCost(c_cost,HS(_i-1,_j,c_puz[(_i-1)*3+_j]),HS(_i,_j,swap_puz[_i*3+_j]),HS(_i-1,_j,swap_puz[(_i-1)*3+_j]))
            if(n_cost <= depth):
                heapq.heappush(q,(n_cost,(c_depth+1,_i-1,_j,2,swap_puz)))
        if(_i != 2 and prev_move != 2):
            swap_puz = swapPuz(c_puz[0:],_i,_j,_i+1,_j)
            n_cost = cost+1+checkCost(c_cost,HS(_i+1,_j,c_puz[(_i+1)*3+_j]),HS(_i,_j,swap_puz[_i*3+_j]),HS(_i+1,_j,swap_puz[(_i+1)*3+_j]))
            if(n_cost <= depth):
                heapq.heappush(q,(n_cost,(c_depth+1,_i+1,_j,1,swap_puz,)))
        if(_j != 0 and prev_move != 3):
            swap_puz = swapPuz(c_puz[0:],_i,_j,_i,_j-1)
            n_cost = cost+1+checkCost(c_cost,HS(_i,_j-1,c_puz[_i*3+_j-1]),HS(_i,_j,swap_puz[_i*3+_j]),HS(_i,_j-1,swap_puz[_i*3+_j-1]))
            if(n_cost <= depth):
                heapq.heappush(q,(n_cost,(c_depth+1,_i,_j-1,4,swap_puz)))
        if(_j != 2 and prev_move != 4):
            swap_puz = swapPuz(c_puz[0:],_i,_j,_i,_j+1)
            n_cost = cost+1+checkCost(c_cost,HS(_i,_j+1,c_puz[_i*3+_j+1]),HS(_i,_j,swap_puz[_i*3+_j]),HS(_i,_j+1,swap_puz[_i*3+_j+1]))
            if(n_cost <= depth):
                heapq.heappush(q,(n_cost,(c_depth+1,_i,_j+1,3,swap_puz)))

def checkCost(c_cost,m_cost,c2_cost,m2_cost):
    return c2_cost - c_cost + m2_cost - m_cost

def sumCost(puz):
    value = 0
    for i in range(3):
        value += HS(i,0,puz[i*3])
        value += HS(i,1,puz[i*3+1])
        value += HS(i,2,puz[i*3+2])
    return value

def HS(i,j,num):
    if(num != 0):
        k = num-1
    else:
        k = 8
    ki = (int)(k/3)
    kj = k - ki*3
    value = abs(i-ki)+abs(j-kj)
    return value


def swapPuz(c_puz, i, j, i2,j2):
    c_puz[i2*3+j2],c_puz[i*3+j] = c_puz[i*3+j],c_puz[i2*3+j2]
    return c_puz

correctPuz = [i+1 for i in range(9)]
correctPuz[8] = 0
puz = [0 for i in range(9)]

i_start = 0
j_start = 0

for i in range(3):
    puz[i*3],puz[i*3+1],puz[i*3+2] = map(int, input().split());
    if(puz[i*3] == 0):
        i_start,j_start = i,0
    elif(puz[i*3+1] == 0):
        i_start,j_start = i,1
    elif(puz[i*3+2] == 0):
        i_start,j_start = i,2

sumcost = sumCost(puz)

finding = 0
depth = 0
while True:
    if(finding == 1):
        break
    iterative(i_start,j_start)
    depth+=1



Measured memory_bytes: 8580
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
	string s;
	cin>>s;
	int n=s.size();
	bool ok=true;
	rep(i,n) if(s[i]!=s[n-1-i]) ok=false;
	if(ok) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
#define ln endl
int n,a[100005],flag;
int main() {
	n=_;
	for( int i=1;i<=n;i++ ) 
		a[i]=_;
	for( int i=2;i<=n;i++ ) 
		if(a[i]-1>=a[i-1]) { --a[i]; continue; }
		else if(a[i]>=a[i-1]) continue;
		else flag=1;
	puts(flag?"No":"Yes");
}

Measured memory_bytes: 640
import sys
import math

n, m = map(int, raw_input().split())
A = []
b = []

for i in xrange(n) :
    A.append(map(int, raw_input().split()))

for i in xrange(m) :
    b.append(input())

for i in xrange(n) :
    sm = 0
    for j in xrange(m) :
        sm += A[i][j] * b[j]
    print sm

Measured memory_bytes: 6560
#include <stdio.h>
#include <math.h>

int main(int argc, char const *argv[])
{
    long double x;
    unsigned long long yokin = 100;
    unsigned long c = 0;
    scanf("%Lf", &x);

    while (yokin < x)
    {
        yokin *= 1.01;
        c++;
    }
    printf("%lu\n", c);
    return 0;
}


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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  ll X, Y;
  cin >> X >> Y;
  int ans = 0;
  for (ll A = X; A <= Y; A *= 2) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		ArrayList<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			list.add(a[i]);
		}
		Collections.sort(list);
		sc.close();
		BinaryIndexedTree tree = new BinaryIndexedTree(N);

		long ans = 0;
		for (int i = 0; i < N; i++) {
			a[i] = Collections.binarySearch(list, a[i]) + 1;
			ans += i - tree.sum(a[i]);
			tree.add(a[i], 1);
		}
		System.out.println(ans);

	}

	static class BinaryIndexedTree {
		int N;
		int[] bit;

		public BinaryIndexedTree(int N) {
			this.N = N;
			bit = new int[N + 1];

		}

		public int sum(int i) {
			int sum = 0;
			while (i > 0) {
				sum += bit[i];
				i -= i & -i;
			}
			return sum;
		}

		public void add(int i, int x) {
			while (i <= N) {
				bit[i] += x;
				i += i & -i;
			}
		}
	}

}

Measured memory_bytes: 110820
#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 = 2e5+23;

int a[N], b[N];

void solve() {
  int n; scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    char c; scanf(" %c", &c);
    a[i] = c == '#';
    b[i] = !a[i];
    a[i] += a[i-1];
  }
  int ans = 1e9;
  for (int i = n; i > 0; --i) {
    b[i] += b[i+1];
    ans = min(ans, a[i-1]+b[i]);
  }
  printf("%d", min(ans, a[n]));
}

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


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <string.h>
using namespace std;
using ll = long long;

#define right true
#define left false

int main()
{
  int n, a, b, c, x;
  while (cin >> n >> a >> b >> c >> x, n || a || b || c || x)
  {
    vector<int> y(n);
    for (auto &e : y)
      cin >> e;
    int t = x;
    int cnt = 0;
    for (int i = 0; i < n; ++i)
    {
      if (x == y[i] && i == 0)
        continue;
      t = (a * t + b) % c;
      cnt++;
      while (t != y[i])
      {
        if (cnt > 10000)
          break;
        t = (a * t + b) % c;
        cnt++;
      }
    }
    if (cnt <= 10000)
      cout << cnt << endl;
    else
      cout << -1 << endl;
  }

  return 0;
}


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

using namespace std;

long long int MOD = 1000000000+7;

long long int powll(long long int a, long long int b){ // aのb乗%1000000007
  if(b == 1) return a;

  long long int tmp = powll(a, b/2)%MOD;
  if(b%2==0) return (tmp*tmp)%MOD;
  return ((tmp*tmp)%MOD*a)%MOD;
}

int main(){
  long long int N, K;
  cin >> N >> K;
  long long int ans=0, dp[K+1];

  for(long long int i=K; i>0; i--){
    dp[i] = powll(K/i, N);
    for(long long int j=2; i*j<=K; j++){
      dp[i] = (dp[i]-dp[i*j]+MOD)%MOD;
    }
  }
  for(long long int i=1; i<=K; i++){
    ans = (ans + (dp[i]*i)%MOD)%MOD;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4372
n = int(input())
arr = list(map(int, input().split()))

frag = True
ex = 0

while frag:
    frag = False
    for j in range(n-1, 0, -1):
        if arr[j-1] > arr[j]:
            arr[j-1], arr[j] = arr[j], arr[j-1]
            frag = True
            ex += 1



def print_space(li):
    for i in range(len(li)-1):
        print(li[i], end=' ')
    else:
        print(li[-1])

        
print_space(arr)
print(ex)



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

int main(){
int r,g,b,make;
  cin >> r >> g >> b;
  make = 100 * r + 10 * g + b;
  if(make % 4 == 0){
  cout << "YES" << endl;
  }else{
  cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <cmath>
#include <memory.h>
#include <iomanip>
#include <cassert>
using namespace std;

#define maxn
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

ll k;
vector<int> res;

vector<int> build(ll k, int t=1) {
    if (k==0) return {};
    if (k%2!=0) {
        vector<int> tmp = build(k/2, t+1);
        tmp.insert(tmp.begin()+tmp.sz()/2, t);
        tmp.push_back(t);
        return tmp;
    }
    else {
        vector<int> tmp = build(k-1, t+1);
        tmp.insert(tmp.begin(), t);
        tmp.push_back(t);
        return tmp;
    }
}

int main() {
    //freopen("goodstr.inp", "r", stdin);
    //freopen("", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> k;
    res = build(k);
    cout << res.sz() << '\n';
    REP(i, res.sz()) cout << res[i] << ' ';
}



Measured memory_bytes: 256
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
long long MAX(long long a,long long b){
    return a>b?a:b;
}
long long MIN(long long a,long long b){
    return a<b?a:b;
}
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long*)b)return 1;
    return -1;
}
int main()
{   int a,b,n,k,m,x,y,i,t;
    scanf("%d%d%d",&a,&b,&t);
    
    printf("%d",t/a*b);

    return 0;
}


Measured memory_bytes: 128
from collections import Counter

S=input()

rlist=[0]
for i in range(len(S)):
  rlist.append((rlist[-1]+int(S[-i-1])*pow(10,i,2019))%2019)
  
c = Counter(rlist)
c[0] -= 1

def nC2(n):
  return n*(n-1)//2
  
ans = c[0]
for k in c.keys():
  if c[k] >= 2:
    ans += nC2(c[k])
    
print(ans)

Measured memory_bytes: 16572
package main

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

func main() {
	var N, M, C int
	code := 0

	fmt.Scan(&N, &M, &C)

	B := make([]int, M)
	A := make([][]int, N)
	for i := range A {
		A[i] = make([]int, M)
	}

	sc := wordScanner()
	for i := range B {
		B[i] = getInt(sc)
	}

	for i := range A {
		for j := range A[i] {
			A[i][j] = getInt(sc)
		}
	}

	for i := range A {
		sum := 0
		for j := range A[i] {
			sum += A[i][j] * B[j]
		}
		if sum+C > 0 {
			code++
		}
	}

	fmt.Println(code)
}

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int(i)
}


Measured memory_bytes: 640
using System;

namespace template
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] a_str = Console.ReadLine().Split(' ');
            int[] a = new int[N];
            for (int i = 0; i < N; i++)
            {
                a[i] = int.Parse(a_str[i]);
            }

            int[] boxes = new int[N];
            for (int i = N; i > 0; i--)
            {
                int j = i + i;
                int sum = 0;
                while (j <= N)
                {
                    sum = (sum + boxes[j - 1]) % 2;
                    j += i;
                }
                boxes[i - 1] = (sum + a[i - 1]) % 2;
            }

            int M = 0;
            for (int i = 0; i < N; i++)
            {
                if (boxes[i] == 1)
                {
                    M += 1;
                }
            }
            Console.WriteLine(M);
            for (int i = 0; i < N; i++)
            {
                if (i > 0)
                {
                    Console.Write(' ');
                }
                if (boxes[i] == 1)
                {
                    Console.Write(i + 1);
                }
            }
            Console.Write('\n');


        }
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

int sumOfDigits(int n) {
  if (n < 10) return n;
  return sumOfDigits(n / 10) + n % 10;
}

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

  ll a;
  cin >> a;

  if (a % sumOfDigits(a) == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll a, b;
    cin >> a >> b;
    cout << max(max(a+b, a-b), a*b);
    return 0;
}

Measured memory_bytes: 3628
from collections import defaultdict

def main():
    n = int(input())
    d = prime_factorize(n)
    cnt = 0
    for k in d.keys():
        cnt_tmp = 1
        while cnt_tmp <= d[k]:
            d[k] -= cnt_tmp
            cnt_tmp += 1
            cnt += 1
    print(cnt)

    

def prime_factorize(n):
    a = defaultdict(int)
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1 
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a

if __name__ == '__main__':
    main()

Measured memory_bytes: 65892
#include<iostream>

using namespace std;

int main() {
	int a, b;

	cin >> a >> b; //bはb-a番目の塔、aはb-a-1番目の塔

	int p = b - a;
	int x = 0;

	for (int i = 1; i <= p; i++) {
		x += i;
	}

	cout << x - b << endl;
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;

const ll INF = -numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

int MAX;
int n;
vll pre, dp;
ll f(int x, int b = 0) {
    if (b <= 1) return pre[x];
    ll &res = dp[x];
    if (res != INF) return res;
    const int m = 1 << b;
    res = pre[x];
    vii v;
    for (int i = 0; i < n; i++) {
        if (x & (1 << i)) {
            v.emplace_back(i);
            // cerr << i << ' ';
        }
    }
    // cerr << '\n';
    for (int i = 1; i < m; i++) {
        int y = 0, b_ = 0;
        for (int j = 0; j < b; j++) {
            if ((i & (1 << j)) and (x & (1 << v[j]))) 
                y |= (1 << v[j]), b_++;
        }
        if ((x ^ y) < y) continue;
        res = max(res, pre[y] + f(x ^ y, b - b_));
    }
    // cerr << x << ": " << b << ", " << res << '\n';
    return res;
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);

    cin >> n;
    MAX = 1 << n;
    
    
    ll arr[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> arr[i][j];
        }
    }
    pre.assign(MAX, 0);
    dp.assign(MAX, INF);
    for (int i = 1; i < MAX; i++) {
        vii v;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) v.push_back(j);
        }
        pre[i] = 0;
        for (int j = 0; j < v.size(); j++) {
            for (int k = j + 1; k < v.size(); k++) {
                pre[i] += arr[v[j]][v[k]];
            }
        }
        // cerr << i << ": " << pre[i] << '\n';
    }
    // cerr << '\n';
    cout << f(MAX - 1, n) << '\n';
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;

const int MAX = 1 << 18;
int n;
int a[MAX];

bool can(int x)
{
	map<int, int> nenuli;
	FOR(i, 0, n - 1)
	{
		if (a[i + 1] > a[i])
		{
			map<int, int> nn;
			for(auto j: nenuli)
				if (j.X < a[i])
					nn[j.X] = j.Y;
				else
					break;
		
			nenuli = nn;
			continue;
		}
		
		int j = a[i + 1] - 1;
		while(j >= 0 && nenuli.count(j) && nenuli[j] == x - 1)
			nenuli.erase(j), --j;
		
		if (j < 0)
			return 0;
		
	//	cout << i << ' ' <<  j << ' ' << nenuli[j] << endl;
		nenuli[j]++;
	}
		
	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);
	
	cin >> n;
	FOR(i, 0, n)	
		cin >> a[i];
		
	bool ok = 1;
	FOR(i, 1, n)
		ok &= a[i] > a[i - 1];
	
	if (ok)
	{
		cout << 1 << endl;
		return 0;
	}
	
	int L = 2, R = n + 2, M;
	while(R - L > 1)
	{
		M = (L + R) >> 1;
		if (can(M))
			R = M;
		else
			L = M;
	}
	
	if (can(L))
		cout << L << endl;
	else
		cout << R << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 9856