akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputstream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputstream);
        AtcoderA solution = new AtcoderA();
        solution.solve(1, in, out);
        out.flush();
        out.close();
    }
    static class AtcoderA {
        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            int n = sc.nextInt();
            int unit = n % 10;
            if (unit == 2 || unit == 4 || unit == 5 || unit == 7 || unit == 9)
                out.println("hon");
            else if (unit == 0 || unit == 1 || unit == 6 || unit == 8)
                out.println("pon");
            else
                out.println("bon");
        }
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            return st.nextToken();
        }

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


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

double power( double a, int n )
{
  double r;
  int abs_n;

  r = 1; abs_n = n < 0 ? -n : n;
  while ( abs_n > 0 ) {
    if ( abs_n % 2 == 1 ) { r *= a; }
    a *= a;
    abs_n /= 2;
  }

  return n >= 0 ? r : 1/r;
}

double nthroot( double a, int n )
{
  double x, y;

  if ( a <= 0 || n < 0 ) { return 0; }
  if ( n == 0 ) { return 1; }

  /* a > 0 かつ n > 0 の場合 */
  y = (a > 1) ? a : 1;
  do {
    x = y;
    y = ((n-1)*x + a/power(x, n-1)) / n;
  } while ( y < x );

  return y;
}

int is_power( int a )
{
  int i;

  if ( a == 1 ) { return 1; }

  for ( i = 2; i <= floor(log2(a)); i++ ) {
    if ( power(floor(nthroot(a, i)), i) == a ) {
      return 1;
    }
  }

  return 0;
}

int main()
{
  int X;

  cin >> X;

  for (int i = X; 0 <= i; i--)
  {
    if ( is_power(i) ) {
        cout << i << endl;
        break;
    }
  }

  return 0;
}


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

using namespace std;

vector<long long> v;

int main(){

    int x, i, n, j = 0;
    long long c, a = 1;
    cin >> n;
    for(i = 0; i < n; ++i){
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end(), greater<int>());
    for(i = 0; i < v.size(); ++i){
        if(v[i] == v[i-1]){
            ++j;
            a*=v[i];
            if(j==2)
                break;
            ++i;
        }
    }
    if(j==2)
        cout << a;
    else
        cout << 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int MAXN = 3000;
const int MAXNUM = 3e5;
const ll MOD = 1e9+7;
 
struct Point{ int x, y; };
 
int h, w, n;
Point arr[MAXN+10];
 
ll fact[MAXNUM+10], invfact[MAXNUM+10];
 
ll mypow(ll x, ll y)
{
    if(y==0) return 1;
    if(y%2) return mypow(x, y-1)*x%MOD;
    ll t=mypow(x, y/2);
    return t*t%MOD;
}
 
ll comb(int n, int r)
{
    if(n<r) return 0;
    return fact[n]*invfact[r]%MOD*invfact[n-r]%MOD;
}
 
ll dp[MAXN+10];
 
int main()
{
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    ll i, j;
 
    fact[0]=1;
    for(i=1; i<=MAXNUM; i++) fact[i]=fact[i-1]*i%MOD;
    invfact[MAXNUM]=mypow(fact[MAXNUM], MOD-2);
    for(i=MAXNUM-1; i>=0; i--) invfact[i]=invfact[i+1]*(i+1)%MOD;
 
    scanf("%d%d%d", &h, &w, &n);
    for(i=0; i<n; i++) scanf("%d%d", &arr[i].x, &arr[i].y);
 
    sort(arr, arr+n, [](const Point& p, const Point& q)
         {
             if(p.x==q.x) return p.y<q.y;
             else return p.x<q.x;
         });
 
    arr[n]={h, w};
    for(i=0; i<=n; i++)
    {
        dp[i]=comb(arr[i].x+arr[i].y-2, arr[i].x-1);
        for(j=0; j<i; j++) 
		if(arr[j].x<=arr[i].x && arr[j].y<=arr[i].y) 
		dp[i]=(dp[i]-dp[j]*comb(arr[i].x-arr[j].x+arr[i].y-arr[j].y, arr[i].x-arr[j].x)%MOD+MOD)%MOD;
    }
    printf("%lld", dp[n]);
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

#define INF (1000000000)
#define ll long long
#define ABS(x)  (x > 0 ? x : -(x))
int main(int argc, char **argv) {
    int i;
    int N;

    int ary[100000] = {0};
    unsigned long long dp[100000+1];
    for(i = 0; i < (sizeof(ary)/sizeof(ary[0])); i++) {
        dp[i]=INF;
    }

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

    dp[0] = 0;  // 最初の足場
    long long tmp = ary[1] - ary[0];
    dp[1] = ABS(tmp);

    for(i = 2; i < N; i++) {
        tmp = dp[i-1] + ABS(ary[i] - ary[i-1]);
        if (tmp < dp[i]) {
            dp[i] = tmp;
        }
        tmp = dp[i-2] + ABS(ary[i] - ary[i-2]);
        if (tmp < dp[i]) {
            dp[i] = tmp;
        }
    }

    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

int main()
{
    string str;
    int h, w;

    cin >> h >> w;

    for (int i = 1; i <= h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> str;
            if (str == "snuke") {
                printf("%c%d\n", 'A' + j, i);
            }
        }
    }

    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()

ll mod = 1000000007;

ll gcd(ll a, ll b){
  if (a%b == 0)return(b);
  else return(gcd(b, a%b));
}

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}

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

  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  vll mul(4);
  mul[0] = a*c;
  mul[1] = a*d;
  mul[2] = b*c;
  mul[3] = b*d;
  ll ret = mul[0];
  rep(i,4){
    ret = max(ret,mul[i]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> A(H, vector<int>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> A[i][j];
    }
  }
  vector<vector<int>> B(H, vector<int>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> B[i][j];
    }
  }

  vector<vector<int>> diff(H, vector<int>(W));
  rep(i, H) {
    rep(j, W) {
      diff[i][j] = abs(A[i][j] - B[i][j]);
    }
  }

  int dpzero = 80 * 2 * (80 + 80);
  int dpmax = 80 * 4 * (80 + 80);
  vector<vector<vector<bool>>> dp(
      H, vector<vector<bool>>(W, vector<bool>(dpmax, false)));
  dp[0][0][dpzero + diff[0][0]] = true;
  dp[0][0][dpzero - diff[0][0]] = true;

  rep(i, H) {
    rep(j, W) {
      rep(k, dpmax) {
        if (dp[i][j][k] == false)
          continue;

        if (i + 1 < H) {
          dp[i + 1][j][k + diff[i + 1][j]] = true;
          dp[i + 1][j][k - diff[i + 1][j]] = true;
        }


        if (j + 1 < W) {
          dp[i][j + 1][k + diff[i][j + 1]] = true;
          dp[i][j + 1][k - diff[i][j + 1]] = true;
        }
      }
    }
  }

  int ans = INF;
  rep(k, dpmax) {
    if (!dp[H - 1][W - 1][k])
      continue;
    chmin(ans, abs(dpzero - k));
  }
  cout << ans << endl;
}

Measured memory_bytes: 42240
import heapq
n,m = map(int,input().split())
a = [int(i) * (-1) for i in input().split()]
 
heapq.heapify(a)

for _ in range(m):
	a_min = heapq.heappop(a)
	heapq.heappush(a,(-(-a_min//2)))

print(-sum(a))

Measured memory_bytes: 14180
import numpy as np
from numba import njit


@njit
def myfunc(n, k, A):
    for _ in range(k):
        l = np.zeros((n + 1,), dtype=np.int64)
        for i, a in enumerate(A[:-1]):
            l[max(0, i - a)] += 1
            l[min(n, i + a + 1)] -= 1
        A = np.cumsum(l)
        if np.all(A[:-1] == n):
            break
    return A


def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    A = np.append(A, 0)
    print(*myfunc(n, k, A)[:-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 125320
Q = 1000000007
n, m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
dp = {
    0: 1,
    1: 0 if 1 in a else 1
}

for k in range(2, n + 1):
    dp[k] = (0 if k in a else dp[k - 1] + dp[k - 2]) % Q


print(dp[n])


Measured memory_bytes: 25228
#include <cstdio>
#include <algorithm>

int main() {
  int A, B, C, X, Y;
  scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);

  int res = A*X + B*Y;
  if (X < Y) {
    res = std::min({res, 2*C*X+B*(Y-X), 2*C*Y});
  } else {
    res = std::min({res, A*(X-Y)+2*C*Y, 2*C*X});
  }
  printf("%d\n", res);
}


Measured memory_bytes: 504
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  if(a + b <= 2 * c) {
    cout << a * x + b * y << endl;
  } else {
    // できるだけCで買う
    int ans = 0;
    if(x < y) {
      ans += x * c * 2;
      if(b <= c * 2) ans += b * (y-x); // 残りを単独で買う
      else ans += c * (y-x) * 2;
    } else {
      ans += y * c * 2;
      if(a <= c * 2) ans +=a * (x-y);
      else ans += c * (x-y) * 2;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
c = 0
if x * y > 0:
  c = abs(y-x)
  if x > y:
    c += 2
elif x * y == 0:
  c = abs(x+y)
  if x > y:
    c += 1
else:
  c = 1+abs(x+y)
print(c)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define CIN>>x scanf("%lld",&x);
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n;
    a=1;
    rep(i,n){
        a*=(i+1);
        a%=MOD;
    }

    cout<<a<<endl;
}

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

const int N = 2005;
const int inf = 1e9+7;

int n, x, a[N], f[N];

int main() {
    scanf("%d %d", &n, &x);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
        f[i] = inf;
    }
    long long result = 1e18;
    for (int i = 0; i < n; ++i) {
        long long cur = 1LL * i * x;
        for (int j = 0; j < n; ++j) {
            f[j] = min(f[j], a[(j - i + n) % n]);
            cur += f[j];
        }
        result = min(result, cur);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    bingo_num = []

    for i in range(3):
        N = LI()
        bingo_num.append(N)

    N = II()

    for i in range(N):
        b = II()
        for row_i in range(3):
            for col_j in range(3):
                if bingo_num[row_i][col_j] == b:
                    bingo_num[row_i][col_j] = 0

    for i in range(3):
        if sum(bingo_num[i]) == 0:
            print("Yes")
            exit()

    for j in range(3):
        if bingo_num[0][j] + bingo_num[1][j] + bingo_num[2][j] == 0:
            print("Yes")
            exit()

    sum_naname = 0
    sum_naname_2 = 0
    for i in range(3):
        sum_naname += bingo_num[i][i]
        sum_naname_2 += bingo_num[i][2 - i]

    if sum_naname == 0 or sum_naname_2 == 0:
        print("Yes")
        exit()
    print("No")


main()


Measured memory_bytes: 64372
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main(){
	int n; cin >> n;
	vector<int> a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	a.push_back(0);
	sort(a.begin(), a.end());
	rep(i, 0, n + 1) {
		if (i % 2) a[i] = 24 - a[i];
	}
	int ans = 24;
	rep(i, 0, n + 1)rep(j, i+1, n + 1) {
		int d = abs(a[i] - a[j]);
		ans = min({ ans,d,24 - d });
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> P;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N;
int d[1000100];
int p[1000100];

int main(){
  scanf("%d", &N);
  rep(i,N) scanf("%d", p+i);
  fill(d, d+N, INF);
 
  queue<P>q;
  q.push(P(0, 0));

  while(!q.empty()){
    P pr = q.front(); q.pop();
    int step = pr.first;
    if(d[pr.second] < step) continue;
    //    cout << step << " " << pr.second << endl;
    if(pr.second >= N-1){
      printf("%d\n", step);
      return 0;
    }

    for(int i=1;i<=6;i++){
      int pos = pr.second+i;
      while(p[pos]!=0){
	if(d[pos+p[pos]] <= step+1) break;
	d[pos+p[pos]] = step+1;
	pos += p[pos];
      }
      //      cout << i << " " << pos << " " << p[pos] << " " << d[pos] << endl;
      if(p[pos]==0 && d[pos] >= step+1){
	d[pos] = step+1;
	q.push(P(d[pos], pos));
      }
    }
  }
  return 0;
}

Measured memory_bytes: 5708
import Foundation

let input1 = readLine()!
let input2 = readLine()!
let n = Int(input1)!
let a = input2.components(separatedBy: " ").map { Int($0)! }
var current = a[0]
var res = 0
for i in (1..<n) {
  if (a[i] < current) {
    res += (current - a[i])
  } else {
    current = a[i]
  }
}
print(res)

Measured memory_bytes: 22096
import java.util.*;
import java.util.stream.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int[] a = new int[3];
		for (int i=0; i<3; i++) {
			a[i] = in.nextInt();
		}
		String[] s = Arrays.stream(a).sorted().mapToObj(String::valueOf).toArray(String[]::new);
		out.println(String.join(" ", s));
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}


Measured memory_bytes: 32148
#include<iostream>
#include<cstdio>
using namespace std;
int gcd(int u, int v)
{
  int r, z;
  if(v > u)
  {
    z = u;
    u = v;
    v = z;
  }
  while((r = u%v) != 0)
  {
    u = v;
    v = r;
  }    
  return v;  
}

int main(void)
{
  int a, b;
  while(scanf("%d %d", &a, &b) != EOF)
  {      
    printf("%d %d\n", gcd(a,b), b/gcd(a,b)*a);
  }
  return 0;
}



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

using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll a[n+1], sum = 0;
    for(int i = 0; i <= n; i++) 
    {
        cin >> a[i];
        sum += a[i];
    }
    ll ans = 1;
    ll node = 1; // non leaf node at level i
    bool flag = false; 
    if(n == 0 && a[0] != 1 ) // root node is a leaf node
flag = true;
if(n != 0 && a[0] !=  0) // root node hase child
flag = true; 

for(int i = 1; i <= n; i++)
{
node = min(node*2, sum); // maximum node possible at level i
ans += node; 
if(node < a[i]) // if max possible node is greater than leaf nodes 
{
flag = true;
break;
}
node -= a[i];
sum -= a[i];

}
if(flag) ans = -1;
cout << ans;
}


Measured memory_bytes: 4388
n, x = map(int, input().split())
ans = 0
 
hambargers = [1]
patties = [1]
 
for i in range(1, n+1):
    num = hambargers[i-1] * 2 + 3
    patty_num = patties[i-1] * 2 + 1
    hambargers.append(num)
    patties.append(patty_num)
 
def cal(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + hambargers[N-1]:
        return cal(N-1, X-1)
    else:
        return patties[N-1] + 1 + cal(N-1, X-2-hambargers[N-1])
 
print(cal(n, x))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
const int MAX = 3001;
int dp[MAX][MAX];
char s[MAX];
char t[MAX];
int result[MAX];
int main()
{
	cin >> s;
	cin >> t;
	int n = strlen(s);
	int m = strlen(t);
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (s[i - 1] == t[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	int maxlen = dp[n][m];
	while (dp[n][m] != 0)
	{
		if (dp[n][m] > max(dp[n][m - 1], dp[n - 1][m]))
		{
			result[dp[n][m]] = n;
			n--; m--;
		}
		else
		{
			if (dp[n - 1][m] > dp[n][m - 1])
				n--;
			else
				m--;
		}
	}

	for (int i = 1; i <= maxlen; i++)
		cout << s[result[i]-1];
	return 0;
}

Measured memory_bytes: 35456
while(True):
  h,w=map(int,input().split())
  if h==0 and w==0:
    break
  rect=''
  for i in range(h):
    for j in range(w):
      if (i+j)%2  == 0:
        rect+='#'
      else:
        rect+='.'
    rect+='\n'
  print(rect)

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define VIN(x) for(auto&youso_: (x) )cin>>youso_
#define VOUT(x, delim) for(auto&youso_: (x) )cout<<youso_<<delim;cout<<endl

#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) i64 __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    SCIN(S);

    i64 N = S.length();
    i64 minreq = N;
    REP(i, N - 1) {
        if (S[i] == S[i + 1]) continue;
        chmin(minreq, max(i + 1, N - (i + 1)));
    }
    COUT(minreq);

    return 0;
}


Measured memory_bytes: 3716
#include <iostream>

using namespace std;

char b;

void solve() {
  char ret;
  switch (b) {
    case 'A':
      ret = 'T';
      break;
    case 'C':
      ret = 'G';
      break;
    case 'G':
      ret = 'C';
      break;
    default:
      ret = 'A';
  }
  cout << ret << endl;
}

int main() {
  cin >> b;
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e10;

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

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var x = rint();
        int happy = (x / 500) * 1000 + ((x % 500) / 5) * 5;
        Write(happy);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27132
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

/*
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;cin>>n;
    cout<<ceil((double)n/2);
    return 0;
}
*/
int a[4][4];
int mark[4][4];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(mark , 0 , sizeof(mark));
    for (size_t i = 0; i < 3; i++) {
        for (size_t j = 0; j < 3; j++) {
            cin>>a[i][j];
        }
    }
    int n,k;cin>>n;
    for (size_t i = 0; i < n; i++) {
        cin>>k;
        for (size_t i = 0; i < 3; i++) {
            for (size_t j = 0; j < 3; j++) {
                if(a[i][j] == k){
                    mark[i][j] = 1;

                }
            }
        }
    }
    ll int sum = 0;
    for (size_t i = 0; i < 3; i++) {
        sum = 0;
        for (size_t j = 0; j < 3; j++) {
            sum += mark[i][j];
        }
        if(sum == 3){
            cout<<"Yes";
            return 0;
        }
    }
    sum = 0;
    for (size_t i = 0; i < 3; i++) {
        sum = 0;
        for (size_t j = 0; j < 3; j++) {
            sum += mark[j][i];
        }
        if(sum == 3){
            cout<<"Yes";
            return 0;
        }
    }
    sum = mark[0][0] + mark[1][1] + mark[2][2];
    if(sum == 3 ){
        cout<<"Yes";
        return 0;

    }
    else if(mark[2][0] + mark[1][1] + mark[0][2] == 3){
        cout<<"Yes";
        return 0;
    }

    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
        int r, g, b, n, ans=0;
        scanf("%d %d %d %d", &r, &g, &b, &n);
        for(int i=0; r*i<=n; i++){
                for(int j=0; r*i+g*j<=n; j++){
                        if((n-r*i-g*j)%b==0) ans++;
                }
        }
        printf("%d\n", ans);
        return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int trnA(char a){
    int m;
    if(a=='A'){
        m=10;
    }
    if(a=='B'){
        m=11;
    }
    if(a=='C'){
        m=12;
    }
    if(a=='D'){
        m=13;
    }
    if(a=='E'){
        m=14;
    }
    if(a=='F'){
        m=15;
    }
    return m;
}
int trnB(char b){
    int n;
    if(b=='A'){
        n=10;
    }
    if(b=='B'){
        n=11;
    }
    if(b=='C'){
        n=12;
    }
    if(b=='D'){
        n=13;
    }
    if(b=='E'){
        n=14;
    }
    if(b=='F'){
        n=15;
    }
    return n;
}

int main(){
    char a,b;
    scanf("%c %c",&a,&b);
    if(trnA(a)>trnB(b)){
        printf(">\n");
    }
    else if(trnA(a)<trnB(b)){
        printf("<\n");
    }
    else{
        printf("=\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout << max(a*b,c*d) << endl;
}


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

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

  cout << (N + 110) / 111 * 111 << endl;
  return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<map>
#include<vector>
#include<string>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while (cin >> n && n){
        string a;
        long long b, c;
        map<string, long long> data;
        vector<string> id;
        rep(i, n){
            cin >> a >> b >> c;
            c *= b;
            if (data.find(a) == data.end()){
                data.insert(make_pair(a, c));
                id.push_back(a);
            }
            else{
                data[a] += c;
            }
        }

        bool NA = true;
        rep(i, id.size()){
            if (data[id[i]] >= 1000000){
                cout << id[i] << endl;
                NA = false;
            }
        }
        if (NA) cout << "NA" << endl;
    }
}

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

const int MAXN = 1e5 + 10;
int a[MAXN], b[MAXN], c[MAXN];
int N;

int main() {
  scanf("%d\n", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
  }

  int swim = 0, bug = 0, homework = 0;
  for (int i = 0; i < N; i++) {
    int swim_ = swim, bug_ = bug;
    swim = a[i] + max(bug, homework);
    bug = b[i] + max(swim_, homework);
    homework = max(swim_, bug_) + c[i];
  }

  printf("%d\n", max(swim, max(bug, homework)));
}

Measured memory_bytes: 1408
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m) = (line[0], line[1]);
    let mut history: Vec<i64> = vec![0;n];
    let mut ac_num = 0;
    let mut pe_num = 0;

    for _ in 0..m{
        let tmpline = read_as_string();
        let tmpline = tmpline.split_whitespace().collect::<Vec<&str>>();
        let (q, state): (usize, &str) = (usize::from_str(tmpline[0]).unwrap() -1, tmpline[1]);
        if history[q] == -1{
            continue;
        }
        if let Some(_) = state.find("AC"){
            ac_num += 1;
            pe_num += history[q];
            history[q] = -1;
        }else{
            history[q] += 1;
        }
    }

    println!("{} {}", ac_num, pe_num);
}


Measured memory_bytes: 4476
#include <iostream>
#include <algorithm>
using namespace std;
int n, p[4009][4009]; long long w[4009], dp[4009][4009];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> w[i + 1], w[i + 1] += w[i];
	for (int i = 0; i <= n - 2; i++) {
		dp[i][i + 2] = w[i + 2] - w[i];
		p[i][i + 2] = i + 1;
	}
	for (int i = 3; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			long long x = 1LL << 60; int opt = -1;
			for (int k = p[j][j + i - 1]; k <= p[j + 1][j + i]; k++) {
				if (x > dp[j][k] + dp[k][j + i]) {
					x = dp[j][k] + dp[k][j + i];
					opt = k;
				}
			}
			dp[j][j + i] = x + w[j + i] - w[j];
			p[j][j + i] = opt;
		}
	}
	cout << dp[0][n] << endl;
	return 0;
}


Measured memory_bytes: 125820
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  GVI(A, N);
  GVI(B, N);
  GVI(C, N);
  vector<ll> LA(N), LB(N);
  sort(ALL(A), greater<int>());
  sort(ALL(B), greater<int>());
  sort(ALL(C), greater<int>());
  int b = 0, c = 0;
  while (b < N) {
    while (c < N && B[b] < C[c])
      c++;
    LB[b] = c;
    b++;
  }
  int a = 0;
  ll sum = 0;
  b = 0;
  while (a < N) {
    while (b < N && A[a] < B[b]) {
      sum += LB[b];
      b++;
    }
    LA[a] = sum;
    a++;
  }
  print(accumulate(ALL(LA), 0LL));
  return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>
int main(void){
int cards[128][14] = {{0}};
  int i, N;
  scanf("%d", &N);
  for(i = 0; i < N; i++) {
    char c; int cn;
    scanf("%c", &c); 
    scanf("%c %d", &c, &cn);
    cards[c][cn] = 1;
  }

  for(i = 1; i <= 13; i++) {

    if(cards['S'][i] == 0) {
      printf("S %d\n", i);
    }
  }
  
    for(i = 1; i <= 13; i++) {

    if(cards['H'][i] == 0) {
      printf("H %d\n", i);
    }
  }
  
    for(i = 1; i <= 13; i++) {

    if(cards['C'][i] == 0) {
      printf("C %d\n", i);
    }
  }
  
    for(i = 1; i <= 13; i++) {

    if(cards['D'][i] == 0) {
      printf("D %d\n", i);
    }
  }

    
}


Measured memory_bytes: 2044
#!/usr/bin/env python3
#ABC70 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(input())
g = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,c = map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
q,k = map(int,input().split())
que = deque()
que.append(k-1)
dist = [-1]*n
dist[k-1] = 0
while que:
    v = que.popleft()
    for x,c in g[v]:
        if dist[x] == -1:
            dist[x] = dist[v] + c
            que.append(x)

for _ in range(q):
    x,y = map(int,input().split())
    print(dist[x-1] + dist[y-1])


Measured memory_bytes: 43720
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
const int md=1e9+7;
int n,k,a[111],dp[111][111111],ans;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		ans=0;
		for(int j=0;j<=k;j++)
		{
			ans=(ans+dp[i-1][j]-(j-a[i]-1>=0?dp[i-1][j-a[i]-1]:0))%md;
			dp[i][j]=(ans+md)%md;
		}
	}
	cout<<dp[n][k]<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N, K;
    cin >> N >> K;
    vll A(N);
    rep(i, N) cin >> A[i];

    vll s(N, -1);
    ll r = K;
    ll c = 1;
    ll step = 0;
    while(r>0){
        if(s[c-1]>=0){
            r %= step-s[c-1];
            if(r==0) break;
        }
        s[c-1] = step;
        c = A[c-1];
        ++step;
        --r;
    }
    cout << c << endl;
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n,x,y;
  cin>>n>>x>>y;
  cout << min(x,y) << " " << max(x+y-n, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
S=int(input())

dp=[0 if i<3 else 1 for i in range(S+1)]


for i in range(3,S-1):
    for j in range(i+3,S+1):
        dp[j]+=dp[i]
        dp[j]%=(10**9+7)

print(dp[-1])

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> x(n) , y(n);
    REP(i,n) {
        cin >> x[i] >> y[i];
    }

    double ans = 0;
    int count = 0;
    vector<int> v(n);
    iota(ALL(v),0);

    do {
        REP(i,n-1) {
            ans += sqrt(pow(abs(x[v[i]] - x[v[i+1]]),2) + pow(abs(y[v[i]] - y[v[i+1]]),2));
        }
        count++;
    } while(next_permutation(ALL(v)));

    ans /= count;

    cout << fixed << setprecision(10) << ans << '\n';

    return 0;
}

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

using namespace std;

#define FOR(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define pb push_back
#define lli long long int
#define INF 100000001
#define all(c) (c.begin(),c.end())
#define sz(c) c.size()
const int MOD = 1e9 + 7;
const int MX = 2e5 + 5;


void solve() {
	int n;
	cin >> n;
	if (n >= 30)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--) {
	solve();

	// }




	return 0;

}

Measured memory_bytes: 3644
#include <iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>

#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
    int n;
    cin >> n;
    int dum;
    priority_queue<int> a;
    vector<int> v(n);
    REP(i,n) {
        cin >> dum;
        v[i] = dum;
        a.push(dum);
    }

    REP(i,n) {
        if (v[i] == a.top()) {
            dum = a.top();
            a.pop();
            cout << a.top() <<endl;
            a.push(dum);
        } else {
            cout << a.top() <<endl;            
        }
    }
}

Measured memory_bytes: 3316
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	vector<int> vs[301];
	int N,M;
	cin >> N >> M;
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			int a;
			cin >> a;
			vs[i].push_back(a);
		}
		reverse(vs[i].begin(),vs[i].end());
	}
	bool done[301]={};
	int ret=N;
	for(int i=0;i<M;i++){
		int c[301]={};
		int m=0;
		int mi=0;
		for(int j=0;j<N;j++){
			while(done[vs[j].back()]){
				vs[j].pop_back();
			}
			int k=vs[j].back();
			c[k]++;
			if(m<c[k]){
				m=c[k];
				mi=k;
			}
		}
		ret=min(m,ret);
		done[mi]=true;
	}
	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 896
import numpy as np
import math
import itertools

n = int(input())
x = np.zeros(n)
y = np.zeros(n)
for i in range(n):
    x[i], y[i] = map(int, input().split())

sum_ = 0
for v in itertools.permutations(np.arange(n), n):
    for i, j in enumerate(v):
        if i == 0:
            pass
        else:
            sum_ += math.sqrt((x[v[i]]-x[v[i-1]])*(x[v[i]]-x[v[i-1]]) + (y[v[i]]-y[v[i-1]])*(y[v[i]]-y[v[i-1]])) 
    # print(v)
    # print(sum_)

print(sum_ / math.factorial(n))

# (0, 1, 2)
# (0, 2, 1)
# (1, 0, 2)
# (1, 2, 0)
# (2, 0, 1)
# (2, 1, 0)


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli mod = 1000000007;

lli n,m;
lli s,t;
graph g;
priority_queue<vll,vector<vll>,greater<vll>> q;
vll dist,tsid,way,yaw;
mat edge;
vll mid_point;
lli ans = 0;

int main(){
  cin >> n >> m;
  cin >> s >> t;
  for(lli i = 0;i < m;i++){
    lli u,v,d;
    cin >> u >> v >> d;
    g[u][v] = g[v][u] = d;
    edge.push_back(vll({u,v,d}));
  }
  q.push(vll({0,s,0}));
  dist = vll(n+1,LONG_MAX);
  way = vll(n+1);
  way[0] = 1;
  while(!q.empty()){
    lli x = q.top()[1];
    lli d = q.top()[0];
    lli from = q.top()[2];
    q.pop();
    if(dist[x] < d) continue;
    way[x] += way[from];
    way[x] %= mod;
    if(dist[x] == LONG_MAX){
      dist[x] = d;
      for(auto& y : g[x]){
        q.push(vll({d+y.second,y.first,x}));
      }
    }
  }
  q.push(vll({0,t,0}));
  tsid = vll(n+1,LONG_MAX);
  yaw = vll(n+1);
  yaw[0] = 1;
  while(!q.empty()){
    lli x = q.top()[1];
    lli d = q.top()[0];
    lli from = q.top()[2];
    q.pop();
    if(tsid[x] < d) continue;
    yaw[x] += yaw[from];
    yaw[x] %= mod;
    if(tsid[x] == LONG_MAX){
      tsid[x] = d;
      for(auto& y : g[x]){
        q.push(vll({d+y.second,y.first,x}));
      }
    }
  }
  if(dist[t] != tsid[s] || dist[t] == LONG_MAX){
    cout << "programing error" << endl;
    return 1;
  }
  for(auto& x : edge){
    if(dist[x[0]]+tsid[x[1]]+x[2] == dist[t]){
      if(dist[x[0]]*2 < dist[t] && tsid[x[1]]*2 < dist[t]){
        mid_point.push_back((way[x[0]]*yaw[x[1]])%mod);
      }
    }else if(dist[x[1]]+tsid[x[0]]+x[2] == dist[t]){
      if(dist[x[1]]*2 < dist[t] && tsid[x[0]]*2 < dist[t]){
        mid_point.push_back((way[x[1]]*yaw[x[0]])%mod);
      }
    }
  }
  for(lli i = 1;i <= n;i++){
    if(dist[i]*2 == dist[t]){
      mid_point.push_back((way[i]*yaw[i])%mod);
    }
  }
  lli sum = accumulate(mid_point.begin(),mid_point.end(),0ll)%mod;
  for(auto x : mid_point){
    ans += ((sum-x+mod)*x)%mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;



}


Measured memory_bytes: 54864
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}
vector<vector<int> > u(3001, vector<int> (3001));

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
char dz[] = {'U', 'D', 'R', 'L'};
string bfs(int x, int y, int px, int py){
	vector<vector<pii> > path(3001, vector<pii> (3001));
	vector<vector<int> > curu = u;
	queue<pii> q;
	q.push({x, y});
	curu[x][y] = 1;
	curu[px][py] = 0;
	while(!q.empty()){
		pii u = q.front();
		q.pop();
		rep(i, 4){
			int qx = u.F + dx[i], qy = u.S + dy[i];
			if(qx >= 0 && qx <= 3000 && qy >= 0 && qy <= 3000 && !curu[qx][qy]) {
				curu[qx][qy] = 1;
				q.push({qx, qy});
				path[qx][qy] = {u.F, u.S};
			}
		}
	}
	// return "1";
	string ans = "";
	while(mp(px, py) != mp(x, y)){
		u[px][py] = 1;
		int cx = px - path[px][py].F;
		int cy = py - path[px][py].S;
		rep(i, 4) if(cx == dx[i] && cy == dy[i]) ans += dz[i];
		tie(px, py) = path[px][py];
	}
	reverse(all(ans));
	return ans;
}
void solve()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x1 += 1500, y1 += 1500, x2 += 1500, y2 += 1500;
	string ans1 = bfs(x1, y1, x2, y2);
	string ans2 = bfs(x2, y2, x1, y1); 
	string ans3 = bfs(x1, y1, x2, y2);
	string ans4 = bfs(x2, y2, x1, y1);
	cout << ans1 << ans2 << ans3 << ans4;
}	 

 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 144708