akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

int *parent, *rank;

void init(int n) {
    for (int i = 0; i <= n; i++) {
        parent[i] = i;
        rank[i] = 0;
    }
}

int root(int x) {
    return parent[x] == x ? x : parent[x] = root(parent[x]);
}

bool same(int x, int y) {
    return root(x) == root(y);
}

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) { return; }

    if (rank[x] < rank[y]) {
        parent[x] = y;
    } else {
        parent[y] = x;
        if (rank[x] == rank[y]) { rank[x]++; }
    }
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    parent = new int[n+1];
    rank = new int[n+1];
    init(n);

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

    for (int i = 0; i < m; i++) {
        int p1, p2;
        scanf("%d %d", &p1, &p2);
        unite(p1, p2);
    }

    int result = 0;
    for (int i = 1; i <= n; i++) {
        result += (i == p[i] || same(i, p[i]));
    }

    printf("%d\n", result);

    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (true) {
			int n = scn.nextInt();
			if (n == 0) {
				break;
			}
			double m = 0;
			int[] s = new int[n];
			for (int i = 0; i < n; i++) {
				s[i] = scn.nextInt();
				m = m + s[i];
			}
			m = m / n;
			double σ = 0;
			for (int i = 0; i < n; i++) {
				σ = σ + (s[i] - m) * (s[i] - m);
			}
			System.out.println(Math.sqrt(σ / n));
		}
	}
}


Measured memory_bytes: 31428
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[6];
    rep(i,1){
        cin >> A[i];
    }
    //sort(A,A+3);
    cout << A[0]*800-(A[0]/15)*200 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
template<typename T>
map<T,ll> factorize(T x){
	map<T,ll> res;
	for(ll i=2;i*i<=x;i++){
		while(x%i==0){
			x/=i;
			res[i]++;
		}
	}
	if(x!=1) res[x]++;
	return res;
}
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
  init();
  ll n,m;
  cin>>n>>m;
  mint ans=1;
  map<ll,ll>mp=factorize(m);
  for(auto p:mp){
      ans*=COM(p.se+n-1,p.se);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 47104
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const int BITSIZE = 100010;

//1-indexed

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int q; cin >> q;
    list<ll> lst;
    auto itr=lst.begin();
    REP(i, q){
        int a; cin >> a;
        if(a==0){
            int b; cin >> b;
            itr=lst.insert(itr, b);
        }
        if(a==1){
            int d; cin >> d;
            if(d<0){
                REP(i, abs(d)){
                    itr--;
                }
            }else{
                REP(i, d){
                    itr++;
                }
            }
        }
        if(a==2){
            itr=lst.erase(itr);
        }
    }
    for(auto itr=lst.begin(); itr!=lst.end(); ++itr){
        cout << *itr << endl;
    }
	return 0;
}


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

int main(){
 
  long long N, K, i, j, cnt = 0, a, b, _K;
  cin >> N >> K;
  vector<long long> A(N), H(N, 0);
  
  for(i = 0; i < N; i++){
    cin >> A.at(i);
    A.at(i)--;
  }
  
  i = 0;
  a = 0;
  while(H.at(a) == 0){
    
    H.at(a) = 1;
    a = A.at(a);
    i++;
  }
  
  j = 0;
  b = 0;
  while(b != a){
    
    b = A.at(b);
    j++;
  }
  
  a = 0;
  
  if(K - j < 0){
    _K = K;
  }else{
    _K = ((K - j) % (i - j)) + j;
  }
  
  for(long long k = 0; k < _K; k++){
    
    a = A.at(a);
  }
  
  cout << a + 1 << endl;
  return 0;
}

Measured memory_bytes: 6376
a,b,c,d,e,f=map(int,input().split())
x=1
y=-1
for i in range(0,f+1,a*100):
    for j in range(0,f+1-i,b*100):
        s=min(f-i-j,(i+j)*e//100)
        if i+j==0:
            continue
        else:
            for p in range(0,s+1,c):
                for q in range(0,s+1-p,d):
                    if y/x<=(p+q)/(i+j):
                        y=p+q
                        x=i+j
print(x+y,y)

Measured memory_bytes: 3064
program main
  implicit none
  integer(8) :: n, i, to, res, mi
  integer(8), allocatable :: a(:)
  read(*, *) n
  allocate(a(n))
  read(*, *) (a(i), i = 1, n)

  mi = huge(0_8)
  do to = -100, 100
    res = 0
    do i = 1, n
      res = res + (a(i) - to) ** 2
    end do
    mi = min(mi, res)
  end do

  write(*, "(i0)") mi

  deallocate(a)
  contains
end


Measured memory_bytes: 256
st = input()
q = int(input())

for _ in range(q):
    rule = list(map(str,input().split()))
    a,b = int(rule[1]), int(rule[2])
    if rule[0] == "print":
        print(st[a:b+1])
    elif rule[0] == "reverse":
        st = st[:a] + st[a:b+1][::-1] + st[b+1:]
    else:
        st = st[:a] + rule[3] + st[b+1:]



Measured memory_bytes: 5612
import sys
nums = input()
a = nums[0] 
b = nums[2]
c = nums[4]

if a == b:
    if b == c:
        print("No")
    else:
        print("Yes")
else:
    if b == c:
        print("Yes")
    elif a == c:
        print("Yes")
    else: 
        print("No")
    

Measured memory_bytes: 2940
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        A: [u128; N],
    }

    let zero = A.iter().filter(|&&a| a == 0).count();

    if zero > 0 {
        println!("0");
        return;
    }

    let mut prd = 1;
    let mx = 10u128.pow(18);
    for &a in &A {
        prd *= a;
        if prd > mx {
            println!("-1");
            return;
        }
    }
    println!("{}", prd);
}


Measured memory_bytes: 5304
def main():
    ans = 0
    n, k = map(int, input().split())
    for i in range(1,n+1):
        temp = 1/n
        eye = i
        while(eye < k):
            eye *= 2
            temp /= 2
        ans += temp
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int n,m,i,j,k,x[110],y[110],s[110],t[110],a,b,h,w;
  scanf("%d",&m);
  while(m--){
    int d[20][20]={0};
    scanf("%d %d %d",&w,&h,&n);
    for(i=0;i<n;i++)scanf("%d %d %d %d",&x[i],&y[i],&s[i],&t[i]);
    //for(i=0;i<=h;i++)d[i][0]=1;
    //for(i=0;i<=w;i++)d[0][i]=1;
    d[0][0]=1;
    for(i=0;i<=h;i++){
      for(j=0;j<=w;j++){
	a=b=1;
	for(k=0;k<n;k++){
	  if(y[k]+t[k]==i+i+1&&x[k]+s[k]==j+j  )a=0;
	  if(y[k]+t[k]==i+i  &&x[k]+s[k]==j+j+1)b=0;
	  }//*/
	d[i+1][j]+=d[i][j]*a;
	d[i][j+1]+=d[i][j]*b;
      }
    }
    d[h][w]?printf("%d\n",d[h][w]):printf("Miserable Hokusai!\n");
  }
  return 0;
}

Measured memory_bytes: 612
n, t = map(int, input().split())
ct = [list(map(int, input().split())) for i in range(n)]
ans = 10 ** 10
cnt = 0
for i in range(n):
  if ct[i][1] <= t:
    ans = min(ans, ct[i][0])
    cnt += 1
if cnt > 0:
  print(ans)
else:
  print("TLE")

Measured memory_bytes: 9108
#include <iostream>
#include <vector>
using namespace std;
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<int> h(n+5);
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    vector<int> l[n+5];
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        l[a].push_back(b);
        l[b].push_back(a);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        bool flag=true;
        for(int j=0;j<l[i].size();j++){
            if(h[i]<=h[l[i][j]]){
                flag=false;
            }
        }
        if(flag){
            ans++;
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 8708
#include <iostream>
#include <set>
#include <map>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    multiset<int> nums;
    map<int, int> bc;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        nums.insert(a);
    }
    for (int i = 0; i < m; i++){
        int b, c;
        cin >> b >> c;
        bc[c] += b;
    }
    for (auto itr = bc.rbegin(); itr != bc.rend(); ++itr){
        int flag = 0;
        for (int j = 0; j < itr->second; j++){
            if (*nums.begin() >= itr->first){
                flag = 1;
                break;
            }
            nums.erase(nums.begin());
            nums.insert(itr->first);
        }
        if (flag == 1) break;
    }
    long long ans = 0;
    for (const int num : nums){
        ans += num;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9600
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

Rec = []
Chk = []

# (V-C)＋(V-C)..の結果を１つずつ見て一番高いものを記録
# 宝石ループ
work = None
for i in range(0, N):
    for j in range(0, N):
        if not(j in Chk) and (work == None or work < V[j] - C[j]):
            work = V[j] - C[j]
            work2 = j
    Chk.append(work2)
    if len(Rec) > 0:
        Rec.append(Rec[i - 1] + work)
    else:
        Rec.append(work)
    work = None

if max(Rec) > 0:
    print(max(Rec))
else:
    print('0')

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

int main() {
  double a;
  double b;
  double mean;
  int intmean;
  double dif;
  int ans;
  cin >> a >> b;
  mean = (a + b) / 2;
  intmean = mean;
  dif = mean - intmean;
  ans = intmean + (dif * 2);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007 //1e9 + 7
#define nl cout<<"\n"
// #define out cout
// #define tf cin
#define s second
#define f first
#define fr(i, n) for(int i = 0; i<n; i++)
#define lr(i, n) for(int i = n-1; i>=0; i--)
#define frr(i, j, n) for(int i = j; i<n; i++)
#define set_val -1
#define Mem(x) memset(x, set_val, sizeof(x))
#define print(x) for(auto xx: x)cout<<xx<<" "
#define FIO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
typedef long double lld;

int main(){
    lli a, b, c, d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c, max(a*d, max(b*c, b*d)));
}

Measured memory_bytes: 3628
#include<cstdio>
#include<complex>
#include<cmath>
using namespace std;
typedef complex<double> xy_t;
int main()
{
  xy_t P[110];
  int N = 0;
  double x,y;
  while(~scanf("%lf,%lf",&x,&y)){
    P[N++] = xy_t(x,y);
  }
  double sum = 0.0;
  for(int i = 0; i + 2 < N; ++i){
    xy_t a = P[0],b = P[i + 1],c = P[i + 2]; 
      sum += (conj(b - a) * (c - a)).imag();
  }
  sum /= 2;
  printf("%.6f\n",abs(sum));
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N;
string S;
cin >> N >> S;

if (N%2 == 1) cout << "No\n";
else if (S.substr(0, N/2) == S.substr(N/2, N)) 
    cout << "Yes\n";
else cout << "No\n";

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
N = int(input()) 
e=[0]*(N+1)
for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j
def num(m):
    return len(list(filter(lambda x: x >= m-1, e)))
print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1)+ num(5) * (num(5) - 1) * (num(3) - 2) // 2) 


Measured memory_bytes: 38512
//c problem
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=200000+10;
const int mod=1e9+7;
ll n,m,a,b;
ll quick(ll a,ll b,ll mod){
	ll res=1,t=a;
	while(b){
		if(b&1)res=(res*t)%mod;
		t=(t*t)%mod;
		b>>=1;
	}
	return res;
}
ll jie[N],inv[N];
void chu(){
	jie[0]=inv[0]=1;
	for(int i=1;i<N;i++)jie[i]=(jie[i-1]*i)%mod,inv[i]=quick(jie[i],mod-2,mod);
}
ll c(ll a,ll b){
	return ((jie[b]*inv[a])%mod*inv[b-a])%mod;
}
int main()
{
	chu(); 
	ll a,b,n,m;
	cin>>n>>m>>a>>b; 
	ll ans=0;
	for(int i=1;i<=n-a;i++){
		ll ans1=c(b-1,b+i-2); 
		ll ans2=c(m-b-1,n-i+m-b-1);
		ans=(ans+ans1*ans2)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6720
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VL T(N),A(N);
  rep(i,N) cin>>T[i]>>A[i];
  rep(i,N-1){
    ll tmp=T[i+1];
    ll tmp2=A[i+1];
    ll X=max((T[i]+tmp-1)/tmp,(A[i]+tmp2-1)/tmp2);
    T[i+1]=X*tmp;
    A[i+1]=X*tmp2;
  }
  cout<<T[N-1]+A[N-1]<<endl;
}

Measured memory_bytes: 256
//  Created by Sengxian on 2017/6/4.
//  Copyright (c) 2017年 Sengxian. All rights reserved.
//  AtCoder Grand Contest 015D 二进制 + 思维
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
	ll A, B;
	cin >> A >> B;
	if (A == B) return puts("1"), 0;
	int r = 0, k = -1;
	for (int i = 60; i >= 0; --i) {
		if ((A >> i & 1) != (B >> i & 1)) {
			r = i;
			break;
		}
		A &= ~(1LL << i);	
		B &= ~(1LL << i);	
	}
	for (int i = r - 1; i >= 0; --i)
		if (B >> i & 1) {
			k = i;
			break;
		}
	// [A, 2^r)
	// [2^r, 2^r + 2^{k + 1})
	// [2^r + A, 2^{r + 1})
	ll intersection = max(0LL, (1LL << r) + (1LL << (k + 1)) - ((1LL << r) + A));
	printf("%lld\n", (1LL << r) - A + (1LL << (k + 1)) + (1LL << r) - A - intersection);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  ll n, k;
  cin >> n >> k;
  vector<vector<ll>> a(n, vector<ll>(2));
  for(int i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1];
  }
  sort(a.begin(), a.end());
  ll cnt = 0;
  for(ll i = 0; i < n; i++){
    cnt += a[i][1];
    if(cnt >= k){
      cout << a[i][0] << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n; string s;
  cin >> n >> s;
  
  vector<int> l(26),r(26);
  rep(i,n) r[s[i]-'a']++;
  int ans = 0;
  for(int i=0; i<n-1; ++i){
    r[s[i]-'a']--;
    l[s[i]-'a']++;
    int res = 0;
    rep(c,26) if(l[c]>0&&r[c]>0) ++res;
    ans = max(ans,res);
  }
  cout << ans << endl;
}


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

ll pow(int x, int y) {
  ll tmp = 1;
  rep(i, y) tmp*=x;
  return tmp;
}

int main() {
  int n,k; cin>>n>>k;
  ll ans=k*pow(k-1, n-1);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n), sum(n+1, 0);

  rep(i, n) {
    cin >> a[i];
    sum[i + 1] += (sum[i] + a[i]) % m;
  }
  map<ll, ll> mp;
  for (int i = 1; i <= n; ++i) {
    mp[sum[i]] += 1;
  }
  ll ans = 0;
  for (auto itr : mp) {
    if (itr.first == 0) {
      itr.second += 1;
    }

    ans += (itr.second * (itr.second - 1)) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define incant() cin.tie(0), ios::sync_with_stdio(false)
#define int long long
#define uint unsigned long long
#define double long double
using str = string;
template <class T> using vec = vector<T>;
template <class T> using vvec = vec<vec<T>>;
template <class T> using que = queue<T>;
template <class T> using pque = priority_queue<T>;
template <class... T> using tup = tuple<T...>;
using vint = vec<int>;
using vvint = vvec<int>;
using vstr = vec<str>;
using pint = pair<int, int>;
using vp = vec<pint>;
using tll = tup<int, int, int>;
using vt = vec<tll>;
using mint = map<int, int>;
using dict = map<str, int>;
using qint = que<int>;
using qp = que<pint>;
using pqint = pque<int>;
using pqp = pque<pint>;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fir first
#define sec second
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define sz(x) x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define ms(v, x) memset(v, x, sizeof v)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload3(__VA_ARGS__, revi, _rev,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) out(x), indent()
#define debug(x) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n'
#define YN(x) print((x) ? "YES" : "NO")
#define Yn(x) print((x) ? "Yes" : "No")
#define yn(x) print((x) ? "yes" : "no")
#define POS(x) print((x) ? "POSSIBLE" : "IMPOSSIBLE")
#define Pos(x) print((x) ? "Possible" : "Impossible")
#define pos(x) print((x) ? "possible" : "impossible")
int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
const int INF = 1e16, MOD = 1e9 + 7;
const int dx4[] = {-1, 0, 1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const double EPS = 1e-9;
const str alphabet = "abcdefghijklmnopqrstuvwxyz";
int n, m, x, y, z, w, h;
str s, t;

signed main(){
    incant();
    while(cin >> n >> m){
        int res = 0, cnt = 0, mx = -INF, mn = INF, a[] = {}, b[] = {}, c[m + 1] = {};
        bool flag = true;
        rep(i, n){
            cin >> x;
            rep(j, x){
                cin >> y;
                c[y]++;
            }
        }
        each(i, c){
            if(i == n){
                res++;
            }
        }
        print(res);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int h, w;
struct lamp{
    char c;
    int up, down, left, right;
};
lamp s[2000][2000] = {0};

int main()
{
    int ans = 0, k = 0;
    string t;
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        cin >> t;
        for(int j = 0; j < w; j++){
            s[i][j].c = t[j];
        }
    }

    /* --- 左右を照らす数 --- */
    for(int i = 0; i < h; i++){
        int kl = 0, kr = 0;
        for(int j = 0; j < w; j++){
            if(s[i][j].c == '#') kr  = 0;
            else                 kr += 1;
            if(s[i][w-1-j].c == '#') kl  = 0;
            else                   kl += 1;
            s[i][j].right = kr;
            s[i][w-1-j].left  = kl;
        }
    }
    /* --- 上下を照らす数 --- */
    for(int j = 0; j < w; j++){
        int ku = 0, kd = 0;
        for(int i = 0; i < h; i++){
            if(s[i][j].c == '#') kd = 0;
            else                 kd += 1;
            if(s[h-1-i][j].c == '#') ku  = 0;
            else                   ku += 1;
            s[i][j].down = kd;
            s[h-1-i][j].up  = ku;
        }
    }

    /* --- スキャン --- */
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            k = s[i][j].left + s[i][j].right + s[i][j].up + s[i][j].down - 3;
            ans = (ans < k ? k : ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 78336
main :: IO()
main = do
    astr <- getLine
    bstr <- getLine
    cstr <- getLine
    putStrLn $ [getsolve astr bstr cstr 'a']


getsolve :: String -> String -> String -> Char -> Char
getsolve astr bstr cstr 'a'
    | astr == []			= 'A'
    | otherwise				= getsolve (tail astr) bstr cstr (head astr)

getsolve astr bstr cstr 'b'
    | bstr == []			= 'B'
    | otherwise				= getsolve astr (tail bstr) cstr (head bstr)

getsolve astr bstr cstr 'c'
    | cstr == []			= 'C'
    | otherwise				= getsolve astr bstr (tail cstr) (head cstr)




Measured memory_bytes: 508
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> ivv;

int main()
{
	int n,a,b,c,x;
	
	while(cin >> n >> a >> b >> c >> x,n)
	{
		int target[n];
		
		REP(i,n)cin >> target[i];
		
		int _count = 0,ret = -1;
		while(_count != n)
		{
			ret++;
			if(x == target[_count])
			{
				_count++;
			}
			
			x = (a * x + b) % c;
			if(ret > 10000)break;
		}
		if(ret <= 10000)
			cout << ret << endl;
		else
			cout << -1 << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 2976
#include <iostream>
#define N 100
using namespace std;
main () {
	int r, c, a[N+1][N+1] = {};
	cin >> r >> c;
	for (int i=0; i<r; i++) for (int j=0; j<c; j++) cin >> a[i][j];
	for (int i=0; i<r; i++) {
		for (int j=0; j<c; j++) {
			a[i][c] += a[i][j];
			a[r][j] += a[i][j];
		}
	}
	for (int i=0; i<r; i++) a[r][c] += a[i][c];

	for (int i=0; i<=r; i++) {
		cout << a[i][0];
		for (int j=1; j<=c; j++) cout << " " << a[i][j];
		cout << endl;
	}
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

template<typename T,typename F,typename G>
class segtree {
    int n;
    vector<T> val;
    T def;
    F merge;
    G _update;
    T _query(int a,int b,int k,int l,int r) {
        if(b <= l || r <= a) return def;
        if(a <= l && r <= b) return val[k];
        T t1 = _query(a,b,2*k+1,l,(l+r)/2);
        T t2 = _query(a,b,2*k+2,(l+r)/2,r);
        return merge(t1,t2);
    }

public:
    segtree(int _n,vector<T> init,T def,
            F merge,G update)
            :def(def),merge(merge),_update(update) {
        n = 1;
        while(n < _n) n *= 2;
        val = vector<T>(2*n-1,def);
        rep(i,_n) val[i+n-1] = init[i];
        rrep(i,n-1) val[i] = merge(val[i*2+1],val[i*2+2]);
    }
    void update(int i,T x) {
        i += n-1;
        val[i] = _update(val[i],x);
        while(i > 0) {
            i = (i-1)/2;
            val[i] = merge(val[i*2+1],val[i*2+2]);
        }
    }
    // segment [a,b)
    T query(int a,int b) {
        return _query(a,b,0,0,n);
    }
    T operator[](int i) const { return val[i]; }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,q;
    string s;
    cin >> n >> s >> q;
    auto generate = [](char c) {
        bitset<26> b;
        b[c-'a'] = 1;
        return b;
    };
    vector<bitset<26>> init(n);
    rep(i,n) init[i] = generate(s[i]);
    auto f = [](auto a,auto b){ return a|b; };
    auto g = [](auto a,auto b){ return b; };
    segtree<bitset<26>,decltype(f),decltype(g)> st(n,init,bitset<26>(0),f,g);
    rep(j,q) {
        int k;
        cin >> k;
        if(k == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            st.update(i,generate(c));
        } else {
            int l,r;
            cin >> l >> r;
            l--;
            cout << st.query(l,r).count() << endl;
        }
    }
}

Measured memory_bytes: 16924
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int S;
    cin >> S;
    int s[5];
    rep(i,4) {
        s[i] = S%10;
        S = S/10;
    }

    if(((s[3]==1 && s[2]<=2) || (s[3]==0 && s[2]<=9 && s[2]>=1)) && ((s[1]==1 && s[0]<=2) || (s[1]==0 && s[0]<=9 && s[0]>=1))){
        cout << "AMBIGUOUS" << endl;
    }
    else if((s[3]==1 && s[2]<=2) || (s[3]==0 && s[2]<=9 && s[2]>=1)) cout << "MMYY" << endl;
    else if((s[1]==1 && s[0]<=2) || (s[1]==0 && s[0]<=9 && s[0]>=1)) cout << "YYMM" << endl;
    else cout << "NA" << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        # 親の番号 根なら要素数(負の数)

    def find(self, x):
        """木の根を求める"""
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        """xとyの属する集合を併合"""
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        """xとyが同じ集合に属するか否か"""
        return self.find(x) == self.find(y)

    def size(self, x):
        """グループのサイズを返す"""
        return -self.parents[self.find(x)]

N , M = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]
uf = UnionFind(N)
for x, y in xy:
    uf.unite(x - 1, y - 1)
ans = 0

for i in range(N):
    if uf.same(i, p[i] - 1):
        ans += 1

print(ans)


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

const int N = 110000;
int n;
int mi[N];
struct aa {
	int l, r;
	bool used;
} a[N];

bool cmp(aa a, aa b) {
	return a.l < b.l;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d%d", &a[i].l, &a[i].r);
	int minr = 1, maxl = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i].r < a[minr].r)
			minr = i;
		if (a[i].l > a[maxl].l)
			maxl = i;
	}
	a[minr].used = true;
	a[maxl].used = true;

	int ans1 = max(0, a[minr].r - a[maxl].l + 1);
	for (int i = 1; i <= n; i++) {
		if (i != minr && i != maxl)
			ans1 = max(ans1, max(0, a[minr].r - a[maxl].l + 1) + a[i].r - a[i].l + 1);
	}

	int R = a[minr].r;
	int L1 = a[minr].l;
	int L = a[maxl].l;
	mi[n + 1] = a[maxl].r;

	sort(a + 1, a + n + 1, cmp);


	for (int i = n; i; i--) {
		mi[i] = mi[i + 1];
		if (!a[i].used)
			mi[i] = min(mi[i], a[i].r);
	}

	for (int i = 1; i <= n; i++) {
		ans1 = max(ans1, max(0, R - max(L1, a[i].l) + 1) + max(0, mi[i + 1] - L + 1));
	}
	printf("%d\n", ans1);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    vector<bool> dp(k+1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dp[0] = false;
    for (int i=0; i <= k; i++) {
        for (int x : a) {
            if (x <= i && !dp[i-x]) dp[i] = true;
        }
    }
    puts(dp[k]?"First":"Second");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    static int n;
    static int count;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        n = Integer.parseInt(sc.next());
        count = 0;
        
        a("", "7");
        a("", "5");
        a("", "3");
        
        System.out.println(count);
    }
    
    private static void a(String s, String s2){
        
        s += s2;
        if(Long.parseLong(s) > n){
            return;
        }
        
        if(s.contains("7") && s.contains("5") && s.contains("3")){
            count++;
        }
        
        a(s, "7");
        a(s, "5");
        a(s, "3");
    }
}

Measured memory_bytes: 34516
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define inf 99999999
#define itn int
#define NMAX 1000010
int n,k;
int m; 
int t,cnt;
int main(){
    FAST;
    cin>>n>>k;
    vector<vector<int> > v(n+1);
    for(int j=1;j<=k;++j){
      cin>>m;
      while(m--){
          cin>>t;
          v[t].push_back(j);
        }  
    }
    for(int i=1;i<=n;++i){
        if(v[i].empty()) cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3596
//https://atcoder.jp/contests/dp/tasks/dp_e
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};


int main(){
    int N,W;
    cin>>N>>W;
    int X=N*1000+10;
    using V=vector<LL>;
    V dp(X,1e10);
    dp[0]=0;
    for(int i:range(N)){
        V nxt=dp;
        int w,v;
        cin>>w>>v;
        for(int j:range(v,X+1)){
            chmin(nxt[j],dp[j-v]+w);
        }
        swap(dp,nxt);
    }
    int ret=0;
    for(int i:range(X)){
        if(dp[i]<=W)chmax(ret,i);
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 1888
a,b = map(int, input().split())
g_1 =[1,3,5,7,8,10,12]
g_2 = [4,6,9,11]
if (a in g_1 and b in g_1) or (a in g_2 and b in g_2) or (a == 2 and b == 2):
  print('Yes')
else:
  print('No')

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

using namespace std;

#define int long long

signed main(){

  int n;
  int ma = 0, num = 0, maxa = 0;
  vector<int> a;

  cin>>n;

  a.resize(n);

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

  for(int i = 0; i < n; i++){
    if(maxa == a[i]) continue;
    if(min(a[i], maxa - a[i]) > ma){
      ma = min(a[i], maxa - a[i]);
      num = a[i];
    }
  }

  cout<<maxa<<" "<<num<<endl;
  return 0;
}


Measured memory_bytes: 1024
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    a,b,c,d=sorted(list(map(int,input().split())))
    if a==1 and b==4 and c==7 and d==9:
        print("YES")
    else:print("NO")

if __name__=='__main__':
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define rep(i, a, b) for(__typeof(a) i = a;i < b;i++)
#define repo(i, a, b) for(__typeof(a) i = a;i<=b;i++)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define eps 1e-6
#define pi 3.141592653589793
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ca(a) cout << a << "\n";
#define a(a) for(auto i:a) cout << i << " ";
using namespace std;
template<class T> inline T gcd(T a, T b) { while(b) b ^= a ^= b ^= a %= b; return a; }
template<class T> inline T mod(T x) { if(x < 0) return -x; else return x; }
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII > PPII;
typedef vector< PII > VPII;
typedef vector< PPII > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main(){
     ll n;
     cin>>n;
     double ans=1,a[n],sum=0;
     rep(i,0,n) {cin>>a[i];ans*=a[i];}
    // cout<<ans;
     rep(i,0,n){
         sum+=ans/a[i];
         //cout<<sum<<" ";
     }
     //cout<<sum;
     cout<<ans/sum;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int MOD = 1e9+7;

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

    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int now;
        cin >> now;
        while(now%2==0){
            ans++;
            now /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
list_xy = [input().split() for _ in range(N)] 
t = [None for _ in range(N+1)]
x = [None for _ in range(N+1)]
y = [None for _ in range(N+1)]
t[0], x[0], y[0] = 0, 0, 0

for i in range(1, N+1):
  t[i] = int(list_xy[i-1][0])
  x[i] = int(list_xy[i-1][1])
  y[i] = int(list_xy[i-1][2])
  
flag = 'Yes'
for i in range(N):
  dt = t[i+1] - t[i]
  dist = (x[i+1] - x[i]) + (y[i+1] - y[i])
  if dist > dt:
    flag = 'No'
  if (t[i] % 2) != ((x[i] + y[i]) % 2):
    flag = 'No'

print(flag)

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;


int n;
int main(){
	int dp[50];
	dp[0] = 1;
	dp[1] = 1;
	for(int i = 0; i < 50; i++){
		if(i > 1){
			dp[i] = dp[i-1]+dp[i-2];
		}
	}
	cin >> n;
	cout << dp[n] << endl;
}


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

int main(void) 
{
    int a, b;
    cin >> a >> b;
    
    if (a < b) {
        cout << 'a' << " < " << 'b' << endl;
    }
    else if (a > b) {
        cout << 'a' << " > " << 'b' << endl;
    }
    else {
        cout << 'a' << " == " << 'b' << endl;
    }
}


Measured memory_bytes: 3120
x, y = map(int, input().split())
A = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
ans = 'No'
for a in A:
    if x in a and y in a:
        ans = 'Yes'
        break
print(ans)

Measured memory_bytes: 3060
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e+7;

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

  int n;
  string s;
  cin >> n >> s;

  int res = 1;
  rep(i,n-1) {
    if(s[i] != s[i+1]) res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
  int cnt;
  char tenki1[3],tenki2[3];
  scanf("%s",&tenki1[0]);
  scanf("%s",&tenki2[0]);
  for(int i=0; i<3; i++){
    if(tenki1[i] == tenki2[i]){
      cnt++;
    }
  }
  printf("%d\n",cnt);
  return(0);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = INT_MAX;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

// Treap
struct node_t {
	int val;
	node_t *ch[2];
	int pri;
	int cnt;
	int sum;
	int mini;

	node_t(int v, double p) :val(v), mini(v), pri(p), cnt(1), sum(v) {
		ch[0] = ch[1] = NULL;
	}
};

int count(node_t *t) { return !t ? 0 : t->cnt; }
int sum(node_t *t) { return !t ? 0 : t->sum; }
int val(node_t *t) { assert(t); return t->val; }
int mini(node_t *t) { return !t ? INF : t->mini; }

void inorder(node_t* root, string name = "") {
	function<void(node_t*)> rec = [&](node_t *x) {
		if (!x)return;
		rec(x->ch[0]);
		cerr << x->val << " ";
		rec(x->ch[1]);
	};
	cerr << name << ": ";
	rec(root);
	cerr << endl;
}

int mini(node_t *t, int l, int r) {
	if (!t)return INF;
	if (r <= l)return INF;
	if (r - l == count(t))
		return mini(t);
	else if (count(t->ch[0]) >= r)
		return mini(t->ch[0], l, r);
	else if (count(t->ch[0]) < l)
		return mini(t->ch[1], l - (count(t->ch[0]) + 1), r - (count(t->ch[0]) + 1));
	return min({
		val(t),
		mini(t->ch[0], l, count(t->ch[0])),
		mini(t->ch[1], 0, r - (count(t->ch[0]) + 1))
	});
}

// ??????????????£?????¨?????????????????¶
node_t *update(node_t *t) {
	if (!t)return t;
	t->cnt = count(t->ch[0]) + count(t->ch[1]) + 1;
	t->sum = sum(t->ch[0]) + sum(t->ch[1]) + t->val;
	t->mini = min({ val(t),mini(t->ch[0]),mini(t->ch[1]) });
	return t;
}

node_t *merge(node_t *l, node_t *r) {
	if (!l)return r;
	if (!r)return l;
	if (l->pri > r->pri) {
		l->ch[1] = merge(l->ch[1], r);
		return update(l);
	}
	else {
		r->ch[0] = merge(l, r->ch[0]);
		return update(r);
	}
}

// ([0, k), [k, n))
pair<node_t*, node_t*> split(node_t *t, int k) {
	if (!t)return pair<node_t*, node_t*>(NULL, NULL);
	if (k <= count(t->ch[0])) {
		pair<node_t*, node_t*> s = split(t->ch[0], k);
		t->ch[0] = s.second;
		return make_pair(s.first, update(t));
	}
	else {
		pair<node_t*, node_t*> s = split(t->ch[1], k - count(t->ch[0]) - 1);
		t->ch[1] = s.first;
		return make_pair(update(t), s.second);
	}
}

node_t *insert(node_t *t, int k, int v) {
	auto s = split(t, k);
	node_t *m = new node_t(v, rand());
	return update(merge(update(merge(s.first, m)), s.second));
}

node_t *erase(node_t *t, int k) {
	auto s1 = split(t, k);
	auto s2 = split(s1.second, 1);
	return update(merge(s1.first, s2.second));
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	node_t *root = NULL;
	rep(i, 0, n) {
		root = insert(root, i, INF);
	}
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		dump(com, x, y);
		if (com == 0) {
			root = erase(root, x);
			root = insert(root, x, y);
		}
		else {
			cout << mini(root, x, y + 1) << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> h(n), f(n);
    for (int& hi : h) cin >> hi;
    for (int i = 1; i < n; ++i) {
        f[i] = f[i - 1] + abs(h[i] - h[i - 1]);
        if (i > 1) f[i] = min(f[i], f[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << f.back();
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<queue>
#include<math.h>
#include<vector>
#include<map>
using namespace std;
#define ll long long
struct node
{
    string str;
    int x;
    int k;
};
int cmp(node a,node b)
{
    if(a.str==b.str)
        return a.x>b.x;
    return a.str<b.str;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        node a[101];
        for(int i=1; i<=n; i++)
        {
            cin>>a[i].str>>a[i].x;
            a[i].k=i;
        }
        sort(a+1,a+n+1,cmp);
        for(int i=1; i<=n; i++)
        {
            cout<<a[i].k<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include "iostream"

using namespace std;

int main() {
  long long n, k;
  cin >> n >> k;
  long long l = 0;
  long long r = k + 10;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    long long mid_copy = mid;
    long long cnt = n;
    long long cost = 0;
    bool flag = true;
    while (mid_copy > 0 && cnt) {
      cost += mid_copy;
      --cnt;
      mid_copy /= 2;
      if (cost > k) {
        flag = false;
        break;
      }
    }
    if (cost > k) flag = false;
    if (flag) {
      l = mid;
    } else {
      r = mid;
    }
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 3100
//============================================================================
// Name        : abc107.cpp
// Author      : a
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int H,W;
	cin >> H >> W;
	char map[H][W];
	bool empty_row[H],empty_col[W];
	for (int i = 0; i < H; ++i) {
		empty_row[i]=true;
	}
	for (int j = 0; j < W; ++j) {
		empty_col[j]=true;
	}
	for (int i = 0; i < H; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < W; ++j) {
			map[i][j] = s[j];
			if(s[j]=='#'){
				empty_row[i] = false;
				empty_col[j] = false;
			}
		}
	}


	for (int i = 0; i < H; ++i) {
		if(empty_row[i]) continue;
		for (int j = 0; j < W; ++j) {
			if(!empty_col[j]){
				cout << map[i][j];
			}
		}
		cout << endl;
	}


	return 0;
}


Measured memory_bytes: 256