akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
int cnt[101];
int main()
{
    int N;
    cin >> N;
    int maximum = -1;
    for(int i = 0 ; i < N; i++)
    {
        int num;
        cin >> num;
        cnt[num]++;
        maximum = max(maximum, num);
    }
    /*for(int i = 0; i < 10; i++)
    {
        cout << cnt[i] << " ";
    }
    cout << endl;*/
    for(int i = 0; i < (maximum+1)/2; i++)
    {
        if(cnt[i] > 0)
        {
            cout << "Impossible" << endl;
            return 0;
        }
    }
    if(maximum%2 == 0)
    {
        if(cnt[maximum/2] > 1)
        {
            cout << "Impossible" << endl;
        } else {
            for(int i = maximum/2; i < maximum ; i++)
            {
                if(cnt[i] == 0)
                {
                    cout << "Impossible";
                    return 0;
                }
            }
            cout << "Possible" << endl;
        }
    } else
    {
        if(cnt[maximum/2 + 1] > 2)
        {
            cout << "Impossible" << endl;
        } else {
            for(int i = maximum/2+1; i < maximum ; i++)
            {
                if(cnt[i] == 0)
                {
                    cout << "Impossible";
                    return 0;
                }
            }
            cout << "Possible" << endl;
        }
    }
}


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

int main()
{


    string s;
    ll i;

    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//累乗チェック
bool f(int x){
    for(int i = 2; i * i <= x; i++){
        int a = i * i;
        while(a <= x){
            if (a == x) return true;
            a *= i;
        }
    }
    return false;
}

 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    int X; cin >> X;
    for(int i = X; i > 1; i--){
        if (f(i)) {
            cout << i << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}


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

int main() {
	int n; cin >> n;
    vector<int> sub(n);
    REP(i, n-1) {
    	int tmp; cin >> tmp;
        ++sub[tmp-1];
    }
    REP(i, n) cout << sub[i] << endl;
    
    return 0;
}


Measured memory_bytes: 3964
from sys import stdin
N = int(input())
L =[stdin.readline().split() for _ in range(N)]
for n in range(N):
  L[n][1] = int(L[n][1])
for n in range(N):
  L[n].append(n)
L = sorted(L, reverse=True, key=lambda x: x[1])
L = sorted(L, reverse=False, key=lambda x: x[0])
for n in range(N):
  print(L[n][2]+1)


Measured memory_bytes: 9128
package main

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

func main() {
	s, t := readString(), readString()
	if s == t[:len(s)] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1756
#define _XOPEN_SOURCE 500
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n - 1); i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

template <class T>
struct ModInt {
    T x;
    ModInt(T x = 0) : x((x + mod) % mod) {}
    ModInt &operator+=(const ModInt a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator+(const ModInt a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator-(const ModInt a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator*(const ModInt a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(T t) const {
        if (!t) return 1;
        ModInt a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(mod - 2);
    }
    ModInt &operator/=(const ModInt a) {
        return (*this) *= a.inv();
    }
    ModInt operator/(const ModInt a) const {
        ModInt res(*this);
        return res /= a;
    }
};
using mint = ModInt<long long>;

int n, k;
mint sum[200005];
void solve() {
    cin >> n >> k;
    rep(i, n + 1) sum[i + 1] = sum[i] + i + 1;
    mint ans = 0;
    loops(i, k, n + 1) {
        auto ma = sum[n] - sum[max(0, n - i)];
        auto mi = sum[i - 1];
        ans += ma - mi + 1;
    }
    cout << ans.x << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 5172
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int res=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            int rest=n-r*i-g*j;
            if(rest<0) continue;
            if(rest%b==0) res++;
        }
    }
    cout<<res<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '.'){
            bool flag = true;
            string t = s;
            t[i] = 'W';
            int l = i;
            while(l >= 0 and t[l] == 'W')l--;
            show(l);
            int r = i;
            while(r < n and t[r] == 'W')r++;
            show(r);
            if(l >= 0 and t[l] == 'B' and r < n and t[r] == 'B')continue;
            if(i == 5)show(l,r);
            int temp = 0;
            while(l >= 0 and t[l] == 'B')l--,temp++;
            if(l >= 0 and t[l] == 'W')ans = max(temp , ans);
            int temp2 = 0;
            while(r < n and t[r] == 'B')r++, temp2++;
            if(r < n and t[r] == 'W')ans = max(temp2, ans);
            show(i,l,r,temp,temp2,ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3196
h, w = map(int, input().split())
n = int(input())
temp = list(map(int, input().split()))
l = []
for i in range(n):
  l += [i+1]*(temp[i])
l = sorted(l)
maze = []
m = 0
for i in range(h):
  maze.append([0]*w)

for i in range(h):
  if i % 2 == 0:
    for j in range(w):
      maze[i][j] = l[m]
      m += 1
  elif not i % 2 == 0:
    for k in range(w-1, -1, -1):
      maze[i][k] = l[m]
      m += 1

for i in maze:
  print(' '.join(map(str, i)))

Measured memory_bytes: 3572
N = int(input())
Pn=list(map(int,input().split()[:N]))

def judge(x,y,z):
    if x < y < z or z< y< x:
        return 1
    else:
        return 0

ret=0
for i in range(1,N-1):
    ret+=judge(Pn[i-1],Pn[i],Pn[i+1])
print(ret)


Measured memory_bytes: 2940
#include <stdio.h>
int main(){
	long k,i,a[51];
	scanf("%ld",&k);
	printf("50\n");
	for(i=0;i<50;i++)
	a[i]=49+(k/50);
	for(i=0;i<k%50;i++)
	a[i]+=50-(k%50-1);
	for(i=k%50;i<50;i++)
	a[i]-=k%50;
	for(i=0;i<50;i++)
	printf("%ld ",a[i]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv vector<vector<int> >
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


ll kaijou(ll x){
  ll sum=1;
  for(int i=1;i<=x;++i){
    sum*=i;
  }

return sum;
}
int main(){
int  n;cin>>n;
vll a(5);
rep(i,n){
  string s;cin>>s;
  char sin=s[0];
  if(sin=='M')a.at(0)++;
  else if(sin=='A')a.at(1)++;
  else if(sin=='R')a.at(2)++;
  else if(sin=='C')a.at(3)++;
  else if (sin=='H')a.at(4)++;
}
ll x=0;
ll y=0;
rep(i,5){
  if(a.at(i)!=0)x++;
  if(a.at(i)>1)y++;
}

if(x<3){
  cout<<0<<endl;
  return 0;
}
ll ans=0;
rep(i,3){
  for(int j=i+1;j<4;j++){
    for(int k=j+1;k<5;k++){
        if(a.at(i)==0||a.at(j)==0||a.at(k)==0)continue;
        ans+=a.at(i)*a.at(j)*a.at(k);

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

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

void sieve( vector<unsigned>& primes, unsigned n )
{
  if(n<2){ 
    return; 
  }
  primes.push_back(2);
  if(n<3){ 
    return; 
  }

  const unsigned lastIdx = (n-3)/2;
  vector<char> flag(lastIdx+1,1);
  for(unsigned i=0;i<=lastIdx;i++){
    if(flag[i]){
      unsigned p=2*i+3;
      primes.push_back(p);
      if(p<=n/p){
        for(unsigned j=i+p;j<=lastIdx;j+=p){
          flag[j]=0;
        }
      }
    }
  }
}

int main() {
  int k;
  cin>>k;
  vector<int> ans={};
  const unsigned n = 55555;
  vector<unsigned> primes;
  sieve(primes,n);
  vector<unsigned>::const_iterator it = primes.begin();
  while (it!=primes.end()){
    int p=*it;
    if(p%5==1) ans.push_back(p);
    it++;
  }

  for(int i=0;i<k;i++){
  	cout<<ans[i]<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int tHP = sc.nextInt();
		int tAt = sc.nextInt();
		int aHP = sc.nextInt();
		int aAt = sc.nextInt();


		while(true){
			aHP -= tAt;
			tHP -= aAt;
			if(aHP <= 0){
				System.out.print("Yes");
				return;
			}
			if(tHP <= 0){
				System.out.print("No");
				return;
			}
		}

	}
}


Measured memory_bytes: 27028
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int N;
pair<int, int> A[100000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i].first;
		A[i].second = i;
	}

	sort(A, A + N);


	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			if (A[i].second % 2 == 1) {
				ans += 1;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <stdint.h>
#include <string>

using namespace std;

int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;

  int count = 0;
  char prev = '\0';
  for (char c : S) {
    if (c == prev)
      continue;
    prev = c;
    ++count;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 512
natu = input().split()
n = int(natu[0])
m = int(natu[1])

work = input().split()
work = [int(n) for n in work]

summary = sum(work)

if (n < summary):
    print(-1)
elif (n == summary):
    print(0)
else:
    print(n-summary)


Measured memory_bytes: 10056
#include <iostream>
#include<vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <stdexcept>
using namespace std;
int main(void)
{
	int A, B, C;
	cin >> A>>B>>C;

	if (A * B * C == 175)
	{
		cout << "YES" << endl;
	}

	else
	{
		cout << "NO" << endl;
	}

	
	
}

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

const int bB = 8;
const int B = 1 << bB;

int up(int x) {
	return (x + (1 << bB) - 1) >> bB;
}

int down(int x) {
	return x >> bB;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	const int H = up(n);
	vector<int> bv(H, 0), v(n, 0);
	while (q--) {
		int com;
		cin >> com;
		if (com) {
			int x;
			cin >> x; x--;
			printf("%d\n", bv[down(x)] + v[x]);
		}
		else {
			int x, y, val;
			cin >> x >> y >> val; x--;
			for (int i = x; i < y && i < (up(x) << bB); i++) {
				v[i] += val;
			}
			if (up(x) <= down(y)) {
				for (int i = up(x); i < down(y); i++) {
					bv[i] += val;
				}
				for (int i = down(y) << bB; i < y; i++) {
					v[i] += val;
				}
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005

int N,L;
int t[MAX];

void solve(){
  int maxm=1;
  for(int i=1;i<=N;i++)
    if(t[i]>t[maxm])maxm=i;

  if(t[maxm]>=L){
    printf("Possible\n");
    for(int i=1;i<maxm;i++)
      printf("%d\n",i);
    
    for(int i=N-1;i>=maxm;i--)
      printf("%d\n",i);
    
    return;
  }

  maxm=1;
  for(int i=1;i+1<=N;i++){
    if(t[i]+t[i+1] > t[maxm]+t[maxm+1])maxm=i;
  }

  if(t[maxm]+t[maxm+1]>=L){
    printf("Possible\n");
    for(int i=1;i<maxm;i++)
      printf("%d\n",i);
    
    for(int i=N-1;i>=maxm;i--)
      printf("%d\n",i);
    
    return;
  }

  printf("Impossible\n");
}

int main(){
  scanf("%d %d",&N,&L);
  for(int i=1;i<=N;i++)scanf("%d",&t[i]);
  solve();
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n, k; cin >> n >> k;
    vector<int> cnt(n, 0);

    for(int i = 0; i < n; i++) {
        int sum = i + 1;
        while(sum < k) {
            sum *= 2;
            cnt[i]++;
        }
    }

    double ans = 0;
    for(int i = 0; i < n; i++) {
        ans += (1.0 / n) * pow(0.5, cnt[i]);
    }

    cout << fixed;
    cout << setprecision(13) << ans << endl;
}


Measured memory_bytes: 1024
import sys
def input(): return sys.stdin.readline().strip()

def first_bit_of(n):
    """
    nの先頭ビットが下から何桁目かを出力する。（最下位を0桁目として）
    """
    if n == 0: return 0
    if n > 0:
        idx = 0
        while n > 0:
            n -= pow(4, idx)
            idx += 1
        return 2 * (idx - 1)
    if n < 0:
        idx = 0
        while n < 0:
            n += pow(2, 2 * idx + 1)
            idx += 1
        return 2 * idx - 1
        

def main():
    N = int(input())
    if N == 0:
        print(0)
        return
    first_place = first_bit_of(N)
    #print("first_bit={}".format(first_place))
    ans = [0] * (first_place + 1)
    ans[0] = 1
    N -= pow(-2, first_place)

    while N != 0:
        place = first_bit_of(N)
        #print("first_bit_of({})={}".format(N, place))
        ans[first_place - place] = 1
        N -= pow(-2, place)
    print("".join(map(str, ans)))
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
chomp (my @v = split / /, <STDIN>);
@v = sort { $a <=> $b } @v;
my $ans = ($v[0] + $v[1]) / 2;
for my $i (2..$n-1) {
  $ans += $v[$i];
  $ans /= 2;
}
say $ans;

Measured memory_bytes: 896
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <cstdio>
#include <algorithm>

#define EPS (1e-5)

using namespace std;


class Point{
public:
  double x, y;
  Point ( double x =0, double y=0): x(x), y(y){}
  Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
  Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
  Point operator * ( double a ){ return Point(a*x, a*y); }
  double abs() { return sqrt(norm());}
  double norm() { return x*x + y*y; }
  bool operator < ( const Point &p ) const{
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == ( const Point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};
Point p[100];
int n;

vector<Point> cross(Point a, Point b){
  vector<Point> res;
  if(fabs((b-a).abs()-2.0)<EPS){
    Point c = a + b;
    res.push_back( Point(c.x/2.0, c.y/2.0) );
  }else if((b-a).abs()<2.0){
    Point ab = b - a;
    Point center = a + Point(ab.x/2.0,ab.y/2.0);
    Point un1 = Point(-ab.y/ab.abs(), ab.x/ab.abs());
    Point un2 = Point(ab.y/ab.abs(), -ab.x/ab.abs());
    double dist = sqrt(1.0 - pow(ab.abs() /2.0, 2.0));
    Point c1 = center + un1 * dist;
    Point c2 = center + un2 * dist;
    res.push_back(c1);
    res.push_back(c2);
  }
  return res;
}

int solve(){
  int ans=1;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      vector<Point> c=cross(p[i], p[j]);
      if(c.empty()) continue;
      int cnt1=2, cnt2=2;
      for(int k=0;k<n;k++){
	if(i==k || j==k) continue;
	if((c[0]-p[k]).abs()-1.0<EPS) cnt1++;
	if(c.size()==2 && (c[1]-p[k]).abs()-1.0<EPS) cnt2++;
      }
      ans=max(ans, max(cnt1, cnt2));
    }
  }
  return ans;
}
main(){
  while(1){
    cin >> n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin >> p[i].x;
      getchar();
      cin >> p[i].y;
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
int main() {
    int a,b,c,x,y,p=0;
    std::cin>>a>>b>>c>>x>>y;
    if(a+b>=2*c){
        p=p+(2*c*std::min(x,y));
    } else{
        p=p+((a+b)*std::min(x,y));
    }
    if(x!=y){
        if(x>y){
            if(a>=2*c){
                p=p+((x-y)*2*c);
            }else{
                p=p+((x-y)*a);
            }
        } else{
            if(b>=2*c){
                p=p+((y-x)*2*c);
            } else{
                p=p+((y-x)*b);
            }
        }
    }
    std::cout<<p;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	int64 X = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		X += a[i];
	}
	int64 ans = INFL;
	int64 x1 = 0;
	for (int i = 0; i < n; ++i) {
		x1 += a[i];
		if (i + 1 < n) ans = min(ans, abs(X - (2 * x1)));
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
 
int main(void){
	long long a,b,r,x,tmp;
	char str[100];
    
	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		sscanf(str,"%lld %lld",&a,&b);
	x=a*b;
	if(a<b){
		tmp=a;
		a=b;
		b=tmp;
	}
	r=a%b;
	while(r!=0){
		a=b;
		b=r;
		r=a%b;
	}

    printf("%lld %lld\n",b,x/b);
    }
    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
 
int main() {
    ll h, w;
    cin >> h >> w;

    vector<string> board(h);
    rep(i, h) {
        cin >> board[i];
    }

    rep(x, h) {
        rep(y, w) {
            if(board[x][y] == '#') {
                bool ok = false;
                rep(dir, 4) {
                    ll nx = x + dx[dir];
                    ll ny = y + dy[dir];
                    if(nx < 0 || h <= nx || ny < 0 || w <= ny) {
                        continue;
                    }
                    if(board[nx][ny] == '.') {
                        continue;
                    }
                    ok = true;
                }
                if(ok == false) {
                    out("No");
                    re0;
                }
            }
        }
    }
    
    out("Yes");
    re0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a;
	int b;
	int c;
	cin >> a;
	cin >> b;
	cin >> c;
	int dummy;
	
	if (a > b)
	{
		dummy = a;
		a = b;
		b = dummy;

	}
	

	if (a > c)
	{
		dummy = a;
		a = c;
		c = dummy;
	}
	
	if (b > c)
	{
		dummy = b;
		b = c;
		c = dummy;
	}
	cout << a<< " " << b <<" "<< c << endl;
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	cout << n * (n - 1) / 2 - n / 2 << endl;
	if (n % 2) {
		repl(i, 1, n) {
			repl(j, i + 1, n + 1) {
				if (i + j == n)
					continue;
				else
					cout << i << " " << j << endl;
			}
		}
	} else {
		repl(i, 1, n) {
			repl(j, i + 1, n + 1) {
				if (i + j == 1 + n)
					continue;
				else
					cout << i << " " << j << endl;
			}
		}
	}

	return 0;
}

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

nums_753 = []
list_357 = ["3","5","7"]
upper_limit = N
def create_nums_of_357(s):
#     print(s)
    for i in list_357:
        news = s + i
        if int(news) > upper_limit:
            continue
        save_bool = True
        for j in list_357:
            if j not in news:
                save_bool=False
                break
        if save_bool:
            nums_753.append(news)
        create_nums_of_357(news)


create_nums_of_357("")

print(len(nums_753))

Measured memory_bytes: 46268
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    string march = "MARCH";
    string s;
    ll count[5] = {};
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        cin >> s;
        for(int j = 0 ; j < 5 ; j++){
            if(march[j] == s[0]){
                count[j]++;
                break;
            }
        }
    }
    long long ans = 0;
    for(int i = 0 ; i < 5 ; i++){
        for(int j = i + 1 ; j < 5 ; j++){
            for(int k = j + 1 ; k < 5 ; k++){
                ans += count[i] * count[j] * count[k];
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3584
//ProblemB

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemB

#define MAXNUM 30000

class Solve {
private:

	void solve() {
		int n;
		cin >> n;

		if (n == 3) {
			cout << "2 5 63" << endl;
			return;
		}

		vector<int> rst{ 2, 4, 3, 9 };
		rst.reserve(n);

		int m2 = 4;
		int m3 = 5;
		int m6 = 1;
		n -= 4;

		while (n > 0) {
			if (n == 1 || (2 * m2 > MAXNUM && 3 * m3 > MAXNUM)) {
				rst.push_back(m6 * 6);
				m6++;
				n--;
			}
			else if (2 * m2 <= MAXNUM) {
				rst.push_back(m2 * 2);
				rst.push_back(m2 * 2 + 2);
				m2 += 3;
				n -= 2;
			}
			else if (3 * m3 <= MAXNUM) {
				rst.push_back(m3 * 3); m3 += 2;
				rst.push_back(m3 * 3); m3 += 2;
				n -= 2;
			}
			else {
				throw;
			}
		}

		for (size_t i = 0; i < rst.size(); i++) {
			if (i != 0) cout << ' ';
			cout << rst[i];
		}
		cout << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL<<60;

int main()
{
  string s;
  cin >> s;
  int len = 1;
  for (int i = 1; i < s.size(); i++) {
    if (s[i - 1] != s[i])
      len++;
  }
  cout << len - 1 << endl;
  return 0;
}

Measured memory_bytes: 512
N,M=map(int,input().split())
A=list(map(int,input().split()))
L=[]
for i in range(M):
  a,b=map(int,input().split())
  L.append([a,b])
A.sort()
L.sort(key=lambda x:x[1],reverse=True)
K=[]
i=0
while len(K)<=N:
  K+=[L[i][1]]*L[i][0]
  i+=1
  if i==M:
    break
K+=[0]*N
j=0
ans=0

while A[j]<K[j]:
  j+=1
  if j==N:
    break
print(sum(K[:j])+sum(A[j:]))

Measured memory_bytes: 88684
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
ll ans[100000];
int color=0;
vector<vector<pair<int,int> > > v(100000);
vector<bool> used(100000,false);
void dfs(int v1,int prev){
    int k=0;
    used[v1]=true;
    for(int i=0;i<v[v1].size();i++){
        if(used[v[v1][i].first])continue;
        if(k==prev){
            k++;
            ans[v[v1][i].second]=k;
            color=max(color,k);
            dfs(v[v1][i].first,k);
            k++;
        }
        else{
            ans[v[v1][i].second]=k;
            color=max(color,k);
            dfs(v[v1][i].first,k);
            k++;
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;

    for (int i = 0; i < n-1; i++)
    {
        int tempa, tempb;
        cin >> tempa>>tempb;
        tempa--;
        tempb--;
        v[tempa].push_back(make_pair(tempb,i));
        v[tempb].push_back(make_pair(tempa,i));
        ans[i]=0;
    }
    dfs(0,-1);
    cout<<color+1<<"\n";
    for(int i=0;i<n-1;i++){
        cout<<ans[i]+1<<"\n";
    }
}



Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(c, i, n) for (int i = c; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    int ans = 0;
    cin >> N;
    rep(1, i, N + 1)
    {
        if (((0 < i) && (i < 10)) || ((99 < i) && (i < 1000)) || ((9999 < i) && (i < 100000)))
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
    int n, m, ch;
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        cin >> ch;
        n -= ch;
    }
    cout << max(-1, n) << endl;
    return 0;

}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vvi a(h,vi(w));
    //vs data(h);
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w){
            a.at(i).at(j) = s.at(j) - '0';
        }
    }
    vvi wsum(h,vi(w+1,0));
    /*rep(j,w){
        rep(i,h){
            sum.at(i+1).at(j) = sum.at(i).at(j) + a.at(i).at(j);
        }
    }*/
    rep(i,h){
        rep(j,w){
            wsum.at(i).at(j+1) = wsum.at(i).at(j) + a.at(i).at(j);
        }
    }
    vvi sum(h+1,vi(w+1,0));
    rep(j,w+1){
        rep(i,h){
            sum.at(i+1).at(j) = sum.at(i).at(j) + wsum.at(i).at(j);
        }
    }

    int ans = 1e9;
    for(int ss=0;ss<(1<<h-1);ss++){
        bitset<10> bt(ss);
        int hcut = bt.count();
        bt.set(h-1,1);
        int s = 0;
        vector<pii> st;
        rep(t,h){
            if(bt.test(t)){
                st.push_back(pii(s,t));
                s = t+1;
            }
        }
        int wcut = 0;
        int l = 0;
        bool impo = false;
        for(int r=0;r<w;r++){
            for(pii P : st){
        
                int choco = sum.at(P.second+1).at(r+1) - sum.at(P.second+1).at(l) - sum.at(P.first).at(r+1) + sum.at(P.first).at(l);
              //cout << choco << " " << P.first << " " << P.second << " " << l << " " << r << endl;
                if(choco > k){
                    if(l == r){
                        impo = true;
                        break;
                    }
                    wcut++;
                    l = r;
                }
            }
            if(impo) break;
        }
        if(impo) continue;
        ans = min(ans,wcut+hcut);
        //cout << wcut << " " << hcut << endl;
    }
  /*rep(i,h+1){
    rep(j,w+1){
      cout << sum.at(i).at(j) << " ";
    }
    cout << endl;
  }*/
    cout << ans << endl;
}


Measured memory_bytes: 384
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]

for b in B:
  for i in range(3):
    for j in range(3):
      if A[i][j] == b:
        A[i][j] = 0
f = False
for i in range(3):
  s = 0
  for j in range(3):
    s += A[i][j]
  if s == 0:
    f = True
for i in range(3):
  s = 0
  for j in range(3):
    s += A[j][i]
  if s == 0:
    f = True
s = 0
for i in range(3):
  s += A[i][i]
if s == 0:
  f = True
s = 0
for i in range(3):
  s += A[i][2-i]
if s == 0:
  f = True
print('Yes' if f else 'No')


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  rep2(i, 1, 9) {
    if (n % i == 0) {
      if (n / i <= 9) {
        cout << "Yes" << endl;
        return (0);
      }
    }
  }

  cout << "No" << endl;
  
  return (0);
}

Measured memory_bytes: 3664
#include <iostream>
using namespace std;
const int MAXN=100005;
int n;
int a[MAXN];

int main()

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

	if (ans==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)

using namespace std;

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

	int val = (a + 9) / 10 + (b + 9) / 10 + (c + 9) / 10 + (d + 9) / 10 + (e + 9) / 10;
	val *= 10;

	int rem = 10;
	if (a % 10 != 0) {
		rem = min(rem, a % 10);
	}
	if (b % 10 != 0) {
		rem = min(rem, b % 10);
	}
	if (c % 10 != 0) {
		rem = min(rem, c % 10);
	}
	if (d % 10 != 0) {
		rem = min(rem, d % 10);
	}
	if (e % 10 != 0) {
		rem = min(rem, e % 10);
	}


	val -= 10;
	val += rem;

	cout << val << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>

using namespace std;

int main(void) {
	int N,M;
	cin >> N >> M;
	vector<int> a(N),b(N),c(M),d(M);
	for (int i = 0; i < N; ++i) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < M; ++i) {
		cin >> c[i] >> d[i];
	}

	for (int i = 0; i < N; ++i) {
		int cn = 0;
		long long md = -1;
		for (int j = 0; j < M; ++j) {
			long long dis = abs(a[i]-c[j]) + abs(b[i]-d[j]);
			if (md < 0) {
				md = dis;
				cn = j + 1;
			}
			else if (dis < md) {
				md = dis;
				cn = j + 1;
			}
		}
		cout << cn << endl;
	}
	return 0;
}


Measured memory_bytes: 256
S = input()
def aaa(S):

    Alphabet = "abcdefghijklmnopqrstuvwxyz"

    if len(S) == 26:
        j = 0
        for i in reversed(range(26)):
            while S[i] != Alphabet[j]:
                j = j + 1
                if j == 26:
                    k = 0
                    while S[i] != Alphabet[k]:
                        k += 1
                    while not Alphabet[k] in S[i+1:]:
                        k += 1
                    return S[:i] + Alphabet[k]                
        return -1

    else:
        for i in range(len(Alphabet)):
            j = 0
            while Alphabet[i] != S[j]:
                j += 1
                if j == len(S):
                    return S + Alphabet[i]

print(aaa(S))

Measured memory_bytes: 3064
local List = {}
function List.new ()
    return {first = 0, last = -1}
end

function List.pushleft (list, value)
    local first = list.first - 1
    list.first = first
    list[first] = value
end

function List.pushright (list, value)
    local last = list.last + 1
    list.last = last
    list[last] = value
end

function List.popleft (list)
    local first = list.first
    local value = list[first]
    list[first] = nil
    list.first = first + 1
    return value
end

function List.popright (list)
    local last = list.last
    local value = list[last]
    list[last] = nil
    list.last = last - 1
    return value
end

function List.empty (list)
    return list.first > list.last
end

----------

local n=io.read("n")
local graph={}
for i=1,n do
    graph[i]={}
end
for i=1,n-1 do
    local a,b=io.read("n","n")
    graph[a][b]=i
    graph[b][a]=i
end

local que=List.new()
List.pushright(que,1)
local out={}
local k=0
while not List.empty(que) do
    local a=List.popleft(que)
    local used=0
    for b,i in pairs(graph[a]) do
        if out[-i] then
            used=used+out[-i]
            break
        end
    end
    local deg=0
    local color=1
    for b,i in pairs(graph[a]) do
        if color==used then
            color=color+1
        end
        out[i]=color
        if graph[a][b]>0 then
            graph[a][b]=-graph[a][b]
            graph[b][a]=-graph[b][a]
            List.pushright(que,b)
            color=color+1
        end
        deg=deg+1
    end
    k=math.max(deg,k)
end

print(k)
for i=1,n-1 do
    print(out[i])
end

Measured memory_bytes: 20872
import itertools


def t(n, p, q):
    np = tuple(map(int, p.split()))
    nq = tuple(map(int, q.split()))
    a = list(itertools.permutations(range(1, n + 1), n))
    return abs(a.index(np) - a.index(nq))


if __name__ == '__main__':
    n = int(input())
    p = input()
    q = input()
    print(t(n, p, q))


Measured memory_bytes: 8052
#include<iostream>
#define ll long long int
using namespace std;

int main()
{
   ll n;
  cin>>n;
  int r = (n%10);
  if(r == 2 || r == 4 || r == 5 || r == 7 || r == 9)
   cout << "hon" << endl;
  else if(r == 0 || r == 1 || r == 6 || r == 8)
    cout << "pon" << endl;
  else 
    cout << "bon" << endl;
  return 0;
}
  

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

int main() {
int K;
  cin >> K;
  if(K >= 1 && K <= 32){
vector<int> vec;
  
  vec = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
   cout << vec.at(K-1) << endl;
}
}

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

int main()
{
    int b,x,t,n=0,i;
    cin>>x>>b>>t;
    for(i=1;i*x<=(t+0.5);i++)
    {
        n=b*i;
    }
    cout<<n<<endl;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, m;
	cin >> n >> m;

	out((n - 1) * (m - 1));

	return 0;
}

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


int num(int n){
    int t=0;
    while(n>=10){
        t+=n%10;
        n/=10;
    }

    t+=n;

    return t;
}



int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！
    int N;
    cin>>N;
    int A,B,i;
    int a,b,temp;
    int min=N;
    for(i=1;i<(N/2)+1;i++){
        A=i;
        B=N-i;
        a = num(A);
        b = num(B);
        temp = a+b;
        if(temp<min){
            min = temp;
        }

    }

    cout << min << endl;

    return 0;
}


//3 人は同時に、他の 2 人の持っている整数の和を求める。
//その後、自分の持っている整数を求めた整数で置き換える。

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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

void solve(int N, int D, vector<vector<int>>& X) {
    int answer = 0;
    REP(i,0,N) {
        REP(j,i+1,N) {
            ll distance = 0;
            REP(k,0,D) distance += pow(abs(X[i][k] - X[j][k]), 2);
            double dis = pow((double)distance, 0.5);
            if (dis - (ll)dis == 0) answer++;
        }
    }

	stringstream ss;
	ss << answer;
	cout << ss.str() << '\n';

    return;
}

signed main() {
    int N, D;
    cin >> N >> D;
    
    vector<vector<int>> X(N, vector<int>(D));
    REP(i,0,N) REP(j,0,D) cin >> X[i][j];

    solve(N, D, X);
    
    return 0;
}



Measured memory_bytes: 512