akhauriyash/Code-Regression huggingface dataset:
import sys
import numpy as np
read = sys.stdin.read


class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if x == y:
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1

    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


N, *xy = map(int, read().split())
xy = np.array(xy, np.int64).reshape(N, 2)

town = np.arange(N)
arg_x = np.argsort(xy[:, 0])
arg_y = np.argsort(xy[:, 1])

edges_x = (xy[arg_x[1:], 0] - xy[arg_x[:-1], 0]).tolist()
town_x = town[arg_x].tolist()
town_x = zip(town_x[1:], town_x[:-1])

edges_y = (xy[arg_y[1:], 1] - xy[arg_y[:-1], 1]).tolist()
town_y = town[arg_y].tolist()
town_y = zip(town_y[1:], town_y[:-1])

edges = list(zip(edges_x, town_x)) + list(zip(edges_y, town_y))
edges.sort()

tree = UnionFind(N)
answer = 0

for d, (t1, t2) in edges:
    if tree.isSameGroup(t1, t2):
        continue

    tree.Unite(t1, t2)
    answer += d

print(answer)

Measured memory_bytes: 71516
@o=(0)x<>;
$i{$_}//=$%,++$%,++$n{$_}for glob<>;
@_=sort{$b-$a}keys%n,0;
$i=1e9;
for(0..$#_-1){
	$o[$i-=$-=$i-$i{$_[$_]}]+=($_[$_]-$_[$_+1])*($n+=$n{$_[$_]})
}
print"@o"


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

int main()
{
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(8);
    int n;
    cin >> n;
    cout << (n / 2 + n % 2) * 1.0 / n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<string>
#include<set>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する

int main(){
    int n,x,t;
    cin>>n>>x>>t;
    int c;
    if(n%x==0){
        c=int(n/x);
    }
    else{
        c=int(n/x)+1;
    }
    cout<<c*t<<endl; 
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int R;
  cin >> R;
  printf("%6f\n", double(2 * R) * M_PI);
}

Measured memory_bytes: 3760
fn calc(a: &Vec<i64>, b: &Vec<i64>, t: &Vec<i64>) -> Vec<i64> {
    let n = a.len();
    let mut res = vec![0; n + 1];
    let mut ways = 0;
    let mut idx = n;
    for i in (0..n).rev() {
        while idx != 0 && b[idx - 1] > a[i] {
            idx -= 1;
            ways += t[idx];
        }
        res[i] = ways;
    }
    res
}
fn main() {
    let n: usize = readln();
    let mut a: Vec<i64> = readln();
    a.sort();
    let mut b: Vec<i64> = readln();
    b.sort();
    let mut c: Vec<i64> = readln();
    c.sort();
    let r = vec![1; n + 1];
    let q = calc(&b, &c, &r);
    let p = calc(&a, &b, &q);
    let ans = p.iter().sum::<i64>();
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


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

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define fo(i, a, b, k) for(int i = a; i <= b; i += k)
#define _fo(i, a, b, k) for(int i = a; i >= b; i -= k)
#define foa(i, a) for (auto &i : a)
#define fod(i, a) for(int i = 1; i*i <= a; i++)
#define sz(a) ((int) a.size())
#define all(a) begin(a), end(a)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mk(x, y) make_pair(x, y)  
#define log2i(x) (31-__builtin_clz(x))
#define log2ll(x) (63-__builtin_clzll(x)) 
#define msz(x) __builtin_popcount(x) 
#define mszll(x) __builtin_popcountll(x) 
#define fom(i, a, b) for(int i = a; i < (1<<b); i++)
#define ifon(i, mask) if(mask&(1<<i))
#define ss(i, mask) while(i=(i-mask)&mask)
#define ifss(i, mask) if(i > (mask^i)) 

typedef vector<int> vi;

const int N = 1e5+1;

int cnt[N];
vi val;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, temp = 0;
	
	cin >> n;
	fo(i, 1, n, 1) {
		int v;
		cin >> v;
		if(cnt[v] == 0) val.pb(v);
		cnt[v]++;
	}
	
	foa(v, val) 
		if(cnt[v] % 2 == 0) temp++;
	
	int s = sz(val);
	if(temp % 2 == 0) cout << s;
	else cout << s-1;
}

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

int main() {
  string s;
  cin>>s;
  int a=s[0]-'0';
  int b=s[1]-'0';
  int c=s[2]-'0';
  int d=s[3]-'0';
  if(a+b+c+d==7) cout<<s[0]<<'+'<<s[1]<<'+'<<s[2]<<'+'<<s[3]<<"=7"<<endl;
  else if(a+b+c-d==7) cout<<s[0]<<'+'<<s[1]<<'+'<<s[2]<<'-'<<s[3]<<"=7"<<endl;
  else if(a+b-c+d==7) cout<<s[0]<<'+'<<s[1]<<'-'<<s[2]<<'+'<<s[3]<<"=7"<<endl;
  else if(a+b-c-d==7) cout<<s[0]<<'+'<<s[1]<<'-'<<s[2]<<'-'<<s[3]<<"=7"<<endl;
  else if(a-b+c+d==7) cout<<s[0]<<'-'<<s[1]<<'+'<<s[2]<<'+'<<s[3]<<"=7"<<endl;
  else if(a-b+c-d==7) cout<<s[0]<<'-'<<s[1]<<'+'<<s[2]<<'-'<<s[3]<<"=7"<<endl;
  else if(a-b-c+d==7) cout<<s[0]<<'-'<<s[1]<<'-'<<s[2]<<'+'<<s[3]<<"=7"<<endl;
  else cout<<s[0]<<'-'<<s[1]<<'-'<<s[2]<<'-'<<s[3]<<"=7"<<endl;
}

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

int main() {
    int n, d, ans;
    cin >> n >> d;

    int one = d*2+1;
    
    if (n%one==0) {
        ans = n/one;
    } else {
        ans = n/one + 1;
    }
    cout << ans << endl;
}

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

int main(){
    int n, ans = 0;
    cin >> n;

    for(int i = 1; i <= 9; i++){
        if(i <= n) ans++;
        else break;
    }
    for(int i = 100; i <= 999; i++){
        if(i <= n) ans++;
        else break;
    }
    for(int i = 10000; i <= 99999; i++){
        if(i <= n) ans++;
        else break;
    }

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


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

int n, m, t;
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  int a[3][3];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> a[i][j];
    }
  }
  bool x[3][3];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      x[i][j] = false;
    }
  }
  cin >> n;
  while (n--) {
    int b;
    cin >> b;
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (a[i][j] == b) x[i][j] = true;
      }
    }
  }
  string ans = "No";
  // Check rows/cols/diags
  for (int i = 0; i < 3; ++i)
    if (x[i][0] && x[i][1] && x[i][2]) ans = "Yes";
  for (int i = 0; i < 3; ++i)
    if (x[0][i] && x[1][i] && x[2][i]) ans = "Yes";
  if (x[0][0] && x[1][1] && x[2][2]) ans = "Yes";
  if (x[0][2] && x[1][1] && x[2][0]) ans = "Yes";
  cout << ans;

  return 0;
}



Measured memory_bytes: 3656
import java.io.PrintWriter
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    var n = nextInt()
    val reg = Regex(".+")
    println(next().replace("(.)\\1+".toRegex(), "1").length)
}

// 入力取得
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

Measured memory_bytes: 34656
#include<stdio.h>

#define MAX 100000

int A[MAX],n;

int partition(int p, int r){
    int i,j;
    int x=A[r];
    int tmp;

    i=p-1;

    for (j=p; j<=r-1; j++) {
        if(A[j]<=x){
          i++;
          tmp=A[i];
          A[i]=A[j];
          A[j]=tmp;
        }
    }

    tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;

    return i+1;
}

int main(void){
  int i;
  int q;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }

  q=partition(0,n-1);

  for(i=0; i<n;i++){
    if(i){
      printf(" ");
    }
    if(i==q){
      printf("[");
    }
    printf("%d",A[i]);
    if(i==q){
      printf("]");
    }
  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 2120
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		int max = 0;
		if(x == 1) {
			max = 1;
		} else if(x == 2) {
			max = 2;
		} else {
			int maxnum = (int)Math.sqrt(x);
			for(int i = 2; i <= maxnum; i++) {
				int tmp = i;
				while(true) {
					tmp =  tmp * i;
					if(tmp > x) {
						max = Math.max(max, tmp/i);
						break;
					}
				}
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 21844
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;

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

    int n, k, x, y;
    cin >> n >> k >> x >> y;

    cout << min(n, k) * x + max(n - k, 0) * y << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1e9
typedef long long ll;
using namespace std;

string s;
int n;

vector<int> b(20010);
vector<int> w(20020);

int main(){
    cin >> n;
    cin >> s;
    b.resize(n+1);
    w.resize(n+1);

    b[0] = 0;
    w[0] = 0; 
    for (int i = 0; i < n; i++){
        if (s[i] == '.'){
            b[i+1] = b[i];
            w[i+1] = w[i] + 1; 
        }        
        if (s[i] == '#'){
            b[i+1] = b[i] + 1;
            w[i+1] = w[i];
        }
    }

    int black = b[n];
    int white = w[n];

    int min_i = INF;
    for (int bound = 0; bound < n; bound++){
        int cnt = 0;
        cnt += b[bound];
        cnt += white - w[bound+1];

        min_i = min(min_i,cnt);
    }

    cout << min_i << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

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

  vector<int> p(n);
  rep(i,n) cin >> p.at(i);

  sort(p.begin(), p.end());

  bool flag = false;
  int s_ans=x;
  int l_ans=x;
  while(!flag){
    bool s=true, l=true;
    rep(i,n){
      if(p.at(i)==s_ans) s=false;
      if(p.at(i)==l_ans) l=false;
    }
    if(s){
      cout << s_ans;
      return 0;
    }else{
      s_ans--;
    }
    if(l){
      cout << l_ans;
      return 0;
    }else{
      l_ans++;
    }
  }
}

Measured memory_bytes: 3624
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;

int max(int a,int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}

int main() {
	int n;
	int x;
	int a[110];

	cin >> n >> x;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);

	int count = 0;
	bool t = false;
	rep(i, n) {
		x -= a[i];
		if (i == n - 1 && x > 0) {
			count--;
		}
		if (x < 0) {
			break;
		}
		else {
			++count;
		}
	}
	cout << count << endl;

}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { if (i) os << " "; os << v[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a - mod; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
      solve();
    }
}


void solve() {
  int n, m, d;
  cin >> n >> m >> d;

  int tmp = n - d;
  if (d) tmp *= 2;
  cout << fixed << setprecision(7) << 1.0 * tmp / n / n * (m - 1) << endl;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vl sc(n);
  vl c(n);
  vector<vl> edge(n,vl(0));
  REP(i,n-1){
    ll ai,bi;
    cin >> ai >> bi;
    ai--;
    bi--;
    edge[ai].push_back(bi);
    edge[bi].push_back(ai);
  }
  ll m = 0;
  REP(i,n) cin >> c[i], m+=c[i];
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  m -= c[0];
  vector<bool> visited(n,false);
  queue<ll> que;
  que.push(0);
  visited[0] = true;
  ll cnt = 0;
  while(!que.empty()){
    ll nd = que.front();
    sc[nd] = c[cnt++];
    que.pop();
    REP(i,edge[nd].size()){
      if(!visited[edge[nd][i]]){
        que.push(edge[nd][i]);
        visited[edge[nd][i]] = true;
      }
    }
  }

  cout << m << endl;
  REP(i,n){
    cout << sc[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1152
#include<iostream>

using namespace std;

int main() {

	string S;
	cin >> S;

	bool flag = false;

	if ((S[0] == 'h' && S.length() == 1) || S.length() %2==1) {
		cout << "No";
		return 0;
	}

	for (int i = 0; i < S.length(); ++i)
	{
		if (i % 2 == 0 && S[i] != 'h') {
			flag = true;
		}
		else if (i % 2 == 1 && S[i] != 'i') {
			flag = true;
		}
	}

	if (flag) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}

	return 0;
}

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

using namespace std;

int main() {
    int n, m;

    cin >> n >> m;

    vector<string> a(n), b(m);

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

    for (int i=0; i<m; i++) {
        cin >> b[i];
    }

    for (int i=0; i<n-m+1; i++) {
        for (int j=0; j<n-m+1; j++) {
            bool exist = true;

            for (int k=0; k<m; k++) {
                if(a[k+i].substr(j, m) != b[k]) {
                    exist = false;
                    break;
                }
            }

            if(exist) {
                cout << "Yes" << endl;                
                return 0;
            }
        }
    }

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


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 998244353;
const ll INF = (ll) 1e15;

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0 || r < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

ll dp[3005][3005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    Combination cmb(C * D + 5);
    memset(dp, 0, sizeof(dp));
    dp[A][B] = 1;
    FOR(i, C, A) {
        dp[i + 1][B] = dp[i][B] * cmb.get(B, 1LL) % MOD;
    }
    FOR(i, D, B) {
        dp[A][i + 1] = dp[A][i] * cmb.get(A, 1LL) % MOD;
    }
    FOR(i, C, A) {
        FOR(j, D, B) {
            //! (i+1,j+1)に塗らない
            ll x = (MOD + dp[i][j + 1] - (dp[i][j] * i) % MOD) % MOD;
            ll y = (MOD + dp[i + 1][j] - (dp[i][j] * j) % MOD) % MOD;
            ll p = (x * j + y * i + dp[i][j] * i * j) % MOD;
            dp[i + 1][j + 1] += p;
            //! (i+1,j+1)に塗る
            dp[i + 1][j + 1] += (MOD + dp[i + 1][j] + dp[i][j + 1]) % MOD;
            dp[i + 1][j + 1] %= MOD;

        }
    }

#if false
    for (ll i = C - 1; i >= 0; --i) {
        REP(j, D) {
            cout << dp[i + 1][j + 1] << " ";
        }
        cout << endl;
    }
#endif

    cout << dp[C][D] << endl;

    return 0;
}

Measured memory_bytes: 214344
import sys
sys.setrecursionlimit(10**6)

def dfs(v, u, k):
    for i in d[v]:
        if i[0] == u:
            continue
        kkyori[i[0]] = k + i[1]
        dfs(i[0], v, k + i[1])

N = int(input())
d = [[] for _ in range(N)]
for i in range(N - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a].append((b, c))
    d[b].append((a, c))
kkyori = [0] * N

Q, K = map(int, input().split())
dfs(K - 1, -1, 0)
for i in range(Q):
    x, y = map(int, input().split())
    print(kkyori[x - 1] + kkyori[y - 1])

Measured memory_bytes: 135600
R = 101
while 1:
	n,S = map(int,raw_input().split())
	if n == 0: break
	d = [int(raw_input()) for i in range(n)]
	r = [0]*R
	for i in set(d): r[i] = d.count(i)
	ans = 0
	for i in range(R):
		if 2*i > S:
			ans += r[i]*(r[i]-1)/2
		ans += r[i]*sum([r[j] for j in range(max(i+1,S-i+1),R)])
	print ans

Measured memory_bytes: 4464
#include <stdio.h>
int main(void){
  int n,i,j,tmp,x,y;
  int a[100];
  x=0; y=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
  }
  for(i=1;i<n;i++){
    for(j=i+1;j<=n;j++){
	  if(a[i] < a[j]){
	    tmp=a[i];
	    a[i]=a[j];
	    a[j]=tmp;
	  }
	}
  }
  for(j=1;j<=n;j++){
    if(j%2 == 1){
	  x=x+a[j];
	}
	else{
	  y=y+a[j];
	}
  }
  printf("%d",x-y);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<list>
#include<algorithm>
using namespace std;

int main(){
  
  int q, command, x, d;
  list<int> L;
  list<int>::iterator it = L.end();
  
  cin >> q;
  for(int i = 0;i < q;i++){
    cin >> command;
    if(command == 0){
      cin >> x;
      it = L.insert(it, x);
    }else if(command == 1){
      cin >> d;
      if(d > 0) for(int i = 0;i < d;i++) ++it;
      else for(int i = 0;i < -d;i++) --it;
    }else if(command == 2){
      it = L.erase(it);
    }
  }
  
  for(it = L.begin();it != L.end();it++) cout << *it << endl;
  
  return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int A, B;
  cin >> A >> B;
  cout << (A + B) % 24 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

signed main() {
    int n;
    cin>>n;
    unordered_set<string> vs;
    rep(i,n) {
        string s;
        cin>>s;
        vs.insert(s);
    }
    cout<<vs.size();
    return 0;
}

Measured memory_bytes: 17732
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll n,k;cin>>n>>k;
  vector<ll>P(n);
  vector<ll>C(n);
  rep(i,n)cin>>P[i];
  rep(i,n)--P[i];
  rep(i,n)cin>>C[i];

  ll ans=-INF;

  if(k<n){
    ll ans=0;
    rep(s,n){
      ll now=s;
      ll num=0;
      rep(i,k){
        num+=C[now];
        now=P[now];
        chmax(ans,num);
      }
    }
  }

  rep(s,n){
    vector<ll>point(n+1,0);
    vector<bool>seen(n,false);
    ll now=s;
    ll loop=0;
    while(1){
      seen[now]=true;
      point[loop+1]=point[loop]+C[now];
      now=P[now];
      loop++;
      if(seen[now])break;
    }
    // cout<<s<<" "<<loop<<" "<<point<<endl;
    ll num=0;
    if(point[loop]>0){
      num=k/loop * point[loop];
      ll x=k- k/loop*loop;
      rep(i,x+1){
        chmax(ans,num+point[i]);
      }

      num=(k/loop - 1)* point[loop];
      x=k- k/loop*loop +loop;
      rep(i,n+1){
        chmax(ans,num+point[i]);
      }
    }else{
      rep(i,n){
        chmax(ans,point[i+1]);
      }
    }

  
    
  }

  // if(ans==0){
  //   ans=-INF;
  //   rep(i,n){
  //     chmax(ans,C[i]);
  //   }
  // }

  cout<<ans<<endl;


  return false;
}

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


Measured memory_bytes: 3736
N = int(input())
suits = ["S", "H","C","D"]
cards = []

for _ in range(N):
    s,n = input().split()
    if s == "S":
        cards.append(int(n))
    if s == "H":
        cards.append(int(n)+13)
    if s == "C":
        cards.append(int(n)+26)
    if s == "D":
        cards.append(int(n)+39)
    
for i in range(1,53):
    if i not in cards: 
        print(suits[(i-1)//13],(i-1)%13+1)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;


int main() {
    int l,r,d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l;i<=r;i++){
        if(i%d==0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

fn main() {
    input! {
        n:usize,
       mut a:[i64;n],
    }
    let mut ans = 1i64;
    let mut dis = 0i64;
    let mut prev = a[0];
    let mut flg = true;
    // a.push(a[n - 1]);
    for i in 0..n {
        // if flg {
        //     dbg!(i, a[i]);
        //     ans += 1;
        //     flg = false;
        //     dis = 0;
        // }
        if dis == 0 {
            if prev < a[i] {
                dis = 1;
            } else if prev > a[i] {
                dis = -1;
            }
        } else if dis == 1 {
            if prev > a[i] {
                // flg = true;
                dis = 0;
                ans += 1;
            } else {
            }
        } else if dis == -1 {
            if prev < a[i] {
                ans += 1;
                // flg = true;
                dis = 0;
            } else {
            }
        }
        prev = a[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 3636
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;
int up(int u) {
  int a = 0;
  while (u) {
    a = u % 10;
    u /= 10;
  }
  return a;
}
lli dp[10][10];
lli f(int ue, int shi, int N) {
  lli ans = 0;
  if (dp[ue][shi] != -1)
    return dp[ue][shi];
  if (shi == 0)
    return 0;
  if (shi == ue && shi <= N)
    ans++;
  if (10 * shi + ue <= N)
    ans++;

  string pp = to_string(shi);
  rep(i, 10) {
    if (i)
      pp += "0";
    for (int j = 0; j <= N; j++) {
      if (pp.size() + to_string(j).size() > 7)
        break;
      string s = pp + to_string(j) + to_string(ue);
      if (stoi(s) <= N) {
        ans++;
      } else {
        break;
      }
    }
    // for (int j = 2; j <= N; j++) {
    //   string l = "";
    //   rep(p, j) l += "0";
    //   string s = to_string(shi) + l + to_string(ue);
    //   cout << s << endl;
    //   if (stoi(s) <= N) {
    //     ans++;
    //   } else {
    //     break;
    //   }
    // }
  }
  dp[ue][shi] = ans;
  return ans;
}
void calc(long long N) {
  lli ans = 0;
  for (int i = 1; i <= N; i++) {
    int ue = up(i);
    int shi = i % 10;
    ans += f(ue, shi, N);
  }
  cout << ans << endl;
}
void solve(long long N) {}

int main() {
  int a;
  long long N;
  rep(i, 10) rep(j, 10) dp[i][j] = -1;
  scanf("%lld", &N);
  calc(N);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()	
{
	int a[26],b[26];
	for(int i=0;i<26;i++)
	{
		a[i]=-1;
		b[i]=-1;
	}
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.length();i++)
	{
		if(a[s[i]-'a']<0)a[s[i]-'a']=t[i]-'a';
		else
		{
			if(a[s[i]-'a']==t[i]-'a')continue;
			else
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
		if(b[t[i]-'a']<0)b[t[i]-'a']=s[i]-'a';
		else
		{
			if(b[t[i]-'a']==s[i]-'a')continue;
			else
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define int ll
#define Endl endl

signed main(){
    int N;
    int u[114514],v[114514],w[114514];
    vector<pair<int,int>> G[114514];
    cin >> N;
    REP(i,N){
        cin >> u[i] >> v[i] >> w[i];
        w[i]%=2;
        u[i]--;v[i]--;
        G[u[i]].push_back({v[i],w[i]});
        G[v[i]].push_back({u[i],w[i]});
    }
    int Ans[114514]={};
    int mode=0;
    
    bool al[214514]={};
    
    pair<int,int> mx={0,0};
    vector<pair<int,int>> Q;
    
    Q.push_back(mx);
    Ans[0]=0;
    while(!Q.empty()){
        pair<int,int> top=Q[(Q.size())-1];
        Q.pop_back();
        int f=top.first;
        int s=top.second;
        //cout << f << " " << s << endl;
        al[f]=1;
        mode = (Ans[f]+s)%2;
        REP(i,G[f].size()){
            if(al[G[f][i].first]==0){
                Q.push_back(G[f][i]);
                Ans[G[f][i].first]=(Ans[f]+G[f][i].second)%2;
                
            }
        }
    }
    
    REP(i,N){
        cout << Ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,T;cin>>N>>T;
    int a = 1001;
    for(int i = 0;i < N;i++){
        int c,t;cin>>c>>t;
        if(t <= T){
            if(c < a){
                a = c;
            }
        }
    }
    if(a == 1001){
        cout<<"TLE"<<endl;
    }else{
        cout<<a<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	int[] a;
	int n=1;
	public static void main(String[] args){
		Main test = new Main();
		Scanner inputScanner = new Scanner(System.in).useDelimiter("\\s");
		int n1 = inputScanner.nextInt();
		int q = inputScanner.nextInt();
		
		
		while (test.n < n1){
			test.n *= 2;
		}
	//	System.out.println(Integer.toString(test.n));
		test.a = new int[(2 * test.n)-1 ]; 
	//	System.out.println(test.a.length);
		for(int i=0;i<test.a.length;i++){
			test.a[i]=Integer.MAX_VALUE;
		}
		
		
		
		
		int cmd=-1;
		int arg1;
		int arg2;
		for(int j =0;j<q;j++){
			cmd = inputScanner.nextInt();
			arg1=inputScanner.nextInt();
			arg2=inputScanner.nextInt();
			
			if(cmd ==0)
				test.update(arg1, arg2);
			else if(cmd ==1)
				System.out.println(test.findMin(arg1, arg2));
		}
	}
	
	public void update(int k, int b){
		k += (n-1);
		a[k] = b;
		while(k > 0){
			k = (k-1)/2;
			a[k] = Integer.min(a[(k*2)+1], a[(k*2)+2]);
		}
	}
	
	public int findMin(int b, int c){
		
		return query(b,c+1,0,0,n);
	}
	
	public int query(int b, int c, int k, int l, int r){
		if (r <= b || c <= l)
			return Integer.MAX_VALUE;
		if((b<=l && r<=c))
			return a[k];
		
		int o1 = query(b,c,(k*2)+1,l,(l+r)/2);
		int o2 = query(b,c,(k*2)+2,(l+r)/2,r);
		return Integer.min(o1, o2);	
	}
}



Measured memory_bytes: 109608
import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, Q = map(int, input().split())
# L = [int(v) for v in input().split()]
# L = [int(input()) for _ in range(Q)]
# S = input().strip()

if N == M:
    if N % Q == 0:
        print(1)
    else:
        print(0)
    exit()

p = (M // Q) + 1
s = (N // Q)

print(p - s - (0 if N % Q == 0 else 1))

Measured memory_bytes: 3316
N = int(input())
C = [int(input()) for _ in range(N)]
MOD = 10**9 + 7
subC = [-2] * (2 * 10 ** 5 + 10)
cntC = [-1]*N
for num, i in enumerate(C):
    cntC[num] = subC[i]+1
    subC[i] = num

# print(cntC)

dp = [0] * (N + 10)
dp[0] = 1
for i in range(N):
    if cntC[i] < 0 or cntC[i] == i:
        dp[i + 1] = dp[i] % MOD
    else:
        dp[i + 1] = (dp[i] + dp[cntC[i]]) % MOD


print(dp[N])

Measured memory_bytes: 26752
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		// 初期化
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		// Streamを使用してint配列の作成
		int[] list = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int result=list[0];
		for(int i=1;i<list.length;i++) {
			// ユークリッドの互除法により算出
			result = GCD(result,list[i]);
		}
		System.out.println(result);
	}

	public static int GCD(int a,int b) {
		if(a == 0) {
			return b;
		}
		else {
			return GCD(b%a,a);
		}
	}
}

Measured memory_bytes: 48824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y) {
    if (!a) {*x = 0; *y = 1; return b;}
    ll x1, y1, gcd = gcdEx(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd;
}
ll modI(ll b, ll m)      {ll x, y; gcdEx(b, m, &x, &y); return (x % m + m) % m;}
typedef pair<ll, ll>      pii;
typedef vector<ll>         vi;
typedef vector<pii>         vii;
typedef set<ll>            si;
typedef map<string, ll>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(ll i=b;i<n;i++)
#define loopv(i,b,n,a)         for(ll i=b;i<n;i+=a)
#define loopr(i,b,n)           for(ll i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() ll begtime = clock();
#define end_routine() ll endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(ll)(MOD+((a%MOD)-(b%MOD))%MOD):(ll)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}

#define test int t;cin >>t;while(t--)
int main()
{
    int t;
    t = 1;
    string s;
    cin >> s;

    for (int i = 0; i < 3; i++)
        cout << s[i];

    return 0;
}


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

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

 vector<string> vec(N);
 for(int i=0; i<N; i++) cin >> vec.at(i);

 sort(vec.begin(), vec.end());

 for(int i=0; i<N; i++) cout<<vec.at(i);

 cout <<endl;
}

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

int osum(int x){
  int c=0;
  while(x>0){
    c+=x%10;
    x=x/10;
  }
  return c;
}
 
int main() {
  int N;
  cin >>N;
  int mi=osum(N-1)+1;
  
  for (int i=2;i<N;i++){
    if(mi > osum(i)+osum(N-i))mi=osum(i)+osum(N-i);
  }
  cout << mi<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
  int a, b;
  cin >> a;
  cout<<a*a;
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

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

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

int32 a[33] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 k;
    cin >> k;
    ANS(a[k]);
    return 0;
}

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

Int gcd3(tuple<Int,Int,Int> T) {
  return __gcd(__gcd(get<0>(T),get<1>(T)),get<2>(T));
}

int main(){ 
  Int K, s;
  cin >> K;
  s = 0;
  
  rep(i,K) {
    rep(j,K) {
      rep(k,K) {
        s += gcd3(make_tuple(i+1,j+1,k+1));
      }
    }
  }
  
  cout << s << endl;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<ll>l,r;
int main() {
	ll n,k;
	cin>>n>>k;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		l.push_back(x);
		r.push_back(x);
	}
	reverse(r.begin(),r.end());
	ll ans=0;
	ll tei=min(n,k);
	for(ll i=0;i<=tei;i++){
		for(ll m=0;m<=i;m++){
		ll toru=m;
		ll toru2=i-m;
		ll suteru=k-i;
		ll j=0;
		ll sum=0;
		vector<ll>gomi;
		while(toru!=0&&j<l.size()){
			toru--;
			ll now=l[j];
			j++;
			sum+=now;
			if(now<0){
				gomi.push_back(now);
			}
		}
		j=0;
		while(toru2!=0&&j<r.size()){
			toru2--;
			ll now=r[j];
			j++;
			sum+=now;
			if(now<0){
				gomi.push_back(now);
			}
		}		
		j=0;
		sort(gomi.begin(),gomi.end());
		while(suteru!=0&&j<gomi.size()){
			suteru--;
			ll now=gomi[j];
			j++;
			sum-=now;
		}
		//cout << sum<<endl;
		ans=max(ans,sum);
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

string s;
set<char> a;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>s;
	for(int i=0;i<4;i++){
		a.insert(s[i]);
	}
	if(a.size()==2)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter

N = int(input())
ab = [[] for _ in range(N)]
for i in range(N - 1) :
  a, b = map(int, input().split())
  ab[a-1].append((b-1, i))
  ab[b-1].append((a-1, i))

M = int(input())
uv = [[int(i) for i in input().split()] for _ in range(M)]

cnt = [set() for _ in range(M)]
def dfs(cur, pre, dest, i) :
  if cur == dest :
    return True
  
  for nex, j in ab[cur] :
    if nex == pre :
      continue
    if dfs(nex, cur, dest, i) :
      cnt[i].add(j)
      return True

  return False

for i, (u, v) in enumerate(uv) :
  dfs(u - 1, -1, v - 1, i)

ret = 1 << (N - 1)
for i in range(1, 1 << M) :
  sgn = 1
  s = set([])
  for j in range(M) :
    if i & (1 << j) :
      s |= cnt[j]
      sgn *= -1
  ret += sgn * (1 << (N - 1 - len(s)))

print(ret)

Measured memory_bytes: 42348
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX




 
void solve()
{
    int n,m;
    cin >> n >> m;
    cout << (n*(n-1))/2 + (m*(m-1))/2 << endl;
}   


signed main()
{


  
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r,w;
ll l,ans,sum;
ll num;
ll x[500005],y[500005],z[500005];
double dp[305][305][305];
bool dame,flag,ok;

double solve(ll i,ll j,ll k){
	double m = (double)(i + j + k);
	if(m <= 0.1f){
		return 0.0f;
	}
	double num = n / m;
	if(dp[i][j][k] != -1){
		return dp[i][j][k];
	}
	if(i >= 1){
		num += solve(i-1,j,k) * (double)i / m;
	}
	if(j >= 1){
		num += solve(i+1,j-1,k) * (double)j / m;
	}
	if(k >= 1){
		num += solve(i,j+1,k-1) * (double)k / m;
	}
	dp[i][j][k] = num;
	return num;
}



int main(){
	cin >> n;
	for(i=0;i<n;i++){
		cin >> d;
		if(d == 1)a++;
		if(d == 2)b++;
		if(d == 3)c++;
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			for(k=0;k<=n;k++){
				dp[i][j][k] = -1;
			}
		}
	}
	ps(solve(a,b,c));

	return 0;
}

Measured memory_bytes: 244864
T = "AKIHABARA"

L = []
for a in range(2) :
    if a :
        sa = "A"
    else :
        sa = ""
    for b in range(2) :
        if b :
            sb = "A"
        else :
            sb = ""
        for c in range(2) :
            if c :
                sc = "A"
            else :
                sc = ""
            for d in range(2) :
                if d :
                    sd = "A"
                else :
                    sd = ""
                
                string = sa + "KIH" + sb + "B" + sc + "R" + sd
                L.append(string)

S = input()
if S in L :
    ans = "YES"
else :
    ans = "NO"
print(ans)


Measured memory_bytes: 3064