akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ar array



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

	int n;
	cin >> n;
	string s;
	cin >> s;
	bool r = 0,w = 0;
	int rs = 0;
	for(int i = 0;i < (int)n; i++){
		if(s[i]=='R') r=1,rs++;
		else w = 1; 	
	}
	if(!r || !w){
		cout << 0;
	}else{
		int ri = rs;
		for(int i = ri-1; ~i; i--){
			if(s[i]=='R') rs--;
		}
		cout << rs;
	}
	return 0;
}




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

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

    int n,m;
    cin>>n>>m;
    int men=n*m;
    int syu=2*n+2*m;
    cout<<men<<" "<<syu<<endl;
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(i,n) for(long long i = 0; i < (long long)(n); ++i)

using namespace std;
using ll = long long;

int main() {
	ll n, ans = 0;
	cin >> n;
	rep(i,n)rep(j,n)rep(k,n) {
		ll g = 0;
		g = __gcd(i+1, j+1);
		ans += __gcd(g, k+1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

x = inp[0]
if(x < 100)
  p 0
  exit
end
c = x/100
am = x-c*100
puts (am <= 5*c)? 1 : 0


Measured memory_bytes: 2044
#include <bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
    long long int n,m;
  cin>>n>>m;
 n=n*(n-1);
 n=n/2;
 m=m*(m-1);
 m=m/2;
  cout<<m+n;
    return 0; 
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010], b[100010], c[100010];
ll mem[100010][3];
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        for(int i=1; i<=n; ++i){
            scanf("%d%d%d",a+i,b+i,c+i);
        }
        for(int i=1; i<=n; ++i){
            mem[i][0]=a[i]+max(mem[i-1][1], mem[i-1][2]);
            mem[i][2]=c[i]+max(mem[i-1][0], mem[i-1][1]);
            mem[i][1]=b[i]+max(mem[i-1][0], mem[i-1][2]);
        }
        ans=max(mem[n][0], max(mem[n][1], mem[n][2]));
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
  float d,t,s;
  cin>>d>>t>>s;
  float t_=d/s;
  if(t_<=t)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3704
#include <stdio.h>
 
int main(void){
  int i,j,n,m,cn;
  char c,s[5]={'S','H','C','D','\0'};
  static int card[4][13];
  scanf("%d\n",&n);
 
  for(i=0;i<n;i++){
    scanf("%c %d\n",&c,&m);
    for(j=0;j<4;j++)
      if(s[j]==c)
        card[j][m-1]=1;
  }
   
  for(i=0;i<4;i++)
    for(j=0;j<13;j++)
      if(card[i][j]==0)
        printf("%c %d\n",s[i],j+1);
 
  return 0;
}


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

int main() {

    int a, b, k; cin >> a >> b >> k;

    vector<int> vec;
    for (int i = a; i <= b ; i++) {
        if (i - a + 1 <= k) vec.emplace_back(i);
        if (b - i + 1 <= k) vec.emplace_back(i);
    }
    sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#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##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<int> X(Q);
    rep(i, Q) cin >> X[i];

    vector<ll> sumA(N + 1);
    rep(i, N) sumA[i + 1] = sumA[i] + A[i];
    vector<ll> sumAeo(N + 1);
    sumAeo[1] = A[0];
    rep(i, 1, N) sumAeo[i + 1] = sumAeo[i - 1] + A[i];

    rep(i, Q) {
        int l = 0, h = 1e9;
        while (h - l > 1) {
            int mid = (l + h) / 2;

            int tak = A.end() - lower_bound(all(A), X[i] + mid);
            int aok = lower_bound(all(A), X[i] + mid) - upper_bound(all(A), X[i] - mid);

            if (aok > tak) h = mid;
            else l = mid;
        }

        auto iab = upper_bound(all(A), X[i] - l);
        auto iatb = lower_bound(all(A), X[i] + l);
        int tak = A.end() - iatb;
        int aok = iatb - iab;
        int atb = iatb - A.begin();
        int ab = iab - A.begin();

        if (tak - aok == 0) {
            write(sumA[N] - sumA[atb] + sumAeo[ab]);
        }
        else if (tak - aok == 1) {
            write(sumA[N] - sumA[atb] + (ab > 0 ? sumAeo[ab - 1] : 0));
        }
        else {
            write(sumA[N] - sumA[atb] + (ab > 1 ? sumAeo[ab - 2] : 0));
        }
    }
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void){
  int K,S; cin>>K>>S;
	int cnt = 0;
  for(int x = 0; x <= K; x++){
		for(int y = 0; y <= K; y++){
			int z = S - x - y;
			if(0 <= z && z <= K)cnt++;
		}
	}
	cout<<cnt;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int k,t;
    cin >> k >> t;
    int a[t],sum = 0;
    for(int i = 0;i < t;i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a,a + t,greater<int>());
    if(sum - a[0] >= a[0] - 1)
    {
        cout << "0\n";
    }
    else
    {
        cout << a[0] - (sum - a[0]) - 1 << "\n";
    }
    
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	
	vector<int> pool;
	
	unordered_set<int> notInPool;
	for (int i = 0; i < k; i++) {
		int a;
		cin >> a;
		notInPool.insert(a);
	}
	
	for (int i = 0; i <= 9; i++) {
		if (!notInPool.count(i)) pool.push_back(i);
	}
	
	queue<int> q;
	q.push(0);
	while (!q.empty()) {
		int head =  q.front(); q.pop();
		if (head >= n) {
			cout << head << endl;
			break;
		}
		
		for (int num : pool) {
			q.push(head * 10 + num);
		}
	}
	
    return 0;
}


Measured memory_bytes: 512
#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;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
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; }
int main(){
int n;
cin>>n;
V<ll> a(n),l(n);
V<P> s(n);
for(int i=0;i<n;i++){
    cin>>a[i]>>l[i];
    s[i].se=a[i]-l[i];
    s[i].fi=a[i]+l[i]-1;
}
sort(all(s));
ll ans=0,t=-inf;
for(int i=0;i<n;i++){
  if(t<s[i].se){
      ans++;
      t=s[i].fi;
  }
}
cout<<ans<<endl;
}



Measured memory_bytes: 3456
#include <iostream> 
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::unordered_set;
using std::unordered_map;

int main()
{
    long long n, k;
    cin >> n >> k;
    vector<long long> A (n, 0);
    for (int i = 0; i < n; i++)
    {
        long long num;
        cin >> num;
        A[i] = num;
    }
    unordered_set<long long> visitedSet;
    unordered_map<long long, long long> visitedMap;
    unordered_map<long long, long long> visitedMap2;
    visitedSet.insert(0);
    visitedMap.emplace(0, 0);
    long long counter = 0;
    long long numPrev = 0;
    while (counter < k && visitedSet.find(A[numPrev] - 1) == visitedSet.end())
    {
        numPrev = A[numPrev] - 1;
        counter++;
        visitedSet.insert(numPrev);
        visitedMap.emplace(numPrev, counter);
        visitedMap2.emplace(counter, numPrev);
    }
    if (counter == k)
        cout << numPrev + 1 << endl;
    else
    {
        long long cycleSize = (counter + 1) - visitedMap[A[numPrev] - 1];
        k -= visitedMap[A[numPrev] - 1];
        int counter = visitedMap[A[numPrev] - 1] + (k % cycleSize);
        cout << visitedMap2[counter] + 1 << endl;  
    }
    
    

}

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

using namespace std;

const int N=10005;

int arr[N],ans[N];
vector<int> adj[N];
vector<int> v;
int n;

void dfs(int x,int pa=-1)
{
	for(int i:adj[x])
		if(i!=pa)
			v.push_back(i);
	for(int i:adj[x])
		if(i!=pa)
			dfs(i,x);
}

int main()
{
	cin >> n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	for(int i=0;i<n;i++)
		cin >> arr[i];
	sort(arr,arr+n);
	reverse(arr,arr+n);
	v.push_back(1);
	dfs(1);
	int cur=0;
	for(int i=0;i<n;i++)
	{
		if(i) cur+=arr[i];
		ans[v[i]]=arr[i];
	}
	cout << cur << endl;
	for(int i=1;i<=n;i++)
		cout << ans[i] << " \n"[i==n];
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int a1b1,a1b2,a1b3;
  cin >> a1b1 >> a1b2 >> a1b3;
  int a2b1,a2b2,a2b3;
  cin >> a2b1 >> a2b2 >> a2b3;
  int a3b1,a3b2,a3b3;
  cin >> a3b1 >> a3b2 >> a3b3;
  bool ans=false;
  for(int a1=0; a1<=a1b1; a1++){
    int b1, b2, b3;
    b1 = a1b1-a1;
    b2 = a1b2-a1;
    b3 = a1b3-a1;
    if(a2b1-b1==a2b2-b2 && a2b2-b2==a2b3-b3 && a3b1-b1==a3b2-b2 && a3b2-b2==a3b3-b3){
      ans = true;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

int main()
{
    vector<stack<char>> vs(3);
    for (int i = 0; i < 3; i++) {
        string s;
        cin >> s;
        for (int j = s.size() - 1; j >= 0; j--) {
            vs[i].push(s[j]);
        }
    }

    char c, next = 'a', ans;
    for (;;) {
        c = next;
        if (vs[next - 'a'].size() == 0) {
            ans = c - ' ';
            break;
        }
        next = vs[next - 'a'].top();
        vs[c - 'a'].pop();
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//atcoder clange
#include <stdio.h>

int main(void){
    int N;
    int K;
    int i,j,k,n;
      scanf("%d", &N);//数値の取得
     scanf("%d", &K);//数値の取得
    char str[N];
   scanf("%s", str);//数値の取得
	
  
  	for(i=0;i<N;i++){
	if(i+1 == K){
		if(str[i] == 'A'){
          str[i] = 'a';
        }
      if(str[i] == 'B'){
        str[i] = 'b';
        }
      if(str[i] == 'C'){
        str[i] = 'c';
        }
    }
    }
  
  	printf("%s",str);
    
    return 0;
}

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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;

    if (n%2 == 0) {
        printf("%.10f\n", 0.5);
    }else{
        printf("%.10f\n", (double)(n/2+1)/n);
    }
    return 0;
}


Measured memory_bytes: 3732
from sys import stdin

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

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

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
      
# N個の島とM本の橋
N, M = [int(x) for x in stdin.readline().rstrip().split()]
bridge = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]
 
# Union-Find木の定義
unionfind = UnionFind(N)
 
# 逆順にする
bridge.reverse()
 
# 結果の格納リスト
result = []
 
# Union-Find木のindexに合わせる
for i in range(M):
    bridge[i] = [bridge[i][0]-1, bridge[i][1]-1]
 
for land1, land2 in bridge:
    # 島同士の所属しているグループが一緒かどうか
    if unionfind.isSameGroup(land1, land2):
        result.append(0)
    else:
        # 島同士が完全に素の場合、それぞれが属するグループの点の数を掛けたものになる
        num = unionfind.Count(unionfind.Find_Root(land1)) * unionfind.Count(unionfind.Find_Root(land2))
        result.append(num)
        # 島同士を繋げる
        unionfind.Unite(unionfind.Find_Root(land1), unionfind.Find_Root(land2))
 
answer = 0
for i in range(M):
    answer += result[M-1-i]
    print(answer)

Measured memory_bytes: 34044
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    char x,y;
    cin>>x>>y;
    char ans ='=';
    if(x>y)ans='>';
    else if(x<y)ans='<';
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>
#include <set>

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

using namespace std;
int H, W;
int c[10][10];
int A[201][201];

bool used[10] = {false};

int cnt[10] = {1000000000};

int dfs(int n, int s) {
    int ret = 1000000;
    REP(i, 10) {
        if (i==1)
            continue;
        if (!used[i]) {
            used[i] = true;
            ret = min(min(ret, s+c[n][1]), dfs(i, s+c[n][i]));
            used[i] = false;
        }
    }
    return ret;
}

int main()
{
    scanf("%d %d", &H, &W);
    REP(i, 10) {
        REP(j, 10)
            scanf(" %d", &c[i][j]);
    }
    REP(i, H) {
        REP(j, W)
            scanf(" %d", &A[i][j]);
    }


    REP(i, 10) {
        cnt[i] = dfs(i, 0);
    }
    int ans = 0;
    REP(i, H) {
        REP(j, W) {
            if (A[i][j]!=-1)
                ans += cnt[A[i][j]];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;
using ll = long long;

int main(){
    ll n;
    cin>>n;
    vector<ll> A(n+2);
    A[0] = 0;
    A[n+1] = 0;
    for (int i=1;i<=n;i++){
        cin>>A[i];
    }
    ll len = 0;
    for (int i=1;i<=n+1;i++){
        len += abs(A[i] - A[i-1]);
    }
    for (int i = 1;i<=n;i++){
        cout << len - abs(A[i]-A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] - A[i-1])<<endl;
    }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
vector<ll> adj[N];
ll val[N];
ll res[N];

void dfs(ll curr, ll prev1 = -1, ll sum1 = 0) {
  res[curr] = sum1 + val[curr];
  for (ll x : adj[curr]) {
    if (x != prev1) {
      dfs(x, curr, sum1 + val[curr]);
    }
  }
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, q;
  cin >> n >> q;

  for (ll i = 1; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  memset(val, 0, sizeof(val));

  for (ll i = 1; i <= q; i++) {
    ll v, x;
    cin >> v >> x;
    val[v] += x;
  }

  dfs(1);

  for (ll i = 1; i <= n; i++)
    cout << res[i] << " ";
  cout << en;
  return 0;
}

Measured memory_bytes: 25856
using System;
using System.Collections.Generic;

namespace PrimeNumber
{
    class Program
    {
        private static bool IsPrime(int n)
        {
            if (n < 2) return false;
            if (n == 2) return true;
            if (n % 2 == 0) return false;

            double l = Math.Sqrt(n);

            for (var i = 3; i <= l; i += 2)
            {
                if (n % i == 0)
                {
                    return false;
                }
            }
            
            return true;
        }

        static void Main(string[] args)
        {
            int num;

            while (int.TryParse(Console.ReadLine(), out num))
            {
                var count = 0;
                for (var i = 2; i <= num; i++)
                  if(IsPrime(i)) count++;
                Console.WriteLine(count);
            }
        }
    }
}


Measured memory_bytes: 9000
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Weather Prediction
            var S = Console.ReadLine();
            string ans = "Sunny";

            switch (S)
            {
                case "Sunny":
                    ans = "Cloudy";
                    break;
                case "Cloudy":
                    ans = "Rainy";
                    break;
            }

            Console.WriteLine(ans);
        }
    }
}

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

using std::pair;
using std::vector;
using std::string;

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

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int M = 16;
const int N = 1 << 16;
const int mo = 1e9 + 7;

int fpm(int x, int y) {
    int res = 1;
    for(; y > 0; y >>= 1) {
        if(y & 1)
            res = (ll) res * x % mo;
        x = (ll) x * x % mo;
    }
    return res;
}

inline void add(int &x, int y) {
    (x += y) >= mo ? x -= mo : 1;
}

int n, m;
int a[M + 5];
int dp[N + 5][M + 5];
int fac[N + 5], inv[N + 5];

inline int binom(int x, int y) {
    if(x < y) return 0;
    return (ll) fac[x] * inv[y] % mo * inv[x - y] % mo;
}

void init() {
    fac[0] = 1;
    for(int i = 1; i <= N; ++i) fac[i] = (ll) fac[i-1] * i % mo;
    inv[N] = fpm(fac[N], mo - 2);
    for(int i = N; i >= 1; --i) inv[i-1] = (ll) inv[i] * i % mo;
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    init();
    read(n), read(m);
    for(int i = 0; i < m; ++i) read(a[i]);

    int all = 1 << n;

    dp[0][m] = 1;
    for(int i = 0; i < all; ++i) {
        for(int k = m; k >= 1; --k) if(dp[i][k]) {
            add(dp[i][k - 1], dp[i][k]);
            for(int j = 0; j < n; ++j) if(!(i >> j & 1)) {
                add(dp[i | (1 << j)][k - 1], (ll) dp[i][k] * binom(all-i-a[k-1], (1<<j)-1) % mo * fac[1 << j] % mo);
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < all; ++i) {
        int tmp = (ll) dp[i][0] * fac[(all - 1) - i] % mo;

        if(__builtin_popcount(i) & 1) {
            add(ans, mo - tmp);
        } else {
            add(ans, tmp);
        }
    } ans = (ll) ans * all % mo;

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

    return 0;
}


Measured memory_bytes: 6144
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;
const int N  =105;
int a[N];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int n, m;
    cin>>n>>m;
    int sum=0;
    for(int i = 1; i <= n; ++i){
        cin>>a[i];
        sum += a[i];
    }
    int cnt=0;
    for(int i=1;i<=n;++i){
        if(a[i] * 4 * m >= sum) cnt++;
    }
    if(cnt >= m) puts("Yes");
    else puts("No");
    return 0;
}



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

using namespace std;

using pii = pair<int, int>;
using lli = long long int;

#define debug(args...) fprintf(stderr, args)
#define pb push_back
#define all(xs) xs.begin(), xs.end()

const int INF = 1e9;

int main() {
	lli a, b, c, d;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	printf("%lld\n", max(a*c, max(b*d, max(a*d, b*c))));
}

Measured memory_bytes: 3860
using System;

public class Program
{
    public static long loop;

    static long n;

    static char[] sc;

    static string output;

    public static void Main(string[] args)
    {
        loop = 0;

        Input();
        Proc();
        Output();
    }

    static void Input()
    {
        string[] input = null;

        // スペース区切りの整数の入力(横、個別)
        input = Console.ReadLine().Split(' ');

        n = long.Parse(input[0]);

        // 文字列を数値の配列として読込
        sc = Console.ReadLine().ToCharArray();
    }

    static void Proc()
    {
        long result = n;

        for (int i = 0; i < n - 1; i ++)
        {
            if (sc[i] == sc[i + 1])
            {
                result--;
            }
        }
    
        output = result.ToString();
    }

    static void Output()
    {
        // 出力
        Console.WriteLine(output);
        output = string.Empty;
    }
}


Measured memory_bytes: 11732
/**
  @file a.cpp
  @title
  @url https://atcoder.jp/contests/abc135/tasks/abc135_a
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  int A, B;
  cin >> A >> B;

  if (min(A, B) == 0) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    REP(k, max(A, B)) {
      if (abs(A - k) == abs(B - k)) {
        cout << k << endl;
        return 0;
      }
    }
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h> 
int main(void){
  int N,S,a,b,c;
  scanf("%d\n", &N);
  int A[N];
  for(int i = 1; i <= N; i++){
    scanf("%d ", &A[i]);
  }
  S = 0;
  b = 0;
  for(int l = 1; l <= N; l++){
    S = S + A[l];
  }
  for(int k = 1; k < N; k++){
    a = S;
    for(int j = 1; j <= k; j++){
      a = a - A[j];
    }
    b = b + A[k]*a;
  }
  printf("%d", b);
  return 0;
}

Measured memory_bytes: 384
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素因数の種類の数＋１が答え

def main():
  a, b = sorted(list(map(int, input().split())), reverse = True)
  while b != 0:
    a, b = b, a % b
  print(num_facto(a) + 1)  
  
def num_facto(n):
  ans = 0
  max_n = int(n ** 0.5) + 1
  is_prime = [True for x in range(max_n + 1)]
  is_prime[0], is_prime[1] = False, False
  for cursor in two_and_odds(max_n):
    if is_prime[cursor]:
      if n % cursor == 0:
        ans += 1
        while n % cursor == 0:
          n = n // cursor
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  if n != 1:
    ans += 1
  return ans

def two_and_odds(max_n):
  if max_n >= 2:
  	yield 2
  for i in range(3, max_n, 2):
    yield i
    
if __name__ == "__main__":
  main()


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

int main()
{
long long A,V,B,W,T;
cin>>A>>V>>B>>W>>T;
    
if ( abs(B-A)-T*V+T*W<=0  ){
 cout<<"YES"<<endl; 
}
else{
 cout<<"NO"<<endl; 
}
}




Measured memory_bytes: 3616
s=gets.chomp
c=0
h=Hash.new(0)
s.length.times do |i|
  if h[s[i]]==0
    c+=1
    h[s[i]]=1
  else
    c-=1
    h[s[i]]=0
  end
end
puts c==0 ? :Yes : :No

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

int A[200010],B[200010],num[200010];
int N,M,W,C,D,E,G,K;
int ans,ans2,sum,sum2,cnt,cnt2,Max=0,Min=INF;
string S,T;
vector<int> V;
set<int> U;
map<int,int> H;
bool F,Q[200010];

signed main(){
	ans=INF;
	cin>>N>>G;
	REP(i,N){
		cin>>A[i]>>B[i];
	}
	REP(Bit,1<<N){
		sum=0,cnt=0,Max=0;
		REP(i,N){
			if(Bit&(1<<i)){
				sum+=100*(i+1)*A[i]+B[i];
				cnt+=A[i];
			}
			else{
				Max=i;
			}
		}
		if(sum<G){
			int need=(G-sum+100*(Max+1)-1)/(100*(Max+1));
			if(need>=A[Max]){
				continue;
			}
			cnt+=need;
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2304
// ARC 54 B

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

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

int A[3][102] = {0};
int U[102] = {0};
int L[102] = {0};

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

  rep(i, 2) {
    rep(j, n) {
      cin >> A[i+1][j+1];
    }
  }

  for (int i = 1; i <= n; i++) {
    U[i] = U[i-1] + A[1][i];
  }

  for (int i = n; i > 0; i--) {
    L[i] = L[i+1] + A[2][i];
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = U[i] + L[i];
    chmax(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int a=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());
        int c=Integer.parseInt(st.nextToken());
        System.out.println((a<b&&b<c) ? "Yes":"No");
    }
}

Measured memory_bytes: 24404
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

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


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))
#define each(itr,v) for(auto (itr):(v))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
	return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
	return a * a;
}

template <typename T>
T gcd(T a, T b) {
	if (a > b) return gcd(b, a);
	return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
	if (n == 0) return 1;
	if (n == 1) return b /* % MOD */;
	if (n % 2 == 0) {
		return mypow(b * b /* % MOD */, n / 2);
	}
	else {
		return mypow(b, n - 1) * b /* % MOD */;
	}
}

ll pcnt(ll b) {
	return __builtin_popcountll(b);
}



// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	pair<int, int> P[N];
	REP(i, N) {
		cin >> P[i].first >> P[i].second;
	}
	ll A = 1, B = 1;
	REP(i, N) {
		ll n = max((A + P[i].first - 1) / P[i].first,( B + P[i].second - 1) / P[i].second);
		A = P[i].first*n;
		B = P[i].second*n;
	}
	cout << A + B << endl;
	return 0;

}

Measured memory_bytes: 256
def main():
  h, w, d = map(int, input().split())
  dic = {}
  for i in range(1, h + 1):
    alst = list(map(int, input().split()))
    for j in range(w):
      dic[alst[j]] = (i, j + 1)
  
  acc = []
  for i in range(d):
    lst = [0]
    a = 0
    x, y = dic[(i - 1) % d + 1]
    for j in range((i - 1) % d + 1 + d, h * w + 1, d):
      x2, y2 = dic[j]
      a += abs(x - x2) + abs(y - y2)
      x, y = x2, y2
      lst.append(a)
    acc.append(lst)
  q = int(input())
  ans = 0
  for _ in range(q):
    l, r = map(int, input().split())
    ld = l // d
    rd = r // d
    if l % d == 0:
      ld -= 1
      rd -= 1
    ans = acc[l % d][rd] - acc[l % d][ld]
    print(ans)

  
main()

Measured memory_bytes: 27488
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

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

  if(x == 0) cout << 1 << endl;
  if(x == 1) cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>

int main() {

  	long long s;
  	std::cin >> s;
  	std::string ans;
  	while (s) {
    	s--;
      	ans += 'a' + s%26;
      	s = s / 26;	
    }
  
  	std::reverse(ans.begin(), ans.end());
    
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main()
{
	int num[3];
  	scanf("%d%d%d",&num[1],&num[2],&num[3]);
  	if(num[1]==num[2]){
    	printf("%d",num[3]);
    }
    if(num[2]==num[3]){
    	printf("%d",num[1]);
    }
  	if(num[3]==num[1]){
    	printf("%d",num[2]);
    }
  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			String input = br.readLine();
			String[] splitInput = input.split(" ", 0);

			int a = Integer.parseInt(splitInput[0]);
			int b = Integer.parseInt(splitInput[1]);
			
			if (!((a >= -1000 && a <= 1000) && (b >= -1000 && b <= 1000))) {
				throw new IllegalArgumentException();
			}
			
			String sign;
			if (a > b) {
				sign = " > ";
			} else if (a < b) {
				sign = " < ";
			} else {
				sign = " == ";
			}
			
			System.out.println("a" + sign + "b");
		
		} catch(NumberFormatException e) {
			e.printStackTrace();
		} catch(IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24216
#include<stdio.h>
int main()
{
long int n,k,i,cc,ans,ll;
  ll=0;
  ans=1;
  cc=0;
  scanf("%ld %ld",&n,&k);
long int sw[100001],a[n],b[n];
  for(i=0;i<n;++i)
  {
  scanf("%ld %ld",&a[i],&b[i]);
  }
  
  for(i=0;i<100001;++i)
  {
  sw[i]=0;
  }

  for(i=0;i<n;++i)
  {
  sw[a[i]]=sw[a[i]]+b[i];
  }
  
  while(cc==0)
  {
  ll=ll+sw[ans];
  if(ll<k) ans++;
  else cc++;
  }
  printf("%ld",ans);
return 0;}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int a,b;
	cin>>a>>b;
	for(int i=b+1-a;i<=a+b-1;i++) cout<<i<<" ";
}

Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))
res = 0
for i in range(N - 2):
  if((p[i] < p[i + 1]) and (p[i + 1] < p[i + 2])):
    res += 1
  if((p[i] > p[i + 1]) and (p[i + 1] > p[i + 2])):
    res += 1
  if((p[i] == p[i + 1]) and (p[i] > p[i + 2])):
    res += 1
  if((p[i] == p[i + 2]) and (p[i] > p[i + 1])):
    res += 1
print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;
//union find木(グループわけができる)
int par[200005];
int unifind(int n) {
	for (int i = 1; i <= n; i++) {
		par[i] = i;
	}
	return 0;
}
//木の根を求める
int unifind_root(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = unifind_root(par[x]);
	}
}
//同じグループか判定
bool unifind_same(int x, int y) {
	return unifind_root(x) == unifind_root(y);
}
//グループ併合
int unifind_unite(int x, int y) {
	x = unifind_root(x);
	y = unifind_root(y);
	if (x == y) {
		return 0;
	}
	par[x] = y;
}

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n,u[200000],v[200000],w[200000];
	long double x=0;
	string str, str2;
	cin >> n ;
	unifind(2*n);
	for (int i = 1; i <= n-1; i++) {
		cin >> u[i]>>v[i]>>w[i];
		if (w[i]%2 == 0) {
			unifind_unite(u[i], v[i]);
			unifind_unite(u[i]+n, v[i]+n);
		}
		else {
			unifind_unite(u[i], v[i]+n);
			unifind_unite(u[i]+n, v[i] );
		}
	}
	for (int i = 1; i <= n; i++) {
		if (unifind_root(1) == unifind_root(i)) {
			cout << 0 << endl;
		}
		else {
			cout << 1 << endl;
		}
	}
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    double ans=0;
    rep(i,n){
      double a;
      cin>>a;
      ans+=(double)1/a;
    }
    cout<<setprecision(30)<<(double)1/ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
sunuke,arai = a[0],sum(a)-a[0]
A = [abs(sunuke-arai)]
for i in range(1,N-1):
    sunuke += a[i]
    arai -= a[i]
    A.append(abs(sunuke - arai))
print(min(A))

Measured memory_bytes: 30612
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  string s, t;
  cin >> s >> t;
  sort(all(s));
  sort(allr(t));
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define int long long
#define pii pair<int, int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define jai_shree_ram  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, a, b, d) for (int i = a; i <= b; i += d)
#define brep(i, a, b, d) for (int i = a; i >= b; i -= d)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
int MOD = 1e9 + 7;
////////////////////////////////



int32_t main(){
    jai_shree_ram
    int x;
    cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;   
}

Measured memory_bytes: 3524
'use strict'
function Main(input) {
  	// 情報の切り分け
    let Nums = input.trim().split('\n').map(x => x.split(' '));
  	// 最初の情報を取り出す
  	let info = Nums.shift();
  
  	// 小さい方で一番大きな値を出す
  	let minNums = Nums.map(num => num[0]);
  	let minNumsTop = Math.max(...minNums);
  
    // 小さい方で一番大きな値を出す
  	let maxNums = Nums.map(num => num[1]);
  	let maxNumsBottom = Math.min(...maxNums);
  	
  	let ans = maxNumsBottom - minNumsTop >= 0 ? 
        		maxNumsBottom - minNumsTop + 1:
    			0;
  	// 大きい方引く小さい方に一足したものが答え
    console.log(ans);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 56156
#include<stdio.h>
#define max 100000
#define NIL -1
typedef struct{
  int parent,left,right;
} node;
node T[max];
int n,D[max],H[max];
void setDepth(int ,int);
int setHeight(int);
int sibling(int);
void print(int);
int main(){
  int v,l,r,root=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL)T[l].parent=v;
    if(r!=NIL)T[r].parent=v;
  }
  for(i=0;i<n;i++)if(T[i].parent==NIL)root=i;
  setDepth(root,0);
  setHeight(root);
  for(i=0;i<n;i++)print(i);
  return 0;
}
void setDepth(int u,int d){
  if(u==NIL)return ;
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
  
}
int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL)
    h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL)
    h2=setHeight(T[u].right)+1;
  return H[u]=(h1>h2 ? h1:h2);
}
int sibling(int u){
  if(T[u].parent==NIL)return NIL;
  if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)
    return T[T[u].parent].right;
  return NIL;
}
void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",sibling(u));
  int deg=0;
  if(T[u].left!=NIL)deg++;
  if(T[u].right!=NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  if(T[u].parent==NIL){
    printf("root\n");
  }else if(T[u].left==NIL&&T[u].right==NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}



Measured memory_bytes: 2044
def main():
    N = int(input())
    P = list(map(int, input().split()))
    delta = [0] * N
    for i, p in enumerate(P):
        delta[p-1] = i
    A = [0] * N
    B = [0] * N
    A[0] = a = delta[0] + 1
    B[0] = b = int(1e9)

    for i in range(1, N):
        a += 1
        b -= 1
        tmp = delta[i] - delta[i-1]
        if tmp > 0:
            a += tmp
        else:
            b += tmp
        A[i] = a
        B[i] = b
    print(*A)
    print(*B)


if __name__ == "__main__":
    main()


Measured memory_bytes: 46084
using System;

namespace Test
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			// 半角スペース区切り
			string[] input = Console.ReadLine().Split(' ');
			ulong a = ulong.Parse(input[0]);
			ulong b = ulong.Parse(input[1]);
			ulong x = ulong.Parse(input[2]);
			ulong i = a / x;
			if (a % x > 0)
			{
				i++;
			}
			ulong j = b / x;
			if (i > j)
			{
				Console.Write((0));
			}
			else
			{
				//出力
				Console.Write((j - i + 1));
			}
		}
	}
}

Measured memory_bytes: 2772
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  cin>>n;
  rep(i,n){
    cout<<"Case " << i + 1 << ":" << endl;
    int num;
    cin>>num;
    rep(j,10){
      num = int(pow(num,2) / 100 ) % 10000;
      cout<<num<<endl;;
    }
  }

}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
	int a,b;
	
	long int c;
	scanf("%d%d",&a,&b);
	if(a >=1&&a<=10000 && b>=1&&b<=10000){
		c = a*b;
		if(c %2 != 0)
			printf("Odd");
		else
			printf("Even");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}

/* main */

struct UnionFind{
  vector<long long> data;
  void boot(long long n){
    for(long long i = 0;i < n;i++)data.push_back(-1);
    return;
  }
  long long root(long long x){
    if(data[x] < 0)return x;
    else return data[x] = root(data[x]);
  }
  bool same(long long x,long long y){
    return root(x) == root(y);
  }
  void unite(long long x,long long y){
    if(!same(x,y)){
      x = root(x);
      y = root(y);
      if(data[x] < data[y]){
        data[x] += data[y];
        data[y] = x;
      }
      else{
        data[y] += data[x];
        data[x] = y;
      }
    }
    return;
  }
  long long getsize(long long x){
    return -data[root(x)];
  }
};

ll H,W;

ll func(ll i,ll j){
    return i*W+j;
}

signed main(){
    cin >> H >> W;
    char c[H][W];
    FOR(i,0,H)FOR(j,0,W)cin >> c[i][j];
    UnionFind UF;
    UF.boot(H*W);
    FOR(i,0,H)FOR(j,0,W-1){
        if(c[i][j] != c[i][j+1])UF.unite(func(i,j),func(i,j+1));
    }
    FOR(i,0,H-1)FOR(j,0,W){
        if(c[i][j] != c[i+1][j])UF.unite(func(i,j),func(i+1,j));
    }
    ll black[H*W] = {0};
    ll white[H*W] = {0};
    FOR(i,0,H)FOR(j,0,W){
        if(c[i][j] == '#'){
            black[UF.root(func(i,j))]++;
        }
        else{
            white[UF.root(func(i,j))]++;
        }
    }
    ll ans = 0;
    FOR(i,0,H*W)ans += black[i] * white[i];
    cout << ans << endl;
}

Measured memory_bytes: 4336
#include<stack>
#include<vector>
#include<cstdio>
#include<map>
#include<queue>
#include<set>
#include<iostream>
#include<string>
#include<algorithm> 
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> p(n);
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		p[k-1]=i;
	}
	int t=1,ans=1;
	for(int i=1;i<n;i++){
		if(p[i]>p[i-1]){
			t++;
		}else{
			t=1;
		}
		ans=max(ans,t);
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <unistd.h>
#include <stdio.h>
#include <string.h>

int main()
{
    int k;
    int len;
    char s[101];

    // 入力受け取り
    scanf("%d", &k);
    scanf("%s",s);

    len = strlen(s);
    if (len <= k)
    {
        printf("%s", s);
    }
    else
    {
        write(1,s,k);
        printf("...");
    }
    return 0;
}

Measured memory_bytes: 2152
using System;
using System.Linq;

class E
{
	static void Main()
	{
		var s = Console.ReadLine();
		var n = s.Length;

		if (s[0] != '1' || s[^1] != '0' || Enumerable.Range(0, n / 2).Any(i => s[i] != s[n - 2 - i])) { Console.WriteLine(-1); return; }

		var dp = new int[n];
		var t = n;
		for (int i = 1; i < n; i++)
		{
			dp[i] = t;
			if (s[i - 1] == '1') t = i;
		}
		Console.WriteLine(string.Join("\n", Enumerable.Range(1, n - 1).Select(i => $"{dp[i]} {i}")));
	}
}


Measured memory_bytes: 41288
#include <cstdio>
#include <utility>
#include <algorithm>

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  using pair = std::pair<int, int>;
  pair p[100000];
  for (int i = 0; i < m; ++i)
  {
    scanf("%d%d", &p[i].second, &p[i].first);
  }
  std::sort(p, p + m);
  int ans = 0;
  int last = -1;
  for (int i = 0; i < m; ++i)
  {
    if (p[i].second <= last) continue;
    ++ans;
    last = p[i].first - 1;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 896