akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int n, m, k;
int a[19][1009];

string s;

int x;
int tai[19];
int v[19];

int rez;

int ap[19];
int lin[19];

void verif()
{
    for(int i = 1; i <= n; i ++)
        ap[i] = 0;

    int cr = x;
    v[++ x] = n;

    for(int i = 1; i <= x; i ++)
    {
        for(int j = max(1, v[i - 1] + 1); j <= v[i]; j ++)
            lin[j] = i;
    }

   // cout << "VERIF\n";
    for(int j = 1; j <= m; j ++)
    {
        int mx = 0;
        for(int i = 1; i <= n; i ++)
        {
            ap[lin[i]] += a[i][j];
            mx = max(mx, ap[lin[i]]);
        }

        if(mx > k)
        {
            cr ++;
            for(int i = 1; i <= n; i ++)
                ap[lin[i]] = 0;

            for(int i = 1; i <= n; i ++)
            {
                ap[lin[i]] += a[i][j];
            }
        }
    }

    int mx = 0;
    for(int i = 1; i <= n; i ++)
    {
        mx = max(mx, ap[lin[i]]);
    }

    if(mx > k)
        cr = n + m + 9;

    rez = min(rez, cr);
}

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

    rez = n + m + 9;
    for(int i = 0; i < (1 << (n - 1)); i ++)
    {
        x = 0;
     //   memset(tai, 0, sizeof(tai));
        for(int j = 0; j < n - 1; j ++)
        {
            if(((1 << j) & i) != 0)
            {
                //tai[j + 1] = 1;
                v[++ x] = j + 1;
            }
        }

        verif();
    }

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i=0;i<N;i++){
    cin >> S.at(i);
  }
  int p = 1, F = 0;
  for (int i=0;i<N;i++){
    p = 1;
    for (int j=0;j<N;j++){
      for (int k=0;k<N;k++){
        if (S.at((j+i)%N).at(k) != S.at((k+i)%N).at(j)){
          p = 0;
          break;
        }
      }
      if (p == 0){
        break;
      }
    }
    F += N * p;
  }
  cout << F << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N, K; cin >> N >> K;
  int result = 0; while (N) { N/=K; result++; }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e3+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
bool vis[N][N];int dp[N][N];char a[N][N];int n,m;
int dfs(int i,int j){
    if(i>n or j>m)return 0;
    if(vis[i][j])return dp[i][j];
    if(a[i][j]=='#')return dp[i][j]=0;
    if(i==n and j==m)return dp[i][j]=1;
    vis[i][j]=1;
    return dp[i][j]=(dfs(i+1,j)+dfs(i,j+1))%M;
}
void solve(){
  cin>>n>>m;
  rep(i,1,n)rep(j,1,m)cin>>a[i][j];
  cout<<dfs(1,1);
}
int32_t main()
{
  ibs;cti;
  solve()
  ,cout<<"\n";
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

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


void solve(long long N){
    cout << N/2 + N%2 << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int n,k;
  cin>>n>>k;
  double ans = 0.0;
  vector<double> v;
  double tmp = (double)k;
  while(tmp > 1 - EPS) {
    v.push_back(tmp);
    tmp = (double)tmp / 2.0;
  }
  FOR(i,1,n+1) {
    if(i >= k) {
      ans += 1.0;
      continue;
    }
    int times = 0;
    for(auto x: v) {
      if (i < x) {
        times++;
      }
    }
    ans += 1.0 / pow(2, times);
  }
  ans *=  1.0 / (double)n;
  printf("%.15f\n",ans);

  



  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int  temp = max(a, b);
	if (temp <= 8)
		cout << "Yay!";
	else
		cout << ":(";
	return 0;
}

Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	string s;
	cin >> s;
	for(int i = 0; i < sz(s); i++)
		if((i % 2 && s[i] == 'R') || (i % 2 == 0 && s[i] == 'L')){
				cout << "No" << endl;
				return 0;
		}
	cout << "Yes" << endl;
	return 0;
}


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

#define endl '\n'

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

    int n,m; cin >> n >> m;
    int h[n];
    for (int i=0; i<n; i++) cin >> h[i];
    vector<int> adj[n];
    for (int i=0; i<m; i++){
        int u,v; cin >> u >> v; u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int ans = 0;
    for (int i=0; i<n; i++){
        bool ok = true;
        for (int x : adj[i]){
            if (h[x] >= h[i]){
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9156
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int a,b;
 
        while(true){
            a = sc.nextInt();
            b = sc.nextInt();
 
            if(a == 0 && b == 0)break;
 
            System.out.printf("%d %d\n", Math.min(a, b),Math.max(a, b));
        }
 
    }
}


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

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 123, MOD = 1e9 + 7;
int n, k;
ll p[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> k;
	for (int i = 1; i <= n + 1; i++) {
		p[i] = p[i - 1] + (i - 1);
	}
	ll ans = 0;
	for (int i = k; i <= n + 1; i++) {
		ll l = p[i];
		ll r = p[n + 1] - p[n + 1 - i];
		ans += (r - l + 1) % MOD;
		if (ans >= MOD) {
			ans -= MOD;
		}
	}
	cout << ans;
}


Measured memory_bytes: 5168
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 998244353;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int k; cin >> k;
  if (k==1) {
    cout << 1 << endl;
    cout << 1 << endl;
    return 0;
  }

  int n;
  if (k%4 == 0) {
    n = (k/4)*2;
  } else {
    n = ((k/4)+1)*2;
  }
  vector<int> vec(2*n);
  rep(i, 2*n) {
    vec.at(i) = i+1;
  }
  int cnt = 2*n;
  while(cnt > k) {
    vec.at(cnt-1) = vec.at(cnt-1-n);
    cnt--;
  }
  
  cout << n << endl;
  rep(i, n) {
    rep(j, n) {
      if (i%2 == 0) {
        cout << vec.at((i+j)%n) << ' ';
      } else {
        cout << vec.at((i+j)%n+n) << ' ';
      }
    }
    cout << '\n';
  }
}

Measured memory_bytes: 1280
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    ll a,b,c;
    ll k;
    cin>>a>>b>>c>>k;
    ll t=0;
    while(b<=a){
        b*=2;
        t++;
    }
    while(c<=b){
        c*=2;
        t++;
    }
    if(t>k){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define N 1050
int lcs(string X,string Y){
  int c[N+1][N+1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for(int i=0;i<=m;i++) c[i][0]=0;
  for(int j=1;j<=n;j++) c[0][j]=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(X[i]==Y[j]) c[i][j]=c[i-1][j-1]+1;
      else c[i][j]=max(c[i-1][j],c[i][j-1]);
      maxl=max(maxl,c[i][j]);
    }
  }
  return maxl;
}
int main(){
  int q;cin>>q;
  while(q--){
    string a,b;cin>>a>>b;
    cout<<lcs(a,b)<<endl;
  }
  return 0;
}



Measured memory_bytes: 7228
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
typedef vector<int> VI;
#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )


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

    vector<tuple<double, double, double>> zs;

    double x1, y1, x2, y2, x3, y3, xp, yp;
    while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
        double z1 = (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
        double z2 = (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
        double z3 = (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
        tuple<double, double, double> t(z1, z2, z3);
        zs.push_back(t);
    }

    for (auto z : zs) {
        if ((get<0>(z) > 0 && get<1>(z) > 0 && get<2>(z) > 0) || (get<0>(z) < 0 && get<1>(z) < 0 && get<2>(z) < 0)) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1228
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int s = stdIn.nextInt();

        int hours = s / 3600;
        int minutes = (s / 60) % 60;
        int seconds = s % 60;

        System.out.println(hours + ":" + minutes + ":" + seconds);
    }
}

Measured memory_bytes: 26064
import statistics
def resolve():
	n = int(input())
	a = list(map(int, input().split()))
	seq = []
	for i in range(1, n+1):
		seq.append(i-a[i-1])
	seq = sorted(seq)
	m = int(statistics.median(seq))
	ans = 0
	for i in seq:
		ans += abs(i-m)
	print(ans)
resolve()

Measured memory_bytes: 27240
from itertools import permutations
from math import factorial

N = int(input())
cities = [tuple(map(int, input().split())) for _ in range(N)]

dists = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(i + 1, N):
        dists[i][j] = dists[j][i] = (
            (cities[j][0] - cities[i][0]) ** 2 + (cities[j][1] - cities[i][1]) ** 2
        ) ** 0.5

total_dist = 0
for p in permutations(range(N)):
    for i in range(N - 1):
        total_dist += dists[p[i]][p[i + 1]]

print(total_dist / factorial(N))


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

int main() {
	multiset<int, greater<int>> ms; int temp;
	for (int i = 0; i < 10; i++) { cin >> temp; ms.insert(temp); }
	auto itr = ms.begin();
	for (int i = 0; i < 3; i++) { cout << *itr << endl; itr++; }
	return 0;
}


Measured memory_bytes: 3100
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    vector<int> a(3);
    rep(i, 0, 3) {
        cin >> a[i];
    }
    sort(all(a));
    cout << a[0] + a[1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int i;
	int n, m, x, y;
	int tmp;
    cin >> n >> m >> x >> y;
	vector<int> x_val;
    vector<int> y_val;

	for (i = 0; i < n; i++) {
		cin >> tmp;
		x_val.push_back(tmp);
	}
	for (i = 0; i < m; i++) {
		cin >> tmp;
		y_val.push_back(tmp);
	}

	sort(x_val.begin(), x_val.end());
	sort(y_val.begin(), y_val.end());

	if (x_val[n - 1] > y_val[0]) {
		cout << "War" << endl;
		return 0;
	} else {
		for (i = x_val[n - 1] + 1; i <= y_val[0]; i++) {
			if (x < i && y >= i) {
				cout<< "No War" << endl;
				return 0;
			}
		}		
	}

	cout << "War" << endl;
	return 0;
}


Measured memory_bytes: 256
lists=[]
emptylists=[]
numbers=int(input())

for nums in range(numbers+3):
    
    if nums<6:
        lists.append(int(nums))
         
    elif nums==6 or nums==36 or nums==216 or nums==1296 or nums==7776 or nums==46656:
        lists.append(1)
        
    elif nums==9 or nums==81 or nums==729 or nums==6561 or nums==59049:
        lists.append(1)
        
    else:
        power6=0
        power9=0
        for k in range(7):
            if 6**(k)< nums <6**(k+1):
                power6=k
                break   
                
        for j in range(6):
            if 9**(j) <nums< 9**(j+1):
                power9=j
                break
        add=min(min(lists[nums-6**(k)]+1 for k in range(0,power6+1)),min(lists[nums-9**(j)]+1 for j in range(0,power9+1)))
        lists.append(add)
print(lists[numbers])


Measured memory_bytes: 3992
/**
 * author: moririn_cocoa       
**/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

int main(void) {
  
  int A;
  int B;
  
  cin >> A;
  cin >> B;
  
  if ( A + B >= 10 ) {
    
    cout << "error" << endl;
  }
  
  else {
    
    cout << A + B << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      char c=s[i];
      for(int j=0;j<s.size();j++){
        if(j<i){
          if(t[i]==s[j]){
            cout<<"No"<<endl;
            return 0;
          }
        }
        if(s[j]==c){
          s[j]=t[i];
        }else if(s[j]==t[i]){
          s[j]=c;
        }
      }
    }
  }
  if(s==t)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 776
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    X+i+(i+1)+(i+2)+..
    
    X < n*(n+1)//2

    n*(n+1)//2-(n-1)*n//2 > n ?
    n//2(2) > n ? false
    """
    X = read_int()
    if X == 1:
        return 1
    low, high = 1, 10**9
    while high-low > 1:
        mid = low+(high-low)//2
        if mid*(mid+1)//2 >= X:
            high = mid
        else:
            low = mid
    if high*(high+1)//2 == X:
        return high
    return high


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 62032
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1e5+10;
char s[N];
int n,rt;
bool firstcheck(){
	if (s[1]=='0'||s[n]=='1') return false;
	for (int i=1;i<n;++i)
		if (s[i]!=s[n-i]) return false;
	return true;
}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("a.in","r",stdin);
#endif
	scanf("%s",s+1);
	n=strlen(s+1);
	if (!firstcheck()){printf("-1\n"); return 0;}
	rt=1;
	for (int i=1;i<n;++i){
		printf("%d %d\n",rt,i+1);
		if (s[i]=='1') rt=i+1;
	}
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <string.h>
int main(){
  int i,j,k,len,now1,now2,now3,count=0,box[1000]={0};
  char input[30001];
  
  scanf("%d",&len);
  scanf("%s",input);
  
  for(i=0;i<=9;i++){
    for(now1=0;now1<(len-2);now1++){
      if(input[now1]==('0'+i)){
        for(j=0;j<=9;j++){
          for(now2=(now1+1);now2<(len-1);now2++){
            if(input[now2]==('0'+j)){
              for(k=0;k<=9;k++){
                for(now3=(now2+1);now3<len;now3++){
                  if(input[now3]==('0'+k)){
                    box[(i*100+j*10+k)]=1;
                    break;
                  }
                }
              }
              break;
            }
          }
        }
        break;
      }
    }
  }
  
  for(i=0;i<1000;i++){
    if(box[i]!=0){
      count++;
    }
  }
  
  printf("%d",count);
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	int max = 0;
	int smax = 0;
	int maxi = 0;
	int smaxi = 0;
	rep(i,n) {
		if(a[i]>=max) {
			smax = max;
			smaxi = maxi;
			max = a[i];
			maxi = i;
		}
		else if(a[i] > smax) {
			smax = a[i];
			smaxi = i;
		}
	}
	rep(i,n) {
		if(i==maxi) print(smax);
		else print(max);
	}
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  bool can=false;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j==n){
        can=true;
        break;
      }
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split())) 
m = int(input())
t = list(map(int, input().split())) 

from collections import Counter

dc, tc = Counter(d), Counter(t)
ans = "YES"
for p in tc.keys():
    if tc[p] > dc[p]:
        ans = "NO"
 
print(ans)

Measured memory_bytes: 56800
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
struct card{
    char suit;
    int value;
};
void BubbleSort(card A[],const int N){
    int flag=1;
    for(int i=0;flag;++i){
        flag=0;
        for(int j=N-1;i<j;--j)
            if(A[j].value<A[j-1].value){
                swap(A[j],A[j-1]);
                flag=1;
            }
    }
}
void SelectionSort(card A[],const int N){
    for(int i=0;i<N;++i){
        int min=i;
        for(int j=i;j<N;++j){
            if(A[j].value<A[min].value){
                min=j;
            }
        }
        if(i!=min){
            swap(A[i],A[min]);
        }
    }
}
int main(void){
    int N;
    scanf("%d%*c", &N);
    card A[N],B[N];
    for(int i=0;i<N;++i){
        scanf("%c%d%*c",&A[i].suit,&A[i].value);
        B[i]=A[i];
    }
    BubbleSort(A, N);
    SelectionSort(B, N);
    for(int i=0;i<N;++i){
        if(i>0){
            putchar(' ');
        }
        printf("%c%d",A[i].suit,A[i].value);
    }
    putchar('\n');
    printf("Stable\n");
    int flag=1;
    for(int i=0;i<N;++i){
        if(i>0){
            putchar(' ');
        }
        printf("%c%d",B[i].suit,B[i].value);
        if(!(B[i].suit==A[i].suit && B[i].value==A[i].value)){
            flag = 0;
        }
    }
    putchar('\n');
    if(flag){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
    return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int ans = 999;
	for (int i = 0;i <= n - 3;++i) {
		int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
		ans = min(ans, abs(num - 753));
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long

int n;

template<class T>
T bist(T ok, T ng){
    auto isOK=[](T mid){
        if(int(mid*1.08)<=n)return true;
        else return false;
    };

    for(int i=0; i<100; i++){
        T mid=(ng+ok)/2;
        if(isOK(mid))ok=mid;
        else ng=mid;
    }
    return ok;
}

void solve(){
    cin>>n;
    int ans=bist(0,n+1);
    if(n!=int(ans*1.08)){
        cout<<":("<<endl;
    }else{
        cout<<ans<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
q = int(input())
M = [int(i) for i in input().split()]
cand = set()
l_A = len(A)

for i in range(2**l_A):
    guess = 0
    for j in range(l_A):
        if(i>>j & 1 == 1):
            guess += A[j]
    cand.add(guess)

for m in M:
    if(m in cand):
        print('yes')
    else:
        print('no')



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

int main()
{
	int a, b;
	cin >> a >> b;
	if ((a * b) % 2 == 1)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
    return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = n - 1; i >= 0; --i)


int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;

    map<char, int> c2i = {{'R', 0}, {'G', 1}, {'B', 2}};
    vector<ll> count(3, 0);
    for(char c : s){
        count.at(c2i.at(c))++;
    }

    ll ans = count.at(0) * count.at(1) * count.at(2);
    REP(i, n){
        for(ll j = i + 1; j < n; ++j){
            if(s.at(i) == s.at(j)){ continue; }
            const ll k = j + j - i;
            if(k < n && s.at(i) != s.at(k) && s.at(j) != s.at(k)){
                ans--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
using namespace std;
#include<string>
#include<cmath>
#include <map>
#include <unordered_map>
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e9;
#include<iterator>




void solve() {
	ll a, b, c, k; cin >> a >> b >> c >> k;
	fr(i, 0, k + 1) {
		if (b > a && c > b) {cout << "Yes"; return;}
		else if (b <= a)b *= 2;
		else if (c <= b)c *= 2;
		//cout << a << " " << b << " " << c << " ";
	}
	cout << "No";
}



int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif

	ll t, h = 1;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {
		//cout << "Case #" << h << ":\n";
		solve();
		//h++;
		//cout << '\n';
	}
	return 0;
}

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

uint64_t solve(int N)
{
    uint64_t res[87];
    res[0] = 2, res[1] = 1;

    for (int i = 2; i <= N; i++)
    {
        res[i] = res[i - 1] + res[i - 2];
    }

    return res[N];
}

int main()
{
    int N;
    cin >> N;
    cout << solve(N) << endl;
}

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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    if ((10 * g + b) % 4 == 0) {
        cout << "YES" << endl;
    } 
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<int,int>
#define iil pair<ll,ll>
#define se second
#define ld long double
#define mod 998244353
#define popcount __builtin_popcountll
#define x0 zxcxzcsacasd
#define x1 ghfghujfgfg
#define y0 olkjhdnncvcv
#define y1 bhvgrewm345345435
#define debug(x) std::cerr<<#x<<": "<<(x)<<'\n'
#define all(x) x.begin(), x.end()
using namespace std;
int n, k;
ll tree[1600010];
ll lazy[1600010];
void push(int pos, int l, int r){
	if(lazy[pos]==0)return;
	tree[pos] += lazy[pos]; // Update it
	tree[pos]%=mod;
	if(l != r) {
		lazy[pos*2] += lazy[pos]; // Mark child as lazy
		lazy[pos*2+1] += lazy[pos]; // Mark child as lazy
		lazy[2*pos]%=mod;
		lazy[2*pos + 1]%=mod;
	}
	lazy[pos] = 0;
}
void update(int pos, int l, int r, int st, int en, int v){
	if(l > en || st > r)return;
	push(pos, l, r);
	if(l>=st && r<=en){
		tree[pos]+=v;
		tree[pos]%=mod;
		if(l!=r){
			lazy[2*pos]+=v;
			lazy[2*pos + 1]+=v;
			lazy[2*pos]%=mod;
			lazy[2*pos + 1]%=mod;
		}
		return;
	}
	int md = (l+r)/2;
	update(2*pos, l, md, st, en, v);
	update(2*pos+1, md+1, r, st, en, v);
}
ll query(int pos, int l, int r, int tar){
	push(pos, l, r);
	if(l==r && l==tar)return tree[pos];
	int md = (l+r)/2;
	if(tar>=l && tar<=md)return query(2*pos, l, md, tar);
	return query(2*pos+1, md+1, r, tar);
}
void test_case(){
	scanf("%d%d", &n, &k);
	vector<ii>segs(k);
	for(int i=0;i<k;i++){
		int l, r;
		scanf("%d%d", &l, &r);
		segs[i] = {l, r};
	}
	update(1, 1, 2*n, 1 , 1, 1);
	for(int i=1;i<=n;i++){
		for(auto s:segs){
			int l = s.fi, r = s.se;
			ll value = query(1, 1, 2 * n, i);
			value%=mod;
			update(1, 1, 2 * n, i + l, i + r, value);
		}
	}
	cout<<query(1, 1, 2 * n, n)%mod<<endl;
}
int main(){
	int t = 1;
	// scanf("%d", &t);
	while(t--)test_case();
}


Measured memory_bytes: 19924
#include <stdio.h>
#include <math.h>

#define PI 3.14159265358979323846

int main(){
  double a,b,h,m;
  double l,degh,degm,deg,rad;

  scanf("%lf %lf %lf %lf",&a,&b,&h,&m);

  degm = 6.0 * m;
  degh = (60.0 * h + m) / 2.0;

  if(degm > degh){
    deg = degm - degh;

    if(deg >= 180){
      deg = 360 - deg;
    }
  }
  else{
    deg = degh - degm;
    if(deg >= 180){
      deg = 360 - deg;
    }
  }

  //printf("%f\n",deg);
  rad = deg * PI / 180.0;

  l = sqrt(pow(a,2.0) + pow(b,2.0) - 2*a*b*cos(rad));

  printf("%.20f\n",l);

  return 0;
}

Measured memory_bytes: 2596
#include<bits/stdc++.h>
#define int long long

using namespace std;


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

    int h, a;
    cin >> h >> a;
    cout << h / a + (h % a != 0);

    return 0;
}

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

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


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

using namespace std;
#define FOR(i, a, b) for (int i = (a), _##i = (b); i < _##i; ++i)
#define REP(i, a) for (int i = 0, _##i = (a); i < _##i; ++i)
typedef long long LL;

LL r,c;

int main(){
//	freopen("test.in","r",stdin);
	cin >> r >> c;
	if( r%3 == 0 || c%3 == 0 ) cout << "0" << endl;
	else{
		LL res = LLONG_MAX;
		LL s[3];
		//Cat doc
		res = min(res, r);
		s[0] = c/3*r;			
		s[1] =  (c - c/3)*(r/2+r%2);
		s[2] =  (c - c/3)*(r/2);
		sort(s,s+3);
		res = min(res, abs(s[2]-s[0]));
		s[0] = (c/3+1)*r;				
		s[1] =  (c - c/3-1)*(r/2+r%2);
		s[2] =  (c - c/3-1)*(r/2);
		sort(s,s+3);
		res = min(res, abs(s[2]-s[0]));
		
		res = min(res, c);		
		s[0] = (r/3)*c;				
		s[1] =  (r - r/3)*(c/2+c%2);
		s[2] =  (r - r/3)*(c/2);
		sort(s,s+3);
		res = min(res, abs(s[2]-s[0]));
		//Cat ngang
		s[0] = (r/3+1)*c;				
		s[1] =  (r - r/3-1)*(c/2+c%2);
		s[2] =  (r - r/3-1)*(c/2);
		sort(s,s+3);
		res = min(res, abs(s[2]-s[0]));
		cout << res << endl;
	}
	return 0;
}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)

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

const int baza = 1307, mod = 1e9 + 7, MAX = (1 << 18);

inline int add(int x, int y){
  x += y;
  if(x >= mod) return x - mod;
  return x;
}

inline int mul(ll x, ll y){
  return x * y % mod;
}

int n, mid;
string s;
point hesh[MAX][2];

int heshaj(int mask, int extra){
  int ret = 0;
  REP(i, mid){
    if( (mask & (1 << i)) == 0) continue;
    ret = add(mul(ret, baza), s[i + extra]);
  }
  return ret;
}

map<point, int> M[2];

int revHashaj(int mask, int extra){
  int ret = 0;
  for(int i = mid - 1; i >= 0; --i){
    if( (mask & (1 << i)) == 0) continue;
    ret = add(mul(ret, baza), s[i + extra]);
  }
  return ret;
}

void brut(int extra){
  REP(mask, (1 << mid)){
    if(!extra) hesh[mask][0].first = heshaj(mask, extra);
    else hesh[mask][1].first = revHashaj(mask, extra);
    int newMask = (1 << mid) - 1;
    newMask ^= mask;
    if(!extra) hesh[mask][0].second = revHashaj(newMask, extra);
    else hesh[mask][1].second = heshaj(newMask, extra);
    M[extra != 0][hesh[mask][extra != 0]] ++;
  }
}

int main(){
  cin >> n >> s;
  mid = n;
  brut(0); brut(mid);
  ll sol = 0;

  for(auto it : M[0]){
    sol += (ll)it.second * M[1][it.first];
  }
  cout << sol;
}


Measured memory_bytes: 53504
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  vector<int> c(n,1);
  rep(i,m){
    int a,b; cin >> a >> b; a--; b--;
    if(h[a]>h[b]){
      c[b]=0;
    } else if(h[a]<h[b]){
      c[a]=0;
    } else {
      c[a]=c[b]=0;
    }
  }
  int ans = 0;
  rep(i,n){
    if(c[i]==1) ans++;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO

    int n;
    cin >> n;

    int a;
    while(n--) {
        cin >> a;
        if(a % 2 == 0) {
            if((a % 3 != 0) && (a % 5) != 0) return cout << "DENIED\n", 0;
        }
    }
    cout << "APPROVED";

}









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

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

string s;
int t[21][17];
int py[20],px[20];
int m=0,sy,sx;

struct state{
  int y,x,S,cost;
};


state calc(int dir,state s){
  int T=0;

  int ny=s.y+dy[dir],nx=s.x+dx[dir];

  while(1){
    if(t[ny][nx]==-1)break;
    T|=(1<<t[ny][nx]);
    ny+=dy[dir];
    nx+=dx[dir];
  }

  if(T==0)s.cost=-2;
  s.y=ny;
  s.x=nx;
  s.cost++;
  s.S-=T;
  return s;
}

int solve(){

  queue< state > Q;
  Q.push((state){sy,sx,(1<<m)-1,0});

  while(!Q.empty()){
    state s=Q.front();Q.pop();
    int S=s.S;

    for(int i=0;i<m;i++)
      if(S>>i&1)
	t[py[i]][px[i]]=i;

    for(int i=0;i<8;i++){
      state next=calc(i,s);
      if(next.cost==-1)continue;
      if(next.y<1)continue;
      if(next.y>19){
	return s.cost+1;
      }
      if(next.y==19){
	if(1<=next.x&&next.x<=15)return s.cost+1;
	else continue;
      }
      if(next.x<1)continue;
      if(next.x>15)continue;
      Q.push(next);
    }
    for(int i=0;i<m;i++)
      if(S>>i&1)
	t[py[i]][px[i]]=-1;
  }
  return -1;
}

int main(){
  for(int i=0;i<21;i++)
    for(int j=0;j<17;j++)
      t[i][j]=-1;

  for(int i=0;i<19;i++){
    cin>>s;
    for(int j=0;j<15;j++){
      if(s[j]=='O'){
	sy=i+1,sx=j+1;
      }else if(s[j]=='X'){
	py[m]=i+1;
	px[m]=j+1;
	m++;
      }
    }
  }
  cout<<solve()<<endl;
  return 0;
}

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

int main(){
    int n;
    long long int C;
    cin >> n >> C;

    vector<long long int> x(n+2), v(n+2);
    x[0] = 0;
    x[n+1] = C;
    for(int i=1; i<=n; i++){
        cin >> x[i] >> v[i];
    }

    vector<long long int> vc(n+1), va(n+1);
    for(int i=1; i<=n; i++){
        vc[i] = vc[i-1] + v[i];//     v[0]=0,   v[1], v[1]+v[2],   ...
        va[i] = va[i-1] + v[n+1-i];// v[n+1]=0, v[n], v[n]+v[n-1], ...
    }

    vector<long long int> g_ac(n+1), h_ac(n+2), g_ca(n+1), h_ca(n+2);// h[i] = optimal c-endpoint for each ac-endpoint i
    // g_ac[0] = 0 = 0 - 0, // g_ca[0] = 0 = 0 - 0
    // h_ac[1] = 0, // h_ca[1] = 0
    int rec_ac = 0;
    int rec_ca = 0;
    for(int i=1; i<=n; i++){
        g_ac[i] = max(g_ac[i-1], vc[i] - x[i]);
        g_ca[i] = max(g_ca[i-1], vc[i] - 2 * x[i]);
        
        if(g_ac[i-1] < vc[i] - x[i]) rec_ac = i;
        h_ac[i+1] = rec_ac;
        if(g_ca[i-1] < vc[i] - 2 * x[i]) rec_ca = i;
        h_ca[i+1] = rec_ca;
    }

    long long int ans = 0;// 0 -> 0 (exit without eating)
    for(int j=1; j<=n+1; j++){
        long long int test_ac = vc[h_ac[j]] + va[n+1-j] - 2 * (C - x[j]) - x[h_ac[j]];
        long long int test_ca = vc[h_ca[j]] + va[n+1-j] - 2 * x[h_ca[j]] - (C - x[j]);
        ans = max({ans, test_ac, test_ca});
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let x, n = Scanf.sscanf (read_line ()) "%d %d" ( fun x n -> x, n)
let lst = Str.split (Str.regexp " ") (read_line ())
          |> List.map int_of_string

let () = 
        let (ans, _) = 
                (
                        if lst = [] then
                                (x, 0)
                        else
                                let set = 
                                        (
                                                let max = List.max lst in
                                                let pset = List.range (-1) `To (max + 1)
                                                           |> Set.of_list in
                                                let sset = Set.of_list lst in
                                                        Set.diff pset sset 
                                        ) in
                                let lst = Set.to_list set in
                                        List.map (fun elmnt -> (elmnt, abs (elmnt - x))) lst 
                                        |> List.sort (fun (el1, diff1) (el2, diff2) -> compare diff1 diff2)
                                        |> List.hd
                ) in
                Printf.printf "%d\n" ans


Measured memory_bytes: 5544
package main

import "fmt"

func main() {
	m := map[rune]int{}
	var S string
	fmt.Scanf("%s", &S)
	for _, s := range S {
		m[s]++
	}

	for _, v := range m {
		if v != 2 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


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

using namespace std;

int main(void)
{
    string S;
    cin >> S;
    int l = S.size();
    int m = l / 2;
    char c = S[m];
    int K;
    int p;
    for (p = 1; p <= m; p++) {
        if (S[m-p] != c || S[m+p-1+l%2] != c) {
            break;
        }
    }
    p--;
    K = m + p + l % 2;
    cout << K << endl;
    return 0;
}


Measured memory_bytes: 512
MOD = 998244353
n, m, k = map(int, input().split())
 
fact = [0]*(n+1)
fact[0] = 1
for i in range(1, n+1):
    fact[i] = fact[i-1]*i % MOD
 
invfact = [0]*(n+1)
for i in range(n+1):
    invfact[i] = pow(fact[i], MOD-2, MOD)
 
 
def nCk(n, k):
    return fact[n]*invfact[k]*invfact[n-k]
 
 
ans = 0
for i in range(k+1):
    ans += m*pow(m-1, n-1-i, MOD)*nCk(n-1, i)
    ans %= MOD
print(ans)

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

int main() {
    int a,b;

    scanf("%d%d",&a,&b);
    
    if(a < b){
        for(int i=0;i<b;i++){
            printf("%d",a);
        }
    }
    else {
        for(int i=0;i<a;i++){
            printf("%d",b);
        }
    }
    printf("\n");
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
 
const int MAX_N = 100000, INF = 1000000000;
int n, k, w[MAX_N + 1], lb = 0, ub = INF, mid;
 
bool judge(int border){
    int sum = 0, i = 0;
    for(int count = k; count > 0 && i < n; count--){
        while(sum + w[i] <= border && i < n){
            sum += w[i];
            i++;
        }
        sum = 0;
    }
    if(i < n){
        return 0;
    }
    return 1;
}
 
int main() {
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &w[i]);
    }
     
    while(ub - lb > 1){
        mid = (ub + lb) / 2;
         
        if(judge(mid)){
            ub = mid;
        } else{
            lb = mid;
        }
    }
     
    printf("%d\n", ub);

    return 0;
}

Measured memory_bytes: 1412
def resolve():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]
    T = []
    last = [0 for _ in range(26)]
    
    def calc(day, typ):
        score = S[day][typ]
        for j in range(26):
            if j == typ:
                continue
            score -= C[j]*(day+1-last[j])
        return score

    for d in range(D):
        maxscore, maxcontest = -float("inf"), None
        for typ in range(26):
            _score = calc(d, typ)
            if maxscore < _score:
                maxscore = _score
                maxcontest = typ
        T.append(maxcontest)
        last[typ] = d+1
    
    [print(t+1) for t in T]



if __name__ == '__main__':
    resolve()

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a, b;

signed main() {
	cin >> a >> b;
	if (a+b==15) cout << '+' << ln;
	else if (a*b==15) cout << '*' << ln;
	else cout << 'x' << ln;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    int N,A,a;
    cin >> N >> A;

    a = N % 500;

    if(a <= A){
        cout << "Yes" << endl;

    }else{
        cout << "No" << endl;
    }
        return 0;
}




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

using namespace std;

const int maxn = 1e5 + 10;
int a[maxn];
int n, b = 0, c = 0, x = 1;

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int j = 0; j < n - 1; j++)
	{
		if(a[j] < a[j + 1])
		{
			if(c > 0)
			{
				c = 0;
				x++;
			}
			else
			{
				b++;
			}
		}
		if(a[j] > a[j + 1])
		{
			if (b > 0)
			{
				b = 0;
				x++;
			}
			else
			{
				c++;
			}
		}
	}
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int a;
    cin >> a;
    string s;
    cin >> s;
    if(a<3200){
        s = "red";
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>

int main(){
    int n,i,sum=0;
    scanf("%d",&n);

    i=n;
    while(i>=1){
        sum+=(i%10);
        i/=10;
    }
    if(n%sum==0){printf("Yes\n");}
    else{printf("No\n");}

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>

using namespace std;
int n, m, x, y;
int cnt[108000];
bool red[108000];
int main(){
  cin >> n >> m;
  for(int i = 1;i <= n;i++){
    cnt[i] = 1;
  }
  red[1] = true;
  for(int i = 0;i < m;i++){
    cin >> x >> y;
    if(red[x])red[y] = true;
    cnt[x]--;
    cnt[y]++;
    if(cnt[x] == 0)red[x] = false;    
  }
  int res = 0;
  for(int i = 1;i <= n;i++)res += red[i];
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;


int main(){
    int x; cin >> x;
    while(x>0){
        x-=1000;
    }
    cout << -x << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans = 0;

  for (int i = 0; i<s.length(); i++){
    if(s[i] != s[s.length() - i - 1]){
      ans++;
    }
  }
  cout << ans/2 << "\n";
  return 0;
}

Measured memory_bytes: 256