akhauriyash/Code-Regression huggingface dataset:
// ----------------------------------------------------------

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;
#define INF_I  			(int)100000009;

int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	vector<int> A(5);
	cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
	int org_data[] =  { 0, 1, 2, 3, 4 };
	vector<int> P(org_data, org_data + 5);

	int final_answer = INF_I;

	do {
		int ans = 0;
		for (int i = 0; i < 5; ++i) {
			while (ans % 10 != 0) ans += 1;
			ans += A[P[i]];
		}
		final_answer = min(final_answer, ans);
	} while (next_permutation(P.begin(), P.end()));

	cout << final_answer << endl;

	return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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










int main(){
    ll n;
    cin >> n;
    vector<ll> p(n);
    REP(i, n){
        cin >> p[i];
    }
    ll ans = 0;
    for(ll i = 1; i < n - 1; i++){
        if((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,x,i,a[101],count=0,sum=0;
    scanf("%d%d",&n,&x);

    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0; i<n; i++)
    {
        sum=sum+a[i];
        if(sum>x)
            break;
        count++;
    }
    printf("%d\n",count+1);

    return 0;
}


Measured memory_bytes: 128
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353
const string YES = "Yes";
const string NO = "No";

void no(){
	cout<<NO NL;
	exit(0);
}
void yes(){
	cout<<YES NL;
	exit(0);
}

struct UF{
  vector<int> data;
  UF(int size):data(size,-1){}
  bool unite(int x,int y){
    x=root(x); y=root(y);
    if(x!=y){
      if(-data[y]>-data[x]) swap(x,y);
      data[x]+=data[y]; data[y]=x;
    }
    return x!=y;
  }
  bool findSet(int x,int y){return root(x)==root(y);}
  int root(int x){return data[x]<0?x:data[x]=root(data[x]);}
  int size(int x) {return -data[root(x)];}
	bool operator()(int x,int y){ return findSet(x,y);}
	int operator[](int x){ return root(x);}
	bool unti(int x,int y){ return unite(x,y);}
};


int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	ll N;
  cin>>N; N;
  vector<ll> A(N);
  rep(i,N){
    cin>>A[i]; A[i];
  }
  vector<ll> B(N);
  rep(i,N){
    cin>>B[i]; B[i];
  }
	auto a=A;
	auto b=B;
	sort(all(a));
	sort(all(b));
	rep(i,N)if(a[i]>b[i]) no();
	reps(i,1,N)if(a[i]<=b[i-1]) yes();
	const int n=N;
	vector<int> inv(n);
	rep(i,n){
		int j=lower_bound(all(b),B[i])-b.begin();
		inv[j]=i;
	}
	UF uf(n);
	rep(i,n){
		int j=lower_bound(all(a),A[i])-a.begin();
		uf.unti(i,inv[j]);
	}
	if(uf.size(0)==n) no();
	yes();
	return 0;
}


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

long lucas[100] = {2, 1};

long search(int n){
	if(lucas[n] != 0) return lucas[n];
	lucas[n] = search(n-1) + search(n-2);
	return lucas[n];
}

int main(){
	int n;
	scanf("%d", &n);
	printf("%ld\n", search(n));
}


Measured memory_bytes: 256
class PriorityQueue
  def initialize
    # 配列で二分木を実現する i 番目の要素の左の子供は 2i+1, 右の子供は 2i+2
    # 親の要素は，子供のどちらより優先度が高いとする
    @array = []
    @size = 0
  end

  def push(a)
    # 最後に仮おきした後，優先度が先祖より高ければ引き上げる
    @array[@size] = a
    heapify_up(@size)
    @size += 1
  end

  def pop()
    # 根の要素 (優先度最大) を取り出した後，最後の要素を根に仮置きし，調整
    raise unless @size > 0
    ans = @array[0]
    @size -= 1
    @array[0] = @array[@size]
    heapify_down(0)
    ans
  end

  def size
    @size
  end

  def empty?
    @size == 0
  end

  def swap(p, q)
    @array[p], @array[q] = @array[q], @array[p]
  end

  def equal_or_better(p, q)
    (@array[p] <=> @array[q]) <= 0
  end

  def heapify_up(n)
    while n > 0
      parent = (n - 1) / 2
      break if equal_or_better(parent, n)
      swap(parent, n)
      n = parent
    end
  end

  def heapify_down(n)
    while true
      l, r = n * 2 + 1, n * 2 + 2
      break if @size <= l
      child = l
      child = r if r < @size && equal_or_better(r, l)
      break if equal_or_better(n, child)
      swap(child, n)
      n = child
    end
  end
end

MAX_V = 50 # 制約の最大値。
MAX_S = MAX_V * 50 + 5
INF   = Float::INFINITY

#　頂点
Edge = Struct.new(:to, :a, :b)
#　両替所
Exchange = Struct.new(:v, :s, :x) do
  include Comparable
  def <=>(other)
    self.x <=> other.x
  end
end

g    = Array.new(MAX_V) { Array.new { Edge.new } }
dist = Array.new(MAX_V) { Array.new(MAX_S + 5) { INF } }

def input
  gets.split.map &:to_i;
end

# メイン
n, m, s = input
#　都市の入力
m.times do
  u, v, a, b = input
  u          = u.pred
  v          = v.pred
  g[u] << Edge.new(v, a, b)
  g[v] << Edge.new(u, a, b)
end

# 銀貨は最大でもMAX_S
s = [s, MAX_S].min
# プライオリティーキュー
q =PriorityQueue.new
# 入力用ラムダ
push = lambda { |v, s, x|
  return if s < 0
  return if dist[v][s] <= x

  dist[v][s] = x
  q.push(Exchange.new(v, s, x))
}

c = []
d = []
n.times do |i|
  cc, dd = input
  c[i]   = cc
  d[i]   = dd
end
push.call(0, s, 0)
until q.empty?
  hoge = q.pop
  v    = hoge.v; s = hoge.s; x = hoge.x
  next if dist[v][s] != x

  ns = [s + c[v], MAX_S].min
  push.call(v, ns, x + d[v])

  g[v].each do |e|
    push.call(e.to, s - e.a, x + e.b)
  end
end


(1 ... n).each do |i|
  ans = INF
  (0 ... (MAX_S + 5)).each do |j|
    ans = [ans, dist[i][j]].min
  end
  puts ans
end


Measured memory_bytes: 20772
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  string S;
  cin >> S;
  int price = 700;
  LOOP(i,3){
    if(S[i]=='o'){
      price += 100;
    }
  }
  cout << price << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl_int(): return list(map(int, input().split()))
def inpl_str(): return list(map(int, input().split()))

a,b,c = inpl_int()
print(a+b+c-max(a,b,c))



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

int N;
long long K;
vector<long long> A;
vector<int> bitAs(40,0);
vector<int> bitK(40);
vector<int> bit1;
long long ans=0;

int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++){
		long long a;
		cin >> a;
		A.push_back(a);
	}
	
	K++;
	for(int i=39;i>=0;i--){
		bitK[i]=K%2;
		if(K%2==1)bit1.push_back(i);
		K/=2;
	}
	
	for(int i=0;i<N;i++){
		long long a=A[i];
		for(int j=39;a>0;j--){
			bitAs[j]+=a%2;
			a/=2;
		}
	}
	
	for(auto b:bit1){
		long long tmp=0;
		for(int i=0;i<b;i++){
			if(bitK[i]==0)tmp+=(1LL<<(39-i))*bitAs[i];
			else tmp+=(1LL<<(39-i))*(N-bitAs[i]);
		}
		tmp+=(1LL<<(39-b))*bitAs[b];
		
		for(int i=b+1;i<40;i++){
			tmp+=(1LL<<(39-i))*max(bitAs[i],N-bitAs[i]);
		}
		ans=max(ans,tmp);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;


int main(){
    string s; cin >> s;
    int l = s.length();
    REP(i, l){
        if(!(i%2)) cout << s[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 512
n, k = map(int, input().split())
a = list(map(int, input().split()))

cur = 0
count = 0
v_set = set()
v_list = []

while cur not in v_set:
    v_set.add(cur)
    v_list.append(cur)

    cur = a[cur] - 1
    count += 1

l_start = v_list.index(cur)
l_end = len(v_list)

if k < l_start:
    print(v_list[k] + 1)
else:
    print(v_list[l_start + (k - l_start) % (l_end - l_start)] + 1)


Measured memory_bytes: 124232
#pragma GCC optimize ("-O3","unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<typeinfo>
#include<typeindex>
#include<type_traits>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; ++i)
#define rer(i,l,r) for(int i=l; i<=r; ++i)
#define gnr(i,l,r) for(int i=r; i>=l; --i)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
#define var(type) valarray<type>
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q,key;
string s,sb;
bool ok;

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

	cin>>n>>m; V(int)g[n];
	rep(i,m){
		cin>>x>>y; g[x-1].eb(y-1);
	}
	double ans=1e18;
	rep(j,n){
		double dp[n]={};
		gnr(i,0,n-2){
			if(g[i].size()==1)dp[i]=dp[g[i][0]]+1.0;
			else if(i==j){
				double ma=0; int id=g[i][0];
				for(int v:g[i])if(cmax(ma,dp[v]))id=v;
				ma=0;
				for(int v:g[i])if(v!=id)ma+=dp[v];
				dp[i]=ma/(g[i].size()-1.0)+1.0;
			}else{
				double ma=0;
				for(int v:g[i])ma+=dp[v];
				dp[i]=ma/g[i].size()+1.0;
			}
		}
		cmin(ans,dp[0]);
	}
	END
}

Measured memory_bytes: 1408
function Main(input) {
  input = input.trim()
  input = input.split("\n").map(Number);
  var N = input[5];
  input.pop();
  function compareFunc(a, b) {
  return a - b;
}
  input.sort(compareFunc);
  if(input[4]-input[0]<=N) console.log("Yay!");
  else console.log(":(")
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
s = list(input())
s1 = ''.join(s[:2])
s2 = ''.join(s[2:])
flag1 = False
flag2 = False
if 1 <= int(s1) and int(s1) <= 12:
  flag1 = True
if 1 <= int(s2) and int(s2) <= 12:
  flag2 = True
if flag1 and flag2:
  print('AMBIGUOUS')
elif flag1:
  print('MMYY')
elif flag2:
  print('YYMM')
else:
  print('NA')


Measured memory_bytes: 38256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int n,k,h[200001];
	long long s=0;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	sort(h,h+n);
	for(int i=0;i<n-k;i++){
		s+=h[i];
	}
	printf("%lld",s);
}

Measured memory_bytes: 896
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int Int_max = LLONG_MAX;
constexpr Int Int_min = LLONG_MIN;
using Container = vector<Int>;
using Grid = vector<vector<char>>; // [y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;


int main() {

	Int N; cin >> N;
	Container h(N + 2);
	rep(i, N)cin >> h[i];

	Container dp(N + 2, Int_max);
	dp[0] = 0;
	
	for (Int i = 0; i < N; ++i) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}

	cout << dp[N - 1] << endl;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long n,a[3][102];
int main()
{
	cin>>n;
	for(int i=1;i<=2;i++)
	  for(int j=1;j<=n;j++)
	    cin>>a[i][j];
	for(int i=1;i<=2;i++)
	    for(int j=1;j<=n;j++)
	      a[i][j]+=max(a[i-1][j],a[i][j-1]);
	cout<<a[2][n];
	return 0;
}

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

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	if(s[2] == s[3] && s[4] == s[5])
	    cout<<"Yes\n";
	else
	    cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
using namespace std;
using ll =long long;
int main() {
	string S;
	cin >> S;
	for (int i=0; i < S.size()-1; i++) {
		if (S[i] != S[i + 1]) {

			cout << "Yes";
			return 0;
		}


	}
	cout << "No";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n,m;cin>>n>>m;
	ll arr[n+5]={0};
	for(int i=0;i<m;i++){
		ll a,b;cin>>a>>b;
		arr[a]+=1;
		arr[b+1]-=1;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		arr[i]+=arr[i-1];
		if(arr[i]==m){ans++;}
	}
	cout<<ans<<endl;
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}

Measured memory_bytes: 4408
from sys import exit
s = input()
ts = ['']
while True:
  nts= []
  for t in ts:
    for w in ['dreamer', 'eraser', 'dream', 'erase']:
      tw = t + w
      if s == tw:
        print('YES')
        exit()
      if s.startswith(tw):
        nts.append(tw)
  if len(nts) == 0:
    print('NO')
    exit()
  ts = nts


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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;

//atcoder ABC 141

//a

int main()
{
	string a[3] = {"Sunny", "Cloudy", "Rainy"};

	string s;

	cin>>s;

	if(s==a[0])
		cout<<a[1]<<endl;
	else if(s==a[1])
		cout<<a[2]<<endl;
	else
		cout<<a[0]<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));    // lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

int main(void)
{
    int h, w;
    cin >> h >> w;
    int c[10][10];
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin >> c[i][j];
        }
    }

    for(int k=0; k<10; k++){
        for(int i=0; i<10; i++){
            for(int j=0; j<10; j++){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    vector<vector<int> >v(h, vector<int>(w));
    int sum = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int tmp;
            cin >> tmp;
            if(tmp == -1)continue;
            sum += c[tmp][1];
        }
    }

    // for(int i=0; i<10; i++){
    //     for(int j=0; j<10; j++){
    //         cout << c[i][j];
    //     }
    //     cout << endl;
    // }


    cout << sum << endl;

}

Measured memory_bytes: 384
//Sum of product of pairs 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18
int mod = 1000000007;

signed main (){
    nvarep(n,a);
    reverse(range(a));
    vector<int>t(n,0);
    rep(i,1,n){
        t[i]=a[i-1]+t[i-1];
    }
    int ans = 0;
    rep(i,1,n){
        ans=(ans+(t[i]%mod*a[i]%mod)%mod)%mod;
    }
    cout<<ans<<nnn;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc144_b() {
	ll N;
	string ans;

	cin >> N;

	ll d;
	ans = "No";
	rep1(i, min(9LL,N)) {
		if (N % i == 0 && N / i <= 9) {
			ans = "Yes";
			break;
		}
	}

	cout << ans << "\n";
}


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

	solve_abc144_b();

	return 0;
}


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

const int N=1000000007;

char str[100]="";

unsigned long long m(long long x,long long y)  //
{
	unsigned long long sum=1;
	while(y)
	{
		if(y%2==1)
		{
			sum*=x;
		}
		y/=2;
		x=x*x;
		x=x%N; 
		sum=sum%N;
	}
	
	return sum;
	
}

/*unsigned long long two(int x,int y) 
{
	unsigned long long z=x;
	itoa(y,str,2);
	for(int i=1;i<=strlen(str);i++)
	{
		if(str[i]=='0'){
		  z=z*z;
		  z=z%N;
		} 
		if(str[i]=='1'){
		  z=x*z*z;
		  z=z%N;
		}  
	}
	
	return z%N;
	
}*/ 

unsigned long long sub(int x,int y)
{
	unsigned long long total=1,i;
	for(i=0;i<=x-1;i++)
	{
		//total*=m(y-i,1);
		total=total*(y-i)%N; 
		total%=N; 
	}
	
	for(i=0;i<=x-1;i++)
	{
	   total*=m(x-i,1000000005);
	   total%=N;	
	}
	
	total%=N;
	
	return total;
	
}

int main()
{
	int n,a,b;
	
	cin>>n>>a>>b;
	
	unsigned long long s=m(2,n);
	
    s--;
    
    unsigned long long aa=sub(a,n);
    
    unsigned long long bb=sub(b,n);
    //cout<<s<<endl;
    //cout<<aa<<endl;
    //cout<<bb<<endl;
    if(s>=aa)
      s=s-aa;
    else{
	  s+=N;
	  s=s-aa;
    }
    s=s%N;
	
	if(s>=bb)
	  s=s-bb;
	else{
	  s+=N;
	  s=s-bb;
	}
	 
    
    s=s%N;
    
    cout<<s<<endl;
    
    return 0;
    
} 

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int kao[10][10000];
int sum=0;
int r,c;
void dfs(int p) {
	if(p==r) {
		int res=0;
		for(int j=0; j<c; j++) {
			int ans=0;
			for(int i=0; i<r; i++) {
				if(kao[i][j]==1) {
					ans++;
				}
			}
			res+=max(ans,r-ans);
		}
		sum=max(sum,res);
		return ;
	}
	dfs(p+1);
	for(int j=0; j<c; j++) {
		if(kao[p][j]==1) {
			
			kao[p][j]=0;
		} else {
		
			kao[p][j]=1;
		}
	}
	dfs(p+1);
	for(int j=0; j<c; j++) {
		if(kao[p][j]==1) {
		
			kao[p][j]=0;
		} else {
		
			kao[p][j]=1;
		}
	}
}



int main() {

	while(true) {
		scanf("%d %d",&r,&c);
		if(r==0&&c==0) break;
		sum=0;
		for(int i=0; i<r; i++)
			for(int j=0; j<c; j++) {
				scanf("%d",&kao[i][j]);

			}

		dfs(0);
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 3496
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::linked_list::LinkedList;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let n: usize = read_line().trim().parse().unwrap();

    let mut que = HashSet::new();
    let mut pos = vec![0; n];
    let mut matches = Vec::with_capacity(n);
    for i in 0..n {
        let a: Vec<usize> = read_line().split_whitespace().map(|s| s.parse::<usize>().unwrap() - 1).collect();
        que.insert(i);
        matches.push(a);
    }

    let mut ans = 0;
    loop {
        let mut used = vec![false; n];
        let mut next = HashSet::new();
        for &i in que.iter() {
            if pos[i] >= n - 1 {
                continue;
            }
            let opp = matches[i][pos[i]];
            if pos[opp] >= n - 1 {
                continue;
            }
            if matches[opp][pos[opp]] == i {
                next.insert(i);
                next.insert(opp);
                if used[i] || used[opp] {
                    continue;
                }
                pos[i] += 1;
                pos[opp] += 1;
                used[i] = true;
                used[opp] = true;
            }
        }
        if next.is_empty() {
            break;
        }
        que.clear();
        que = next;
        ans += 1;
    }

    if pos.iter().find(|p| **p < n - 1).is_none() {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}


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

constexpr int MAX_N = 100;

int main() {
  int N;
  int W[MAX_N];
  cin >> N;
  int total{};
  for (int i{}; i < N; ++i) {
    cin >> W[i];
    total += W[i];
  }

  int ans{total - W[0] * 2};

  for (int i{1}; i < N; ++i) {
    int temp{ans - W[i] * 2};
    if (abs(ans) < abs(temp)) break;
    ans = temp;
  }

  cout << abs(ans) << endl;
  return 0;
}


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

int main() {
    ll n;
    cin >> n;
    vector<ll> num(100005);
    ll sum = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        sum += a;
        num[a]++;
    }
    ll q;
    cin >> q;
    vector<ll> ans(q);
    rep(i, q) {
        ll b, c;
        cin >> b >> c;
        sum += (c - b) * num[b];
        ans[i] = sum;
        num[c] += num[b];
        num[b] = 0;
    }
    rep(i, q) cout << ans[i] << endl;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef pair<int,int> P;

int main(){
	int N,M;
	cin >> N >> M;
	vector<vector<P>> edge(N+1);
	vector<int> check(N+1);
	rep(i,M){
		int x,y;
		cin >> x >> y;
		check[y]++;
		edge[x].push_back(make_pair(x,y));
	}

	queue<int> que;
	for(int i=1; i<=N; i++){ if(check[i]==0) { que.push(i); check[i]--; } }

	vector<P> sorted;
	while( !que.empty() ){
		int node = que.front(); que.pop();
		for(int i=0; i<(int)edge[node].size(); i++){
			check[edge[node][i].second]--;
			if(check[edge[node][i].second] == 0){ 
				que.push(edge[node][i].second); 
				check[edge[node][i].second]--;
			}
			sorted.push_back(edge[node][i]);
		}
	}

	vector<int> path(N+1);
	for(P p : sorted){
		path[p.second] = max(path[p.second], path[p.first]+1);
	}
	cout << *max_element(path.begin(),path.end()) << endl;
	return 0;
}



Measured memory_bytes: 10412
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int sum = 0;
		int x[] = new int[M];
		for(int i = 0;i<M;i++){
			x[i] =sc.nextInt();
			sum+=x[i];
		}
		if(N<sum)
			System.out.println("-1");
		else
		System.out.println(N-sum);
			
	}

}


Measured memory_bytes: 46068
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        d: [usize;n],
    }

    let mut d_tmp: Vec<usize> = Vec::new();
    for i in d {
        d_tmp.push(i);
    }

    d_tmp.sort();
    let mut cnt = 0;
    let mut p = 0;
    let mut q = 0;
    for i in d_tmp {
        cnt += 1;
        if cnt == n /2 {
            p = i;
        } else if cnt == n /2 + 1 {
            q = i;
            break;
        }
    }

    let ans = q - p;
    println!("{}", ans);
}

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

int N;

int solve(int x,int y,int in,long long s[]){
    int left=x; int right=y;
    while(right-left>1){
        int mid=(left+right)/2;
        if(s[in]-s[mid]<=s[mid]){
            right=mid;
        }else{
            left=mid;
        }
    }
    return left;
}

int solve2(int x,int y,int in,long long s[]){
    int left=x; int right=y;
    while(right-left>1){
        int mid=(left+right)/2;
        if(s[N]-s[mid]<=s[mid]-s[in]){
            right=mid;
        }else{
            left=mid;
        }
    }
    return left;
}

int main(){
    cin >> N;
    long long a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    long long s[N+1]={};
    for(int i=1;i<=N;i++){
        s[i]+=s[i-1]+a[i-1];
    }
    long long ans=1e18;
    for(int i=0;i<=N;i++){
        int ind1=solve(0,i,i,s);
        int ind2=solve2(i,N,i,s);
        //cout << ind1 << " " << ind2 << endl;
        long long p1=s[ind1];
        long long p2=s[ind1+1];
        long long q1=s[i]-s[ind1];
        long long q2=s[i]-s[ind1+1];
        long long lmin=min(p1,q1); long long lmax=max(p1,q1);
        if(abs(p1-q1)>abs(p2-q2)) lmin=min(p2,q2),lmax=max(p2,q2);
        long long r1=s[ind2]-s[i];
        long long s1=s[N]-s[ind2];
        long long r2=s[ind2+1]-s[i];
        long long s2=s[N]-s[ind2+1];
        long long rmin=min(r1,s1); long long rmax=max(r1,s1);
        if(abs(s1-r1)>abs(s2-r2)) rmin=min(s2,r2),rmax=max(r2,s2);
        long long tmp=max(rmax,lmax)-min(lmin,rmin);
        ans=min(tmp,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int n,k;
    string s;
    cin >> n >> k;
    k*=2;
    cin >> s;
    int b=0;
    rep(i,s.size()-1){
        if (s.at(i)!=s.at(i+1)) b++;
    }
    if (k<=b) cout << n-b+k-1 << endl;
    else cout << n-1 << endl;
}

Measured memory_bytes: 512
from bisect import bisect_left


def solve(string):
    a, b, q, *stx = map(int, string.split())
    s = [-10**10] + stx[:a] + [2 * 10**10]
    t = [-10**10] + stx[a:a + b] + [2 * 10**10]
    x = dict([])
    ans = []
    i_s = 0
    i_t = 0
    # for _x in stx[-q:]:
    for _x in sorted(stx[-q:]):
        # """
        while s[i_s] < _x:
            i_s += 1
        while t[i_t] < _x:
            i_t += 1
        # """
        # i_s, i_t = bisect_left(s, _x), bisect_left(t, _x)
        ls, rs = _x - s[i_s - 1], s[i_s] - _x
        lt, rt = _x - t[i_t - 1], t[i_t] - _x
        r_max = rs if rs > rt else rt
        l_max = ls if ls > lt else lt
        # ans.append(
        x[_x] = str(
            min(r_max, l_max, rt + ls + (rt if rt < ls else ls),
                rs + lt + (rs if rs < lt else lt)))
    return "\n".join([x[_x] for _x in stx[-q:]])
    # return "\n".join(ans)


if __name__ == '__main__':
    n, m, l = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, l) + '\n'.join([input() for _ in range(n + m + l)])))


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

#define rep(i,n) for(int (i)=0; (i)<(int)(n); (i)++)
#define frep(i,m,n) for(int (i)=(m); (i)<(int)(n); (i)++)
#define rrep(i,n) for(int (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(int (i)=(n)-1; (i)>(int)(m)-1; (i)--)
#define all(x) (x).begin(), (x).end()
#define sqr(x) (x)*(x)
#define CEIL(a,b) ((a)+(b)-1) /(b)

typedef long long ll;
const int INF = 1001001001;
const int MOD = 1000000007;

// A:array of pair, N:size of array
void sort_second(vector<pair<ll, ll>> &A, int N);
// a^n
ll a_n(ll a, ll n);
// make vector of (n!)%MOD, (n!)^(-1)%MOD to calculate nCk
void nCk(vector<ll> &n, vector<ll> &ninv);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    int n, ans = 0;
    string s;
    cin >> n >> s;
    rep(i, n-2) {
        if(!s.compare(i, 3, "ABC")) ans++;
    }
    cout << ans << endl;
    return 0;
}

void sort_second(vector<pair<ll, ll>> &A, int N) {
    rep(i, N) swap(A.at(i).first, A.at(i).second);
    sort(all(A));
    rep(i, N) swap(A.at(i).first, A.at(i).second);
}
ll a_n(ll a, ll n) { 
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD ;
}

/* calculate a^n with no recursive process (%MOD)
ll a_n(ll a, ll n) { 
    ll ret = a, count = 1;
    int num = 1;
    vector<ll> memory(100);
    memory.at(0) = a;

    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
        memory.at(num) = ret;
        num++;
    }
    if(count == n) return ret;
    else {
        bitset<100> bit = bitset<100>(n-count);
        rep(i, 100) {
            if(bit.test(i)) ret = (ret * memory.at(i)) % MOD;
        }
        return ret;
    }    
}
*/

void nCk(vector<ll> &n, vector<ll> &ninv) {
    n[0] = 1;
    for(int i = 1; i < n.size(); i++) n[i] = (n[i-1] * i) % MOD;
    ninv[n.size()-1] = inv(n[n.size()-1]);
    for(int i = n.size() - 2; i > -1; i--) ninv[i] = (ninv[i+1] * (i+1)) % MOD;
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back

int MOD = 998244353;
int fact[222'222];
int power(int a, int n)
{
    int res = 1;
    int now = a;
    while(n)
    {
        if (n&1)
        {
            res  = (res*now) %MOD;
        }
        n>>=1;
        now = (now*now)%MOD;
    }
    return res;
}
int inv(int a)
{
    return power(a, MOD-2);
}
int C(int n, int r)
{
    if (n < r) return 0;
    return fact[n] %MOD * inv(fact[n-r])%MOD * inv(fact[r])%MOD;
}
int n, m, k;
int f(int p)
{
    return m * power(m-1, n-1-p)%MOD*C(n-1,p)%MOD;
}
void solve()
{
    fact[0] = 1;
    forn(i, 222'222-1) fact[i+1] = fact[i] * (i+1)%MOD;
    cin>>n>>m>>k;
    int ans = 0;
    forn(i, k+1)
    {
        ans =(ans + f(i))%MOD;
    }
    cout << ans <<'\n';
}


signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    //cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 5348
#include<iostream>
using namespace std;
int main()
{
	long long int m,n,x;
	long long int sum1=0;
	cin>>x>>m>>n;
	if((x>1&&n>=m)||(x==1&&m==n))
	{
		cout<<(x-2)*(n-m)+1<<endl;
	}
	else
	cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)

def main():
    N, *A = map(int, open(0))

    E = [[] for _ in range(N + 1)]
    for i, v in enumerate(A, 1):
        E[v - 1].append(i)

    def dfs(v):
        D = sorted(map(dfs, E[v]))
        return max([0] + [len(D) - i + d for i, d in enumerate(D)])

    print(dfs(0))


main()


Measured memory_bytes: 204516
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

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


int main(){
  ll x,ans=0,n=100;
  cin>>x;
  
  while(n<x){
    n*=1.01;
    ans++;
  }
  
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

int GetDigit(int num) {
	return log10(num) + 1;
}

int main() {
	cin >> s;
	vector<ll> cnt(s.size());
	vector<ll> R(s.size());
	vector<ll> L(s.size());
	rep(i, s.size()) {
		cnt[i] = 0;
	}
	ll j;
	j = 0;
	rep (i, s.size()-1) {
		if (s[i] == 'R' && s[i + 1] == 'L') {
			cnt[i]++;
			cnt[i + 1]++;
			R[j] = i;
			L[j] = i + 1;
			j++;
		}
	}
	R.resize(j + 1);
	L.resize(j + 1);
	j = 0;
	rep(i, s.size() - 1) {
		if (s[i] == 'R' && s[i + 1] == 'R') {
			if ((R[j] - i) % 2 == 1) {
				cnt[R[j] + 1]++;
			}
			else {
				cnt[R[j]]++;
			}
		}
		else if (s[i] == 'R' && s[i + 1] == 'L') {
			j++;
		}
	}
	j--;
	for (ll i = s.size() - 1; i > 0; i--) {
		if (s[i] == 'L' && s[i - 1] == 'L') {
			if (abs(L[j] - i) % 2 == 1) {
				cnt[L[j]-1]++;
			}
			else {
				cnt[L[j]]++;
			}
		}
		else if (s[i] == 'L' && s[i - 1] == 'R') {
			j--;
		}
	}
	rep(i, s.size()) {
		if (i == s.size() - 1) {
			cout << cnt[i] << endl;
			return 0;
		}
		cout << cnt[i] << " ";
	}
	
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Vec  =vector<int>;

int		main(void)
{
	int s, w;
	cin >> s >> w;
	if (s > w)
		cout << "safe" << endl;
	else
		cout << "unsafe" << endl;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
public class Lesson06
{
    public static void Main()
    {
        string num  = Console.ReadLine();
        
        string[] nums = num.Split(' ');
        
        int A = int.Parse(nums[0]);
        int B = int.Parse(nums[1]);
        int C = int.Parse(nums[2]);
        
        if(A<=C && C<=B){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
        
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
#define cd complex<long double>
typedef  long long  ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;
const ld pi=acos(-1);



void fft(vector<cd> & a ,bool invert){
    auto r = [&](int n, int log){int res=0;for(int i=0; i<log; i++){if((n>>i)&1)res|=1<<(log-1-i);} return res;};
    int n=(int)a.size();
    int log=0;
    while((1<<log)<n)
        log++;
    for(int i=0; i<n; i++){
        if(i<r(i,log))
            swap(a[i],a[r(i,log)]);
    }
    
    for(int len=2; len<=n; len<<=1){
        ld ang=2*pi/len*(invert?-1:1);
        cd w, wn(cos(ang),sin(ang));
        for(int j=0; j<n; j+=len){
            w=1;
            for(int k=0; k<len/2; k++){
                cd u=a[j+k], v=w*a[j+k+(len>>1)];
                a[j+k]=u+v;
                a[j+k+(len>>1)]=u-v;
                w*=wn;
            }
        }
    }
    if(invert){
        for(cd & c: a){
            c/=n;
        }
    }
}

vll mult(vi & a, vi & b){
    int n=1;
    while(n<a.size()+b.size()){
        n<<=1;
    }
    vector<cd> aa(a.begin(),a.end()), bb(b.begin(),b.end());
    aa.resize(n);bb.resize(n);
    fft(aa,false);
    fft(bb,false);
    for(int i=0; i<n; i++){
        aa[i]*=bb[i];
    }
    fft(aa,true);
    n=int(a.size()+b.size()-1);
    vll ans(n);
    for(int i=0; i<n; i++){
        ans[i]=round(aa[i].real());
    }
    return ans;
}





int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,a,b,c,d,y,l,z;
    cin >> n >> m;
    vi v(1e5+1),vv;
    for(int i=0 ;i<n ;i++){
        cin >> a;
        v[a]++;
    }
    vv=v;
    vll ans;
    ans=mult(v,v);
    a=0;
    b=0;
    for(ll i=ans.size()-1; i>=0; i--){
        a=ans[i];
        if(a>=m){
            b+=i*m;
            m=0;
            break;
        }
        else{
            m-=a;
            b+=i*a;
        }
    }
    cout << b << el;
    return 0;
}



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

using namespace std;

long long gcd(long long x, long long y)
{
    long long r;

    if (x == 0 || y == 0)
    {
        return 0;
    }

    while ((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

long long lcm(long long x, long long y)
{
    if (x == 0 || y == 0)
    {
        return 0;
    }

    return (x * y / gcd(x, y));
}

int main()
{
    long long n, m;
    string s, t;

    cin >> n >> m;
    cin >> s;
    cin >> t;
    long long l = lcm(n, m);
    vector<long long> ss(n);
    vector<long long> tt(m);
    for (long long i = 0; i < n; i++)
    {
        ss[i] = l / n * i;
    }
    for (long long i = 0; i < m; i++)
    {
        tt[i] = l / m * i;
    }
    vector<long long> intersection;
    set_intersection(ss.begin(), ss.end(), tt.begin(), tt.end(), inserter(intersection, intersection.end()));
    for (long long i = 0; i < intersection.size(); i++)
    {
        long long item = intersection[i];
        std::vector<long long>::iterator s_it = find(ss.begin(), ss.end(), item);
        long long s_idx = distance(ss.begin(), s_it);
        std::vector<long long>::iterator t_it = find(tt.begin(), tt.end(), item);
        long long t_idx = distance(tt.begin(), t_it);
        if (s[s_idx] != t[t_idx])
        {
            l = -1;
            break;
        }
    }
    cout << l << endl;
}

Measured memory_bytes: 2112
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(i) for i in input().split()] + [0]

count = 0
tmp = 1
for i in range(1, N+1):
    if A[i] == A[i - 1]:
        tmp += 1
    else:
        # 等しくなくなったら
        count += tmp // 2
        tmp = 1  # tmp のリセット

print(count)


Measured memory_bytes: 3060
import sys
from collections import defaultdict

cnt = defaultdict(int)

def main():
    n, *a = map(int, sys.stdin.read().split())

    for val in a:
        cnt[val] += 1
    
    ans = 0
    for i in range(1, 10**5):
        ans = max(ans, cnt[i-1] + cnt[i] + cnt[i+1])

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 20116
n = int(input())
aa = list(map(int, input().split()))

if n % 3 != 0:
    if all(map(lambda x: x == 0, aa)):
        print('Yes')
    else:
        print('No')
else:
    m = n // 3

    cnt_map = {}
    for a in aa:
        if a not in cnt_map:
            cnt_map[a] = 0
        cnt_map[a] += 1

    if len(cnt_map.keys()) > 3:
        print('No')
    elif len(cnt_map.keys()) == 1:
        k = list(cnt_map.keys())[0]
        if k == 0:
            print('Yes')
        else:
            print('No')
    elif len(cnt_map.keys()) == 2:
        k1, k2 = cnt_map.keys()
        if k1 > k2:
            k1, k2 = k2, k1
        if k1 == 0 and cnt_map[k1] == m:
            print('Yes')
        else:
            print('No')
    elif len(cnt_map.keys()) == 3:
        a, b, c = cnt_map.keys()
        if a == b ^ c and cnt_map[a] == m and cnt_map[b] == m and cnt_map[c] == m:
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 14212
#include<iostream>
#include<cstring>
#include<cstdio>
#define oddc(x) ((x&1)?1:2)
using namespace std;
int main()
{
	int n,s=1;scanf("%d",&n);
	for(int i=1,x;i<=n;i++)
		scanf("%d",&x),s*=oddc(x);
	int ans=1;while(n--) ans*=3;
	printf("%d\n",ans-s);return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define w(e) int e ; cin >> e ; while (e--)  
#define ll long long 
#define endl "\n"
#define mod  10000000007
#define pi 3.1415926535897932384626433
#define setbit(x) __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)  
/*
*/
int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n , k ; cin >>  n >> k ;
    if (n<k)
    {
    	if (abs(n-k)<n)
    	{
    		cout << abs(n-k) <<endl;
    	}
    	else
    		cout << n << endl;
    }
    else if (n==k || n%k==0)
    {
    	cout << 0 << endl;
    }
    else if (n>k)
    {
    	cout << (((n/k)+1)*k) - n << endl;
    }
	return  0;
}

Measured memory_bytes: 3568