akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
#define N 200002
struct edge{int to,nxxt;}e[N];
int n,m,head[N],cnt=1,dep[N],siz[N],sx,sy,leh,fa[N],col[N];
int sz[N][2],b[N],tot;
inline void ins(int u,int v){e[cnt].to=v;e[cnt].nxxt=head[u];head[u]=cnt++;}
void df5(int te,int la)
{siz[te]=dep[te];
	for(int i=head[te];i;i=e[i].nxxt)
	{
		int j=e[i].to;if(j==la)continue;dep[j]=-dep[te];
		df5(j,te);siz[te]+=siz[j];
	}
}
void dfs(int te,int la)
{
	for(int i=head[te];i;i=e[i].nxxt)
	{
		int j=e[i].to;if(j==la)continue;
		if(dep[j]!=-1){sx=te,sy=j;continue;}
		dep[j]=dep[te]+1;fa[j]=te;col[j]=-col[te];dfs(j,te);
	}
}
void clfs(int te,int la)
{
	for(int i=head[te];i;i=e[i].nxxt)
	{
		int j=e[i].to;if(j==la||(sx==te&&sy==j)||(sx==j&&sy==te))continue;
		clfs(j,te);sz[te][0]+=sz[j][0],sz[te][1]+=sz[j][1];
	}
}
void clf5(int te,int la)
{siz[te]=col[te];
	for(int i=head[te];i;i=e[i].nxxt)
	{
		int j=e[i].to;if(j==la||(sx==te&&sy==j)||(sx==j&&sy==te))continue;
		clf5(j,te);siz[te]+=siz[j];
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	if(m==n-1)
	{
		for(int i=1;i<n;i++)
		{
			int x,y;scanf("%d%d",&x,&y);
			ins(x,y);ins(y,x);
		}
		dep[1]=1;df5(1,1);
		ll ans=0;for(int i=2;i<=n;i++)ans+=abs(siz[i]);
		if(siz[1])ans=-1;printf("%lld\n",ans);return 0;
	}
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		ins(x,y);ins(y,x);
	}memset(dep,-1,sizeof(dep));dep[1]=0;
	fa[1]=1;col[1]=1;dfs(1,1);
	int tx=sx,ty=sy;
	while(dep[tx]>dep[ty])tx=fa[tx],leh++;
	while(dep[ty]>dep[tx])ty=fa[ty],leh++;
	while(tx^ty)tx=fa[tx],ty=fa[ty],leh+=2;
	if(leh%2==0)
	{
		int wt=0,bl=0;
		for(int i=1;i<=n;i++)
		{
			if(dep[i]&1)wt++;else bl++;
		}
		if(abs(wt-bl)&1){puts("-1");return 0;}
		clf5(1,1);ll tv=siz[1]/2;
		col[sx]-=tv,col[sy]-=tv;
		ll ans=abs(tv);
		clf5(1,1);
		for(int i=2;i<=n;i++)ans+=abs(siz[i]);
		printf("%lld\n",ans);return 0;
	}
	for(int i=1;i<=n;i++)sz[i][1]=col[i];
	sz[sx][0]=1;sz[sy][0]=-1;clfs(1,1);
	if(sz[1][0]||sz[1][1]){puts("-1");return 0;}
	ll ans=0;b[++tot]=0;
	for(int i=1;i<=n;i++)
	{
		if(!sz[i][0])ans+=abs(sz[i][1]);
		else
		{
			if(sz[i][0]==1)b[++tot]=-sz[i][1];
			else b[++tot]=sz[i][1];
		}
	}
	sort(b+1,b+1+tot);ll xv=b[(tot+1)/2];
	for(int i=1;i<=n;i++)if(sz[i][0])ans+=abs(xv*sz[i][0]+sz[i][1]);
	printf("%lld\n",ans+abs(xv));
}


Measured memory_bytes: 16208
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;



int main(){
    int n;
    cin >> n;
    vector<int> c(n - 1), s(n - 1), f(n - 1);
    for (int i = 0; i < n - 1; i++){
        cin >> c[i] >> s[i] >> f[i];
    }

    int i;
    for (i = 0; i < n - 2; i++){
        int t = s[i] + c[i];
        for (int j = i + 1; j < n - 1; j++){
            int k = max(0, (t - s[j] + f[j] - 1) / f[j]);
            t = s[j] + k * f[j] + c[j];
        }
        cout << t << endl;
    }

    cout << s[i] + c[i] << "\n" << 0 << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int N = sc.NextInt();
        int K = sc.NextInt();
        int[] L = sc.IntArray();
        Array.Sort(L);
        int ans = 0;
        for (int i = 0; i < K; i++)
        {
            int j = N - i - 1;
            ans += L[j];
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
def PRIME(N):
    LIM = int(N**0.5)+2
    for i in range(2, LIM):
        if N%i == 0:
            return False
    return True

n = int(input())
p = []
ans = ""
for i in range(2, 55556):
    if i%5 == 1:
        if PRIME(i):
            p.append(i)

for j in range(n):
    ans += str(p[j])+" "

print(ans)


Measured memory_bytes: 3060
// by DEADFISH
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define p 1e6+7
#define N 10010
#define mc(a,b) memset(a,b,sizeof(a))
#define close std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ln;
string s; 
int main()
{
	cin>>s;
	int len=s.length();
	bool flag=false;
	for(int i=0;i<len;i++)
	{
		if(s[i]=='C') for(int j=i;j<=len;j++)
		{
			if(s[j]=='F') flag=1;
		}
	}
	if(flag) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

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


	int N, K;
	cin >> N >> K;

	ll kosuu[100001] = {};
	for (int i = K; i >= 1; i--) {
		int k = K / i;
		ll tmp = modpow(k, N);
		for (int j = i + i; j <= K; j += i) {
			tmp -= kosuu[j];
		}
		kosuu[i] = (tmp % mod + mod) % mod;
	}
	ll kotae = 0;
	rep1(i, K) {
		kotae += kosuu[i] * i % mod;
	}
	co(kotae% mod);

	Would you please return 0;
}

Measured memory_bytes: 4436
// AC版.
// 解き直し.
// ABC 131解説.
// https://img.atcoder.jp/abc131/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
const int MAX_V = 1e5 + 1;
// const int MAX_V = 8;
using LL = long long;
int cX[MAX_V], cY[MAX_V];  // 各頂点X, Y ごとに, 連結成分番号を保存.
LL cVX[MAX_V], cVY[MAX_V]; // 各連結成分 の X, Y の 頂点数を保存.
vector<int> X[MAX_V], Y[MAX_V];

// 深さ優先探索(depth-first search).
// https://ja.wikipedia.org/wiki/深さ優先探索
// @param x: 探索開始の頂点X番号.
// @param l: 連結成分番号(※1以上).
// @return : 特に無し.
void dfs(int x, int l){

    // 1. 終了条件設定.
    // -> 連結成分番号が設定済みであれば, 終了.
    if(cX[x] > 0) return;
    
    // 2. 頂点 X について, 連結成分情報 を 設定.
    cX[x] = l, cVX[l]++;
    
    // 3. 頂点 X に, 隣接する 頂点 Y を 探索.
    for(auto &y : X[x]){
        
        if(cY[y] > 0) continue;
        // 3-1. 頂点 Y に, 連結成分 l を設定し, 連結成分のカウンターを +1 更新.
        cY[y] = l, cVY[l]++;
        
        // 3-2. 頂点 Y に, 隣接する 頂点 X を 探索(再帰処理).
        for(auto &nx : Y[y]){
            if(cX[nx] > 0) continue;
            dfs(nx, l);
        }
    }
}

int main() {

    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);

    // 以下, 解説通り.
    // 2. グラフ作成.
    for(int i = 0; i < N; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        // u -> v
        X[u].push_back(v);
        // v -> u
        Y[v].push_back(u);
    }
    
    // グラフ情報確認.
    // for(int i = 1; i < MAX_V; i++){
    //     if(X[i].size() > 0) for(auto &p : X[i]) printf("%d %d\n", i, p);
    // }
    
    // 3. 連結成分に分解.
    int c = 0;
    for(int i = 1; i < MAX_V; i++) if(X[i].size() > 0 && cX[i] == 0) c++, dfs(i, c);
    
    // グラフ連結情報確認.
    // for(int i = 1; i < MAX_V; i++){
    //     printf("cX[%d], cY[%d] = [%d, %d]\n", i, i, cX[i], cY[i]);
    //     printf("cVX[%d], cVY[%d] = [%lld, %lld]\n", i, i, cVX[i], cVY[i]);
    // }
    
    // 4. 後処理.
    // ※各連結成分 の X, Y の 頂点数(cVX, cVY) について, long long で 計算しないと, 
    // テストケース(09.txt, 10.txt, 11.txt, 15.txt) で, WA となるので要注意.
    LL ans = 0;
    for(int i = 1; i < MAX_V; i++) ans += cVX[i] * cVY[i];
    ans -= N; // 連結済 の 辺数 を 減算.
    printf("%lld\n", ans);
    return 0;

}

Measured memory_bytes: 12288
s=input().replace('BC','X')
i=0
count=0
while i<len(s):
    if s[i]=='A':
        p=i
        i+=1
        while i<len(s) and( s[i]=='A' or s[i]=='X'):
            if s[i]=='X':
                count+=i-p
                p+=1
            i+=1
    else:
        i+=1
print(count)

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

int main(){
  int h,w,K; cin >> h >> w >> K;
  vector<vector<char>> table(h,vector<char>(w));
  vector<vector<int>> ans(h,vector<int>(w));
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){ cin >> table[i][j];}
  }
  //以上入力
  
  int num = 0;
  int upper = 0; //上端
  int lower = -1;
  
  while( upper < h && lower+1 < h){ 
    //上からi段目まで確定した
    upper = lower+1;
    
    bool flag = false;

    lower = upper;
    
    while( lower < h){
      
      vector<int> vec;
      
     for(int j = 0; j < w; j++){ 
      if( table[lower][j] == '#'){ 
        
        vec.push_back(j); flag = true; 
       }
     }
    
     int sz = (int)vec.size();
    
     if(!flag){ //この行にはいちごがなかった→そのまま続きの行まで
       lower++;
     }
     else{
      
      if( num+sz == K){ lower = h-1; }
      
       
      
      int right = -1;
      int left = 0;
      
      
      
      //upperとlowerが定まった条件のもとで,切断して行く
      for(int i = 0; i < sz; i++){
         left = right+1;
         right = vec[i];
        if( i == sz-1){ right = w-1;}
        
        for(int s = upper; s <= lower; s++){
          for(int t = left; t <= right; t++){ 
            ans[s][t] = num;
          }
        }
        num++;
                                   }
       
       break;
       
        }//elseとじ
    
    
    } // lower_whileとじ
    
  } // upper_whileとじ
  
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){ 
      cout << ans[i][j]+1 << " ";
    }
    cout << endl;
  }
  
  
  return 0;
}

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

int main() {
    int x; cin >> x;
    int ans = 0;
    for (int i = 1; i <= 1000; i++) {
        if (100*i <= x && x <= 100*i+5*i) {
            ans = 1;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  int k;
  cin >> k;
  ll ans = 0;
  FOR(i, 1, k + 1) FOR(j, 1, k + 1) FOR(l, 1, k + 1) {
    ans += gcd(i, gcd(j, l));
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define all(c) (c).begin(), (c).end()
#define index_of(c, x) find(all(c), x) - (c).begin()

int solve(int n, const vector<int>& d) {
    vector<char> ex(1000, 0);
    rep(i, n) {
        int x = 0;
        rep(j, 3) {
            if (i + j >= n) break;
            x = x * 10 + d[i + j];
            ex[x] = 1;
        }
    }
    return index_of(ex, 0);
}

int main() {
    int n; cin >> n;
    vector<int> d(n);
    for (int& e : d) cin >> e;
    cout << solve(n, d) << endl;
}

Measured memory_bytes: 3096
x = []
y = []
while True:
    try:
        a, b, p, c, d, q = map(int, input().split())
        x.append((d*p-b*q)/(a*d-b*c))
        y.append((a*q-c*p)/(a*d-b*c))
    except EOFError:
        break

for i in range(len(x)):
    print("{:.3f} {:.3f}".format(x[i]+0, y[i]+0))

Measured memory_bytes: 7628
#include <bits/stdc++.h>
#define int long long
using namespace std;
int INF = 1e18;
int dp[2001][2001], lft[4000][2001];
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i=0; i <= n; i++) for (int j=0; j <= n; j++) dp[i][j] = INF;
    vector<pair<int, int> > v;
    for (int i=0; i < 2*n; i++){
        char ch;
        int wh;
        cin >> ch >> wh;
        if (ch == 'W') v.push_back(make_pair(0, wh-1));
        else v.push_back(make_pair(1, wh-1));
    }
    for (int i=0; i < 2*n; i++) for (int j=0; j <= n; j++) lft[i][j] = 0;
    vector<int> ba(n), bb(n);
    fill(ba.begin(), ba.end(), 0);
    fill(bb.begin(), bb.end(), 0);
    int wind[n], lind[n];
    for (int i=0; i < 2*n; i++){
        if (v[i].first == 0) wind[v[i].second] = i;
        else lind[v[i].second] = i;
    }
    for (int i=0; i < 2*n; i++){
        int e=0, f=0;
        for (int j=0; j <= i; j++){
            if (v[j].first) f++;
            else e++;
        }
        for (int j=i+1; j < 2*n; j++){
            if (v[j].first) f++;
            else e++;
            if (v[j].first == v[i].first){
                if (v[i].second > v[j].second){
                    if (v[i].first) bb[f-1]++;
                    else ba[e-1]++;
                }
                continue;
            }
            lft[j][v[i].second+1]++;
        }
    }
    for (int i=0; i < 2*n; i++) for (int j=1; j <= n; j++) lft[i][j] += lft[i][j-1];
    dp[n][n] = 0;
    int cur = 0;
    for (int i=n-1; i >= 0; i--){
        cur += ba[i];
        dp[i][n] = cur;
    }
    cur = 0;
    for (int i=n-1; i >= 0; i--){
        cur += bb[i];
        dp[n][i] = cur;
    }
    for (int i=n-1; i >= 0; i--){
        for (int j=n-1; j >= 0; j--){
            int a = wind[i], b = lind[j];
            dp[i][j] = min(dp[i][j], dp[i+1][j] + lft[a][n] - lft[a][j] + ba[i]);
            dp[i][j] = min(dp[i][j], dp[i][j+1] + lft[b][n] - lft[b][i] + bb[j]);
        }
    }
    //for (int i=n; i >= 0; i--) for (int j=n; j >= 0; j--) cout << i << " " << j << " " << dp[i][j] << endl;
    cout << dp[0][0];
}


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

const int INF = 1e9;

int main() {
  int n;
  cin>>n;
  long a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a, a+n);
  long long ans=0;
  long left=a[0];
  long right=a[0];
  int first=1;
  int last=n-1;
  while(first<=last){
    long v1=abs(left-a[first]);
    long v2=abs(left-a[last]);
    long v3=abs(right-a[first]);
    long v4=abs(right-a[last]);
    if(v1>=v2&&v1>=v3&&v1>=v4){
      ans+=v1;
      left=a[first];
      ++first;
    }else if(v2>=v3&&v2>=v4){
      ans+=v2;
      left=a[last];
      --last;
    }else if(v3>=v4){
      ans+=v3;
      right=a[first];
      ++first;
    }else{
      ans+=v4;
      right=a[last];
      --last;
    }
  }
  cout<<ans<<endl;

}

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

int main() {
    string s;
    string ss = "ATGC";
    cin >> s;
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        bool f = 0;
        for (int j = 0; j < 4; j++) {
            if (s[i] == ss[j]) {
                f = 1;
            }
        }
        if (f) cnt++;
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << max(cnt, ans) << endl;
    return 0;
}

Measured memory_bytes: 256
def is_reachable(axis,goal):
    res=sum(axis)-goal
    if(res%2==1 or res <0):
        return False
    res//=2
    tmp=1
    for x in axis:
        tmp|=tmp << x
    if( tmp & (1 << res)):
        return True
    else:
        return False


s=input()
x,y=map(int,input().split())
x_axis=[]
y_axis=[]

i=0
while(s[i]=="F"):
    x-=1
    i+=1
    if(i>=len(s)):
        break

flag=True
tmp_count=0

for j in range(i+1,len(s)):
    if(s[j]=="F"):
        tmp_count+=1
    else:
        if(flag):
            y_axis.append(tmp_count)
        else:
            x_axis.append(tmp_count)
        tmp_count=0
        flag= not flag
    
if(tmp_count!=0):
    if(flag):
        y_axis.append(tmp_count)
    else:
        x_axis.append(tmp_count)

if( is_reachable(x_axis,x) and is_reachable(y_axis,y)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const ll maxn = 1e5 + 500;
ll a[maxn][3],dp[maxn][3];
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	for(int i = 1;i <= n; ++i)
	{
		scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
	}
	dp[1][0] = a[1][0];
	dp[1][1] = a[1][1];
	dp[1][2] = a[1][2];
	for(int i = 2;i <= n; ++i)
	{
		dp[i][0] = max(dp[i - 1][1],dp[i - 1][2]) + a[i][0];
		dp[i][1] = max(dp[i - 1][0],dp[i - 1][2]) + a[i][1];
		dp[i][2] = max(dp[i - 1][0],dp[i - 1][1]) + a[i][2];
	}
	printf("%d\n",max(max(dp[n][0],dp[n][1]),dp[n][2]));
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

#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(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, k;
vector<int> t;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k;
  int a = 1;
  t.push_back(a);
  while(k >= a) {
    a *= 2;
    t.push_back(a);
  }

  double p = 0.0;
  FOR(i, 1, n + 1) {
    REP(j, t.size()) {
      if(i * t[j] >= k) {
        double b = n * t[j];
        p += 1 / b;
        break;
      }
    }
  }

  cout << fixed << setprecision(9) << p << endl;
}


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000

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

ll mp[5];

int main()
{	
	int n;cin >> n;
	REP(i,n)
	{
		string str;cin >> str;
		if(str[0] == 'M')mp[0]++;
		else if(str[0] == 'A')mp[1]++;
		else if(str[0] == 'R')mp[2]++;
		else if(str[0] == 'C')mp[3]++;
		else if(str[0] == 'H')mp[4]++;
	}
	
	vector<int> v{0,0,1,1,1};
	ll ans = 0;
	do
	{
		ll tmp = 1;
		REP(i,5)
		{
			if(v[i] == 1)tmp *= mp[i];
		}
		ans += tmp;
	}while(next_permutation(ALL(v)));
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long
using namespace std;


int main(){
   
   int a,b,c,d;cin>>a>>b>>c>>d;
if(abs(a-c) <= d or (abs(a-b) <=d and abs(b-c)<=d)) cout<<"Yes"<<endl;
else cout<<"No"<<endl;


    
    return 0;
}

 



Measured memory_bytes: 256
# def merge(A, left, mid, right):
#     L = A[left:mid] + [1000000]
#     R = A[mid:right] + [1000000]
#     # L.append(1000000)
#     # R.append(1000000)

#     i = 0
#     j = 0
#     global count
    
#     for k in range(left, right):
#         count += 1
#         if L[i] <= R[j]:
#             A[k] = L[i]
#             i += 1
#         else:
#             A[k] = R[j]
#             j += 1

def merge(A, left, mid, right):
    global count
    inf = 10 ** 9
    L = A[left:mid] + [inf]
    R = A[mid:right] + [inf]
 
    i = 0
    j = 0
    for k in range(left, right):
        count += 1
        # print(L)
        # print(R)
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
A = list(map(int, input().split()))
count = 0
mergeSort(A, 0, n)

print(' '.join(list(map(str, A))))
print(count)


Measured memory_bytes: 66580
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
struct edge{
  int from,to;
  edge(){}
  edge(int from,int to):from(from),to(to){}
};

  
const int MAX = 333;
using BS=bitset<MAX>;
vector<BS> G(MAX);
vector<vector<int> > rG(MAX);
vector<int> vis(MAX);

void dfs(int v,int r){
  if(vis[v]) return;
  vis[v]=1;
  G[v]|=G[r];
  for(int u:rG[v]) if(!vis[u]) dfs(u,r);
}; 

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  auto D=G;
  map<string, int> R;
  int sz=0;

  {
    string p,q;
    cin>>p>>q;
    R[p]=sz++;
    R[q]=sz++;
  }
  
  int n;
  cin>>n;
  vector<vector<edge> > sG(n);
  vector<map<int,set<int> > > M(MAX);
  
  for(int i=0;i<n;i++){
    int m;
    cin>>m;
    for(int j=0;j<m;j++){
      string s,t;
      cin>>s>>t;
      if(!R.count(s)) R[s]=sz++;
      if(!R.count(t)) R[t]=sz++;
      sG[i].emplace_back(R[s],R[t]);
      M[R[s]][R[t]].insert(i);
    }
  }

  vector<int> used(n, 0);
  queue<edge> q;

  auto WF=[sz](){
    for(int k=0;k<sz;k++)
      for(int i=0;i<sz;i++)
	for(int j=0;j<sz;j++)
	  G[i][j]=G[i][j]||(G[i][k]&&G[k][j]);
  };
  
  for(int i=0;i<sz;i++) G[i][i]=1;
  auto add_edge=[&](int from, int to){
    rG[to].push_back(from);
    fill(vis.begin(),vis.end(),0);
    dfs(to,to);
  };
  auto add=[&](int x){
    for(edge e:sG[x])
      if(!D[e.from][e.to])
	add_edge(e.from, e.to);
  };
  
  q.emplace(0,1);
  add_edge(0,1);
  
  while(!q.empty()){
    edge e=q.front();q.pop();
    if(D[e.from][e.to]) continue;
    D[e.from][e.to]=1;
    for(int i:M[e.from][e.to]){
      if(used[i]) continue;
      used[i]=1;
      add(i);
    }
    if(q.empty()){
      for(int i=0;i<sz;i++)
	for(int j=0;j<sz;j++)
	  if(i!=j&&!D[i][j]&&G[i][j])
	    q.emplace(i,j);
    }
  }
  
  for(int i=0;i<sz;i++)
    G[i][i]=0;

  WF();

  for(int i=0;i<sz;i++){
    if(!G[i][i]) continue;
    cout<<"No"<<endl;
    return 0;
  }
  
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 17932
k=int(input())
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans=0
for h in range(1,k+1):
    for i in range(1,k+1):
        for j in range(1,k+1):
            ans+=gcd(h,i,j)

print(ans)

Measured memory_bytes: 69716
n = int(input())
for _ in range(n):
  s = input()
  rec = [None] * 52
  ind = 25
  rec[ind] = s[0]
  max_ind = 25
  min_ind = 25

  for i in range(1, len(s), 3):
    direct = s[i:i + 2]
    if direct == "->":
      ind += 1
      max_ind = max(ind, max_ind)
    else:
      ind -= 1
      min_ind = min(ind, min_ind)
    rec[ind] = s[i + 2]

  print("".join(rec[min_ind:max_ind + 1]))


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int ans[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K;
	cin >> K;
	cout << ans[K - 1];
	return 0;
}


Measured memory_bytes: 3640
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Scanner;

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

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int N = sc.nextInt();

    	long[] A = new long[N];

    	BigInteger times = BigInteger.valueOf(1);
    	long K = (long) Math.pow(10,18);

    	boolean flg = true;
    	boolean haszero = false;

    	for(int i=0;i<N;i++) {
    		A[i]=sc.nextLong();
    	}

    	for(int i=0;i<N;i++) {
    		if(A[i]==0) {
    			haszero = true;
    			break;
    		}
    	}

    	if(haszero==false) {

        	for(int i=0;i<N;i++) {
        		times = times.multiply(BigInteger.valueOf(A[i]));

        		if(times.compareTo(BigInteger.valueOf(K))==1) {
        			flg = false;
        			break;
        		}
        	}

        	if(flg) {
        		System.out.println(times);
        	} else {
        		System.out.println("-1");
        	}

    	} else {
    		System.out.println("0");
    	}
    }
}

Measured memory_bytes: 50780
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(A: int, B: int):
    return max(A-2*B, 0)


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(f'{solve(A, B)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75248
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gsort(arr) sort(arr, arr+n, greater<ll>()); 
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sync2 cout<<fixed<<setprecision(10)
const ll inf=1e9+7;
const ll inf2=inf*inf;
#define pi 3.14159265358979323846
#define for0(i,n) for (int i = 0; i <(int)n; i++)
#define for1(i,n) for (int i = 1; i<=(int)n; i++)
#define all(vv) vv.begin(),vv.end()
priority_queue <ll, vector<ll>, greater<ll>> mnheap;
priority_queue <ll> mxheap;
#define vc(vv) vector<ll> vv;
ll gcd(ll x,ll y){if (x == 0)return y;return gcd(y%x, x);}
int is_prime(ll x) {if(x<2)return 0;for(ll i=2;i*i<=x;i++){if(x%i==0)return 0;}return 1;}
inline ll modpw(ll x, ll y, ll z) {ll res=1;x=x%z;while(y){if(y&1) res=(res*x)%z;x=(x*x)%z;y/=2;}return res;}
inline ll modinv(ll x,ll z){return modpw(x,z-2,z);}
ll lcm(ll x,ll y){return (x*y)/gcd(x,y);}
#define pYES cout<<"YES"<<endl
#define pNO cout<<"NO"<<endl

ll dp[105][100005];
int main()
{
     sync;
     int t;
     //cin>>t;
     t=1;
     while(t--)
     {
          ll n,w;
          cin>>n>>w;
          ll a[n+1][2];
          for0(i,n)cin>>a[i+1][0]>>a[i+1][1];
          for(int i=1;i<=n;i++)
          {
               for(int j=1;j<=w;j++)
               {
                    
                    if(a[i][0]<=j)
                    {
                         dp[i][j]=max(a[i][1]+dp[i-1][j-a[i][0]],dp[i-1][j]);                         
                    }
                    else
                    {
                         dp[i][j]=dp[i-1][j];
                    }

               }
          }
          cout<<dp[n][w]<<endl;
     }
}

Measured memory_bytes: 81808
object Main extends App {
  val Array(n, m) = io.StdIn.readLine().split(' ').map(_.toInt)
  val an = io.StdIn.readLine().split(' ').map(_.toInt)
  val topM: Array[Int] = an.sortWith{ (x, y) => x > y}.take(m)
  val sum = an.sum
  println(if (topM.forall(_ >= sum.toDouble / (4 * m))) "Yes" else "No")
}

Measured memory_bytes: 27196
a, b, c, x, y = map(int, input().split())

z = min(x, y)
if x > y:
    p = 2*c*z + a*(x-z)
else:
    p = 2*c*z + b*(y-z)

q = a*x + b*y
r = 2*c * max(x, y)

print(min(p, q, r))


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

int main(){

  int N,D;

  cin>>N>>D;

  double x[10][10];

  
  for(int i=0;i<N;i++){
	for(int j=0;j<D;j++){
	  cin>>x[i][j];
	}
  }

  int cnt=0;
  
  for(int i=0;i<N;i++){
	for(int j=i+1;j<N;j++){

	  double ans=0;
	  
	  for(int k=0;k<D;k++){
		ans+=pow((x[i][k]-x[j][k]),2);
	  }

	  if(sqrt(ans)==int(sqrt(ans))){
		cnt++;
	  }
		 
	  
	  
	}
  }

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


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

using namespace std;

template <typename T>
struct BIT
{
	int N, K;
	vector<T> bit;

	BIT(int X)
	{
		bit = vector<T>(X + 1, 0);
		N = X + 1;
		K = pow(2, (int)(log(X) / log(2)));
	}

	void chmax(int idx, T w)
	{
		for (int x = idx; x <= N; x += x & -x)
		{
			bit[x] = max(bit[x], w);
		}
	}

	T getmax(int idx)
	{
		T res = 0;
		for (int x = idx; x > 0; x -= x & -x)
			res = max(res, bit[x]);
		return res;
	}
};

void solve()
{
	int N;
	cin >> N;
	vector<long> hs(N);
	BIT<long> bit(N);
	for (int i = 0; i < N; i++) cin >> hs[i];
	long ans = 0;
	for (int i = 0; i < N; i++)
	{
		long a, res;
		cin >> a;
		res = a+bit.getmax(hs[i]-1);
		ans = max(ans, res);
		bit.chmax(hs[i], res);
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return (x * y) / gcd(x, y); }


int main(){
    ll n, m; cin >> n >> m;
    vector<int> p(m);
    vector<vector<int>> k(m, vector<int>(n, 0));
    vector<int> cnt(m);
    bool ok = true;
    int ans = 0;

    for (int i = 0; i < m; ++i) {
        int a; cin >> a;
        for (int j = 0; j < a; ++j) {
            int s; cin >> s;
            k[i][s-1] = 1;
        }
    }

    for (int l = 0; l < m; ++l) {
        cin >> p[l];
    }

    for (int i1 = 0; i1 < (1<<n); ++i1) {
        for (int i = 0; i < n; ++i) {
            if((i1>>i)&1){
                for (int j = 0; j < m; ++j) {
                    if(k[j][i]) cnt[j]++;
                }
            }
        }
        for (int l = 0; l < m; ++l) {
            if (cnt[l]%2 != p[l]) ok = false;
            cnt[l] = 0;
        }
        if(ok) ans++;
        ok = true;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
n, Y = map(int, input().split())

for x in range(n+1):
    for y in range(n-x+1):
        z = n - x - y
        if 10000*x + 5000*y + 1000*z == Y:
            print(x, y, z)
            exit(0)
print("-1 -1 -1")


Measured memory_bytes: 42900
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll n, m;
	cin >> n >> m;
	ll ans = 0,count= 0;
	vector<P>q(n);
	ll a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		q[i] = make_pair(a, b);
	}
	sort(q.begin(), q.end());
	for (int i = 0; i < n; i++) {
		if (count+q[i].second< m) {
			ans += q[i].first * q[i].second;
			count += q[i].second;
		}
		else {
			ans += (m - count) * q[i].first;
			count = m;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000


int main(){
	
	int N;
	cin>>N;
	
	vector<long long> A(N),B(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	priority_queue<pair<int,int>> P;
	
	for(int i=0;i<N;i++){
		cin>>B[i];
		if(A[i]!=B[i]){
			P.push(make_pair(B[i],i));
		}
	}
	long long ans = 0;
	while(P.size()!=0){
		int a = P.top().first;
		int b = P.top().second;
		P.pop();
		
		long long k = B[(b+1)%N]+B[(b-1+N)%N];
		if(B[b]<A[b]){
			cout<<-1<<endl;
			return 0;
		}
		long long x = B[b]-A[b];
		ans += x/k;
		if(x/k==0){
			cout<<-1<<endl;
			return 0;
		}
		
		B[b] -= (x/k)*k;
		if(A[b]!=B[b]){
			P.push(make_pair(B[b],b));
		}
		
	}
	
	for(int i=0;i<N;i++){
		if(A[i]!=B[i]){
			cout<<-1<<endl;
			return 0;
		}
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 5492
#include <stdio.h>
 
int get_uint() {
    int s = 0;
    int a = getchar_unlocked();
    if(a < 48 || 57 < a) return a;
    while(47 < a && a < 58) {
        s = 10 * s + (a & 0xf);
        a = getchar_unlocked();
    }
    return s;
}
void put_uint(int s) {
    if(!s) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(s) buf[i++] = (char)(s % 10 + '0'), s /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
typedef struct Card {
    int i;
    int s;
    char a;
} Card;
 
// retard desu LMAO
void *partition(Card *fir, Card *last) {
    Card pivot = *(last - 1);
    Card *p = fir - 1;
    for(Card *is = fir; is != last - 1; ++is) {
        if(is->s <= pivot.s) {
            p++;
            Card tmp = *p;
            *p = *is;
            *is = tmp;
        }
    }
    Card tmp = *++p;
    *p = pivot;
    *(last - 1) = tmp;
    return p;
}
void quicksort(void *fir, void *last, size_t M) {
    if(last - fir <= M) return;
    void *mid = partition(fir, last);
    quicksort(fir, mid, M);
    quicksort(mid, last, M);
}
 
int main(int argc, char **argv) {
    int s = get_uint();
    Card A[s];
    for(int i = 0; i < s; ++i) {
        A[i].a = getchar_unlocked();
        getchar_unlocked();
        A[i].s = get_uint();
        A[i].i = i;
    }
    quicksort(A, A + s, sizeof(Card));
 
    int flag = 0;
    for(int i = 1; i < s; ++i) {
        if(A[i].s==A[i-1].s && A[i].i < A[i-1].i){
            flag = 1;
            break;
        }
    }
    puts(flag ? "Not stable" : "Stable");
    for(int i = 0; i < s; ++i) {
        putchar_unlocked(A[i].a), putchar_unlocked(' ');
        put_uint(A[i].s), putchar_unlocked('\n');
    }
    return 0;
}



Measured memory_bytes: 2788
n = int(input())
a = list(map(int,input().split()))
acc = [0]*n
acc[0] = a[0]
def solve():
  for i in range(1,n):
    acc[i] = a[i]+acc[i-1]
  oddans = 0
  odddiff = 0
  #simulation in case of odd is positive
  for i in range(n):
    if i%2 == 0 and (acc[i]+odddiff)<=0:
      oddans += abs(acc[i]+odddiff)+1
      odddiff += (abs(acc[i]+odddiff))+1
    elif i%2 != 0 and (acc[i]+odddiff)>=0:
      oddans += acc[i]+odddiff+1
      odddiff -= acc[i]+odddiff+1
  #neg
  evenans = 0
  evendiff = 0
  for i in range(n):
    if i%2 == 0 and (acc[i]+evendiff)>=0:
      evenans += (acc[i]+evendiff+1) 
      evendiff -= (acc[i]+evendiff+1)
    elif i%2 != 0 and (acc[i]+evendiff)<=0:
      evenans += (abs(acc[i]+evendiff)+1)
      evendiff += (abs(acc[i]+evendiff)+1)
  return min(evenans,oddans)
  
print(solve())
  

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

using namespace std;

int main() {
    string n;
    cin>>n;
    long long int sum = 0;
    long long int len = n.length();
    for(int i = 0; i < len; i++) {
        sum += (int)n[i] - (int)'0';
    }
    cout<<(sum%9 == 0 ? "Yes" : "No")<<endl;
    return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
    int k,x;cin>>k>>x;
    if(x-k<-1000000){
        for(int i=-1000000;i<x+k-1;i++){
            cout<<i<<' ';
        }
        cout<<x+k-1<<endl;
    }
    else if(x+k>1000000){
        for(int i=x-k+1;i<1000000;i++){
            cout<<i<<' ';
        }
        cout<<1000000<<endl;
    }
    else{
        for(int i=x-k+1;i<k+x-1;i++)cout<<i<<' ';
        cout<<k+x-1<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[220000];
int main(){
  ll n,tmp;
  cin>>n;
  rep(i,0,n)cin>>a[i];
  ll g=1;
  rep(i,0,n){
    if(a[i]==g)g++;
  }
  if(g!=1)cout<<n-g+1;
  else cout<<-1;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second
 
using namespace std;
 
int main(){
 
    int n;
    cin >> n;
    int a[70000];
  
	for(int i = 0; i < 70000; i++) a[i] = 1;
	for(int i = 2; i < sqrt(70000); i++){
		if(a[i]){
			for(int j = 0; i * (j + 2) < 70000; j++){
				a[i *(j + 2)] = 0;
			}
		}
	}
    int x = 0;

	for(int i = 5; i < 70000; i++){
		if(a[i] && i % 10 == 1){
			cout << i;
            x++;
            if(x == n) break;
          	cout << ' ';
		}
	}
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    Fast;
    long long t,n,m,i,j,k,x=0,y=0,z;
    int a[4];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if((a[2]!=a[1] && a[0]==a[1])|| (a[1]==a[2] && a[1]!=a[0])){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}


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



int main() {
  int N; 
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
	  cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int anser=1;
  for(int j=0;j<N-1;j++){
	  if(vec.at(j)!=vec.at(j+1)){
		  anser++;
	  }

  }
  cout<<anser<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 2002;

int A[N];

void check(vi &v, vi &v1, int k) {
  if(v.size() >= k) {
    sort(all(v));
    reverse(all(v));
    while(v.size() >= k) {
      v1.pb(v.back());
      v.pop_back();
    }
  }
  v.clear();
}

int main() {
  int n,k,q;
  scanf("%d%d%d",&n,&k,&q);
  rep(i,1,n+1) {
    S(A[i]);
  }

  int ans = 1000000009;
  rep(i,1,n+1) {
    vi v, v1;
    rep(j,1,n+1) {
      if(A[j] < A[i]) {
        check(v, v1, k);
      } else {
        v.pb(A[j]);
      }
    }
    check(v, v1, k);
    sort(all(v1));
    if(v1.size() >= q) {
      ans = min(ans, v1[q - 1] - v1[0]);
    }
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll lp[100001];
vector<ll> pr;

void prime()
{
    repf(i,1,100001) lp[i]=i;
    repf(i,2,100001)
    {
        if(lp[i]==i)
        {
            for(ll j=2*i;j<100001;j+=i)
            {
                if(lp[j]==j) lp[j]=i;
            }
        }
    }
    repf(i,2,100001) if(lp[i]==i) pr.pb(i);
}


void solve(ll tt) {
    ll x;
    cin>>x;
    if(x==0) cout<<1<<endl;
    else cout<<0<<endl;
} 


int main()
{
    IOS;
    prime();
    ll t=1;
    // cin>>t;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

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

using namespace std;

typedef long long LL;
typedef vector<int>    VI;
typedef vector<bool>   VB;
typedef vector<string> VS;

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define RANGE(x, min, max) min <= x && x <= max

int w, h;
VS tbl;

const int DX[] = {-1, 0, 1, 0}, DY[] = {0, -1, 0, 1};

int dfs(int y, int x) {
	int res = 1;
	tbl[y][x] = '#';
	rep (i, 4) {
		int ny = y + DY[i], nx = x + DX[i];
		if (RANGE(ny, 0, h - 1) && RANGE(nx, 0, w - 1) && tbl[ny][nx] == '.') {
			res += dfs(ny, nx);
		}
	}
	return res;
}

int main(void) {
	while (1) {
		tbl.clear();
		cin >> w >> h;
		if (w == 0 && h == 0) break;
		rep (i, h) {
			string s;
			cin >> s;
			tbl.PB(s);
		}
		int sy, sx;
		rep (i, h) rep (j, w) {
			if (tbl[i][j] == '@') {
				sy = i;
				sx = j;
				break;
			}
		}
		cout << dfs(sy, sx) << endl;	
	}
    return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define int long long
#define p pair <int,int> 
using namespace std;


bool is_safe(vector <vector <char> >& a, int x, int y, int h, int w){
   return x>=0 && x<h && y>=0 && y<w && a[x][y]!='#';
}

int32_t main() {
    int h,w,sx,sy,dx,dy; cin>>h>>w>>sx>>sy>>dx>>dy;
    
    vector < vector <char> > a(h, vector <char> (w,'.'));
    vector < vector <int> > dp(h, vector <int> (w,LONG_LONG_MAX));

    for(int i=0 ; i<h ; i++){
        for(int j=0 ; j<w ; j++){
            cin>>a[i][j];
        }
    }
    
    deque <p> q; 
    q.push_front({sx-1,sy-1});
    dp[sx-1][sy-1]=0;
    
    vector <p> move({{-1,0},{1,0},{0,1},{0,-1}});

    while(!q.empty()){
       p curr = q.front();
       q.pop_front();
       int x = curr.first, y = curr.second;

       for(auto i:move){
          int X = x + i.first;
          int Y = y + i.second;
          if(is_safe(a,X,Y,h,w) && dp[X][Y] > dp[x][y]){
               dp[X][Y] = dp[x][y];
               q.push_front({X,Y});
          }
       }   
          
         for(int i=-2 ; i<=2 ; i++){
           for(int j=-2 ; j<=2 ; j++){
               int X = x + i;
                int Y = y + j;
                if(is_safe(a,X,Y,h,w) && dp[X][Y] > dp[x][y]+1){
                    dp[X][Y] = dp[x][y]+1;
                    q.push_back({X,Y});
                }
           }
         } 
    }
        int res = dp[dx-1][dy-1];
        res == LONG_LONG_MAX ? cout<<-1 : cout<<res;
}

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

int main() {
  char a, b, ans;
  cin >> a >> b;

  if (a == 'H') {
    if (b == 'H') {
      ans = 'H';
    } else {
      ans = 'D';
    }
  } else {
    if (b == 'H') {
      ans = 'D';
    } else {
      ans = 'H';
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int x = s.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = s.nextInt();
    }
    long sum = 0;
    if (a[0] > x) {
      sum += a[0] - x;
      a[0] = x;
    }
    for (int i = 1; i < n; i++) {
      if (a[i] + a[i-1] > x) {
        sum += a[i] + a[i-1] - x;
        a[i] = x - a[i-1];
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 33860
#include<bits/stdc++.h>
using namespace std;
const int roll[10][10]{
        {3, 2, 6, 1, 5, 4}, //W
        {4, 2, 1, 6, 5, 3}, //E
        {2, 6, 3, 4, 1, 5}, //N
        {5, 1, 3, 4, 6, 2} //S
		};
int main()
{
    int Dice[10], NewDice[10], key[200];
    string cmd;
    key['W'] = 0, key['E'] = 1, key['N'] = 2, key['S'] = 3;
    for(int i = 0; i < 6; i++)
    {
		cin >> Dice[i];
	}
	cin >> cmd;
	for(int i = 0; i < cmd.size(); i++)
	{
		for(int j = 0; j < 6; j++)
    	{
    		NewDice[j] = Dice[roll[key[cmd[i]]][j]-1];	
		}
		for(int j = 0; j < 6; j++)
    	{
    		Dice[j] = NewDice[j];
		}
	}
	cout << Dice[0] << endl;
	return 0;
 } 


Measured memory_bytes: 3172