akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#define M 1000000000

int mycount = 0;

void merge(int *A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int i, j;

    int L[n1+1], R[n2+1];

    for(i=0; i<n1; i++) {
        L[i] = A[left+i];
    }
    for(i=0; i<n2; i++) {
        R[i] = A[mid+i];
    }

    L[n1] = M;
    R[n2] = M;
    i = 0;
    j = 0;

    for(int k=left; k<right; k++) {
        mycount++;
        if(L[i]<=R[j]) {
            A[k] = L[i];
            i++;
        }
        else {
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(int *A, int left, int right) {
    if(left+1<right) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main() {
    int n;

    cin >> n;
    int A[n];
    for(int i=0; i<n; i++) {
        cin >> A[i];
    }
    mergeSort(A, 0, n);
    for(int i=0; i<n; i++) {
        cout << A[i];
        if(i<n-1) {
            cout << " ";
        }
    }
    cout << endl;
    cout << mycount << endl;

    return 0;
}


Measured memory_bytes: 6884
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
#define M 1000000007

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll a,b,n;
    cin>>a>>b>>n;
    ll k=n/b;
    k=min(n,b-1);
    cout<<floor(a*k/b)<<endl;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned LL
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector< PII >
#define VVI vector< VI >
#define PB push_back
#define F first
#define S second
const int INF=1e9;
const int MOD=1e9+7;
int h,w,freq[26]={0};
string s[100];
bool used[101][101];
bool my_cmp(int x,int y){
    return x>y;
}
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>s[i];
        for(int j=0;j<w;j++)freq[s[i][j]-'a']++;
    }
    VI need;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(used[i][j])continue;
            int cur=1;
            used[i][j]=1;
            if(i!=h-i+1){
                cur++;
                used[h-i+1][j]=1;
            }
            if(j!=w-j+1){
                cur++;
                used[i][w-j+1]=1;
            }
            if(i!=h-i+1&&j!=w-j+1){
                cur++;
                used[h-i+1][w-j+1]=1;
            }
            need.push_back(cur);
            assert(cur!=3);
        }
    }
    sort(need.begin(),need.end(),my_cmp);
    for(auto i:need){
        bool found=0;
        for(int j=0;j<26;j++){
            if(i<=freq[j]){
                freq[j]-=i;
                found=1;
                break;
            }
        }
        if(!found){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  int w, a, b;
  cin >> w >> a >> b;
  cout << max((ll)0, abs(a-b)-w) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
struct sound{
  string name;
  int time;
};

int main() {
  int N, j, sum;
  cin >> N;
  vector<sound> music(N);
  string X;
  for(int i = 0;i < N;i++){
    cin >> music.at(i).name >> music.at(i).time;
  }
  cin >> X;
  
  //Xは何曲め
  for(j = 0;j < N;j++){
    if(X == music.at(j).name){
      break;
    }
  }
  
  //X曲目から最後までの和
  sum = 0;
  for(int i = j + 1;i < N;i++){
    sum += music.at(i).time;
  }
  
  cout << sum << endl;

  
 
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) throws Exception {
        FastReader fr  = new FastReader();
        String s = fr.next();
        BigInteger val = new BigInteger(s);
        BigInteger rem  = val.mod(new BigInteger("3"));
        if(rem.compareTo(BigInteger.ZERO)==0){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 38084
/*
{By GWj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int main(){
	fastio;
	LL a,b,c,d;
	R2(a,b);
	R2(c,d);
	cout<<max(max(a*c,b*d),max(a*d,b*c))<<endl;
	return 0;
}


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

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

    ll n, x, d;
    cin >> n >> x >> d;
    if (d == 0) {
        if (x == 0) {
            cout << 1 << endl;
            return 0;
        }
        cout << n + 1 << endl;
        return 0;
    }
    ll a = d / __gcd(d, x), b = -x / __gcd(d, x);
    if (a < 0) {
        a *= -1;
        b *= -1;
    }
    ll ans = 0;
    vector<ll> zl(n + 1, 1e18), zr(n + 1, -1e18);
    for (ll k = 0; k <= n; k++) {
        ll p = k * (k - 1) / 2, q = k * (2 * n - k - 1) / 2;
        if (k + a <= n) {
            zl[k + a] = b + min(zl[k], p);
            zr[k + a] = b + max(zr[k], q);
        }
        if (zr[k] == -1e18)
            ans += q - p + 1;
        else if (zr[k] < p || q < zl[k])
            ans += q - p + 1;
        else if (p <= zl[k] && zr[k] <= q)
            ans += q - p - zr[k] + zl[k];
        else if (zl[k] <= p)
            ans += max(0LL, q - zr[k]);
        else
            ans += zl[k] - p;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
int n;
int dis[305][305];
bool ok[305][305],flag;
int main(){
    read(n);
    for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) read(dis[i][j]);
    for (int k=1;k<=n;k++){
        for (int i=1;i<=n;i++){
            for (int j=1;j<=n;j++)if (i!=j && i!=k && j!=k){
                if (dis[i][k]+dis[k][j]<dis[i][j]) flag=true;
                if (dis[i][k]+dis[k][j]==dis[i][j]) ok[i][j]=true;
            }
            if (flag) break;
        }
        if (flag) break;
    }
    if (flag) puts("-1");
    else{
        ll ans=0;
        for (int i=1;i<=n;i++){
            for (int j=i+1;j<=n;j++){
                ans+=1LL*(ok[i][j]?0:dis[i][j]);
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K; cin >> N >> K;
  string s = "";
  while(N / K > 0){
    s = to_string(N % K) + s;
    N /= K;
  }
  if(N != 0){
    s = to_string(N) + s;
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N = Integer.parseInt(scan.next());

        int count = 0;
        int ans = 0;
        for(int i = 1; i <= N; i+=2){

            count = 0;

            for(int j = 1; j <= N; j+=2){
                if(i%j == 0) count++;
            }
            if(count == 8) ans ++;
        }

        System.out.println(ans);

    }
}

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

int main() {
	int n, q;
	cin >> n >> q;
	vector<vector<int>>graph(n + 1, vector<int>(0));
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		graph.at(x).push_back(y);
		graph.at(y).push_back(x);
	}
	vector<vector<int>>children(n+1, vector<int>(0));
	queue<int>qc;
	qc.push(1);
	while (qc.size() > 0) {
		int v = qc.front();
		for (int i = 0; i < graph.at(v).size(); i++) {
			int x = graph.at(v).at(i);
			if (children.at(x).size() == 0) {
				children.at(v).push_back(x);
				qc.push(x);
			}
		}
		qc.pop();
	}
	
	vector<ll>ans(n+1,0);

	for (int i = 0; i < q; i++) {
		int st, pl;
		cin >> st >> pl;
		ans.at(st) += pl;
	}
	queue<int> plq;
	plq.push(1);
	while (plq.size() > 0) {
		int x = plq.front();
		for (int i = 0; i < children.at(x).size(); i++) {
			int v = children.at(x).at(i);
			ans.at(v) += ans.at(x);
			plq.push(v);
		}
		plq.pop();
	}
	for (int i = 1; i < n + 1; i++) {
		if (i == 1)cout << ans.at(i);
		else cout << " " << ans.at(i);
	}

}

Measured memory_bytes: 25856
# 私たちはN人で旅行しようとしており、その交通手段として電車とタクシーがあります。電車を使うと1人あたりA円かかります。
# タクシーを使うとN人でB円かかります。全員の交通費の合計は最小でいくらになるでしょうか。

N,A,B = map(int,input().split())

print(min(N * A,B))

Measured memory_bytes: 9080
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y, h;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	int a[100];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0, sum = 0;
	sort(a, a + n);
	reverse(a, a + n);
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0)
			ans += a[i];
		else
			sum += a[i];
	}
	cout << ans - sum << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
"use strict";
const main = input => {
    let s = input[0], ans;
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ans=1;
    if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) ans=1;
    if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) ans=1;
    console.log(ans==1?'Yes':'No');
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 21064
N = int(input())
A = []
p = 0
q = 0
for i in range(N):
  a = int(input())
  A.append(a)
  if a > p:
    q = p
    p = a
  elif a > q:
    q = a
for i in range(N):
  if A[i] == p:
    print(q)
  else:
    print(p)

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

int h, w;
char a[8][8];

bool dfs(int i, int j){
    if(i == h-1 && j == w-1) return true;
    if(i+1 < h && a[i+1][j] == '#' && dfs(i+1,j)) return true;
    if(j+1 < w && a[i][j+1] == '#' && dfs(i,j+1)) return true;
    return false;
}

int main(){
    cin >> h >> w;
    int c = 0;
    rep(i,h) {
        rep(j,w){
            cin >> a[i][j];
            if(a[i][j] == '#') c++;
        }
    }
    if(dfs(0,0) && c == h+w-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
import math._
import scala.collection.mutable.Queue

object Main {

  def calc(g: Array[Array[Int]]): Int = {
    val rows = g.length
    val cols = g(0).length

    var ans = 0
    val used = Array.fill(rows, cols)(false)
    for (i <- 0 to rows-1) {
      for (j <- 0 to cols-1) {
        if (g(i)(j) == 1 && !used(i)(j)) {
          ans += 1

          var q = new Queue[(Int, Int)]
          q.enqueue((i, j))
          while (!q.isEmpty) {
            val (r, c) = q.dequeue

            if (!used(r)(c)) {
              used(r)(c) = true

              for (dr <- -1 to 1; dc <- -1 to 1) {
                val row = r + dr
                val col = c + dc
                if (0 <= row && row < rows && 0 <= col && col < cols) {
                  if (g(row)(col) == 1) {
                    q.enqueue((row, col))
                  }
                }
              }
            }
          }
        }
      }
    }
    ans
  }

  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)

    var b = true
    while (b) {
      val w, h = sc.nextInt
      if (w == 0 && h == 0) {
        b = false
      }
      else {
        var g = Array.fill(h, w)(0)
        for (i <- 0 to h-1) {
          for (j <- 0 to w-1) {
            g(i)(j) = sc.nextInt
          }
        }

        println(calc(g))
      }
    }
  }
}

Measured memory_bytes: 76236
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var nw = Console.ReadLine().SplittedStringToInt32List();
        var N = nw[0];
        var W = nw[1];
        var dp = new int[N + 1, W + 1];
        
        for (int i = 0; i < N; i++)
        {
            var vw = Console.ReadLine().SplittedStringToInt32List();
            var v = vw[0];
            var w = vw[1];

            for (int j = 0; j <= W; j++)
            {
                if (j - w >= 0)
                    dp[i + 1, j] = Math.Max(dp[i, j], dp[i + 1, j - w] + v);
                else
                    dp[i + 1, j] = dp[i, j];
            }
        } 

        Console.WriteLine(dp[N,W]);
        Console.ReadLine();
    }

    #region ライブラリ

    #region 文字列処理

    public static int ToInt32(this string str) => int.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();

    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    #endregion
    #region DeepClone
    public static T DeepClone<T>(this T src)
    {
        using (var memoryStream = new MemoryStream())
        {
            var binaryFormatter
              = new BinaryFormatter();
            binaryFormatter.Serialize(memoryStream, src);
            memoryStream.Seek(0, SeekOrigin.Begin);
            return (T)binaryFormatter.Deserialize(memoryStream);
        }
    }
    #endregion

    public static int Gcd(int a,int b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }
    #endregion
}



Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vs = vector<string>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  ll N;
  string S, T, ans = "";
  cin >> N >> S >> T;

  for (ll i = 0; i < N; i++) {
    ans += S.at(i);
    ans += T.at(i);
  }

  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e18 + 7;

int main (){
    ios_base::sync_with_stdio(false);
    
    ll n, s = 100, count = 0;
    cin >> n;

    while (s < n){
        count++;
        s += s/100;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3692
a = input().split()

a_int = [int(x) for x in a]

if (a_int[2] > a_int[0] and a_int[1] > a_int[2]):
    print("Yes")

elif(a_int[2] < a_int[0] and a_int[1] < a_int[2]):
    print("Yes")

else :
    print("No")

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  vector<int> res;
  vector<bool> used(N, false);
  function<void(int)> f = [&](int i) {
    res.emplace_back(i);
    used[i] = true;
    for (int j : G[i]) {
      if (!used[j]) {
        f(j);
        break;
      }
    }
  };
  f(0);
  reverse(res.begin(), res.end());
  used[0] = false;
  res.pop_back();
  f(0);
  cout << res.size() << '\n';
  for (const auto &v : res) {
    cout << v + 1 << (&v == &res.back() ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 12024
import java.util.ArrayList;
public class Main {
	public static void main(String args[]){
		//ArrayList<Integer> a=new <Integer>ArrayList();
		for(int i=1;i<=9;i++){
			for(int j=1;j<=9;j++){
				System.out.printf("%dx%d=%d\n",i,j,i*j);
			}
		}
		
	}
}

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

int routeSum(vector<int> data, int from, int n, int k){
    int result = 0;
    int f = from;
    int t = f + 1;

    do{
        if(f == n-1){
            result += (k - data.at(f)) + data.at(0);
            f = 0;
            t = 1;
            continue;
        }

        result += data.at(t) - data.at(f);
        f++;
        t++;
        if(t == n){
            t = 0;
        }
    } while(t != from);

    return result;
}

int main(){
    int n, k;
    vector<int> points(0);

    cin >> k >> n;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        points.push_back(a);
    }

    int maxDist = (k - points.at(n-1)) + points.at(0);
    int maxPoint = 0;
    for(int i=1; i< n; i++){
        int dist = points.at(i) - points.at(i-1);
        if(dist > maxDist){
            maxDist = dist;
            maxPoint = i;
        }
    }

    cout << routeSum(points, maxPoint, n, k) << endl;

    return 0;
}

Measured memory_bytes: 1908
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 1000000000000
#define MAX 1000000000000000000
typedef long long ll;
typedef pair<ll,int> P;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

int main(){
    ll S;
    cin>>S;
    ll x1,y1,x2,y2;
    x1=1000000000;
    x2=1;
    y2=(S+999999999)/x1;
    y1=x1*y2-S;
    cout<<0<<endl<<0<<endl<<x1<<endl<<y1<<endl<<x2<<endl<<y2<<endl;
}


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

int C[1001][1001];
string N1, N2;

int lcs()
{
	int m = N1.size();
	int n = N2.size();
	int maxl = 0;

	N1 = " " + N1;
	N2 = " " + N2;

	for (int i = 1; i <= m; i++)
		C[i][0] = 0;
	for (int i = 1; i <= n; i++)
		C[0][i] = 0;

	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (N1[i] == N2[j])
				C[i][j] = C[i - 1][j - 1] + 1;
			else
				C[i][j] = max(C[i - 1][j], C[i][j - 1]);

			maxl = max(maxl, C[i][j]);
		}
	}

	return maxl;
}

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

	int q;

	cin >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> N1 >> N2;
		cout << lcs() << endl;
	}
		
	return 0;                                                                            
}


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

const int mod = 1e9+7;
long long a[100005];

long long bc[100005];

long long pot(long long a, long long b){
	if (b == 0)
		return 1;
	if (b == 1)
		return a;
	if (b % 2 == 0){
		long long  t = pot(a,b/2);
		return t*t%mod;
	}
	else{
		long long t = pot(a,b-1);
		return t*a%mod;
	}
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	sort(a+1,a+n+1);
	long long wynik = 0;

	bc[k-1] = 1;
	for (int i = k; i <= n; ++i){
		bc[i] = 1LL * i * bc[i-1] % mod;
		bc[i] *= pot((i-k+1),mod-2) % mod;
		bc[i] %= mod;
		//cout << i << ": " <<  bc[i] << "\n";
	}

	for (int i = 1; i <= n; ++i){
		if (i >= k){
			//cout << i << ": " << " + " << bc[i-1] << " * " << a[i] << "\n";
			wynik += bc[i-1] * a[i] % mod;
			wynik %= mod;
		}
		if (i <= n-k+1){
			//cout << i << ": " << " - " << bc[n-i] << " * " << a[i] << "\n";
			wynik -= bc[n-i] * a[i] % mod;
			wynik = (wynik+mod) % mod;
		}
	//	cout << i << ": " << wynik << "\n";
	}
	cout << wynik << "\n";
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>>;
using GraphEdge = vector<vector<int>>;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {    long long t = a / b;    a -= t * b; swap(a, b);    u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
//MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int main(){
    int a,b;cin >> a >> b;
    if(a%2==0 || b%2==0)cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
 
int main(void){
	int in[2]={0};
	int i;
	int count=0;
	int rev=0,num=0;
	scanf("%d %d",&in[0],&in[1]);
	for(i=in[0];i<=in[1];i++){
		num=i;
		rev=0;
		while(num>0){
			rev=rev*10+num%10;
			num/=10;
		}
		if(i==rev){
			count++;
		}
	}
	printf("%d",count);	
	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10 ** 9)

n,m,q = map(int,input().split())
abcd = []
for i in range(q):
  abcd.append(tuple(map(int,input().split())))

ans = 0
def dfs(l):
  global ans
  if len(l) == n:
    ans = max(check(l),ans)
  else:
    if len(l) == 0:
      mx = 1
    else:
      mx = l[-1]
    for i in range(mx,m+1):
      tmpl = l + [i]
      dfs(tmpl)

def check(l):
  res = 0
  for a,b,c,d in abcd:
    a -= 1
    b -= 1
    if l[b]-l[a] == c:
      res += d
  return res

dfs([])
print(ans)


Measured memory_bytes: 73144
H, W = map(int, input().split())
s = []
for i in range(-1, H+1):
	if i < 0 or i >= H:
		tmp = ["."] * (W + 1)
	else:
		tmp = ["."]
		for t in input():
			tmp.append(t)
	tmp.append(".")
	s.append(tmp)


for h in range(1, H+1):
	judge = True
	for w in range(1, W+1):
		if s[h][w] != "#":
			continue
		judge = False
		if s[h+1][w] == "#":
			judge = True
		if s[h-1][w] == "#":
			judge = True
		if s[h][w+1] == "#":
			judge = True
		if s[h][w-1] == "#":
			judge = True
		if not judge:
			break
	if not judge:
		break

ret = 'Yes' if judge else 'No'
print(ret)
			


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	String dd=sc.next();
    	String S=sc.next();
    	
    	String result="A"+S.substring(0, 1)+"C";
    	
    	System.out.println(result);
    }
}


Measured memory_bytes: 21844
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;
class P
{
    static void Main()
    {
        int[] abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
        for (int i = 1; i <= abc[1]; i++)
        {
            if((abc[0] * i) % abc[1] == abc[2])
            {
                Console.WriteLine("YES");
                return;
            } 
        }
        Console.WriteLine("NO");
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) y=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  --a;
  ll ans;
  if(a == -1) ans = b / x + 1;
  else ans = b / x - a / x;
  cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    a, b, c, k = map(int, input().split())

    ans = 0
    if k >= a:
        ans += a
        k = k - a
        if k >= b:
            k = k - b
            ans -= k
            print(ans)
        else:
            print(ans)
    else:
        ans += k
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9184
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <cmath>
#include <vector>
#include <cstring>
#define MP make_pair
using namespace std;

bool used[100010];
int A[200010],B[200010],D[200010];
long long dp[100010];
vector<pair<int,int> > ve[100010]={};
priority_queue<pair<long long,int> ,vector<pair<long long,int> >,greater<pair<long long,int> > > pq;
map<long long,long long> ma;
int main(){
	int N,M,C;
	long long hog,puy,dsum,mns;
	vector<pair<int,int> >::iterator it;
	map<long long,long long>::iterator itm;
	cin>>N>>M>>C;
	dsum=0;
	for(int i=1;i<=M;i++){
		cin>>A[i]>>B[i]>>D[i];
		ve[A[i]].push_back(MP(B[i],D[i]));
		ve[B[i]].push_back(MP(A[i],D[i]));
		dsum+=D[i];
	}
	int np;
	long long nd;
	
	pq.push(MP(0,1));
	while(!pq.empty()){
		np=pq.top().second;
		nd=pq.top().first;
		pq.pop();
		if(!used[np]){
			used[np]=true;
			dp[np]=nd;
			for(it=ve[np].begin();it!=ve[np].end();it++){
				if(!used[it->first]){
					pq.push(MP(nd+(long long)(it->second),it->first));
				}
			}
		}
	}

	for(int i=1;i<=M;i++){
		hog=max(dp[A[i]],dp[B[i]]);
		itm=ma.find(hog);
		if(itm==ma.end()){
			ma.insert(MP(hog,D[i]));
		}
		else{
			puy=(*itm).second;
			puy+=D[i];
			ma.erase((*itm).first);
			ma.insert(MP(hog,puy));
		}
	}
	long long res=dsum;
	mns=0;
	for(itm=ma.begin();itm!=ma.end();itm++){
		mns+=(*itm).second;
		//cout<<(*itm).first<<" "<<dsum-mns+C*((*itm).first)<<endl;//
		res=min(res,dsum-mns+C*((*itm).first));
	}
	/*
	for(int i=1;i<=N;i++){
		cout<<i<<" "<<dp[i]<<endl;
	}
	*/
	cout<<res<<endl;
}

Measured memory_bytes: 18820
#include<stdio.h>
int main(){
    int i,j,n,t,b[100],a[5][5],c[5][5];
    for(i=0;i<3;i++)
        for(j=0;j<3;j++)
            scanf("%d",&a[i][j]);
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&b[i]);
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
                c[i][j]=0;
            for(t=0;t<n;t++){
                if(b[t]==a[i][j]) c[i][j]=1;
            }
        }
    }
    if(c[0][0]==1&&c[0][1]==1&&c[0][2]==1){printf("Yes\n"); return 0;}
    else if(c[1][0]==1&&c[1][1]==1&&c[1][2]==1){printf("Yes\n"); return 0;}
    else if(c[2][0]==1&&c[2][1]==1&&c[2][2]==1){printf("Yes\n"); return 0;}
    else if(c[0][0]==1&&c[1][1]==1&&c[2][2]==1){printf("Yes\n"); return 0;}
    else if(c[2][0]==1&&c[1][1]==1&&c[0][2]==1){printf("Yes\n"); return 0;}
    else if(c[0][0]==1&&c[1][0]==1&&c[2][0]==1){printf("Yes\n"); return 0;}
    else if(c[0][1]==1&&c[1][1]==1&&c[2][1]==1){printf("Yes\n"); return 0;}
    else if(c[0][2]==1&&c[1][2]==1&&c[2][2]==1){printf("Yes\n"); return 0;}
    else {printf("No\n"); return 0;}
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <stack>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; ++i) cin >> S[i];
    int q; cin >> q;
    vector<int> T(q);
    for (int i = 0; i < q; ++i) cin >> T[i];
    int cnt = 0;

    // 線形探索
    for (int i = 0; i < q; ++i) {
        int key = T[i];
        int j = 0;
        while (true) {
            if (key == S[j]) {
                cnt++;
                break;
            }
            if (j >= n) break;
            j++;
        }
    }

    cout << cnt << endl;

    return 0;
}


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


public class Hello
{
    public static void Main()
    {
        List<string> text = new List<string>();
        string str;
        while (!((str = Console.ReadLine()) == null))
        {
            for (int i = 0; i <= 26; i++)
            {
                string shift = string.Join("", str.Select(x => ('a' <= x && x <= 'z') ? (char)((x + i - 'a') % 26 + 'a') : x));

                if (shift.Contains("the") || shift.Contains("this") || shift.Contains("that"))
                {
                    text.Add(shift);
                    break;
                }
            }
        }

        foreach (string item in text)
            Console.WriteLine(item);
    }

}



Measured memory_bytes: 16116
//csjosh

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> //required
// #include <ext/pb_ds/tree_policy.hpp> //required
// using namespace __gnu_pbds; //required 
using namespace std;

#define ll long long 
#define loop(x) for(int i=0;i<x;i++)

#define llu unsigned long long 
#define pb push_back
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra
ll mod=1e9+7;
// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }

// typedef tree<
// pair<int, int>,
// null_type,
// less<pair<int, int>>,
// rb_tree_tag,
// tree_order_statistics_node_update> ordered_set;
 
  ll n,k;

void multiply(ll b[55][55],ll c[55][55]){
  ll d[55][55];
  memset(d,0,sizeof d);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        d[i][j]=(d[i][j]+(b[i][k]*c[k][j]))%mod;
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      b[i][j]=d[i][j];
    }
  }
}
void power(ll b[55][55],ll h){
 ll ans[55][55];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j){
        ans[i][j]=1;
      }
      else
        ans[i][j]=0;
    }
  }
  while(h>0){
    if(h&1)
      multiply(ans,b);
    multiply(b,b);
    h=h/2;
  }   
 for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      b[i][j]=ans[i][j];
    }
  }
}
int main(){
    IOS;  
   
     ll a[55][55];
    cin>>n>>k;
   
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
        cin>>a[i][j];
    //if i do a^k then i will get all the paths
    power(a,k);
    int ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        ans=(ans+a[i][j])%mod;
      }
    }
    cout<<ans<<endl;
 }



Measured memory_bytes: 384
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
char s[10];
int main() {
	cin >> s;
	if (s[0] == s[1]) return printf("Bad\n"), 0;
	if (s[1] == s[2]) return printf("Bad\n"), 0;
	if (s[2] == s[3]) return printf("Bad\n"), 0;
	printf("Good\n");
	return 0;
}

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

int main()
{
    int N,boss;
    cin >> N;
    int A[N+1];
    int B[(200000)+1]{0};
    for(int i=2;i<(N+1);i++)
    {
        cin >> A[i];
        boss = A[i];
        B[boss] += 1;
    }
    for(int i=1;i<(N+1);i++)
    {
        cout << B[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5180
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
#define N 200003
#define LL long long
#define mod 998244353

int a,b;

inline int read(){
	int X=0,w=0;
	char ch=0;
	while (ch<'0' || ch>'9')
	  w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9')
	  X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w ? -X : X;
}

int main(){
	a=read();b=read();
	if (a>b) swap(a,b);
	if ((a+b)%2==0) printf("%d\n",(a+b)/2);
	  else printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <random>
#include <map>
#include <iomanip>
#include <sstream>

//AtCoderC++.cpp

using namespace std;


#define rep(i,from,to) for(int i=from;i<to;i++)
#define ints(name,n) vector<int> name;name.resize(n)

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	rep(i, 0, h) {
		rep(j, 0, w) {
			if (!ts[i][j])return false;
		}
	}
	return true;
}

bool is_month(const string& mm) {
	if (mm[0] > '1') return false;
	if (mm[0] == '1') {
		return mm[1] <= '2';
	} else {
		return mm[1] != '0';
	}
}

int main() {
	string s;
	cin >> s;
	auto isYYMM = is_month(s.substr(2, 2));
	auto isMMYY = is_month(s.substr(0, 2));
	if (isYYMM&&isMMYY) {
		cout << "AMBIGUOUS" << endl;
	} else if (isYYMM) {
		cout << "YYMM" << endl;
	} else if(isMMYY){
		cout << "MMYY" << endl;
	} else {
		cout << "NA" << endl;
	}
}

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

int edge[8][8];
int visited[8];
int ans = 0;
int n;

void dfs(int pos){
    if(visited[pos]) return;
    visited[pos] = 1;
    int ok = 1;
    for(int i = 0; i < n; i++) ok *= visited[i];
    if(ok) ans++;
    for(int i = 0; i < n; i++){
        if(edge[pos][i]==1) dfs(i);
    }
    visited[pos] = 0;
    return;
}

int main(){
    int m;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        visited[i] = 0;
        for(int j=0;j<n;j++){
            edge[i][j] = 0;
        }
    }
    int a,b;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        edge[a-1][b-1] = 1;
        edge[b-1][a-1] = 1;
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())

    def Eratosthenes(x: int) -> set:
        """x以下の素数の集合を返す"""
        import math
        sup = int(x)
        primes = {i for i in range(2, sup+1)}
        for i in range(2, int(math.sqrt(sup+1))+1):
            if i in primes:
                mul = 2
                while i*mul <= sup:
                    primes.discard(i*mul)
                    mul += 1
        return primes

    p = Eratosthenes(55555)
    for v in p.copy():
        if v % 5 != 1:
            p.discard(v)

    from itertools import combinations
    for i, v in enumerate(combinations(p, N)):
        if i == 0:
            print(*v)
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 43372
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
signed main()
{
    fast;
    int n,m;
    cin>>n>>m;
    int ans = 0;
    priority_queue<int> pq;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        pq.push(x);
    }
    while(m>0 && !pq.empty())
    {
        int tp = pq.top();
        pq.pop();
        pq.push(tp/2);
        m--;
    }
    while(!pq.empty())
    {
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<iomanip>
using namespace std;
int n,w;
main()
{
	while(cin>>n>>w,n)
	{
		int a[100]={};
		int maxv=0;
		for(int i=0;i<n;i++)
		{
			int v;cin>>v;
			a[v/w]++;
			maxv=maxv<a[v/w]?a[v/w]:maxv;
		}
		double ans=1e-2;
		int l=99;
		while(a[l]<1)l--;
		int cnt=l;
		for(int i=0;i<=l;i++)
		{
			ans+=(cnt-i)*1.0/cnt*a[i]/maxv;
		}
		cout<<fixed<<setprecision(9)<<ans<<endl;
	}
}



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

int main(void){
  int a,b;
  while(cin>>a>>b){
    switch(a){
    case 1:a=b*6000;break;
    case 2:a=b*4000;break;
    case 3:a=b*3000;break;
    case 4:a=b*2000;break;
  }
    cout<<a<<endl;
  }
  
}

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


int main(){
	ll A,B,C,S;
	cin >> A >> B >> C;
	S = 7*A+B;
	ll ans = min( (C/S)*7 + (C%S+A-1)/A, (C+S-1)/S * 7);
	cout << ans << endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    unordered_set<int> s(100000);
    int n;
    cin>>n;
    int p;
    while(n-->0)
    {
        cin>>p;
        if(s.find(p)==s.end()) s.insert(p);
        else s.erase(p);
    }
    cout<<s.size();
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 a,b,c,k;
  cin >> a >> b >> c >> k;
  int32 ans = 0;
  ans += min(a,k);
  k-=a;
  k-=b;
  if(k > 0)
    ans -= min(c,k);
  ANS(ans);
  return 0;
}

Measured memory_bytes: 3640
def main():
    from collections import defaultdict
    import sys
    input = sys.stdin.readline

    H, W, N = map(int, input().split())

    g = defaultdict(int)
    for _ in range(N):
        a, b = (int(x) - 1 for x in input().split())
        for i in range(3):
            if a - i < 0: continue
            if a - i + 3 > H: continue
            for j in range(3):
                if b - j < 0: continue
                if b - j + 3 > W: continue
                g[(a - i) * W + (b - j)] += 1
                # (a,b)を塗ったとき影響される3x3マス目の左上の座標に加算する

    ctr = [0] * 10
    tot = (H - 2) * (W - 2)
    for cnt in g.values():
        ctr[cnt] += 1
        tot -= 1
    ctr[0] = tot

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


if __name__ == '__main__':
    main()


Measured memory_bytes: 104816
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define LL long long
#define R register
char s[100005],p[100005];
int main()
{
	cin>>s;
	int len=strlen(s);
	for(R int i=0;i<len;i++)p[i]=s[i];
	for(R int i=0;i<len/2;i++)swap(s[i],s[len-i-1]);
	for(R int i=0;i<len;i++)
	{
		if(s[i]=='b')s[i]='d';
		else if(s[i]=='d')s[i]='b';
		else if(s[i]=='p')s[i]='q';
		else if(s[i]=='q')s[i]='p';
		if(s[i]!=p[i])
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
  int b,c,d;

  scanf("%d %d %d",&b,&c,&d);

  if(b==1&&c==0&&d==0){printf("Close\n");}
  else if(b==0&&c==1&&d==0){printf("Close\n");}
  else if(b==1&&c==1&&d==0){printf("Open\n");}
  else if(b==0&&c==0&&d==1) {printf("Open\n");}
  else  printf("Close\n");

  return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string str,x,y;
int n,a,b;
int main(){
	cin>>n;
	while(n--){
		cin>>str;
		x=str;
		sort(x.begin(),x.end());
		y=x;
		reverse(y.begin(),y.end());
		a=b=0;
		for(int i=0;i<(int)str.size();i++){
			a+=x[i];b+=y[i];
			a*=10;b*=10;
		}
		cout<<(b-a)/10<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int num,pernum,perint,rem;
    double per,perans;
    
    scanf("%d %d",&num,&pernum);
    per    = pernum;
    perint = num / pernum;
    rem    = num % pernum;
    perans = num / per;
    printf("%d %d %lf\n",perint,rem,perans);
    return 0;
}

Measured memory_bytes: 636