akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
long long n,a,b,po[35],ans=1,fac=1,inv[200005];
int main(){
    scanf("%lld %lld %lld",&n,&a,&b);
    po[0]=2;
    for(int i=1;i<=30;i++)po[i]=(po[i-1]*po[i-1])%MOD;
    long long x=n;
    for(int i=0;i<=30;i++){
        if(x%2LL)ans=(ans*po[i])%MOD;
        x/=2LL;
        if(!x)break;
    }
    ans--;
    x=1;
    for(long long i=2;i<=200000;i++)fac=(fac*i)%MOD;
    po[0]=fac;
    for(int i=1;i<=30;i++)po[i]=(po[i-1]*po[i-1])%MOD;
    x=MOD-2LL;
    inv[200000]=1;
    for(int i=0;i<=30;i++){
        if(x%2LL)inv[200000]=(inv[200000]*po[i])%MOD;
        x/=2LL;
        if(!x)break;
    }
    for(long long i=199999;i>=0;i--)inv[i]=(inv[i+1]*(i+1))%MOD;
    long long mm=1;
    for(long long i=n;i>n-a;i--)mm=(mm*i)%MOD;
    mm=(mm*inv[a])%MOD;
    ans=(ans+MOD-mm)%MOD;
    mm=1;
    for(long long i=n;i>n-b;i--)mm=(mm*i)%MOD;
    mm=(mm*inv[b])%MOD;
    ans=(ans+MOD-mm)%MOD;
    printf("%lld",ans);
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << ((abs(b - a) <= d && abs(c - b) <= d) || abs(c - a) <= d ? "Yes"
                                                                      : "No")
       << "\n";
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
 ll N,T;cin>>N>>T;vl t(N);rep(i,N)cin>>t[i];ll tot=T;
  f(i,1,N){
    tot +=min(t[i]-t[i-1],T);
  }
  cout<<tot<<endl;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int w,h,n;
    cin>>w>>h>>n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    REP(i,n) cin>>a[i]>>b[i]>>c[i];
    int d=0,e=w,f=0,g=h;
    REP(i,n){
        if(c[i]==1){
        d=max(d,a[i]);
        }else if(c[i]==2){
        e=min(e,a[i]);
        }else if(c[i]==3){
        f=max(f,b[i]);
        }else{
        g=min(g,b[i]);
        }
    }
    if(d<=e&&f<=g){
        cout<<(e-d)*(g-f);
    }else{
        cout<<0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
using namespace std;
 
int main()
{
    int a,b,count=0;
    scanf("%d %d",&a,&b);
    for(int i=a;i<=b;i++)
    {
        string s = to_string(i);
        if(s[0]==s[4] && s[1]==s[3]) count++;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 3820
N, K = map(int, input().split())
numlist = []
for i in range(K*2):
    numlist.append(list(map(int,input().split())))
anslist=[]

i=0
while i<K*2:
    if not i%2==0:
        anslist.extend(numlist[i])
    i+=1
    
ans=0
j=0
while j<N:
    check=j+1
    if check not in anslist:
        ans+=1
    j+=1
    
print(ans)

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

int main() {
    long long n; cin >> n;
    int minlen = 15;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;
        long long j = n / i;
        string si = to_string(i);
        string sj = to_string(j);
        int len = (si.size() < sj.size() ? sj.size() : si.size());
        minlen = min(minlen, len);
    }
    cout << minlen << endl;
    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

n = gets.to_i
s = n.times.map { gets.chomp.chars.sort }

h = Hash.new { 0 }

s.each do |e|
  h[e] += 1
end

sum = 0
h.each do |k, v|
  sum += (v * (v - 1) / 2) if v > 1
end

puts sum


Measured memory_bytes: 69884
#template
def inputlist(): return [int(k) for k in input().split()]
#template
H,W = inputlist()
graph = [0]*H
for i in range(H):
    graph[i] = list(input())
from collections import deque
que = deque()
seen = [[False]*W for _ in range(H)]
li = []
for x in range(H):
    for y in range(W):
        if graph[x][y] == '#':
            tp = (x,y)
            li.append(tp)
que.append(li)
dx = [1,0,-1,0]
dy = [0,1,0,-1]
count = 0
while len(que) != 0:
    l = que.popleft()
    lis = []
    for tup in l:
        xa = tup[0]
        ya = tup[1]
        for i in range(4):
            nx = xa + dx[i]
            ny = ya + dy[i]
            if nx >= H or ny >= W or nx < 0 or ny < 0:
                continue
            if graph[nx][ny] == '#':
                continue
            graph[nx][ny] = '#'
            lis.append((nx,ny))
    count+=1
    if len(lis) == 0:
        print(count-1)
        exit()
    que.append(lis)

Measured memory_bytes: 138340
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

// エラトステネスの篩
void Hurui(vector<bool> &prime)
{
    prime.at(0) = 0;
    prime.at(1) = 0;
    rep(2, i, prime.size())
    {
        if (prime.at(i) == 1)
        {
            for (ll j = i + i; j < prime.size(); j += i)
            {
                prime.at(j) = 0;
            }
        }
    }
}

ll pow(ll a, ll b)
{
    if (b == 0)
    {
        return 1;
    }
    if (b % 2 == 0)
    {
        return pow(a, b / 2) * pow(a, b / 2);
    }
    else
    {
        return a * pow(a, b - 1);
    }
}

int main()
{
    ll N, P;
    cin >> N >> P;
    if (N == 1)
    {
        cout << P << endl;
        return 0;
    }
    vector<bool> prime(1000000, 1);

    // エラトステネスの篩による素数列挙
    Hurui(prime);
    vector<ll> p;
    rep(0, i, 1000000)
    {
        if (prime.at(i) == 1)
        {
            p.push_back(i);
        }
    }

    ll ans = 1;
    for (auto i : p)
    {
        ll cnt = 0, PP = P;
        while (PP % i == 0)
        {
            cnt++;
            PP /= i;
        }
        ans *= pow(i, cnt / N);
    }

    cout << ans << endl;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    int tmp;
    rep(i,N)
    {
        rep(j,N)
        {
            tmp = p[i];
            p[i] = p[j];
            p[j] = tmp;
            bool flag = true;
            rep(k,N-1)
            {
                if( p[k] > p[k+1] ) flag = false;
            }
            if(flag)
            {
                cout << "YES" << endl;
                return 0;
            }
            p[j] = p[i];
            p[i] = tmp;
            //rep(l,N) cout << p[l] << " ";
            //cout << endl;
        }
    }
    cout << "NO" << endl;



}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	if a == 0 {
		fmt.Println(0)
		return
	}
  
	forward := n / (a + b) * a
	
	var back int
	if n%(a+b) <= a {
		back = n % (a + b) % a
	} else {
		back = a
	}
  
	fmt.Println(forward + back)
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
using namespace std;

int main()
{
    int m,n,o,i,j,k;
    //long long int m,n,o,i,j,k;
    //float f,g,h;
    //char c,d;
    //string a;
    cin>>n>>m;
    int *stair=new int [n+1];
    stair[0]=1;stair[1]=1;stair[2]=2;
    for(i=0;i<m;i++)
    {
        cin>>o;
        stair[o]=-1;
    }
    for(i=1;i<=n;i++)
    {
        if(stair[i]==-1) stair[i]=0;
        else
        {
            if(i==1) continue;
            stair[i]=stair[i-1]+stair[i-2];
            stair[i]%=mod;
        }
    }
    //cin>>m>>c>>n>>d>>i;
    //cin>>f>>g;
    //cin>>c;
    cout<<stair[n];
    delete [] stair;
    return 0;
}



Measured memory_bytes: 640
def find_d(a,k,n):
    d = a[0] + (k - a[n-1])
    point = 0
    
    for i in range(n-1):
        tmp = a[i+1] - a[i]
        if d<tmp:
            d = tmp
            point = i+1
    return d

if __name__ == "__main__":
    k, n = map(int, input().split())
    a = list(map(int, input().split()))
    d = find_d(a,k,n)
    
    print(k-d)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  for(int i = 0; i < k; i++){
    vector<int> sum(n);
    for(int j = 0; j < n; j++){
      int l = max(0, j-a.at(j)), r = min(n, j+a.at(j) + 1);
      if(r < n) sum.at(r)--;
      sum.at(l)++;
    }
    int now = 0;
    for(int j = 0; j < n; j++){
      now += sum.at(j);
      a.at(j) = now;
    }
    if(a.at(0) == n && a.at(n-1) == n) break;
  }
  
  for(auto now : a) cout << now << " ";
  cout << endl;
}

Measured memory_bytes: 4840
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    ll N,M;cin>>N>>M;
    ll a[100010][2];
    rep(i,0,N){
        a[i][0]=1;//cn
        a[i][1]=0;//red
    }
    a[0][1]=1;
    rep(i,0,M){
        int x,y;
        cin>>x>>y;
        a[x-1][0]--;
        a[y-1][0]++;
        if(a[x-1][1]==1)a[y-1][1]=1;
        if(a[x-1][0]==0)a[x-1][1]=0;
    }
    ll cn=0;
    rep(i,0,N){
        if(a[i][1]==1)cn++;
    }
    cout<<cn<<endl;
}






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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define MIN(c) (*min_element(ALL(c))) 
#define MAX(c) (*max_element(ALL(c)))
#define ACC(c) (accumulate(ALL(c), 0))
#define SLL(x, n) ((x) << (n))
#define SRL(x, n) ((x) >> (n))
#define MIN2(a, b) ((a) < (b)) ? (a) : (b)
#define MAX2(a, b) ((a) > (b)) ? (a) : (b)
#define MP(a, b) (make_pair((a), (b)))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    string s;
    cin >> s;
    int len = s.length();
    int i = 0, cntA = 0;
    ll sum = 0;
    while(i < len){
        while(i < len && s[i] == 'A'){
            cntA++;
            i++;
        }
        if(i > 0 && i + 1 < len && s[i] == 'B' && s[i + 1] == 'C'){
            sum += cntA;
            i += 2;
            while(i + 1 < len && s[i] == 'B' && s[i + 1] == 'C'){
                sum += cntA;
                i += 2;
            }
        }else{
            while(i < len && s[i] != 'A') i++;
            cntA = 0;
        }
    }
    PRINT(sum);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <tuple>
#include <queue>
#define INF (long long)1000000007
#define MOD (long long)998244353
using namespace std;



int main(void){
    int n,m;
    cin >> n >> m;
    using P = pair<long long, long long>;
    vector< P > G[n]; //pair<距離, 行き先>
    vector<long long> dist(n,INF*100000); //sからiの距離
    vector<bool> used(n,false);

    int l,r,c;
    for(int i=0; i<m; i++){
        cin >> l >> r >> c;
        G[l-1].push_back(make_pair(c,r-1));
    }


    priority_queue<P, vector<P>, greater<P> > q;
    q.push( P(0, 0) ); //0 s
    for(int i=1; i<n; i++)G[i].push_back(make_pair(0, i-1));

    //dijkstra
    while(!q.empty()){
        long long d;
        long long t;
        tie(d,t)=q.top();q.pop();
        if(used[t])continue;
        dist[t]=d;
        used[t]=true;
        for( P e: G[t]){
            if(dist[e.second] <= d+e.first)continue;
            q.push( P(d+e.first, e.second));
        }
    }
    if(dist[n-1]==INF*100000)dist[n-1]=-1;
    cout << dist[n-1] << endl;
    
    return 0;
}


Measured memory_bytes: 9972
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 int main() {
	int A,B;cin>>A>>B;
   if(A+B>=10){cout<<"error";}
   else{cout<<A+B;}
	}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <cstring>
#include <string>
#include <tuple>
#include <climits>
#include <cmath>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
const int INF = 987654321;
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int main(){
    int arr[1000];
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i = 0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    sort(arr,arr+n);
    int ans = 0;
    for(int i = 0;i<k;i++){
        ans += arr[i];
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
string s;
int a,b;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s;
	a=(s[0]-'0')*10+(s[1]-'0');
	b=(s[2]-'0')*10+(s[3]-'0');
	if (a==0 && b==0) cout<<"NA";
	else if (a<=12 && b<=12 && a!=0 && b!=0) cout<<"AMBIGUOUS";
	else if (b<=12 && b!=0) cout<<"YYMM";
	else if (a<=12 && a!=0) cout<<"MMYY";
	else cout<<"NA";
	return 0;
}

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

using namespace std;

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

int main(){
  int n;
  cin >> n;
  REP(i, 11) if(i > 0){
    if(i == 10){
      cout << "No" << endl;
      break;
    }
    if(n % i == 0 && n / i < 10){
      cout << "Yes" << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//#pragma GCC optimize "trapv"
int main()
{
	// ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    
	ll n,x,t;
	cin>>n>>x>>t;

	ll ans = n/x;
	if(n%x!=0)
		ans++;
	cout<<ans*t<<"\n";

}

Measured memory_bytes: 3592
#include <stdio.h>

int main() {
  int height, width, i, j, count;
  scanf("%d %d", &height, &width);
  int answer[height][width];
  char str[height+1][width+1];
  for(i = 0; i < height; i++) {
    scanf("%s", &str[i]);
  }
  for(i = 0; i < height; i++) {
    for(j = 0; j < width; j++) {
      count = 0;
      if(str[i][j] == '.') {
        if(i == 0) {
          if(j == 0) {
            count += (str[i][j+1] == '#')? 1 : 0;
            count += (str[i+1][j] == '#')? 1 : 0;
            count += (str[i+1][j+1] == '#')? 1 : 0;
          } else if(j == width - 1) {
            count += (str[i][j-1] == '#')? 1 : 0;
            count += (str[i+1][j] == '#')? 1 : 0;
            count += (str[i+1][j-1] == '#')? 1 : 0;
          } else {
            count += (str[i][j-1] == '#')? 1 : 0;
            count += (str[i][j+1] == '#')? 1 : 0;
            count += (str[i+1][j-1] == '#')? 1 : 0;
            count += (str[i+1][j] == '#')? 1 : 0;
            count += (str[i+1][j+1] == '#')? 1 : 0;
          }
        } else if(i == height - 1) {
          if(j == 0) {
            count += (str[i][j+1] == '#')? 1 : 0;
            count += (str[i-1][j] == '#')? 1 : 0;
            count += (str[i-1][j+1] == '#')? 1 : 0;
          } else if(j == width - 1) {
            count += (str[i][j-1] == '#')? 1 : 0;
            count += (str[i-1][j] == '#')? 1 : 0;
            count += (str[i-1][j-1] == '#')? 1 : 0;
          } else {
            count += (str[i][j-1] == '#')? 1 : 0;
            count += (str[i][j+1] == '#')? 1 : 0;
            count += (str[i-1][j-1] == '#')? 1 : 0;
            count += (str[i-1][j] == '#')? 1 : 0;
            count += (str[i-1][j+1] == '#')? 1 : 0;
          }
        } else {
          if(j == 0) {
            count += (str[i-1][j+1] == '#')? 1 : 0;
            count += (str[i-1][j] == '#')? 1 : 0;
            count += (str[i][j+1] == '#')? 1 : 0;
            count += (str[i+1][j] == '#')? 1 : 0;
            count += (str[i+1][j+1] == '#')? 1 : 0;
          } else if(j == width - 1) {
            count += (str[i][j-1] == '#')? 1 : 0;
            count += (str[i-1][j] == '#')? 1 : 0;
            count += (str[i-1][j-1] == '#')? 1 : 0;
            count += (str[i+1][j] == '#')? 1 : 0;
            count += (str[i+1][j-1] == '#')? 1 : 0;
          } else {
            count += (str[i-1][j-1] == '#')? 1 : 0;
            count += (str[i-1][j] == '#')? 1 : 0;
            count += (str[i-1][j+1] == '#')? 1 : 0;
            count += (str[i][j-1] == '#')? 1 : 0;
            count += (str[i][j+1] == '#')? 1 : 0;
            count += (str[i+1][j-1] == '#')? 1 : 0;
            count += (str[i+1][j] == '#')? 1 : 0;
            count += (str[i+1][j+1] == '#')? 1 : 0;
          }
        }
      }
      answer[i][j] = count;
    }
  }
  for(i = 0; i < height; i++) {
    for(j = 0; j < width; j++) {
      if(str[i][j] == '.') {
        printf("%d", answer[i][j]);
      } else {
        printf("#");
      }
    }
    printf("\n");
  }
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

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

void Main()
{
	string s;
  	cin >> s;
	if(s[0] == s[2]) puts("Yes");
  	else puts("No");
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
s = input()
TD = [input().split() for i in range(Q)]


def simulate(n):
    if n == -1:
        return -1
    if n == N:
        return 1
    for t, d in TD:
        if t == s[n]:
            if d == "L":
                n -= 1
            else:
                n += 1
        if n == -1:
            return -1
        elif n == N:
            return 1
    return 0


l = -1
r = N
while l+1 < r:
    n = (l+r)//2
    sim = simulate(n)
    if sim == -1:
        l = n
    else:
        r = n
L = l

l = -1
r = N
while l+1 < r:
    n = (l+r)//2
    sim = simulate(n)
    if sim == 1:
        r = n
    else:
        l = n
R = r
print(R-L-1)


Measured memory_bytes: 41392
//#include <algorithm>
#include <array>
//#include <cassert>
//#include <cfloat>
//#include <cmath>
//#include <cstdio>
//#include <cstdlib>
//#include <deque>
#include <iostream>
//#include <limits>
//#include <map>
//#include <queue>
//#include <set>
//#include <stack>
//#include <string>
//#include <tuple>
//#include <unordered_map>
//#include <unordered_set>
//#include <vector>
using namespace std;

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

string S;
long sum;

void dfs(int cur, array<char, 10> plus) {
  if (cur >= S.size()) {
    long num{};
    for (int i{}; i < S.size(); ++i) {
      if (plus[i] == '+') {
//        cerr << num << endl;
        sum += num;
        num = 0;
      }
      num *= 10;
      num += S[i] & 0xF;
    }
//    cerr << num << endl;
    sum += num;
    return;
  }
  dfs(cur + 1, plus);
  plus[cur] = '+';
  dfs(cur + 1, plus);
}

int main() {
  cin >> S;
  array<char, 10> plus;
  dfs(1, plus);
  cout << sum << endl;

  return 0;
}


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

using ll = long long;

const ll MOD = 1e9+7;

int H, W, K;

ll add(ll a, ll b) {
   return ((a%MOD) + (b%MOD))%MOD;
}

int main() {
   cin >> H >> W >> K;
   --K;

   ll dp[H+1][W];
   fill(dp[0], dp[H+1], 0);
   dp[0][0] = 1;

   for (int h = 0; h < H; h++) { // それぞれの高さについてループを回す
      for (int mask = 0; mask < (1<<(W-1)); ++mask) { // bit全探索のループ

         // 横線が隣り合っていないかチェック
         bool ok = true;
         for (int i = 0; i < W-2; ++i) {
            // これで末尾が11のときにはじくことが出来る
           if (((mask >> i) & 3) == 3) ok = false;
         }
         if (!ok) continue;

         for (int i = 0; i < W; i++) {
            // go right
            if ((i < W) && ((mask >> (W - (i+2)))&1)) {
               dp[h+1][i+1] += dp[h][i];
               dp[h+1][i+1] %= MOD;
               // dp[h+1][i+1] = add(dp[h+1][i+1], dp[h][i]);
               dp[h+1][i] += dp[h][i+1];
               dp[h+1][i] %= MOD;
               // dp[h+1][i] = add(dp[i+1][i], dp[h][i+1]);
               i++;
            } 
            // go left
            // else if ((i >= 1) && ((mask >> (W - (i)))&1)) {
            //    dp[h+1][i-1] += dp[h][i];
            // } 
            // straight
            else {
               dp[h+1][i] += dp[h][i];
               dp[h+1][i] %= MOD;
               // dp[h+1][i] = add(dp[h+1][i], dp[h][i]);
            }
         }

         // 各始点がどこへ移動するか求める
         /*
         int perm[W];
         for (int i = 0; i < W; ++i) perm[i] = i;

         for (int i = 0; i < W-1; ++i) { // あみだくじのルールにしたがって位置をswap
            if ((mask >> i) & 1) swap(perm[i], perm[i+1]);
         }

         // 配る
         for (int i = 0; i < W; ++i) {
            dp[h+1][perm[i]] += dp[h][i];
            dp[h+1][perm[i]] %= MOD;
         }
         */
      }
   }

   cout << dp[H][K] << endl;

   // for (int yi = 0; yi <= H; yi++) {
   //    for (int xi = 0; xi < W; xi++) {
   //       printf(" %2lld", dp[yi][xi]);
   //    }
   //    puts("");
   // }

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
const ll MOD=1e9+7;
using namespace std;

vector<int> ans;
int state[105][105]={};
int n;
void bfs(int s){
  queue<int> q;
  q.push(s);
  while(!q.empty()){
    int u=q.front();
    q.pop();
    for(int v=0;v<n;v++){
      //隣接していない
      if(state[u][v]==false) continue;
      //既に探索されている
      if(ans[v]!=INT_MAX) continue;
      //未探索の場合
      ans[v] = ans[u]+1;
      q.push(v);
    }
  }

  rep(i,n){
    if(ans[i]==INT_MAX) ans[i] = -1;
    cout << i+1 << " " << ans[i] << endl;
  }
}

int main(){
  cin >> n;
  ans.resize(n,INT_MAX);
  ans[0]=0;
  rep(i,n){
    int u,k;
    cin >> u >> k;
    u--;
    rep(j,k){
      int v;
      cin >> v;
      v--;
      state[u][v]=1;
    }
  }
  bfs(0);
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
int  main()
{
  int N,K; 
  cin >> N;
  cin >> K;
   vector<int> height;
  vector<int> dp(N,INT_MAX);
  int x;
  for(int i=0;i<N;i++)
  {
    cin >> x;
    height.push_back(x);
  }
  
  dp[0]=0;
  for(int i=0;i<N;i++)
  {
    for(int j=i+1;j<=(i+K)&&j<N;j++)
    {
      dp[j]=min(dp[j],dp[i]+abs(height[i]-height[j]));
    }
  }
  
  cout << dp[N-1];
  
}

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int n, k, l[100];
    cin >> n >> k;
    REP(i, n)
    {
        cin >> l[i];
    }

    sort(l, l + n);

    int ans = 0;
    for (int i = 0; i < k; i++)
    {
        ans += l[n - 1 - i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((int)(x).size())

typedef map<int, int> M;
typedef pair<int, int> P;
typedef long long ll;

int main() {
  int tmp = 0, result = 0;
  string S;
  cin >> S;
  REP(i, 3) {
    if (S[i] == 'R') {
      tmp++;
    } else {
      if (tmp > result) {
        result = tmp;
      }
      tmp = 0;
    }
  }
  if (tmp > result) {
    result = tmp;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;
class Main {
  public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int i;
for(i=1;i<=n;i++) {
	int x=i;
	if(x%3==0) {
		System.out.print(" "+i);
	}
	else {
		for(;x>0;x/=10) {
			if(x%10==3) {
				System.out.print(" "+i);
				break;
			}

	}
	}
}
System.out.println();
sc.close();
  }
}






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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 305;

int N;
double dp[maxn][maxn][maxn];

double d(int a,int b,int c){
    double &ans = dp[a][b][c];
    if(ans >= -0.5) return ans;
    ans = 1;
    if(c) ans += (c * d(a,b+1,c-1))/N;
    if(b) ans += (b * d(a+1,b-1,c))/N;
    if(a) ans += (a * d(a-1,b,c))/N ;

    ans *= N;
    ans /= (a+b+c);

    return ans;

}

int main()
{
    cin >> N;
    _for(i,0,maxn) _for(j,0,maxn) _for(k,0,maxn) dp[i][j][k] = -1;
    dp[1][0][0] = N;

    int a = 0,b = 0,c = 0;
    _for(i,0,N){
        int k;cin >> k;
        if(k == 1) a++;
        else if(k == 2) b++;
        else c++;
    }

    printf("%.12lf\n",d(a,b,c));



    return 0;
}


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

using namespace std;

const int MOD = 1e9 + 7;

int n;
vector <int> edge[100005];
long long dp[100005][2];

void solve(int id, int p) {
    dp[id][0] = dp[id][1] = 1;
    for (int i = 0; i < edge[id].size(); i++) {
        int to = edge[id][i];
        if (to == p) continue;
        solve(to, id);
        dp[id][0] = dp[id][0] * (dp[to][0] + dp[to][1]);
        dp[id][0] %= MOD;
        dp[id][1] = dp[id][1] * dp[to][0];
        dp[id][1] %= MOD;
    }
}

int main() {
    scanf("%d", &n);
    
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        edge[x].push_back(y);
        edge[y].push_back(x);
    }

    solve(1, -1);

    printf("%lld\n", (dp[1][0] + dp[1][1]) % MOD);
}



Measured memory_bytes: 14208
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd
enu = enumerate

sys.setrecursionlimit(10**7)
n, a, b = map(int, input().split())
MOD = 10**9 + 7

class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
                ) if isinstance(other, ModInt) else
                ModInt(self.x * pow(other, MOD - 2, MOD))
            )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
            )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
                ModInt(other * pow(self.x, MOD - 2, MOD))
            )

    def __rpow__(self, other):
        return (
                ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
                ModInt(pow(other, self.x, MOD))
                )

def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = 1
    for i in range(n, n - r, -1):
        over = over * i % p
    under = 1
    for i in range(1, r + 1):
        under = under * i % p
    inv = pow(under, p - 2, p)
    return over * inv % p

cnt = pow(2, n, MOD)
ng1 = cmb(n, a, MOD)
ng2 = cmb(n, b, MOD)

cnt, ng1, ng2 = map(ModInt, [cnt, ng1, ng2])

res = (cnt - ng1 - ng2 - 1)

print(res)




Measured memory_bytes: 3316
#include <stdio.h>
int main(void) {
  while (1) {
  int n = -1,d,k = 0;
  scanf("%d %d\n",&n,&d);
  if (n == -1) {break;}
    if (n % (2 * d + 1) != 0) {k = 1;}
  printf("%d\n",(n / (2 * d + 1)) + k);
  }
 return 0; 
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        double n = sc.nextInt() - 1;
        int k = sc.nextInt() - 1;

        System.out.println((int)Math.ceil(n / k));
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(void) {
	char s[4];
	int count[10000] = { 0 };
;
	int county = 0;
	for (int i = 0; i < 4; i++) {
		scanf("%c", &s[i]);
		count[s[i]]++;
		if (count[s[i]] >= 2) {
			county++;
		}
	}

	if (county == 2) {
		printf("Yes");
	}
	else
		printf("No");

	return 0;
}

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

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

  for (int i = 0; floor(i * 1.08) <= 50000; i++) {
    if (floor(i * 1.08) == N) {
      cout << i << "\n";
      return 0;
    }
  }

  cout << ":(" << "\n";
}

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    B = il()

    ret = 0
    for n in range(N):
        tmp = sum(A[:n+1]) + sum(B[n:])
        ret = max(ret, tmp)
    print(ret)


if __name__ == '__main__':
    main()


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  vector<int> A(N);
  int cnt = 0;
  for ( int i = 0; i < N; i++ ) {
    int a;
    cin >> a;
    cnt += !(a%2);
  }

  cout << cnt << endl;
  
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
vi g[125252];

int dfs(int p,int bef,int &ans){
  if(g[p].size()==1)return 0;
  int a=0, b=0;
  REP(i,g[p].size()){
    int to = g[p][i];
    if(to==bef)continue;
    int x = dfs(to,p,ans);
    if(x>a){
      b=a;a=x;
    }else if(x>b){
      b=x;
    }
    // printf("%d : %d\n",p,x);
  }
  // printf("%d : %d, %d\n",p,a,b);
  if(g[p].size()==2)a++;
  CHMAX(ans,a+b);
  return a;
}

int main(){
  scanf("%d",&n);
  REP(i,n-1){
    int x,y;
    scanf("%d%d",&x,&y);
    --x;--y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int ans = 0;
  int root = -1;
  REP(i,n){
    if(g[i].size()==1){
      ans++;
    }else if(g[i].size()==2){
      root = i;
    }
  }
  if(root != -1){
    int add=0;
    dfs(root,-1,add);
    ans += add;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 6400
N = int(input())
H = list(map(int, input().split()))
diff_H = []
for i in range(1, len(H)):
    diff_H += [H[i] - H[i - 1]]

longest = 0
streak = 0
for d_h in diff_H:
    if d_h <= 0:
        streak += 1
    else:
        longest = max(streak, longest)
        streak = 0
longest = max(streak, longest)
print(longest)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i++)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int a,b;
  cin >> a >> b;
  
  int q,w,e;
  q = a + b;
  w = a - b;
  e = a * b;
  
  cout << max({q,w,e}) << endl;
}


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

using namespace std;
typedef long long ll;
int N;
ll a[300003];
ll ans;
int main() {
  cin >> N;

  for(int i = 0; i < 3*N; i++) cin >> a[i];

  sort(a,a+3*N,greater<ll>() );
 

  for(int i = 0; i < N; i++) {
    ans += a[2*i+1];
  }

  cout << ans <<endl;
}


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int di[5] = {-1, 0, 1, 0};
const int dj[5] = {0, -1, 0, 1};
int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  int ans = 0;
  rep(si, h) rep(sj, w)
  {
    if (s[si][sj] == '#')
      continue;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != INF)
        return;
      dist[i][j] = x;
      q.push(P(i, j));
    };
    update(si, sj, 0);
    while (!q.empty())
    {
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      rep(dir, 4)
      {
        int ni = i + di[dir];
        int nj = j + dj[dir];
        if (ni < 0 || ni >= h || nj < 0 || nj >= w)
          continue;
        if (s[ni][nj] == '#')
          continue;
        update(ni, nj, dist[i][j] + 1);
      }
    }
    rep(i, h) rep(j, w)
    {
      if (dist[i][j] == INF)
        continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import Data.Maybe

solveImpl :: Int -> [String] -> [Maybe String]
solveImpl _ [] = []
solveImpl _ ("0":_) = [Nothing]
solveImpl a (x:xs) = Just ("Case " ++ show a ++ ": " ++ x) : solveImpl (a + 1) xs

solve :: [String] -> [Maybe String]
solve xs = solveImpl 1 xs

main :: IO ()
main  = getContents
    >>= return . lines
    >>= return . solve
    >>= return . catMaybes
    >>= mapM_ putStrLn

Measured memory_bytes: 5068
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
int main(){
	int w,h,n;
	cin >> w >> h >> n;
	std::vector<int> py(n);
	std::vector<int> px(n);
	std::vector<pair<int,int> > x(n);
	std::vector<pair<int,int> > y(n);

	for(int i = 0; i < n; ++i){
		cin >> px[i] >> py[i];

		x[i]=std::make_pair(px[i], i);
		y[i]=std::make_pair(py[i], i);
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	vector<int> rmax(n+1,0);
	for(int i = n - 1; i != -1; --i){
		rmax[i] = max(rmax[i+1], py[x[i].second]);
	}

	int val = y[n-1].first;
	for(int i = 0; i < n; ++i){
		val = min(val, rmax[i + 1] + x[i].first);
	}
	cout << val << endl;
}



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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, m; std::cin >> n >> m;
  vi dp(1 << n, inf);
  dp[0] = 0;
  rep(i, m) {
    int a, b; std::cin >> a >> b;
    int key = 0;
    rep(i, b) {
      int c; std::cin >> c;
      key += 1 << (c-1);
    }
    rep(j, 1 << n) {
      chmin(dp[j], dp[j-(j&key)]+a);
    }
  }
  int ans = dp[(1 << n) - 1];
  if (ans == inf) ans = -1;
  std::cout << ans << "\n";
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll A, B, C;
  IN(A,B,C);
  if(A+B+C>=22){
    OUT("bust");
  }else{
    OUT("win");
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string S;
    cin >> S;
    int N = S.size();
    int n = (N-1)/2;
    for(int i = 0; i < N; i++){
        if(S[i] != S[N-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = 0; i < n; i++){
        if(S[i] != S[n-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = 0; i < n; i++){
        if(S[N-i-1] != S[n+1+i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main()
{
    int a[3];
    int t = 1;

    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }

    for(int i = 0; i < 3; i++){
        if(a[i] == 5 || a[i] == 7){

        }else{
            t = 0;
        }
    }
    if(a[0] + a[1] + a[2] != 17){
        t = 0;
    }
    if(t == 0){
        cout << "NO";
    }else{
        cout << "YES";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int card[4][13]  = {0};
    char Class;
    int Rank, n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> Class >> Rank;
        if (Class == 'S') {
            card[0][Rank] = 1;
        } else if (Class == 'H') {
            card[1][Rank] = 1;
        } else if (Class == 'C') {
            card[2][Rank] = 1;
        } else if (Class == 'D') {
            card[3][Rank] = 1;
        }
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 1; j <= 13; j++) {
            if (card[i][j] != 1) {
                if (i == 0) {
                    cout << 'S' << " " << j << endl;
                } else if (i == 1) {
                    cout << 'H' << " " << j << endl;
                } else if (i == 2) {
                    cout << 'C' << " " << j << endl;
                } else if (i == 3) {
                    cout << 'D' << " " << j << endl;
                }
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3076
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<char> ans;

    vector<char> alphabet;
    for (char _char='A'; _char<='Z'; _char++) alphabet.push_back(_char);
    for (char _char='A'; _char<='Z'; _char++) alphabet.push_back(_char);
    for (char _char='A'; _char<='Z'; _char++) alphabet.push_back(_char);

    for (char _char: s) {
        auto ret = find(alphabet.begin(), alphabet.end(), _char);
        auto idx = distance(alphabet.begin(), ret);
        cout << alphabet[idx+n];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 888