akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
    def __init__(self, N):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self.parent = [n for n in range(0, N)]
        # グループの深さ
        self.depth = [1] * N
 
    def find(self, x):
        """ 木の根(どのグループか)を求める """
        if self.parent[x] == x: return x
        self.parent[x] = self.find(self.parent[x]) # 縮約
        return self.parent[x]
 
    def unite(self, x, y):
        """ xとyの属する集合を併合する """
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy: return
 
        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self.depth[gx] < self.depth[gy]:
            self.parent[gx] = gy
        else:
            self.parent[gy] = gx
            if self.depth[gx] == self.depth[gy]: self.depth[gx] += 1
 
    def is_same_group(self, x, y):
        """ xとyが同じ集合に属するか否か """
        return self.find(x) == self.find(y)
      
N, M = list(map(int, input().split()))
E = [[int(x)-1 for x in input().split()] for _ in range(M)]

# 各辺について、その辺が存在しない時、aとbが連結になるかをUnion-Findで判定する
ans = 0
for i in range(M):
  uf = UnionFind(N)
  for j, e in enumerate(E):
    if i==j: continue
        
    a, b = e
    uf.unite(a, b)
      
  # i番目の辺を除くすべての辺をつないだあとで、i番目の辺(a, b)がつながるかを判定する
  # つながらないならば、そのi番目の辺は橋である
  a, b = E[i]
  if not uf.is_same_group(a, b):
    ans += 1

print(ans)      


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n, m, to[607], dp[607][607], g[607], res;
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int main()
{
	n = read();
	m = read();
	for (int i = 1; i <= m; i++)
	{
		int a = read(), b = read();
		to[a] = b; to[b] = a;
	}
	g[0] = 1;
	for (int i = 2; i <= 2 * n; i += 2)
		g[i] = 1LL * g[i - 2] * (i - 1) % mod;
	for (int i = 1; i <= 2 * n; i++)
		for (int j = i + 1; j <= 2 * n; j += 2)
		{
			int c = j - i + 1;
			for (int k = i; k <= j; k++)
				if (to[k])
				{
					c--;
					if (to[k]<i || to[k]>j)c = -1;
				}
			if (c < 0)continue;
			dp[i][j] = g[c];
			for (int k = j, cc = 0; k > i; k--)
			{
				cc += (!to[k]);
				dp[i][j] = (dp[i][j] - 1LL * dp[i][k - 1] * g[cc] % mod + mod) % mod;
			}
			res = (res + 1LL * dp[i][j] * g[2 * n - 2 * m - c] % mod) % mod;
		}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define el '\n'
#define ull unsigned long long
#define ui unsigned int
#define ll long long
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d",n)
int main()
{
    ll n,m;
    cin>>n;
    if(n%2==0)
        cout<<n<<el;
    else
        cout<<2*n<<el;
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
    var tairu = input[0];
    
    var g = 0; // 010101...パターン
    var k = 0; // 101010...パターン

    // console.log('タイルの長さ: %s', tairu.length);
    for (var i = 0; i < tairu.length; i++) {
        var t  = i % 2; // 0 or 1
        if (t === parseInt(tairu.charAt(i), 10)) {
            k++;
        } else {
            g++;
        }
    }
    // console.log('g: %s', g);
    // console.log('k: %s', k);

    console.log(k < g ? k : g);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7488
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]
amax = max(A)
amaxcnt = A.count(amax)

for i in range(N):
    ai = A[i]
    if ai == amax and amaxcnt == 1:
        A.pop(i)
        print(max(A))
        A.insert(i, 0)
    else:
        print(amax)


Measured memory_bytes: 12512
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 4001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll,ll,ll>>>;

// MOD確認

ll H[100010];
bool A[100010];

int main(){
    ll N,M;
    cin >> N >> M;
    rep(i,N) cin >> H[i];
    rep(i,100010) A[i] = 1;
    rep(i,M){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        if(H[a] >= H[b]) A[b] = 0;
        if(H[a] <= H[b]) A[a] = 0;
    }
    ll ans = 0;
    rep(i,N) if(A[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 4512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n;
  cin >> n;
  vl c(n, 0);
  bool ok = true;
  rep(i, n) {
    ll d;
    cin >> d;
    c[d]++;
    if(i == 0 && d != 0) ok = false;
  }
  if(!ok || c[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  mint ans = 1;
  rep(i, n - 1) ans *= mint(c[i]).pow(c[i + 1]);
  cout << ans << endl;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> pa(m);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        pa[i]=make_pair(b,a);//ソートの為にfirstにbを代入
    }
    sort(pa.begin(),pa.end());//bでソート
    
    int ans=1,x=pa[0].first-1;
    for(int i=1;i<m;i++){
        if(pa[i].second<=x){
            continue;
        }else{
            x=pa[i].first-1;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).

#define in input_int()
#define ins input_string()
int input_int(){int a;cin>>a;return a;}
string input_string(){string s;cin>>s;return s;}
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};



int n,m,k,a,b,c,d,x,y,arr[N];
string s;
void solve()
{
    cin>>n;
    forn(i,1,n)cin>>arr[i];
    int ans=0;
    forn(i,1,n)forn(j,i+1,n)forn(k,j+1,n)
    {
        set<int>dc{arr[i],arr[j],arr[k]};
        if(dc.size()<3)continue;
        a=*dc.begin();
        dc.erase(dc.begin());
        b=*dc.begin();
        dc.erase(dc.begin());
        c=*dc.begin();
        dc.erase(dc.begin());

        if(a+b>c)ans++;
    }
    cout<<ans;
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}
//       clang++ c.cpp ; ./a.out < a.txt ;  

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

int main(){
    string s,x;
    int n,ans;
    ans = 0;
    while(true){
        cin >> s;
        if(s == "0"){
            break;
        };
        for(int i=0; i<s.size(); i++){
            x = s[i];
            sscanf(x.c_str(),"%d",&n);
            ans += n;
        };
        cout << ans << endl;
        ans = 0;
    };
    return 0;
}


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

int main() {
	int h, a;
	cin >> h >> a;

	int ans = 0;
	while (h > 0) {
		h -= a;
		++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''


n=int(input())
ans=0
for i in range(1,n+1):
    ans+=i*(n//i)*(1+n//i)//2
print(ans)

Measured memory_bytes: 63244
import java.util.*

fun main(args: Array<String>) {
    val s = readLine() ?: return
    val q = readLine()?.toInt() ?: return
    var isReversed = false
    val result = LinkedList<String>()
    result.apply {
        s.forEach {
            addLast(it.toString())
        }
        repeat(q) {
            val query = readLine()?.split(" ") ?: return
            when (query[0].toInt()) {
                1 -> {
                    isReversed = !isReversed
                }
                2 -> {
                    val operationType = query.getOrNull(1)?.toInt() ?: return
                    val c = query.getOrNull(2) ?: return
                    when (operationType) {
                        1 -> {
                            if (isReversed) {
                                addLast(c)
                            } else {
                                addFirst(c)
                            }
                        }
                        2 -> {
                            if (isReversed) {
                                addFirst(c)
                            } else {
                                addLast(c)
                            }
                        }
                    }
                }
            }
        }
    }
    if (isReversed) {
        result.reverse()
    }
    println(result.joinToString(""))
}



Measured memory_bytes: 91320
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, x;
	bool found = false;

	cin >> n;
	for (i = 1; i <= n; i++) {
		x = (i * 108) / 100;
		if (x == n) {
			found = true;
			cout << i << "\n";
			break;
		}
	}
	if (!found) cout << ":(\n";

	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int H, W, N;
int sr, sc;
string S, T;

int main() {
	cin >> H >> W >> N;
	cin >> sr >> sc;
	cin >> S;
	cin >> T;
	
	int l = 0;
	int r = W + 1;
	int t = 0;
	int b = H + 1;
	bool ans = true;
	
	for (int i = S.size() - 1; i >= 0; i --) {
		switch (T[i]) {
		case 'L' :
			r = min(r + 1, W + 1);
			break;
		case 'R' :
			l = max(l - 1, 0);
			break;
		case 'U' :
			b = min(b + 1, H + 1);
			break;
		case 'D' :
			t = max(t - 1, 0);
			break;
		}
		switch (S[i]) {
		case 'L' :
			l ++;
			break;
		case 'R' :
			r --;
			break;
		case 'U' :
			t ++;
			break;
		case 'D' :
			b --;
			break;
		}
		//cout << l << r << t << b << endl;
		if (r - l < 2) ans = false; 
		if (b - t < 2) ans = false;
		if (!ans) break;
	}
	
	if (ans and sr < b and sr > t and sc < r and sc > l) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int main(void){
    
    ll d,s,t;
    cin>>d;
    cin>>s;
    cin>>t;
    
    if(s*t >= d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    // Your code here!
    
}


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

int main(int argc, char const *argv[])
{
    int cards[4][13]{}, n, y;
    char x;
    cin >> n;
    rep(i, n) {
        cin >> x >> y;
        if(x=='S') cards[0][y-1] = y;
        if(x=='H') cards[1][y-1] = y;
        if(x=='C') cards[2][y-1] = y;
        if(x=='D') cards[3][y-1] = y;
    }

    rep(i, 4) {
        rep(j, 13) {
            if(cards[i][j]==false) {
                if(i==0) cout << "S " << j+1;
                if(i==1) cout << "H " << j+1;
                if(i==2) cout << "C " << j+1;
                if(i==3) cout << "D " << j+1;
                cout << endl;
            }
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;



int main() {

    int n,k;
    cin>>n>>k;

    vector<long long >arr(n);

    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    if(n<k)cout<<0;
    else{
        long long sum=0;
        for(int i=0;i<n-k;i++){
            sum+=arr[i];
        }
        cout<<sum;
    }
    //cout<<accumulate(arr.begin(),arr.begin()+n-k,0);



	return 0;
}


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

int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  if(a+b==c+d){
    cout <<"Balanced"<<endl;
  }
  else{
    if(a+b>c+d){
      cout<<"Left"<<endl;
    }
    if(a+b<c+d){
      cout<<"Right"<<endl;
    }
  }// ここにプログラムを追記
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int H,W;
    scanf("%d",&H);
    scanf("%d",&W);
    char map[(H+2)*(W+2)];
    char c[W];
    for(int i=0;i<(H+2)*(W+2);i++)map[i]='#';

    for(int i=0;i<H;i++){
        scanf("%s",c);
        for(int j=0;j<W;j++)map[(i+1)*(W+2)+j+1]=c[j];
    }
    
    for(int i=0;i<(H+2)*(W+2);i++){
        printf("%c",map[i]);
        if(i%(W+2)==W+1)printf("\n");
    }
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
signed main(){
  string s;
  ll f=0,e=0;
  cin>>s;
  if(s[0]=='0'){
    if('0'<s[1] && '9'>=s[1]){
      f++;
    }
  }
  if(s[0]=='1'){
    if('0'<=s[1] && '2'>=s[1]){
      f++;
    }
  }
  if(s[2]=='0'){
    if('0'<s[3] && '9'>=s[3]){
      e++;
    }
  }
  if(s[2]=='1'){
    if('0'<=s[3] && '2'>=s[3]){
      e++;
    }
  }
  if(f==1 && e==1){
    cout<<"AMBIGUOUS\n";
  }else if(f==1 && e==0){
    cout<<"MMYY\n";
  }else if(f==0 && e==1){
    cout<<"YYMM\n";
  }else if(f==0 && e==0){
    cout<<"NA\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int i;
    vector<int> A;
    int n;
    cin >> n;
    for (i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }
    int q;
    cin >> q;
    for (i = 0; i < q; i++)
    {
        int b, e;
        cin >> b >> e;
        reverse(A.begin() + b, A.begin() + e);
    }
    for (i = 0; i < A.size() - 1; i++)
    {
        cout << *(A.begin() + i) << ' ';
    }
    cout << *(A.end() - 1) << endl;
}


Measured memory_bytes: 3160
#include <stdio.h>
int main(){
    int a,b,su,di,pr,qu;
    char op;
    for(;;) {
        scanf("%d %c %d", &a,&op,&b);
        if (op == '+') {
            su = a + b;
            printf("%d\n", su);
        } else if (op == '-') {
            di = a - b;
            printf("%d\n", di);
        } else if (op == '*') {
            pr = a * b;
            printf("%d\n", pr);
        } else if (op == '/') {
            qu = a / b;
            printf("%d\n", qu);
        } else {
            break;
        }
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;
ll sl();

int main() {
  int N, K;
  cin >> N >> K;
  vector<pair<int, int>> ans;
  for (int i = 1; i < N; i++) {
    ans.emplace_back(0, i);
    for (int j = i + 1; j < N; j++) {
      if (K > 0) {
        K--;
      } else {
        ans.emplace_back(i, j);
      }
    }
  }
  if (K == 0) {
    cout << ans.size() << endl;
    for (auto p : ans) {
      cout << p.first + 1 << ' ' << p.second + 1 << endl;
    }
  } else {
    cout << -1 << endl;
  }
}

ll sl() {
  ll x;
  cin >> x;
  return x;
}

struct init {
  init() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} init;


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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

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

    int N, M;
    while (true)
    {
        cin >> N >> M;
        if (N == 0)
            break;
        int r;
        cin >> r;
        VVI v(M, vector<int>(1000, 0));
        for (int i = 0; i < r; i++)
        {
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            t -= 540;
            m--;
            if (s)
                v[m][t]++;
            else
                v[m][t]--;
        }
        for (int i = 0; i < M; i++)
        {
            for (int j = 1; j <= 720; j++)
            {
                v[i][j] += v[i][j - 1];
            }
        }
        int q;
        cin >> q;
        for (int i = 0; i < q; i++)
        {
            int ts, te, m;
            cin >> ts >> te >> m;
            ts -= 540;
            te -= 540;
            m--;
            int res = 0;
            for (int j = ts; j < te; j++)
                if (v[m][j])
                    res++;
            cout << res << endl;
        }
    }
}


Measured memory_bytes: 41208
n = int(input())
if n == 1:
  print(0)
  exit()
  
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

chk = factorization(n)
ans = 0
cnt = 2
ss = 1
for num,k in chk:
  while k >= ss:
    ans += 1
    ss += cnt
    cnt += 1
    #print(num,k,ss,cnt,chk,ans)
  ss = 1
  cnt = 2

print(ans)

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

int h, w;
int c[10][10];
int a[10];
int ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> h >> w;
	for(int i=0; i<10; ++i)
		for(int j=0; j<10; ++j)
			cin >> c[i][j];
	for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j){
			int t;
			cin >> t;
			if(t != -1)
				++a[t];
		}
	for(int k=0; k<10; ++k)
		for(int i=0; i<10; ++i)
			for(int j=0; j<10; ++j)
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
	for(int i=0; i<10; ++i)
		ans += a[i] * c[i][1];
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n ;
    cin >> n ;
    vl v ;
    forn(i , 1 , n ) {
       ll x;
       cin >> x;
       v.pb(x) ;
    }
    ll foo = acc(v) ;
    ll m ;
    cin >> m ;
    vl ans ;
    forn(i , 1 , m ) {
       ll p , t ;
       cin >> p >> t;
       ll ini = foo ;
       ll now = ini - v[p-1] + t ;
       cout << now << el ;
    }
}































Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Solution
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var sorted = x.OrderBy(i => i).ToArray();

        var answer = new StringBuilder();
        for (int i = 0; i < n; i++)
        {
            var mean = sorted[n / 2];
            if (x[i] < mean)
            {
                answer.AppendLine(mean.ToString());
            }
            else
            {
                answer.AppendLine(sorted[n / 2 - 1].ToString());
            }

        }

        Console.Write(answer);
    }
}

Measured memory_bytes: 48632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] H = new int[N];
        for (int i = 0; i < H.length; i++) {
            H[i] = sc.nextInt();
        }
        boolean[] isGood = new boolean[N];
        for (int i = 0; i < isGood.length; i++) {
            isGood[i] = true;
        }
        for (int i = 0; i < M; i++) {
            int A = sc.nextInt();
            int B = sc.nextInt();
            if (H[A - 1] >= H[B - 1]) {
                isGood[B - 1] = false;
            }
            if (H[A - 1] <= H[B - 1]) {
                isGood[A - 1] = false;
            }
        }
        int counter = 0;
        for (int i = 0; i < isGood.length; i++) {
            if (isGood[i]) {
                counter++;
            }
        }
        System.out.println(counter);
        sc.close();
    }
}

Measured memory_bytes: 59456
import math
L = 10**6 + 1

N = int(input())
A = list(map(int, input().split()))
memo = [0] * L
flag = 0 

for a in A:
    memo[a] += 1

for i in range(2, L):
    if sum(memo[i::i]) > 1:
        flag = 1
        break

g = 0
for i in range(N):
    g = math.gcd(g, A[i])

if flag == 0:
    answer = 'pairwise coprime'
elif flag == 1 and g == 1:
    answer = 'setwise coprime'
else:
    answer = 'not coprime'

print(answer)


Measured memory_bytes: 195252
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

bool solve(int N, int M, int K){
    for(int n=0; n<=N; n++){
        int cnt = n*M;
        int delta = N - 2*n;
        for(int m=0; m<=M; m++){
            if(cnt + delta*m == K){
                return true;
            }
        }
    }

    return false;
}

int main(){
    int N, M, K;  cin >> N >> M >> K;
    if(solve(N, M, K)){
        cout << "Yes" << endl;
    }else if(solve(M, N, K)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    
    int a, b, c, n;
    cin >> a >> b >> c >> n;
    int ans = 0;
    for (int i = 0; i <= n; i += a) {
        for (int j = 0; j <= n - i; j += b) {
            ans += (n - i - j) % c == 0;
        }   
    }   
    cout << ans << '\n';

}

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

using namespace std;

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

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

const int INF = 1e9;

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

    vector<int> h(N), dp(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
        dp[i] = INF;
    }

    dp[0] = 0;
    for (int i = 0; i < N; i++)
    {
        for (int k = 1; k <= K; k++)
        {
            if (i + k < N)
            {
                chmin(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
            }
        }
    }

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


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        char[] c = s.toCharArray();
        Arrays.sort(c);
        
        if((c[0] == c[1]) && (c[2] == c[3]) && (c[1] != c[2])){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
n=int(input())

s=[[[0]*10 for i in range(3)] for k in range(4)]

for i in range(n):
    b,f,r,v=map(int,input().split())
    s[b-1][f-1][r-1]+=v
    
for i in range(3):
    for k in range(10):
        print(' ' +str(s[0][i][k]),end='')
    print()    
print('#'*20)

for i in range(3):
    for k in range(10):
        print(' ' + str(s[1][i][k]),end='')
    print()
        
print('#'*20)
for i in range(3):
    for k in range(10):
        print(' ' + str(s[2][i][k]),end='')
    print()
print('#'*20)

for i in range(3):
    for k in range(10):
        print(' ' + str(s[3][i][k]),end='')
    print()


Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>

const int MOD = pow(10,9)+7;
typedef long long ll;

using namespace std;
int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}


int isPrime(int x){
    
    int g = (int)sqrt(x);
    
    for(auto j = 2; j<=g; j++){
        
        if (x % j == 0){
            return 0;
        }
    }
    
    return 1;
}


int main() {
  
    int N = in();
    
    ll nums[N+1];
    
    for(auto i = 1; i <= N; i++){
        nums[i] = 1;
    }
    
    
    vector<int> primes;
    
    for(auto i = 2; i <= N; i++){
        
        if (isPrime(i)){
            primes.push_back(i);
        }
    }
    
    
    
    for (auto i = 2; i<= N; i++){
        int temp = i;
        
        for(auto p : primes){

            while(temp != 0){
                if (temp%p == 0){
                    nums[p] += 1;
                    temp/=p;
                }else{
                    break;
                }
            }
                
        }
        
    }
    
    
    int ans = 1;
    
    for(auto i = 2; i <= N; i++){
        ans = ans * nums[i] % MOD;
    }

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



Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <functional>
#include <algorithm>

const int N = 1e5 + 10;
const int inf = 1e9 + 10;

int dsu[N], weight[N], cnt[N];

int root(int x) {
  if (x != dsu[x]) dsu[x] = root(dsu[x]);
  return dsu[x];
}

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

  std::vector<std::tuple<int, int, int>> edges;
  for (int i = 0; i < m; ++i) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    edges.emplace_back(z, x - 1, y - 1);
  }

  std::sort(edges.begin(), edges.end());

  for (int i = 0; i < n; ++i) dsu[i] = i;
  int ret = 0;
  for (auto &e: edges) {
    int w = std::get<0>(e);
    int a = root(std::get<1>(e));
    int b = root(std::get<2>(e));
    if (a != b) {
      dsu[a] = b;
      weight[b] = std::min(weight[b] + weight[a], inf);
      cnt[b] += cnt[a];
    }
    cnt[b]++;
    if (weight[b] >= w) {
      ret += cnt[b];
      cnt[b] = 0;
    }
  }
  printf("%d\n", m - ret);
  return 0;
}


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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector<int> H(N);
  for (int& h : H) cin >> h;

  A *= 1000;
  T *= 1000;
  int ans = -1, a;
  for (int i = 0; i < N; i++) {
    if (ans == -1 || abs(A - T + H[i] * 6) < ans) {
      ans = abs(A - T + H[i] * 6);
      a = i + 1;
    }
  }
  cout << a << endl;
}

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


int main()
{
	int n;
	double a,b,c=1,sum=0,dist=0;
	vector<pair<double,double>>v;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		v.push_back(make_pair(a,b));
		c*=i;
	}
	sort(v.begin(),v.end());
	do
	{
	    dist=0;
	    for(int i=1;i<v.size();i++)
	    {
	    	double p=v[i].first,q=v[i].second,x=v[i-1].first,y=v[i-1].second;
	    	sum+=sqrt((p-x)*(p-x)+(q-y)*(q-y));
	    }
	    dist+=sum;
	}
	while(next_permutation(v.begin(),v.end()));
	cout<<setprecision(15)<<dist/c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main () {
  
  int a, b, c;
  cin >> a >> b >> c;
  double s = 0.5 * (a + b + c);
  cout << pow(s * (s - a) * (s - b) * (s - c), 0.5);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#ifdef DOC
#define _NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N
#define _FE_1(_CALL, x) _CALL(x)
#define _FE_2(_CALL, x, ...) _CALL(x) \
_FE_1(_CALL, __VA_ARGS__)
#define _FE_3(_CALL, x, ...) _CALL(x) \
_FE_2(_CALL, __VA_ARGS__)
#define _FE_4(_CALL, x, ...) _CALL(x) \
_FE_3(_CALL, __VA_ARGS__)
#define _FE_5(_CALL, x, ...) _CALL(x) \
_FE_4(_CALL, __VA_ARGS__)
#define _FE_6(_CALL, x, ...) _CALL(x) \
_FE_5(_CALL, __VA_ARGS__)
#define FOR_EACH_MACRO(MACRO, ...)                                  \
    _NTH_ARG(__VA_ARGS__, _FE_6, _FE_5, _FE_4, _FE_3, _FE_2, _FE_1) \
    (MACRO, __VA_ARGS__)
#define watch(x) cerr << #x " = " << (x) << "; ";
#define debug(...)                       \
    cerr << "Line " << __LINE__ << ": "; \
    FOR_EACH_MACRO(watch, __VA_ARGS__)   \
    cerr << endl
#else
#define debug(...)
#endif

using namespace std;

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    return os << '{' << p.first << ", " << p.second << '}';
}

template <class T, class = decltype(begin(declval<T>())),
          class = enable_if_t<!is_same<T, string>::value>>
ostream &operator<<(ostream &os, const T &c)
{
    os << '[';
    for (auto it = begin(c); it != end(c); ++it)
        os << (it == begin(c) ? "" : ", ") << *it;
    return os << ']';
}
typedef long long ll;
#define F(i, a, b) for (int i = (a); i <= (b); i++)
#define D(i, a, b) for (int i = (a); i >= (b); i--)
#define R(i, a, b) for (int i = (a); i < (b); i++)
#define N 500000
#define ALL(vt) vt.begin(), vt.end()
#define ALLR(vt) vt.rbegin(), vt.rend()
int solve(){
    int n, k; cin >> n >> k;
    vector<int> h(n); for(int &k : h) cin >> k;
    vector<int> dp(n, 0);
    if(n == 1) return 0;
    if(n == 2) return h[1] - h[0];
    dp[1] = abs(h[1] - h[0]);    
    R(i, 2, n){                
        int mm = 1e9;
        R(j, 1, k + 1){
            if(i - j >= 0){
                mm = min(dp[i-j] + abs(h[i] - h[i-j]), mm);
            }                        
        }
        dp[i] = mm;        
        // debug(dp[i]);
    }
    return dp[n-1];
}
int main(){
    cout << solve();

}

Measured memory_bytes: 1024
from pprint import pprint

MOD = 10 ** 9 + 7
L = input()
nl = len(L)
dp = [[0 for _ in range(2)]
      for _ in range(nl + 1)]
dp[0][0] = 1

for i in range(1, nl + 1):
    li = i - 1

    # 小さいこと確定
    dp[i][1] = dp[i - 1][1] * 3 % MOD

    ############################
    if L[li] == '1':
        dp[i][1] += dp[i - 1][0]  # a, b 両方0

    # 当該桁まで =
    if L[li] == '1':
        dp[i][0] = dp[i - 1][0] * 2 % MOD  # a, b いずれか 1
    else:
        dp[i][0] = dp[i - 1][0]  # a, b 両方0

    dp[i][0] %= MOD
    dp[i][1] %= MOD

print(sum(dp[-1])%MOD)


Measured memory_bytes: 26388
s = input()
n = len(s)

for i in range(2**(n-1)):
    x = [s[0]]
    for j in range(n-1):
        if (i>>j)&1:
            y ='+'
        else:
            y = '-'
        x.append(y)
        y = 0
        x.append(s[j+1])
    z = ''.join(x)
    if eval(z) == 7:
        print(z + '=7')
        break

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

#define INF INT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

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

using namespace std;

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

    int a;
    string s;
    cin >> a >> s;
 
    string  ans;
    if(a >= 3200)ans = s;
    else ans = "red";

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    cout << S[0] << S[1] << S[2] << endl;
    return 0;
}

Measured memory_bytes: 3628
/*ex9-2
  Sweet_Sweet_Soul*/


#include <stdio.h>
#include <stdlib.h>

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}


int main(void){
    int count=0;/*答えのカウント*/
    char cube[100001];/*100000文字なのでnull文字含めて確保*/
    char *ptr;/*文字列操作用のポインタ*/
    char tmp;/*pop用の変数*/
    node *list=NULL;/*リスト用のポインタ*/
    scanf("%s",cube);
    ptr=cube;
    while(*ptr!='\0'){
        if(list==NULL || list->elem==*ptr){ /*listの一番上とptrの現在地が一緒 or listが空の場合*/
            push(&list,*ptr);
        }
        else{ /*listの一番上とptrの現在地が異なる*/
            pop(&list);/*listとcubeで一つづつ除去*/
            count=count+2;/*取り出した数をカウント*/
        }
        ptr++;
    }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 4920
S=input()
N=len(S)+1
S='>'+S+'<'
a=[0] * (N+2)

i=1
while i<=N:
    if S[i-1]==">" and S[i]=="<":
        a[i]=0

        j=i
        while j>=1:
            if S[j-1]==">":
                if a[j-1]<=a[j]:
                    a[j-1]=a[j]+1
                j=j-1
            else:
                break

        k=i
        while k<=N:
            if S[k]=="<":
                if a[k+1]<=a[k]:
                    a[k+1]=a[k]+1
                k=k+1
            else:
                break
    i=i+1

a[0]=0
a[N+1]=0
print(sum(a))


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n,d,a;
    cin>>n>>d>>a;

    vector<pair<long long, long long> > inp(n);

    vector<long long> cum(n + 5);

    for(int i = 0; i < n; i++) {
        cin>>inp[i].first>>inp[i].second;
    }

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

    ll cnt = 0;

    for(int i = 0; i < n; i++) {

        if(inp[i].second > 0) {
            ll extra = (inp[i].second + a - 1) / a;
            cnt = cnt + extra;

            ll next = inp[i].first + 2*d;

            int idx = (int)(upper_bound(inp.begin(), inp.end(), make_pair(next, 1ll<<60)) - inp.begin());
            cum[i] += extra;
            cum[idx] -= extra;
        }

        if(i < n - 1) {
            cum[i+1] = cum[i+1] + cum[i];
            inp[i+1].second -= cum[i+1]*a;
        }

    }

    cout<<cnt<<endl;

}


Measured memory_bytes: 4992
import java.util.*;
import java.io.*;
 
public class Main{
    
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int K = s.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < N; i++){
			list.add(s.nextInt());
		}
		Collections.sort(list);
		int sum = 0;
		for(int i = 0; i < K; i++){
			sum += list.get(i);
		}
		System.out.println(sum);
		
		
			
	}
} 

Measured memory_bytes: 39004
import math
import operator as op
from functools import reduce
from fractions import Fraction as frac

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom
"""
int(input())
map(int,input().split())
list(map(int,input().split()))
"""
# t=int(input())
t=1
for term in range(t):
    n=int(input())
    A=list(map(int,input().split()))
    B=[0 for i in range(n)]
    B[1]=abs(A[0]-A[1])
    for i in range(2,n):
        B[i]=min(B[i-2]+abs(A[i-2]-A[i]),B[i-1]+abs(A[i-1]-A[i]))
    print(B[n-1])

Measured memory_bytes: 15768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 25184
n = int(input())
xmax, ymax = n//4, n//7
ok = False
for x in range(0, xmax+1):
    for y in range(0, ymax+1):
        if n == 4*x + 7*y:
            ok = True
            break
    if ok: break
print("Yes" if ok else "No")


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){

int N;
cin >>N;
int HeadB=0;
int BackA=0;
int both=0;
int answer=0;
    for(int k=0;k<N;k++){
    string str1;
    cin >>str1;
    
    int ans=0;
    int Acount=0;
    
        for(int i=0;i<str1.size();i++){//s[k]
        
            if(str1[i]=='A'){
            Acount++;
            }
            else if(str1[i]=='B'&&Acount!=0){
            ans++; 
            Acount=0;
            }
            else
            {
            Acount=0;
            }
        }
    answer+=ans;
        if(str1[0]=='B' && str1[str1.size()-1]=='A'){
        both++;
        }
        else if(str1[0]=='B'){
        HeadB++;
        }
        else if(str1[str1.size()-1]=='A'){
        BackA++;
        }


    }
   
    if(HeadB==0 && BackA==0 && both>0){
        answer+=both-1;
    }
    else {
        answer+=min(HeadB+both,BackA+both);
    }
cout <<answer <<endl;

}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {

        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            //var NA = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            //var N = NA[0];
            //var A = NA[1];


            Console.WriteLine(N >= 30? "Yes":"No");
        }


    }


}


Measured memory_bytes: 27480
#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 = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
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; }

using Weight = int;
struct Edge {
	int s, d; Weight w;
	Edge() {};
	Edge(int s, int d, Weight w) : s(s), d(d), w(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
	g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
	addArc(g, a, b, w);
	addArc(g, b, a, w);
}

// トポロジカルソート O(|E|+|V|)
// 入次数が0の点と辺を取り除きながらretに追加
vector<int> topologicalSort(const Graph &g) {
	int n = g.size(), k = 0;
	vector<int> ord(n), indeg(n);
	for (auto &es : g) for (auto &e : es) indeg[e.d]++;
	queue<int> q;
	for (int i = 0; i < n; i++)
		if (indeg[i] == 0)
			q.push(i);
	while (q.size()) {
		int v = q.front(); q.pop(); ord[k++] = v;
		for (auto &e : g[v])
			if (--indeg[e.d] == 0)
				q.push(e.d);
	}
	return *max_element(indeg.begin(), indeg.end()) == 0 ? ord : vector<int>();
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	Graph g(N);

	vector<int> a(N - 1 + M), b(N - 1 + M); rep(i, 0, N - 1 + M) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		addArc(g, a[i], b[i]);
	}
	vector<int> v = topologicalSort(g);
	dump(v);

	vector<int> idx(N);
	rep(i, 0, N)idx[v[i]] = i;
	dump(idx);

	vector<int> p(N);
	vector<int> m(N, -1);
	rep(i, 0, a.size()) {
		if (idx[a[i]] < idx[b[i]]) {
			if (m[b[i]] < idx[a[i]]) {
				m[b[i]] = idx[a[i]];
				p[b[i]] = a[i] + 1;
			}
		}
	}
	dump(p);

	rep(i, 0, p.size()) { cout << p[i] << endl; }

	return 0;
}

Measured memory_bytes: 10608
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long 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] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int n;
	cin >> n;
	string s = to_string(n);
	if ((s[0] == s[1]) && (s[1] == s[2])) {
		cout << "Yes";
		return 0;
	}
	if ((s[1] == s[2]) && (s[2] == s[3])) {
		cout << "Yes";
		return 0;
	}
	cout << "No";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define V vector<ll>
#define Q int tt,qq; cin>>tt ;for(qq=1;qq<=tt;qq++)
#define I ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
    ll n,i,mn=1e9,j;
    cin>>n;
    V a(n);
    for(auto &x:a)
    {
        cin>>x;
        mn=min(mn,x);
    }
    while(1)
    {
        j=0;
        bool x=1;
        for(i=0;i<n;i++)if(a[i]!=0&&a[i]!=mn){x=0;break;}
        if(x==1)break;
        for(i=0;i<n;i++)
        {
            if(mn==a[i])j++;
            if(j!=1||mn!=a[i])a[i]=a[i]%mn;
        }
        for(i=0;i<n;i++)if(a[i]!=0)mn=min(mn,a[i]);
    }
    cout<<mn;
}


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

#ifdef ENABLE_DEBUG
#define DEBUG(a) cerr<<#a<<":"<<a<<endl
#else
#define DEBUG(a) 
#endif



void solve(long long N, vector<long long> A, vector<long long> B){
    long long sumA=0,sumB=0;
    long long ans=0;
    long long diffAB[N];
    for(long long i=0;i<N;i++){
        sumA+=A[i];
        sumB+=B[i];
        diffAB[i]=A[i]-B[i];
    }
    if(sumA<sumB){
        cout<<-1<<endl;
        return;
    }
    sort(diffAB,diffAB+N);
    for(long long i=0;i<N;i++){
        DEBUG(diffAB[i]);
    }
    long long l=0,r=N-1;
    bool changed=false;
    while(diffAB[l]<0){
        while(diffAB[l]<0){
            if(diffAB[l]<=-diffAB[r]){
                diffAB[l]+=diffAB[r];
                diffAB[r]=0;
                r--;
                changed=false;
            }else{
                diffAB[r]+=diffAB[l];
                diffAB[l]=0;
                changed=true;
            }
        }
        l++;
    }
    DEBUG(l);
    DEBUG(r);
    DEBUG(changed);
    ans=l+(N-r-1)+(changed?1:0);
    cout<<ans<<endl;
    return ;
}

int main(){
    long long N;
    scanf("%lld",&N);
    vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>

using namespace std;

int main()
{
    int n,m,l,a,b;
    cin>>n>>m>>l;
    if(l%n==0)
        a=l/n;
    else
         a=l/n+1;
    if(l%m==0)
        b=l/m;
    else
         b=l/m+1;
    if(a<b)
       cout<<a;
    else
        cout<<b;
    return 0;
}


Measured memory_bytes: 256