akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
using namespace std;
int a[100010];
int main()
{
    double sum = 0, n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i]; sum += a[i];
    }
    sum = (int)((double)(sum / n) + 0.5);
    //cout << sum;
    int res = 0,sum1=sum;
    for (int i = 0; i < n; i++)
    {
        int t = abs(sum1 - a[i]);
        res += (t * t);
    }
    cout << res;

}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int N;
string S;
int main() {
  while (cin >> N >> S) {
	int res = 0;
	for (int i = 1; i+1 < N; ++i) {
	  int con1[30] = {0};
	  int con2[30] = {0};
	  for (int j = 0; j < i; ++j) {
		con1[S[j] - 'a']++;
	  }
	  for (int j = i; j < N; ++j) {
		con2[S[j] - 'a']++;
	  }
	  int tmp = 0;
	  for (int j = 0; j < 30; ++j) {
		if (con1[j] && con2[j]) ++tmp;
	  }
	  res = max(res, tmp);
	}
	cout << res << endl;
  }
}
		


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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin()), ((c).end())

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int N;
vector<int> v[6];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  int orgN = N;
  int sum = 0;
  set<int> st;
  for (int i = 2; i <= 30000; i++) {
    if (i % 2 == 0 || i % 3 == 0) {
      if (N > 0) {
        sum += i;
        st.EMP(i);
        N--;
      } else {
        v[i % 6].PB(i);
      }
    }
  }
  if (orgN == 3) {
    cout << "2 5 63" << endl;
  } else if (orgN == 4) {
    cout << "2 5 20 63" << endl;
  } else if (orgN == 5) {
    cout << "2 3 4 6 9" << endl;
  } else {
    if (sum % 6 == 2) {
      st.erase(8);
      st.EMP(v[0][0]);
    } else if (sum % 6 == 3) {
      st.erase(9);
      st.EMP(v[0][0]);
    } else if (sum % 6 == 5) {
      st.erase(9);
      st.EMP(v[4][0]);
    }
    for (auto it = st.begin(); it != st.end(); it++) {
      if (it != st.begin()) cout << " ";
      cout << *it;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1280
n, m, l = map(int, input().split())

l1 = [[10 ** 15 for i in range(n)] for i in range(n)]
for i in range(n):
    l1[i][i] = 0

for _ in range(m):
    a, b, c = map(int, input().split())
    l1[a - 1][b - 1] = c
    l1[b - 1][a - 1] = c

for i in range(n):
    for j in range(n):
        for k in range(n):
            l1[j][k] = min(l1[j][k], l1[j][i] + l1[i][k])

l2 = [[10 ** 4 for i in range(n)] for i in range(n)]
for i in range(n):
    l2[i][i] = 0

for i in range(n):
    for j in range(n):
        if l1[i][j] <= l:
            l2[i][j] = 1

for i in range(n):
    for j in range(n):
        for k in range(n):
            l2[j][k] = min(l2[j][k], l2[j][i] + l2[i][k])

q = int(input())
lq = []
for _ in range(q):
    lq.append(list(map(int, input().split())))

for sq in lq:
    res = l2[sq[0] - 1][sq[1] - 1]
    if res == 10 ** 4:
        print(-1)
    else:
        print(res - 1)


Measured memory_bytes: 75352
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX_V 100010
 
using namespace std;
 
typedef pair<int,int> ii;
typedef vector<ii>   vii;
typedef vector<int>   vi;
const int DFS_WHITE = -1; // unvisited
const int DFS_BLACK =  1; // visited
 
int V,E;
int dfsNumberCounter,rootChildren,dfsRoot;
vi dfs_num,dfs_low,dfs_parent,articulation_vertex;
vii AdjList[MAX_V];// ii(neighbor,weight)
 
vii ans;
 
void articulationPointAndBridge(int u)
{
  dfs_low[u] = dfs_num[u] = dfsNumberCounter++;
  for(int j=0;j<(int)AdjList[u].size();j++)
    {
      ii v = AdjList[u][j];
      if(dfs_num[v.first] == DFS_WHITE)
    {
      dfs_parent[v.first] = u;
      if(u == dfsRoot)rootChildren++;
 
      articulationPointAndBridge(v.first);
 
      if(dfs_low[v.first] >= dfs_num[u])
        articulation_vertex[u] = true;
      if(dfs_low[v.first] >  dfs_num[u])
        ans.push_back(ii(min(u,v.first),max(u,v.first)));
        //printf("Edge (%d,%d) is a bridge\n",u,v.first);
      dfs_low[u] = min(dfs_low[u],dfs_low[v.first]);
 
    }
      else if(v.first != dfs_parent[u])
    dfs_low[u] = min(dfs_low[u],dfs_num[v.first]);
    }
}
 
void compute()
{
  dfsNumberCounter = 0; dfs_num.assign(V,DFS_WHITE); dfs_low.assign(V,0);
  dfs_parent.assign(V,0); articulation_vertex.assign(V,0);
  //puts("Bridges:");
  for(int i = 0; i < V; i++)
    if(dfs_num[i] == DFS_WHITE)
      {
    dfsRoot = i; rootChildren = 0;
    articulationPointAndBridge(i);
    articulation_vertex[dfsRoot] = (rootChildren > 1);// special case
      }
  //puts("Articulation Points");
  //for(int i = 0; i < V; i++)
  //if(articulation_vertex[i])
      //printf("Vertex %d\n",i);
}
 
int main()
{
  scanf("%d%d",&V,&E);
  rep(i,V)AdjList[i].clear();
  rep(i,E)
    {
      int s,t;
      scanf("%d%d",&s,&t);
      AdjList[s].push_back(ii(t,1));
      AdjList[t].push_back(ii(s,1));
    }
 
  ans.clear();
  compute();
  sort(ans.begin(),ans.end());
  ans.erase(unique(ans.begin(),ans.end()),ans.end());
  rep(i,ans.size())cout << ans[i].first << " " << ans[i].second << endl;
 
  return 0;
}

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

using namespace std;

using lint = long long;

const int inf = 1e5 + 9;
const int mod = 1e9 + 7;

vector<int> T[inf];
vector<int> tree[inf];
bool vis[inf];
int N, K, par[inf], p[inf];

void dfs(int here) {
    vis[here] = true;
    for (auto there : T[here]) {
        if (vis[there]) continue;
        tree[here].push_back(there);
        par[there] = here;
        dfs(there);
    }
}

void dfsa(int here, int cnt, int dep) {
    p[here] = cnt;
    if (dep >= 1) cnt = K - 2;
    else --cnt;
    for (auto there : tree[here]) {
        dfsa(there, cnt--, dep + 1);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> N >> K;
    for (int i = 0; i < N - 1; i++) {
        int X, Y; cin >> X >> Y;
        T[X].push_back(Y);
        T[Y].push_back(X);
    }
    dfs(1);
    dfsa(1, K, 0);
    lint ANS = 1LL;
    for (int i = 1; i <= N; i++) {
//        cout << p[i] << ' ';
        ANS *= p[i];
        ANS %= mod;
    }
    cout << ANS << '\n';
}


Measured memory_bytes: 16768
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 9716
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=1e6+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int bb=18;
const double eps=1e-10;
const double pi=acos(-1);
int n,m;
char str[N];
int f[N];
map<string,int> mm;
vector<string> v;
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    r(n);
    string ss;
    FOR(i,1,n){
        cin>>ss;
        mm[ss]++;
    }
    map<string,int>::iterator it;
    int maxx=0;
    for(it=mm.begin();it!=mm.end();it++){
        maxx=max(maxx,it->second);
    }
    for(it=mm.begin();it!=mm.end();it++){
        if(it->second==maxx) v.push_back(it->first);
    }
    sort(v.begin(),v.end());
    for(string s:v) cout<<s<<endl;
    return 0;
}



Measured memory_bytes: 28276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		boolean can = false;
		if( Math.abs(A-C) <= D) {can=true;}
		if( Math.abs(A-B)<=D && Math.abs(B-C) <=D) {can=true;}
		if(can) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23636
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    String alphabet = "";

    for( char c = 'a'; c <= 'z'; c++){
      alphabet += c;
    }

    if(alphabet.contains(str)){
      System.out.println("a");
    }else{
      System.out.println("A");
    }

    return;
  }
}

Measured memory_bytes: 39076
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    ll x;
    cin>>x;
    ll a[x];
    for (int i=0; i<x; i++)
        cin>>a[i];
    ll ans=0,mx=a[0];
    for (int i=1; i<x; i++)
    {
        if (a[i]<mx)
        {
            ans=ans+mx-a[i];
        }
        mx=max(mx,a[i]);
    }
    cout<<ans;
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vl a(n+1),b(n);
	REP(i,n+1)cin>>a[i];
	REP(i,n)cin>>b[i];
	ll ans=0,rem=0;
	REP(i,n){
		ll d=min(a[i],rem);
		a[i]-=d;
		rem-=d;
		ans+=d;
		ll c=min(a[i],b[i]);
		a[i]-=c;
		b[i]-=c;
		rem=b[i];
		ans+=c;
	}
	ans+=min(a[n],rem);
	cout<<ans<<endl;

}

Measured memory_bytes: 1792
#include <iostream> 
#include <bits/stdc++.h> 
using namespace std; 
void solve() 
{
    int t; 
    cin >> t; 
    if(t>30) {
        cout << "Yes" << endl; 
    }
    else 
        if(t==30) {
            cout << "Yes" << endl; 
        }
        else 
        {
            cout << "No" << endl; 
        }
}
int main () 
{

    solve() ; 
    return 0; 
}


Measured memory_bytes: 3636
from collections import defaultdict

INF = float("inf")

N, *A = map(int, open(0).read().split())

dp = defaultdict(lambda: -INF)
dp[(0, 0, False)] = 0

for i, a in enumerate(A, 1):
    p = i // 2
    for j in [p - 1, p, p + 1]:
        dp[(i, j, True)] = a + dp[(i - 1, j - 1, False)]
        dp[(i, j, False)] = max(dp[(i - 1, j, False)], dp[(i - 1, j, True)])

print(max(dp[(N, N // 2, True)], dp[(N, N // 2, False)]))

Measured memory_bytes: 341772
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll N;
    vector<pair<ll, ll>> works; // 所要時間、〆切時刻
    cin >> N;
    for (ll i = 0; i < N; ++i) {
        ll A, B;
        cin >> A >> B;
        works.emplace_back(A, B);
    }

    // 〆切が近い順に並び替え
    sort(begin(works), end(works), [](auto&& a, auto&& b) { return a.second < b.second; });

    // トータル所要時間、〆切時刻にする
    partial_sum(
        begin(works), end(works),
        begin(works),
        [](auto&& a, auto&& b) {
            b.first += a.first;
            return b;
        });

    // すべての所要時間が〆切時刻以内に終わっているか
    bool ok = all_of(begin(works), end(works), [](auto&& r) { return r.first <= r.second; });

    cout << (ok ? "Yes\n" : "No\n");
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
using u32 = uint32_t;

int main() {
	u32 N;
	cin >> N;
	
	for(uint i=0; i<N; i++) {
		u32 A;
		cin >> A;
		
		if(A % 2 == 0 && A % 3 != 0 &&  A % 5 != 0) {
			cout << "DENIED";
			return 0;
		}
	}
	
	cout << "APPROVED";
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<long long> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  bool flag = true;
  for (int i = 1; i < N; i++) {
    if (H.at(i) - H.at(i-1) > 0) H.at(i)--;
    else if (H.at(i) - H.at(i-1) < 0) flag = false;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

const int NIL = -1;
const int MAX = 2147483647;
clock_t START, END;

struct Node {
	int l, r, key, lazy;
};

bool debug = false;
Node Tree[500010];
int mark[500010];
int n = 0, N = 1;


void update(int x, int y, int z, int k, int height)
{
	if (!mark[k]) {
		Tree[k].l = k * (1 << height) - N;
		Tree[k].r = min(Tree[k].l + (1 << height) - 1, n - 1);
		mark[k] = 1;
	}
	if (x > y)
		return;
	if (x <= Tree[k].l && Tree[k].r <= y) {
		Tree[k].key = z;
		Tree[k].lazy = 1;
		return;
	}
	else if (Tree[k].r < x || Tree[k].l > y) {
		return;
	}
	else {
		if (Tree[k].lazy) {
			Tree[k].lazy = 0;
			Tree[2 * k].key = Tree[2 * k + 1].key = Tree[k].key;
			Tree[2 * k].lazy = Tree[2 * k + 1].lazy = 1;
		}
		update(x, min(Tree[k].l + (1 << (height - 1)) - 1, y), z, 2 * k, height - 1);
		update(max(Tree[k].l + (1 << (height - 1)), x), y, z, 2 * k + 1, height - 1);
	}
}

int find(int k, int height, int z)
{
	if (!mark[k]) {
		Tree[k].l = k * (1 << height) - N;
		Tree[k].r = min(Tree[k].l + (1 << height) - 1, n - 1);
		mark[k] = 1;
	}
	if (Tree[k].lazy) {
		Tree[2 * k].key = Tree[2 * k + 1].key = Tree[k].key;
		Tree[2 * k].lazy = Tree[2 * k + 1].lazy = 1;
		return Tree[k].key;
	}
	else {
		if (z <= Tree[k].l + (1 << (height - 1)) - 1)
			return find(2 * k, height - 1, z);
		else
			return find(2 * k + 1, height - 1, z);
	}
}

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in15.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int q, com, x, s, t, k, height = 0;
	scanf("%d%d", &n, &q);
	while (N < n) {
		N *= 2;
		height++;
	}
	for (int i = 1; i <= n + N - 1; i++) {
		Tree[i].key = MAX;
		Tree[i].lazy = 1;
	}
	for (int i = 0; i < q; i++) {
		scanf("%d", &com);	 
		if (com) {
			scanf("%d", &k);
			printf("%d\n", find(1, height, k));
		}
		else {
			scanf("%d%d%d", &s, &t, &x);
			update(s, t, x, 1, height);
		}
	}
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 9836
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
a = [0];a.extend(readInts());a.append(0)
base = sum([abs(a[i]-a[i+1]) for i in range(n+1)])

for i in range(1,n+1):
	print(base-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1]))+abs(a[i-1]-a[i+1]), end=" ")

Measured memory_bytes: 21040
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<iomanip>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;typedef long long LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e9+7;
const int inf=1e9+7;
const double eps=1e-6;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return (r+m)%m;}
const double pi=acos(-1);


int main()
{
    TB
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int flag=k;k=0;
    while(b<=a){
        b*=2;k++;
    }
    while(c<=b){
        c*=2;k++;
    }
    if(flag>=k){
        cout<<"Yes\n";
    }else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 3608
n, m = map(int, input().split())
mod = 10 ** 9 + 7

MAX = 5 * 10 ** 5

fact = [1] * (MAX + 1)
for i in range(1, MAX + 1):
    fact[i] = (fact[i-1] * i) % mod

inv = [1] * (MAX + 1)
for i in range(2, MAX + 1):
    inv[i] = inv[mod % i] * (mod - mod // i) % mod

fact_inv = [1] * (MAX + 1)
for i in range(1, MAX + 1):
    fact_inv[i] = fact_inv[i-1] * inv[i] % mod


def comb(n, k):
    if n < k:
        return 0
    return fact[n] * fact_inv[n-k] * fact_inv[k] % mod


p1 = 1
p2 = 1

for i in range(m, m - n, -1):
    p2 *= i
    p2 %= mod

ans = 0
for i in range(n + 1):
    ans += (-1) ** (i % 2) * comb(n, i) * p1 * p2 ** 2
    ans %= mod

    p1 *= m - i
    p1 %= mod

    p2 *= inv[m - i]
    p2 %= mod

print(ans)


Measured memory_bytes: 68180
function Main(input) {
    input = input.split('\n');
    const inp = input[0].split(' ');
    const N = Number(inp[0]);
    const M = Number(inp[1]);
    const X = Number(inp[2]);
    const A = input[1].split(' ').map(x => Number(x));

    const field = Array(N + 1).fill(0);

    for (const i of A)
        field[i] = 1;

    let costA = 0;
    for (let i = X; i < N + 1; i++) {
        costA += field[i];
    }
    let costB = 0;
    for (let i = X; i >= 0; i--) {
        costB += field[i];
    }
    costA < costB ? console.log(costA) : console.log(costB);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
import collections
s = input()
l = len(s)
for i in range(l-1):
	t = s[i:i+3]
	c = collections.Counter(t)
	if s[i] == s[i+1]:
		print (i+1,i+2)
		exit()
	if c.most_common()[0][1] >= 2:
		print (i+1,i+3)
		exit()
print (-1,-1)

Measured memory_bytes: 43624
#include<iostream>
using namespace std;
int main()
{
  int S;
  cin >> S;
  int S1 = S / 1000;
  int S2 = (S % 1000) / 100;
  int S3 = (S % 100) / 10;
  int S4 = S % 10;
  if (S1 == S2 || S2 == S3 || S3 == S4) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
import time
start=time.time()
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
d=read()
c=list(reads())
s=[[]for i in range(d)]
for i in range(d):
    s[i]=list(reads())
contestcount=26
last=[0 for i in range(contestcount)]
maxscore=0
backup=()
score=0
t=[0 for i in range(d)]
"""for i in range(d):#日にち
  dele=0
  for j in range(contestcount):
        dele-=c[j]*(i+1-last[j])
  for j in range(contestcount):#貪欲法
    hoge=maxscore
    hoge+=s[i][j]
    hoge-=dele
    hoge+=c[j]*(i+1-last[j])
    if hoge>=score:
      backup=(j,last[j])
      score=hoge  
    #print(score,backup)
  maxscore=score
  last[backup[0]]=backup[1]
  t[i]=backup[0]
  #print(backup[0]+1)
"""
import random
for i in range(d):
	t[i]=random.randint(0,contestcount-1)
    
backup=t[:]
while(time.time()-start<1.8):
  ran1=random.randint(0,d-1)
  ran2=random.randint(0,d-1)
  newscore=0
  if ran1==ran2:
    if ran2!=0:
      ran2-=1
    else:ran2+=1
  t[ran1],t[ran2]=t[ran2],t[ran1]
  for i in range(d):
    newscore+=s[i][t[i]]
    last[t[i]]=i+1
    for j in range(contestcount):
        newscore-=c[j]*(i+1-last[j])
  #print(newscore,score,ran1,ran2)
  if newscore>score:
    score=newscore
  else:t=backup[:]
for i in range(d):
  print(t[i]+1)

Measured memory_bytes: 81532
import java.util.Scanner;

public class Main {
	
	private static void solve(int n, int[][] happy) {
		
		int[][] dp = new int[n][3];
		
		// recording day 0 happiness
		for (int i=0; i<3; i++) {
			dp[0][i] = happy[0][i];
		}
		
		for (int i=0; i<n-1; i++) {
				dp[i+1][0] = happy[i+1][0] + Math.max(dp[i][1], dp[i][2]);
				dp[i+1][1] = happy[i+1][1] + Math.max(dp[i][0], dp[i][2]);
				dp[i+1][2] = happy[i+1][2] + Math.max(dp[i][0], dp[i][1]);
		}
		
		int max = Math.max(dp[n-1][0], dp[n-1][1]);
		System.out.println(Math.max(max, dp[n-1][2]));
	}

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		int[][] happy = new int[n][3];
		for (int i=0; i<n; i++) {
			for (int j=0; j<3; j++) {
				happy[i][j] = scanner.nextInt();
			}
		}
			
		solve(n, happy);
		
		scanner.close();
	}

}


Measured memory_bytes: 100144
#include<stdio.h>
#include <iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int n, m;
	int ans;

	cin >> n >> m;

	ans = n * (n - 1) / 2 + m * (m - 1) / 2;

	cout << ans;

	return 0;
}

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

ll n;
ll a[3000];
ll dp[3000][3000];

ll optimal(ll i,ll j){
	if(i>j)
	return 0;
	
	if(dp[i][j]!=-1)
	return dp[i][j];
	
	ll op1=a[i]+min(optimal(i+2,j),optimal(i+1,j-1));
	ll op2=a[j]+min(optimal(i,j-2),optimal(i+1,j-1));
	return dp[i][j]=max(op1,op2);
}

int main(){
	cin>>n;
	ll sum=0;
	for(ll i=0;i<n;i++)
	cin>>a[i],sum+=a[i];
	memset(dp,-1,sizeof(dp));
	ll maxv=optimal(0,n-1);
	ll other=sum-maxv;
	cout<<maxv-other<<endl;
	
}

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

namespace ConsoleApplication1
{
    class EdgeData
    {
        internal int cap, flow;

        public EdgeData() { }

        public EdgeData(int cap, int flow)
        {
            this.cap = cap;
            this.flow = flow;
        }
    }

    class EdmondsKerp
    {
        enum Color { White, Gray, Black }

        readonly int n, INFTY = int.MaxValue;

        EdgeData[,] G;
        int[] parent, minCap;
        Color[] color;

        public EdmondsKerp(int V)
        {
            n = V;

            G = new EdgeData[n, n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    G[i, j] = new EdgeData();
                }
            }

            parent = new int[n];
        }

        public void AddEdge(int from, int to, int cap)
        {
            G[from, to] = new EdgeData(cap, 0);
            G[to, from] = new EdgeData(0, cap);
        }

        public int MaxFlow(int s, int t)
        {
            int maxFlow = 0;

            while (BFS(s, t))
            {
                maxFlow += minCap[t];

                int v = t;

                while (v != s)
                {
                    int u = parent[v];

                    G[u, v].flow += minCap[t];
                    G[v, u].flow -= minCap[t];
                    G[u, v].cap -= minCap[t];
                    G[v, u].cap += minCap[t];
                    v = u;
                }
            }
            return maxFlow;
        }

        private bool BFS(int s, int t)
        {
            minCap = Enumerable.Repeat(INFTY, n).ToArray();
            color = new Color[n];

            Queue<int> que = new Queue<int>();
            que.Enqueue(s);
            color[s] = Color.Gray;

            while (que.Count > 0)
            {
                int v = que.Dequeue();

                for (int u = 0; u < n; u++)
                {
                    if (color[u] == Color.White && G[v, u].cap > 0)
                    {
                        minCap[u] = Math.Min(minCap[v], G[v, u].cap);
                        parent[u] = v;
                        color[u] = Color.Gray;

                        if (u == t) return true;
                        que.Enqueue(u);
                    }
                }
            }
            return false;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int V = int.Parse(input[0]);
            int E = int.Parse(input[1]);

            EdmondsKerp EK = new EdmondsKerp(V);

            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                int u = int.Parse(input[0]);
                int v = int.Parse(input[1]);
                int c = int.Parse(input[2]);

                EK.AddEdge(u, v, c);
            }

            Console.WriteLine(EK.MaxFlow(0, V - 1));
        }
    }
}

Measured memory_bytes: 11016
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll q,h,s,d,n,best=0;
  cin >>q >> h >> s >> d >> n;
  q *= 8;
  h *= 4;
  s *= 2;
  best += (n/2)*min(min(q,h),min(s,d));

  q /= 2;
  h /= 2;
  s /= 2;
  n %= 2;
  best += n*min(min(q,h),s);
  cout << best<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
 
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
const int N = 4e5 + 5;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	
	string s; cin >> s;
	ll k, n = s.size(); cin >> k;
	if (n == 1)
	{
		cout << k/2;
		return 0;
	}
	ll ans = 0;
	ll pref = 0, suf = 0;
	for (int i = 0; i < n;)
	{
		int j = i;
		while (j < n and s[j] == s[i]) ++j;
		if (i != 0 and j != n) ans += k * ((j-i)/2);
		else
		{
			if (i == 0) pref = j-i;
			if (j == n) suf = j-i;
		}
		i = j;
	}
	if (pref == n)
	{
		cout << (1LL * n * k) / 2;
		return 0;
	}
	if (s[0] != s.back())
	{
		ans += k * (pref/2);
		ans += k * (suf/2);
	}
	else
	{
		ans += pref/2;
		ans += suf/2;
		ans += (k-1) * ((pref + suf)/2);
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
                String Str = sc.nextLine();
                String s;
                int i = Str.indexOf("Y");
                    if(i==-1)
                      s = "Three";
                    else
                      s = "Four";

		System.out.println(s);
	}
}

Measured memory_bytes: 21972
N,K=gets.chomp.split(" ").map{|a|a.to_i}
A=gets.chomp.split(" ").map{|a|a.to_i}
Asum = Array.new(A.size)
Asum[0] = A[0]
for i in 1..(N-1)
	Asum[i] = Asum[i-1] + A[i]
end
i = 0
SUM = Array.new(N*(N+1)/2)
for l in 0..(N-1)
	for r in l..(N-1)
		SUM[i] = Asum[r] - Asum[l] + A[l]
		i += 1
	end
end
# p SUM
d = 2**38
x = 0
while(d > 0)
	# puts "test : #{d}"
	cnt = 0
	for i in 0..(N*(N+1)/2 - 1)
		cnt += 1 if (x+d) & SUM[i] == (x+d)
	end
	# puts "cnt : #{cnt}"
	x += d if cnt >= K
	d /= 2
end
puts x


Measured memory_bytes: 5884
N = input()

M = int(N) % 10

if M == 2 or M == 4 or M == 5 or M == 7 or M == 9:
    print("hon")

elif M == 0 or M == 1 or M == 6 or M == 8:
    print("pon")

elif M == 3:
    print("bon")

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

ten=-1
five=-1
one=-1

for i in range(N+1):
    for j in range(0, N-i+1):
        k = N-i-j
        if(10000*i + 5000*j + 1000*k == Y):
            ten = i
            five = j
            one = k

out = str(ten) + ' ' + str(five) + ' ' + str(one)
print(out)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b, c, d; cin >> a >> b >> c >> d;
  int x[200] = {};
  ++x[a], --x[b+1];
  ++x[c], --x[d+1];

  rep(i, 199) x[i+1] += x[i];

  int ans = 0;
  rep(i, 200) if (x[i] == 2) ++ans;

  if (ans) --ans;
  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3652
Scanf.scanf "%s" (fun s ->
    Printf.printf "%d\n" @@
    if s = "RRR" then 3 else
    if s = "SRR" || s = "RRS" then 2 else
    if s = "SRS" || s = "RSS" || s = "SSR" || s = "RSR" then 1 else 0
)

Measured memory_bytes: 3800
import sys
from heapq import heappush, heappop
from operator import itemgetter

na = lambda: map(int, sys.stdin.readline().split())

n, m = na()
ab = [list(na()) for _ in range(n)]
ab.sort(key=itemgetter(0))

ans = 0
p = 0
h = []
for day in range(1, m+1):
  for i in range(p, len(ab)):
    if ab[i][0] <= day:
      heappush(h, -ab[i][1])
      p += 1
    else:
      break
  if h:
    ans += -heappop(h)

print(ans)

Measured memory_bytes: 76636
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
 
using namespace std;
typedef long long ll;
 
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}
 
 
//for(int i = ; i < ; i++){}
 
int main(){
  int h,w;
  cin>>h>>w;
  char a[h][w];
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin>>a[i][j];
    }
  }
  int l[h][w];//left
  int r[h][w];//right
  int d[h][w];//down
  int u[h][w];//up
  
  //lwft
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(a[i][j]=='#'){
        l[i][j]=0;
      }
      else{
        if(j==0){
          l[i][j]=1;
        }
        else{
          l[i][j]=l[i][j-1]+1;
        }
      }
    }
  }
 
  //right
  for(int i = 0; i < h; i++){
    for(int j = w-1; j >= 0; j--){
      if(a[i][j]=='#'){
        r[i][j]=0;
      }
      else{
        if(j==w-1){
          r[i][j]=1;
        }
        else{
          r[i][j]=r[i][j+1]+1;
        }
      }
    }
  }
  
  //up
  for(int j = 0; j < w; j++){
    for(int i = 0; i < h; i++){
      if(a[i][j]=='#'){
        u[i][j]=0;
      }
      else{
        if(i == 0){
          u[i][j]=1;
        }
        else{
          u[i][j]=u[i-1][j]+1;
        }
      }
    }
  }
  
  //down
  for(int j = 0; j < w; j++){
    for(int i = h-1; i >= 0; i--){
      if(a[i][j]=='#'){
        d[i][j]=0;
      }
      else{
        if(i == h-1){
          d[i][j]=1;
        }
        else{
          d[i][j]=d[i+1][j]+1;
        }
      }
    }
  }
 
  int ans = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
     ans = max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3); 
    }
  }
  cout<<ans<<endl;
  return 0;
}
 
 

Measured memory_bytes: 66688
#include <iostream>
#include <string>
#include<math.h>
#include <cstdio>
#include <iomanip>

using namespace std;

int main(){
  int W, H, x, y;
  double men = 1.0;
  int way = 0;
  cin >> W >> H >> x >> y;
  men = double(W) * double(H) / 2.0;
  if(x == W / 2.0 && y == H / 2.0){
    way = 1;
  }
  cout << fixed << setprecision(12) << men << " " << way << endl;
  return 0;
}


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


int main(void){
  char s[101];
  scanf("%s",s);
  int len = strlen(s);

  for(int i = 0; i < len; i++){
    if(i % 2 == 0){
    	if (s[i] == 'L'){
    		puts("No");
    		return 0;
    	}
    }
    else{
    	if (s[i] == 'R'){
    		puts("No");
    		return 0;
    	}
    }
  }
  puts("Yes");

  return 0;
}


Measured memory_bytes: 128
using System;
 
class Program {
    private static int Main() {
        var input = Console.ReadLine();
        var values = input.Split( ' ' );
 
        int a = int.Parse( values[ 0 ] );
        int b = int.Parse( values[ 1 ] );
        int c = int.Parse( values[ 2 ] );
 
        bool isYes = ( a < b ) && ( b < c );
 
        var output = isYes ? "Yes" : "No";
        Console.WriteLine( output );
 
        return 0;
    }
}

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

#define int long long 

#define fs first
#define sc second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define pb push_back
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MP make_pair
#define sqr(x) ((x) * (x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
	fastio;
	#ifdef FlameDragon
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif

	int n, a, b;
	cin >> n >> a >> b;
	int s = a + b - 1;
	if (s > n) {
		cout << "-1\n";
		return 0;
	}	
	vector<int> ans;
	int st = n - a + 1;
	for (int i = 0; i < a; i++) {
		ans.pb(st + i);
	}
	for (int border = a; border <= n; border++) {
		int k = (border) / a + (border % a ? 1 : 0);
		int take = n - border + k;
		// cout << border << ' ' << take << '\n';
		if (take == b) {
			int z = a;
			for (; z + a - 1 < border; z += a) {
				st -= a;
				for (int i = 0; i < a; i++) {
					ans.pb(st + i);
				}
			}
			int cnt = border - z;
			st -= cnt;
			for (int i = 0; i < cnt; i++) {
				ans.pb(st + i);
			}
			st--;
			while (st > 0) {
				ans.pb(st);
				st--;
			}
			assert(sz(ans) == n);
			for (auto x : ans) {
				cout << x << ' ';
			}
			cout << '\n';
			return 0;
		}
	}
	cout << "-1\n";
	
}

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

int a[2][100];

int main(){
	int n, ans=0;
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[1][i];
	for(int i=0; i<n; i++) cin >> a[2][i];

	for(int i=0; i<n; i++){
		int temp = 0;
		for(int j=0; j<n; j++){
			if(j<=i) temp += a[1][j];
			if(j>=i) temp += a[2][j];
		}
		ans = max(ans, temp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
def devisorlister(n):
    devisor_list=[]
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            devisor_list.append(i)
    if devisor_list==[]:
        devisor_list=[1]
    return max(devisor_list)

k=int(input())
m=devisorlister(k)
print(len(str(int(k/m))))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int k=0;
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.length();i++){
        if(a[i]==b[i]){
            k++;
        }
    }
    cout<<k;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
using pp = pair<int,char>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
const int MX = 200005;

int solve(vector<vector<int>> p,vector<vector<int>> q,int b){
    int res = INF;
    rep(i,p.size()){
        sort(q[i].begin(),q[i].end());
        rep(j,p[i].size()){
            int l = -1 ,r = q[i].size();
            while(r - l > 1){
                int m = (l+r)/2;
                if(p[i][j]<=q[i][m]) r = m;
                else l = m;
            }
            if(r==q[i].size()) continue;
            res = min(res,abs(p[i][j]-q[i][r])*b);
        }
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> xd(MX);
    vector<vector<int>> xu(MX);
    vector<vector<int>> yl(MX);
    vector<vector<int>> yr(MX);
    vector<vector<int>> xyl(2*MX); // y-x+MX;
    vector<vector<int>> xyr(2*MX); // y-x+MX;
    vector<vector<int>> xyd(2*MX); // y-x+MX;
    vector<vector<int>> xyu(2*MX); // y-x+MX;
    vector<vector<int>> yxl(2*MX); // y+x;
    vector<vector<int>> yxr(2*MX); // y+x;
    vector<vector<int>> yxd(2*MX); // y+x;
    vector<vector<int>> yxu(2*MX); // y+x;

    rep(i,n){
        int xx,yy;
        char u;
        cin >> xx >> yy >> u;
        if(u=='U') xd[xx].push_back(yy);
        if(u=='D') xu[xx].push_back(yy);
        if(u=='R') yl[yy].push_back(xx);
        if(u=='L') yr[yy].push_back(xx);
        if(u=='R') xyl[yy-xx+MX].push_back(xx);
        if(u=='D') xyr[yy-xx+MX].push_back(xx);
        if(u=='L') xyu[yy-xx+MX].push_back(xx);
        if(u=='U') xyd[yy-xx+MX].push_back(xx);
        if(u=='R') yxl[yy+xx].push_back(xx);
        if(u=='U') yxr[yy+xx].push_back(xx);
        if(u=='L') yxu[yy+xx].push_back(xx);
        if(u=='D') yxd[yy+xx].push_back(xx);
    }

    int mn = INF;

    mn = min(mn,solve(xd,xu,5));
    mn = min(mn,solve(yl,yr,5));
    mn = min(mn,solve(xyl,xyr,10));
    mn = min(mn,solve(xyd,xyu,10));
    mn = min(mn,solve(yxl,yxr,10));
    mn = min(mn,solve(yxd,yxu,10));

    if(mn==INF) cout << "SAFE" << endl;
    else cout << mn << endl;
    return 0;
}

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

int main()
{
    string n;
    cin >> n;
    if(n[0]==n[2]){
        cout << "Yes" << endl;
    }else{
        cout <<"No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, j, k, in) for (ll i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (ll i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

ll dp[400][400], val[400][400];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> ais(n);
    REP(i, n)
    cin >> ais[i];
    ll infinity = 400000000001ll;

    memset(dp, infinity, sizeof(dp[0][0]) * 400 * 400);
    memset(val, 0, sizeof(dp[0][0]) * 400 * 400);

    REP(i, n)
    dp[i][i] = 0;

    REP(i, n) {
        REP(j, n) {
            if (i == j)
                val[i][j] = ais[i];
            else
                val[i][j] = val[i][j - 1] + ais[j];
        }
    }

    FOR(s, 1, n, 1) {
        REP(i, n) {
            if (i + s >= n) break;
            int b = i, t = i + s;
            FOR(j, b, t, 1) {
                dp[b][t] = min(dp[b][t], dp[b][j] + dp[j + 1][t] + val[b][j] + val[j + 1][t]);
            }
        }
    }

    cout << dp[0][n - 1] << endl;

    return 0;
}

Measured memory_bytes: 2816
//region Template
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#ifdef LOCAL
#include "../debug_prettyprint.hpp"
#else
#define debug(...) 42
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#endif
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<<fixed<<setprecision(12);
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = max(lhs, rhs.val); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = min(lhs, rhs.val); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//endregion

const ll BIG = 1e12;
mcf_graph<int,ll> g(2*55*55);
int H,W;
vector<string> grid;
set<pii> visited;

int id(int r, int c, int type) {
    return type*55*55+r*55+c;
}
int source = id(54,0, 0);
int sink = id(54,0, 1);

void dfs(int origin, int d, int r, int c) {
    if(visited.count({r,c}))
        return;
    visited.insert({r,c});

    if(grid[r][c]=='#')
        return;

    g.add_edge(origin, id(r,c,1), 1, BIG-d);

    if(r+1<H && grid[r+1][c]!='#') {
        dfs(origin, d+1, r+1, c);
    }

    if(c+1<W && grid[r][c+1]!='#') {
        dfs(origin, d+1, r, c+1);
    }
}

signed main() {
    FASTIO

    cin>>H>>W;
    grid = READ<string>(H);
    int pieces=0;

    FOR(r,H)
    FOR(c,W) {
        g.add_edge(id(r,c,1), sink, 1, 0);

        if(grid[r][c]=='o') {
            visited.clear();
            dfs(id(r,c,0), 0, r, c);
            g.add_edge(source, id(r,c,0), 1, 0);
            pieces++;
        }
    }

    auto f = g.flow(source, sink);
    ll ans = f.first*BIG - f.second;
    cout<<ans<<endl;

}

Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<char,char> p2;
#define sz(a) ll(a.size())
void solve(){
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll cnt=0;
	while(b<=a){
		b*=2;
		cnt++;
	}
	while(c<=b){
		c*=2;
		cnt++;
	}
	if(cnt<=k)
	cout<<"Yes";
	else
	cout<<"No";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
    solve();
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll a,b;cin >>a>>b;
    cout <<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

ll N,M,S,T;

void solve() {
    cin >> N >> M;
    vvll to(N),to1(3*N);
    ll a,b;
    rep(i,M){
        cin >> a >> b;
        a--;b--;
        to1[a].pb(b+N);
        to1[a+N].pb(b+N+N);
        to1[a+N+N].pb(b);
    }
    cin >> S >> T;
    S--;T--;
    ll ans = 0;
    vll move(3*N,0);
    bool ok = false;
    queue<ll> que;
    que.push(S);
    while(!que.empty()){
        if(ok) break;
        ll u = que.front();
        que.pop();
        for(ll v:to1[u]){
            if(v==T) {
                ans = move[u]+1;
                ok = true;
                break;
            }
            if(move[v]!=0){
                continue;
            }
            move[v] = move[u]+1;
            que.push(v);
        }
    }
    if(ok){
        print(ans/3);
    }else{
        print(-1);
    }
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 24332
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    set<int> s;
    int res = 0;
    for (int i = 0; i < n; i++) {
        s.insert(v[i]);
        if (i == k - 1) {
            res++;
        } else if (i > k - 1) {
            s.erase(v[i - k]);
            if (v[i - k] < *s.begin()) {
                if (*s.rbegin() <= v[i]) {

                } else {
                    res++;
                }
            } else {
                res++;
            }
        }
    }

    int c = 1;
    int l = 0;
    for (int i = 1; i < n; i++) {
        if (v[i] > v[i - 1]) {
            c++;
        } else {
            if (c >= k) {
                l++;
            }
            c = 1;
        }
    }
    if (c >= k) l++;
    if (l > 1) res -= l - 1;
    cout << res << endl;
}




Measured memory_bytes: 13488
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(void) {
	double W, H, x, y;
	cin >> W >> H >> x >> y;

	cout << W * H / 2.0 << endl;


	if (W / 2 == x && H / 2 == y)
	{
		cout << 1;
	}
	else
	{
		cout << 0;
	}
}

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

int main() {
	char s[3];
	int flag=0;
	for(int i=0;i<3;i++){
		cin>>s[i];
		if(s[0]!=s[i]){
			flag=1;
		}
	}
	if(flag==0){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	// your code goes here
	return 0;
}

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

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

	int A,B;

	cin>>A>>B;

	int powerstrip = 0;
	int slot = 1;

	while(slot < B)
	{
		slot += A;
		++powerstrip;
		slot -= 1;
	}

	cout << powerstrip << '\n';
}

Measured memory_bytes: 256