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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a,b,c,k;
    cin>>a>>b>>c>>k;

    int ans = 0;
    if(k<=a) {
        ans+=k;
        cout<<ans;
        return 0;
    }   
    ans+=a;
    k-=a;
    if(k<=b) {
        cout<<ans;
        return 0;
    }
    k-=b;
    ans-=k;
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main()
{
    int T[101][101],r,c;
 
    cin>>r>>c;
    for(int i=0;i<r;i++)
        for(int j=0;j<c;j++)cin>>T[i][j];
 
    for(int i=0;i<=r;i++)T[i][c]=0;
    for(int j=0;j<=c;j++)T[r][j]=0;
 
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            T[i][c]+=T[i][j];
            T[r][j]+=T[i][j];
            T[r][c]+=T[i][j];
        }
    }
 
    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            if(j)cout<< " ";
            cout<<T[i][j];
        }
        cout<<endl;
    }
 
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<long> a(3 * N);
    for (int i = 0; i < 3 * N; i++) {
        cin >> a.at(i);
    }

    long ans = 0;
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    for (int i = 1; i < N + N; i += 2) {
        ans += a.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200016
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
int n , m , k;
int A[MAXN];
void solve( ) {
    cin >> n >> m;
    cout << n * ( n - 1 ) / 2 + m * ( m - 1 ) / 2;
}
signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	cnt := 0
	ans := 0

	for i := 0; i < n; i++ {
		switch rune(s[i]) {
		case 'I':
			cnt++
		case 'D':
			cnt--
		}
		ans = max(ans, cnt)
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 512
N = int(input())
H_list = [int(x) for x in input().split()]
lst = [0] * N
cnt = 0
for i, h in enumerate(H_list[::-1]):
    if (i == 0):
        lst[i] = 0
        prev = h
        continue
    if (h >= prev):
        cnt += 1
        lst[i] = cnt
    else:
        cnt = 0
        lst[i] = cnt
    prev = h
print(max(lst))


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

int main(){
  int n;
  cin >> n;
  vector<int>a(3*n);
  long long ans=0;
  
  for(int i=0; i<3*n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  for(int i=1; i<=n; i++){
    ans+=a[2*i-1];
  }
  cout << ans << endl;
  
  
  
}

Measured memory_bytes: 1408
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	m := map[int]bool{}
	for _, b := range a {
		_, ok := m[b]
		if ok {
			fmt.Printf("NO")
			return
		}
		m[b] = true
	}

	fmt.Printf("YES")
}


Measured memory_bytes: 10368
N = int(input())
X = []; Y = []; P = []
INF = float("inf")
for i in range(N):
  x,y,p = list(map(int,input().split()))
  X.append(x);Y.append(y);P.append(p)
ans = [INF for _ in range(N+1)] #0本置いた時からN本置いた時までN+1個

def calc(A):
  n = len(A) #Aにはいくつ入っているか。つまり、xoryで選ばれたものはいくつあるか。
  A.sort()
  dp = [[INF]*(n+1) for _ in range(n+1)] #i個目までカバーしてj個目まで道を置いた。
  dp[0][0] = 0
  for l in range(n):
    for r in range(l+1,n+1):
      now = INF
      for k in range(l,r):
        s = 0
        for i in range(l,r):
          s += abs(A[i][0]-A[k][0])*A[i][1]
        now = min(now,s)
      for j in range(n):
        dp[r][j+1] = min(dp[r][j+1], dp[l][j]+now)
      now = 0
      for i in range(l,r):
        now += abs(A[i][0])*A[i][1]
      for j in range(n+1):
        dp[r][j] = min(dp[r][j], dp[l][j]+now)

  
  res = [INF for _ in range(n+1)] #道が0本からn本
  for j in range(n+1):
    res[j] = dp[n][j]

  return res
    

for s in range(1<<N): #x軸にするかをbitで全探索
  AX = [];AY = [] #Aは選ばれた村を追加していく。2**N回これは更新される。
  for i in range(N):
    if (s>>i)&1 == 1: #x軸で見る
      AX.append((X[i],P[i]))
    else:
      AY.append((Y[i],P[i]))
    
  dx = calc(AX)
  dy = calc(AY)
  for i in range(len(dx)):
    for j in range(len(dy)):
      ans[i+j] = min(ans[i+j],dx[i]+dy[j])
for t in ans:
  print(t)

Measured memory_bytes: 77448
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

ll n,s,b;

ll f(ll b,ll n){
    if(n<b)return n;
    else return f(b,n/b)+(n%b);
}

int main(){
    cin >> n >> s;
    if(n==s){
        put(s+1);
        return 0;
    }
    for(ll i=2;i*i<=n;++i){
        if(f(i,n)==s){
            put(i);
            return 0;
        }
    }
    for(ll i=floor(sqrt(n));i>0;--i){
        ll b = (n-s)/i+1;
        if(b>1){
            if((n-s)%i==0&&f(b,n)==s){
                put(b);
                return 0;
            }
        }
    }
    put("-1");
    return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::vector<std::vector<long long>> A, long long N, std::vector<long long> b){
    for (int l = 0; l < N; l++) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (A[i][j] == b[l]) A[i][j] = -1;
            }
        }
    }

    bool flag = false;
    if (A[0][0] == -1 && A[0][1] == -1 && A[0][2] == -1) flag = true;
    if (A[1][0] == -1 && A[1][1] == -1 && A[1][2] == -1) flag = true;
    if (A[2][0] == -1 && A[2][1] == -1 && A[2][2] == -1) flag = true;
    if (A[0][0] == -1 && A[1][0] == -1 && A[2][0] == -1) flag = true;
    if (A[0][1] == -1 && A[1][1] == -1 && A[2][1] == -1) flag = true;
    if (A[0][2] == -1 && A[1][2] == -1 && A[2][2] == -1) flag = true;
    if (A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1) flag = true;
    if (A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1) flag = true;
    cout << (flag ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<std::vector<long long>> A(3, std::vector<long long>(3));
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    long long N;
    scanf("%lld",&N);
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&b[i]);
    }
    solve(std::move(A), N, std::move(b));
    return 0;
}


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

int main() {
  int N, K, Q, V;
  cin >> N >> K >> Q;

  vector<int> A(N, K - Q);

  for (int i = 0; i < Q; i++) {
    cin >> V;
    A.at(V - 1) += 1;
  }

  for (int i = 0; i < N; i++) {
    cout << (A.at(i) <= 0 ? "No" : "Yes") << endl;
  }
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> sticks = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    int n, m;
    cin >> n >> m;
    vector<int> values(m);
    for (int& value : values) {
        cin >> value;
    }
    sort(values.begin(), values.end(), [](int i, int j) { return i > j; });
    int inf = 10000000;
    vector<int> num_digits(n+1, -inf);
    num_digits[0] = 0;
    for (int i = 1; i <= n; ++i) {
        int best = -inf;
        for (int value : values) {
            int i0 = i - sticks[value];
            if (i0 >= 0 && num_digits[i0] != -inf) {
                best = max(best, num_digits[i0]+1);
            }
        }
        num_digits[i] = best;
    }
    assert (num_digits[n] > 0); // given by the problem.
    while (n > 0) {
        for (int value : values) {
            int n0 = n - sticks[value];
            if (n0 >= 0 && num_digits[n0] == num_digits[n]-1) {
                cout << value;
                n = n0;
                break;
            }
        }
    }
    cout << endl;
    return 0;
}


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

int main() {
  int N, K;
  cin >> N;
  cin >> K;
  
  int x[N];
  for (int i=0; i<N; i++) {
    cin >> x[i];
  }
  
  int length=0;
  for (int i=0; i<N; i++) {
    if (x[i]<(K-x[i])) {
      length += 2*x[i];
    } else {
      length += 2*(K-x[i]);
    }
  }
  
  cout << length << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define sz(s) (int)s.size()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e4+10;
const ll INF = 1e18;

ll power(ll x,ll y){
	ll t=1;
	while(y>0){
		if(y%2) y-=1,t=t*x%mod;
		else y/=2,x=x*x%mod;
	}
return t;
}

int poss[N];

int main(){
	int n,x;
	scanf("%d",&n);
	poss[0]=1;
	REP(i,n){
		scanf("%d",&x);
//		printf("%d\n",x);
		for(int j=N-1;j>=x;j--)
			poss[j]|=poss[j-x];
	}
	int f=-1;
	for(int i=N-1;i>=0;i--){
		if (poss[i]&&i%10!=0) {f=i; break;}
	}
	if (f==-1) f=0;
	printf("%d\n",f);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
char m[3];
for(int i=0;i<3;i++)cin>>m[i];
sort(m,m+3);
if(m[0]=='a'&&m[1]=='b'&&m[2]=='c')cout<<"Yes";
else cout<<"No";
 return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 class Main{
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int nban,nsyu;
			for(int i = 0; i<4; i++){
				nsyu = sc.nextInt();
				nban = sc.nextInt();
				switch (nsyu){
				case 1: System.out.println(nban*6000);break;
				case 2: System.out.println(nban*4000);break;
				case 3: System.out.println(nban*3000);break;
				case 4: System.out.println(nban*2000);break;
				}
			}

		}

	}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A*B, C*D) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> g(n);
    vector<ll> cnt(n, 0);
    set<ll> on, off;
    rep(i, n - 1 + m) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        on.insert(a);
        off.insert(b);
        cnt[b]++;
    }
    ll root = 0;
    rep(i, n) {
        if ((on.count(i) > 0) && (off.count(i) == 0)) {
            root = i;
            break;
        }
    }
    vector<ll> ans(n);
    ans[root] = -1;
    queue<ll> q;
    q.push(root);
    while(!q.empty()) {
        ll u = q.front(); q.pop();
        for(auto v : g[u]) {
            if (cnt[v] == 1) {
                ans[v] = u;
                q.push(v);
            }
            else {
                cnt[v]--;
            }
        }
    }
    rep(i, n) {
        cout << (ans[i] + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 17280
#include<iostream>

using namespace std;

int main( void ){
  
  int a,b,c,d,e,f;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  cin >> f;
    
  if(f >=e-a) cout << "Yay!";
  else cout << ":(";
  
  return 0;
}
  

Measured memory_bytes: 256
public class
Main
{
  int[ ] a;

  private void
  unite (
    int x,
    int y
    )
  {
    if ( a[ y ] != y )
      unite ( x, a[ y ] );
    else
      a[ y ] = x;
  }

  private int
  getRepresentation (
    int x
    )
  {
    if ( a[ x ] == x )
      return ( x );

    a[ x ] = getRepresentation ( a[ x ] );
    return ( a[ x ] );
  }

  private boolean
  same (
    int x,
    int y
    )
  {
    return ( getRepresentation ( x ) == getRepresentation ( y ) );
  }

  public void
  run (
    java.io.InputStream in,
    java.io.PrintStream out
    )
  {
    java.util.Scanner sc = new java.util.Scanner ( in );
    int n, q;
    int i;

    n = sc.nextInt ( );
    q = sc.nextInt ( );

    a = new int[ n ];
    for ( i = 0; i < n; ++i )
      a[ i ] = i;

    for ( i = 0; i < q; ++i )
    {
      int c, x, y;

      c = sc.nextInt ( );
      x = sc.nextInt ( );
      y = sc.nextInt ( );
      if ( c == 0 )
      {
        if ( !same ( x, y ) )
          unite ( x, y );
      }
      else
        System.out.println ( same ( x, y ) ? "1" : "0" );
    }

    sc.close ( );
  }

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

Measured memory_bytes: 102420
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct UF{
    vector<int> par,sz;
    explicit UF(int n):par(n),sz(n,1){
        iota(par.begin(),par.end(),0);
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    bool unit(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y) return false;
        if(sz[x]>sz[y]){
            par[y]=x;
            sz[x]+=sz[y];
        }
        else{
            par[x]=y;
            sz[y]+=sz[x];
        }
        return true;
    }
    bool same(int x, int y){return find(x)==find(y);}
};

void solve(){
    int n,q;
    cin>>n>>q;
    UF d(n);
    {
        int t,u,v;
        fr(_,q){
            cin>>t>>u>>v;
            if(t) cout<<d.same(u,v)<<'\n';
            else d.unit(u,v);
        }
    }
}

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


Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    vector<int> y(50000);
    rep(i,50000){
        y[i] = i*1.08;
    }
    rep(i,50000){
        if(y[i] == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3728
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

count = 0
count_list = []
result = 0

for i in range(len(A)):
  if i != 0 and i < len(A):
    if A[i-1] == A[i]-1:
      count_list.append(A[i-1])
  result += B[A[i]-1]

for i in count_list:
  result += C[i-1]

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define _START_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _END_ return 0;

using namespace std;

int main()
{   
    _START_
    
    ll int a, b, x, c = 0;
    cin >> a >> b >> x;
    if (a % x)
    {
        if (a + (x - (a % x)) <= b)
        {
            a += (x - (a % x));
            c++;
        }
    }
    else
        c++;
    c += ((b - a) / x);
    cout << c;
    
    _END_
}

Measured memory_bytes: 3660
function Dice() {
  this.top = 1;
  this.bottom = 6;
  this.front = 2;
  this.back = 5;
  this.left = 4;
  this.right = 3;
}

Dice.prototype.goNorth = function() {
  var temp = this.top;
  this.top = this.front;
  this.front = this.bottom;
  this.bottom = this.back;
  this.back = temp;
  return this.top;
};

Dice.prototype.goSouth = function() {
  var temp = this.top;
  this.top = this.back;
  this.back = this.bottom;
  this.bottom = this.front;
  this.front = temp;
  return this.top;
};

Dice.prototype.goEast = function() {
  var temp = this.top;
  this.top = this.left;
  this.left = this.bottom;
  this.bottom = this.right;
  this.right = temp;
  return this.top;
};

Dice.prototype.goWest = function() {
  var temp = this.top;
  this.top = this.right;
  this.right = this.bottom;
  this.bottom = this.left;
  this.left = temp;
  return this.top;
};

Dice.prototype.goLeft = function() {
  var temp = this.front;
  this.front = this.left;
  this.left = this.back;
  this.back = this.right;
  this.right = temp;
  return this.top;
};

Dice.prototype.goRight = function() {
  var temp = this.front;
  this.front = this.right;
  this.right = this.back;
  this.back = this.left;
  this.left = temp;
  return this.top;
};

Dice.prototype.move = function(dir) {
  switch (dir) {
    case 'North':
      return this.goNorth();
    case 'South':
      return this.goSouth();
    case 'East':
      return this.goEast();
    case 'West':
      return this.goWest();
    case 'Left':
      return this.goLeft();
    case 'Right':
      return this.goRight();
  }
};

(function(stdin) {
  var lines = stdin.trim().split('\n');
  while (1) {
    var n = Number(lines.shift().trim());
    if (n == 0) {
      break;
    }
    var sum = 1;
    var dice = new Dice();
    for (var i = 0; i < n; i++) {
      sum += dice.move(lines.shift().trim());
    }
    console.log(sum);
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 16956
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<vector<bool>> graph(N, vector<bool>(N, false));
  REP(i, M){
    int u, v;
    cin >> u >> v;
    u--; v--;
    graph[u][v] = true;
    graph[v][u] = true;
  }

  int ans = 0;
  vector<int> vec(N-1);
  REP(i, N-1) vec[i] = i+1;
  do{
    bool ok = true;
    REP(i, N-1){
      if(i == 0){
        if(!graph[0][vec[i]]) ok = false;
      }else{
        if(!graph[vec[i]][vec[i-1]]) ok = false;
      }
    }
    if(ok) ans++;
  }while(next_permutation(ALL(vec)));

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
#coding: utf-8

N, M = (int(x) for x in input().split())

S = []
for i in range(M):
    items = [int(x)-1 for x in input().split()]
    S.append(items[1:])

P = [int(x) for x in input().split()]

ret = 0
for bit in range(2**N):
    on = [i for i in range(N) if bit & (1 << i)]
    ok = True
    for i in range(M):
        s = S[i]
        p = P[i]
        if sum(1 for switch in s if switch in on) % 2 != p:
            ok = False
            break
    if ok:
        ret += 1
print(ret)


Measured memory_bytes: 9148
#include <stdio.h>
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
	double a, b, c, d, e, f;
	double b1, c1, e1, f1;
	double x, y;

	while (cin >> a >> b >> c >> d >> e >> f) {
		b1 = b * d;
		c1 = c * d;
		e1 = e * a;
		f1 = f * a;

		if (b1 == e1) continue;
		y = (c1 - f1) / (b1 - e1);
		x = (c - b * y) / a;
		printf("%.3f %.3f\n", x, y);
	}
	
	return 0;
}

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

int main() {
  int N,A,X;
  cin>>N>>A;
  X=N%500;
    
  if (A>=499){
    cout<<"Yes"<<endl;
  }
  else if(A>=X){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
amount = int(input())
before_tax = int(amount / 1.08)
after_tax = before_tax + 1
if int(after_tax * 1.08) == amount:
  print(int(after_tax))
elif int(before_tax * 1.08) == amount: 
  print(int(before_tax))
else:
  print(":(")

Measured memory_bytes: 3060
N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i).map{|v| v-1}
B = gets.chomp.split(" ").map(&:to_i)
C = gets.chomp.split(" ").map(&:to_i)

v = 0
prev_j = -100
N.times do |i|
  j = A[i]
  v += B[j]
  v += C[prev_j] if prev_j + 1 == j
  prev_j = j
end
puts v


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<int> g = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    if(g[x] == g[y]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000000000010000;

ll kai[100010];
ll bit[700010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= 700005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
}

ll H, W;
string a[1010];
ll dp[1010][1010];

void solve() {
	cin >> H >> W;
	rep(i, H) {
		cin >> a[i];
	}
	dp[0][0] = 1;
	rep(i, H) {
		rep(j, W) {
			if (i < H - 1 && a[i + 1][j] == '.') {
				(dp[i + 1][j] += dp[i][j]) %= mod;
			}
			if (j < W - 1 && a[i][j + 1] == '.') {
				(dp[i][j + 1] += dp[i][j]) %= mod;
			}
		}
	}
	cout << dp[H - 1][W - 1] << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}
////////////////////////////////////////////////////////////////////////////////////////////jagfhaoi;sd;joi;asdfjzasdi;lfjoi;ernjsdoivcnoizvdfnvdfnon/////////////////////////////////////////////////////////
////////////////////jgoiadhsjgoi;vsjvgfonhjasoivhoivhno

Measured memory_bytes: 9472
use std::io::BufRead;

fn main() {
    let handle = std::io::stdin();
    let mut buf = String::new();
    handle.lock().read_line(&mut buf).unwrap();
    let mut info = buf.trim().split_whitespace();
    let a: f64 = info.next().unwrap().parse().unwrap();
    let b: f64 = info.next().unwrap().parse().unwrap();
    let arg: f64 = info.next().unwrap().parse::<f64>().unwrap().to_radians();
    let aria = 0.5 * a * b * arg.sin();
    let c = (a.powi(2) + b.powi(2) - 2.0 * a * b * arg.cos()).powf(0.5);
    println!("{:.*} {:.*} {:.*}", 5, aria, 5, a + b + c, 5, b * arg.sin())
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N,M;
    cin>>N>>M;
    vector<int> S(N),T(M);
    rep(i,N)cin>>S.at(i);
    rep(i,M)cin>>T.at(i);
    vector<vector<ll>> dp(N+1,vector<ll> (M+1));
    rep(i,N){
        if(S.at(i)==T.at(0)){
            dp[i][0]=1;
        }
    }
    rep(i,N)dp[i+1][0]+=dp[i][0];
    rep(i,M){
        if(T.at(i)==S.at(0)){
            dp[0][i]=1;
        }
    }
    rep(i,M)dp[0][i+1]+=dp[0][i];
    for(int i=1;i<N;i++){
        for(int j=1;j<M;j++){
            dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
            if(S.at(i)==T.at(j)){
                dp[i][j]+=dp[i-1][j-1]+1;
            }
            dp[i][j]%=MOD;
            if(dp[i][j]<0)dp[i][j]+=MOD;
        }
    }
    cout<<dp[N-1][M-1]+1<<endl;
    /*rep(i,N){
        rep(j,M){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
}

Measured memory_bytes: 34676
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

int main(){
  ll N;
  cin >> N;
  map<ll,ll> map;
  ll sum=0;
  for(ll i=0;i<N;i++){
    ll a;
    cin >> a;
    map[a]++;
    sum+=a;
  }
  ll Q;
  cin >> Q;
  for(ll i=0;i<Q;i++){
    ll b,c;
    cin >> b >> c;
    map[c]+=map[b];
    sum+=c*map[b];
    sum-=b*map[b];
    map[b]=0;
    cout << sum << endl;
  }
}

Measured memory_bytes: 9336
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;

int main(){
    
    int s, w;
    cin >> s >> w;
    
    if(w >= s){
        cout << "unsafe" << "\n";
    } else {
        cout << "safe" << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 3048
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
 
 
int main(){
  int d;
  cin >> d;

  if(d == 25){
    cout << "Christmas" << endl;
  }else if(d == 24){
    cout << "Christmas Eve" << endl;
  }else if(d == 23){
    cout << "Christmas Eve Eve" << endl;
  }else if(d == 22){
    cout << "Christmas Eve Eve Eve" << endl;
  }
}

Measured memory_bytes: 256
# C - Tax Increase
from math import floor


def calc(a: int, b: int) -> int:
    for i in range(1, 1010):
        if floor(i * 0.08) == a and floor(i * 0.1) == b:
            return i
    return -1


def main():
    A, B = map(int, input().split())
    print(calc(A, B))


if __name__ == "__main__":
    main()


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    int ans1=0;
    int ans2=1000000;
    for(int i=0; i<m; i++){
        cin >> l.at(i) >> r.at(i);
        ans1=max(ans1,l.at(i));
        ans2=min(ans2,r.at(i));
    }
    if(ans2-ans1<0){
        cout << 0 << endl;
    }
    else{
        cout << ans2-ans1+1 << endl;
    }
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll a,b;
  cin>>a>>b;
  if(a==b){
    cout << "Draw" << endl;
  }
  else{
    if(a==1){
      cout << "Alice" << endl;
    }
    else if(b==1){
      cout << "Bob" << endl;
    }
    else{
      if(a>b){
        cout << "Alice" << endl;
      }
      else{
        cout << "Bob" << endl;
      }
    }
  }
  return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
bitset<32> b[200020], ans[200020];
int main() {
	int n;
	cin >> n;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		b[i] = (a);
	}
	for (int i = 0; i <= 31; i++) {
		int o = 0;
		for (int j = 0; j < n; j++) {
			if (b[j][i]) {
				o++;
			}
		}
		if (o % 2 == 1) {
			for (int j = 0; j < n; j++) {
				if (b[j][i]) {
					b[j][i] = 0;
				}
				else {
					b[j][i] = 1;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << b[i].to_ulong();
		if (i != n - 1) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 5084
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>

using namespace std;

int main(){
	int N,M;
	int dt,vt;
	while(scanf("%d %d",&N,&M)){
		if(N==0&&M==0)
		break;
		map<int, int> mp;
		for(int i=0;i<N;i++){
			scanf("%d %d",&dt,&vt);
			auto itr=mp.find(dt);
			if(itr!=mp.end()){
				if(itr->second < vt)
				mp[dt]=vt;
			}
			else{
				mp[dt]=vt;
			}
		}
		int sum=0;
		for(auto itr=mp.begin();itr!=mp.end();itr++){
			sum+=itr->second;
		}
		printf("%d\n",sum);
	}
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,Q;
const int MN = 100000;
int d[MN];
int main(){
	cin>>N>>Q;
	rep(i,Q){
		int x,y;
		cin>>x>>y;
		x--,y--;
		d[x]++,d[y]++;
	}
	rep(i,N) if(d[i]%2==1){
		puts("NO");
		return 0;
	}
	puts("YES");
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int s,w;
	cin>>s>>w;
	cout<<(s<=w?"unsafe":"safe")<<endl;
}


Measured memory_bytes: 3652
import sys
#import numpy as np
import math
from fractions import Fraction
import itertools

input=sys.stdin.readline

n=int(input())
s=list(map(int,input().split()))

d=[0]*(n+1)
d[1]=abs(s[0])
for i in range(2,n+1):
    d[i]=d[i-1]+abs(s[i-1]-s[i-2])
ans=abs(s[n-1])+d[n]-d[2]+d[0]+abs(s[1])
print(ans)
for i in range(1,n-1):
    ans=abs(s[n-1])+d[i]+d[n]-d[i+2]+abs(s[i+1]-s[i-1])
    print(ans)
ans=d[n-1]+abs(s[n-2])
print(ans)

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

int digit_sum(int n)
{
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

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

    int sum = 0;
    for (int i = 0; i <= n; i++) {
        int s = digit_sum(i);
        if (a <= s && s <= b) {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  long int  s, c, t=0;

  scanf("%ld %ld", &s, &c);

  if( s*2 <= c){
      t = s;
      c -= t * 2;
      t += c / 4;
  }else{
      t = c / 2;
      s -= t;
  }

  printf("%ld", t);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;
ll inf=1LL<<50;

struct edge{ll from,to,cost;};

edge es[2010]; //MAX_E
ll d[1010]; //S→Gのcost //MAX_V
ll N,M;

//最短経路を求める
void bellman_ford(int s){
	for(int i=0;i<N;i++) d[i]=inf;
	d[s]=0;
	for(int i=0;i<N;i++){
		bool update=false;
		for(int j=0;j<M;j++){
			edge e=es[j];
			if(d[e.from]!=inf && d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
                if(i==N-1) return;
			}
		}
	}
    return;
}

//ゴールまで負の閉路に巻き込まれずに到達可能か　bellman_fordの直後に使用
bool negative[1010]; 
void bellman_ford_sec(){
	for(int i=0;i<N;i++) negative[i]=true;
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			edge e=es[j];
			if(d[e.from]!=inf && d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				negative[e.to]=false; //到達不能
			}
		}
	}
    return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M;
	for(int i=0;i<M;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		x--; y--; z=-z;
		es[i].from=x;
		es[i].to=y;
		es[i].cost=z;
	}
	bellman_ford(0);
	bellman_ford_sec();
	if(!negative[N-1]){
		cout<<"inf"<<endl;
	}else{
		cout<<-d[N-1]<<endl;
	}
	return 0;
}


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

using namespace std;

int main() {
    // g++ -Wall -Wextra -O2 -std=c++17 helloworld.cpp
    int x;

    cin >> x;

    vector<bool> sieve(x);
    vector<int> v {100, 101, 102, 103, 104, 105};

    sieve[0] = true;

    for(int i = 0; i < 6; ++i) {
        int val = v[i];

        for (int j = 0; j <= x - val; ++j) {
            if (sieve[j]) {
                sieve[j + val] = true;
            }
        }
    }

    if (sieve[x]) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

void solve(long long N, vector<long long> A){
	LL ans=0;
	for(int i=1; i<N; ++i) {
		if (A[i-1]%2!=0 && A[i]>0) {
			--A[i-1];
			--A[i];
			++ans;
		}
	}	
	for(auto i:A) {
		ans+=i/2;
	}
	cout<<ans<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



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

#define pb push_back
#define fi first
#define se second


using namespace std;


vector<int> v;

int main()
{
	unsigned long long n;
	cin>>n;


	if(n%2!=0)
	{
		cout<<0<<endl;
		return 0;
	}

	n = n/2;

	long long pot = 5;

	long long result = 0;

	while(pot <= n)
	{
		result += n/pot;
		pot *=5;
	}

	cout<<result<<endl;


	return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main() {
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;
    cin>>s;
    int l=0;
    int n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]=='0') l++;
    }
    cout<<2*min(l,n-l);
}

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

int main() {
  int N, cnt=0;
  cin >> N;
  int A[N];
  bool flag=false;
  
  for(int i=0; i<N; i++)
    cin >> A[i];
  
  while(true){
    for(int i=0; i<N; i++){
      if(A[i] % 2 != 0){
        flag=true;
        break;
      }
      A[i] /= 2;
    }
    if(flag==true)
      break;
    else
      cnt++;
  }
  
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
odd_steps = ['R', 'U', 'D']
even_steps = ['L', 'U', 'D']

S = input()

flg = True
for i in range(len(S)):
    if (i + 1) % 2 == 1 and S[i] not in odd_steps:
        flg = False
        break

    if (i + 1) % 2 == 0 and S[i] not in even_steps:
        flg = False
        break

print('Yes') if flg else print('No')


Measured memory_bytes: 38492
from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = input()

t = int(n[-1])
if t == 3:
    print("bon")
elif t == 0 or t == 1 or t == 6 or t == 8:
    print("pon")
else:
    print("hon")

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 100005  //check the limits, man
int main()
{
    int n,m,q,i,j,a,b,k;
    in2(n,m);
    in(q);
    vii vp;
    while(q--)
    {
        in2(a,b);
        lp(i,a-2,a+1)
        {
            lp(j,b-2,b+1)
            {
                if(i>0 && j>0 && i+2<=n && j+2<=m)
                    vp.pb(i,j);
            }
        }
    }
    sort(all(vp));
    vi v(10,0);
    i=0;
    ll ans;
    ans=n-2,ans*=(m-2);
    n=vp.size();
    while(i<n)
    {
        j=i,k=0;
        while(j<n && vp[i]==vp[j])
            j++;
        k=j-i;
        v[k]++;
        i=j;
    }
    k=0;
    lp(i,1,10)
        k+=v[i];
    llout(ans-k);
    lp(i,1,10)
        out(v[i]);
}


Measured memory_bytes: 10476
import java.util.Scanner;

public class Main {
	int w, h;
	int[][] f;

	void dfs(int x, int y) {
		if (x < 0 || w <= x || y < 0 || h <= y) {
			return ;
		}
		if (f[y][x] == 0) {
			return;
		}
		f[y][x] = 0;
		for (int i = -1; i <= 1; i++) {
			for (int j = -1; j <= 1; j++) {
				int nx = x + i;
				int ny = y + j;
				dfs(nx, ny);
			}
		}
	}

	public void mapDebug(int[][] a) {
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
	}


	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			w = sc.nextInt();
			h = sc.nextInt();
			if ((w | h) == 0) {
				break;
			}
			f = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					f[i][j] = sc.nextInt();
				}
			}

			int ans = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (f[i][j] == 1) {
						//					System.out.println("(" + j + ", " + i + ")");
						dfs(j, i);
						ans++;
						//					mapDebug(f);
					}
				}
			}
			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 43296
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    set<pl> s;
    forn(n) {
        cin >> v[i];
        s.insert({v[i], i});
    }
    while (!s.empty()) {
        auto temp = *(s.begin());
        cout << temp.ss + 1 << " ";
        s.erase(temp);
    }
    cout << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 7808
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<fstream>

#define rep(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005
#define pb push_back
#define MP make_pair

using namespace std;

int main(){
	lint x;
	cin>>x;
	lint a=x%11;
	lint b=(x-a)/11;
	b=b*2;
	if(a>6)b+=2;
	else if(a!=0) b++;
	cout<<b;
return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

void _main() {
  ll abc[3];
  rep(i, 0, 3) cin >> abc[i];

  bool exist_even = false;
  rep(i, 0, 3) if (abc[i] % 2 == 0) exist_even = true;
  if (exist_even) {
    cout << 0 << "\n";
    return;
  }

  sort(abc, abc + 3);
  cout << (abc[0] * abc[1]) << "\n";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import itertools
a = int(input())
b = int(input())
c = int(input())
k = 3*c
f = [
        [             a,      b,     k-a-b ],
        [ 2*k-2*a-b-2*c,      c, 2*a+b+c-k ],
        [     a+b+2*c-k,  k-b-c,     k-a-c ] ]
assert f[0][2] + f[1][1] + f[2][0] == k
for y in range(3):
    print(*f[y])


Measured memory_bytes: 3188
let N = Int(readLine()!)!
var ans = 0
if N >= 105 {
    for i in 105.stride(to: N+1, by: 2) {
        var cnt = 0
        for j in 3..<i {
            if i % j == 0 {
                cnt += 1
            }
        }
        if cnt == 6 {
            ans += 1
        }
    }
}
print(ans)


Measured memory_bytes: 768
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	s := scanString(sc)
	k := scanInt(sc)
	for i := range s {
		c := int(s[i] - '0')
		if c > 1 {
			return c
		}
		if k-1 == i {
			return c
		}
	}
	return -1
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
n = gets.chomp
t, a = gets.split.map(&:to_i)
hs = gets.split.map(&:to_i)
ret = nil
ret_h = nil
hs.each_with_index do |h, i|
  unless ret
    ret = i
    ret_h = t - (h * 0.006)
  else
    tmp_h = t - (h * 0.006)
    if (ret_h - a).abs > (tmp_h - a).abs
      ret = i
      ret_h = tmp_h
    end
  end
end
puts (ret + 1)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long 
const int N=1e5+5;
int n,cou=0;
string s;


int32_t main(){
	IOS;
	
	//code
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++){
		if(s.substr(i,3)=="ABC")
			cou++;
	}
	cout<<cou<<endl;
	//code
	
	return 0;

}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from collections import defaultdict



N,A = map(int, input().split())
Xn = list(map(int, input().split()))

dp = defaultdict(lambda:0)
for i in range(N):
  x = Xn[i]-A
  keys = list(dp.items())
  if x > 0:
    keys = sorted(keys,reverse=True)
  else:
    keys = sorted(keys)
  for k,t in keys:
    dp[k+x] += dp[k]
  dp[x] += 1

print(dp[0])


Measured memory_bytes: 3572