akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

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;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

int main(){

  ll n = in();
  ll l = in();
  ll t = in();
  vector<ll> x(n), w(n), y(n);
  ll p = -1, q;
  REP(i, n){
    x[i] = in();
    w[i] = in();
    if(w[i] == 2){
      w[i] = -1;
    }
    y[i] = ((x[i] + w[i] * t) % l + l) % l;
    if(w[i] == 1){
      p = i;
      q = y[i];
    }
  }

  if(p == -1){
    REP(i, n){
      printf("%lld\n", y[i]);
    }
    return 0;
  }

  ll c = 0;
  REP(i, n){
    if(w[i] == -1){
      c += 2 * t / l;
      ll d = (x[i] - x[p] + l) % l;
      if(d <= 2 * t % l){
        c++;
      }
    }
  }

  sort(y.begin(), y.end());
  ll r = -1;
  REP(i, n){
    if(y[i] == q){
      r = i;
    }
  }
  assert(r != -1);

  // y[r] is (p + c) % n's solution

  REP(i, n){
    ll j = ((r - (p + c) + i) % n + n) % n;
    printf("%lld\n", y[j]);
  }
  
  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

vector<ll > divisor(ll n) {
  vector< ll > div;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      div.push_back(i);
      //重複許すマジ
      if(i * i != n) div.push_back(n / i);
    }
  }
  sort(div.begin(), div.end());
  return (div);
}

int main(){

    ll N; cin >> N;

    vector<ll > D = divisor(N);

    string s = to_string(D[D.size() / 2]);
    cout << s.length() << endl; 

}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return


# B
def B():
    s = S()
    for i in range(len(s)):
        if i % 2:
            if s[i] not in ["L", "U", "D"]:
                print("No")
                return
        else:
            if s[i] not in ["R", "U", "D"]:
                print("No")
                return
    print("Yes")
    return


# C
def C():
    n, k, q = LI()
    a = IR(q)
    sc = [0] * n
    for i in a:
        sc[i - 1] += 1
    for i in sc:
        print("Yes" if i > q - k else "No")
    return


# D
def D():
    n, m = LI()
    a = LI()
    q = []
    for i in range(n):
        heappush(q, -a[i])
    for i in range(m):
        x = heappop(q)
        x *= -1
        x >>= 1
        heappush(q, -x)
    print(-sum(q))
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    C()
    return


# Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 49756
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
M = lines[0][1]
C = 10 ** 10

a = []
for i in 1..N do
  a[i-1] = lines[1][i-1]
end

b = []
for i in 1..M do
  b[i-1] = lines[i+1][1] * C + lines[i+1][0]
end
b.sort!

i = 0
a2 = []
while i <= N and b != [] do
  num = b[-1] / C
  fois = b[-1] % C
  if fois > 0 then
    a2.push(num)
    b[-1] -= 1
    i += 1
  else
    b.pop
  end
end
  
for i in 1..a2.length do
  a.push(a2[i-1])
end
a.sort!
  
ans = 0
for i in 1..N do
  ans += a[-i]
end

puts ans

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

int main(){
    int n;
    cin >> n;
    vi v(n);
    for(int i=0;i<n;i++) cin >> v[i];
    map<int,int> mp_odd,mp_even;
    for(int i=0;i<n;i++){
        if(i%2==0){
            mp_odd[v[i]]++;
        }else{
            mp_even[v[i]]++;
        }
    }
    int mxo1=0,mxe1=0;
    int mxo1n,mxe1n;
    for(auto x:mp_odd){
        if(mxo1<x.second){
            mxo1=x.second;
            mxo1n=x.first;
        }
    }
    for(auto x:mp_even){
        if(x.first==mxo1n) continue;
        if(mxe1<x.second){
            mxe1=x.second;
            mxe1n=x.first;
        }
    }
    int mxo2=0,mxe2=0;
    int mxo2n,mxe2n;
    for(auto x:mp_even){
        if(mxo2<x.second){
            mxo2=x.second;
            mxo2n=x.first;
        }
    }
    for(auto x:mp_odd){
        if(x.first==mxo2n) continue;
        if(mxe2<x.second){
            mxe2=x.second;
            mxe2n=x.first;
        }
    }  
    int ans=min(n-mxe1-mxo1,n-mxe2-mxo2);
    cout << ans << endl;
}

Measured memory_bytes: 8112
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 3005;
const int mod = 1e9 + 7;
#define sz(v) ((int)v.size())

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << b + min(a + b + 1, c) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    if (a == b)
        printf("Draw\n");
    else if (a > b || a == 1)
        if (b == 1)
            printf("Bob\n");
        else
            printf("Alice\n");
    else
        printf("Bob\n");
    return 0;
}

Measured memory_bytes: 128
#include<stack>
#include<iostream>
#include<string>

using namespace std;

int main() {
  int x, y;
  string word;
  stack<int> s;

  while(cin >> word) {
    if(word == "+"){
      x = s.top();
      s.pop();
      y = s.top();
      s.pop();
      s.push(x+y);
    }
    else if(word == "-") {
      x = s.top();
      s.pop();
      y = s.top();
      s.pop();
      s.push(y-x);
    }
    else if(word == "*") {
      x = s.top();
      s.pop();
      y = s.top();
      s.pop();
      s.push(x*y);
    }
    else if(word == "/") {
      x = s.top();
      s.pop();
      y = s.top();
      s.pop();
      s.push(y/x);
    }
    else {
      s.push(stoi(word));
    }
  }

  cout << s.top() << endl;
  return 0;
}

Measured memory_bytes: 3220
n = int(input())
t_list = list(map(int,input().split()))
m = int(input())
drink_list = [list(map(int,input().split())) 
              for nesya in range(m)]
sum_t_list = sum(t_list)
for drink in drink_list:
  a = drink[0]
  b = drink[1]
  c = t_list[a-1] - b
  print(sum_t_list - c)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <string>

int main() {
    int N;
    std::cin >> N;
    std::vector<std::tuple<int, int, char, long long, std::string>> v(N);
    for (auto& e : v) {
        std::cin >>
            std::get<0>(e) >>
            std::get<1>(e) >>
            std::get<2>(e) >>
            std::get<3>(e) >>
            std::get<4>(e);
    }

    std::sort(v.begin(), v.end());
    for (auto& e : v) {
        std::cout
            << std::get<0>(e) << " "
            << std::get<1>(e) << " "
            << std::get<2>(e) << " "
            << std::get<3>(e) << " "
            << std::get<4>(e) << std::endl;
    }
}



Measured memory_bytes: 12128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long MOD = 1000000007;
		int N = sc.nextInt();
		
		long[][][] dp = new long[2][2][N+1];
		dp[0][0][0] = 1;
		for(int i=0; i<N; i++) {
			dp[0][0][i+1] = (dp[0][0][i+1] + dp[0][0][i]*8)%MOD;
			dp[0][1][i+1] = (dp[0][1][i+1] + dp[0][1][i]*9)%MOD;
			dp[1][0][i+1] = (dp[1][0][i+1] + dp[1][0][i]*9)%MOD;
			dp[1][1][i+1] = (dp[1][1][i+1] + dp[1][1][i]*10)%MOD;
			
			dp[1][0][i+1] = (dp[1][0][i+1] + dp[0][0][i])%MOD;
			dp[0][1][i+1] = (dp[0][1][i+1] + dp[0][0][i])%MOD;
			dp[1][1][i+1] = (dp[1][1][i+1] + dp[1][0][i] + dp[0][1][i])%MOD;
		}

		System.out.println(dp[1][1][N]);

		sc.close();
	}
}


Measured memory_bytes: 68064
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int cnt = 0;
  if(s[0]=='0'){
    for(int i=0; i<n; ++i){
      if(i%2==0){
        if(s[i]!='0') cnt++;
      }
      else if(i%2==1){
        if(s[i]!='1') cnt++;
      }
    }
  }
  int cnt1 = 0;
  if(s[0]=='1'){
    for(int i=0; i<n; ++i){
      if(i%2==0){
        if(s[i]!='1') cnt1++;
      }
      else if(i%2==1){
        if(s[i]!='0') cnt1++;
      }
    }
  }


  cout << max(cnt, cnt1);
  return 0;
}

Measured memory_bytes: 3736
N = int(input())
#１個４ドルのケーキと１個７ドルのドーナツが合計Nドルになる買い方があるか？

a = N // 4
b = N // 7

flag = 0

for i in range(a + 1):
    for j in range(b + 1):
        if 4 * i + 7 * j == N:
            flag = 1
            break

if flag == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll P=1000000007;
ll MAX=1e15;
ll MIN=-1*(1e15);
ll a[200001];
void  solve()
{
    ll n,i,j,k,l,m,o,q,r,t;
    ll ans=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ans+=a[n-1];
    j=n-2;
    for(i=n-3;i>=0;)
    {
      if(i>=0)
      {
      ans+=a[j];
      i--;
      }
      if(i>=0)
      {
      ans+=a[j];
      i--;
      }
      j--;
    }
    cout<<ans<<endl;
}
int main()
{
    ll t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5172
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (a, b) = listOfInt()
    println((a-1)*(b-1))
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 35980
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  ll d = c - a - b;
  cout << (d > 0 && 4 * a * b < d * d ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    ll a;
    cin>>a;
    string s;
    cin>>s;
    bool flag = true;
    if (s.size()%2 ==0)
    {
        rep(i, s.size()/2){
            if(s[i]!=s[i+s.size()/2]){
                flag = false;
            }
        }
    }
    else
    {
        flag = false;
    }
    pr(flag ? "Yes":"No");
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
#define INF 1e9
typedef pair<int, int> P;

/* 　"assert"    assert(A：条件式)で　Aが真なら処理は続行、偽ならプログラムを終了する　*/

/*　　ラムダ式　　 auto a = [キャプチャ](パラメータ){ 処理 }  */

/* string型　メンバ関数　substr()    replace()  */

ll calc(ll cnt){
    ll ret = 1;
    rep(i,cnt){
        ret *= 2;
    }
    return ret;
}

int main(){
    ll h; cin >> h;
    ll n = h;
    ll cnt = 0;
    ll ans = 0;
    while (h != 1) {
        cnt++;
        ll t = calc(cnt-1);
        if(h%2 == 1){
            n -= t;
        }
        h = h/2;
        ans += t;
        //cout <<"h=" << h << ", ans=" << ans << "+" << calc(cnt-1) << endl;
    }
    cout << ans + n << endl;
    
}







Measured memory_bytes: 256
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        edges: [(usize,usize,usize);n-1]
    }

    let mut adj_list = vec![vec![]; n + 1];
    for i in 0..n - 1 {
        let e = edges[i];
        adj_list[e.0].push((e.1, e.2));
        adj_list[e.1].push((e.0, e.2));
    }

    let mut color = vec![0; n + 1];

    //println!("{:?}", nodes);

    let mut visited = vec![false; n + 1];
    let mut q = VecDeque::new();
    q.push_back((1, 0));
    while !q.is_empty() {
        let node = q.pop_back().unwrap();
        if !visited[node.0] {
            if node.1 % 2 == 1 {
                color[node.0] = 1;
            }
            visited[node.0] = true;
            for i in 0..adj_list[node.0].len() {
                q.push_front((adj_list[node.0][i].0, node.1 + adj_list[node.0][i].1));
            }
        }
    }

    for i in 1..n + 1 {
        println!("{}", color[i]);
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 11284
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;
#define MAXN 200000100


int32_t main(){
	ios::sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	if(a>b) swap(a, b);
	if(a==1 and b==2) 
		cout << 3 << endl;
	if(a==2 and b==3)
		cout << 1 << endl;
	if(a==1 and b == 3)
		cout << 2 << endl;
}


Measured memory_bytes: 384
(* Vicfred
 * https://atcoder.jp/contests/abc077/tasks/abc077_b
 * binary search
 * *)
let rec upper_bound l r p =
    if r <= 1 + l then l
    else let m = (l + r) / 2 in
    if p m
    then upper_bound m r p
    else upper_bound l m p

let main = Scanf.scanf "%d\n" @@ fun n ->
    let m = upper_bound 0 (n + 1) @@ fun m -> m * m <= n in
    Printf.printf "%d\n" @@ m * m



Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;

int main(void){
	scanf("%d%d",&n,&m);
	int l1=1;
	int l2=1+m+1;
	for(int i=0;i<m;i++){
		if(i%2==0){
			printf("%d %d\n",l1,l1+m-i);
			l1++;
		}else{
			printf("%d %d\n",l2,l2+m-i);
			l2++;
		}
	}
	return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    vector<string> hoge(h);
    for(int i=0;i<h;i++) cin>>hoge.at(i);
    
    for(int i=1;i<=2*h;i++){
        for(int j=1;j<=w;j++){
            int x=(i+1)/2;
            int y=j;
            
            cout<<hoge.at(x-1).at(y-1);
        }
        cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    int a[n];
    for( int i = 0; i < n; ++i ) cin >> a[i];

    int min_res = INF;
    for( int i = 0; i <= n - k; ++i ) {
        int tmp = min( abs( a[i] ) + a[i + k - 1] - a[i], abs( a[i + k - 1] ) + a[i + k - 1] - a[i] );
        min_res = min( min_res, tmp );

    }

    cout << min_res << endl;
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <deque>
using namespace std;

//x, yðüêé
typedef pair<int, int> P;

int w, h;
char map[22][22];

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

int main() {
	while (1) {
		cin >> w >> h;
		if (w == 0 && h == 0) break;		
		P start;
		for (int i = 0; i < h; i++) {
			cin >> map[i];
			char* at = strchr(map[i], '@');
			if (at != NULL) {
				start.first = at - map[i];
				start.second = i;
			}
		}
		//Ç¤\¦³êéH
		/*for (int i = 0; i < h; i++) {
			cout << map[i] << endl;
		}*/
		//[³DæTõ
		deque<P> deq;	//deque<P<int, int>>Æ·éÆ>>ZqÆÔá¦Äðß³êé
		int count = 0;
		deq.push_back(start);
		while (!deq.empty()) {
			P current = deq.back();
			deq.pop_back();
			count++;
			for (int i = 0; i < 4; i++) {
				int nextX = dx[i] + current.first;
				int nextY = dy[i] + current.second;
				if (0 <= nextX && nextX < w && 0 <= nextY && nextY < h
					&& map[nextY][nextX] == '.') {
					deq.push_back(P(nextX, nextY));
					map[nextY][nextX] = '#';//ßçÈ¢æ¤Éßé
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

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


int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	vector<int> waters;
	vector<int> sugars;
	for (int i = 0; i <= F; i++) {
		for (int j = 0; j <= F; j++) {
			int water = 100 * A * i + 100 * B * j;
			int sugar = C * i + D * j;
			if (water <= F && water>0) waters.push_back(water);
			if (sugar <= F) sugars.push_back(sugar);
			if (water > F&& sugar > F) break;
		}
	}
	int max_sugar = 0;
	int max_water = 0;
	double max_noudo = -1;
	for (int water : waters) {
		for (int sugar : sugars) {
			if (water + sugar > F) continue;
			double noudo = sugar * 100.0 / (1.0 * sugar + 1.0 * water);
			if (noudo > E * 100.0 / (100.0 + 1.0 * E)) continue;
			if (max_noudo < noudo) {
				max_noudo = noudo;
				max_water = water;
				max_sugar = sugar;
			}
		}
	}

	cout << max_water + max_sugar << " " << max_sugar;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll h,w; cin>>h>>w;
    char s[h][w];
    rep(i,h)rep(j,w) cin>>s[i][j];

    ll di[]={1,0,-1,0},dj[]={0,1,0,-1};
    bool ok=true;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.') continue;
            bool ok2=false;
            rep(k,4){
                ll ni=i+di[k],nj=j+dj[k];
                if(ni<0||h<=ni||nj<0||w<=nj) continue;
                if(s[ni][nj]=='#') ok2=true;
            }
            if(!ok2){
                ok=false;
                break;
            }
        }
    }
    cout<< (ok ? "Yes" : "No") <<endl;
    return 0;
}

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

using namespace std;

int main(void)
{
  string str;
  int num = 0;

  cin >> str;
  for(int i = 0; i < str.size(); i++){
    if(str[i] == '+'){
      num++;
    }else{
      num--;
    }
  }

  cout << num << endl;
  return 0;
}


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

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

    int temp = a;
    a = b;
    b = temp;

    temp = a;
    a = c;
    c = temp;

    cout << a << " " << b << " " << c;
    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n, a;
  cin >> n;
  string s;
  vector<tuple<string, int, int> > v(n);
  for (int i = 0; i < n; i++) {
    cin >> s >> a;
    v[i] = make_tuple(s, a, i + 1);
  }

  sort(v.begin(), v.end(),
       [](auto const& a, auto const& b) {
         if (get<0>(a) == get<0>(b))
           return get<1>(a) > get<1>(b);
         else
           return get<0>(a) < get<0>(b);
       });

  for (int i = 0; i < n; i++) {
    cout << get<2>(v[i]) << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int[] num = new int[5]; 
        int sum = 0;
        int ans = 0;

        for(int i = 1; i <= N; i++){
            //数字iの各桁の和を算出
            int tmp = i;
            for(int j = 0; j < 5; j++){
                num[j] = tmp % 10;
                tmp /= 10;
            }
            sum = num[0] + num[1] + num[2] + num[3] + num[4];
            
          	//数字iの各桁の和がA以上B以下ならば加算
            if(sum >= A && sum <= B) ans += i;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21332
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000000
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
// #define ll long long
// #define int long long
#define ll int

 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
vector< pii> v[maxn];
ll col[maxn];
void dfs(ll root,ll par)
{
    for(auto it:v[root])
    {
        if(it.x==par)continue;
        col[it.x]=it.y%2==0?col[root]:!col[root];
        dfs(it.x,root);
    }
}
void solve()
{
    ll n;cin>>n;ll a,b,c;
    for(ll i=1;i<n;i++)
    {
        cin>>a>>b>>c;
        v[a].pb(mp(b,c));
        v[b].pb(mp(a,c));
    }
    dfs(1,-1);
    for(ll i=1;i<=n;i++)cout<<col[i]<<endl;
}

signed main()
{
   Need_for_speed(activated);
    
//satisfy
//    {
//  solve();
//   }

    solve();
    
    return 0;
}


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

int main(){
    string s;

    while(cin>>s){
        s[0] = '2';
        s[1] = '0';
        s[2] = '1';
        s[3] = '8';
        cout<<s<<endl;
    }

    return 0;
}



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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

constexpr ll INF = 1e15;

constexpr ll mod = 1e9 + 7;

template<typename T>
void cmpmax(T& reference, T value) {
	reference = max(reference, value);
}

template<typename T>
void cmpmin(T& reference, T value) {
	reference = min(reference, value);
}

int main() {
	int n;
	cin >> n;
	vector<int> counts(4, 0);
	rep(i, n) {
		int a;
		cin >> a;
		counts[a]++;
	}

	vector<vector<vector<double>>> dp(n + 10, vector<vector<double>>(n + 10, vector<double>(n+10, 0)));
	
	//dp[i][j][k]...1枚の皿がi個、2枚の皿がj個、3枚の皿がk個のときに、必要な手数の期待値
	//dp[i][j][k] = (n-i-j-k) / n * dp[i][j][k] + i / n * dp[i-1][j][k] + j / n * dp[i+1][j-1][k] + k / n * dp[i][j+1][k-1] + 1
	//(i+j+k)/n * dp[i][j][k] = i / n * dp[i-1][j][k] + j / n * dp[i+1][j-1][k] + k / n * dp[i][j+1][k-1] + 1

	const double dn = n;
	const int km = counts[3] + 1;
	rep(k, km) {
		rep(j, n + 1) {
			if (k + j> n) continue;
			rep(i, n + 1) {
				if (i + j + k > n) continue;
				if (i == 0 && j == 0 && k == 0) continue;
				double right = dn;
				if (i > 0) right += i * dp[i - 1][j][k];
				if (j > 0) right += j * dp[i + 1][j - 1][k];
				if (k > 0) right += k * dp[i][j + 1][k - 1];
				dp[i][j][k] = right / (i + j + k);
			}
		}
	}
	cout << setprecision(10) << dp[counts[1]][counts[2]][counts[3]] << endl;
	return 0;
}


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

int main() {
    int N;
    cin >> N; 
    vector<string>S(N);
    set<string>Set;
    for(int i = 0; i < N; i++) {
        cin >> S[i];
        Set.insert(S[i]);
    }
    if(Set.size() == 4) {
        cout << "Four" << endl;
    }
    else {
        cout << "Three" << endl;
    }
}

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

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

    bool check[100];
    for( int i = 0; i < n; i++ )
    {
        check[i] = false;
    }
    for( int i = 0; i < n; i++ )
    {
        if( a[i] % 2 != 0 )
        {
            check[i] = true;
        }
        else if( a[i] % 2 == 0 )
        {
            if( a[i] % 3 == 0 || a[i] % 5 == 0 )
            {
                check[i] = true;
            }
            else
            {
                check[i] = false;
            }
        }
    }
    
    bool k = false;
    for( int i = 0; i < n; i++ )
    {
        if( check[i] == false )
        {
            k = true;
            break;
        }
    }
    if( k == false )
    {
        cout << "APPROVED" << endl;
    }
    else
    {
        cout << "DENIED" << endl;
    }
    return 0;
}



Measured memory_bytes: 764
import math
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
z = []
x = []
y = [A, B, C, D, E]
for i in range(5):
    a = math.ceil(y[i] / 10)
    a *= 10
    x.append(a)
for i in range(5):
    c = x[i] - y[i]
    z.append(c)
k = max(z)
print(sum(x) - k)

Measured memory_bytes: 9204
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    sx, sy, tx, ty = map(int, readline().split())
    dx = tx-sx
    dy = ty -sy
    ans = ('U'*dy+'R'*dx)+ ('D'*dy+'L'*dx)+('L'+'U'*(dy+1)+'R'*(dx+1)+'D')+('R'+'D'*(dy+1)+'L'*(dx+1)+'U')
    print(ans)
if __name__ == '__main__':
    main()

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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int b[100100];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll n, k; cin >> n >> k;
    ll demf = 1;
    for (int i = 1; i <= n; ++i){
        ll dem = 1;
        ll aux = i;
        while(aux < k){
            dem*=2; aux*=2;
        }
        dem*=n;
        b[i] = dem;
        demf = dem*demf/__gcd(demf, dem);
    }
    double a = 0.0;
    for (int i = 1; i <= n; ++i){
        a += demf/b[i];
    }

    cout << setprecision(18) << a/(double)demf << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)

int main()
{
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, 0, n) { cin >> x[i]; }
  int min = 1000000;
  rep(i, 1, 100)
  {
    int count = 0;
    for (int j = 0; j < n; j++)
    {
      count += (x[j] - i) * (x[j] - i);
    }
    if (count < min)
    {
      min = count;
    }
  }
  cout << min << endl;
  return 0;
}


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

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

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

    long long ans = 0;

    if(A[0] > x){
        ans += A[0]-x;
        A[0] = x;
    }

    for(int i = 1; i < n; i++){
        if(A[i-1]+A[i] > x){
            ans += A[i]-(x-A[i-1]);
            A[i] = x-A[i-1];
        }
    }

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

Measured memory_bytes: 640
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    s=list(input())
    n=len(s)
    ans=0
    for i in range(n//2):
        if s[i]!=s[n-1-i]:
            ans+=1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 39020
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

unsigned GetDigit(unsigned num) {
	unsigned digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

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

	cout << max(c - (a - b), 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {

    string s;
    cin >> s;
    REP(i, s.size()) cout << 'x';
    cout << endl;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int prime[10001];
int twin_prime[10001];

void isprime(int n) {
    int i, k, l = 0, p1, q1;
    for(i = 2; i <= n; i++) {
        prime[i] = 1;
    }
    for(i = 2; i <= n; i++) {
        if(prime[i]) {
            for(k = 2*i; k <= n; k+=i) {
                prime[k] = 0;
            }
        }
        if(prime[i]) {
            twin_prime[l] = i;
            l++;
        }
    }
    for(i = 0; i < l; i++) {
        if(twin_prime[i+1]-twin_prime[i]==2) {
            p1 = twin_prime[i];
            q1 = twin_prime[i+1];
        }
    }
    printf("%d %d\n", p1, q1);
}

int main() {
    int i, n;
    for(i = 0; i < 10000; i++) {
        scanf("%d", &n);
        if(n == 0) break;
        isprime(n);
    }
    return 0;
}

Measured memory_bytes: 1808
import math

inputted = list(map(int, input().split()))
N = inputted[0]
K = inputted[1]

num_of_rolls = lambda dice, K: max(0, math.ceil(math.log2(K / dice)))
continius_probability = lambda rolls: (1 / 2) ** rolls
dice_probablility = lambda N: 1 / N

answer = sum([continius_probability(num_of_rolls(dice, K)) for dice in range(1, N + 1)])
answer *= dice_probablility(N)

print(answer)


Measured memory_bytes: 6296
#include <bits/stdc++.h>
#define ll long long
#define For(i,a,b) for (int i=a;i<=b;i++)
#define maxn 100007
using namespace std;

int n, q;
ll k;
int d[maxn];

void open() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("attack.inp","r",stdin);
    //freopen("attack.out","w",stdout);
}

void read() {
    cin >> n >> k >> q;
    int a;
    memset(d,0,sizeof(d));
    For(i,1,q) {
        cin >> a;
        d[a]++;
    }
}

void print() {
    For(i,1,n) {
        if (d[i]+k-q<=0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

int main()
{
    open();
    read();
    print();
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IREP(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define IMAX INT_MAX
#define IMIN INT_MIN
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
template<typename T> inline void chmin(T &a, T b){ if(a > b) a = b; }
template<typename T> inline void chmax(T &a, T b){ if(a < b) a = b; }
template<typename T> inline void xch(T &a, T &b){ T w = a; a = b; b = w; }

int main() {
    REP(i, 9){
        REP(j, 9){
            std::cout << i + 1 << "x" << j + 1 << "=" << (i + 1) * (j + 1) << endl;
        }
    }
    
    return 0;
}



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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long A, long long P) {
  P += A * 3;
  cout << P / 2 << endl;
}

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


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if (a + b == c) cout << "Yes\n";
  else if (b + c == a) cout << "Yes\n";
  else if (c + a == b) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


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

void wfs(int pos, int& cnt, vector<bool> hist, const vector<vector<bool>>& table)
{
	hist[pos] = true;
	if(count(hist.begin(), hist.end(), false) == 0)
	{
		cnt++;
		return;
	}

	for(int i=1; i<table[pos].size(); i++)
	{
		if(table[pos][i] != true || hist[i] != false)
			continue;

		wfs(i, cnt, hist, table);
	}
}

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

	vector<vector<bool>> table(N, vector<bool>(N, false));
	for(int i=0; i<M; i++)
	{
		int a, b;
		cin >> a >> b;

		a--;
		b--;

		table[a][b] = true;
		table[b][a] = true;
	}

	int ret = 0;
	wfs(0, ret, vector<bool>(N, false), table);

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

vector<vector<int> > E; // edges
vector<bool> vis;
int ans;
int N;
void dfs(int tmp, int par, int value){
  if(vis[tmp]) return;
  if(value+1 == N) {
    ans++;
    return;
  }
  vis[tmp] = true;
  for(int c: E[tmp])
    if(c != par)
      dfs(c, tmp, value+1);
  vis[tmp] = false;
}

int main() {
  int M;
  cin >> N >> M;
  E = vector<vector<int> >(N);
  vis = vector<bool>(N);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  ans = 0;
  dfs(0, -1, 0);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int fie[3][100000];
int main(){
    int N;
    cin>>N;
    for(int i=0;i<3;i++){
        for(int j=0;j<N;j++){
            cin>>fie[i][j];
        }
    }
    int pos[100000]={0};
    int pospos[100000]={0};
    int muki[100000]={0};
    for(int i=0;i<N;i++){
        if(fie[0][i]%3==1){
            if(fie[1][i]==fie[0][i]+1&&fie[2][i]==fie[0][i]+2){
                pos[fie[2][i]/3-1]=i;
                pospos[i]=fie[2][i]/3-1;
            }
            else{
                puts("No");
                goto exit;
            }
        }
        else if(fie[0][i]%3==0){
            if(fie[1][i]==fie[0][i]-1&&fie[2][i]==fie[0][i]-2){
                pos[fie[0][i]/3-1]=i;
                pospos[i]=fie[0][i]/3-1;
                muki[i]=1;
            }
            else{
                puts("No");
                goto exit;
            }
        }
        else{
            puts("No");
            goto exit;
        }
    }
    for(int i=0;i<N-2;i++){
        int a=pos[i];
        swap(muki[i],muki[a]);
        if((a-i)%2==1){
            puts("No");
            goto exit;
        }
        if(i!=pos[i]){
            int b=pospos[i];
            if(((max(a,i)-min(a,i))/2)%2==1){
                muki[i]=1-muki[i];
                muki[a]=1-muki[a];
            }
            swap(pospos[i],pospos[a]);
            pos[i]=i;
            pos[b]=a;
            muki[i+1]=1-muki[i+1];
        }
    }
    for(int i=0;i<N-2;i++){
        if(muki[i]){
            muki[i]=0;
            muki[i+2]=1-muki[i+2];
        }
    }

    if(muki[N-2]||muki[N-1])puts("No");
    else puts("Yes");
exit:
    return 0;
}



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

int main(){
    int counter = 0;
    string S;
    cin >> S;
    S += 'Z';

    int tmp = 0;
    rep(i, S.size()+1){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            tmp++;
        }else{
            counter = max(counter, tmp);
            tmp = 0;
        }
    } 

    cout << counter << endl;

    return 0;
}

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

#define ff first
#define ss second
#define it(a, x) for (auto &a : x)
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vs vector<string>
#define gi greater<int>
#define vc vector<char>
#define vvi vector<vi>
#define vvc vector<vc>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define deb(x) cout << #x << "=" << x << endl;
#define in(i, n) for (auto i = 0; i < n; i++)
#define all(x) begin(x), end(x)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());//random shuffler

ll fxp(ll a, ll b) {
    if (b == 0) return 1;
    if (b % 2 == 0) {
        ll c = fxp(a, b / 2);
        return (c * c) % mod;
    }
    return (a * fxp(a, b - 1)) % mod;
}

void c_p_c() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}

void solve() {
    int x;
    cin >> x;
    cout << (!x);
}

int main(int argc, char const *argv[]) {
    c_p_c();
    solve();
    return 0;
}


Measured memory_bytes: 3620
N=int(input())
A=[60]*30
T=' '
B=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(N):
    S=input()
    for k in range(26):
        count=S.count(B[k])
        if A[k]>=count:
            A[k]=count

for i in range(26):
    for k in range(A[i]):
        T=T+B[i]
print(T.strip())

Measured memory_bytes: 3064
import heapq
k = int(input())
j = [0] * k
for i in range(k):
    j[i] = [(tuple([(i * 10) % k, 0]))]
    j[i].append(tuple([(i + 1) % k, 1]))

min_cost = [float("inf")] * k
def dijkstra(s):
    queue = [tuple([1, s])]
    while queue:
        p = heapq.heappop(queue)
        for e in j[p[1]]:
            if p[0] + e[1] >= min_cost[e[0]]:
                continue
            min_cost[e[0]] = p[0] + e[1]
            heapq.heappush(queue, tuple([min_cost[e[0]], e[0]]))
dijkstra(1)
print(min_cost[0])

Measured memory_bytes: 38260
#include<stdio.h>
#include<string.h>
int main(){
    int a=0,b=0;
    char s[100];
    scanf("%s",s);
    for(int i=0;s[i]!='\0';i++){
        a++;
    }
    for(int j=0;j<a;j++){
        if((j%2==0)&&(strncmp(&s[j],"L",1)==0)){
            b++;
            break;
        }
        if((j%2==1)&&(strncmp(&s[j],"R",1)==0)){
            b++;
            break;
        }
    }
    if(b==1){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int[] min = {a,b,c};
    Arrays.sort(min);
    System.out.println(min[0] + min[1]);
  }
}

Measured memory_bytes: 23636
from itertools import combinations_with_replacement

def main():
    n, m, q = map(int, input().split())
    num_list = []
    for _ in range(q):
        num_list.append(list(map(int,input().split())))

    max_num = 0

    l = [ i for i in range(1,m+1)]
    c_list = list(combinations_with_replacement(l, n))

    for c in reversed(c_list):
        tmp_count = 0
        for i in range(q):
            aa = num_list[i][0]
            bb = num_list[i][1]
            cc = num_list[i][2]
            dd = num_list[i][3]
            if c[bb-1] - c[aa-1] == cc:
                tmp_count += dd

        max_num = max(max_num, tmp_count)

    print(max_num)

if __name__ == '__main__':
    main()

Measured memory_bytes: 84984