akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
int gcd(int a, int b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
int ans = 0;
int s[10][10];
int k[10];
int p[10];
void bit(int m, int n,int d) {
	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			bool w = true;
			rep(i, 0,d ) {
				int x = 0;
				rep(j, 0, k[i])if (now[s[i][j] - 1] == '1')x++;
				if (x%2 != p[i])w = false;
			}
			if(w)ans += 1;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}
;
int main() {
	string s;
	cin >> s;
	int a = 0, b = 0;
	rep(i, 0, s.size()) {
		if (s[i] == '0')a++;
		else b++;
	}
	cout << 2*min(a,b) << endl;
	return 0;

}

Measured memory_bytes: 512
N,M,K = list(map(int,input().split()))
MOD = 998244353
 
fac = [1] * (N+1)
inv = [1] * (N+1)
ifac = [1] * (N+1)
for i in range(2,N+1):
    fac[i]=(fac[i-1]*i)%MOD
    inv[i]= -(inv[MOD%i]*(MOD//i))%MOD
    ifac[i]=(ifac[i-1]*inv[i])%MOD
 
cmbarr = [1] * N
for r in range(N-1):
    cmbarr[r+1] = cmbarr[r] * (N - 1 - r) * inv[r + 1] % MOD
 
A = [M*pow(M-1,N-1-i,MOD)*cmbarr[i] % MOD for i in range(K+1)]
print(sum(A) % MOD)

Measured memory_bytes: 48508
def getN():
    return int(input())

def getIntList():
    return list(map(int, input().split()))


def main():

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

    slist = [0] * N

    for i in range(K):
        d = getN()
        A = getIntList()
        for j in range(d):
            slist[A[j]-1] += 1
    
    print(slist.count(0))
    
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 9092
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
struct team{
    char name;
    int win=0,lose=0,draw=0;
    bool operator<(const team &a)const{
        if(win==a.win)return lose<a.lose;
        return win>a.win;
    }
};
int main(){
    while(1){
        int n;
        team teams[10];
        cin>>n;
        if(!n)break;
        for(int i=0;i<n;i++){
            cin>>teams[i].name;
            for(int j=0;j<n-1;j++){
                int a;
                cin>>a;
                if(a==0)teams[i].win++;
                else if(a==1)teams[i].lose++;
                else teams[i].draw++;
            }
        }
        sort(teams,teams+n);
        for(int i=0;i<n;i++){
            cout<<teams[i].name<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2996
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i < 10; i++){
        if(n % i == 0 && n / i < 10){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

string s[100][100];

int main(){
    int h, w;
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> s[i][j];
    
    int a;
    char b;
    rep(i, h) rep(j, w){
        if (s[i][j] == "snuke"){
            a = i + 1;
            b = j + 'A';
        }
    }
    cout << b << a << endl;

    return 0;
}

Measured memory_bytes: 384
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int D = int.Parse(input[1]);

            int[,] X = new int[D,n];
            for(int i = 0;i < n; i++)
            {
            string[] input_X = Console.ReadLine().Split(' ');
            for(int j = 0;j < D;j++)
                X[j,i] = int.Parse(input_X[j]);
            }

            int sum = 0;

            
            for(int i = 0;i < n; i++)
                for(int j = i + 1;j < n; j++)
                {
                    double length = 0;
                    for(int k = 0; k < D;k++)
                        length += (X[k,i] -X[k,j])*(X[k,i] -X[k,j]);
                    
                    length = Math.Sqrt(length);
                    int test = (int)length;
                    if(length == test)
                        sum++;
                }

            Console.WriteLine(sum);
        }
    }

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n),b(n),c(n);
    REP(i,n){
        cin >> a[i] >> b[i] >> c[i];
    }
    ll dp[n+1][3];
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    
    FOR(i,1,n+1){
        dp[i][0]=max(dp[i-1][1]+a[i-1],dp[i-1][2]+a[i-1]);
        dp[i][1]=max(dp[i-1][0]+b[i-1],dp[i-1][2]+b[i-1]);
        dp[i][2]=max(dp[i-1][0]+c[i-1],dp[i-1][1]+c[i-1]);
    }
    cout << max({dp[n][0],dp[n][1],dp[n][2]}) << endl;
    return 0;
}

Measured memory_bytes: 4992
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::cin >> N;
	std::cout << (180 * (N-2)) << "\n";
}


Measured memory_bytes: 512
import sys


def solve():
    readline = sys.stdin.readline
    N = int(readline())
    ABC = (map(int, readline().split()) for _ in range(N))
    x, y, z = 0, 0, 0
    for a, b, c in ABC:
        x, y, z = a + max(y, z), b + max(x, z), c + max(x, y)

    return max(x, y, z)


if __name__ == "__main__":
    answer = solve()
    print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int sum,h[100009];
int n,x,y,s[100009],f[100009];
struct tt{
    int to;
    int next;
    double w;
};
tt r[200009];
inline void add(int a,int b)
{
    r[++sum].to=b;
    r[sum].next=h[a];
    h[a]=sum;
    r[++sum].to=a;
    r[sum].next=h[b];
    h[b]=sum;
}
inline int boo(int x,int fa)
{
    s[x]=1;
    int ans=0;
    for(int i=h[x];i;i=r[i].next)
    {
        if(r[i].to==fa)
          continue;
        if(boo(r[i].to,x))
          return 1;
        if(s[r[i].to])
        {
            ans++;
            s[x]=0;
            if(ans==2)
              return 1;
        }
    }
    return 0;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        add(x,y);
    }
    if(boo(1,0)||s[1])
      printf("First");
    else 
      printf("Second");
      return 0;
}

Measured memory_bytes: 4608
n = gets.to_i
strings = []
n.times do
  strings << gets.strip.chars.reduce(Hash.new{0}){|memo,c| memo[c] += 1;memo}
end

ans = {}
('a'..'z').each {|c| ans[c] = 100}

strings.each do |h|
  ans.each do |k,v|
    if h[k]
      ans[k] = [h[k], v].min
    else
      ans[k] = 0
    end
  end
end

puts ans.map{|k,v|k*v}.sort.join('')

Measured memory_bytes: 1916
import bisect

def solve():
    N = int(input())
    L = [int(i) for i in input().split()]
    L.sort()
    total = 0
    for s in range(N-2):
        for m in range(s+1, N-1):
            l = bisect.bisect_left(L, L[s] + L[m], 0, N)
            if l > m: total += l - m - 1
    print(total)

    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    ll a, b, n; cin >> a >> b >> n;
    cout << a* min(n, b-1) / b << endl;
    system("pause");
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
typedef pair<int, int> pii;


int main() {
	int n;
	cin >> n;
	vector<int> t(n+2);
	vector<int> sum_t(n+3);
	for (int i = 1; i <=n;i++) {
		cin >> t[i];
		sum_t[i+1] +=sum_t[i] + t[i];
	}
	t[n] = 0;
	sum_t[n + 2] = sum_t[n + 1];
	vector<int> v_max(n+2);
	for (int i = 1; i <=n;i++) {
		cin >> v_max[i];
	}
	v_max[n+1] = 0;

	double ans = 0;
	double last_v = 0;
	for (double ti = 0; ti <= sum_t[n + 1]; ti+=0.5) {
		double v = 10000;
		for (int i = 0; i <= n + 1;i++) {
			if (ti < sum_t[i]) {
				v = min(v, v_max[i] + sum_t[i] - ti);
			}
			else if (ti > sum_t[i + 1]) {
				v = min(v, v_max[i] + ti - sum_t[i + 1]);


			}
			else {
				v = min(v, 1.0 * v_max[i]);
			}
			//cout << v << " " << i << endl;
		}

		ans += (v + last_v)*0.25;
		//cout << ans << " " << v << endl;
		last_v = v;

	}
	printf("%lf", ans);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
        using namespace std;
        #include <ext/pb_ds/assoc_container.hpp>
        #include <ext/pb_ds/tree_policy.hpp>
        using namespace __gnu_pbds;
        #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
        #define ll long long
        #define int long long
        #define lb long double
        #define f(i,a,b) for(int i=(a);i<=(b);i++)
        #define fd(i,a,b) for(int i=a;i>=b;i--)
        #define vi vector<int>
        #define mii map<int,int>
        #define pii pair<int,int>
        #define si set<int>
        #define pb push_back
        #define mk make_pair
        #define fi first
        #define se second
        #define fv(i,v) for(auto i=v.begin();i!=v.end();++i)
        #define fdv(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
        #define print(a,n) f(i,1,n) cout<<a[i]<<" "; cout<<endl;
        #define printv(v) for(auto iv: v) cout<<iv<<" "; cout<<endl;
        #define all(v) v.begin(),v.end()
        #define r(a,n) ll a[n+1]; f(i,1,n) cin>>a[i];
        #define pi 3.141592653589793238
        const int mod=1e9+7;
        const int inf=1e18;
        int parent[26];
        int size[26];
        const int MAXN=2*1e5+1;
        int spf[MAXN];
        //vector<bool> vis(MAXN);

        ll power(ll x, unsigned ll y)
        {
            ll res = 1;
            while (y > 0)
            {
                if (y & 1)
                    res = res*x;
                y = y>>1;
                x = x*x;
            }
            return res;
        }

        bool isPrime(int n)
        {
            if (n <= 1)
                return false;
            if (n <= 3)
                return true;

            if (n % 2 == 0 || n % 3 == 0)
                return false;

            for (int i = 5; i * i <= n; i = i + 6)
                if (n % i == 0 || n % (i + 2) == 0)
                    return false;

            return true;
        }
        void sieve()
        {
            spf[1] = 1;
            for (int i=2; i<MAXN; i++)
                spf[i] = i;
            for (int i=4; i<MAXN; i+=2)
                spf[i] = 2;
            for (int i=3; i*i<MAXN; i++)
            {
                if (spf[i] == i)
                {
                    for (int j=i*i; j<MAXN; j+=i)
                        if (spf[j]==j)
                            spf[j] = i;
                }
            }
        }

        int lcm(int a, int b)
        {
            return (a*b)/__gcd(a,b);
        }
        bool sortcol( const vector<int>& v1,
                       const vector<int>& v2 ) {
         return v1.size() >= v2.size();
        }
        signed main()
        {
            ios_base::sync_with_stdio(false);
            cin.tie(0);
            int t=1;
           // cin>>t;
            while(t--)
            {
               int n;
               cin>>n;
               r(a,n);
               int cnt=0;
               for(int i=1;i<=n;i+=2)
               {
                   if(a[i]%2!=0)cnt++;
               }
               cout<<cnt<<endl;
            }
        }


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
  while(x->left != NIL){
    x=x->left;
  }
  return x;
}
 
Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k < u->key){ return treeSearch(u->left,k);}
  else { return treeSearch(u->right,k);}
}
 
Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL) return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
 
Node treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL){ y=z;}
  else {y= treeSuccessor(z);}
  if(y->left!=NIL){ x=y->left;}
  else {x=y->right;}
  if(x!=NIL){ x->parent=y->parent;}
  if(y->parent==NIL){ root=x;}
  else if(y==y->parent->left){ y->parent->left=x;}
  else {y->parent->right=x;}
  if(y!=z){
    z->key=y->key;
  }
    return y;
}
 
 
void insert(int k){
  Node y = NIL, x = root, z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){ x=x->left;}
    else{x=x->right;}
  }
  z->parent=y;
  if(y==NIL){ root = z;}
  else if(z->key < y->key){y->left=z;}
  else y->right=z;
}
 
void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  root=NIL;
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

Measured memory_bytes: 24040
#include <cmath>

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define MOD 1000000007

typedef long long ll;
typedef std::pair< int, int > P;

long K, A, B;

ll solve() {
    if (B == 1 || B - A < 2) return K+1;
    ll biscuits = 1;
    while (K > 0) {
        if ( biscuits < A ) {
            if ( A - biscuits <= K) {
                K = K - (A - biscuits);
                biscuits = A;
            } else {
                biscuits += K;
                K = -1;
            }
        } else {
            if ( K < 2 ) {
                ++biscuits;
                K = -1;
            } else {
                ll mod     = biscuits % A;
                ll divided = biscuits / A;
                biscuits = biscuits + (B-A);
                K -= 2;
            }
        }
    }
    return biscuits;
}

int main() {
    std::cin >> K >> A >> B;
    std::cout << solve() << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{	int n,k,a=0,b=0; cin>>n>>k; a=n/k; if(k%2==0) b=(n+k/2)/k;
	cout<<(ll)a*a*a+(ll)b*b*b;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func check(s string, a, b int) bool {
	// a から b に行けるか
	for i := a; i+1 <= b; i++ {
		if s[i] == '#' && s[i+1] == '#' {
			return false
		}
	}
	return true
}

func check2(s string, b, d int) bool {
	// b が d までのいい感じのところにいれば a は d+1 までいけるか？
	for i := b - 1; i+2 <= d+1; i++ {
		if s[i] == '.' && s[i+1] == '.' && s[i+2] == '.' {
			return true
		}
	}
	return false
}

func main() {
	var n, a, b, c, d int
	var s string
	fmt.Scan(&n, &a, &b, &c, &d, &s)
	a -= 1
	b -= 1
	c -= 1
	d -= 1

	ans := false
	if c < d {
		ans = check(s, a, c) && check(s, b, d)
	} else {
		ans = check(s, b, d) && check(s, a, c) && check2(s, b, d)
	}

	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int n;
int a[100010];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int index;
		cin>>index;
		a[index]=i;
	}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<" ";	
	} 
	cout<<endl;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(void)
{

int a,b;
int i,j;

while(1){
scanf("%d %d",&a,&b);
if(a==0&&b==0){
break;
}
for(i=0;i<a;i++){
for(j=0;j<b;j++){
if(i==0||i==a-1||j==0||j==b-1){
printf("#");
}
else{
printf(".");
}
}
printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 1000
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

 
int main() {
    ll ans = 0;
    ll n, a, b;

    cin >> n >> a >> b;

    cout << min(n * a, b) << endl;

    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}

		int[] dis = new int[N];
		dis[0] = K - A[N-1] + A[0];
		for(int i = 1; i < N; i++) {
			dis[i] = A[i] - A[i-1];
		}

		int maxDis = 0;
		for(int i = 0; i < N; i++) {
			if(dis[i] >= maxDis) {
				maxDis = dis[i];
			}
		}
		System.out.println(K - maxDis);
		sc.close();
	}
}


Measured memory_bytes: 66892
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define MOD 1000000007
 
int main()
{
	fast;
	ll t;
	cin>>t;
  ll mid=t%10;
  if(mid==2||mid==4||mid==5||mid==7||mid==9)
    cout<<"hon"<<endl;
  else if(mid==0||mid==1||mid==6||mid==8)
    cout<<"pon"<<endl;
  else if(mid==3)
    cout<<"bon"<<endl;
}

Measured memory_bytes: 3652
N = int(input())
A = [int(input()) for _ in range(N)]
maxa = max(A)
if A.count(maxa) > 1:
  for _ in range(N):
    print(maxa)
else:
  for i in range(N):
    if A[i] == maxa:
      if i == N - 1:
        print(max(A[: N - 1]))
      else:
        print(max(A[: i] + A[i + 1: ]))
    else:
      print(maxa)

Measured memory_bytes: 15004
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r;
    cin>>r;
    cout<<3*r*r<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
using namespace std; 
 


int main() {
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    if(n==1){
        if(m==1) ans=1;
        else if(m==2) ans=0;
        else{
            ans=m-(2);
        }
    }
    else{
        if(m==1) ans=n-2;
        else ans=(m*n)-2*(n+m-2);
    }
    cout<<ans;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  if(n>=65 && n<=90) cout<<1<<endl;
  else if(n>=97 && n<=122) cout<<2<<endl;
  else cout<<0<<endl;

  return 0;
}


Measured memory_bytes: 3192
#include <stdio.h>
#include <string.h>

int main(void){
  int n;
  scanf("%d", &n);
  
  int m;//辺の数
  int a;//中心に考える頂点
  int b;//a以外のある頂点
  int s;//ペアの和
  int i;
  if(n==3){//n=3の時
    printf("2\n");
    printf("1 3\n");
    printf("2 3\n");
  }else if(n%2==0){//nが偶数の時
    s=1+n;
    m=((n*(n-2))/2);
    printf("%d\n", m);
    for(a=1; a<n; a++){
      b=s-a;
      for(i=1; i<n+1; i++){
        if(i < a){
          continue;
        }else{
          if(i!=a && i!=b){
            printf("%d %d\n", a, i);
          }
        }
      }
    }
  }else if(n%2==1){//nが奇数の時
    s=n;
    m=(((n-1)*(n-1))/2);
    printf("%d\n", m);
    for(a=1; a<n; a++){
      b=s-a;
      for(i=1; i<n; i++){//nが偶数の出力
        if(i < a){
          continue;
        }else{
          if(i!=a && i!=b){
            printf("%d %d\n", a, i);
          }
        }
      }
      printf("%d %d\n", a, n);//nが奇数の出力
    }
  }
  
  return 0;
}

Measured memory_bytes: 1684
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	vector<vi> s;
	vi p(m);
	rep(i, m){
		int k; cin >> k;
		vi v(k);
		rep(j, k) cin >> v[j], v[j]--;
		s.pb(v);
	}
	rep(i, m) cin >> p[i];
	
	int ans = 0;
	rep(i, 1 << n){
		vi cnt(m);
		bool ok = 1;
		rep(j, m) for(int k : s[j]) if(i & 1 << k) cnt[j] ^= 1;
		rep(j, m) ok &= cnt[j] == p[j];
		if(ok) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)

int main(void){
	int r,c;
	while(cin >> r >> c,r){
		int row[10010];
		rep(j,c) row[j]=0;
		rep(i,r)rep(j,c){
			int in;
			cin >> in;
			row[j]|=(in<<i);
		}
		int ans=0,all=(1<<r)-1;
		r--;
		rep(mask,1<<r){
			int cur=0;
			rep(i,c){
				int zero=row[i]^mask;
				int one=zero^all;
				cur+=max(__builtin_popcount(zero),__builtin_popcount(one));
			}
			ans=max(ans,cur);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1200
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long Q = scan.nextLong() * 4;
        long H = scan.nextLong() * 2;
        long S = scan.nextLong();
        long D = scan.nextLong();
        long N = scan.nextLong();
        long answer = N * S;
        answer = Math.min(answer, N * H);
        answer = Math.min(answer, N * Q);
        long x = N / 2 * D;
        if (N % 2 == 1) {
            x += Math.min(Q, Math.min(H, S));
        }
        answer = Math.min(answer, x);
        System.out.println(answer);
    }
}


Measured memory_bytes: 22996
/*
f(l, r) {
    if (l==r) dp[l][r] = a[l]
    dp[l][r] = max(a[l]-dp[l+1][r], a[r]-dp[l][r-1])
}
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 3005;
ll dp[N][N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i < n; i++) cin >> a[i];
    for (int l = n-1; l >= 0; l--) {
        for (int r = l; r < n; r++) {
            if (l==r) dp[l][r] = a[l];
            else dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
        }
    }
    cout << dp[0][n-1] << "\n";
    return 0;
}

Measured memory_bytes: 70016
#include <stdio.h>

int main(void){
    int H,W;
    scanf("%d",&H);
    scanf("%d",&W);
    int map_i[(H+2)*(W+2)];
    char c[W];
    char ans[H*W+H];
    for(int i=0;i<(H+2)*(W+2);i++)map_i[i]=-9;

    for(int i=0;i<H;i++){
        scanf("%s",c);
        for(int j=0;j<W;j++){
            if(c[j]=='#')map_i[(i+1)*(W+2)+j+1]=9;
            else map_i[(i+1)*(W+2)+j+1]=0;
        }
    }
    
    for(int i=0;i<(H+2)*(W+2);i++){
        if(map_i[i]>=9){
            map_i[i-1]++;
            map_i[i+1]++;
            map_i[i-(W+2)]++;
            map_i[i-(W+2)-1]++;
            map_i[i-(W+2)+1]++;
            map_i[i+(W+2)]++;
            map_i[i+(W+2)-1]++;
            map_i[i+(W+2)+1]++;
        }
    }
    int count=0;
    for(int i=0;i<(H+2)*(W+2);i++){
        if(map_i[i]>=0){
            if(map_i[i]>=9)ans[count]='#';
            else ans[count]='0' + map_i[i];
            count++;
        }
    }https://atcoder.jp/contests/abc075/submit#
    for(int i=0;i<count;i++){
        printf("%c",ans[i]);
        if(i%W==W-1)printf("\n");;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



signed main() {
    ll n, m;
    cin >> n >> m;
    ll l;
    ll r;
    
    ll left = 0;
    ll right = 1e5+1;
    
    rep(i, n) {
        cin >> l >> r;
        left = max(l, left);
        right = min(r, right);
    }
    mes(max((ll)0, right-left+1));
    
    
    
    
    
   
    
    
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  cin>>N>>S;
  int A=S.size();
  vector<int>n(A);
  for(int i=0;i<A;i++){
    for(int j=0;j<26;j++){
      if(S.at(i)==alpha.at(j)) n[i]=j;
    }
  }
  for(int i=0;i<A;i++){
    S.at(i)=alpha.at((n[i]+N)%26);
    cout<<S.at(i);
  }
  cout<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>

int main() {
  int N,u,v;
  cin >> N >> u >> v;
  
  //graphの代入 N-1本の辺
  Graph G(N);
  rep(i,N-1){
    int a,b;
    cin >> a >> b;
    G.at(a-1).push_back(b-1);
    G.at(b-1).push_back(a-1);
  }

  queue<int> q;
  vector<int> du(N,-1);	//根=0としたときの各頂点の距離
//vector<bool> check(N,false);
    
  du.at(u-1) = 0;	//Takashi君を根とする
//check.at(u-1) = true;
  q.push(u-1);
  while(!q.empty()){
    int x = q.front();
    rep(i,G.at(x).size()){
      int p = G.at(x).at(i);
      if(du.at(p) >= 0) continue;	//確定済み
      du.at(p) = du.at(x) + 1;
      q.push(p);
    }
    q.pop();
  }
  
  vector<int> dv(N,-1);	//根=0としたときの各頂点の距離
//vector<bool> checkv(N,false);
    
  dv.at(v-1) = 0;	//Aoki君を根とする
//checkv.at(v-1) = true;
  q.push(v-1);
  while(!q.empty()){
    int x = q.front();
    rep(i,G.at(x).size()){
      int p = G.at(x).at(i);
      if(dv.at(p) >= 0) continue;	//確定済み
      dv.at(p) = dv.at(x) + 1;
      q.push(p);
    }
    q.pop();
  }
  
  
  int g = u - 1;
  rep(i,N){
    bool isLeaf = (G.at(i).size() == 1);
    bool Can_go_i = (du.at(i) < dv.at(i));
    bool betterEnd = (dv.at(i) > dv.at(g));
    if( isLeaf && Can_go_i && betterEnd) g = i;
  }
  
  cout << dv.at(g) - 1 << endl;
  return 0;
}


Measured memory_bytes: 6656
#include<cstdio> 
#include<cmath> 
int main() 
{ 
    int a,b; 
    scanf("%d%d",&a,&b); 
    int l=0, k=b; 
    while(k!=0) l++,k/=10; 
    int w=10; 
    for(int i=1;i<l;i++) 
        w*=10; 
    int num=w*a+b;
    if(int(sqrt(num))*int(sqrt(num))==num) 
        puts("Yes");
    else
        puts("No");
}

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

using namespace std;

int main() {
    unsigned long num, x;
    cin >> num >> x;
    
    vector<unsigned long> r;
    r.resize(num);

    for (auto&& e : r) {
        cin >> e;
        x -= e;
    }
    
    sort(r.begin(), r.end());
    
    unsigned long count = num;
    while (r[0] <= x) {
        x -= r[0];
        ++count;
    }
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 384
import math
n = int(input())
a = [float(x) for x in list(input().split())]
b = [float(x) for x in list(input().split())]

result = 0
for aa, bb in zip(a, b):
    result += abs(aa - bb)
print(round(result, 6))

result = 0
for aa, bb in zip(a, b):
    result += abs(aa - bb) ** 2
print(round(math.sqrt(result), 8))

result = 0
for aa, bb in zip(a, b):
    result += abs(aa - bb) ** 3
print(round(math.pow(result, 1/3), 8))

result = []
for aa, bb in zip(a, b):
    result.append(abs(aa - bb))
print(max(result))



Measured memory_bytes: 5728
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int A, B, C; cin >> A >> B >> C;

    string ans = "No";
    if (A < C && C < B || B < C && C < A) ans = "Yes";

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n, X;
  cin >> n >> X;
  int m[n];
  
  int sum = 0, cnt = 0;
  int mn = 10000;

  for(int i=0; i<n; ++i){
    cin >> m[i];
    sum += m[i];
    cnt++;
    mn = min(mn, m[i]);
  }

  if(X - sum >= mn){
    cnt += (X - sum) / mn;
  }

  cout << cnt;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	string s; int cnt(0);
	while (cin >> s) {
		while (s.size() < 5)s = "0" + s;
		vector<string>v(8, "     ");
		v[2] = "=====";
		rep(i, 0, 5) {
			rep(j, 0, 8) {
				switch (j)
				{
				case 0:
					if ('0' <= s[i] && s[i] <= '4')v[j][i] = '*';
					break;
				case 1:
					if ('5' <= s[i] && s[i] <= '9')v[j][i] = '*';
					break;
				case 2:
					break;
				case 3:
					if (s[i] != '0'&&s[i] != '5')v[j][i] = '*';
					break;
				case 4:
					if (s[i] != '1'&&s[i] != '6')v[j][i] = '*';
					break;
				case 5:
					if (s[i] != '2'&&s[i] != '7')v[j][i] = '*';
					break;
				case 6:
					if (s[i] != '3'&&s[i] != '8')v[j][i] = '*';
					break;
				case 7:
					if (s[i] != '4'&&s[i] != '9')v[j][i] = '*';
					break;
				default:
					break;
				}
			}
		}
		if (cnt++)cout << endl;
		rep(i, 0, 8)cout << v[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3220
#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if(a == b){
        for(int i = 0; i < a; ++i) cout << b;
        cout << endl;
    }
    else{
        if(a > b) {
            for (int i = 0; i < a; ++i) cout << b;
            cout << endl;
        }
        else{
            for(int i = 0; i < b; ++i) cout << a;
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const ll INF = 1e9;
int main() {
	cin.sync_with_stdio(false);
	int R, G;
	cin >> R >> G;
	cout << G * 2 - R << endl;
	return 0;
}

Measured memory_bytes: 768
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    s,w = map(int,input().strip().split())
    if w>=s:
        print("unsafe")
    else:
        print("safe")


if __name__ == '__main__':
    main()

Measured memory_bytes: 83480
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
//using P = pair<int, int>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}

struct Edge{int to, id;};

vector<vector<Edge>> g;
vector<int> P, Q;
int n;
int ans1=-1, ans2=-1;
int main(){
    fast_io

    cin>>n;
    rep(i,n){
        int p;
        cin>>p;
        P.push_back(p);
    }
    rep(i,n){
        int q;
        cin>>q;
        Q.push_back(q);
    }

    vector<int> a(n);
    rep(i,n){
        a[i]=i+1;
    }
    int cnt=1;
    do{
        bool flag=true;
        for(int i=0;i<n;i++){
            //cout<<a[i]<<" ";
            if(a[i]!=P[i]){
                flag=false;
            }
        }
        if(flag && ans1==-1){
            ans1=cnt;
            break;
        }
        cnt++;
        //cout<<endl;

    }while(next_permutation(a.begin(), a.end()));
    cnt=1;
    sort(a.begin(), a.end());
    do{
        bool flag=true;
        for(int i=0;i<n;i++){
            //cout<<a[i]<<" ";
            if(a[i]!=Q[i]){
                flag=false;
            }
        }
        if(flag && ans2==-1){
            ans2=cnt;
            break;
        }
        cnt++;
        //cout<<endl;

    }while(next_permutation(a.begin(), a.end()));
    //cout<<ans1<<" "<<ans2<<endl;
    cout<<abs(ans1-ans2)<<endl;
    return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

#ifdef LOCAL
#define i64 "%lld"
#else
#define i64 "%I64d"
#endif

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 2020;

int n;
vi adj[N];

int dfs(int u, int p, int l) {
    if (l < 0) return 0;
    int res = 1;
    for (int v : adj[u]) if (v != p) res += dfs(v,u,l-1);
    return res;
}

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

    int k;
    cin >> n >> k;
    forn(_,n-1) {
        int u,v; cin >> u >> v;
        u--; v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if (k&1) {
        int ans = 1e9;
        forn(u,n) for (int v : adj[u]) if (u < v) {
            ans = min(ans, n - dfs(u,v,k/2) - dfs(v,u,k/2));
        }
        cout << ans << endl;
    }
    else {
        int ans = 1e9;
        forn(u,n) ans = min(ans, n-dfs(u,-1,k/2));
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 384
import math

n = int(input())

def F(a, b, c, d) :
    return lambda x : a * x**3 + b * x**2 + c * x + d
    
def X(a, b, c) :
    a = 3 * a
    b = 2 * b
    
    try :
        D = math.sqrt(b**2 - 4 * a * c)
        
        if D == 0 :
            return 0
        else :
            return (-b + D) / (2 * a), (-b - D) / (2 * a)
        
    except :
        return -1
def boa(fz, lmax, lmin, p, n) :
    if fz > 0 :
        if lmin > 0 :
            p, n = 2, 1
        else :
            n = 3
    elif fz == 0 :
        if 0 < lmin and lmax < 0 :
            p, n = 1, 1
        elif lmax > 0 :
            p = 2
        else :
            n = 2
    else :
        if lmax > 0 :
            p = 3
        else :
            p, n = 1, 2
        
    return p, n
            
def ao(fz, lmax, p, n) :
    if fz > 0 :
        n = 2
    elif fz == 0 :
        if lmax == 0 :
            p = 1
        else :
            n = 1
    else :
        if lmax > 0 :
            p = 2
        else :
            p, n = 1, 1
        
    return p, n

def bo(fz, lmin, p, n) :
    if fz > 0 :
        if lmin > 0 :
            p, n = 1, 1
        else :
            n = 2
    elif fz == 0 :
        if lmin == 0 :
            n = 1
        else :
            p = 1
    else :
        p = 2
        
    return p, n
      
def aob(fz, p, n) :
    if fz > 0 :
        n = 1
    elif fz < 0 :
        p = 1
        
    return p, n
    
def P(x, y) :
    if x > 0 :
        print(y, 0)
    elif x < 0 :
        print(0, y)
    else :
        print(0, 0)
        
for i in range(n) :
    a, b, c, d = map(int, input().split())
    if a < 0 :
        a *= -1
        b *= -1
        c *= -1
        d *= -1
        
    f = F(a, b, c, d)
    
    p = 0
    # Positive integer
    n = 0
    # Negative integer
    
    if X(a, b, c) == -1 :
        P(-d, 1)
            
    elif X(a, b, c) == 0 :
        if f(-b / (3 * a)) == 0 :
            P(-b, 3)
        else :
            P(-d, 1)
            
    else :
        if f(X(a, b, c)[0]) < f(X(a, b, c)[1]) :
            lmax = X(a, b, c)[1]
            # Local maximum
            lmin = X(a, b, c)[0]
            # Local minimum
        else :
            lmax = X(a, b, c)[0]
            lmin = X(a, b, c)[1]
        
        fmax = f(lmax)
        fmin = f(lmin)
        fz = f(0)
        
        if lmax == lmin :
            if lmax < 0 :
                print(0, 3)
            elif lmax > 0 :
                print(3, 0)
            else :
                print(0, 0)
                
        elif fmin < 0 and 0 < fmax :
            pn = boa(fz, lmax, lmin, p, n)
            print(pn[0], pn[1])
            
        elif fmax == 0 :
            pn = ao(fz, lmax, p, n)
            print(pn[0], pn[1])
            
        elif fmin == 0 :
            pn = bo(fz, lmin, p, n)
            print(pn[0], pn[1])
            
        else :
            pn = aob(fz, p, n)
            print(pn[0], pn[1])


Measured memory_bytes: 5756
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
//#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;

string s(int a,int b,int c){
	if(a<=c && c<=b)return "Yes";
	else return "No";
}

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

Measured memory_bytes: 256
using System;

class Test{
  static void Main(string[] args){
    string[] tmp = Console.ReadLine().Split(' ');
    int a = int.Parse(tmp[0]);
    int b = int.Parse(tmp[1]);
    int result = a * b;
    if(result % 2 == 0){
      Console.WriteLine("Even");
    }else{
      Console.WriteLine("Odd");
    }
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll n, cnt = 0;
  cin >> n;
  REP(i, n) {
    ll h;
    cin >> h;
    cnt += (h % 2);
  }
  cout << (cnt % 2 ? "NO" : "YES") << endl;
}


Measured memory_bytes: 384