akhauriyash/Code-Regression huggingface dataset:
# chokudaiをredcorderにするのはなんとなくできそうなきがするがなんでできないのだろうか
# c->r, r->c = rhokudai
# i->r, r->I = ihokudar
# たしかに出来なかった
# つまり目的の文字にできるのはせいぜい1回まで
# （2回目以降はそれより前に変化させた文字に影響が出る）
# なので、各文字の登場回数を出し、その数だけで比較する
s, t = list(input()), list(input())
sd, td = {}, {}
for sv in s:
    if sv not in sd:
        sd[sv] = 1
    else:
        sd[sv] += 1
for tv in t:
    if tv not in td:
        td[tv] = 1
    else:
        td[tv] += 1
ss, ts = sorted(sd.values()), sorted(td.values())
if ss == ts:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 12236
import sys

def main():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())

    if v <= w:
        print('NO')
        sys.exit()

    diff = abs(a-b)
    shrink = v - w

    if (shrink * t >= diff):
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
const int N=1000009;
int bit[N],l[N];
void update(int x,int d){
	while(x<N){
		bit[x]+=d;
		x+=(x & -x);
	}
}
int read(int x){
	int sum=0;
	while(x>0){
		sum+=bit[x];
		x-=(x & -x);
	}
	return sum;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,q,j=0;
	cin >> n >> q;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin >> a[i];
	int ans[q];
	pair <pair <int,int> ,int > v[q];
	for(int i=0;i<q;i++){
		cin >> v[i].f.s >> v[i].f.f;
		v[i].s=i;
	}
	sort(v,v+q);
	memset(l,-1,sizeof(l));
	memset(bit,0,sizeof(bit));
	for(int i=1;i<=n;i++){
		if(l[a[i]]!=-1)
			update(l[a[i]],-1);
		l[a[i]]=i;
		update(l[a[i]],1);
		while(v[j].f.f==i){
			ans[v[j].s]=read(v[j].f.f)-read(v[j].f.s-1);
			j++;
		}
	}
	for(int i=0;i<q;i++)
		cout << ans[i] << endl;
}

Measured memory_bytes: 21340
#include<bits/stdc++.h>
using namespace std;
main(){
  long long n,q;
  long long plot[300005]={0};
  long long before[300005]={0};
  cin>>n>>q;
  long long maxs=-1;
  for(int i=0;i<n;i++){
    long long num;
    cin>>num;
    plot[num]=1;
    maxs=max(maxs,num);
  }
  long long c[300005];
  long long b=0;
  for(int i=0;i<=maxs;i++){
    before[i]=b;
    if(plot[i]==1){
      b=i;
    }
  }
  for(int i=0;i<q;i++){
    cin>>c[i];
    long long pos=maxs;
    long long ans=0;
    while(pos>0){
      ans=max(ans,pos%c[i]);
      pos=before[pos-pos%c[i]];
    }
    cout<<ans<<endl;
  }
  
}

Measured memory_bytes: 8564
/**
 * Author : RDP
 * There are no two words in the English language more harmful than "good job".
 * 1729 ;)
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
using ll = long long;
#define endl '\n'
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) 
{
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define all(x) (x).begin(), (x).end()
/* **************************************************************************************** */

void test_case()
{
    ll d, t, s;
    cin >> d >> t >> s;
    if(ceil(double(d) / s) <= t)
        cout << "Yes";
    else 
        cout << "No";
    return ;
}
int main()
{
	FAST_IO
    int t = 1;
    //cin >> t;
    while(t--)
        test_case();
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,q;
	cin>>n>>q;
	vi a(n),b(n);
	rep(i,n)cin>>a[i]>>b[i];
	ll l=0,r=2e18;
	while(r-l>1){
		ll h=(l+r)/2;
		ll sum=0;
		rep(i,n)if(h-a[i]>=0)sum+=1+(h-a[i])/b[i];
		if(sum>q-1)r=h;
		else l=h;
	}
	cout<<r<<endl;
}




















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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

typedef unsigned long long ull;
 
mt19937_64 r(std::chrono::high_resolution_clock::now().time_since_epoch().count());

ull const MASK30 = (1<<30)-1;
ull const MASK31 = INT_MAX;
ull const MOD = (1LL<<61)-1;
ull const MOD5 = MOD*5;
ull const base = r()%MOD;
 
struct RollingHash {
private:
    vector<ull> power,hash;
public:
    inline ull mul(ull a,ull b) {
        ull au = a>>31;
        ull ad = (a&MASK31);
        ull bu = b>>31;
        ull bd = (b&MASK31);
        ull mid = au*bd+ad*bu;
        return ((au*bu)<<1)+ad*bd+(mid>>30)+((mid&MASK30)<<31);
    }

    inline ull calcmod(ull a) {
        a = (a&MOD)+(a>>61);
        if (a > MOD) a -= MOD;
        return a;
    }

    RollingHash(string& s) {
        int n = s.size();
        power.resize(n+1);
        hash.resize(n+1);
        power[0] = 1;
        hash[0] = 0;
        for (int i = 0;i < n;++i) power[i+1] = calcmod(mul(power[i],base));
        for (int i = 0;i < n;++i) hash[i+1] = calcmod(mul(hash[i],base)+s[i]);
    }

    ull get(int l, int r)  {
        if (l) return calcmod(hash[r]+MOD5-mul(hash[l],power[r-l]));
        return hash[r];
    }
 
 
    ull connect(ull h1,int l,int r) {
        ull h2 = get(l,r);
        return calcmod(mul(h1,power[r-l])+h2);
    }

    // [l,r)
    int LCP(int l1,int r1,RollingHash& rh,int l2,int r2) {
        int ok = 0,ng = min(r1-l1,r2-l2)+1;
        while (ng-ok > 1) {
            int mid = (ok+ng)/2;
            if (get(l1,l1+mid) == rh.get(l2,l2+mid)) ok = mid;
            else ng = mid;
        }
        return ok;
    }
};

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    RollingHash rh(s);
    for (int i = 0;i < n-1;++i) for (int j = i+1+ans;j < n-ans;++j) {
        ans = max(ans,min(j-i,rh.LCP(i,j,rh,j,n)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <map>
using namespace std;
int x[10000];
int main() {
	
	int n;
	cin>>n;
	int MAX;
	for(int i = 0; i < n; i++)
	{
		cin>>x[i];
	}
	MAX = x[0];
	int k = 1;
	for(int i = 1; i < n; i++)
	{
		if(x[i] >= MAX)
		{
			k++;
			MAX = x[i];
		}
	}
	cout<<k;
	
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();

        final int[] b = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int sum = b[0];
        for (int i = 0; i < n - 2; i++) {
            sum += Math.min(b[i], b[i + 1]);
        }
        sum += b[b.length - 1];

        System.out.println(sum);
    }
}

Measured memory_bytes: 26964
import string
s = input()

s = sorted(set(s))
moji = [chr(i) for i in range(ord('a'), ord('z')+1)]
# print(s)
# print(moji)

def b():
    for i in range(len(moji)):
        if i > len(s)-1 or moji[i] != s[i]:
            return moji[i]
    return "None"

print(b())



Measured memory_bytes: 3832
#include<stdio.h>
int main(){
int n, k, x, i, sum=0;

scanf("%d %d", &n, &k);
for(i=0; i<n; i++){
scanf("%d", &x);
if(x < k-x){
sum += x * 2;
}else{
sum += (k-x) * 2;
}
}
printf("%d\n", sum);

return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()

X = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
x = {}
for i in range(26):
    x[X[i]] = i
ans = ''
for i in range(len(S)):
    ans += X[(x[S[i]]+N)%26]
print(ans)

Measured memory_bytes: 41196
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    ll m = LLONG_MAX;
    for (ll i = 0; i < n - k + 1; i++)
    {
        // cout << i << " " << i + k - 1 << endl;
        m = min(m, abs(v[i]) + abs(v[i] - v[i + k - 1]));
        m = min(m, abs(v[i + k - 1]) + abs(v[i] - v[i + k - 1]));
    }
    cout << m << endl;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

int main() {
  char a; cin>>a;
  if('a'<=a&&a<='z') cout<<'a'<<endl;
  else cout<<'A'<<endl;
}


Measured memory_bytes: 3648
x,n = map(int, input().split())
p = list(map(int, input().split()))
p.sort()

pidx = 0
ansabs = 1000
for i in range(102):
    if pidx < n and i == p[pidx]:
        pidx += 1
        continue
    if ansabs > abs(i - x):
        ansabs = abs(i - x)
        ans = i

print(ans)


Measured memory_bytes: 9180
/**
 *   
 *   Date: 22 December 2019
 *   Time: 17:49:31
**/
#pragma GCC optimize("O3")
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>
#include <cstring>
#include<queue>
#include<stack>
#include<climits>
#include<iomanip>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1000000007;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll a,b,c,d;
	cin>>a>>b;
	d=6-(a+b);
	cout<<d<<endl;

return 0;
}

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

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

}cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;

int main(){
  int n;
  cin >> n;
  ll ans = 0;
  rep(i, n+1){
    if (i%3 && i%5) ans += (ll)i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A,B; cin >> A >> B;
    string S; cin >> S;
    bool ans = true;
    for(int i = 0; i < A; i++){
        if(!('0' <= S[i] && S[i] <= '9')) ans = false;
    }
    if(S[A] != '-') ans = false;
    for(int i = A+1; i < A+B; i++){
        if(!('0' <= S[i] && S[i] <= '9')) ans = false;
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

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


int main()
{
    ll n,d;
    cin >> n >> d;
    d=d*d;
    int ans=0;
    REP(i,n){
        ll x,y;
        cin >> x >> y;
        if(d>=x*x+y*y){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#define N 105
#define WHITE 0
#define BLACK 1
#define inf 1000000

int a[N][N];
int n;

void prim();
int main(){

  int i,j;

  scanf("%d",&n);
  for(i=0; i < n; i++){
    for(j=0; j < n; j++){
      scanf("%d",&a[i][j]);
    }
  }

  prim();

  return 0;
}

void prim(){
  int u,b,v;
  int cost,s=0;
  int d[N],p[N],color[N];

  for(u=0; u < n; u++){
    d[u]=inf;
    p[u]=0;
    color[u]=WHITE;
  }
  d[0]=0;

  while(1){
    cost=inf;
    for(b=0; b < n; b++){
      if(color[b] ==WHITE && d[b] < cost){
	cost=d[b];
	u=b;
      }
    }
      if(cost == inf) break;

      color[u]=BLACK;

      for(v=0; v < n; v++){
	if(color[v] == WHITE && a[u][v] < d[v] && a[u][v] != -1){
	  p[v]=u;
	  d[v]=a[u][v];
	}
      }
  }
  for(u=0; u < n; u++){
    s+=d[u];
  }

  printf("%d\n",s);
}

Measured memory_bytes: 640
#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 h, w; std::cin >> h >> w;
  vvi cost(10, vi(10));
  rep(i, 10) rep(j, 10) std::cin >> cost[i][j];
  rep(k, 10) rep(i, 10) rep(j, 10) chmin(cost[i][j], cost[i][k]+cost[k][j]);
  int ans = 0;
  rep(i, h) rep(j, w) {
    int a; std::cin >> a;
    if (a == -1) continue;
    ans += cost[a][1];
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))

    a = list(range(N))
    if N % 2 == 1:
        a2 = a[::2] * 2
        a2.sort(reverse=True)
        a2.pop()
    else:
        a2 = a[1::2] * 2
        a2.sort(reverse=True)
    A.sort(reverse=True)

    if tuple(a2) == tuple(A):
        comb = (2 ** (N // 2)) % 1000000007
        print(str(comb))
    else:
        print('0')

main()


Measured memory_bytes: 13880
#include <stdio.h>
#define MAX 10000
int main(){

  int i,j,count=0;
  int n,q;
  int S[MAX],T[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i] == S[j]){
	count++;
	break;
      }
    }
  }

  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, C;
    cin >> A >> B >> C;
    if ((B / A) >= C) {
        cout << C << endl;
    } else {
        cout << (B / A) << endl;
    }
    return 0;
}

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

using namespace std;

// 1 つの証言を表す構造体
using pint = pair<int,int>; // 「人」と「0 or 1」

// 入力
int N;
vector<vector<pint>> v;

// 整数 bit に対応する「決め打ち」が整合しているかを判定
bool judge(int bit) {
    
    // i 人目の証言を検証する
    for (int i = 0; i < N; ++i) {
        
        // i 人目が「不親切」だったら、証言はすべて無意味
        if ( !(bit & (1 << i)) ) continue;

        // それぞれ確認
        for (pint xy : v[i]) {
            int x = xy.first; // x が
            int y = xy.second; // y = 1: 正直、y = 0: 不親切

            // y = 1 なのに「不親切」だったらダメ
            if (y == 1 && !(bit & (1 << x))) return false;

            // y = 0 なのに「正直者」だったらダメ
            if (y == 0 && (bit & (1 << x))) return false;
        }
    }
    return true;
}


int main() {
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i) {
        int A; cin >> A;
        v[i].resize(A);
        for (int j = 0; j < A; ++j) {
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first; // 0-indexed に
        }
    }

    int res = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        
        // 矛盾 check
        if (judge(bit)) {
            
            bitset<15> s(bit);
            // bit に含まれる人数を数える
            int cnt = s.count();
           
            res = max(res, cnt);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);

	if(a < b){
		printf("a < b\n");
	}else if(a > b){
		printf("a > b\n");
	}else if(a == b){
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<string>
using namespace std;
int main(void){
    double c;
    while(cin >> c){
        if(c<=48.00)                    cout << "light fly" << endl;
        else if(48.00<c && c<=51.00)    cout << "fly" << endl;
        else if(51.00<c && c<=54.00)    cout << "bantam" << endl;
        else if(54.00<c && c<=57.00)    cout << "feather" << endl;
        else if(57.00<c && c<=60.00)    cout << "light" << endl;        
        else if(60.00<c && c<=64.00)    cout << "light welter" << endl;
        else if(64.00<c && c<=69.00)    cout << "welter" << endl;
        else if(69.00<c && c<=75.00)    cout << "light middle" << endl;
        else if(75.00<c && c<=81.00)    cout << "middle" << endl;
        else if(81.00<c && c<=91.00)    cout << "light heavy" << endl;
        else                            cout << "heavy" << endl;
    }
}


Measured memory_bytes: 3168
package main

import (
	"fmt"
)

func isA(a int) bool {
	switch a {
	case 1, 3, 5, 7, 8, 10, 12:
		return true
	}
	return false
}

func isB(a int) bool {
	switch a {
	case 4, 6, 9, 11:
		return true
	}
	return false
}

func isC(a int) bool {
	if a == 2 {
		return true
	}
	return false
}

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

	if (isA(x) && isA(y)) ||
		(isB(x) && isB(y)) ||
		(isC(x) && isC(y)) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 1836
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 2 * 105000;
const int INF = (int) 1e9;

class SegmentTree {
private: 
  long long tree[4 * MAXN];
  int num;
public:
  void init(int n) {
    num = 1;
    while (num < n) {
      num *= 2;
    }
    for (int i = 1; i < 2 * num; i++) {
      tree[i] = -INF;
    }
  }

  long long getMax(int l, int r) {
    l = num + l; r = num + r;
    long long res = -INF;
    
    while (l <= r) {
      if (l & 1) {
        res = max(res, tree[l]);
        l++;
      }
      if (r % 2 == 0) {
        res = max(res, tree[r]);
        r--;
      }
      l /= 2; r /= 2;
    }

    return res;
  }

  void update(int pos, long long val) {
    pos = num + pos;
    tree[pos] = val;
    pos /= 2;
    while (pos >= 1) {
      tree[pos] = max(tree[pos * 2], tree[pos * 2 + 1]);
      pos /= 2;
    }
  }
};

int n;
int h[MAXN];
int a[MAXN];
long long ans;
SegmentTree tree;

int main() { 

  scanf("%d", &n);

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

  tree.init(n);

  for (int i = 0; i < n; i++) {
    long long cur = a[i];
    if (h[i] > 1) {
      long long mx = tree.getMax(0, h[i] - 2);
      if (mx >= 0) {
        cur += mx;
      }
    }
    ans = max(ans, cur);
    tree.update(h[i] - 1, cur);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8448
#include<iostream> 
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a+b > c+d) {
        cout << "Left" << endl;
    } else if (a+b < c+d) {
        cout << "Right" << endl;
    } else cout << "Balanced" << endl;
}

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

int main()
{
  string s;
  cin>>s;
  
  bool flag1=false;
  if(s.at(2)==s.at(3))
    flag1=true;

  bool flag2=false;
  if(s.at(4)==s.at(5))
    flag2=true;  

  if(flag1==true && flag2==true)
    cout<<"Yes"<<endl;
  else
  {
    cout<<"No"<<endl;
  }
  

  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
AtCoder A
"""
import math
# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column

# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']

def main():
    # N = int(input())
    A, B = list(map(int,input().split()))
    print(math.floor((A*3+B)/2))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#include <cstdio>   
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;

int a[100001];

int binary_search(int n,int k){
    int low = 0,high = n,mid,ind;
    ind = 0;
    while(low<high){
        mid = (low+high)/2;

        if(a[mid]<k){
            low = mid+1;
        }
        else if(a[mid]>=k){
            high = mid;
            ind = mid;
        }
    }
    return ind;
}

int main(){
    ofstream out("output.txt");

    int n;
    cin>>n;

    for(int i= 0; i<n; i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int cont = 0,ind;
    for(int k = a[0]; k<=a[n-1]; k++){
        ind = binary_search(n,k);
        //cout<<k<<" "<<ind<<endl;
        if(ind == (n)/2) cont++;
    }   

    cout<<cont<<endl;
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string A, B; cin >> A >> B;
    int na = A.size(), nb = B.size();
    string res = "EQUAL";
    if(na == nb){
        if(A < B) res = "LESS";
        if(A > B) res = "GREATER";
    }
    else {
        if(na < nb) res = "LESS";
        if(na > nb) res = "GREATER";
    }

    cout << res << endl;

    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int64 A, B, C, K;
  cin >> A >> B >> C >> K;
  for(int x = 0; x <= K; x++) {
    for(int y = 0; y <= K; y++) {
      for(int z = 0; z <= K; z++) {
        if(x + y + z > K) {
          continue;
        }
        int64 a = A, b = B, c = C;
        for(int p = 0; p < x; p++) a *= 2;
        for(int p = 0; p < y; p++) b *= 2;
        for(int p = 0; p < z; p++) c *= 2;
        if(a < b && b < c) {
          cout << "Yes\n";
          return 0;
        }
      }
    }
  }
  cout << "No\n";
}


Measured memory_bytes: 3604
n = int(input())
a = n // 1000
b = n % 1000 // 100
c = n % 100 // 10
d = n % 10

def calc(ind, x):
    if ind == 0:
        return x
    else:
        return -x

flag = 0
for j in range(2):
    ans1 = a
    if flag:
        break
    ans2 = ans1 + calc(j, b)
    for k in range(2):
        if flag:
            break
        ans3 = ans2 + calc(k, c)
        for l in range(2):
            ans4 = ans3 + calc(l, d)
            if ans4 == 7:
                flag = 1
                result = ['+' if x == 0 else '-' for x in [j, k, l]]
                break
answer = str(a) + result[0] + str(b) + result[1] + str(c) + result[2] + str(d) + '=7'
print (answer)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
    
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef vector<pair<int, int> > vp;
typedef pair<int, int> pr;
    
#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i > _a; i--)
#define pb push_back
#define print(v) cout << v << '\n'
#define pr_vec(v)   for (int i = 0; i != v.size(); i++) cout << v[i] << ' '
#define vin(v)  for (auto &i: v)    cin >> i
    
ll M = 1e9 + 7;

struct ListNode {
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode *next) : val(x), next(next) {}
};

void traverse(ListNode* root) {
    while (root) {
        cout << root->val << ' ';
        root = root->next;
    }
    cout << '\n';
}
     
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t, n, m, k, q;
    string s;
    
    cin >> n;

    if (n % 1000 == 0)  print(0);
    else    print(1000 - n % 1000);
    
    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int count = 0;
  if (a != b) {
    count++;
  }
  if (b != c) {
    count++;
  }
  if (c != a) {
    count++;
  }
  if (count == 0) {
    count = 1;
  }
  cout << count << endl;
}

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

typedef long long ll;
typedef pair<int,int>P;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define pb push_back
#define vec vector<int>


/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);
ll lcm(ll, ll);//AとBの最小公倍数
ll gcd(ll,ll);*/
/*--------------------------------------------*/
/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a = A;
    ll b = B;
    if (a == 0 || b == 0) { return 0; }
    if (a < 0) { a = -a; }
    if (b < 0) { b = -b; }
    while (b > 0) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return A/a*B;
}

ll gcd(ll a,ll b){
    while (b != 0) {
        int t = b;
        b = a % b;
        a = t;
    }
    return a;
}


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

ll divisor(ll n){
    for(ll i=2;i<=n;i++){
        ll d=1;
        ll tmp=i;
        while(tmp>0){
            d++;
            while(tmp%d==0){
                prime[i]++;
                tmp/=i;
            }
        }
    }
    ll sum=1;
    for(ll i=2;;i<=n;i++){
        sum*=(prime[i]+1)/MOD;
    }    
    cout<<"sum="<<sum<<endl;

    return sum%MOD;
}
*/
/*--------------------------------------------*/

const int MAX_N = 110000;

int dp[MAX_N]; // dp[i] が i についての答え

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

    // 初期化
    for (int i = 0; i < MAX_N; ++i) dp[i] = N; // INF の気持ち
    dp[0] = 0;

    // 貰う DP --- dp[n] に遷移を集める
    for (int n = 1; n <= N; ++n) {
        for (int pow6 = 1; pow6 <= n; pow6 *= 6) {
            //printf("n=%d,pow6=%d,,dp[%d]=%d\n",n,pow6,n,dp[n]);
            dp[n] = min(dp[n], dp[n - pow6] + 1);
            //printf("n=%d,pow6=%d,,dp[%d]=%d\n",n,pow6,n,dp[n]);
        }
        for (int pow9 = 1; pow9 <= n; pow9 *= 9) {
            //printf("n=%d,pow9=%d,,dp[%d]=%d\n",n,pow9,n,dp[n]);
            dp[n] = min(dp[n], dp[n - pow9] + 1);
            //printf("n=%d,pow9=%d,,dp[%d]=%d\n",n,pow9,n,dp[n]);
        }
    }

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

Measured memory_bytes: 640
//  aoj-VolumeICPCOOC2015-C  / 2015-11-29
#include<iostream>
#include<vector>
#include<cassert>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<tuple>
#include<array>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef ll int__;
#define rep(i,j) for(int__ i=0;i<(int__)(j);i++)
#define repeat(i,j,k) for(int__ i=(j);i<(int__)(k);i++)
#define all(v) v.begin(),v.end()

template<typename T>ostream& operator << (ostream &os , const vector<T> &v){
    rep(i,v.size()) os << v[i] << (i!=v.size()-1 ? " " : "\n"); return os;
}

template<typename T>ostream& operator << (ostream &os , const set<T> &v){
    os << "[";
    for(T i : v) os << i << " ";
    os << "]" << endl;
    return os;
}

template<typename T>istream& operator >> (istream &is , vector<T> &v){
    rep(i,v.size()) is >> v[i]; return is;
}

#ifdef DEBUG
void debug(){ cerr << endl; }
#endif
template<class F,class...R> void debug(const F &car,const R&... cdr){
#ifdef DEBUG
    cerr << car << " "; debug(cdr...);
#endif
}

typedef vector<vector<int>> Edgelist;

set<int> get_neighbors(const Edgelist &E,int s,int dist){
    set<int> state[2];
    state[0].insert(s);
    rep(i, dist){
        set<int> &pre = state[ i%2 ],
                 &now = state[ (i+1)%2 ];
        now.clear();
        for(int pv : pre){
            for(int nxt : E[pv]){
                now.insert(nxt);
            }
        }
        //debug("get",dist,i+1,now);
    }
    return state[dist%2];
}

set<int> get_intersection(int n,array<set<int>,3> &sets){
    vector<int> cnt(n,0);
    rep(i,3){
        for(int v : sets[i]){
            cnt[v]++;
        }
    }
    set<int> ret;
    rep(i,n)if(cnt[i]==3)ret.insert(i);
    return ret;
}

bool solve(){
    int n,m; cin >> n >> m;
    array<int,3> abc; rep(i,3) cin>>abc[i];
    Edgelist E(n);
    rep(i,m){
        int a,b; cin >> a >> b;
        --a;--b;
        E[b].push_back(a); // reversed edge
    }
    debug(E);
    
    set<int> goals;
    array<set<int>,3> neighbors;
    vector<bool> visited(n);
    vector<int> dist(n,-1);
    goals.insert(n-1);
    int pre_goals_size = 0;
    int turn = 1;
    while(pre_goals_size != (int)goals.size()){
        pre_goals_size = goals.size();
        set<int> goals_clone = goals;
        for(int v : goals_clone){
            if(visited[v])continue;
            visited[v] = true;
            rep(i,3){
                set<int> tmp = get_neighbors(E, v, abc[i]);
                neighbors[i].insert( all(tmp) );
                debug(i,neighbors[i]);
            }
        }

        set<int> intersection = get_intersection(n,neighbors);
        debug(intersection);
        for(int ng : intersection){
            if(not goals.count(ng)){
                dist[ng] = turn;
                goals.insert(ng);
            }
        }
        turn++;
    }

    if(dist[0] < 0) cout << "IMPOSSIBLE" <<endl;
    else cout << dist[0] << endl;
    
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    while(solve());
    return 0;
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
int main() {
	ll a,b,c;
  	ll ans = INF;
  	cin >> a >> b >> c;
  	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0) ans = 0;
  	else {
      ll pat1 = (a + 1) * b * c - a * b * c;
      ll pat2 = a * (b + 1) * c - a * b * c;
      ll pat3 = a * b * (c + 1) - a * b * c;
      chmin(ans,pat1);
      chmin(ans,pat2);
      chmin(ans,pat3);
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int LinearSearch(int*,int,int);

int main()
{
  int n,q,T,i,num=0;
  int S[10000];

  scanf("%d",&n);

  for(i=0;i<n;i++) {
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&T);
    if(LinearSearch(S,T,n) == 1){
      num++;
    }
  }

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

}

int LinearSearch(int *A,int T,int n)
{
  int i;
  for(i=0;i<n;i++) {
    if(A[i] == T)
      return 1;
  }

  return 0;
}
    



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    int a,b,h,m;cin >> a >> b >>h >>m;
    double ang1,ang2,theta;
    theta =  PI * 2 * (h / 12.0 + m / 60.0/ 12.0 - m / 60.0);
    double ans=0;
    ans = sqrt(a*a+b*b-2*a*b*cosl(theta));
    cout << fixed << setprecision(20) << ans << endl;

    return 0;
}




Measured memory_bytes: 4176
(n, m) = map(int, input().split())
a = []
b = []
graph = [[False for _ in range(n)] for _ in range(n)]
for _ in range(m):
    (a_i, b_i) = map(int, input().split())
    a_i -= 1
    b_i -= 1
    graph[a_i][b_i] = True
    graph[b_i][a_i] = True
    a.append(a_i)
    b.append(b_i)


def dfs(v):
    visit[v] = True
    for i in range(n):
        if not graph[v][i]:
            continue
        if visit[i]:
            continue
        dfs(i)


ans = 0
for i in range(m):
    graph[a[i]][b[i]] = False
    graph[b[i]][a[i]] = False
    visit = [False for _ in range(n)]
    dfs(0)
    bridge = False
    for j in range(n):
        if not visit[j]:
            bridge = True
            break
    if bridge:
        ans += 1
    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True

print(ans)


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

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

    string s;
    cin >> s;

    int n = s.size();

    int l = 0, r = n - 1, cnt = 0;
    while(l <= r){
        if(l == r) break;
        if(s[l] == s[r]){
            l++;
            r--;
        }else if(s[l] == 'x'){
            l++;
            cnt++;
        }else if(s[r] == 'x'){
            r--;
            cnt++;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>

typedef long long ll;
typedef unsigned int uint;

const int MaxN = 55, MaxW = 1 << 18;

ll C[MaxN][MaxN], F[MaxN];

void init_binom(int n, int k) {
	for (int i = 0; i <= n; ++i) {
		C[i][0] = 1; F[i] = 0;
		for (int j = 1; j <= i && j <= k; ++j) {
			F[i] += C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
		}
	}
}

int buk[MaxW];

int main() {
	int n, k; uint S, T;
	scanf("%d%d%u%u", &n, &k, &S, &T);
	init_binom(n, k);
	std::vector<uint> arr;
	for (int i = 0; i < n; ++i) {
		uint x; scanf("%u", &x);
		if (S == (S & x) && T == (T | x)) arr.push_back(x);
	}
	uint M = ~S & T;
	ll ans = F[arr.size()];
	for (uint S = M; S; --S &= M) {
		for (uint x: arr) ++buk[x & S];
		ll sum = 0;
		for (uint x: arr) {
			int &t = buk[x & S];
			sum += F[t];
			t = 0;
		}
		ans += __builtin_popcount(S) & 1 ? -sum : sum;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4276
#include <iostream>

using namespace std;

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

int main(){
	int T;
	cin >> T;
	while(T--){
		int x, y, w, h;
		cin >> x >> y >> w >> h;
		int n;
		cin >> n;
		int ans = 0;
		rep(i, n){
			int xx, yy;
			cin >> xx >> yy;
			if(x <= xx && xx <= x+w && y <= yy && yy <= y+h) ans++;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    ll x[n],y[n],h[n];
    int remi;
    REP(i,n){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]>0)remi = i;
    }
    ll tmp;
    int i=0;
    REP(cx,101){
        REP(cy,101){
            tmp = h[remi]+llabs(x[remi]-cx)+llabs(y[remi]-cy);
            REP(k,n){
                if(h[k] > 0){
                    if(tmp==h[k]+llabs(x[k]-cx)+llabs(y[k]-cy)){
                        continue;
                    }   
                    tmp = -1;
                    break;
                }
                else{
                    if(tmp > llabs(x[k]-cx)+llabs(y[k]-cy)){
                        tmp = -1;
                        break;
                    }
                }
            }
            if(tmp != -1){
                cout << cx << " " << cy << " " << tmp << endl;
                return 0;
            }
        }
    }
    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;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  bool ans = true;
  rep(i,n) {
    if (a[i]%2==0){
      if (a[i]%3!=0 && a[i]%5!=0) ans = false;
    }
  }
  if (ans) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		l: usize,
		r: usize,
		d: usize,
	}

	let mut count = 0;
	for i in l..=r {
		if i % d == 0 {
			count += 1;
		}
	}

	println!("{}", count);
}



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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n) { cin >> a[i]; }
    sort(a.begin(), a.end());
    rep(i, n - 1) { ans += (a[i + 1] - a[i]); }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

vll getDivisors(ll n) 
{ 
	vll facts;
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i) 
            	facts.push_back(i);     
  
            else {
            	facts.push_back(i);
            	facts.push_back(n/i);
            } 
               
        } 
    } 
    return facts;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll n, m,ans=0; cin>>n;
    vll divs = getDivisors(n);
    for(ll a : divs) {
    	m = n/a - 1;
    	if(m > 0 && a == n/m && a == n%m) {
    		ans += m;
    	}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
int MOD=1000000000+7;
int INF=1e6;

using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    string s,t;
    int q;
    cin>>s>>t>>q;
    int snum[1100000]={},tnum[110000]={};
    int temp=0;
    rep(i,s.size()){
        if(s[i]=='A') temp++;
        snum[i+1]=temp;
    }
    temp=0;
    rep(i,t.size()){
        if(t[i]=='A') temp++;
        tnum[i+1]=temp;
    }
    rep(i,q){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int sa=snum[b]-snum[a-1];
        int sb=b-a+1-sa;
        int x=(sa-sb+300000)%3;

        int ta=tnum[d]-tnum[c-1];
        int tb=d-c+1-ta;
        int y=(ta-tb+300000)%3;
        
        if(x==y) cout<<"YES";
        else cout<<"NO";
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 5632
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << (a <= 8 && b <= 8 ? "Yay!" : ":(") << '\n';
}


Measured memory_bytes: 256