akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,m,q;
    cin>>n>>m>>q;
    int sum[n+1][n+1];
    memset(sum,0,sizeof(sum));
    for(int i=0;i<m;i++){
        int l,r;
        cin>>l>>r;
        sum[l][r]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            sum[i][j]=sum[i][j]+sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1];
        }
    }
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        cout<<sum[n][r]-sum[l-1][r]<<endl;
    }
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n,m;
  cin>>n>>m;
  int a[n],b[n],c[m],d[m];
  rep(i,n) cin>>a[i]>>b[i];
  rep(i,m) cin>>c[i]>>d[i];
  rep(i,n) {
    int mm = 0;
    int mdis = abs(a[i] - c[0]) + abs(b[i] - d[0]);
    rep(j,m) {
      if(abs(a[i] - c[j]) + abs(b[i] - d[j]) < mdis) {
        mm = j;
        mdis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      }
    }
    cout << mm + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int one=n/100,two=n%100;
    bool o=0,t=0;
    if(one>0&&one<=12) o=1;
    if(two>0&&two<=12) t=1;
    if(o&&t) cout << "AMBIGUOUS" << endl;
    else if(o) cout << "MMYY" << endl;
    else if(t) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
       int a;string s;cin>>a>>s;
       cout<<(a>=3200?s:"red");
    }
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N + 2), B(N + 1), S(N + 2);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i + 1);
    }

    for (int i = 0; i < N + 1; i++) {
        B[i] = abs(A[i + 1] - A[i]);
        //  cout << B[i] << " ";
    }
    //cout << endl;
    for (int i = 0; i < N + 1; i++) {
        S[i + 1] = S[i] + B[i];
        //  cout << S[i + 1] << " ";
    }
    //cout << endl;
    for (int i = 0; i < N; i++) {
        cout << S[i] + abs(A[i + 2] - A[i]) + S[N + 1] - S[i + 2] << "\n";
    }
}


Measured memory_bytes: 3584
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main() {

    int A1,A2,A3; cin>>A1>>A2>>A3;
    if(A1+A2+A3 >= 22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;

    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc138/tasks/abc138_e

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int S_MAX = 1e5;
const int T_MAX = 1e5;

char s[S_MAX + 1];
char t[T_MAX + 1];

int S, T;
set<int> pos[26];

void solve() {
  S = strlen(s);
  T = strlen(t);
  REP(i, S) pos[s[i] - 'a'].insert(i);
  int use = 0;
  int cur = -1;
  REP(i, T) {
    set<int> &st = pos[t[i] - 'a'];
    if (st.empty()) {
      puts("-1");
      return;
    }
    auto it = st.upper_bound(cur);
    if (it == st.end()) {
      use++;
      it = st.begin();
    }
    cur = *it;
  }
  printf("%lld\n", (ll)use * S + cur + 1);
}

void input() {
  scanf("%s", s);
  scanf("%s", t);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 5120
import sys
input = sys.stdin.readline
def isSafe(position):
    return not position in listM
 
 
STEP = 2
N,M = map(int,input().split())
dp = [0] * (N+1)
cnt = 0
 
 
listM={int(input()) for i in range(M)}
dp[0] = 1
 
for i in range(N):
    if i+1 > N:
        break
    if isSafe(i+1):
        dp[i+1] += dp[i]
    if i+2 > N:
        break
    if isSafe(i+2):
        dp[i+2] += dp[i]
        #dp[j] = 0
    #print(dp)
        
print(dp[N] % 1000000007)

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 1e5 + 3;
int N;
vector<int> V[MC];
string C;
int ans[MC][8];

void solve(int p , int q){
	fill(ans[q],ans[q]+8,1e9);
	ans[q][0] = C[q]=='B'?0:1;
	ans[q][4] = C[q]=='W'?0:1;
	for(auto r : V[q]) if(r != p){
		solve(q,r);
		if(ans[r][0] == 0) continue;
		int tmp[8]; fill(tmp,tmp+8,1e9);
		repp(i,0,4) repp(j,0,4) if((i&j) == i) repp(k,0,4) if((j&k) == 0){
			tmp[j^k] = min(tmp[j^k],ans[q][(j==1?0:4)^k]+ans[r][i]+(j==2?0:1)+(j==1||j==2?1:2));
			tmp[j^k] = min(tmp[j^k],ans[q][(j==1?0:4)^k]+ans[r][4^i]+(j==2?1:0)+(j==1||j==2?1:2));
			tmp[4^j^k] = min(tmp[4^j^k],ans[q][(j==1?4:0)^k]+ans[r][i]+(j==2?0:1)+(j==1||j==2?1:2));
			tmp[4^j^k] = min(tmp[4^j^k],ans[q][(j==1?4:0)^k]+ans[r][4^i]+(j==2?1:0)+(j==1||j==2?1:2));
		}
		repp(i,0,8) ans[q][i] = min(tmp[i],tmp[4^i]+1);
	}
}

int main(){
	cin >> N;
	repp(i,1,N){
		int x,y; cin >> x >> y; --x; --y;
		V[x].push_back(y);
		V[y].push_back(x);
	}
	cin >> C;
	int z = 0;
	while(z < N && C[z] == 'B') ++z;
	if(z == N) return cout << 0 << endl , 0;
	solve(-1,z);
	repp(i,1,4) ans[z][0] = min(ans[z][0],ans[z][i]);
	cout << ans[z][0] << endl;
	return 0;
}


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

const int MAX_NUM = 100000;

int N;
int h[MAX_NUM];

// dp[i] := インデックスi(0起算)の足場までの最小コスト
int dp[MAX_NUM];
//if ( i == 0 ) {
//	dp[i + 1] = dp[i] + ::abs( h[i + 1] - h[i] );
//}
//else {
//	dp[i + 1] = ::min( dp[i] + ::abs( h[i + 1] - h[i] ),
//					   dp[i - 1] + ::abs( h[i + 1] - h[i - 1] ) );
//}

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

	dp[0] = 0;

	for ( int i = 0; i < N - 1; ++i ) {
		if ( i == 0 ) {
			dp[i + 1] = dp[i] + ::abs( h[i + 1] - h[i] );
		}
		else {
			dp[i + 1] = ::min( dp[i] + ::abs( h[i + 1] - h[i] ),
							   dp[i - 1] + ::abs( h[i + 1] - h[i - 1] ) );
		}
	}

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

Measured memory_bytes: 1024
#include "bits/stdc++.h"

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

using namespace std;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};

//using Graph = vector<vector<Edge>>
using Graph = vector<vector<int>>;

// header area

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i++)cin >> H[i];

    Graph G(N);
    int a, b;

    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        G[a - 1].push_back(H[b - 1]);
        G[b - 1].push_back(H[a - 1]);
    }

    int ans = 0;

    for (int i = 0; i < N; i++) {
        if (G[i].size() == 0)ans++;
        else {
            for (int j = 0; j < G[i].size(); j++) {
                if (H[i] <= G[i][j])break;
                if (j == G[i].size() - 1)ans++;
            }
        }
    }

    cout << ans;
}

Measured memory_bytes: 8740
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	vi a(3);
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << (a[1] - a[0]) + (a[2] - a[1]) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int m, n;
vector<vector<int>> feats;

map<vector<int>, int> memo;
vector<int> fix;

int dfs(){
    if(memo.find(fix) != memo.end()) return memo[fix];
    int num = 0;
    for(int i=0;i<n;i++){
        bool ok = true;
        for(int j=0;j<m;j++){
            if(fix[j] != 0 && fix[j] != feats[i][j]){
                ok = false;
                break;
            }
        }
        if(ok) num++;
    }
    if(num <= 1) return 0;

    int ret = m;
    for(int i=0;i<m;i++){
        if(fix[i] == 0){
            fix[i] = 1;
            int res1 = dfs();
            fix[i] = 2;
            int res2 = dfs();
            ret = min(ret, max(res1, res2) + 1);
            fix[i] = 0;
        }
    }
    memo[fix] = ret;
    return ret;
}

int main(){
    while(true){
        cin >> m >> n;
        if(m == 0) break;

        feats.assign(n, vector<int>(m, 0));
        for(int i=0;i<n;i++){
            string str;
            cin >> str;
            for(int j=0;j<str.size();j++){
                if(str[j] == '1'){
                    feats[i][j] = 1;
                }else{
                    feats[i][j] = 2;
                }
            }
        }
        sort(feats.begin(), feats.end());

        memo.clear();
        fix.assign(m, 0);
        cout << dfs() << endl;
    }

    return 0;
}

Measured memory_bytes: 10332
N,Y = map(int,input().split())

ans = [-1,-1,-1]

for n1 in range(N+1):
  for n2 in range(N-n1+1):
    yen = n1 * 10000 + n2 * 5000 + (N-n1-n2) * 1000
    if yen == Y:
      ans = [n1,n2,N-n1-n2]
      break

print(" ".join(map(str,ans)))

Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <map>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;

  map<Pii, int> count;

  for (int i = 1; i <= n; i++) {
    int first = i % 10;
    int t = i;
    while (t > 9) t /= 10;
    int last = t;
    count[Pii(first, last)]++;
  }

  int ans = 0;
  for (auto &x: count) ans += x.second * count[Pii(x.first.second, x.first.first)];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
int main(){
	int p=0;
	char s[100002];
	scanf("%s",s);
	FOR(i,0,strlen(s)) if(s[i] == 'p') p++;
	printf("%d",strlen(s)/2 - p);
}

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

int main(){
  ios_base::sync_with_stdio(false);

  int n;
  int a[111];
  int ans1 = 0;
  int ans2 = 0;
  int ave, t=0;; 
 
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    t+=a[i];
  }
  ave = t / n;
  
  for(int i=0;i<n;i++){
    int m = a[i];
    ans1 += pow(m-ave,2);
    ans2 += pow(m-(ave+1), 2); 
  }
  
  cout << min(ans1, ans2) << endl; 

  return 0;
}

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

using namespace std;

int main()
{
 string s;
 cin >> s;
 sort(s.begin(),s.end());
   
 string t;
 cin >> t;
 sort(t.begin(),t.end());
 reverse(t.begin(),t.end());
 
 if (s<t) cout << "Yes" << endl;
 else cout << "No" << endl;
  
}
   


Measured memory_bytes: 256
#include<iostream>
#define INF 1000000006
#define N 5000001
using namespace std;
int n,cnt;
int a[N],L[N],R[N];
void merge(int l,int m,int r){
  int n1=m-l,n2=r-m;
  for(int i=0;i<n1;i++) L[i]=a[l+i];
  for(int i=0;i<n2;i++)R[i]=a[m+i];
  L[n1]=INF,R[n2]=INF;
  int i=0,j=0;
  for(int k=l;k<r;k++){
    if(L[i]<R[j]){
      a[k]=L[i],i++;
    }else {
      a[k]=R[j],j++;
    }
    cnt++;
  }
}

void msort(int l,int r){
  int m;
  if(l+1<r){
 m=(l+r)/2;
  msort(l,m);
  msort(m,r);
  merge(l,m,r);
  }
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  msort(0,n);
  for(int i=0;i<n-1;i++) cout<<a[i]<<" ";
  cout<<a[n-1]<<endl<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 10332
m, d = map(int, input().split())
ans = 0
for i in range(1, m+1):
    days = filter(lambda x: '2' <= x[1], [str(x) for x in range(22, d+1)])
    for day in days:
        if int(day[0]) * int(day[1]) == i:
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,k; cin >> n >> k;
    ll res = 0;
    for(ll b = max(k,1ll);b <= n; ++b){
        ll p = n/b, r = n%b;
        res += p * max(0ll, b-k);
        res += max(0ll, r-k+1);
        if(k == 0)--res;
    }
    cout << res << endl;
}

Measured memory_bytes: 384
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int a,b,c,ans;
  std::cin >> c >> a >> b;
  ans=c-a;
  while(ans>=0) ans-=b;
  std::cout << ans+b << '\n';
  return 0;

}


Measured memory_bytes: 256
fun main(args : Array<String>) {
        val n = readLine()!!.toInt()
        var (red, blue) = (1..n * 2).map { readLine()!!.split(" ").map { it.toInt() } }
                .let { listOf(it.take(n).sortedByDescending { it[1] }, it.takeLast(n).sortedBy { it[0] }) }
        blue.forEach { b -> red.find { it[0] < b[0] && it[1] < b[1] }
                ?.let { red = red.minusElement(it) } }
        println(n - red.size)
}

Measured memory_bytes: 37844
#include<iostream>
#include<cmath>
#include<stack>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
const ll inf =1e17;
typedef unsigned long long ull;
#define scn(a) scanf("%d",&a)
#define scd(a) scanf("%lf",&a)
#define scl(a) scanf("%lld",&a)
#define ptf(a) printf("%d\n",a)
#define mes(a,b) memset(a,b,sizeof(a))
#define fon(s,n) for(int i=s;i<=n;i++)
#define range(i,a,b) for(int i=a;i<=b;++i)
#define rerange(i,a,b) for(int i=a;i>=b;--i)
//#define N 100010
//const ll p =998244353;
//const int S=20;
ll gcd(ll a,ll b) { return b>0 ? gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll q_pow(ll a,ll b,ll mod)
{
	ll ans=1,res=a;
	while(b){
		if(b&1) ans=ans*res%mod;
		res=res*res%mod;
		b>>=1;
	}
	return ans%mod;
}
//ll a[100005];
//int cnt[105]={0};
//char s[1005];
//char t[1005];
int main()
{
	//int a, b, c, d, n, t;
	//int t;
	// //double n,m,x,y;
	// scn(t);
	// while (t--)
	// {
	// 	int n;scn(n);
	// 	for(int i=0;i<n;i++) scl(a[i]);
	// 	sort(a,a+n);
	// 	ll ans1=a[n-1]*a[n-2]*a[n-3]*a[n-4]*a[n-5];
	// 	ll ans2=a[n-1]*a[n-2]*a[n-3]*a[1]*a[0];
	// 	ll ans3=a[n-1]*a[3]*a[2]*a[1]*a[0];
	// 	ll ans=max(ans1,ans2);
	// 	ans=max(ans,ans3);
	// 	printf("%lld\n",ans);
	// }
	string s,t;
	cin>>s>>t;
	//scanf("%s",&s);scanf("%s",&t);
	int n=s.length();int m=t.length();
	int ans=m;
	int k=0;
	for(int i=0;i<=n-m;i++){
		k=0;
		for(int j=0;j<m;j++ ){
			if(s[i+j]!=t[j]) k++;
		}
		ans=min(ans,k);
	}
	ptf(ans);
	return 0;
}





Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t



int main(){
    ll n; cin >> n;
    vector<ll> A(n), B(n); rep(i, n)cin >> A[i] >> B[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    double medmin, medmax;
    if(n%2 == 1) medmin = A[n/2], medmax = B[n/2];
    else medmin = (double)(A[n/2-1]+A[n/2])/2, medmax = (double)(B[n/2-1]+B[n/2])/2;
    if(n%2==0)cout << (ll)((medmax-medmin)*2.0 +1.0)<< endl;
    else cout << (ll)(medmax-medmin)+1 << endl;


}

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

int main(void)
{
    int n;
    char input[256];
    if (fgets(input, 255, stdin) != NULL)
    {
        n = atoi(input);
        printf("%d", n * n);
    }

    return 0;
}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

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


const int MAX = 42;




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

  if(X >= 30){
    cout << "Yes"<< endl;
  }else{
    cout << "No" << endl;
  }

  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 3632
import copy
N = int(input())
A = list(map(int, input().split()))

a_types = set(A)

count_dict = [0] * N
for each in A:
    count_dict[each - 1] += 1

all_types = 0
for value in count_dict:
    all_types += value * (value - 1) // 2

# result_dict = {}
# for each in a_types:
#     result_dict[each] = all_types - count_dict[each] + 1

for a in A:
    print(all_types - count_dict[a - 1] + 1)

Measured memory_bytes: 26908
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int NR= 2e5 + 5 ;
ifstream in("viitor.in");
ofstream out("viitor.out");

long double a,b,c ;
int main()  {
    cin >> a >> b >> c ;
    if ( ( long double ) 2 * sqrt(a*b) < ( long double ) c - a - b  )
        cout << "Yes" << '\n' ;
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vpl x(n),y(n);
    rep(i,n){
        cin >> x[i].fi >>y[i].fi;
        x[i].se=i;y[i].se=i;
    }
    sort(all(x));
    sort(all(y));
    vtpl(ll,ll,ll) v;
    rep(i,n-1){
        ll cost=abs(x[i].fi-x[i+1].fi);
        v.pb(tie(cost,x[i].se,x[i+1].se));
    }
    rep(i,n-1){
        ll cost=abs(y[i].fi-y[i+1].fi);
        v.pb(tie(cost,y[i].se,y[i+1].se));
    }
    sort(all(v));
    UnionFind uf(n);
    ll ans=0;
    rep(i,v.size()){
        ll cost=at(v[i],0);
        ll a=at(v[i],1);
        ll b=at(v[i],2);
        if(!uf.same(a,b)){
            ans+=cost;
            uf.merge(a,b);
        }
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 11632
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for(int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for(int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for(auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef priority_queue<ll, vl> decendingQueue;              //降順
typedef priority_queue<ll, vl, greater<ll>> ascendingQueue; //昇順
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

void solve(long long W, long long H, long long x, long long y) {
    ll ans = 0;
    if(2 * x == W && 2 * y == H) {
        ans = 1;
    }

    double men = (double)W * H / 2;
    printf("%.6f ", men);
    print(ans);
}

int main() {
    long long W;
    scanf("%lld", &W);
    long long H;
    scanf("%lld", &H);
    long long x;
    scanf("%lld", &x);
    long long y;
    scanf("%lld", &y);
    solve(W, H, x, y);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
int main() {
  while (cin >> N) {
	string res = "ai1333";
	for (int i = 0; i < N/100; ++i) res += "3";
	cout << res << endl;
  }
}










Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
//int ar[100001];

int main() {
	io;
	int n;
	cin>>n;
	ll sum = 0;
	for(int i = 1; i<= n; i++) {
		if(i == 1 || i == 2)
			sum += i;
		else {
			if(i%3 == 0 && i%5 == 0)
				continue;
			else if(i%3 == 0)
				continue;
			else if(i%5 == 0)
				continue;
			else sum += i;
		}
	}
	cout<<sum;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

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

    int n, m;
    cin >> n >> m;
    int d[110][110], used[110][110] = {};
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            d[i][j] = INF;
        }
    }
    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
        used[a][b] = 1;
        used[b][a] = 1;
    }
    int nxt[110][110];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            nxt[i][j] = j;
        }
    }
    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (d[i][j] > d[i][k] + d[k][j])
                {
                    d[i][j] = d[i][k] + d[k][j];
                    nxt[i][j] = nxt[i][k];
                }
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            for (int k = i; k != j; k = nxt[k][j])
            {
                used[k][nxt[k][j]] = 0;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            ans += used[i][j];
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, i, j;
	
	cin>>n>>i>>j;
	--i, --j;
	
	cout<<((j - i) % 2 == 0 ? "Alice" : "Borys")<<'\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr[200005];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1; i<=n; i++) cin>>arr[i];
	int curr=n;
	int ret = 0;
	while(curr>1){
		for(int i=0; i<k; i++) curr--;
		curr++;
		ret++;
	}
	cout<<ret;
}

Measured memory_bytes: 3940
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;

int n, m, R;
int visited[200];
int edge[200][200];
int ans = INT_MAX;

void dfs(int pre, int now, int cnt, int d){
  if(cnt == R){
    ans = min(ans, d+edge[pre][now]);
    return;
  }
  if(pre>=0) d += edge[pre][now];
  rep(i, n)if(visited[i]==0){
    visited[i] = 1;
    dfs(now, i, cnt+1, d);
    visited[i] = 0;
  }
  if(pre>=0) d -= edge[pre][now];
  return;
} 

int main(){
  cin >> n >> m >> R;
  rep(i, n) visited[i] = -1;
  rep(i, n){
    rep(j, n) edge[i][j] = 100000000;
    edge[i][i] = 0;
  }
  rep(i, R){
    int r;
    cin >> r;
    visited[r-1] = 0;
  }
  rep(i, m){
    int a, b, c;
    cin >> a >> b >> c;
    edge[a-1][b-1] = edge[b-1][a-1] = c;
  }
  rep(k, n)rep(i, n)rep(j, n) edge[i][j] = min(edge[i][j], edge[i][k]+edge[k][j]);
  dfs(-1, -1, 0, 0);
  cout << ans << endl;
}

Measured memory_bytes: 384
N, K = [int(x) for x in input().split()]
V = [int(x) for x in input().split()]
ans = 0
for i in range(min(N, K)+1):
    for j in range(min(N, K)+1-i):
        tmp = []
        tmp.extend(V[:i])
        tmp.extend(V[N-j:])
        lst = sorted(tmp)
        for k in range(K-(i+j)+1):
            if (k >= len(lst)): break
            if (k==0): 
                s = sum(lst)
                if (ans < s):
                    ans = s
                continue
            if (lst[k-1] < 0):
                s = sum(lst[k:])
                if (ans < s):
                    ans = s
            else:
                break
print(ans)


Measured memory_bytes: 42092
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[100100];

int main() {
	ll n;
	cin>>n;
	vector<ll> v;
	rep(i,0,n){
		ll a;
		cin>>a;
		v.pb(a);
	}
	ll mx = 0;
	vector<ll> v1;
	vector<ll> v2;
	v1.pb(0);
	v2.pb(0);
	rep(i,0,v.sz){
		if(v[i]>mx){
			v1.pb(v[i]);
			v2.pb(i+1);
			mx = v[i];
		}
	}
	reverse(all(v1));
	reverse(all(v2));
	map<ll,ll> ma;
	sort(all(v));
	ll index = 0;
	ll total = 0;
	rep(i,0,v.sz){
		if(index==v[i])continue;
		ma[v[i]] += (v[i]-index)*(n-i) + total;
		total += (v[i]-index)*(n-i);
		index = v[i];
	}
	clr(d,0);
	rep(i,0,v1.sz-1){
		d[v2[i]]+=ma[v1[i]] - ma[v1[i+1]];
	}
	rep(i,1,n+1){
		cout << d[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 10396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
int main(){
    int n;
    ll m;
    m=1;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        ll x;
        cin >>x;
        if(x==0){
            m =0;
            
        }
        a[i]=x;
    }
    if(m !=0)
    rep(i,n){
        if(m <= 1000000000000000000/a[i]){
            m *= a[i];
        }
        else{
            m =-1;
            break;
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 4024
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)1e9+1
#define MOD (long long)1e9+7
#define INF64 (long long)1e18+1

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
  llint N,M,L,A,B;
  llint K[MAX_N];
  llint ans;
  vector<char> C;
  bool bool_ans;

  cin >> N;
  vector<llint> H(N);
  rep(i,0,N) {
    cin >>H[i];
  }

  if (N == 1) {
    put("Yes");
    return 0;
  }

  llint buf;

  buf = H[0] - H[1];



  if(buf <= -1 ) {
    H[1] -= 1;
  }else if(buf == 0) {
    H[0] -= 1;
    H[1] -= 1;
  } else if (buf == 1) {
    H[0] -= 1;
  } else {
    put("No");
    return 0;
  }

  if (N>=3) {
  rep(i,1,N-1) {
    buf = H[i] - H[i+1];

    if(buf <= -1 ) {
      H[i+1] -= 1;
    }else if(buf == 0) {
      //no
    } else {
      put("No");
      return 0;
    }
  }
  }

  put("Yes");


  return 0;
}


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

struct Node {
	int key;
	Node *p, *l, *r;
};

Node *nil;
Node *root = nil;

void insert(int k) {
	Node *y = nil;
	Node *x = root;
	Node *z = new Node;
	z->key = k;
	z->l = nil;
	z->r = nil;
	while (x != nil) {
		y = x;
		if (z->key < x->key) x = x->l;
		else x = x->r;
	}
	z->p = y;
	if (y == nil) root = z;
	else {
		if (z->key < y->key) y->l = z;
		else y->r = z; 
	}
}

void inorder(Node *root) {
	if (root == nil) return;
	inorder(root->l);
	cout << ' ' << root->key;
	inorder(root->r);
}

void preorder(Node *root) {
	if (root == nil) return;
	cout << ' ' << root->key;
	preorder(root->l);
	preorder(root->r);
}

void print() {
	inorder(root);
	cout << endl;
	preorder(root);
	cout << endl;
}

Node * findNode(int key) {
	Node *x = root;
	while (x != nil && key != x->key) {
		if (key < x->key) x = x->l;
		else x = x->r;
	}
	return x;
}

void find(int key) {
	if (findNode(key) == nil) cout << "no" << endl;
	else cout << "yes" << endl;
}

Node * getMinimum(Node *x) {
	while (x->l != nil) {
	x = x->l;
	}
	return x;
}

Node * getSuccessor(Node *x) {
	return getMinimum(x->r);
}

void del(Node *x) {
	if (x->l == nil && x->r == nil) {
		if (x == root) delete(x);
		if(x->p->l == x) {
			x->p->l = nil;
			delete(x);
		} else {
			x->p->r = nil;
			delete(x);
		}
	} else if (x->l == nil) {
		if (x == root) {
			x->r->p = nil;
			root = x->r;
			delete(x);
		}
		if (x->p->l == x) {
			x->p->l = x->r;
			x->r->p = x->p;
			delete(x);
		} else {
			x->p->r = x->r;
			x->r->p = x->p;
			delete(x);
		}
	} else if (x->r == nil) {
		if (x == root) {
			x->l->p = nil;
			root = x->l;
			delete(x);
		}
		if (x->p->l == x) {
			x->p->l = x->l;
			x->l->p = x->p;
			delete(x);
		} else {
			x->p->r = x->l;
			x->l->p = x->p;
			delete(x);
		}
	} else {
		x->key = getSuccessor(x)->key;
		del(getSuccessor(x));
	}
}

void deleteNode(int key) {
	Node *x = findNode(key);
	if (x == nil) return;
	del(x);
}

int main() {
	int n, key;
	char cmd[10];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> cmd;
		if (cmd[0] == 'i') {
			cin >> key;
			insert(key);
		} else if (cmd[0] == 'f') {
			cin >> key;
			find(key);
		} else if (cmd[0] == 'd') {
			cin >> key;
			deleteNode(key);
		} else print();
	}

	return 0;
}

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

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    if((a == b && a != c) || (b == a && b != c))
    {
        cout<<"Yes";
    } 
    else if((a == c && a != b) || (c == a && c != b))
    {
        cout<<"Yes";
    }
    else if(b == c && b != a)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	printf("%.13lf\n",sqrt(a*a+b*b-2*a*b*cos(((h+m/60)*30-m*6)*3.14159265358979323/180)));
	return 0;
}

Measured memory_bytes: 4168
N= int(input())
A = list(map(int, input().split()))
res = 1
max_res = 10**18
if 0 in A:
    res=0
for i in range(0,N):
    res = res * A[i]
    if res ==0:
        break
    elif res>max_res:
        res = -1
        break
print(res)

Measured memory_bytes: 84616
#include <iostream>


int main() {


	//入力
	int K, S;
	std::cin >> K >> S;


	//処理
	int ans = 0;
	for (int X = 0; X <= K; X++)for (int Y = 0; Y <= K; Y++) {
		if (S - (X + Y) <= K && S - (X + Y) >= 0)ans++;
	}


	//出力
	std::cout << ans << '\n';


	return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#define MAX_N 100003

//Union-Find木
int par[MAX_N]; //親
int ran[MAX_N]; //木の深さ

//n要素で初期化
void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        ran[i] = 0;
    }
}

//木の根を求める
int find(int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合を併合
void unit(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(ran[x] < ran[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(ran[x] == ran[y]) ran[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}
int main(void){
    ll n, m;
    cin >> n >> m;

    init(n);
    rep(i, 0, m){
        ll t1, t2, t3;
        cin >> t1 >> t2 >> t3;
        unit(t1, t2);
    }

    map<ll, ll> ans;
    rep(i, 0, n){
        ans[find(i)]++;
    }

    cout << ans.size() << endl;
    return 0;
}


Measured memory_bytes: 7296
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
MOD = int(1e9)+7

dp = [[0]*W for _ in range(H)]
for w in range(W):
    if a[0][w]=="#":
        break
    dp[0][w] = 1
for h in range(H):
    if a[h][0]=="#":
        break
    dp[h][0] = 1
       
for h in range(H):
    for w in range(W):
        if h+1<H and w+1<W and a[h+1][w+1]==".":
            dp[h+1][w+1] = dp[h][w+1] + dp[h+1][w]
    #print(dp)
print(dp[-1][-1]%MOD)

Measured memory_bytes: 165260
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define DR(i,a,b) for (int i=(b); i-->(a);)
#define D(i,n) DR(i,0,n)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream &operator<<(ostream &os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i];
    return os;
}
const bool debug = 1;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c; cin>>a>>b>>c;
    cout<<b+min(c,a+b+1)<<"\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int whole;
	int number;
	int num[200000]; 
	scanf("%d%d",&whole,&number);
	for(int n=0;n<number;n++)
		{scanf("%d",&num[n]);}
	int result=0;
	for(int n=1;n<number;n++)
		{if(result<num[n]-num[n-1])
			{
			result=num[n]-num[n-1];}
		}
	if(result>whole-num[number-1]+num[0])
		result=whole-result;
	else
		result=num[number-1]-num[0];
	printf("%d",result);
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main() {
   int n,m;
   cin>>n>>m;
   int a[m];
   long sum=0;
   for(int i=0;i<m;i++)
   {
       cin>>a[i];
       sum+=a[i];
   }
   int ans=n-sum;
   if(ans<0)
   cout<<-1<<endl;
   else
   cout<<ans<<endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
template <typename X>
class DST
{
private:
  int n;
  vector<X> dat,delay;
  const X init = 0;

  void eval(int k,int l,int r)
  {
    if(delay[k] != 0){
      dat[k] += delay[k];
      //      dat[k] = delay[k];      
      if(k < n-1){
	delay[2*k+1] += delay[k]/2;
	delay[2*k+2] += delay[k]/2;
	// delay[2*k+1] = delay[k]; // change update
	// delay[2*k+2] = delay[k];	
      }
      delay[k] = 0;
    }
  }
  

  
public:  
  DST(int _n)
  {
    n = 1;
    while(n < _n) n *= 2;
    dat.assign(2*n-1,init);
    delay.assign(2*n-1,init);
  }

  void update(int a,int b,X x,int k,int l,int r)
  {
    eval(k,l,r);
    
    if(r<=a||b<=l) return ;
    
    if(a<=l&&r<=b){
      delay[k] += (r-l)*x;
      //      delay[k] = x; // change update
      eval(k,l,r);
    }
    else{
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      dat[k] = dat[2*k+1] + dat[2*k+2];
      // dat[k] = dat[2*k+1]; //change update
      // dat[k] = dat[2*k+2];      
    }
  }

  X query(int a,int b,int k,int l,int r)
  {
    eval(k,l,r);
    
    if(r<=a||b<=l) return 0;

    if(a<=l&&r<=b) return dat[k];    
    else{
      X vl = query(a,b,2*k+1,l,(l+r)/2);
      X vr = query(a,b,2*k+2,(l+r)/2,r);
      return vl + vr;
    }
  }

  int size(){
    return n;
  }
  
  int get_dat(int x){
    return dat[n-1+x];
  }    
  
  void all_eval(){
    rep(i,2*n-1){
      eval(i,0,0);
    }
  }
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<n){
      rep(i,num){
	cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
    index = 0;
    num = 1;
    while(index<n){
      rep(i,num){
	cout << delay[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;    
    }
  }
  
};


pair<ll,ll> xh[200010];
bool C(int xx,ll d){
  return xh[xx].first<=d;
}
int lower(int l,int r,ll d){//条件を満たす中で最大のものを返す
  int lb=l-1,ub=r+1;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(C(mid,d)) lb=mid;
    else ub=mid;
  }
  return lb;
}

int main()
{
  ll n,d;
  ll a;
  cin >> n >> d >> a;
  vector<int> h(n);
  rep(i,n){
    ll xx;
    ll hh;
    cin >> xx >> hh;
    xh[i] = {xx,hh};
  }
  sort(xh,xh+n);
  vector<pair<int,int>> p(n);
  rep(i,n){
    ll dd = xh[i].first+2*d;
    int ub = lower(1,n-1,dd);
    p[i] = {i,ub+1};
  }
  // rep(i,n){
  //   cout << p[i].first << ":" << p[i].second << "\n";
  // }

  DST<ll> dst(n);
  rep(i,n){
    dst.update(i,i+1,xh[i].second,0,0,dst.size());
    //    dst.show();
  }

  ll cnt = 0;
  rep(i,n){
    ll aa = dst.query(i,i+1,0,0,dst.size());
    // dst.show();
    // cout << aa << "\n";
    if(aa<=0) continue;
    ll ddd = (ll)(aa+a-1)/a;
    cnt += ddd;
    dst.update(p[i].first,p[i].second,-(ddd*a),0,0,dst.size());
  }
  cout << cnt << "\n";

  
  return 0;
}


Measured memory_bytes: 13952
#include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<math.h>

using namespace std;
typedef unsigned long long ll;

const int mod=1000000007;

int ans;
int p,q,a,n;

//p/q < bunsi/bunbo
//p*bunbo = q*bunsi
void solve(int bunbo, int bunsi, int k, int now){
    if(p*bunbo == q * bunsi){
        ans++;
        return;
    }
    if(k==n){
        return;
    }
    if(p*bunbo < bunsi*q){
        return;
    }
    for(int i=now;i*bunbo<=a;i++){
        //bunsi/bunbo + 1/i
        solve(bunbo*i, bunsi*i+bunbo, k+1, i);
    }
}

int main(){
    while(cin>>p>>q>>a>>n,p){
        ans=0;
        solve(1,0,0,1);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)

	a, r := x/11, x%11
	ans := a * 2
	if r >= 1 && r <= 6 {
		ans++
	} else if r >= 7 {
		ans += 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        char c = sc.next().charAt(0);

        System.out.println(solve(c));

        sc.close();
    }

    static String solve(char c) {
        return "aeiou".indexOf(c) >= 0 ? "vowel" : "consonant";
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
const int mx = 100005;
int n, a, p[mx], m[mx], pc, mc, ans;

int main(){
    scanf("%d", &n);
    rep(i,n){
        scanf("%d", &a);
        ans += abs(a);
        (a < 0 ? m[mc++] : p[pc++]) = a;
    }
    if(pc){
        if(mc){
            printf("%d\n", ans);
            for(int i = 1; i < pc; i++){
                printf("%d %d\n", m[0], p[i]);
                m[0] -= p[i];
            }
            for(int i = 0; i < mc; i++){
                printf("%d %d\n", p[0], m[i]);
                p[0] -= m[i];
            }
        }else{
            sort(p, p+pc);
            printf("%d\n", ans - p[0]*2);
            for(int i = 2; i < pc; i++){
                printf("%d %d\n", p[0], p[i]);
                p[0] -= p[i];
            }
            printf("%d %d\n", p[1], p[0]);
        }
    }else{
        sort(m, m+mc);
        printf("%d\n", ans + m[mc-1]*2);
        for(int i = 0; i < mc-1; i++){
            printf("%d %d\n", m[mc-1], m[i]);
            m[mc-1] -= m[i];
        }
    }
}

Measured memory_bytes: 2304
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

class Main{

	static char[][] map;
	static int N;
	static int M;
	static boolean flag;
	static int ans;



	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力
		int A =sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();


		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = A; i < A+K;i++){
			if(i > B){
				break;
			}
			list.add(i);
		}
		for(int i = B; i > B-K;i--){
			if(i < A){
				break;
			}
			list.add(i);
			
		}

		list = new ArrayList<Integer>(new HashSet<>(list));
		Collections.sort(list);
		
		for(int i = 0;i <list.size();i++){
			System.out.println(list.get(i));
		}



	}


}

class Pair implements Comparable{
	String from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  int ans = 0;
  for(int i = 0; i < n - 2; ++i){
    if(v[i] < v[i + 1] && v[i + 1] < v[i + 2]) ans++;
    if(v[i] > v[i + 1] && v[i + 1] > v[i + 2]) ans++;
  }
  cout << ans << endl;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

constexpr long long mod = 1000000007;

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

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

    int n, m;
    cin >> n >> m;
    vi s(m);

    vector<char> c(m);
    rep(i, m) cin >> s[i] >> c[i];

    int ans = -1;
    if (n == 1) {
        rep(i, 10) {
            bool b = true;
            char t = i + '0';

            rep(j, m) {
                if (t != c[j]) {
                    b = false;
                    break;
                }
            }

            if (b) {
                ans = i;
                break;
            }
        }
    } else {
        int lim = 1;
        rep(i, n) lim *= 10;

        for (int i = lim / 10; i < lim; i++) {
            bool b = true;
            string t = to_string(i);

            //cout << i << endl;

            rep(j, m) {
                if (t[s[j] - 1] != c[j]) {
                    b = false;
                    break;
                }
            }

            if (b) {
                ans = i;
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256