akhauriyash/Code-Regression huggingface dataset:
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数定義や変数宣言







//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int n;
cin>>n;
int sum=0;


for (int i = 1; i <=n; ++i)
{
	if (i%15!=0 && i%5!=0 && i%3!=0)
	{
		sum+=i;
	}
}

cout<<sum<<endl;




return 0;

}

Measured memory_bytes: 3584
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

ll ceil(ll x, ll y){
  return (x + y - 1) / y;
}

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

  int n;
  cin >> n;
  ll a[n], b[n];
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }

  ll k = 0;
  for(int i = n - 1; i >= 0; i--){
    k += ceil((a[i] + k), b[i]) * b[i] - (a[i] + k);
  }

  cout << k << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;


static const long long mod = 1000000007;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b, n;
  cin >> a >> b >> n;

  auto g = [&](ll x){
    return (a*x)/b - a*(x/b);
  };

  cout << g(min(b - 1, n)) << endl;

  return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)

string A[8];
signed main()
{
	int h,w;cin>>h>>w;
	rep(i,h)cin>>A[i];
	rep(i,h)rep(j,w) {
		if (A[i][j] != '#') continue;
		if (i+1<h and j+1<w and A[i+1][j] == '#' and A[i][j+1] == '#') {
			cout << "Impossible\n";
			return 0;
		}
		if (i-1>=0 and j-1>=0 and A[i-1][j] == '#' and A[i][j-1] == '#') {
			cout << "Impossible\n";
			return 0;
		}
	}

	cout << "Possible\n";
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

const INF: usize = 0x3f3f3f3f;

fn main(){
    let (h, w): (usize, usize) = readln();
    let mut c: Vec<Vec<char>> = Vec::with_capacity(h);
    for _ in 0..h {
        let cs = get_chars();
        c.push(cs);
    }

    let mut res = 0;
    for l in 0..w-1 {
        let r = l + 1;
        let mut dp: Vec<Vec<usize>> = vec![vec![INF;h+1];h+1];
        let mut cost: Vec<Vec<usize>> = vec![vec![0;h+1];h+1];
        for d in 0..h {
            cost[h-d][h] = 0;
            cost[h][h-d] = 0;
            for i in (0..h-d).rev() {
                cost[i][i+d] = cost[i+1][i+1+d];
                if c[h-1-i][l] == c[h-1-i-d][r] {
                    cost[i][i+d] += 1;
                }
                cost[i+d][i] = cost[i+1+d][i+1];
                if c[h-1-i-d][l] == c[h-1-i][r] {
                    cost[i+d][i] += 1;
                }
            }
        }

        dp[0][0] = 0;
        for i in 0..h+1 {
            for j in 0..h+1 {
                if i > 0 {
                    dp[i][j] = min(dp[i][j], dp[i-1][j] + cost[i-1][j]);
                }
                if j > 0 {
                    dp[i][j] = min(dp[i][j], dp[i][j-1] + cost[i][j-1]);
                }
            }
        }
        res += dp[h][h];
    }

    println!("{}", res);
}


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

#[allow(dead_code)]
fn get_chars() -> Vec<char>{
    get_line().chars().collect()
}

#[allow(dead_code)]
fn readln<T: Read>() -> T{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

trait Read{
    fn read(s: &str) -> Self;
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl<T: Read> Read for Vec<T>{
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B){
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C){
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

Measured memory_bytes: 2556
#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
#define ll long long 



int main()
{
	ll n,w,i,j;
	cin>>n>>w;
	ll a[n][2];
	ll maxval=1000*n;
	ll dp[n+1][maxval+1];
	for(i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1];
	}
	for(i=0;i<=maxval;i++)
	{
		dp[1][i]=INT_MAX;
	}
	dp[1][a[0][1]]=a[0][0];
	dp[1][0]=0;
	for(i=2;i<=n;i++)
	{
		for(j=0;j<=maxval;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=a[i-1][1])
			{
				dp[i][j]=min(dp[i][j],dp[i-1][j-a[i-1][1]]+a[i-1][0]);
			}
		}
	}
	ll ans=0;
	for(i=0;i<=maxval;i++)
	{
		if(dp[n][i]<=w)
		{
			ans=i;
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 81672
using System;
using System.Collections.Generic;
using System.Linq;

namespace College
{
    class Program
    {
        static string Join(int[] input)
        {
            string result = "";

            foreach(int i in input)
                result += (" " + i.ToString());

            return result;
        }

        static void Main(string[] args)
        {
            List<List<int[]>> college = new List<List<int[]>>(){
                new List<int[]>(){
                    new int[]{0, 0, 0, 0, 0, 0 ,0, 0, 0, 0},
                    new int[]{0, 0, 0, 0, 0, 0 ,0, 0, 0, 0},
                    new int[]{0, 0, 0, 0, 0, 0 ,0, 0, 0, 0}
                },
                new List<int[]>(){
                    new int[]{0, 0, 0, 0, 0, 0 ,0, 0, 0, 0},
                    new int[]{0, 0, 0, 0, 0, 0 ,0, 0, 0, 0},
                    new int[]{0, 0, 0, 0, 0, 0 ,0, 0, 0, 0}
                },        
                new List<int[]>(){
                    new int[]{0, 0, 0, 0, 0, 0 ,0, 0, 0, 0},
                    new int[]{0, 0, 0, 0, 0, 0 ,0, 0, 0, 0},
                    new int[]{0, 0, 0, 0, 0, 0 ,0, 0, 0, 0}
                },
                new List<int[]>(){
                    new int[]{0, 0, 0, 0, 0, 0 ,0, 0, 0, 0},
                    new int[]{0, 0, 0, 0, 0, 0 ,0, 0, 0, 0},
                    new int[]{0, 0, 0, 0, 0, 0 ,0, 0, 0, 0}
                }
            };

            int limit = int.Parse(Console.ReadLine());

            for(int i = 0; i < limit; i++)
            {
                int[] _c = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray();
                college[_c[0] - 1][_c[1] - 1][_c[2] - 1] = college[_c[0] - 1][_c[1] - 1][_c[2] - 1] + _c[3];
            }

            for(int j = 0; j < college.Count; j++)
            {
                List<int[]> b = college[j];

                foreach(int[] r in b)
                {
                    Console.WriteLine(Join(r));
                }

                if(j != college.Count - 1)
                    Console.WriteLine(new string('#', 20));
            }
        }
    }
}

Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9

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

    vector<int> x(N);
    for (int i = 0; i < N ; i++){
        cin >> x.at(i);
    }
    int A_dis = 0;
    int B_dis = 0;
    int A_pos = 0;
    int B_pos = K;

    for(int i = 0; i < N; i++){
        if(abs(A_pos - x.at(i)) <= abs(B_pos - x.at(i))){
            A_dis = A_dis + 2 * x.at(i);
        }else{
            B_dis = B_dis + 2 * abs(x.at(i) - B_pos);
        }
    }

    cout << A_dis + B_dis << endl;
}


Measured memory_bytes: 256
require 'set'
N, M = gets.split.map(&:to_i)
h = Hash.new{|h1, k| h1[k] = Set.new}
M.times do
  a, b = gets.split.map(&:to_i)
  h[a] << b 
  h[b] << a 
end

def route(h, x, st)
  nx = h[x] - st
  if nx.size == 0 
    return st.size == N - 1 ? 1 : 0 
  end
  tot = 0 
  st1 = st.dup
  st1 << x 
  nx.each do |y|
    tot += route(h, y, st1)
  end
  tot 
end
  
puts route(h, 1, Set.new)

Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int s;
  int a,b,c;
  cin>>s;
  a=s/100;
  b=(s-100*a)/10;
  c=(s-100*a-10*b)/1;
  /*cout<<a<<endl<<b<<endl<< c<<endl;*/
  cout<<a+b+c;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int X, Y;
signed main() {
    cin >> X >> Y;
    if (abs(X - Y) > 1) {
        cout << "Alice" << endl;
    } else {
        cout << "Brown" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

func abs(n int) int {
	if n < 0 {
		return -n
	} else {
		return n
	}
}

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

	ABCD := strings.Split(sc.Text(), " ")
	A, _ := strconv.Atoi(ABCD[0])
	B, _ := strconv.Atoi(ABCD[1])
	C, _ := strconv.Atoi(ABCD[2])
	D,_:=strconv.Atoi(ABCD[3])

	if abs(A - C) <= D || (abs(A - B) <= D && abs(B - C) <= D) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

using namespace std;

typedef double ll;

struct Point
{
    ll x,y;
    Point(){ x = y = 0.0; }
    Point(ll _x, ll _y) : x(_x), y(_y){}

    Point operator+ (Point p)
    {
        return Point(p.x + x, p.y + y);
    }

    Point operator- (Point p)
    {
        return Point(x - p.x, y - p.y);
    }

    ll operator* (Point p)
    {
        return p.x * x + p.y * y;
    }

    Point operator* (ll t)
    {
        return Point(x*t, y*t);
    }

    ll operator~ ()
    {
        return x * x + y * y;
    }

    ll operator% (Point p)
    {
        return x * p.y - y * p.x;
    }

};

Point areIntersectSegment(Point a, Point b, Point p, Point q)
{
    Point v1=(b-a);
    Point v2=(q-p);
    double t;
    t = (double)(( p - a ) % v2) / (double)(v1 % v2);
    return a + v1*t;
}

int main()
{
    cout << fixed;
    cout.precision(10);
    ios::sync_with_stdio(0); cin.tie(0);
    Point p0,p1,p2,p3,ans;
    Point vec, vec1;
    int q;
    cin >> q;
    while(q--)
    {
        cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
        ans = areIntersectSegment(p0,p1,p2,p3);
        cout << ans.x << " " << ans.y << '\n';
    }
    return 0;
}

Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define mem(a, b)     memset(a, b, sizeof(a))
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*sort(v.begin(), v.end(),
     [](const pair<int, int>& x, const pair<int, int>& y)
{
    if (x.first != y.first)
        return x.first < y.first;
    return x.second < y.second;
});
*/
int const fx[]= {+1,+0,-1,+1};
int const fy[]= {-1,+1,+0,+0};
const int inf = numeric_limits<int>::max();
const int mx=2e5;
const ll mod=1e9+7;
ll pow(ll x,ll n)
{
    ll res=1;
    while(n)
    {
        if(n%2)
        {
            res=res*x;
            n--;
        }
        x=x*x;
        n/=2;
    }
    return res;
}
int main()
{
    string s="aabcdefghijklmnopqrstuvwxyz";
    ll n,i,sum=0;
    cin >> n;
    i=0;
    while(sum<n)
    {
        i++;
        sum+=pow(ll(26),i);
    }
    i--;
    vector<char>v(20);
    int j;
    for(j=i;j>=0;j--)
    {
        int y=n%26;
        if(y==0)y=26;
        v[j]=s[y];
        n-=y;
        n/=26;
    }
    for(j=0;j<=i;j++)
        cout << v[j];
    cout << endl;
    return 0;
}




Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


void solve( int n, VI A ) {
    int remain = 32;
    bool flag = true;
    int k = 0;
    while( remain > 0 ) {
        if ( flag ) {
            int take = ( remain - 1 ) % 5;
            remain -= take;
            if ( remain < 0 ) remain = 0;
            cout << remain << endl;
        } else {
            remain -= A[k];
            if ( remain < 0 ) remain = 0;
            cout << remain << endl;
            k = ( k + 1 ) % n;
        }
        flag = !flag;
    }
}

int main() {
    int n;
    while ( cin >> n && n ) {
        VI A(n);
        for ( int i = 0; i < n; ++ i ) cin >> A[i];
        solve( n, A );
    }
    return 0;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, cnt = 0, d, e;
  cin >> n >> m;
  vector <int> h(n);
  for (int i = 0; i < n; ++i){
	cin >> h[i];
  }
  vector <vector<int>> o(n);
  for (int i = 0; i < m; ++i){
	cin >> d >> e;
	--d;
	--e;
	o[d].push_back(e);
	o[e].push_back(d);
  }
 
  for (int i = 0; i < n; ++i){
	bool ans = true;
		for (int j : o[i]){
			if (h[i] <= h[j]) ans = false;
		}
	if (ans) ++cnt;
  }
  
  cout << cnt << "\n";
return 0;
}


Measured memory_bytes: 8740
//C-Linear Approximation
#include <bits/stdc++.h>
using namespace std;

int main(){
  string a;
  int x=0;
  cin >> a;
  

   
  
  for(int i=0; i<4; i++){
    for(int j=0; j<4; j++){
      if(a[i]==a[j]){
        x+=1;
      }
    }
  }

  
  if(x==8){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}


Measured memory_bytes: 384
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int m, n;
	int[][] down, right;

	void run(){
		for(;;){
			m=sc.nextInt();
			n=sc.nextInt();
			if((m|n)==0){
				break;
			}
			down=new int[n][m];
			right=new int[n][m];
			for(int j=0; j<2*n-1; j++){
				int y=j/2;
				if(j%2==0){
					for(int i=0; i<m-1; i++){
						right[y][i]=sc.nextInt();
					}
					right[y][m-1]=1;
				}else{
					for(int i=0; i<m; i++){
						down[y][i]=sc.nextInt();
					}
				}
			}
			solve();
		}
	}

	void solve(){
		for(int j=0; j<n; j++){
			debug(j, right[j]);
		}
		debug();
		for(int j=0; j<n; j++){
			debug(j, down[j]);
		}

		// ツ湘」ツ可コツ債カツ右

		int[][][] w=new int[n+1][m+1][4];
		for(int i=0; i<m; i++){
			w[0][i][0]=1;
			w[n-1][i][1]=1;
		}
		for(int j=0; j<n; j++){
			w[j][0][2]=1;
			w[j][m-1][3]=1;
		}
		for(int j=0; j<n; j++){
			for(int i=0; i<m; i++){
				if(right[j][i]==1){
					w[j][i][3]=1;
					w[j][i+1][2]=1;
				}
				if(down[j][i]==1){
					w[j][i][1]=1;
					w[j+1][i][0]=1;
				}
			}
		}

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

		LinkedList<P> que=new LinkedList<P>();
		int[][] d=new int[n][m];
		for(int j=0; j<n; j++){
			fill(d[j], -1);
		}

		que.offer(new P(0, 0));
		d[0][0]=0;

		for(; !que.isEmpty();){
			P p=que.poll();
			for(int i=0; i<4; i++){
				if(w[p.y][p.x][i]==0){
					P q=new P(p.x+dx[i], p.y+dy[i]);
					if(d[q.y][q.x]==-1){
						d[q.y][q.x]=d[p.y][p.x]+1;
						que.offer(q);
					}
				}
			}
		}
		println(d[n-1][m-1]+1+"");
	}

	class P{
		int x, y;

		P(int x, int y){
			this.x=x;
			this.y=y;
		}
	}

	void debug(Object... os){
		// System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int MX = 3007;
ld a[MX];
ld p[MX][MX];

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

  for(int i=1;i<=n;i++){
    cin >> a[i];
  }

  p[0][0] = 1;
  for(int i=1;i<=n;i++){
    for(int j=0;j<=i;j++){
      if(i==j) p[i][j] = p[i-1][j-1]*a[i];
      else if(j == 0) p[i][j] = p[i-1][j] * (1-a[i]);
      else{
        p[i][j] = p[i-1][j]*(1-a[i]) + p[i-1][j-1]*a[i];
      }
    }
  }
  int half = (int) n/2+1;
  ld ans=0;
  for(int i=half;i<=n;i++){
    ans += p[n][i];
  }
  
  cout<< fixed << setprecision(20) << ans;
  return 0;
}


Measured memory_bytes: 139776
import sys
sys.setrecursionlimit(10**7)
def dfs(v):
    for w in e[v]:
        if root[w]>=0:continue
        root[w]=v
        dfs(w)
def dfs2(v):
    for w in e[v]:
        if f[w]:continue
        f[w]=1
        data[w]+=data[v]
        dfs2(w)
input=sys.stdin.readline
n,q=map(int,input().split())
e=[[]for _ in range(n)]
root=[0]+[-1]*(n-1)
data=[0]*n
for _ in range(n-1):
    a,b=map(int,input().split())
    e[a-1]+=b-1,
    e[b-1]+=a-1,
#dfs(0)
for _ in range(q):
    p,x=map(int,input().split())
    data[p-1]+=x
f=[1]+[0]*(n-1)
dfs2(0)
print(*data)

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 int n;
  cin >> n ;
  VI  x(n);
  VI  y(n);
  rep(i,n){
    cin>> x.at(i);
    y.at(i)=x.at(i);
  }
  sort(y.begin(),y.end());
  int a,b;
  a=y.at((n-1)/2);
  b=y.at((n+1)/2);
  rep(i,n){
    if(x.at(i)<=a){
      cout << b << endl;
    }
    else if(x.at(i)>=b){
      cout << a << endl;
    }
  }
}

Measured memory_bytes: 3712
#include <stdio.h>
int main(void)
{
  double w,h,x,y;
  double ans=0;
  scanf("%lf",&w);
  scanf("%lf",&h);
  scanf("%lf",&x);
  scanf("%lf",&y);
  ans = (double)(w * h) / 2;
  printf("%f ",ans);

  if((double)w/2 == x && (double)h/2 == y)
	printf("%d",1);
  else
	printf("%d",0);




  return 0;
}

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

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

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

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

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

    ll N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];
    vector<ll> b(N);
    ll rui = 0;
    REP(i, N){
    	b[i] = max((i+1) - (a[i]+1)/2-rui, 0ll);
    	rui += b[i];
    }
    //cout << b << endl;

    vector<ll> c(N);
    ll now = 1;
    REP(i, N){
    	c[i] = now;
    	now += b[i];
    }
    //cout << c << endl;

    map<ll, ll> mp;
    REP(i, N) mp[c[i]]++;

    ll res = 1;
    ll ac = 0;
    for(int i=1;i<=N;i++){
    	ac += mp[i];
    	res *= (ac - (i-1));
    	res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8832
N=io.read"*n"
i=1
s=0
while true do
	s=s+math.floor(26^i+.5)
	if(N<s)then break end
	i=i+1
end
s=N-s+math.floor(26^i+.5)-1
if(s<0)then i=i-1 s=math.floor(26^i+.5)-1 end
r={}
ab=string.byte"a"
for j=1,i do
	r[i-j+1]=string.char(ab+s%26)
	s=(s-s%26)/26
end
print(table.concat(r))

Measured memory_bytes: 3060
#include <iostream>
#include <complex>
#include <vector>
#include <queue>
#include <cstdio>
using namespace std;

typedef complex<double> Point;
typedef pair <int, double> Edge;
typedef vector <Edge> Graph;
typedef pair <double, int> Node;
typedef priority_queue <Node, vector<Node>, greater<Node> > Queue;
const int size = 10001;
Point P[size];
bool used[size];
Graph G[size];

double solve( int s ) {
    double answer = 0.0;
    Queue Q;
    Node start( 0.0, s );
    Q.push( start );

    while ( ! Q.empty() ) {
        Node node = Q.top();
        Q.pop();

        double c = node.first;
        int t = node.second;
        
        if ( used[t] ) continue;
        used[t] = true;
        answer += c;

        for ( Graph::iterator it_i = G[t].begin();
              it_i != G[t].end(); ++ it_i ) {
            Edge e = *it_i;
            double nc = e.second;
            int nt = e.first;
            Node next( nc, nt );
            Q.push( next );
        }
    }

    return answer;
}

int main() {
    int n, m;
    while ( cin >> n >> m ) {
        for ( int i = 0; i < n; ++ i ) {
            used[i] = false;
            G[i].clear();
        }
        
        for ( int i = 0; i < n; ++ i ) {
            int x, y;
            cin >> x >> y;
            P[i] = Point( x, y );
        }
        
        double sum1 = 0.0;
        for ( int i = 0; i < m; ++ i ) {
            int p, q;
            cin >> p >> q;
            p --;
            q --;
            double d = abs( P[p] - P[q] );
            G[p].push_back( Edge( q, d * -1 ) );
            G[q].push_back( Edge( p, d * -1 ) );
            sum1 += d;
        }
        
        double sum2 = 0.0;
        for ( int i = 0; i < n; ++ i ) {
            if ( used[i] ) continue;
            sum2 += solve( i );
        }

        printf( "%.3f\n", sum1 + sum2 );
    }
    return 0;
}

Measured memory_bytes: 2628
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int, P > PP;

#define MAX_N 2005

vector<int> G[MAX_N];
int t[MAX_N][MAX_N];

int N,K,S;
int x[MAX_N],y[MAX_N],z[MAX_N];
/*
bool incheck(int id,int px,int py,int pz){
  if(x[id]<=px && px<x[id]+S)
    if(y[id]<=py && py<y[id]+S)
      if(z[id]<=pz && pz<z[id]+S)
        return true;
  return false;
}
*/
int calc(int a,int b){
  assert(a!=b);
  int ax=x[a],ay=y[a],az=z[a];
  int bx=x[b],by=y[b],bz=z[b];

  int XY = max(0, min(ax+S,bx+S)-max(ax,bx) )* max(0, min(ay+S,by+S)-max(ay,by) );
  XY=S*S*2-XY;

  int YZ = max(0, min(ay+S,by+S)-max(ay,by) )* max(0, min(az+S,bz+S)-max(az,bz) );
  YZ=S*S*2-YZ;

  int ZX = max(0, min(az+S,bz+S)-max(az,bz) )* max(0, min(ax+S,bx+S)-max(ax,bx) );
  ZX=S*S*2-ZX;

  return S*S*12-XY*2-YZ*2-ZX*2;
}

bool isIntersect(int a,int b){
  if(x[b]+S<=x[a] || x[a]+S<=x[b])return false;
  if(y[b]+S<=y[a] || y[a]+S<=y[b])return false;
  if(z[b]+S<=z[a] || z[a]+S<=z[b])return false;
  return true;
}


void init(){
  for(int i=0;i<MAX_N;i++){
    G[i].clear();
  }
  memset(t,0,sizeof(t));
}

int Ans,flg;

void dfs(int pos,int prev,int sum,int depth,int root){

  if(depth==K){
    flg=1;
    for(int i=0;i<(int)G[pos].size();i++){
      if(root==G[pos][i]){
        sum+=( t[pos][root] );
      }
    }
    Ans=max(Ans,sum);
    return;
  }

  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(to==root)continue;
    dfs(to,pos,sum+t[pos][to],depth+1,root);
  }
}



int solve(){
  if(K==1)return S*S*6;
  if(K==2){
    int maxm=0;
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        maxm=max(maxm,t[i][j]);
      }
    }
    if(maxm==0){
      return -1;
    }
    return S*S*12-maxm;
  }
  Ans=flg=0;
  for(int i=0;i<N;i++){
    dfs(i,-1,0,1,i);
  }
  if(Ans==0)return -1;
  return S*S*6*K-Ans;
}

int main(){
  while(1){
    cin>>N>>K>>S;
    if(N==0&&K==0&&S==0)break;

    init();
    for(int i=0;i<N;i++){
      cin>>x[i]>>y[i]>>z[i];
      for(int j=0;j<i;j++){
        assert( x[i]!=x[j] || y[i]!=y[j] || z[i]!=z[j] );
      }
    }


    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(i==j)continue;

        if(isIntersect(i,j)){
          t[i][j]=calc(i,j);
          G[i].push_back(j);
        }
      }
    }
    int output=solve();
    cout<< output <<endl;
  }
  return 0;
}

Measured memory_bytes: 18840
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(string, N);
	int flag = 0;
	loop(i, N.size()-1) if(N[i+1] != '9') flag = -1;
	out((N[0]-'0')+(N.size()-1)*9 + flag);
}



Measured memory_bytes: 256
from sys import stdin,stdout
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
def dfs1(src):
    global steps
    if steps==rem:return src
    steps+=1
    return dfs1(g[src][0])
def dfs(src):
    global steps,done,boc,nic
    vis[src]=1
    steps+=1
    if steps-1==k:
        print(src)
        exit(0)
    dfn[src]=steps
    for neigh in g[src]:
        if not vis[neigh]:dfs(neigh)
        else:
            boc,done,nic=[neigh,steps,steps-dfn[neigh]+1]
            # print(done,boc,nic)
            return

n,k=list(map(int,stdin.readline().split()))
done,boc,nic=0,0,0
a=list(map(int,stdin.readline().split()))
g=defaultdict(list)
for i in range(1,n+1):
    g[i]+=[a[i-1]]
vis=[0]*(n+1)
dfn=[0]*(1+n)
steps=0
dfs(1)
# print(done,boc,nic)
left=k-done
rem=(left%nic)
if rem==0:rem=nic
steps=1
print(dfs1(g[boc][0]))

Measured memory_bytes: 196124
using System;
class Program
{
  static void Main(string[] args)
  {
    string s = Console.ReadLine();
    if (s == "Sunny")
    {
      Console.WriteLine("Cloudy");
    }
    else if (s == "Cloudy")
    {
      Console.WriteLine("Rainy");
    }
    else
    {
      Console.WriteLine("Sunny");
    }
  }
}

Measured memory_bytes: 13140
def comp(n,s,a):
  cnt=1
  flag=s[0]
  for i in range(1,n):
    if flag==s[i]:cnt+=1
    else:
      flag=s[i]
      a+=[cnt]
      cnt=1
  a+=[cnt]
  return a
n=int(input())
a=sorted(list(map(int,input().split())))
b=comp(n,a,[])
l,r=0,len(b)-1
if l==r:b[0]=1
while l<r:
  while b[l]==1 and l<r:l+=1
  while b[r]==1 and l<r:r-=1
  if b[l]>1:
    b[l]-=1
    b[r]-=1
while b[l]>1:b[l]-=2
print(sum(b))

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sortd(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      int k = n - (i + j);
      if (k < 0) {
        continue;
      }
      if ((10000 * i + 5000 * j + 1000 * k) == y) {
        cout << i << " " << j << " " << k << " " << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int H, W;
	string S[26][26];
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> S[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == "snuke") {
				cout << (char)('A' + j) << i + 1 << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
  int A, B, C, D, E, F;
  scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);

  std::vector<int> a(F+1), b(F+1);
  for (int i = 0; i <= F; i += A)
    for (int j = 0; j <= F; j += B) {
      if (100*(i+j) > F) break;
      a[100*(i+j)] = 1;
    }

  for (int i = 0; i <= F; i += C)
    for (int j = 0; j <= F; j += D) {
      if (i+j > F) break;
      b[i+j] = 1;
    }

  int res_a = 1;
  int res_b = 0;
  for (int ai = 0; ai <= F; ++ai) {
    if (!a[ai]) continue;
    for (int bi = 0; bi <= F; ++bi) {
      if (!b[bi]) continue;
      if (ai+bi > F) continue;
      if (bi*100 > E*ai) continue;
      if (res_b*(ai+bi) <= bi*(res_a+res_b)) {
        res_a = ai;
        res_b = bi;
      }
    }
  }
  printf("%d %d\n", res_a+res_b, res_b);
}


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

int main() {
    int n;
    cin >> n;
    int ar[n][3];
    for(int i=0;i<n;i++) {
        for(int j=0;j<3;j++)
            cin >> ar[i][j];
    }
    long long int dp[n][3];
    for(int j=0;j<3;j++)
        dp[0][j] = ar[0][j];
    for(int i=1;i<n;i++) {
        for(int j=0;j<3;j++) {
            dp[i][j] = ar[i][j] + max(dp[i-1][(j+1)%3] , dp[i-1][(j+2)%3]);
        }
    }
    long long int maax = 0;
    for (int i=0;i<3;i++) {
        if(maax < dp[n-1][i])
            maax = dp[n-1][i];
    }
    cout << maax << endl;

}

Measured memory_bytes: 3712
#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;
  cin>>n;
  ll a[n];
  REP(i,n){
    cin>>a[i];
  }
  bool ok=true;
  int cnt=0;
  while (true)
  {
    /* code */
    REP(i,n){
      if (a[i]%2!=0)
      {
        /* code */
        ok=false;
        break;
      }
      a[i]/=2;
      
    }
    if (!ok)
    {
      /* code */
      break;
    }
    cnt++;
  }
  cout<<cnt<<endl;
  
  }

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

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

int main(){
	string s; ll k; cin >> s >> k;
	int len = s.size(); bool flag = false; int t = 0;
	Rep(i, len){
		int l = s[i] - '1';
		t = l;
		if(i+1 >= k){
			break;
		}
		if(l == 0){
			continue;
		}else{
			break;
		}
	}
	cout << t + 1 << endl;
	return 0;
}

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

typedef long long ll;

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll GetDigit(ll num) {return log10(num)+1;}

bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0){
      return false;
    }
  }
  return true;
}

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

  if(a == b && c != a && c != b){
    cout << "Yes" << endl;
  }else if(a == c && b != a && b != c){
    cout << "Yes" << endl;
  }else if(b == c && a != c && a != b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
(defun split (delimiter target-string)
  (let ((delimiter-position (search delimiter target-string))
        (delimiter-size (length delimiter)))
    (if delimiter-position
        (cons (subseq target-string 0 delimiter-position)
              (split delimiter (subseq target-string (+ delimiter-position delimiter-size))))
        (list target-string))))

(defun is-approved-paper (n)
  (or (oddp n)
      (zerop (mod n 3))
      (zerop (mod n 5))))

(defun my-and (l)
  (and (car l)
       (if (cdr l)
           (my-and (cdr l))
           T)))

(defun is-approved (l)
  (if (my-and l)
      "APPROVED"
      "DENIED"))
  
(let* ((n (read))
      (papers-str (read-line))
      (papers (mapcar #'parse-integer (split " " papers-str))))
  (princ (is-approved (mapcar #'is-approved-paper papers))))

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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using llint = long long int ;
using namespace std;


int main(){
    int N;
    int K;
    cin>>N>>K;
    double pki[200010];
    rep(i,N){
        double p;
        cin>>p;
        pki[i]=(p+1)/2;
    }
    
    
    double ruiseki[200010];
    ruiseki[0]=0;
    for (int i = 1; i <= N; i++)
    {
        ruiseki[i]=ruiseki[i-1]+pki[i-1];
    }
    double ans=0;
    for (int i = 0; i < N-K+1; i++)
    {
        ans=max(ans,ruiseki[i+K]-ruiseki[i]);
    }
    printf("%.10lf\n", ans);

    return 0;
}

Measured memory_bytes: 3328
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in      io.Reader
	out     io.Writer
	N, M, A int
	D       []bool
	E       [][]bool
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	con.Scan(&con.N, &con.M)
	con.D = make([]bool, con.N)
	con.E = make([][]bool, con.N)
	for i := range con.E {
		con.E[i] = make([]bool, con.N)
	}
	for i := 0; i < con.M; i++ {
		var a, b int
		con.Scan(&a, &b)
		con.E[a-1][b-1] = true
		con.E[b-1][a-1] = true
	}
	con.rec(0, 0)
	con.Println(con.A)
	return nil
}

func (con *contest) rec(v, n int) {
	if n+1 == con.N {
		con.A++
		return
	}
	con.D[v] = true
	for i := 0; i < con.N; i++ {
		if con.E[v][i] && !con.D[i] {
			con.rec(i, n+1)
		}
	}
	con.D[v] = false
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int h, a; cin >> h >> a;
  int ans = 0;
  for(int i = 0; i < 1e5; i++){
    if(h <= 0) break;
    ans++;
    h -= a;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
base = []
i = 1
j = 1
i_6 = 6
i_9 = 9
dp = [float("inf")]*(n+1)
dp[0] = 0

base.append(1)

while i_6<=n:
  i_6 = 6**i
  base.append(i_6)
  i = i+1
  
while i_9<=n:
  i_9 = 9**j
  base.append(i_9)
  j = j+1
  
base.sort()
base_n = len(base)

for i  in range(1,n+1):
  for j in range(base_n):
    if 0 > i-base[j]:
      break
     
    temp = dp[i-base[j]]
    if temp < dp[i]:
      dp[i] = temp + 1
      
    
print(dp[n])

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

int main()
{
	int A, B, Q;
	cin >> A >> B >> Q;
	vector<long long> s(A);
	vector<long long> t(B);
	vector<long long> x(Q);

	for (auto i = 0; i < A; ++i)
	{
		cin >> s[i];
	}
	for (auto i = 0; i < B; ++i)
	{
		cin >> t[i];
	}
	for (auto i = 0; i < Q; ++i)
	{
		cin >> x[i];
	}

	auto search = [](vector<long long>& list, long long start, long long& west, long long& east)
	{
		auto last = list.size() - 1;
		if (start < list[0])
		{
			west = -1;
			east = list[0];
			return;
		}
		if (start > list[last])
		{
			west = list[last];
			east = -1;
			return;
		}

		auto low = 0;
		auto high = last;
		while (high - low > 1)
		{
			auto mid = (high + low) / 2;
			auto pos = list[mid];
			if (pos > start)
			{
				high = mid;
			}
			else if (pos < start)
			{
				low = mid;
			}
			else
			{
				high = mid;
				low = mid;
			}
		}

		west = list[low];
		east = list[high];
	};

	for (auto i = 0; i < Q; ++i)
	{
		long long sWest, sEast, tWest, tEast;
		auto start = x[i];
		search(s, start, sWest, sEast);
		search(t, start, tWest, tEast);

		long long len = 1e11;
		if (sWest >= 0)
		{
			if (tWest >= 0)
			{
				len = min(len, start - min(sWest, tWest));
			}
			if(tEast >= 0)
			{
				len = min(len, tEast - sWest + min(tEast - start, start - sWest));
			}
		}
		if (sEast >= 0)
		{
			if (tWest >= 0)
			{
				len = min(len, sEast - tWest + min(sEast - start, start - tWest));
			}
			if (tEast >= 0)
			{
				len = min(len, max(sEast, tEast) - start);
			}
		}

		cout << len << endl;
	}

	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//ll

int main(){
  int n;cin>>n;
  int ans = INF;
  repd(i,1,(n+1)/2+1){
    int k = 0;
    string ii = to_string(i), jj = to_string(n-i);
    int is = ii.size(), js = jj.size();
    rep(j,is){
      k += ii[j]-'0';
    }
    rep(j,js){
      k += jj[j]-'0';
    }
    ans = min(ans, k);
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;

int main() {
	int n;
	cin >> n;
	bool isApp = true;
	for (int i = 0; i < n;i++) {
		int a;
		cin >> a;
		if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
			isApp = false;
			break;
		}
	}
	cout << (isApp ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll>P;
ll a[100009],b[100009];
P c[100009];

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    c[i]=P(a[i]+b[i],i);
  }
  sort(c,c+n);
  reverse(c,c+n);

  ll x=0,y=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      int idx=c[i].second;
      x+=a[idx];
    }
    else{
      int idx=c[i].second;
      y+=b[idx];
    }
  }
  cout<<x-y<<endl;
  return(0);
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define fr(i,x) for( int i=0;i<(x);i++)
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int main()
  {
      
          ll k,a,b,f=0;
          cin>>k>>a>>b;
         for (int i = a; i <=b; i++) 
         {
         
        if(i%k==0)
    	{
    	     f=1;
    	    break;
		}
         }
         if(f==1)
          {
              cout<<"OK"<<endl;
              }
		else
	
		cout<<"NG"<<endl;
		
       
      
  }

Measured memory_bytes: 3632
N, Ma, Mb = map(int, input().split())

G = []
for i in range(N):
 a, b, c = map(int, input().split())
 G.append( (a,b,c) )

M = 1 + min(sum([ a for a, b, c in G ]),
            sum([ b for a, b, c in G ]) )
INF = 1000000000
dp = [INF] * (M * M)
dp[0] = 0
for a, b, c in G:
  for i in reversed(range(0, M - a)):
    for j in reversed(range(0, M - b)):
      dp[(i+a)*M+(j+b)] = min(dp[(i+a)*M+(j+b)], dp[i*M+j] + c)
ans = INF
x = 1
while Ma * x < M and Mb * x < M:
  ans = min(ans, dp[Ma * x * M + Mb * x])
  x += 1
if ans >= INF:
  ans = -1
print(ans)


Measured memory_bytes: 3924
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(void)
{
	string p, a[100];
	int n;
	cin >> p;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	int q = 0;
	q = p.size();
	int o[100];
	int co = 0;
	for (int i = 0; i < n; i++)
	{
		o[i] = 0;
		o[i] = a[i].size();
		
		a[i] += a[i].substr(0, q);
		for (int j = 0; j < o[i]; j++)
		{
			if (a[i].substr(j, q) == p)
			{
				co++;
				break;
			}
		}
	}

	cout << co << endl;
}




Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    vector<vector<int>> vec(3, vector<int>(3));
    vector<vector<bool>> bingo(3, vector<bool>(3));
    for(int i=0; i<3; i++){
        for (int j=0; j<3; j++){
            cin >> vec[i][j];
        }
    }
    int n;
    cin >> n;
    vector<int> b(n);
    for (int i=0; i<n; i++) cin >>b[i];
    for(int i=0; i<3; i++){
        for (int j=0; j<3; j++){
            bingo[i][j] = false;
            for (int k=0; k<n; k++){
                if (vec[i][j] == b[k]) bingo[i][j] = true;
            }
        }
    }
    for (int i=0; i<3; i++){
        if (bingo[i][0] && bingo[i][1] && bingo[i][2]){
            out("Yes");
            return 0;
        }
    }
    for (int i=0; i<3; i++){
        if (bingo[0][i] && bingo[1][i] && bingo[2][i]){
            out("Yes");
            return 0;
        }
    }
    if (bingo[0][0] && bingo[1][1] && bingo[2][2]){
        out("Yes");
        return 0;
    }
    if (bingo[0][2] && bingo[1][1] && bingo[2][0]){
        out("Yes");
        return 0;
    }
    out("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

  vector<int> v(2);
  REP(i,2) {
    cin >> v[i];
  }
  int ans = 0;
  REP(i,2) {
    auto itr = max_element(ALL(v));
    ans += *itr;
    --*itr;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n, s) for (int i = (s); i < (n); i++)
using namespace std;
typedef long long int LL;
typedef long double LD;

const int MOD = 1e9 + 7;

int main() {
	int N, C, A[400], B[400];

	scanf("%d %d", &N, &C);
	REP(i, N, 0) scanf("%d", A+i);
	REP(i, N, 0) scanf("%d", B+i);

	LL dp[2][401], sum[401];;
	int idx = 0;
	memset(dp[idx], 0, sizeof(dp[idx]));
	dp[idx][0] = 1;

	REP(i, N, 0) {
		int _idx = idx;
		idx = (idx+1)%2;
		memset(dp[idx], 0, sizeof(dp[idx]));
		REP(k, B[i] + 1, A[i]) {
			sum[0] = dp[_idx][0];
			dp[idx][0] = (dp[idx][0] + sum[0]) % MOD;
			REP(j, C + 1, 1) {
				sum[j] = ((k * sum[j-1]) % MOD + dp[_idx][j]) % MOD;
				dp[idx][j] = (dp[idx][j] + sum[j]) % MOD;
			}
		}
	}

	printf("%d\n", dp[idx][C]);
	return 0;
}

Measured memory_bytes: 256