akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<bitset>
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 cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int N, M;
bool A[700][700];
int D[700];
bool dame;
int dfs(int v, int d) {
	D[v] = d;
	int ret = (d & 2) - 1;
	auto a = A[v];
	for (int to = 0; to < N; to++) if (!a[to]) {
		if (!D[to]) ret += dfs(to, d ^ 2);
		else if (D[to] == d) {
			dame = 1;
			return 0;
		}
	}
	return ret;
}

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


	N = getint();
	M = getint();
	rep(i, M) {
		int a = getint() - 1, b = getint() - 1;
		A[a][b] = true;
		A[b][a] = true;
	}
	rep(i, N) A[i][i] = true;

	int kouho[700];
	int k = 0;
	int mannnaka = 0;
	rep(i, N) if (!D[i]) {
		int tmp = abs(dfs(i, 1));
		if (dame) {
			printf("-1");
			return 0;
		}
		mannnaka += tmp;
		kouho[k++] = tmp * 2;
	}


	bitset<1410> BS(0);
	BS[0] = 1;
	rep(i, k) BS |= BS << kouho[i];

	int saishou = 1e9;
	for (int i = 0; i <= mannnaka * 2; i++) {
		if (BS[i]) chmin(saishou, abs(i - mannnaka));
	}
	int X = (N + saishou) / 2;
	int Y = (N - saishou) / 2;
	int kotae = X * (X - 1) / 2 + Y * (Y - 1) / 2;

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
 
int main(){
    int a, b;
    cin >> a >> b;;

    if (a==b) {
        cout << "a == b" << endl;
    } else if (a>b) {
        cout << "a > b" << endl;
    } else {
        cout << "a < b" << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int ans = 0;
    for(int i=1;i<=C;i++){
        if(i%A==0){
            ans += B;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
string moji1="bdtflsphnz";
string moji2="cwjqvxmkgr";
string moji3="BDTFLSPHNZ";
string moji4="CWJQVXMKGR";
int main(){cout<<fixed<<setprecision(10);
		  int n;
           cin>>n;
           int c=n;
           int sum=0;
           while(n>0){
            sum+=n%10;
             n/=10;
           }
           //cout<<sum<<endl;
           Yes(c%sum==0);
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define fd(i,k,n,d) for(int i = k; i<n; i+=d)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)       array<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//****************************************************************************************************************************************//

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

//*****************************************************************************************************************************************//

template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}

template<class T>
T power(T a,T b,T m){
    T res = (T)1;
    a%=m;
    while(b>0){
        if(b&1)res = (res*a)%m;
        b>>=1;
        a = (a*a)%m;
    }
    return res;
}

//*****************************************************************************************************************************************//

struct dsu{
  map<int,int> pr,sz;
  dsu(){
    (this->pr).clear();
    (this->sz).clear();
  }
  void make(int x){
    pr[x] = x;
    sz[x] = 1;
  }
  int getpar(int x){
    if(pr[x] == x)return x;
    return pr[x] = getpar(pr[x]);
  }
  void merge(int x,int y){
    x = getpar(x);
    y = getpar(y);
    if(sz[x]<sz[y])swap(x,y);
    pr[y] = x;
    sz[x]+=sz[y];
    sz[y] = 0;
  }
};

//******************************************************************************************************************************************//


void solve(){
  int n;
  cin>>n;
  int ans = (n%1000 == 0?0:(n/1000+1)*1000-n);
  cout<<ans<<"\n";
}

signed main(){
    fastio();
    int cs = 1;
    //cin>>cs;
    while(cs--){
        solve();
    }
}


Measured memory_bytes: 3648
#include<stdio.h>

int main(void)
{
	int i,n,m,ans;
	scanf("%d%d",&n,&m);
	for(i=0;i+n<=m/2;i++){
		if(m%(n+i)==0){
			ans=m/(n+i);
			printf("%d",ans);
			return 0;
		}
	}
	printf("1");
	return 0;
}

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

int main(){
  int N, f;
  cin >> N;
  vector<int> kagami_size(N);
  for (int i=0;i<N;i++){
    cin >> kagami_size.at(i);
  }
  f = N;
  for(int i=0;i<N;i++){
    int tmp_size = kagami_size.at(i);
    if (!tmp_size){
      continue;
    }else{
      for(int j=i;j<N;j++){
        if(tmp_size==kagami_size.at(j) && i!=j){
          f--;
          kagami_size.at(j) = 0;
        }
      }
    }
  }
  cout << f << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/*2点間の距離*/

double dist(int xa, int xb,int ya,int yb)
{
  double d;
  d = (xa-xb)*(xa-xb) + (ya-yb)*(ya-yb);
  return sqrt(d);
}

int main ()
{
  int  n,i,j;
  int *x,*y;
  double d;

  scanf("%d", &n);
  x = calloc(n,sizeof(int));
  y = calloc(n,sizeof(int));

  for(i=0; i<n; i++)
    scanf("%d%d",&x[i],&y[i]);

    for(i=0; i<n; i++)
    {
      for(j=0; j<n; j++)
      d += dist(x[i],x[j],y[i],y[j])/n;
    }

  printf("%lf", d);

  return 0;
}


Measured memory_bytes: 2180
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

bool is_edge(ll R, ll C, ll x, ll y) {
  return x == 0 || x == R || y == 0 || y == C;
}

struct num {
  ll x1, y1, x2, y2;
};

struct point {
  ll x, y;
  int id;
};

int place(ll R, ll C, const point &p) {
  if(p.y == 0) return 0;
  if(p.x == R) return 1;
  if(p.y == C) return 2;
  return 3;
}

int main() {
  ios::sync_with_stdio(false);
  ll R, C, N;
  cin >> R >> C >> N;
  vector<num> ns(N);
  FOR(n,ns) {
    cin >> n.x1 >> n.y1 >> n.x2 >> n.y2;
  }
  vector<point> ps;
  REP(i,0,N) {
    num n = ns[i];
    if(is_edge(R, C, n.x1, n.y1) && is_edge(R, C, n.x2, n.y2)) {
      ps.push_back({n.x1, n.y1, i});
      ps.push_back({n.x2, n.y2, i});
    }
  }
  sort(ps.begin(), ps.end(), [=](point p, point q) {
      int pp = place(R, C, p);
      int pq = place(R, C, q);
      if(pp != pq) {
        return pp < pq;
      }
      switch(pp) {
      case 0:
        return p.x < q.x;
        break;
      case 1:
        return p.y < q.y;
        break;
      case 2:
        return p.x > q.x;
        break;
      default:
        return p.y > q.y;
      }
    });
  stack<int> st;
  FOR(p,ps) {
    if(st.empty() || st.top() != p.id) {
      st.push(p.id);
    } else {
      st.pop();
    }
  }
  cout << (st.empty() ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 11632
package main

import (
	"fmt"
	"os"
)

var sumac int
var sumwa int

func run() int {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)
	ac := make(map[int]bool, 0)
	wa := make(map[int]int, 0)
	for i := 0; i < m; i++ {
		var p int
		var s string
		fmt.Scanf("%d %s\n", &p, &s)
		if _, ok := ac[p]; !ok {
			if s == "AC" {
				ac[p] = true
				sumac++
				if wap, ok := wa[p]; ok {
					sumwa += wap
				}
			} else {
				wa[p]++
			}
		}
	}

	fmt.Println(sumac, sumwa)

	return 0
}

func main() {
	os.Exit(run())
}


Measured memory_bytes: 7936
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <climits>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  ll k;
  cin >> n >> k;
  vecint a(n);
  REPe(e, a) cin >> e;
  vecll x(n, 0);
  vecll y(n, 0);
  REP(i, n) {
    FOR(j, i + 1, n) {
      if (a[i] > a[j]) {
        x[i]++;
      }
    }
    FOR(j, 0, i) {
      if (a[i] > a[j]) {
        y[i]++;
      }
    }
  }
  // REP(i, n) cout << x[i] << " " << y[i] << endl;

  ll ans = 0;
  REP(i, n) {
    ans += ((x[i] + y[i]) * (((k * k - k) / 2) % MOD) + k * x[i]) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}
//////////////////////////////////////////////


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int F() {
	register int a, b, c;
	while(c=getchar(), c<'-');
	b=(c=='-');
	for(a=b?0:c-'0'; c=getchar(),c>'-'; a=a*10+c-'0');
	return b?-a:a;
}
const int N=2e5+10;
int fa[N];
int find(register int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
int deg[N];
bool mark[N], appear[N];
bool work() {
	register int n=F(), h=F(), i, a, b, c, d, cnt=0, ans=0;
	for(i=1; i<=2*h; ++i) fa[i]=i, deg[i]=0, appear[i]=mark[i]=0;
	for(i=1; i<=n; ++i) {
		a=F(), b=F(), c=F(), d=F();
		++deg[c=c?c:a+h];
		--deg[d=d?d+h:b];
		fa[find(c)]=find(d);
		appear[c]=appear[d]=1;
	}
	for(i=1; i<=2*h; ++i) if(appear[i]) {
		if(i<=h&&deg[i]>0 || i>h&&deg[i]<0) return 0;
		mark[i] = deg[i]!=0;
	}
	for(i=1; i<=2*h; ++i) mark[find(i)]|=mark[i];
	for(i=1; i<=2*h; ++i) if(appear[i] && find(i)==i && !mark[i]) return 0;
	return 1;
}
int main() {
	register int t=1;
	while(t--) puts(work()?"YES":"NO");
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/python
# coding: UTF-8


#import scipy.optimize
#import numpy as np

    
##################################################################

if __name__ == "__main__":
    Input1 = [input() for i in range(1)]
    N,Q = list(map(int,Input1[0].split()))
    Input2 = [input() for i in range(1,N+Q)]
    a = [0]*(N-1)
    b = [0]*(N-1)
    p = [0]*(Q)
    x = [0]*Q
    for i in range(N-1):
        a[i],b[i] = list(map(int,Input2[i].split()))
    for i in range(N-1,N-1+Q):
        p[i+1-N],x[i+1-N] = list(map(int,Input2[i].split()))

##    Node = [1]*(N+1)
##    for i in range(N-1):
##        Node[b[i]] = a[i]
##    Root = [False]*(N+1)
##    Root[1] = True
##    Parent = [[],[1]]
##    for i in range(2,N+1):
##        Parent.append([i])
##        j = i
##        temp = Node[j]
##        Parent[i] = Parent[i]+Parent[temp]
##        while Root[i]==False:
##            if any([Root[k] for k in Parent[i]]):
##                Root[i]=True
##            else:
##                j = Node[j]
##                Parent[i] = Parent[i]+Parent[j]

    graph = [[] for i in range(N+1)]
    for i in range(N-1):
        graph[a[i]].append(b[i])
        graph[b[i]].append(a[i])

    
    Cntr = [0]*(N+1)
    for i in range(Q):
        Cntr[p[i]] += x[i]
        
    q=[(0,1)]
    while q:
        parent,child = q.pop()
        Cntr[child]+=Cntr[parent]
        for i in graph[child]:
            if i==parent:
                continue
            q.append((child,i))
    print(' '.join(map(str,Cntr[1:])))


Measured memory_bytes: 111784
n = gets.to_i
a = gets.chomp.split
b = gets.chomp.split
c = gets.chomp.split
n.times do |i|
    a[i] = a[i].to_i
    b[i] = b[i].to_i
    c[i] = c[i].to_i if i < n-1
end

satisfaction = b[a[0]-1]
(n-1).times do |i|
    satisfaction += b[a[i+1]-1]
    satisfaction += c[a[i]-1] if a[i+1] == a[i]+1
end

puts satisfaction

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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(b - a == c - b)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, t;
  cin >> n >> t;
  vector<P> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(all(p));
  vi a(n), b(n);
  rep(i, n) {
    a[i] = p[i].first;
    b[i] = p[i].second;
  }
  int dp[n + 1][t][2] = {};
  rep(i, n + 1) rep(j, t) rep(k, 2) dp[i][j][k] = -1;
  dp[0][0][0] = 0;
  rep(i, n) rep(j, t) rep(k, 2) {
    if(dp[i][j][k] == -1) continue;
    int ni = i + 1;
    int nj = j + a[i];
    dp[ni][j][k] = max(dp[ni][j][k], dp[i][j][k]);
    if(k) {
      if(nj < t) dp[ni][nj][1] = max(dp[ni][nj][1], dp[i][j][1] + b[i]);
    } else {
      if(nj < t)
        dp[ni][nj][0] = max(dp[ni][nj][0], dp[i][j][0] + b[i]);
      else
        dp[ni][j][1] = max(dp[ni][j][1], dp[i][j][0] + b[i]);
    }
  }
  int ans = 0;
  rep(j, t) rep(k, 2) ans = max(ans, dp[n][j][k]);
  cout << ans << endl;
}

Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;

int main()
{
    string s;
    ll cnt = 0;
    cin >> s;

    for (ll i = 0; i < s.size(); i++)
    {
        if (s[i] == 'R')
        {
            cnt++;
        }
    }
    if (s[1] == 'R')
    {
        cout << cnt << endl;
    }
    else
    {
        if (cnt == 2)
        {
            cout << 1 << endl;
        }
        else
        {
            cout << cnt << endl;
        }
    }
}

Measured memory_bytes: 3592
N, T = map(int, input().split())
t = [int(i) for i in input().split()]
ans = 0
s = 0
d = 0
for t_i in t:
	d = max(t_i + T - s, 0)
	ans += min(d, T)
	s = t_i + T
print(ans)

Measured memory_bytes: 25196
#MLE注意！ not は使わず !=

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = [0]*n
    for i in a:
        res[i-1] += 1
    for i in res:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 90608
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数leng
#define INF 9223372036854775807 //  巨大数INF
using namespace std;

int f(int n) {
  if (n % 2 == 0) n = n / 2;
  else n = (3 * n) + 1;
  return n;
}

signed main() {
  bool ok = false;
  int s = 0;
  cin >> s;
  int n = s;
  vector<int> record(0);
  record.push_back(n);
  rep(i, INF) {
    n = f(n);
    record.push_back(n);
    rep(j, i+1) {
      if (n == record[j]) {
        cout << i+2 << endl;
        ok = true;
        break;
      }
    }
    if (ok) break;
  }
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())
    if V <= W: print("NO")
    else:
        diff = abs(A - B)
        if (V - W) * T >= diff: print("YES")
        else: print("NO")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
bool isvalid(ll x,ll y,ll n, ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
vector<ll>v[100011];

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t;

    ll a,b,c;
    cin>>c>>b>>a;
    ll k;
    cin>>k;
    ll ans = 0;

    // if(b<c){
        while(b<=c){
            b = b*2;
            ans++;
        }
    // }
    // cout<<b;
    while(a <= b){
        ans++;
        a = a*2;
    }
    // cout<<a;
    // cout<<ans<<" ";
    if(ans<=k){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 6000
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
const int maxx=100010;
 
vector<int> A[maxx];
int pre[maxx],parent[maxx],low[maxx];
bool flag[maxx];
int v,e,now=1;
 
void dfs(int u){
	flag[u]=true;
	low[u]=now;
	pre[u]=now;
	now++;
	for(int i=0;i<A[u].size();i++){
		if(flag[A[u][i]]==false) {//if the next has not been visited
			parent[A[u][i]]=u;//update the parent array
			dfs(A[u][i]);//dfs the next point
			low[u]=min(low[u],low[A[u][i]]);//if the low value of son point is smaller
		}
		else if(parent[u]!=A[u][i]){//if a point has been visited and the edge between u and A[u][i] is not in dfs tree,
			low[u]=min(low[u],pre[A[u][i]]);//update the value of low array
		}
		
	}
	return ;
}
 
 
int main (){
	int x,y;
	parent[0]=0;
	for(int i=0;i<maxx;i++){
		flag[i]=false;
	}
	cin>>v>>e;
	while(e--){
		cin>>x>>y;
		A[x].push_back(y);
		A[y].push_back(x);
	}
	dfs(0);
	
	//for(int i=0;i<v;i++) cout<<i<<"  "<<low[i]<<endl;//debug
	
	set<int> ans;//save the answer data in set
	int cnt=0;
	for(int i=1;i<v;i++){
		int p=parent[i];
		if(p==0) cnt++;
		else if(pre[p]<=low[i]) ans.insert(p);
	}
	if(cnt>=2) ans.insert(0);
	for(set<int>::iterator it=ans.begin();it!=ans.end();it++) cout<<*it<<endl;
	return 0;
	
}


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

const int MAX_N = 100005;
int64_t ans[MAX_N];

int main() {
  int64_t s = 0;
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int val;
    scanf("%lld", &val);
    ans[val]++;
    s += val;
  }
  int Q;
  scanf("%d", &Q);
  for (int i = 0; i < Q; ++i) {
    int64_t B, C;
    scanf("%lld %lld", &B, &C);
    s -= ans[B] * B;
    s += ans[B] * C;
    ans[C] += ans[B];
    ans[B] = 0;
    printf("%lld\n", s);
  }
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	string s;
	cin >> s;
	int m = s.length(), n = m;
	for (int i = 1; i < s.length(); ++i){
		if (s[i] != s[i-1]){
			m = min(max(i,n-i),m);
		}
	}
	cout << m << "\n";	
	return 0;
}


Measured memory_bytes: 3788
# coding: utf-8


def if_hi(input_):
    hi = 'hi'
    for i in range(0, len(input_), len(hi)):
        if input_[i:i+len(hi)] == hi:
            pass
        else:
            return False
    return True


def main():
    input_ = input()
    
    if len(input_) < 2:
        print('No')
    elif if_hi(input_):
        print('Yes')
    else:
        print('No')

    return 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

using R = long double;
R p[6], q[6];

R calc(R a) {
    R sm = 0;
    for (int i = 0; i < 6; i++) {
        R x = a * p[i];
        R y = (1-a) * q[i];
        R sh = x+y;
        if (x+y > 1e-15) {
            sm += sh * max(x, y) / (x+y);
        }
    }
    return sm;
}

int main() {
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    for (int i = 0; i < 6; i++) {
        cin >> p[i]; p[i] /= 100;
    }
    for (int i = 0; i < 6; i++) {
        cin >> q[i]; q[i] /= 100;
    }
    R l = 0, r = 1;
    for (int i = 0; i < 200; i++) {
        R mdl = (l+l+r)/3, mdr = (l+r+r)/3;
        if (calc(mdl) < calc(mdr)) {
            r = mdr;
        } else {
            l = mdl;
        }
    }
    cout << calc(l) << endl;
/*    for (int i = 0; i <= 100; i++) {
        cout << i << " " << calc(R(i)/100) << endl;
    }*/
    return 0;
}


Measured memory_bytes: 256
# print('input >>')
X, N = map(int,(input().split()))
ps = list(map(int,(input().split())))

all_num = [i for i in range(0, 102)]

for p in ps: # 10000
    all_num.remove(p)

diff = 1000
ans = 1000
anss = []

for num in all_num:
    my_diff = abs(num - X)
    if my_diff < diff:
        ans = num
        diff = my_diff

# print('-----output-----')
print(ans)

Measured memory_bytes: 9200
import sys

def 解():
    def isNotValid(dt,dx,dy):
        iD = dx+dy
        if dt % 2 : #奇数
            if iD % 2 and iD <= dt:
                return False
            else:
                return True
        else: #偶数
            if iD % 2 == 0 and iD <= dt:
                return False
            else:
                return True
    iN = int(input())
    bt,bx,by =0, 0,0
    for t,x,y in [[int(_) for _ in sLine.split()] for sLine in  sys.stdin.readlines()]:
        if isNotValid(t-bt,abs(x-bx),abs(y-by)):
            print("No")
            exit()
        bt,bx,by = t, x,y
    print("Yes")
解()


Measured memory_bytes: 28284
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap



class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@mt
def slv(N, K):
    ans = 0
    M = Mod(10**9+7)

    c = {}
    for k in range(K, 0, -1):
        n = M.pow(K//k, N)
        for j in range(2, K//k+1):
            n = M.sub(n, c[j*k])
        ans = M.add(ans, M.mul(n, k))
        c[k] = n

    return ans


def main():
    N, K = read_int_n()
    print(slv(N, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 90012
#include <stdio.h>

void calc(char);
void push(int);
int pop(void);

int stack[1000];
int stackUsed[1000];

main(){

  int i, END_OF_INPUT;
  char str[9];

  // INITIALIZE
  for(i=0; i<100; i++){
    stack[i] = 0;
    stackUsed[i] = 0;
  }

  while(1){

    END_OF_INPUT=0; i=0;
    while(1){
      scanf("%c",&str[i]);
      if(str[i] == ' '){
	str[i]='\0';
	break;
      }
      if(str[i] == '\n'){
	str[i]='\n';
	END_OF_INPUT=1;
	break;
      }
      i++;
    }

    if('0' <= str[0] && str[0] <= '9'){
      push(atoi(str));
    }else{
      calc(str[0]);
    }

    if(END_OF_INPUT) break;

  }

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

  return 0;

}

void calc(char exp){

  int op1, op2, ans;

  op2 = pop();
  op1 = pop();

  switch(exp){
  case '+':
    ans = op1 + op2;
    break;
  case '-':
    ans = op1 - op2;
    break;
  case '*':
    ans = op1 * op2;
    break;
  default:
    break;
  }

  push(ans);

}

void push(int value){

  int i=0;
  while(stackUsed[i]==1){
    i++;
  }
  stack[i] = value;
  stackUsed[i] = 1;

}

int pop(){

  int i=0, tmp;
  while(stackUsed[i]==1){
    i++;
  }
  tmp = stack[i-1];
  stack[i-1] = 0;
  stackUsed[i-1] = 0;
  return tmp;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define fastio() ios_base::sync_with_stdio(false);\
cin.tie(NULL);
 
#define md 1000000007
 
 
#define lli long long int
#define pb push_back
#define mp make_pair
#define vvi(r,c) vector<vector<lli>> v(r,vector<lli>(c));
 
 
void solve(){
  int n,W;
  cin>>n>>W;
  vector<int> w(n),v(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>w[i]>>v[i];
    sum+=v[i];
  }
 // cout<<sum<<endl;
  vector<int> dp(sum+1,md);
  dp[0]=0;
  for(int j=0;j<n;j++){
  for(int i=sum;i>0;i--){
      if(i-v[j]>=0){
        dp[i]=min(dp[i],w[j]+dp[i-v[j]]);
      }  
  }
  }
  int i;
  for(i=sum;i>0;i--){
  //  cout<<dp[i]<<endl;
      if(dp[i]<=W){
        // cout<<dp[i]<<" ";
        break;
      }
  }
  cout<<i<<endl;
 
}
 
 
int main()
{  
    fastio();
  int t;
  
  t=1;
  while(t--){
    solve();
  }
 
  return 0;
}


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

int main(void)
{
  for(;;){
    int n,k;
    scanf("%d %d",&n,&k);
    if(n==0 && k == 0)return 0;
    
    int blood[k];
    for(int i=0;i<k;i++){
      scanf("%d",&blood[i]);
    }

    bool sucsses=true;
    for(int i=0;i<n;i++){
      for(int j=0;j<k;j++){
	int tmp;
	scanf("%d",&tmp);
	blood[j]-=tmp;
	if(blood[j]<0){sucsses=false;}
      }
    }

    if(sucsses)
      printf("Yes\n");
    else
      printf("No\n");

  }
  return 1;
}

Measured memory_bytes: 1168
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;
#define Vi vector<int>
#define FOR(i,n) for(int i=0;i<n;i++)

int main(){
  int n;
  cin>>n;
  Vi a(n),b(n,-1);
  FOR(i,n)
    //cin>>a[i];
    scanf("%d",&a[i]);

  for(int i=0;i<n;i+=2){
    b[n/2+i/2]=a[i];
  }
  if(n%2==1){
    for(int i=0;i<n-1;i+=2){
      b[i/2]=a[n-2-i];
    }
    reverse(b.begin(),b.end());
  }else{
    for(int i=0;i<n;i+=2){
      b[i/2]=a[n-1-i];
    }
  }


  cout<<b[0];
  for(int i=1;i<n;i++)
    cout<<" "<<b[i];
  cout<<endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <numeric>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
typedef pair<int, int> P;

typedef long long ll;
const int MOD = 1000000007;

int main(){  
  int N,D,count = 0;
  int point[10][10];
  cin >> N >> D;
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> point[i][j];
    }
  }
  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
      if(i == j) continue;
      float sum = 0;
      for(int k=0;k<D;k++){
        sum += pow(point[j][k] - point[i][k],2);
      }
      for(int k=0;k<=127;k++){
        if(sum < pow(k,2)+1 && sum > pow(k,2)-1) count++;
      }
    }
  }
  cout << count;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= 5) {
    cout << 0 << endl;
  } else if (a >= 6 && a <= 12) {
    cout << b / 2 << endl;
  } else {
    cout << b << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin>>s;
	if(s[0]==s[1] && s[1]==s[2])cout<<"Yes"<<endl;
	else if(s[3]==s[1] && s[1]==s[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

	


Measured memory_bytes: 256
N=int(input())
cnt={}
cnt['AC']=0
cnt['WA']=0
cnt['TLE']=0
cnt['RE']=0

for i in range(N):
  s=input()
  cnt[s]+=1
  
print('AC x '+str(cnt['AC']))
print('WA x '+str(cnt['WA']))
print('TLE x '+str(cnt['TLE']))
print('RE x '+str(cnt['RE']))

Measured memory_bytes: 9092
#include <stdio.h>

int main(void)
{
	
	int n,m,x,tmp,y;
	
	while(scanf("%d %d", &m, &n) != EOF){
		if(n > m){
			tmp = m;
			m = n;
			n = tmp;
		}
		x = m;
		y = n;
		while(n != 0){
			tmp = n;
			n = m%n;
			m = tmp;
		}
		printf("%d %d\n", m, x/m*y);
	}
	
	return(0);
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int i,j;
  int cnt = 0;
  vector<int> a(2*m);
  for(i=0;i<2*m;i++) cin >> a[i];
  for(i=1;i<=n;i++){
    for(j=0;j<2*m;j++){
      if(a[j]==i) cnt++;
    }
    cout << cnt << "\n";
    cnt = 0;
  }
  return 0;
}

Measured memory_bytes: 256
import collections


def duplicate(n):
    return n * (n - 1) // 2


def main():
    n, k = map(int, input().split())
    A = tuple(map(int, input().split()))
    
    a = 0;
    
    for i in range(n - 1):
        for j in range(i + 1, n):
            if A[i] > A[j]:
                a += 1
    
    a_counter = collections.Counter(A)
    
    b = duplicate(n)
    for key in a_counter:
        if a_counter[key] >= 2:
            b -= duplicate(a_counter[key])
    
    print((a * k + b * k * (k - 1) // 2) % ((10 ** 9) + 7))


main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll a, b;
  cin >> a >> b;
  if ((b - a + 1) % 2 == 0) {
    if (a % 2 == 0) {
      if ((b - a + 1) % 4 == 0) cout << 0 << endl;
      else cout << 1 << endl;
    }
    else {
      ll ans = a ^ b;
      if ((b - a - 1) % 4 == 0) cout << (ans ^ 0) << endl;
      else cout << (ans ^ 1) << endl;
    }
  }
  else {
    if (a % 2 == 0) {
      if ((b - a) % 4 == 0) cout << (b ^ 0) << endl;
      else cout << (b ^ 1) << endl;
    }
    else {
      if ((b - a) % 4 == 0) cout << (a ^ 0) << endl;
      else cout << (a ^ 1) << endl;
    }
  }
}

Measured memory_bytes: 256
#include <tuple>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int f(vector<int>& A, vector<tuple<int,int,int,int>>& reqs, int i, int N, int M, int Q){
    if(i == N){
        int res = 0;
        for(int q = 0;q < Q;q++){
            if(A[get<1>(reqs[q])] - A[get<0>(reqs[q])] == get<2>(reqs[q])){
                res += get<3>(reqs[q]);
            }
        }
        // for(int i = 0;i < N;i++)cout<<A[i]<<" ";
        // cout<<": "<<res<<endl;
        return res;
    }
    int res = 0;
    for(int d = A[i-1];d <= M;d++){
        A[i] = d;
        res = max(res, f(A,reqs,i+1,N,M,Q));
    }
    return res;
}

int main(){
    int N,M,Q;
    cin>>N>>M>>Q;
    vector<tuple<int,int,int,int>> reqs;
    for (int i = 0; i < Q; i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        reqs.push_back(make_tuple(a-1,b-1,c,d));
    }
    vector<int> A(N,1);
    cout<<f(A, reqs, 1, N, M, Q)<<endl;
}

Measured memory_bytes: 3608
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{

    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var A = int.Parse(inputs[0]);
        var B = int.Parse(inputs[1]);
        int result;
        if (B % A == 0)
        {
            result = A + B;
        }
        else
        {
            result = B - A;
        }
        Console.WriteLine(result);
    }
}



Measured memory_bytes: 11092
#include <iostream>
#include <cassert>
#include <cmath>
#include <iomanip>
//#define NDEBUG
int main(void){
    using namespace std;
    static const int INPUT_A_MAX = pow(10,9.0);
    static const int INPUT_B_MAX = pow(10,9.0);
    static const int INPUT_A_MIN = 1;
    static const int INPUT_B_MIN = 1;
    int input_a = 0;	/* 入力値は整数 */
    int input_b = 0;	/* 入力値は整数 */
    int d = 0;
    int r = 0;
    double f = 0;
 
    cin >> input_a;
    cin >> input_b;
 
    /* 入力値の前提条件 */
    assert (INPUT_A_MIN <= input_a && input_a <= INPUT_A_MAX);
    assert (INPUT_B_MIN <= input_b && input_b <= INPUT_B_MAX);
 
    /* Calculation */
    d = input_a / input_b;          /* 割り算(整数) */
    r = input_a % input_b;          /* あまり(整数) */
    f = static_cast<double>(input_a) / static_cast<double>(input_b);    /* 割り算(浮動小数点数) */
 
    /* Output */
    cout << d << " " << r << " " << fixed << f << endl;
    return 0;
}


Measured memory_bytes: 3264
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  string s; cin >> s;
  int cnt0 = 0, cnt1 = 0;
  rep(i, s.length()) {
      if(s[i]=='0') ++cnt0;
      if(s[i]=='1') ++cnt1;
  }
  cout << 2*min(cnt0, cnt1) << '\n';
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main(){
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  int m = std::max(a, std::max(b, c));
  int d = m - a;
  d+= m-b; d+= m-c;
  if(d%2==0) printf("%d\n", d/2);
  else printf("%d\n", (d+3)/2);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define mm map<ii>
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

    string str;
    cin>>str;

    map<char,int> m;

    forn(i,0,str.size())
    {
        m[str[i]]++;
    }

    if(m.size() == 2)
    {
        forv(i,m)
        {
            if(i.ss != 2) 
            {
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }


    return 0;
}

Measured memory_bytes: 256
Z = 998244353


def calc(N, D):
    if D[0] != 0:
        return 0
    d = {}
    for Di in D:
        d[Di] = 1 + (d[Di] if Di in d else 0)
    if d[0] != 1:
        return 0
    result = 1
    for i in range(max(d.keys())):
        if not i + 1 in d:
            return 0
        result *= (d[i] ** d[i + 1]) % Z
        result = result % Z
    return result


N = int(input())
D = [int(s) for s in input().split()]
print(calc(N, D))

Measured memory_bytes: 18592
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int h1,m1,h2,m2,k;
		h1=sc.nextInt();
		m1=sc.nextInt();
		h2=sc.nextInt();
		m2=sc.nextInt();
		k=sc.nextInt();
		h1=h1*60+m1;
		h2=h2*60+m2;
		print(h2-h1-k);
	}
	
	private static void print(Object o) {
		System.out.println(o.toString());
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 32436
#include<bits/stdc++.h>
using namespace std;
const int N=100000;
int f[N],a[N];
int main()
{
    int n,m;
    cin>>n>>m;
    int x[N],y[N];
    for(int i=1;i<=n;i++)
    {
        f[i]=1;
        if(i==1)
            a[i]=1;
        else
            a[i]=0;
    }
    for(int i=1;i<=m;i++)
    {
        cin>>x[i]>>y[i];
    }
    for(int i=1;i<=m;i++)
    {
        f[x[i]]--;
        f[y[i]]++;
        if(a[x[i]]==1)
        {
            a[y[i]]=1;
        }
        if(f[x[i]]==0)
            a[x[i]]=0;
    }
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
            sum++;
    }
    cout<<sum<<endl;
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n; cin >> n;
  vector<int> dist(n, 9 * 5);
  dist[1] = 1;
  auto comp = [&](int a, int b) { return dist[a] < dist[b]; };
  priority_queue<int, vector<int>, decltype(comp)> pq(comp);
  pq.push(1);
  while(pq.size()) {
    int i = pq.top();
    pq.pop();
    if(dist[(i + 1) % n] > dist[i] + 1) {
      dist[(i + 1) % n] = dist[i] + 1;
      pq.push((i + 1) % n);
    }
    if(dist[i * 10 % n] > dist[i]) {
      dist[i * 10 % n] = dist[i];
      pq.push(i * 10 % n);
    }
  }
  cout << dist[0];
}


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

using namespace std;
#define INF 1000000000

int main(void)
{
    int n, m, r, a, b, c;
    cin >> n >> m >> r;

    vector<int> rs;
    int adj[n + 1][n + 1] = {};
    for(int i = 0; i < r; i++)
    {
        cin >> a;
        rs.push_back(a);
    }

    for(int i = 0; i < m; i++)
    {
        cin >> a >> b >> c;
        adj[a][b] = c;
        adj[b][a] = c;
    }

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

    int dp[n + 1][n + 1] = {};

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            if(i == j) dp[i][j] = 0;
            else if(adj[i][j]) dp[i][j] = adj[i][j];
            else dp[i][j] = INF;
        }
    }

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            for(int k = 1; k <= n; k++)
            {
                dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
            }
        }
    }
    // for(int i = 0; i <= n; i++) { for(int j = 0; j <= n; j++) { cout << dp[i][j]; } cout << endl; } cout << endl;

    sort(rs.begin(), rs.end());

    long long mi = INF, cur;

    do
    {
        cur = 0;
        for(int i = 0; i < r - 1; i++)
        {
            cur += 1ll*dp[rs[i]][rs[i + 1]];
        }
        mi = min(mi, cur);
    }
    while(next_permutation(rs.begin(), rs.end()));

    cout << mi << endl;
}


Measured memory_bytes: 512
//AOJ 0535 Crossing Black Ice
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 100000000, MAX_N = 90, MAX_M = 90;
int nm[MAX_N][MAX_M], flag[MAX_N][MAX_M], n, m, sum = 1, res = 0, ans;
void dfs(int x, int y){
	flag[x][y] = sum;
	res = max(res, flag[x][y]);
	for (int i = -1; i <= 1; i++){
		for (int j = -1; j <= 1; j++){
			if (i == 0 || j == 0){
				if (flag[x + i][y + j] == 0 && x + i < n&&y + j < m&& x + i >= 0 && y + j >= 0 && nm[x + i][y + j] == 1){
					sum = flag[x][y];
					sum++;
					dfs(x + i, y + j);
					flag[x + i][y + j] = 0;
				}
			}
		}
	}
	return;
}
int main(){
	while (true){
		cin >> m >> n;
		if (m == 0 && n == 0){
			return 0;
		}
		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				cin >> nm[i][j];
			}
		}
		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				if (nm[i][j] == 1){
					sum = 1;
					res = 0;
					dfs(i, j);
					flag[i][j]=0;
					ans = max(ans, res);
				}
			}
		}
		cout << ans << endl;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				flag[i][j] = 0;
			}
		}
		ans=0;
	}
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  bool check[h][w];
  char map[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> map[i][j];
      if (map[i][j] == '.') check[i][j] = true;
      else check[i][j] = false;
    }
  }
  for (int i = 0; i < h; i++) {
      bool a = true;
      for (int x = 0; x < w; x++) {
        if (check[i][x]!=true) a = false;
      }
      if (a==true) continue;

      for (int j = 0; j < w; j++) {
        bool b = true;
        for (int y = 0; y < h; y++) {
          if (check[y][j] != true) b = false;
        }
        if (b == true) continue;
        else {
          cout << map[i][j];
        }
      }
    cout << '\n';
  }
}


Measured memory_bytes: 256