akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define fio ios::sync_with_stdio(false);

typedef long long ll;
typedef pair <ll, ll> pi;

const ll maxn  = 2e3 + 6;
const ll mod = 1e9 + 7;

ll n, m, a[maxn], b[maxn], dp[maxn][maxn], ps[maxn][maxn];

ll add(ll a, ll b) {
    a += b;
    if (a < 0)
        a += mod;
    if (a >= mod)
        a -= mod;
    return a;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++)
        cin >> b[i];
    dp[0][0] = ps[0][0] = 1;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (!i || !j)
                ps[i][j] = dp[i][j] = 1;
            else if (!i && !j)
                ps[i][j] = dp[i][j] = 1;
            else {
                dp[i][j] = (a[i - 1] == b[j - 1]) * (ps[i - 1][j - 1]);
                ps[i][j] = add(add(add(ps[i][j - 1], ps[i - 1][j]), -ps[i - 1][j - 1]), dp[i][j]);
            }
        }
    }
    /*for (int i = 0; i <= n; i++) {
        cout << i << " : ";
        for (int j = 0; j <= m; j++) 
            cout << ps[i][j] << " ";
        cout << endl;
    }*/
    cout << ps[n][m] << endl;
	return 0;
}


Measured memory_bytes: 63104
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
using namespace std;

int main(){
  int n; cin >> n;
  for(int i = 1; i <= n; i++){
    int x = i;
    if(x % 3 == 0){
      cout << " " << i;
    }else if(x % 10 == 3){
      cout << " " << i;
    }else{
      while(x){
        x /= 10;
        if(x % 10 == 3){
          cout << " " << i;
          break;
        }
      }
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3096
u[];main(c){char*x,*y,*z;for(;scanf("%s%s%s",x=u,y=u+14,z=u+28)/3;puts(y))for(c=*y++;c-*z&&putchar(c),*z;)c=c==*z?++z,*x++:*y++;exit(0);}

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

int main(){
    while(1){
        int i,n=0;
        char x[1000];
        scanf("%s",&x);
        if(x[0]=='0') break;
        else{
            for(i=0; i<strlen(x); i++){
            n+=x[i]-'0';
            }
            printf("%d\n",n);
        }
    }
    return 0;
}



Measured memory_bytes: 2024
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	if x == 2 || y == 2 {
		fmt.Println("No")
		return
	}

	one := map[int]bool{1: true, 3: true, 5: true, 7: true, 8: true, 10: true, 12: true}
	two := map[int]bool{4: true, 6: true, 9: true, 11: true}
	if (one[x] && one[y]) || (two[x] && two[y]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
N,K = map(int,input().split())
A = list(map(int,input().split()))
R = [N]*N
def update(A):
    b = [0]*N
 
    for i,a in enumerate(A):
        l = max(0,i-a)
        r = min(N-1,i+a)
 
        b[l] += 1
        if r+1 < N:
            b[r+1] -= 1
    
    res = []
    s = 0
    for i in b:
        s += i
        res.append(s)
    return res
 
for _ in range(K):
    A = update(A)
    if A == R:
      break
print(*A)


Measured memory_bytes: 217868
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 10e9+7;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;




signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n;
    vec(a,n);
    REP(i,n-1){
        int tmp;
        cin >> tmp;
        tmp--;
        a[tmp]++;
    }
    REP(i,n){
        print(a[i]);
    }

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 4784
#include <iostream> 
#include <queue>
#include <string>
#include <set>
using namespace std;

int main()
{
	int n;
	int dp[30];
	int year;
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	while(cin >> n && n != 0){
		
		for(int i = 0; i < n; i++)
		{
			dp[i+3] = dp[i+2] + dp[i+1] + dp[i]; 
		}
		year = dp[n]/3650 + 1;
		cout << year << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a >= 13)cout << b << endl;
	else if (a >= 6)cout << b / 2 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
ball = [0]*(N+1)
ball[1]=1
ball_num = [1]*(N+1)
for i in range(M):
    x,y=map(int,input().split())
    if ball[x]==1:
        ball[y]=1
    ball_num[x]-=1
    ball_num[y]+=1
    if ball_num[x]==0:
        ball[x]=0
    
cnt = 0
for a,b in zip(ball_num,ball):
    cnt += (a!=0 and b != 0)
print(cnt)

Measured memory_bytes: 10824
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> anys;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(anys{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

// Extended Euclid's greatest common divisor algorithm
// Find (x, y, g)
// where $a*x + b*y = g$ and g is the greatest common divisor of (a, b)
long long ext_gcd(long long a, long long b, long long &x, long long &y){
	if(b == 0){
		x = 1; y = 0; return a;
	}
	long long nx, ny;
	long long g = ext_gcd(b, a%b, nx, ny);
	x = ny; y = nx - a/b *ny;
	return g;
}

struct mint {
	typedef long long ll;
	ll x, m;
	mint(ll x=0, ll m=1e9+7): x((m+x%m)%m), m(m) {}
	mint operator-() const { return mint(m-x, m); }
	mint& operator+=(const mint o) { x=(x+o.x)%m; return *this; }
	mint& operator+=(const ll o) { return (*this)+=mint(o, m); }
	mint& operator-=(const mint o) { return (*this)+=(-o); }
	mint& operator-=(const ll o) { return (*this)-=mint(o, m); }
	mint& operator*=(const mint o) { x = x*o.x%m; return *this; }
	mint& operator*=(const ll o) { return (*this)*=mint(o, m); }
	mint& operator/=(const mint o) { return (*this)*=o.inv(); }
	mint& operator/=(const ll o) { return (*this)/=mint(o, m); }
	friend mint operator+(mint l, const mint r) { l+=r; return l; }
	friend mint operator+(mint l, const ll r) { l+=r; return l; }
	friend mint operator+(const ll l, mint r) { r+=l; return r; }
	friend mint operator-(mint l, const mint r) { l-=r; return l; }
	friend mint operator-(mint l, const ll r) { l-=r; return l; }
	friend mint operator-(const ll l, mint r) { r-=l; return r; }
	friend mint operator*(mint l, const mint r) { l*=r; return l; }
	friend mint operator*(mint l, const ll r) { l*=r; return l; }
	friend mint operator*(const ll l, mint r) { r*=l; return r; }
	friend mint operator/(mint l, const mint r) { l/=r; return l; }
	friend mint operator/(mint l, const ll r) { l/=r; return l; }
	friend mint operator/(const ll l, const mint r) { return mint(l, r.m)/r; }
	bool operator==(const mint o) const { return x==o.x; }
	bool operator!=(const mint o) const { return x!=o.x; }
	friend bool operator==(const ll l, const mint r) { return mint(l, r.m) == r; }
	friend bool operator!=(const ll l, const mint r) { return mint(l, r.m) != r; }
	friend std::ostream& operator<<(std::ostream &os, const mint x) { return os << x.x; }

	mint pow(ll k) const {
		if(k==0) return mint(1, m);
		if(k%2) return pow(k-1)*x;
		mint z = pow(k/2); return z*z;
	}

	mint inv() const {
		ll y,z;
		ext_gcd(x, m, y, z);
		return mint(y, m);
	}
};

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

	ll ans = 0;
	for(int a=1; a<=K; a++) for(int b=1; b<=K; b++) for(int c=1; c<=K; c++){
		ll p, q, r, s;
		ans += ext_gcd(ext_gcd(a, b, p, q), c, r, s);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]mint, n)
	ss := make([]mint, n+1)
	for i := 0; i < n; i++ {
		aa[i] = mint(getNextInt(scanner))
		ss[i+1] = ss[i].add(aa[i])
	}
	var ans mint
	for i := 0; i < n; i++ {
		ans.addAs(aa[i].mul(ss[i]))
	}
	fmt.Fprintln(writer, ans)
}

type mint int64

func (mt mint) mod() mint {
	m := mint(1e9 + 7)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) inv() mint {
	return mt.pow(mint(0).sub(2))
}
func (mt mint) pow(n mint) mint {
	p := mint(1)
	for n > 0 {
		if n&1 == 1 {
			p.mulAs(mt)
		}
		mt.mulAs(mt)
		n >>= 1
	}
	return p
}
func (mt mint) add(x mint) mint {
	return (mt + x).mod()
}
func (mt mint) sub(x mint) mint {
	return (mt - x).mod()
}
func (mt mint) mul(x mint) mint {
	return (mt * x).mod()
}
func (mt mint) div(x mint) mint {
	return mt.mul(x.inv())
}
func (mt *mint) addAs(x mint) *mint {
	*mt = mt.add(x)
	return mt
}
func (mt *mint) subAs(x mint) *mint {
	*mt = mt.sub(x)
	return mt
}
func (mt *mint) mulAs(x mint) *mint {
	*mt = mt.mul(x)
	return mt
}
func (mt *mint) divAs(x mint) *mint {
	*mt = mt.div(x)
	return mt
}


Measured memory_bytes: 9332
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;


using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	ll n, a, b;
	cin >> n >> a >> b;
	ll dif = n % (a + b);
	ll ans = n / (a + b);
	ans *= a;
	if (dif >= a) ans += a;
	else ans += dif;

	cout << ans << endl;


	return 0;
}


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

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

    int ans = 1;
    for (int i = 2; i <= sqrt(x); i++) {
        int buff = 1;
        while (true) {
            buff *= i;
            if (buff > x) break;
            ans = max(ans, buff);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<iostream>
#include<cstdlib>
using namespace std;
const int maxn=1e5;

int n,x,y,t,a[maxn];
char s[maxn];
int main(){
	cin>>x>>y;
	cout<<x+y/2<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
const ll INF = 1e18;

VV<> dp(301, V<>(301, INF));
ll res = INF;

int main(){
    INT(n, k); 
    VEC(int, h, n); h.pb(0);
    if(n == k){
        print(0);
        return 0;
    }
    dp[0][n] = 0;
    REP(i, n) REP(j, i + 1) REP(k, n + 1) if(i != k) chmin(dp[j + 1][i], dp[j][k] + max(h[i] - h[k], 0));
    REP(j, n) chmin(res, dp[n - k][j]);
    print(res);
}

Measured memory_bytes: 4292
N = int(input())
N_1 = round(N/3, 6)
N_2 = round(N/3, 6)
N_3 = round(N/3, 6)

if N_1+N_2+N_3!=N:
  N_3 += N-(N_1+N_2+N_3)
print(N_1*N_2*N_3)


Measured memory_bytes: 38256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;
 
typedef pair<int,int> P;

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin >> a[i];
		a[i]--;
	}
	int ans=0;
	for(int i=0;i<N;i++){
		if(a[a[i]]==i)
			ans++;
	}
	cout << ans/2 << endl;
	return 0;
}

Measured memory_bytes: 640
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string();

    let mut num_rl_vec: Vec<(usize, usize)> = Vec::new();

    //(num of r, num of l)
    let mut new_elem: (usize, usize) = (0, 0); 
    let mut l_occured = false;
    //seperate and count
    for ch in s.chars(){
        if !l_occured{
            if ch == 'R'{
                new_elem.0 += 1;
            }else{
                l_occured = true;
                new_elem.1 += 1;
            }
        }else{
            if ch == 'R'{
                l_occured = false;
                num_rl_vec.push(new_elem);
                new_elem = (1, 0);
            }else{
                new_elem.1 += 1;
            }
        }
    }
    num_rl_vec.push(new_elem);

    for num_rl in num_rl_vec{
        //calculate
        let final_num_r = (num_rl.0 - num_rl.0/2) + (num_rl.1/2);
        let final_num_l = (num_rl.1 - num_rl.1/2) + (num_rl.0/2);        
        //println!("{}, {}", final_num_r, final_num_l);

        for _ in 0..num_rl.0-1{
            print!("0 ");
        }

        print!("{} {} ", final_num_r, final_num_l);
        
        for _ in 0..num_rl.1-1{
            print!("0 ");
        }
    }
    println!("");
 }


Measured memory_bytes: 4476
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            //Console.WriteLine("INPUT A B T:");
            string inputbuf = Console.ReadLine();
            string[] inputdata = inputbuf.Split(' ');
            int A = Convert.ToInt32(inputdata[0]);
            int B = Convert.ToInt32(inputdata[1]);
            int T = Convert.ToInt32(inputdata[2]);

            int con = 1;
            int biscuit_num = 0;
            while (con <= T)
            {
                if (con % A == 0)
                    biscuit_num = biscuit_num + B;
                con++;
            }

            //Console.WriteLine("OUTPUT:");
            Console.WriteLine(biscuit_num);
            //Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(false);cin.tie();cout.tie();
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int main()
{
    speed
    int a,b;
    cin>>a>>b;
    int w=a/b;
    if(a%b!=0)
        w++;
    cout<<w;
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
O=10**9+7
D=[1]+[0]*input()
M=len(raw_input())
for _ in D[1:]:D=[D[0]+D[1]]+[(i+2*j)%O for i,j in zip(D[2:]+[0],D[:-1])]
print D[M]*(-~O/2)**M%O

Measured memory_bytes: 73244
#include <stdio.h>
#include <string.h>
int main(void)
{
 char S[101];
 int A;
 int i;
 scanf("%s",S);
 A = strlen(S);
 for(i=0;i<A;i++)
 {
  printf("x");
 }
 printf("\n");
// printf("%d\n",A);
 return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
int main(){
	ll n,m;
	while(cin>>n>>m,n+m){
		vi in(m);
		rep(i,m)cin>>in[i];
		vi ha(m);
		rep(i,m)rep(j,m)if(i!=j&&in[i]%in[j]==0)ha[i]=1;
		vi tmp;
		rep(i,m)if(ha[i]==0)tmp.pb(in[i]);
		in=tmp;
		ll out=n*(n+1)/2,cnt=n;
		ll m=in.size();
		ll N=1<<m;
		loop(i,1,N){
			ll t=1;
			ll co=0;
			rep(j,m)if(i&1<<j){
				t=lcm(t,in[j]),co++;
				if(t>n)break;
			}
			if(t>n)continue;
			ll q=n/t;
			if(co%2)out-=t*q*(q+1)/2,cnt-=q;
			else out+=t*q*(q+1)/2,cnt+=q;
		}
		if(cnt==0)cnt=1;
		cout<<shosu(9)<<(double)out/cnt<<endl;
	}
}

Measured memory_bytes: 3296
n,k,s=map(int,input().split())
sMax=10**9
if k==0:
    if s==sMax:
        print("1 "*n)
    else:
        print((str(sMax)+" ")*n)
else:
    if s==sMax:
        print((str(s)+" ")*k+"1 "*(n-k))
    else:
        print((str(s)+" ")*k+(str(sMax)+" ")*(n-k))

Measured memory_bytes: 6260
#include <stdio.h>
#include <string.h>
int main(){
  int a[5];
  int i,j;
  int tmp;
  for(i=0;i<5;i++)scanf("%d",&a[i]);

  for(i=0;i<5;i++){
    for(j=4;j>i;j--){
      if(a[j]>a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }
  for(i=0;i<4;i++)
  printf("%d ",a[i]);
  printf("%d\n",a[4]);
  return 0;
}

Measured memory_bytes: 596
s = input()

ops = ["-", "-", "-"]
n = 3

for i in range(n**3):
    ops = ["-", "-", "-"]
    for j in range(n):
        if i >> j & 1:
            ops[j] = "+"
    f = s[0] + ops[0] + s[1] + ops[1] + s[2] + ops[2] + s[3]
    if eval(f) == 7:
        print(f + "=7")
        break


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

#define STRING(str) #str

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;

	long long ans = -3e18;
	ans = max(ans, a*c);
	ans = max(ans, a*d);
	ans = max(ans, b*c);
	ans = max(ans, b*d);
	if (a<=0 && 0<=b) ans = max(ans, 0LL);
	if (c<=0 && 0<=d) ans = max(ans, 0LL);
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main() {
	string A;
	cin >> A;	
	 if (A == "111") {
		cout << "999" << endl;
	}
			else if (A == "119") {
			cout << "991" << endl;
		}
				else if (A == "199") {
				cout << "911" << endl;
		}
		else if (A == "191") {
			cout << "919" << endl;
		}
		else if (A == "911") {
		cout << "199" << endl;
		}
		else if (A == "919") {
		cout << "191" << endl;
		}
		else if (A == "991") {
		cout << "119" << endl;
		}
		else if (A == "999") {
		cout << "111" << endl;
		}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool cmp(char a,char b)
{
    return a>b;
}
int main()
{
string a,b;
cin>>a>>b;
sort(a.begin(),a.end());
sort(b.begin(),b.end(),cmp);
//cout<<a<<" "<<b<<endl;
int i=0,j=0;
int is=0,js=0;
while(i<a.size()&&j<b.size())
{
    if(a[i]<b[j])
    {
        js=1;
        break;
    }
    if(a[i]>b[j])
    {
        is=1;
        break;
    }
    i++,j++;
}
if(is==1)
{
    cout<<"No"<<endl;
}
else if(js==1)
cout<<"Yes"<<endl;
else
{
    if(a.size()<b.size())
    cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
return 0;
}
 


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
// chctxdy
string ans;
int main(){
	ll n, m; cin >> n >> m;
	for (ll i = 0; i<n; i++) ans.pb(' ');
	for (ll i = 0; i<m; i++){
		ll pos, val; cin >> pos >> val;
		if (pos == 1 && val == 0 && n > 1){
			cout << -1; return 0;
		}
		else if (ans[pos - 1] != ' ' && ans[pos - 1] != val + '0'){
			cout << -1; return 0;
		}
		else ans[pos - 1] = val + '0'; 
	}
	for (ll i = 0; i<n; i++){
		if (ans[i] == ' '){
			if (i != 0 || n == 1) ans[i] = '0';
			else ans[i] = '1';
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 999999999
const int mod = 1000000007;
ll cnt = 0;
 
int main(){
 ll n;  cin >> n;
 vector<int> a(n),b(n);

 for(int i=0;i<n;i++){
     cin >> a.at(i);
     b[i] = a[i];
 }
 sort(b.begin(),b.end());

 ll l,r;
 l = b.at(n/2-1);
 r = b.at(n/2);

for(int i=0;i<n;i++){
    if(a[i]>=r)cout << l << endl;
    else cout << r << endl;
}




}

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

int main(){

  int a[1224];
  int n, i, max1 = -1000000, min1 = 10000000;

  cin >> n;

  for(i = 0; i < n; i++){
    cin >> a[i];
    max1 = max(max1, a[i]);
    min1 = min(min1, a[i]);
  }
  cout << max1 - min1 << endl;
  return 0;
}


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

int main() {
  ll n, k;
  cin >> n >> k;
  map<ll, ll> mp;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    mp[a] += b;
  }

  ll ans, cnt = 0;
  for (auto x : mp) {
    cnt += x.second;
    if (k <= cnt) {
      ans = x.first;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main() {
  int N, K, C;
  string S;
  cin >> N >> K >> C >> S;
  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }
  vector<int> max_before(N + C + 10);
  for (int i = 0; i < N; i++) {
    if (S[i] == 'o') {
      max_before[i]++;
      i += C;
    }
  }
  for (int i = 1; i < N; i++) {
    max_before[i] += max_before[i - 1];
  }
  vector<int> max_after(N + C + 10);
  for (int i = N - 1; i >= 0; i--) {
    if (S[i] == 'o') {
      max_after[i]++;
      i -= C;
    }
  }
  for (int i = N - 2; i >= 0; i--) {
    max_after[i] += max_after[i + 1];
  }

  vector<int> ans;
  if (S[0] == 'o' and max_after[1] < K) ans.push_back(1);
  for (int i = 1; i < N - 1; i++) {
    if (S[i] == 'x') continue;
    if (max_before[i - 1] + max_after[i + 1] < K) ans.push_back(i + 1);
  }
  if (S[N - 1] == 'o' and max_before[N - 2] < K) ans.push_back(N);

  for (auto a : ans) {
    cout << a << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
const int INF = 1e8;

int main(){
    string S; Int K;
    cin >> S >> K;

    Int N = S.size();
    Int ans = 0;
    
    Int head = -1, tail = N;
    if(S[0] == S[N-1]){
        while(S[0] == S[head+1]) head++;

        while(S[0] == S[tail-1]) tail--;

        Int n_head = head+1, n_tail = N-tail;

        ans += n_head/2 + n_tail/2;
        ans += (n_head+n_tail)/2 * (K-1);
    }

    if(head == N-1){
        if(N % 2 == 0) cout << N/2 * K << endl;
        else {
            if(K % 2 == 0) cout << N * K/2 << endl;
            else cout << N * (K/2) + N/2 << endl;
        }
        return 0;
    }
    

    for(int i=head+1; i<tail-1; i++){
        if(S[i+1] == S[i]){
            S[i+1] = '0';
            ans += K;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
// rep(i,1,10) is from 1 to 9 and rep(I,10,1) is from 9 to 1
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back //FASTER THAN PUSH BACK!
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int modp(int a,int n)
{
    if(n==0) return 1;
    if(n==1) return a;
    int res=modp(a,n/2);
    if(n%2==0) return (res*res);
    else return (a*res*res);
}

vi adj[1000000];


void solve()
{
    int t,n,m,i,k,l,r,u,v,w,j,s,sum=0,pos=-1,flag=0,count=0;
    string S,T,U;
    // int a,b;
    cin>>n>>m;
    vi h(n+1);
    rep(i,0,n) cin>>h[i+1];
    while(m--)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    rep(i,1,n+1)
    {
        for(int x:adj[i])
        {
            if(h[x]>=h[i]) flag=1;
        }
        if(!flag) count++;
        flag=0;
    }
    cout<<count;
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 30920
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 1e18

int main(){
    int x, y;
    bool flag = false;
    cin >> x >> y;
    for(long i=x*2; i<=MAX; i += x){
        if(x == y) break;
        if(x%y == 0) break;
        if(i%x == 0 && i%y != 0 && i <= MAX){
            cout << i << endl;
            flag = true;
            break;
        }
    }
    if(!flag) cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
int main()
{
    int k;
    std::string s;
    std::cin>>k;
    std::cin>>s;
    std::size_t lg=s.length();
    if(lg<=k){
        std::cout<<s;
    }else{
        std::cout<<s.erase(k,lg-k);
        std::cout<<"...";
    }
    std::cout<<std::endl;
    return 0;
}

Measured memory_bytes: 3632
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;

int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0 ,0 };


int main(void) {
	int k;
	int p, q;

	cin >> k;

	p = k / 2;
	q = k - p;

	cout << p * q << endl;

	return 0;
}

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

#define V_MAX 1100
#define INF (1<<25)
#define pb push_back
#define sz size()
#define clr clear()

struct edge{int f,t,cost,cap,rev;};

vector<edge> G[V_MAX];
bool use[V_MAX];
int m,n;
int b[500],r[500];


void AddEdge(int from,int to,int cap){
  G[from].push_back((edge){from,to,0,cap,G[to].size()});
  G[to].push_back((edge){to,from,0,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  use[v] = true;
  for(int i=0;i<(int)G[v].size();i++){
    edge &e  = G[v][i];
    if(!use[e.t] && e.cap > 0){
      int d = dfs(e.t, t,min(f,e.cap));
      if(d>0){
	e.cap -= d;
	G[e.t][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

int FordFullkerson(int s,int t){
  int flow = 0;
  for(;;){
    memset(use,0,sizeof(use));
    int tmp = dfs(s,t,INF);
    if(!tmp)return flow;
    flow += tmp;
  }
} 

int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}

int main(){
  while(1){
    cin >> m >> n;
    if(!m && !n)break;

    for(int i=0;i<m;i++)cin >> b[i];
    for(int i=0;i<n;i++)cin >> r[i];

    for(int i=0;i<=m+n+1;i++)G[i].clr;
    for(int i=1;i<=m;i++)AddEdge(0,i,1);
    for(int i=m+1;i<=m+n;i++)AddEdge(i,m+n+1,1);

    for(int i=0;i<m;i++)
      for(int j=0;j<n;j++)
	if(gcd(b[i],r[j])>1)AddEdge(i+1,m+j+1,1);

    cout << FordFullkerson(0,m+n+1) << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s;
  cin >> s;
  int siz = s.length();
  ll ans = 0;
  for (int bit = 0; bit < (1<<(siz-1)); ++bit) {
    ll temp = 0;
    rep(i,siz) {
      temp = temp*10 + (s[i]-'0');
      if (i < siz-1 && !(bit & (1<<i))) { //フラグなし:+ (+で区切りがつく)
        ans += temp;
        temp = 0;
      }
    }
    ans += temp;
  }
  cout << ans << endl;
  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

ll n,m,q; 
vll a,b,c,d;

ll ans=0;
void rec(vll v, ll len){
  if(len>=n-1){
    ll tmp=0;
    rep(i,q){
      if(v[b[i]]-v[a[i]]==c[i]) tmp+=d[i];
    }
    chmax(ans,tmp);
    return;
  }
  
  ireps(i,v[len],m){
    v[len+1]=i;
    rec(v,len+1);
  }
  
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>m>>q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  rep(i,q){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    a[i]--,b[i]--;
  }
  
  vll v(n);
  reps(i,m){
    v[0]=i;
    rec(v,0);
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3656
<?php
$sc = new Scanner();

$coin_500 = $sc->nextInt();
$coin_100 = $sc->nextInt();
$coin_50 = $sc->nextInt();
$total = $sc->nextInt();

$case = 0;

$coin_total = 0;
for ($i = 0; $coin_500 >= $i; $i++) {
    for ($j = 0; $coin_100 >= $j; $j++) {
        for ($k = 0; $coin_50 >= $k; $k++) {
            $coin_total = 500 * $i + 100 * $j + 50 * $k;
            if ($coin_total === $total) {
                $case++;
            }
        }
    }
}

out::println($case);


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 (double)$this->next();
    }
}

class out
{
    public static function println($str = "")
    {
        echo $str . PHP_EOL;
    }
}

Measured memory_bytes: 4732
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int B[100];
int C[100];
int A[100];
int main()
{
  //flash;
  int n;
  cin>>n;
  int sum=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-1; ++i)
  {
  	cin>>C[i];
  }
  for (int i = 0; i < n; ++i)
  {
  	sum+=(B[A[i]-1]);
  	//debug(sum);
  	//debugs(A[i+1],A[i]-1);
  	if(i!=n-1 && A[i+1]==(A[i]+1))
  	{
  		//debugs(A[i+1],A[i]-1);
  		sum+=(C[A[i]-1]);
  	}
  }
  cout<<sum;
  return 0;
}
//code the AC sol !
// BS/queue/map


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

using namespace std;

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int x;
    cin >>x;
    vector<bool> dp(x+1);
    fill(all(dp),false);

    dp[100]=true;
    dp[101]=true;
    dp[102]=true;
    dp[103]=true;
    dp[104]=true;
    dp[105]=true;

    for (int i = 0; i <= x; i++){
        for (int j = 100; j <= 105; j++){
            if(dp[i] && i+j<=x)dp[i+j]=true;
        }
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << dig(n) << endl;

    if(dp[x])cout << "1" <<endl;
    else cout << "0" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
  int n;
  cin>>n;
  for (int i=0;i<n;i++){
    double x1,x2,x3,y1,y2,y3;
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    double a,b,c,d,e,f;
    a=-2*x1+2*x2;
    b=-2*y1+2*y2;
    c=x2*x2+y2*y2-x1*x1-y1*y1;
    d=-2*x1+2*x3;
    e=-2*y1+2*y3;
    f=x3*x3+y3*y3-x1*x1-y1*y1;
    double x=(c*e-b*f)/(a*e-b*d),y=(c*d-a*f)/(b*d-a*e);
    double r=(x1-x)*(x1-x)+(y1-y)*(y1-y);
    r=sqrt(r);
    printf("%.3f %.3f %.3f\n",x,y,r);
  }
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
//const ll INF = 1e18+3;
const ll mod = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;

//#include<iostream>
//#include<queue>
//using namespace std;
const int dir[4][2]={{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
const int INF=1e9;

int main() {
    int n,m,k,x1,y1,x2,y2;
    cin>>n>>m>>k>>x1>>y1>>x2>>y2;
    x1--;
    x2--;
    y1--;
    y2--;
    char mp[n][m]={};
    int dis[n][m]={};
    int i,j,ans=0;
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            cin>>mp[i][j],dis[i][j]=INF;
    queue<pair<int,int> >que;
    dis[x1][y1]=0;
    que.push(make_pair(x1,y1));
    while (!que.empty())
    {
        int x=que.front().first;
        int y=que.front().second;
        que.pop();
        for(i=0;i<4;i++)
        {
            int nx=x, ny=y;
            int nd=dis[x][y]+1;
            for(j=1; j<=k; j++)
            {
                nx+=dir[i][0];
                ny+=dir[i][1];
                if (nx<0||ny<0||nx>=n||ny>=m||mp[nx][ny]=='@'||dis[nx][ny]<nd)
                    break;
                if(dis[nx][ny]>nd)
                {
                    dis[nx][ny]=nd;
                    que.push(make_pair(nx, ny));
                }
            }
        }
    }
    ans=dis[x2][y2];
    cout<<(ans == INF ? -1 : ans);
    return 0;
}



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

using namespace std;

//#define WAIT cout << flush,system("pause");
#define TRUE 1
#define FALSE 0

typedef pair<int, int> ii;
typedef vector<int> vi; 
typedef long long ll;
typedef vector< ii > vii; 
typedef pair<int , pair<int , int> > tri;

#define F first
#define S second


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string s,ans;
	getline(cin,s);
	
	for(int i = 0; i < s.length(); ++i){
		
		if(s[i] >= 'a' && s[i] <= 'z')
			ans.push_back(toupper(s[i]));
			
		else if(s[i] >= 'A' && s[i] <= 'Z')
			ans.push_back(tolower(s[i]));
		
		else
			ans.push_back(s[i]);
	}
	
	cout << ans << '\n';
	
	//WAIT
}









Measured memory_bytes: 3204
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, max, min;
    cin >> a >> b >> c;
    
    if(a < b){
        if(c < b){
            max = b;
        }else{
            max = c;
        }
    }else{
        if(c < a){
            max = a;
        }else{
            max = c;
        }
    }
    if(a < b){
        if(c < a){
            min = c;
        }else{
            min = a;
        }
    }else{
        if(c < b){
            min = c;
        }else{
            min = b;
        }
    }
    cout << min << " " <<(a+b+c)-(min+max) << " " << max << endl;
    
    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
ll a,b,visit[500005];
vector<ll> v[500005];
void dfs(ll cur)
{
	visit[cur]=1;
	if(cur>100000) a++;
	else b++;
	for(auto x:v[cur]) if(!visit[x]) dfs(x);
}
int main()
{
	ll n,i,x,y;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>x>>y;
		v[x].pb(y+100000);
		v[y+100000].pb(x);
	}
	ll s=0;
	for(i=1;i<=200000;i++)
	{
		if(!visit[i])
		{
			a=0;
			b=0;
			dfs(i);
			s+=a*b;
		}
	}
	cout<<s-n;
	return 0;
}

Measured memory_bytes: 19584
unittest
{
	assert( [ "5 3", "-10 10 -10 10 -10" ].parse.expand.solve == 10 );
	assert( [ "4 2", "10 -10 -10 10" ].parse.expand.solve == 20 );
	assert( [ "1 1", "-10" ].parse.expand.solve == 0 );
	assert( [ "10 5", "5 -4 -5 -8 -4 7 2 -4 0 7" ].parse.expand.solve == 17 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nk[ 1 ], as );
}

auto solve( long k, long[] as )
{
	// 全体を白or黒で塗る⇒範囲を狭めて逆の色で塗る⇒更に範囲を狭めて逆の色で塗る⇒(繰り返し)
	// のように塗ると、最後のkマス以外は連続するマス数を気にせずに好きな色で塗れる
	
	// 最後のkマスを全検索してスコアの最大値を計算
	auto ans = 0L;
	auto t  = as[ 0 .. k ].sum;
	auto lp = 0L;
	auto rp = as[ k .. $ ].filter!( ( a ) => 0 < a ).sum;
	for( auto li = 0L, ri = k;; li++, ri++ )
	{
		ans = max( ans, lp + rp + ( ( 0 < t ) ? t : 0 ) );
		if( ri == as.length ) break;
		t += as[ ri ] - as[ li ];
		if( 0 < as[ li ] ) lp += as[ li ];
		if( 0 < as[ ri ] ) rp -= as[ ri ];
	}
	return ans;
}


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

#define IL inline
IL int read() {
	char ch = getchar(); int u = 0, f = 1;
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); }
	return u * f; 
}

bitset<10050>dp[2010];
pair<int, int>F[2][10010];
string s[2010];
char ans[1000010];
int len[2010];
int main() {
#ifdef Edgration
	freopen("in", "r", stdin);
#endif
	int n = read(), k = read();
	for (int i = 1; i <= n; ++i) {
		cin >> s[i];
		len[i] = s[i].size();
	}
	dp[n + 1][0] = 1;
	for (int i = n; i >= 1; --i) dp[i] = dp[i + 1] | (dp[i + 1] << len[i]);
	int ll = 0;
	for (int i = 1; i <= n; ++i) if (dp[i + 1][k - len[i]]) F[0][++ll] = (make_pair(i, 0));
	int T = 0;
	for (int i = 0; i < k; ++i) {
		char minchar = 'z';
		for (int j = 1; j <= ll; ++j) minchar = min(minchar, s[F[T][j].first][F[T][j].second]);
		ans[i] = minchar;
		int minid = n + 1; int cur = 0;
		for (int j = 1; j <= ll; ++j) {
			int NowId = F[T][j].first; int NowLen = F[T][j].second;
			if (s[NowId][NowLen] != minchar) continue;
			if (NowLen + 1 == len[NowId]) minid = min(minid, NowId);
			else F[T ^ 1][++cur] = make_pair(NowId, NowLen + 1);
		}
		for (int j = minid + 1; j <= n; ++j) 
			if (k - len[j] - i - 1 >= 0 && dp[j + 1][k - len[j] - i - 1]) F[T ^ 1][++cur] = make_pair(j, 0);
		ll = cur;
		T ^= 1;
	}
	printf("%s", ans);
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,x,y;
    cin>>n>>x>>y;
    if((n>1&&y>=x)||(n==1&&x==y)){
        cout<<(n-2)*(y-x)+1<<endl;
    }
    else cout<<0<<endl;
    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;

    int res = 0;
    rep(i, 2) {
        if (a > b) res += a, --a;
        else res += b, --b;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int d;
  cin >> d;
  switch (d){
  case 22: cout << "Christmas Eve Eve Eve" << endl; break;
  case 23: cout << "Christmas Eve Eve" << endl; break;
  case 24: cout << "Christmas Eve" << endl; break;
  case 25: cout << "Christmas" << endl; break;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int main(){
    IOS
    //io_set();
    ll n,i,j,m=INT_MAX;
    cin>>n;
    ll a[n],s=0;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=-100;i<=100;i++){
        ll ans=0;
        for(j=0;j<n;j++){
            ans+=((abs(i-a[j]))*(abs(i-a[j])));
        }
        m=min(m,ans);
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256