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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

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

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

int grid[11][11];

void solve()
{
    int N, M, Q;
    cin >> N >> M >> Q;
    LL score = 0;
    vector<tuple<int, int, int, int>> Qs;
    REP1 (i, Q)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        Qs.push_back({a, b, c, d});
    }

    vector<int> dx;
    REP1 (i, N)
    {
        dx.push_back(0);
    }
    REP1 (i, M - 1)
    {
        dx.push_back(1);
    }

    do
    {
        vector<int> A;
        int cur = 1;
        A.push_back(cur);
        for (auto delta : dx)
        {
            if (delta == 0)
            {
                A.push_back(cur);
            }
            else
            {
                cur++;
            }
        }
        LL scr = 0;
        for (auto tpl : Qs)
        {
            int a = get<0>(tpl);
            int b = get<1>(tpl);
            int c = get<2>(tpl);
            int d = get<3>(tpl);
            if (A[b] - A[a] == c)
            {
                scr += d;
            }
        }
        score = max(scr, score);

    } while (next_permutation(dx.begin(), dx.end()));
    std::cout << score << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> vec(h);
    for (int i = 0; i < h; i++) {
        cin >> vec.at(i);
    }

    for (int i = 0; i < 2 * h; i++) {
        cout << vec.at(i / 2) << endl;
    }
    return 0;
}


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

int main()
{
    int N;
    int ans = 0;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> d.at(i);
    }

    for (int i = 0; i < N-1; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            ans += d.at(i)*d.at(j);
        }
        
    }
    
    cout << ans;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string a , b;
    cin>>a>>b;
    string s = (a+b);
    stringstream st(s);
    int num = 0;
    st>>num;
    if((int)sqrt(num) * (int)sqrt(num) == num){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}

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>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

  map<int, int> mapa;
  map<int, int> mapb;
  vector<int> v(2*n+1);
  for (size_t i = 0; i <= 2*n; i++) {
    v[i]=0;
    mapa[i]=-1;
    mapb[i]=-1;
  }
  for (size_t i = 0; i < n; i++) {
    scanf("%d %d\n",&a,&b );
    mapa[a]=b;
  }
  for (size_t i = 0; i < n; i++) {
    scanf("%d %d\n",&a,&b );
    mapb[a]=b;
  }
  int tmp;
  int count=0;
  for (size_t i = 0; i < 2*n; i++) {
    if(mapb[i]!=-1){
      int max=-1;
      int index=-1;
      for (int j = i-1; j >=0; j--) {

        if(mapa[j]!=-1 && mapa[j]<mapb[i] && v[j]!= 1 ){

          if(max<mapa[j]){
            index=j;
            max=mapa[j];
          }
        }

      }
      if(index!=-1){
        v[index]=1;
        count++;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}


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

using namespace std;

int main(){
    string S;
    bool flg = true;
    string move;

    cin >> S;

    for(int i = 0; i < S.length(); ++i) {
        move = S[i];
        
        if((i % 2 == 1) && (move == "R")){
            flg = false;
        }
        if((i % 2 == 0) && (move == "L")){
            flg = false;
        }
    }

    if(flg){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main(){
    string s;
    cin >> s;

    vector<char> dir = {'N', 'S', 'E', 'W'};
    vector<int> count(4);
    for(int i=0; i<s.length(); i++){
        for(int j=0; j<4; j++){
            if(s[i] == dir[j]){
                count[j] += 1;
            }
        }
    }
    if((count[0] != 0 && count[1] == 0)
    || (count[1] != 0 && count[0] == 0)
    || (count[2] != 0 && count[3] == 0)
    || (count[3] != 0 && count[2] == 0)){
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3632
def div(n):
    r = int(n**(1/2))
    for i in range(1, r + 1):
        if n % i == 0:
            yield i
            if i*i != n:
                yield n // i


n = int(input())
count = len(list(div(n-1)))-1
for i in div(n):
    if i > 1:
        x = n
        while x % i == 0:
            x //= i
        if x % i == 1:
            count += 1

print(count)


Measured memory_bytes: 9448
#include <stdio.h>
int main(void){
  int N,i,A,max=0;
  long int s=0;
  setbuf(stdout,NULL);
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A);
    if(A<max)s+=max-A;
    else if(A>=max)max=A;
  }
  printf("%ld",s);
  return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

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

//int main(){//平方数を1<k<=nで割ったあまりを求める
//	lint n;cin>>n;
//	LIV ans(n);
//	for(int i=1;i<=n;++i){
//		set<int> s;
//		rep(x,i)s.insert(x*x%i);
//		cout<<i<<": ";
//		for(auto x:s)cout<<x<<",";cout<<endl;
//		ans[i-1]=s.size();
//	}rep(i,n)cout<<ans[i]<<endl;
//	getchar();
//	getchar();
//}

//sub-EOF


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n, t;
llong a[100005];
llong ans = 1;

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

    llong max_s = 0;
    llong minv = a[0];
    for (int i = 1; i < n; i++) {
        llong s = a[i] - minv;

        if (max_s < s) {
            max_s = s;
            ans = 1;
        }
        else if (max_s == s) {
            ans++;
        }

        minv = min(a[i], minv);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import sys
def input(itr=iter(sys.stdin.readlines())):  # pylint: disable= redefined-builtin
    return next(itr).rstrip('\n\r')
###############################################################################

from networkx.utils.union_find import UnionFind

N, Q = map(int, input().split())

uf = UnionFind()
responses = []
for _ in range(Q):
    uq, u, v = map(int, input().split())
    if uq == 0:
        uf.union(u, v)
    else:
        responses.append(1 if uf[u] == uf[v] else 0)

print(*responses, sep='\n')


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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
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; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353

ll N, K;
vll A(505);
vll r(505);


ll plusminus(ll k) { // kを約数とするために必要な最小操作回数
    rep(i, N) {
        r[i] = A[i] % k;
    }
    sort(all(r));

    ll pSum = 0 , mSum = 0;
    rep(i, N) {
        if (r[i] == 0) continue;
        pSum += (k - r[i]);
    }

    rep(i, N) {
        if (r[i] == 0) continue;
        mSum += r[i];
        pSum -= (k - r[i]);
        if(mSum == pSum) {
            break;
        }
    }

    return mSum;
}


int main() {
    cin >> N >> K;
    ll S = 0;
    A.assign(N,0);
    r.assign(N,0);

    rep(i, N) {
        cin >> A[i];
        S += A[i];
    }
    ll ans = 1;

    for (ll i = 1 ; i * i <= S ; i++) {
        if (S % i == 0) {
            if (plusminus(i) <= K) {
                chmax(ans, i);
            }
            if (plusminus(S / i) <= K) {
                chmax(ans, S / i);
            }
        }
    }

    cout << ans << endl;

}




Measured memory_bytes: 256
use std::process;
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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: u64, 
        x: u64,
        l: [u64; n],
    }   
    let mut ans = 1;
    let mut d =0;
    for i in l {
        d = d + i;
        if d > x {
            break;
        }
        else {
            ans += 1;
        }
    }

    println!("{}" ,ans);

}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, q);
    Cin(string, s);
    Cins2(char, q, t, d);
    
    int ans = n;
    {
        int lb = -1, ub = n+1;
        while(ub - lb > 1){
            int m = (lb + ub) / 2;
            auto f = [q, s, t, d](int m) -> bool {
                For(i, q){
                    if(s[m] == t[i]){
                        if(d[i] == 'L') m --; else m ++;
                        if(m < 0) return false;
                    }
                }
                return true;
            };
            (f(m) ? ub : lb) = m;
        }
        ans -= ub;
    }
    Reverse(s);
    {
        int lb = -1, ub = n+1;
        while(ub - lb > 1){
            int m = (lb + ub) / 2;
            auto f = [q, s, t, d](int m) -> bool {
                For(i, q){
                    if(s[m] == t[i]){
                        if(d[i] == 'R') m --; else m ++;
                        if(m < 0) return false;
                    }
                }
                return true;
            };
            (f(m) ? ub : lb) = m;
        }
        ans -= ub;
    }
    Cout(ans);
    
}


Measured memory_bytes: 1476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int main() {
	fastio; int n, x, t;
  	cin >> n >> x >> t;
  	cout << (n+x-1)/x * t;
}


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

int  n, v, j;

void insertionSort(int a[]){
  for(int i=1; i<n; i++){
    v=a[i];
    j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
      a[j+1]=v;
    }
    for(int k=0; k<n; k++){
      if(k<n-1) cout << a[k] << " ";
      if(k==n-1) cout << a[k] << endl;
    }
  }
}
 
int main(){
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];

  for(int k=0; k<n; k++){
    if(k<n-1) cout << a[k] << " ";
    if(k==n-1) cout << a[k] << endl;
  }
  
  insertionSort(a);
  return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
ll mopow(ll a,ll x,ll mod){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}
int main(){
    int h,w,k;cin>>h>>w>>k;
    vector<string> s(h);
    vector<int> cnt(h,0);
    for(int i=0;i<h;++i){
        cin>>s[i];
        for(int j=0;j<w;++j)if(s[i][j]=='#') cnt[i]++;
    }
    int ans[h][w];
    int c=1;
    for(int i=0;i<h;++i){
        if(cnt[i]==0) continue;
        bool shown=false;
        for(int j=0;j<w;++j){
            if(s[i][j]=='#'){
                if(shown) c++;
                else shown=true;
            }
            ans[i][j]=c;
        }
        c++;
    }
    for(int i=0;i<h;++i){
        if(cnt[i]>0){
            int b=i-1,f=i+1;
            while(b>=0&&cnt[b]==0){
                for(int j=0;j<w;++j){
                    ans[b][j]=ans[i][j];
                }
                b--;
            }
            while(f<h&&cnt[f]==0){
                for(int j=0;j<w;++j){
                    ans[f][j]=ans[i][j];
                }
                f++;
            }
        }
    }
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cout<<ans[i][j];
            if(j<w-1) cout<<' ';
            else cout<<endl;
        }
    }
    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

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

    map<int, int> m;
    for (int i = 0; i < N; i++) {
        m[a[i]]++;
    }

    ll ans = 0;
    for (map<int, int>::iterator it = m.begin(), end = m.end(); it != end; it++) {
        if (it->first <= it->second) {
            ans += (it->second - it->first);
        } else {
            ans += it->second;
        }
    }

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

Measured memory_bytes: 5120
#include <cstdlib>
#include <iostream>
#include <stack>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

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

	int n;
	cin >> n;

	vector<int> a(n);
	for(auto &e : a) cin >> e;

	stack<int> sta;
	int ans = 0;
	for(const auto &e : a) {
		while(!sta.empty() && sta.top() > e) sta.pop();

		if(sta.empty() || sta.top() < e) {
			++ans;
			sta.push(e);
		}
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 2592
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, F[100][10], P[100][11];

int main(void) {
  cin >> N;
  REP(i, 0, N) REP(j, 0, 10) cin >> F[i][j];
  REP(i, 0, N) REP(j, 0, 11) cin >> P[i][j];

  ll ans = -(1LL << 60);
  REP(s, 1, 1LL << 10) {
    ll sum = 0;
    REP(i, 0, N) {
      ll cnt = 0;
      REP(j, 0, 10) if((s & (1LL << j)) && F[i][j] == 1) cnt++;
      sum += P[i][cnt];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};


void solve(int ca){
    int D; cin>>D;
    for (int i = 0; i < D; ++i) {
        cout<<i%26+1<<endl;
    }
}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


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

const ll mod=998244353;
int n,s,a[3005];
ll dp[3005][3005],ans;

int main()
{
    scanf("%d%d",&n,&s);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    for(int i=1;i<=n;i++)
    {
        dp[i][0]+=i;
        dp[i][a[i]]++;
        for(int j=1;j<=s;j++)
        {
            dp[i][j]+=dp[i-1][j];
            if(j>=a[i]) dp[i][j]+=dp[i-1][j-a[i]];
            dp[i][j]%=mod;
        }
        ans=(ans+dp[i][s])%mod;
    }
    printf("%lld",ans);
    return 0;
}

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

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    int n = s.size();
    for(int i=0;i<n;i++){
        if(s[i]!=t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3640
use std::io::Read;

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

fn main() {
    let s: String = read();
    let res = match s.as_str() {
        "Sunny" => "Cloudy",
        "Cloudy" => "Rainy",
        "Rainy" => "Sunny",
        _ => unreachable!(),
    };
    println!("{}", res);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(scanner.nextInt());
        }
        Collections.sort(a);

        int[][] bc = new int[m][2];
        for (int i = 0; i < m; i++) {
            bc[i][0] = scanner.nextInt();
            bc[i][1] = scanner.nextInt();
        }
        Arrays.sort(bc, Comparator.<int[]>comparingInt(ar -> ar[1]).reversed());

        long sum = 0;
        for (int[] array : bc) {
            for (int i = 0; i < array[0]; i++) {
                if (a.isEmpty() || a.get(0) >= array[1]) {
                    break;
                }
                a.remove(0);
                sum += array[1];
            }
        }

        for (int i : a) {
            sum += i;
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 99592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}
const double PI=3.14159265358979323846;
template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int R;
  cin >> R;
  long double ans = 2 * R * PI;
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++) {
  	cin >> W.at(i);
  }
  
  //全体の重さ
  int Sall = 0;
  for (int i = 0; i < N; i++) {
      Sall += W.at(i);
  }
  
  int min = 10000;
  for (int i = 0; i < N - 1; i++) {
  	int S1 = 0, S2 = 0;
    
    for (int j = 0; j <= i; j++) {
      S1 += W.at(j);
    }
    
    S2 = Sall - S1;
    
    if (min > abs(S1 - S2)) {
      min = abs(S1 - S2);
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

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

    int c, t;
    int i, min;

    min = 0;

    for (i=0;i <= N;i++) {
        scanf("%d %d",&c,&t);
        if (t <= T) {
            if (c < min || min == 0) {
                min = c;
            };
        };
    };

    if (min == 0) {
        printf("TLE\n");
    } else {
        printf("%d\n",min);
    };

    return 0;

}

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

const int maxn = 310, P = 998244353;
int n, m, a[maxn][maxn], b[maxn][maxn];

int qp(int x, int y) {
    int z = 1;
    for (; y; y >>= 1, x = 1LL * x * x % P) {
        if (y & 1)
            z = 1LL * z * x % P;
    }
    return z;
}

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = m; j; j--)
            if (a[i][j]) {
                if (b[j][j]) {
                    for (int k = 1; k <= m; k++) {
                        a[i][k] ^= b[j][k];
                    }
                } else {
                    for (int k = 1; k <= m; k++) {
                        b[j][k] = a[i][k];
                    }
                    break;
                }
            }
    }
    int cnt = 0;
    for (int i = 1; i <= m; i++) {
        if (b[i][i])
            cnt++;
    }
    int ans = qp(2, n + m) - qp(2, n + m - cnt) + P;
    printf("%lld\n", 1LL * ans * qp(2, P - 2) % P);
    return 0;
}

Measured memory_bytes: 1024
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
// #include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {


    int X; cin >> X;
    
    int res = 1;

    for(int i=2; i<=sqrt(X); i++) {
        int r = i;
        while ( r*i <= X ) {
            r *= i;
        }
        res = max(res, r);
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string w;
    cin>>w;
    int i,j,n;
    int f=1;
    sort(w.begin(),w.end());
    for(i=0; w[i]; i+=j)
    {
        n=0;
        for(j=i;; j++)
        {
            if(w[i]==w[j])
                n++;
            else
                break;
        }
        if(n%2!=0)
        {
            f=0;
            break;
        }
    }
    if(f==1)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
#define f(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
char a[1001][1001];
long long int dp[1001][1001];
int h,w;



int main(){
    cin>>h>>w;
    f(i,1,h){
        f(j,1,w){
            cin>>a[i][j];
        }
    }
    memset(dp,0,sizeof(dp));
    f(i,1,h){
        f(j,1,w){
            if(a[i][j]=='#')
                continue;
            if(i==1&&j==1)
                dp[i][j]=1;
            else
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%1000000007;
        }
    }

    cout<<dp[h][w]<<endl;
    return 0;
}

Measured memory_bytes: 9088
#include<stdio.h>
#define NUMBER 100
int main(void)
{
  int N,K,P;
  int i;
  int A[NUMBER];

  scanf("%d",&N);
  for( i = 0; i < N; i++){
    scanf("%d %d",&K,&P);
    A[i] = K % P;
    if(K % P == 0)
      A[i] = P;
  }

  for( i = 0; i < N; i++){
    printf("%d\n",A[i]);
  }
  
  return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
 
using namespace std;
 
const double eps=1e-10;

int main()
{

	double _min,_max;
	cin>>_min;
	_max=_min;

	double t;
	while(cin>>t){
		_min=min(_min,t);
		_max=max(_max,t);
	}

	cout<<_max-_min<<endl;

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = LLONG_MAX;

int A[100010];
signed main(){
  int n,k;
  cin>>n>>k;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    A[a]+=b;
  }

  rep(i,100010){
    k-=A[i];
    if(k<=0){
      cout<<i<<endl;
      return 0;
    }
  }

}


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

struct data{
    int a,b,c,d;
};

int main(){
    int N,M,Q;
    cin>>N>>M>>Q;
    vector<data> x(Q);
    vector<int> A(10);
    for(int i=0;i<Q;i++){
        cin>>x[i].a>>x[i].b>>x[i].c>>x[i].d;
    }
    int ans=0;
    for(int i=0;i<(1<<M);i++){
        bitset<10> k(i);
        if(k.count()==N){
            for(int j=0;j<10;j++){
                if(k.test(j)) A[j]=j;
                else A[j]=-20;
            }
            int ans1=0;
            for(int j=0;j<Q;j++){
                if(A.at(x[j].b-1)-A.at(x[j].a-1)==x[j].c){
                    ans1+=x[j].d;
                }
            }
            ans=max(ans,ans1);
        }
    }
    cout<<ans<<endl;
} */

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

int ans,n,m,q;
vector<int> a(55),b(55),c(55),d(55);

void dfs(vector<int> A){
    if(A.size()==n){
        int now=0;
        for(int i=0;i<q;i++){
            if(A[b[i]-1]-A[a[i]-1]==c[i]){
                now+=d[i];
            }
        }
        ans=max(ans,now);
        return;
    }
    if(A.size()==0){
        A.push_back(1);
    }
    else{
        A.push_back(A.back());
    }
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
    
}

int main(){
    cin>>n>>m>>q;
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }

    ans=0;
    dfs(vector<int>(0));

    cout<<ans<<endl;    
}

Measured memory_bytes: 3604
my @s;
{
  chomp (my $in = <STDIN>);
  @s = split '', $in;
}
my $ans = 0;
for my $i (0..2**$#s-1) {
  my $b = sprintf "%0".$#s."b", $i;
  my $sum = $s[0];
  for my $j (1..$#s) {
    if ("0" eq substr($b, $j-1, 1)) {
      $sum .= $s[$j];
    } else {
      $sum .= "+".$s[$j];
    }
  }
  $ans += eval($sum);
}
print "$ans\n";

Measured memory_bytes: 512
import itertools

N = int(input())
xy = [[int(i) for i in input().split()] for j in range(N)]

spots = [i for i in range(N)]

dist = 0
n = 0
for route in itertools.permutations(spots, N):
    for i in range(N-1):
        start, goal = route[i], route[i+1]
        dist += ((xy[start][0]-xy[goal][0])**2 + (xy[start][1]-xy[goal][1])**2)**0.5
    n += 1

print(dist / n)

Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>

using namespace std;
long long int mpown(long long int m, int n);

int bitCount(int bits);
int main()
{
    int n,k;
    cin >> n >>k;
    vector<long long int> v(n);
    for(int i=0;i<n;i++)cin >> v.at(i);
    // vector<vector<long long int>> dp(n+1,vector<long long int>(n+1,0));
    // vector<vector<long long int>> dpm(n+1,vector<long long int>(n+1,0));
    // vector<vector<long long int>> dpmn(n+1,vector<long long int>(n+1,0));
    // dp.at(i).at(j) : 左からi個，右からj個とったときの価値の合計
    // dpmn.at(i).at(j) : 左からi個，右からj個とったときの負の宝石の数
    // dpm.at(i).at(j) : 左からi個，右からj個とったときの負の価値の合計
    int r = min(n,k);
    priority_queue<long long int> mns;
    long long int sv=0;
    long long int temp;
    long long int ans=(-1000000000000);
    for(int a=0;a<=n;a++){
        for(int b=0;b<=r-a;b++){
            
            sv=0;
            priority_queue<long long int> mns;
            for(int i=0;i<a;i++){
                sv+=v.at(i);
                if(v.at(i)<0)
                mns.push(-v.at(i));
            }
            for(int j=0;j<b;j++){
                sv+=v.at(n-j-1);
                if(v.at(n-j-1)<0)
                mns.push(-v.at(n-j-1));
            }
            for(int i=0;i<k-(a+b);i++){
                if(mns.empty()){break;}
                sv+=mns.top();
                mns.pop();
            }
            

            if(ans<sv){ans=sv;
            // cout << a << " " << b << endl;
            }
        }
    }
    cout << ans << endl;
}

int bitCount(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); //  2bitごとに計算
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); //  4bitごとに計算
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); //  8bitごとに計算
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); //  16ビットごとに計算
    return (bits & 0x0000ffff) + (bits >> 16);             //  32ビット分を計算
}
long long int mpown(long long int m, int n)
{
    if (n == 0)
        return 1;
    else if (n == 1)
        return m;
    else
    {
        long long int temp = mpown(m, n / 2);
        return temp * temp * (n & 1 ? m : 1);
    }
}

Measured memory_bytes: 3128
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
const int N=1e6+8;
ll n,x,y,k,val[N],ans,dp[N],a,mx=0;
vector<ll>g[N];
inline void dfs(ll v,ll fa)
{
	for(int i=0;i<g[v].size();i++)
	{
		//cout<<v<<endl;
		ll u=g[v][i];
		if(u==fa)continue;
		dfs(u,v);
		dp[v]++;
		dp[v]+=dp[u];
		mx=max(dp[v],mx);
	}
}
int main()
{
	ios::sync_with_stdio(0);
   	string str;
   	cin>>str;
   	if(str[str.size()-1]=='s')cout<<str<<"es";
   	else cout<<str<<"s";
    
}

Measured memory_bytes: 27052
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
 	int A, B, count = 0;
  	cin >> A >> B;
  
	for(int i=A; i<B+1; i++){
      if((i/10000)%10 == i%10 && (i/1000)%10 == (i/10)%10)
        count++;
    }

      cout << count  <<endl;
}

Measured memory_bytes: 256
N = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))

cnt = 0
for i in range(N):
    a = a_list[i]
    b = b_list[i]
    if a >= b:
        cnt += b
    else:
        cnt += a
        kill = min(a_list[i+1], b-a)
        cnt += kill
        a_list[i+1] -= kill
        
print(cnt)

Measured memory_bytes: 82020
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	int N, L[2005];
	
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	sort(L, L + N);
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = j + 1; k < N; k++) {
				if (L[i] + L[j] <= L[k]) {
					break;
				} else {
					if (L[i] + L[k] > L[j] && L[k] + L[j] > L[i]) {
						ans++;
					}
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import math

def main():
    H,K = map(int, input().split())
    if H==1 or K ==1:
        print(1)
        return
    elif H%2==0 or K%2==0:
        print(int(H*K/2))
        return
    else:
        print(int(math.ceil(H*K/2)))
        return
        

main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ---------------------------------------------------------------------------

int main(){
  string S;
  cin >> S;
  int N = S.size();
  vector<vector<ll>> dp(N+1,vector<ll> (2,0));
  dp[0][0] = 1;
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      if(S[i] == '1'){
        (dp[i+1][1] += dp[i][j])%mod;
      }else{
        (dp[i+1][j] += dp[i][j])%mod;
      }
      if(!(S[i]=='0' and j==0)) (dp[i+1][j] += (dp[i][j]*2)%mod)%mod;
    }
  }
  cout << (dp[N][0] + dp[N][1])%mod << endl;
  return 0;
}

Measured memory_bytes: 5760
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"
#include "cmath"
#include "set"
#include "map"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<set<int> > x(26);
  for (int j = 0; j < 26; j++)
  {
    x[j].insert(n + 1);
  }

  for (int i = 0; i < n; i++)
  {
    x[s[i] - 'a'].insert(i);
  }

  int q;
  cin >> q;
  int que, m, l, r;
  char c;
  for (int i = 0; i < q; i++)
  {
    cin >> que;
    if (que == 1)
    {
      cin >> m >> c;
      m--;
      int d = s[m] - 'a';
      x[d].erase(m);
      d = c - 'a';
      x[d].insert(m);
      s[m] = c;
    }
    else
    {
      cin >> l >> r;
      l--;
      r--;
      int ans = 0;
      for (int j = 0; j < 26; j++)
      {
        auto lb = x[j].lower_bound(l);
        if (*lb <= r)
        {
          ans++;
        }
      }
      cout << ans << "\n";
    }
  }
}


Measured memory_bytes: 24196
import sys


def bit_add(arr, n, i, x):
    while i <= n:
        arr[i] += x
        i += i & -i


def bit_sum(arr, i):
    result = 0
    while i > 0:
        result += arr[i]
        i ^= i & -i
    return result


n, q = map(int, sys.stdin.buffer.readline().split())
ccc = list(map(int, sys.stdin.buffer.readline().split()))

mp = map(int, sys.stdin.buffer.read().split())
itr = zip(mp, mp)
rli = [0] * q
for i in range(q):
    l, r = next(itr)
    rli[i] = (r << 40) + (l << 20) + i
rli.sort()
mask = (1 << 20) - 1

bn = n + 2
bit = [0] * (bn + 1)
ans = [0] * q
appeared = [-1] * (n + 1)
p = 0

for j in range(q):
    k = rli[j]
    r = k >> 40
    l = (k >> 20) & mask
    i = k & mask
    while p < r:
        c = ccc[p]
        before_appeared = appeared[c]
        if before_appeared != -1:
            bit_add(bit, bn, before_appeared + 2, -1)
        bit_add(bit, bn, p + 2, 1)
        appeared[c] = p
        p += 1

    ans[i] = bit_sum(bit, r + 1) - bit_sum(bit, l)

print('\n'.join(map(str, ans)))


Measured memory_bytes: 236496
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	string s;
	cin>>s;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	cout<<a+b+c<<endl;
}

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

const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v,int N,bool visited[nmax]){
  bool all_visited=true;
  for(int i=0;i<N;i++){
    if(visited[i]==false)
      all_visited=false;
  }
  if(all_visited){
    return 1;
  }
  int ret=0;
  for(int i=0;i<N;i++){
    if(graph[v][i]==false) continue;
    if(visited[i]) continue;
    visited[i]=true;
    ret+=dfs(i,N,visited);
    visited[i]=false;
  }
  return ret;
}

int main()
{
  int N,M;
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int A,B;
    cin>>A>>B;
    graph[A-1][B-1]=graph[B-1][A-1]=true;
  }
  bool visited[nmax];
  for(int i=0;i<N;++i){
    visited[i]=false;
  }
  visited[0]=true;
  cout<< dfs(0,N,visited) <<endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int train = a * n;
    int taxi = b;
    pw.println(Math.min(train, taxi));
  }
}


Measured memory_bytes: 21844
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		BigInteger A = new BigInteger(String.valueOf(sc.next()));
		BigInteger B = new BigInteger(String.valueOf(sc.next()));
		
		if (A.compareTo(B) == 0) {
			System.out.println("EQUAL");
		} else if (A.compareTo(B) > 0) {
			System.out.println("GREATER");
		} else {
			System.out.println("LESS");
		}
		
		sc.close();
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>

using namespace std;

int main(){

  int N; cin >> N;
  vector <int> V(N);
  vector <int> C(N);
  int ans = 0;
  

  for (int i = 0; i < N; ++i){
    cin >> V.at(i);
  }
  for (int i = 0; i < N; ++i){
    cin >> C.at(i);
  }
  for (int i = 0; i < N; ++i){
    if(V.at(i) > C.at(i)){
      ans += V.at(i) - C.at(i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from fractions import gcd
import math

def main():
    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    tmp = 1
    count = None
    for i in range(N):
      tmp = (tmp * a[i]//2) // gcd(tmp,a[i]//2)
      c = 0
      n = a[i]//2
      while n % 2 == 0:
        c += 1
        n //= 2
      if i == 0:
        count = c
      elif count != c:
        print(0)
        exit()
    print((M//tmp +1)//2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16280
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int *A,n,d1,d2=0,tmp,q=0,con = 0;
    scanf("%d",&n);
    A = (int *)malloc(sizeof(int)*n-1);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&d1);
        A[i] = d1;
    }
    tmp = A[n-1];
    for(int i=0;i<n;i++)
    {
        if(A[i] <= tmp)
        {
            if(A[i] == tmp) con += 1;
            d2 = A[i];
            A[i] = A[q];
            A[q] = d2;
            q = q + 1;
        }
    }
    for(int i=0;i<n-1;i++)
    {
        if(tmp == A[i])
        {
            con -= 1;
            if(con == 0){
                printf("[%d] ",A[i]);
            }else {
                printf("%d ",A[i]);
            }
        }
        else
        {
            printf("%d ",A[i]);
        }
    }
    printf("%d\n",A[n-1]);
    return 0;
}


Measured memory_bytes: 2088
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    int n; cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];
    VI b = a, c = a;
    if(prev_permutation(ALL(b))){
        REP(i, n){
            if(i) cout << " ";
            cout << b[i];
        }
        cout << "\n";
    }
    REP(i, n){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << "\n";
    if(next_permutation(ALL(c))){
        REP(i, n){
            if(i) cout << " ";
            cout << c[i];
        }
        cout << "\n";
    }
    return 0;
}



Measured memory_bytes: 3172
<?php
list($N, $K) = ints();
$A = ints();

for($i = 0; $i < min($A); $i++){
    $dp[$i] = 2;//Secondの勝ち
}
for($i = min($A); $i <= $K; $i++){
    //2に遷移させることができれば1の勝ち
    $flag = false;
    foreach($A as $a){
        if($i-$a >= 0 &&$dp[$i-$a] == 2){
            $flag = true;
        }
    }
    $dp[$i] = $flag ? 1 : 2;
}
echo $dp[$K] == 2 ? "Second":"First";

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 10744