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

int main() {
    int N;

    cin >> N;

    double p[N + 1];

    for (int i = 1; i <= N; i++) {
        cin >> p[i];
    }

    vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
    dp[1][1] = p[1];
    dp[1][0] = 1 - p[1];

    for (int i = 2; i <= N; i++) {
        for (int j = 0; j <= i; j++) {
            if (j > 0) {
                dp[i][j] += dp[i - 1][j - 1] * p[i];
            }

            dp[i][j] += dp[i - 1][j] * (1 - p[i]);
        }
    }

    double res = 0;
    int S = N / 2 + 1;

    for (int i = S; i <= N; i++) {
        res += dp[N][i];
    }

    printf("%.12f\n", res);
}

Measured memory_bytes: 70656
#include <stdio.h>
int main(void){
    // Your code here!
    int x;
    
    
    scanf("%d", &x);
    if((x<-40) || (x>40)){
        printf("incorrect temperature.\n");
        return -1;
    }
    
    if(x>=30){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 1644
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 120
typedef long long ll;

int main(){
  ll sum;
  int N,A[110000];
  cin>>N;
  A[0]=0;
  A[N+1]=0;
  for(int i=1;i<=N;i++){
    cin>>A[i];
  }
  for(int i=0;i<=N;i++){
    sum+=abs(A[i+1]-A[i]);
  }

  for(int i=1;i<=N;i++){
    cout<<sum-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])<<endl;
  }
  
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define INF 9999999
#define LINF 99999999999
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}

bool cmp(pair<ll,ll> l, pair<ll,ll> r){
	return l.first<r.first;
}

 
int main(void){
	ll k,n,tmp;
	cin>>n>>k;
	vector<ll> h;
	rep(i,n){
		cin>>tmp;
		h.push_back(tmp);
	}
	sort(h.begin(),h.end());
	int i=0;
	ll ans=LINF;
	while(true){
		int j=i+k-1;
		if(j==n){
			break;
		}
		ans = min(ans,h[j]-h[i]);
		i++;
	}
	cout<<ans<<endl;

	return 0;
}

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

int n,arr[4][4],arr1[11];

int main()
{
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            cin>>arr[i][j];

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr1[i];
        for(int j=0;j<3;j++)
            for(int k=0;k<3;k++)
                if(arr[j][k]==arr1[i])
                    arr[j][k]=0;

    }

    if((arr[0][0]==0 and arr[0][1]==0 and arr[0][2]==0)||(arr[1][0]==0 and arr[1][1]==0 and arr[1][2]==0) || (arr[2][0]==0 and arr[2][1]==0 and arr[2][2]==0) || (arr[0][0]==0 and arr[1][0]==0 and arr[2][0]==0) || (arr[0][1]==0 and arr[1][1]==0 and arr[2][1]==0) || (arr[0][2]==0 and arr[1][2]==0 and arr[2][2]==0) || (arr[0][0]==0 and arr[1][1]==0 and arr[2][2]==0) || (arr[0][2]==0 and arr[1][1]==0 and arr[2][0]==0))
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
S = input().strip()
T = input().strip()
rS = []
if len(S) >= len(T):
    for i in range(len(S)):
        rS.append(S[i])
    for i in range(len(rS) - len(T), -1, -1):
        eq = True
        for j in range(len(T)):
            if not(rS[i + j] == T[j] or rS[i + j] == "?"):
                eq = not(eq)
                break
        if eq:
            for j in range(len(T)):
                rS[i + j] = T[j]
            break
    if eq:
        for i in range(len(rS)):
            if rS[i] == "?":
                rS[i] = "a"
        for i in range(len(rS)):
            print(rS[i], end='')
        print("")
    else:
        print("UNRESTORABLE")
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
// ITP1_7_B How many ways?
import java.io.*;

public class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         while (true) {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }

   private static int combination(int n, int x) {
      int count = 0;
      for (int i = 1; i <= n; i++) {
         for (int j = 1; j < i; j++) {
            for (int k = 1; k < j; k++) {
               if (i + j + k == x)
                  count++;
            }
         }
      }

      return count;
   }
}

Measured memory_bytes: 18592
def roll(dice,dir)
  case dir
  when "N" then dice[0],dice[1],dice[5],dice[4] = dice[1],dice[5],dice[4],dice[0]
  when "S" then dice[0],dice[1],dice[5],dice[4] = dice[4],dice[0],dice[1],dice[5]
  when "E" then dice[0],dice[2],dice[5],dice[3] = dice[3],dice[0],dice[2],dice[5]
  when "W" then dice[0],dice[2],dice[5],dice[3] = dice[2],dice[5],dice[3],dice[0]
  end
  dice
end

d1 = gets.split(" ").map{|i| i.to_i}
d2 = gets.split(" ").map{|i| i.to_i}

yn = false    
for i in 1..6
  d = Marshal.load(Marshal.dump(d2))
  case i
  when 2 then d = roll(d,"S")
  when 3 then d = roll(roll(d,"W"),"S")
  when 4 then d = roll(d,"N")
  when 5 then d = roll(roll(d,"E"),"S")
  when 6 then d = roll(roll(d,"S"),"S")
  end
  next if d[1] != d1[1]
  next if d[4] != d1[4]
  for j in 1..4
    d = roll(d,"W")
    yn = (d == d1)
    break if yn
  end
  break if yn
end

puts(yn ? "Yes" : "No")

Measured memory_bytes: 8724
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int x, y;
    cin >> x >> y;

    bool c = false;
    rep(i, 101) rep(j, 101) {
        if (i+j == x && i*2+j*4 == y) c = true;
    }
    yns(c);
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>
#include <cassert>

using namespace std;

using i64 = long long int;
using u64 = std::uint_fast64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 INF = std::numeric_limits<i64>::max();
constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
constexpr i64 MOD = 1000000007;
constexpr i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

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

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

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

vector<int64_t> dijkstra(Graph G, int64_t s) {
    vector<int64_t> dist(G.size(), INF);
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.emplace(0, s);
    while (!que.empty()) {
        int64_t cost, idx;
        tie(cost, idx) = que.top(); que.pop();
        if (dist[idx] < cost) continue;
        for (edge e : G[idx]) {
            int64_t next_cost = cost + e.cost;
            if (dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

int main() {
    i64 a, b, c;
    cin >> a >> b >> c;
    i64 cnt = 0;
    for (int i = 0; i < 100000; ++i) {
        if (a % 2 || b % 2 || c % 2) {
            cout << i << endl;
            return 0;
        }
        i64 ta, tb, tc;
        ta = (b + c) / 2;
        tb = (a + c) / 2;
        tc = (a + b) / 2;
        a = ta;
        b = tb;
        c = tc;
    }
    cout << -1 << endl;
}

// 4 12 20
// 2 6 10
// 8 12 16
// 4 6 8
// 10 12 14
// 5 6 7

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{
	int a, b, c;
	cin >> a >> b >> c;
	if((a == b && b != c) || (a == c && c != b) || (b == c && a != b)) cout << "Yes";
	else cout << "No";
}
 
 
 
 
int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{      
        var initial = Console.ReadLine();
        var N = int.Parse(initial.Split(' ')[0]);
        var K = int.Parse(initial.Split(' ')[1]);
        var Q = int.Parse(initial.Split(' ')[2]);
        
        if(K>Q)
        {
          for(int i = 0; i<N; i++){         
          	Console.WriteLine("Yes");
          }
          return;
        }   
        
        var answers = new int[N];
     	for(int i = 0; i<Q; i++)
        {
          answers[int.Parse(Console.ReadLine())-1]+=1;
        }
       
        for(int i = 0; i<N; i++){         
          Console.WriteLine(K-Q + answers[i] > 0 ?"Yes":"No");
        }      
	}
}

Measured memory_bytes: 15584
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

class UnionFind{
  vi p,r;
  int s;
public:
  UnionFind(int n):p(n,-1),r(n,0),s(n){ }
  int find(int x){ return (p[x]<0)?x:(p[x] = find(p[x])); }
  bool same(int x,int y){return find(x)==find(y);}
  void unite(int x,int y){
    x = find(x); y = find(y);
    if(x==y)return;
    s--;

    if(r[x] < r[y])p[x] = y;
    else p[y] = x;
    if(r[x] == r[y])r[x]++;
  }
  int size() { return s; };
};

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

  map<int,int> cnt;
  vi a(n);
  int x = 0;
  rep(i,n) {
    cin >> a[i];
    x ^= a[i];
    cnt[a[i]]++;
  }
  cnt[x]++;

  vi b(n);
  rep(i,n) {
    cin >> b[i];
    cnt[b[i]]--;
    if (cnt[b[i]]<0) {
      cout << -1 << endl;
      return 0;
    }
  }

  int num = 0;
  set<int> ida, idb;
  rep(i,n) {
    if (a[i] != b[i]) {
      ida.em(a[i]);
      idb.em(b[i]);
      num++;
    }
  }
  if (num==0) {
    cout << 0 << endl;
    return 0;
  }
  vi ids(all(ida));

  UnionFind uf(ids.size());
  rep(i,n) {
    if (a[i] != b[i]) {
      int ai = distance(ids.begin(), lower_bound(all(ids),a[i]));
      int bi = distance(ids.begin(), lower_bound(all(ids),b[i]));
      uf.unite(ai, bi);
      cerr << ai << " " << bi << endl;
    }
  }
  cerr << uf.size() << endl;
  if (idb.count(x)) {
    num--;
  }
  cerr << num << endl;

  cout << num + uf.size() << endl;
}


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

using namespace std;
typedef long long ll;

int dp[3001][3001] = {0};
int main()
{
    string s, t;
    cin >> s >> t;

    for (int i = 1; i <= s.length(); i++)
    {
        for (int j = 1; j <= t.length(); j++)
        {
            if (s[i - 1] == t[j - 1])
            {
                dp[i][j] = max(dp[i - 1][j - 1] + 1, dp[i - 1][j]);
                dp[i][j] = max(dp[i][j], dp[i][j - 1]);
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    string ans = "";
    int idx_i = s.length();
    int idx_j = t.length();
    while (true)
    {
        if (dp[idx_i][idx_j] == 0)
        {
            break;
        }

        if (dp[idx_i - 1][idx_j - 1] + 1 == dp[idx_i][idx_j] && s[idx_i - 1] == t[idx_j - 1])
        {
            ans = t[idx_j - 1] + ans;
            idx_i--;
            idx_j--;
        }
        else
        {
            if (dp[idx_i][idx_j - 1] == dp[idx_i][idx_j])
            {
                idx_j--;
            }
            else
            {
                idx_i--;
            }
        }
    }
    cout << ans << endl;

    // system("pause");
}

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

  int main() {
    string S;
    cin >> S;
    if (S == "AAA") {
      cout << "No" << endl;
    }
    else if (S == "BBB") {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }




Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    L = SI()
    b = 1
    ans = 1
    for s in L[-1::-1]:
        if s == '1':
            ans = (ans*2 + b) % MOD
        b = (b * 3) % MOD
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 42092
#include <stdio.h>

int main(){
	int i, j, k, a[3][3],n,c=0;
	for(i=0;i<3;i++) for(j=0;j<3;j++) scanf("%d",&a[i][j]);
	scanf("%d",&n);
	int b[n];
	for(i=0;i<n;i++) scanf("%d",&b[i]);
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			for(k=0;k<n;k++){
				if(b[k]==a[i][j]){
					a[i][j]=0;
					break;
				}
			}
		}
	}
	for(i=0;i<3;i++){
		if((a[i][0]==a[i][1])&&(a[i][1]==a[i][2])) c=1;
	}
	for(i=0;i<3;i++){
		if((a[0][i]==a[1][i])&&(a[1][i]==a[2][i])) c=1;
	}
	if((a[0][0]==a[1][1])&&(a[1][1]==a[2][2])) c=1;
	if((a[0][2]==a[1][1])&&(a[1][1]==a[2][0])) c=1;
	
	if(c==1) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = nextInt();
        String s = next();
        String[] strArray = s.split("");

        int Answer = 1;

        for (int i = 0; i < n - 1; i++) {
        	if (!strArray[i].equals(strArray[i + 1])) {
        		Answer += 1;
        	}
        }

        println(Answer);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

}


Measured memory_bytes: 32532
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,k;
int arr[2005];

void solve()
{
	cin>>n>>k;rep(i,0,n)cin>>arr[i];
	
	int b,a,ans=0;
	
	rep(i,0,n)
	{
		b=0,a=0;
		rep(j,0,i)if (arr[i]>arr[j])b++;
		rep(j,i+1,n)if (arr[i]>arr[j])a++;
		
		ans = (ans + (((k*(k+1))/2)%MOD)*a + (((k*(k-1))/2)%MOD)*b)%MOD;
	}
	cout<<ans<<"\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 	
 	#ifdef local
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 	int t=1;
    //cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
	}
	
    #ifdef local
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
using namespace std;
int main(){
	string s,t;for(int i,n,f;cin>>s,s!="0";){
		queue<string>q;
		map<string,int>d;d[s]=1;
		for(q.push(s);q.size();){
			s=q.front();q.pop();n=s.length();
			for(f=i=0;i<n-1;i++)if(s[i]!=s[i+1]){
				t=s;t[i]=t[i+1]=(char)('r'+'g'+'b'-s[i]-s[i+1]);f++;
				if(!d[t])d[t]=d[s]+1,q.push(t);
			}
			if(!f){cout<<d[s]-1<<endl;goto N;}
		}
		cout<<"NA"<<endl;N:;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  // s to t
  for (auto i = sy; i < ty; i++) cout << "U";
  for (auto i = sx; i < tx; i++) cout << "R";

  // t to s
  for (auto i = ty; i > sy; i--) cout << "D";
  for (auto i = tx; i > sx; i--) cout << "L";

  // s to t
  cout << "L";
  for (auto i = sy; i <= ty; i++) cout << "U";
  for (auto i = sx-1; i < tx; i++) cout << "R";
  cout << "D";

  // t to s
  cout << "R";
  for (auto i = ty; i >= sy; i--) cout << "D";
  for (auto i = tx+1; i > sx; i--) cout << "L";
  cout << "U";

  return 0;
}


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

int main(){
    long long n, m; cin >> n >> m;
    long long ans=0;
    if (n*2<=m){//cがsの2倍以上あれば
        ans+=n;
        m-=n*2;
        ans+=m/4;
    } else {//なかったら
        ans+=m/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>

#define MAX 20000
using namespace std;



int main(){
  int n[MAX];
  int count=0;
  for(int i=0;i<MAX;i++){
    std::cin >> n[i];
    count++;
    if(n[i]==0)break;
  }
  for(int i=1;i<count;i++){
    std::cout << "Case " <<i<<": "<<n[i-1]<< '\n';
  }
}

Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <climits>
#include <queue>

using namespace std;

#define int long long int

// int MOD = 1e9 + 7;

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int A, B;
	cin>>A>>B;
	if(A < 10 and A > 0){
		if(B<10 and B > 0){
			cout<<A*B<<endl;
			return 0;
		}
	}
	cout<<-1<<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;
  while(a>0&&c>0){
    c-=b;
    
    if(c<=0)break;
    a-=d;
  }
  if(a>0) cout<<"Yes";
  else cout<<"No";
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int[] i = new int[3];

		i[0] = sc.nextInt();
		i[1] = sc.nextInt();
		i[2] = sc.nextInt();

		Arrays.sort(i);

		System.out.print(i[2]*10+i[1]+i[0]);

	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;

int sqrtN;
int N, Q;
vector<int> data, backet;

int get(int l, int r) {
    int res = INT_MAX;
    for (int i = l; i <= r; ++i) {
        if (i % sqrtN == 0 && i + sqrtN <= r) {
            res = min(res, backet[i / sqrtN]);
            i += sqrtN - 1;
        } else {
            res = min(res, data[i]);
        }
    }
    return res;
}

void update(int p, int val) {
    data[p] = val;
    backet[p / sqrtN] = INT_MAX;
    for (int i = (p / sqrtN) * sqrtN; i - (p / sqrtN) * sqrtN < sqrtN; ++i) {
        backet[p / sqrtN] = min(backet[p / sqrtN], data[i]);
    }
}

void debug() {
    cerr << "data = ";
    for (int e : data) cerr << e << " ";cerr << endl;
    cerr << "backet = ";
    for (int e : backet) cerr << e << " ";cerr << endl;
}

int main() {
    scanf("%d%d", &N, &Q);
    sqrtN = sqrt(N);
    data.resize(N, INT_MAX);
    backet.resize(sqrtN + 2, INT_MAX);
    while (Q--) {
        int c, x, y;
        //debug();
        scanf("%d%d%d", &c, &x, &y);
        if (c) {
            cout << get(x, y) << endl;
        } else {
            update(x, y);
        }
    }
}

Measured memory_bytes: 3428
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    map<ll,ll> m1,m2;
    int n;
    cin >> n;
    rep(i,n){
        ll a;
        cin >> a;
        m1[i+a]++;
        m2[i-a]++;
    }
    ll ans = 0;
    for(auto u : m1){
        ans += u.second*m2[u.first];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 37760
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int a,b,c; cin>>a>>b>>c;
  if(a==b&&b==c&&!(a%2)){
    cout << -1 << endl; return 0;
  }
  int ans = 0;
  while(!(a%2||b%2||c%2)){ // 最大最小の二分探索 O(logM)
    int a1 = a; int b1 = b; int c1 = c;
    a = (b1+c1)/2; b = (c1+a1)/2; c = (a1+b1)/2;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,c,k;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  for(int i=0;i<k;i++){
      if(a>=b){
        b*=2;
      }
      else if(b>=c)c*=2;
    
     if(c>b&&b>a){
      printf("Yes");
      return 0;
    }
}
  printf("No");
  return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

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

using namespace std;

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

    vector <ll> sousaCnt(N+1,N+1);

    sousaCnt[0] = 0;
    for(ll i = 0; i<=N; ++i)
    {
        for(ll j = 1; j + i <= N; j*=6)
        {
            sousaCnt[i + j] = min(sousaCnt[i + j],sousaCnt[i] + 1);
        }
        for(ll j = 1; j + i <= N; j*=9)
        {
            sousaCnt[i + j] = min(sousaCnt[i + j],sousaCnt[i] + 1);
        }
    }

    cout << sousaCnt[N] << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N,M;
    cin>>N>>M;
    vector<ll> a(N);
    vector<ll> mod2(N);
    rep(i,N){
        cin>>a[i];
        mod2[i] = (a[i]/2) % 2;
    }
    sort(all(mod2));
    rep(i,N-1){
        if(mod2[i] != mod2[i+1]){
            cout<<0<<endl;
            return 0;
        }
    }
    ll l = a[0]/2;
    rep(i,N){
        a[i] /= 2;
        l = lcm(l,a[i]);
    }
    //cerr<<l<<endl;
    rep(i,N){
        if(l > a[i] && l / a[i] % 2 == 0){
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans = 0;
    if((M/l) % 2 == 1){
        ans = M / l / 2 + 1;
    }
    else{
        ans = M / l / 2;
    }
    cout<<ans<<endl;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


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

    ll r = 0, w = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') r++;
        else w++;
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'W'){
            if(0 < r) {
                r--;
                ans++;
            }
        }else{
            r--;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = 0;

		for(int i = 1;i <= c; i++) {
			if(c % i == 0 && (a <= i && b >= i)) {
				x++;
			}
		}

		System.out.println(x);
	}

}


Measured memory_bytes: 26408
#include <iostream>
#define llint long long

using namespace std;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int x, y, ans = 0;
	cin >> x >> y;
	if(x <= 3) ans += (4-x)*100000;
	if(y <= 3) ans += (4-y)*100000;
	if(x == 1 && y == 1) ans += 400000;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;

int main() {
  int N,W;
  cin >> N >> W;
  vector<ll> weight(110);
  vector<ll> value(110);
  vector<vector<ll>> dp(110, vector<ll>(100100));
  
  for(int i = 0;i<N;i++){
    cin >> weight[i];
    cin >> value[i];
  }

  
  for(int i = 0;i<N;i++){
   for(int sum_w = 0;sum_w <= W;sum_w++){
     if(sum_w - weight[i] >= 0){
       chmax(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i]);
     }
     chmax(dp[i+1][sum_w],dp[i][sum_w]);

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


Measured memory_bytes: 87296
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [n, m, a, b] = input[0].split(" ").map((x: string): number => +x);

type Tile = "." | "<" | ">" | "v" | "^";
const map: Array<Array<Tile>> = new Array(n).fill([]).map(() => new Array(m).fill("."));

const _a = Math.max(0, a - (n % 2 === 1 ? Math.floor(m / 2) : 0));
const _b = Math.max(0, b - (m % 2 === 1 ? Math.floor(n / 2) : 0));

const l = Math.floor(n / 2) * Math.floor(m / 2);
const is_odd = n % 2 === 1 && m % 2 === 1;

console.error(input[0]);
console.error(_a, _b);
console.error(_a - _a % 2 + _b - _b % 2 + _a % 2 * 2 + _b % 2 * 2, l);

let flg_yes = false;
// ^<>
// v.^
// <>v
// の並びを使うかどうか
let need_ex = false;
if (is_odd) {
	if (_a + _b <= l * 2) {
		flg_yes = true;
		if (_a - _a % 2 + _b - _b % 2 + _a % 2 * 2 + _b % 2 * 2 > l * 2) {
			need_ex = true;
		}
	}
}
else {
	if (_a - _a % 2 + _b - _b % 2 + _a % 2 * 2 + _b % 2 * 2 <= l * 2) {
		flg_yes = true;
	}
}
console.error(flg_yes, need_ex);
if (!flg_yes) {
	console.log("NO");
}
else {
	let blocks = l;
	let ra = a;
	let rb = b;
	if (n % 2 === 1) {
		for (let i = 0; i + 1 < m && ra > 0; i += 2) {
			// for (let i = m - 3; i >= 0 && ra > 0; i -= 2) {
			map[n - 1][i] = "<";
			map[n - 1][i + 1] = ">";
			ra -= 1;
		}
	}
	if (m % 2 === 1) {
		for (let i = 0; i + 1 < n && rb > 0; i += 2) {
			// for (let i = n - 3; i >= 0 && rb > 0; i -= 2) {
			map[i][m - 1] = "^";
			map[i + 1][m - 1] = "v";
			rb -= 1;
		}
	}
	let x = 0;
	let y = 0;
	if (need_ex) {
		while (ra > 1 || rb > 1) {
			if (ra > 1) {
				map[y][x] = "<";
				map[y][x + 1] = ">";
				ra -= 1;
				if (ra > 0) {
					map[y + 1][x] = "<";
					map[y + 1][x + 1] = ">";
					ra -= 1;
				}
			}
			else {
				map[y][x] = "^";
				map[y + 1][x] = "v";
				rb -= 1;
				if (rb > 0) {
					map[y][x + 1] = "^";
					map[y + 1][x + 1] = "v";
					rb -= 1;
				}
			}
			if (x + 3 < m) {
				x += 2;
			}
			else if (y + 3 < n) {
				y += 2;
				x = 0;
			}
			else {
				break;
			}
		}
		map[n - 3][m - 3] = "<";
		map[n - 3][m - 2] = ">";
		map[n - 3][m - 1] = "^";
		map[n - 2][m - 3] = "^";
		map[n - 2][m - 2] = ".";
		map[n - 2][m - 1] = "v";
		map[n - 1][m - 3] = "v";
		map[n - 1][m - 2] = "<";
		map[n - 1][m - 1] = ">";
	}
	else {
		while (ra > 0 || rb > 0) {
			if (ra > 0) {
				map[y][x] = "<";
				map[y][x + 1] = ">";
				ra -= 1;
				if (ra > 0) {
					map[y + 1][x] = "<";
					map[y + 1][x + 1] = ">";
					ra -= 1;
				}
			}
			else {
				map[y][x] = "^";
				map[y + 1][x] = "v";
				rb -= 1;
				if (rb > 0) {
					map[y][x + 1] = "^";
					map[y + 1][x + 1] = "v";
					rb -= 1;
				}
			}
			if (x + 3 < m) {
				x += 2;
			}
			else if (y + 3 < n) {
				y += 2;
				x = 0;
			}
			else {
				break;
			}
		}
	}
	console.log("YES");
	for (const row of map) {
		console.log(row.join(""));
	}
}


Measured memory_bytes: 32100
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int a[1000000];

int main() {
	int n;
	scanf("%d", &n);
	FOR (i, n)
		scanf("%d", &a[i]);
	int ret = 0;
	int idx = 0;
	int incdec = 0;
	while (idx < n) {
		ret++;
		int j = idx + 2;
		while (j < n) {
			if (a[idx] < a[j - 1] && a[j - 1] > a[j])
				break;
			if (a[idx] > a[j - 1] && a[j - 1] < a[j])
				break;
			j++;
		}
		idx = j;
	}
	cout << ret << endl;
	return 0;
}

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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	string s;
	cin>>s;

	for(auto x:s)
	{
		if(x=='7')
		{
			cout<<"Yes";
			return;
		}
	}

	cout<<"No";
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

Measured memory_bytes: 3600
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

template<typename T>
class LazySegmentTree{
//区間更新・区間最小クエリ
public:
    int n,sz;
    T monoid=0;
    vector<T> v,lazy;

    LazySegmentTree():n{0},sz{0}{}
    LazySegmentTree(int n_in):n{n_in},sz{1}{
        while(sz<n) sz*=2;
        v.assign(2*sz-1,monoid);
        lazy.assign(2*sz-1,monoid);
    }

    void init_u(){
        for(int i=sz-2;i>=0;i--)
        v[i]=min(v[2*i+1],v[2*i+2]);
    }

    void eval(int k,int l,int r){
        if(lazy[k]==monoid) return;
        if(r-l>1){
            lazy[2*k+1]=lazy[k];
            lazy[2*k+2]=lazy[k];
        }
        v[k]=lazy[k];
        lazy[k]=monoid;
    }

    //update(a,b,x,0,0,s.sz); xは代入する値
    void update(int a,int b,T x,int k,int l,int r){
        eval(k,l,r);
        if(b<=l || r<=a) return;
        if(a<=l && r<=b){
            lazy[k]=x;
            eval(k,l,r);
        }
        else{
            update(a,b,x,2*k+1,l,(l+r)/2);
            update(a,b,x,2*k+2,(l+r)/2,r);
            v[k]=min(v[2*k+1],v[2*k+2]);
        }
    }

    //query(a,b,0,0,s.sz);
    T query(int a,int b,int k,int l,int r){
        if(r<=a || b<=l) return monoid;
        eval(k,l,r);
        if(a<=l && r<=b) return v[k];
        T vl=query(a,b,k*2+1,l,(l+r)/2);
        T vr=query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }

    T operator[](const int& idx) const{
        return v[idx+sz-1];
    }
};

int main(){
    int n,k; cin>>n>>k;
    vector<int> a(n,0);
    rep(i,n) cin>>a[i];
    LazySegmentTree<int> seg{300001};
    rep(i,n){
        int cnt=seg.query(max(0,a[i]-k),min(300001,a[i]+k+1),0,0,seg.sz);
        seg.update(a[i],a[i]+1,cnt-1,0,0,seg.sz);
    }
    cout<<-seg.query(0,300001,0,0,seg.sz)<<endl;
}

Measured memory_bytes: 12772
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    int n;
    cin>>n;
    vector<map<char,int>> mp;
    vector<vector<int>> ch(n,vector<int>(26));
    rep(i,0,n){
        string s;
        cin>>s;
        for(int c=0;c<s.size();c++){
            ch[i][s[c]-'a']++;
        }
    }
    string ans;
    rep(i,0,26){    // 英字26字分回す
        int minv=INF;
        rep(j,0,n){ // 文字列の数だけ
            minv=min(minv,ch[j][i]); // 各文字列の各英字の最小個数
        }
        if(minv==0)continue;
        string tmp(minv,i+'a');
        ans+=tmp; // 英字の個数分末尾に追加していく
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

# sys.stdin = open('a1.in')


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


def read_str_list():
    return input().split()


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


def read_str():
    return input()


def main():
    a, b, c, d = read_int_list()
    res = max(a * b, c * d)
    print(res)


main()


Measured memory_bytes: 2940
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)
        
        self.par = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        tmpx,tmpy=x,y
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
            self.par[tmpy]  =tmpx

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            self.par[tmpx]  = tmpy
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]



N,M=map(int,input().split())
tree=UnionFind(N)

state=[-1]*(N+1)
for i in range(M):
    x,y,z=map(int,input().split())
    tree.Unite(x,y)

memo=[0]*(N+1)

ans=0
for i in range(1,N+1):
    if memo[tree.Find_Root(i)]==0:
        ans+=1
        memo[tree.Find_Root(i)]+=1

print(ans)


Measured memory_bytes: 10052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC126C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();

            var n = nums[0];

            // 1の時を考える
            var sum = 0.0;
            foreach (var i in Enumerable.Range(1, n))
            {
                if (i < nums[1])
                {
                    var p = Math.Ceiling(Math.Log(nums[1] / (double)i, 2));
                    sum += Math.Pow(0.5, p);
                }
                else
                {
                    sum += 1;
                }
            }

            sum /= n;

            Console.WriteLine("{0:0.0000000000}", sum);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX/2e5

void solve(ll index){
	ll n,a,b;
	cin >> n >> a >> b;
	cout << min(n*a,b) << ln;
}

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) solve(i+1);
    return 0;
}

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

vector<vector<char>> e2(int a, int j, vector<vector<char>> c){
  for(int i=0;i<a;i++)c.at(i).erase(c.at(i).begin()+j);
  return c;
}


int main() {
  int a,b;
  cin>>a>>b;
  vector<vector<char>> c(a,vector<char>(b));
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      cin>>c.at(i).at(j);
    }
  }
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      if(c.at(i).at(j)=='#')break;
      else if(j==b-1){
        c.erase(c.begin()+i);
        a-=1;
        i-=1;
      }
    }
  }
  for(int j=0;j<b;j++){
    for(int i=0;i<a;i++){
      if(c.at(i).at(j)=='#')break;
      else if(i==a-1){
        c=e2(a,j,c);
        b-=1;
        j-=1;
      }
    }
  }
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
    cout << c.at(i).at(j);
    }
    cout << endl;
  }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

template<class T> void warshall_floyd(vector<T>& G){
    int N = G.size();
    REP(k,N){
        REP(i,N){
            REP(j,N){
                G[i][j] = min(G[i][j], G[i][k]+G[k][j]);
            }
        }
    }
}


int main() {
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N,vector<int>(N,INF));
    REP(i,N){
        G[i][i] = 0;
    }
    REP(i,M){
        int a,b,c; cin >> a >> b >> c;
        a--;
        b--;
        G[a][b] = c;
        G[b][a] = c;
    }

    vector<vector<int>> G_origin(G);
    warshall_floyd(G);
    int ans = 0;
    REP(i,N){
        FOR(j,i+1,N){
            if(G[i][j]!=G_origin[i][j] && G_origin[i][j]!=INF) ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3692
import java.util.Scanner;
    
    public class Main{
    public static void main(String args[]){
    int N;
    int sum=0;
    	Scanner scan = new Scanner(System.in);
    N=scan.nextInt();
    for(int i=0;i<N;i++){
    	sum=sum+(i+1);
    }
    System.out.println(sum);
    }
}

Measured memory_bytes: 9936
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ul=unsigned long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

void solve(){
    int n;
    cin>>n;
    vector<ul> a(n);
    set<ul> base;
    for(auto&i:a) cin>>i;
    string s;
    cin>>s;
    ifr(i,n){
        for_each(base.rbegin(),base.rend(),[&](auto&v){
            chmin(a[i],a[i]^v);
        });
        if(a[i]){
            if(s[i]=='0') base.insert(a[i]);
            else{
                cout<<1<<'\n';
                return;
            }
        }
    }
    cout<<0<<'\n';
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t;
    cin>>t;
    fr(i,t) solve();
}

Measured memory_bytes: 3636