akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)

int main(){
    int Q;
    scanf("%d", &Q);

    bool prm[101010];
    rep(i, 100001) prm[i] = true;
    for(int i = 2; i <= 100000; i += 2) prm[i] = false;
    prm[0] = false; prm[1] = false; prm[2] = true;
    for(int i = 3; i * i <= 100000; i += 2){
        if(prm[i])
            for(int j = 3*i; j < 100000; j += 2*i) 
                prm[j] = false;
    }

    int num[101010] = {0};
    for(int i = 1; i < 100001; i++) {
        if(i % 2 == 1 && prm[i] && prm[(i+1)/2]) num[i]++;
        num[i] += num[i-1];
    }

    rep(i, Q){
        int le, ri;
        scanf("%d%d", &le, &ri);
        printf("%d\n", (num[ri] - num[le-1]));
    }
}

Measured memory_bytes: 2224
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
typedef pair<ll, pii> T;

struct Dijk{
  // solve(s, g) or solve(s).
  // show d and p.
  typedef pair<ll,int> pli;
  int n;
  vector<vpll>E;
  vl d;
  vi p;
  void init(const vector<vpll>&e){n=sz(e);E=e;FOR(i,0,n)sort(rng(E[i]));d.resize(n);p.resize(n);}
  void o(int S,int G){FOR(i,0,n){d[i]=(i==S)?0:linf;p[i]=-1;}priority_queue<pli,vector<pli>,greater<pli>>Q;Q.push(pll(0,S));pli t;vector<bool>F;FOR(i,0,n)F.pb(0);ll f;int c=0,s;while(!Q.empty()){t=Q.top();Q.pop();f=t.fi;s=t.se;if(F[s])continue;F[s]=1;c++;if(c==n||s==G)break;each(itr,E[s]){ll ff=itr->fi,ss=itr->se;if((!F[ff])&&(f+ss<d[ff])){d[ff]=f+ss;p[ff]=s;Q.push(pll(f+ss,ff));}}}}
  ll solve(int s,int g){o(s,g);return d[g];}
  void add(ll a, ll b, ll l){E[a].pb(mp(b, l));}
  void solve(int s){o(s,-1);}
};

int n, a, b;
ll DP[300][300], l, r;
vector<T> v;
Dijk dijk;
vector<vpll>E;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    FOR(j, 0, n){
      DP[i][j] = linf;
      cin >> a;
      if(j <= i) continue;
      v.pb(mp(a, mp(i, j)));
    }
  }
  E.resize(n);
  dijk.init(E);
  ll ans = 0;
  sort(rng(v));
  each(itr, v){
    l = itr->fi;
    a = itr->se.fi;
    b = itr->se.se;
    r = dijk.solve(a, b);
/*
    FOR(i, 0, n){
      cout << i << ":: ";
      each(itrr, dijk.E[i]) cout << "(" << itrr->fi << "," << itrr->se << "), ";
      cout << endl;
    }
    show(l);
    show(a);
    show(b);
    show(r);
    cout << endl;
*/
    if(r < l){
      cout << -1 << endl;
      return 0;
    }
    if(r > l){
      ans += l;
      dijk.add(a, b, l);
      dijk.add(b, a, l);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1784
fun main(args: Array<String>) {
    val X = readLine()!!.toLong()

    var yokin: Long = 100
    var counter = 0
    while (true) {
        counter++
        yokin = (yokin * 1.01).toLong()

        if (X <= yokin) {
            break
        }
    }

    println(counter)
}


Measured memory_bytes: 34384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ctime>
using namespace std;

void solve()
{
    int N,x; cin>>N>>x;
    vector<int> a(N+1),s(N+1,0);
    for (int i = 0; i < N; ++i) cin>>a[i];
    long long ans = 0;
    for (int i = 0; i < N-1; ++i){
        if(a[i]+a[i+1]>x){
            ans+=a[i]+a[i+1]-x;
            a[i+1]=max(0,x-a[i]);
        }
    }
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    // input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <bitset>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 + 10, MOD = 1e9 + 7;



int main() {
    fastInp;

    ll n;
    cin >> n;
    map<ll, ll>cnt;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
            cnt[a]++;
    }

    vector<ll> mx;
    for (auto cur : cnt) {
        if (cur.second >= 2) mx.push_back(cur.first);
        if (cur.second >= 4) mx.push_back(cur.first);
    }

    sort(mx.rbegin(), mx.rend());

    if (mx.size() <= 1) {
        cout << "0";
    }
    else {
        cout << mx[0] * mx[1];
    }
   
    return 0;
}


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

 using namespace std;

 int main() {
   string O, E;
   int i;

   cin >> O >> E;

   if (O.length() == E.length()) {
     for (i = 0; i < O.length(); i++) {
       cout << O.at(i) << E.at(i);
     }
     cout << endl;
   }

   else {
     for (i = 0; i < E.length(); i++) {
       cout << O.at(i) << E.at(i);
     }
     cout << O.at(O.length() - 1) << endl;
   }
 }


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;

int n, m, mtemp, x[10], y[10];

struct line{
  int len[9], right[8];
};

int det(int x1, int y1, int x2, int y2) {
  return x1 * y2 - x2 * y1;
}

line l[51];
bool ok[51];

bool same(line l1, line l2) {
  bool flag = true;
  for (int i = 0; i < m - 1 && flag; i++) if (l1.len[i] != l2.len[i]) flag = false;
  for (int i = 0; i < m - 2 && flag; i++) if (l1.right[i] != l2.right[i]) flag = false;
  if (flag) return true;
  flag = true;
  for (int i = 0; i < m - 1 && flag; i++) if (l1.len[i] != l2.len[m - 2 - i]) flag = false;
  for (int i = 0; i < m - 2 && flag; i++) if (l1.right[i] == l2.right[m - 3 - i]) flag = false;
  if (flag) return true;
  return false;
}

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    for (int i = 0; i <= n; i++) {
      scanf("%d", &mtemp);
      for (int j = 0; j < mtemp; j++) scanf("%d%d", &x[j], &y[j]);
      if (i == 0) m = mtemp;
      else if (m != mtemp) { ok[i] = false; continue; }
      else ok[i] = true;
      for (int j = 0; j < mtemp - 1; j++) {
        if (x[j] == x[j + 1]) l[i].len[j] = abs(y[j + 1] - y[j]);
        else l[i].len[j] = abs(x[j + 1] - x[j]);
      }
      for (int j = 0; j < mtemp - 2; j++) {
        if (det(x[j] - x[j + 1], y[j] - y[j + 1], x[j + 2] - x[j + 1], y[j + 2] - y[j + 1]) > 0)
          l[i].right[j] = 1;
        else l[i].right[j] = -1;
      }
    }
    for (int i = 1; i <= n; i++) if (ok[i] && same(l[0], l[i])) printf("%d\n", i);
    printf("+++++\n");
  }
}



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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

#define endl '\n'
#define MAX

typedef long long ll;
typedef pair<int,int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;


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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	const ll mod = 1e9 + 7;
	
	int n, k;
	cin >> n >> k;
	
	vector<int> a(n + 1);
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	
	vector<vector<ll>> dp(2, vector<ll>(k + 1));
	
	dp[0][0] = 1;
	for(int j = 1; j <= k; j++)
		dp[0][j] = (dp[0][j] + dp[0][j - 1]) % mod;
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= k; j++){
			
			int hi = j;
			int lo = max(0, j - a[i]);
			
			ll x = 0;
			if(lo)
				x = (dp[(i + 1) % 2][hi] + mod - dp[(i + 1) % 2][lo - 1]) % mod;
			else
				x = dp[(i + 1) % 2][hi];
			dp[i % 2][j] = x;
		}
		
		for(int j = 1; j <= k; j++)
			dp[i % 2][j] = (dp[i % 2][j] + dp[i % 2][j - 1]) % mod;
	}
	
	if(k)
		cout << (dp[n % 2][k] + mod - dp[n % 2][k - 1]) % mod << endl;
	else
		cout << dp[n % 2][k] << endl;

	return 0;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    String[] s = str[0].split("");
    String[] t = str[1].split("");
    String ans = "";
    for (int i=0; i<n; i++){
      ans = ans + (s[i] + t[i]);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21332
//============================================================================
// Name        : ProjG.cpp
// Author      : Yong Kiat
// Version     :
// Copyright   : By Algotae.
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>

using namespace std;

int main() {
	int N, W;
	cin >> N >> W;

	int weights[N];
	int values[N];
	for (int i = 0; i < N; i++) {
		cin >> weights[i] >> values[i];
	}

	int dp[100001];
	fill(dp, dp + 100001, W + 1);

	int res = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 100000 - values[i]; j >= 0; j--) {
			dp[j + values[i]] = min(dp[j + values[i]], dp[j] + weights[i]);

			if (dp[j] + weights[i] <= W) {
				dp[j + values[i]] = min(dp[j + values[i]], dp[j] + weights[i]);
				res = max(res, j + values[i]);
			}
		}

		dp[values[i]] = min(dp[values[i]], weights[i]);
		res = max(res, values[i]);
	}

	cout << res;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

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

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

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

    long long int a, b, c, k, ans=0;
    cin >> a >> b >> c >> k;
    if (k>=a) {
        ans+=a;
        k-=a;
        if (k>=b) {
            k-=b;
            if (k>=0)
                ans-=k;
        }
    }
    else {
        cout << k;
        return 0;
    }
    cout << ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string N;
  cin >> N;
  bool ok = false;
  for (ll i = 0; i < 3; ++i) {
    if (N.at(i) == '7') {
      ok = true;
    }
  }
  if (ok) {
    cout << "Yes" << "\n";
  }
  else {
    cout << "No" << "\n";
  }
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll gcd(ll x, ll y) {
    if (x < y) {
        return gcd(y, x);
    }
    if (y == 0) return x;
    return gcd(y, x % y);
}
int main() {
    ll a, b;
    cin >> a >> b;
    //cout << gcd(a, b) << endl;
    ll x = gcd(a, b);
    ll div = 2;
    ll ret = 1;
    while((x) && (div <= 1000000)) {
        if (x % div == 0) ret++;
        while (x % div == 0) {
            x /= div;
        }
        div++;
    }
    if (x > 1000000) {
        ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
 
using namespace std;
 
long long h[100005],n;
long long dp[100005];
long long mn(int i)
{
    if(i == n)
        return 0;
    if(i > n)return 1e9;
    if(dp[i] != -1)return dp[i];
 
    return dp[i] = min(abs(h[i] - h[i+1]) + mn(i+1), abs(h[i] - h[i+2]) + mn(i+2));
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>h[i];
    memset(dp,-1,sizeof(dp));
    cout<<mn(1)<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
using ll = long long;
using namespace std;
using P = pair<int, int>;

int main(){
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;
    if(V <= W) cout << "NO" << endl;
    else if (abs(A-B) <= T*(V-W)) cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 3624
//04
#include<iostream>
#include<algorithm>

using namespace std;

struct edge{
  int a,b,f;
  edge(int aa,int bb,int ff){
    a=aa;
    b=bb;
    f=ff;
  }
  edge(){};
};

int main(){
  for(int c,n,m,s,ds;cin>>c>>n>>m>>s>>ds,c|n|s|m|ds;){
    edge e[500];
    for(int i=0;i<m;i++){
      int a,b,f;
      cin>>a>>b>>f;
      e[i]=edge(a,b,f);
    }
    int d[101][11];
    fill_n(d[0],101*11,1<<29);
    d[s][c]=0;
    for(int l=0;l<n;l++){
      for(int i=0;i<m;i++){
	for(int j=0;j<2;j++){
	  int s=e[i].a,t=e[i].b;
	  if(j){
	    swap(s,t);
	  }
	  for(int k=0;k<=10;k++){
	    d[t][k]=min(d[t][k],d[s][k]+e[i].f);
	    if(k){
	      d[t][k-1]=min(d[t][k-1],d[s][k]+e[i].f/2);
	    }
	  }
	}
      }
    }
    cout<<*min_element(d[ds],d[ds+1])<<endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define f first
#define s second
unordered_map<char,vector<string>> adj;
vector<ll> vis(100005,0);
vector<ll> p(100005,0);
ll c[100005];
/*void dfs(ll node,ll len)
{
	if(len==n)
	{
		ans++;
		return;
	}
	for(auto str:adj[node])
		dfs(str[0],len+1);
}*/
int main()
{
  float d,t,s;
  cin>>d>>t>>s;
  float time=d/s;
  if(time<=t)
      cout<<"Yes";
    else
      cout<<"No";

}

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

using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
using Tuple = tuple<int, int, int>;

const double PI=3.1415926535897932;

int main() {
    ll n,m; cin >> n >> m;
    vector<ll> a(n);
    rep(i, m) cin >> a[i];

    ll sum = 0;
    rep(i, m) sum += a[i];

    ll asobi = n - sum;

    if(asobi < 0) {
        cout << -1 << endl;
    } else {
        cout << asobi << endl;
    }

    return 0;

}

Measured memory_bytes: 11180
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
int M = 100000;
int dx[4] = {0,-1,0,1};
int dy[4] = {1,0,-1,0};

int main(){
  int H,W;
  cin >> H >> W;
  char a[H][W];
  int dis[H][W];
  bool checked[H][W];
  queue<p> q;

  for(int i=0;i<H;i++){
  	for(int j=0;j<W;j++){
  		cin >> a[i][j];
  		checked[i][j] = false;
  	}
  }

  for(int i=0;i<H;i++){
  	for(int j=0;j<W;j++){
  	   if(a[i][j]=='#'){
  	   	  dis[i][j] = 0;
          q.push(make_pair(i,j));
          checked[i][j] = true;
  	   }else{
          dis[i][j] = M;
       }
  	}
  }

  while(!q.empty()){
    int i = q.front().first;
    int j = q.front().second;
    q.pop();
    for(int k=0;k<4;k++){
      if(0<=i+dy[k] && i+dy[k]<H && 0<=j+dx[k] && j+dx[k]<W && checked[i+dy[k]][j+dx[k]]==false){
        q.push(make_pair(i+dy[k],j+dx[k]));
        checked[i+dy[k]][j+dx[k]] = true;
        dis[i+dy[k]][j+dx[k]] = min(dis[i][j]+1, dis[i+dy[k]][j+dx[k]]);
      }
    }
  }
  

  int ans = 0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans = max(ans, dis[i][j]);
    }
  }
  cout << ans <<endl;

  return 0;
}



Measured memory_bytes: 14352
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader r = new InputReader(System.in);
		long[] arr = new long[3];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = r.nextInt();
		}
		Arrays.sort(arr);
		for (int i = 0; i < arr.length; i++) {
			if (arr[i] % 2 == 0) {
				System.out.println(0);
				return;
			}
		}
		System.out.println(arr[0] * arr[1]);
	}

	static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader(FileReader stream) {
			reader = new BufferedReader(stream);
			tokenizer = null;
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;
			}
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 7764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  ll a,b,c,d,e,f,g;
  cin>>a>>b>>c>>d>>e>>f>>g;

  ll ans=b;

  if(a==0) ans+=(d/2)*2+(e/2)*2;  
  else if(d==0) ans+=(a/2)*2+(e/2)*2;  
  else if(e==0) ans+=(a/2)*2+(d/2)*2;  
  else if(a%2==1&&d%2==1&&e%2==1) ans+=(a/2)*2+(d/2)*2+(e/2)*2+3;
  else if(a%2==0&&d%2==1&&e%2==1) ans+=(a/2)*2+(d/2)*2+(e/2)*2+1;
  else if(a%2==1&&d%2==0&&e%2==1) ans+=(a/2)*2+(d/2)*2+(e/2)*2+1;
  else if(a%2==1&&d%2==1&&e%2==0) ans+=(a/2)*2+(d/2)*2+(e/2)*2+1;
  else ans+=(a/2)*2+(d/2)*2+(e/2)*2;

  cout << ans << endl;
}

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


    ll nck(ll n, ll k){
    
    ll p=1000000007;
    ll p2;
    p2=p-2;
    vector <int> r(35);
    vector <ll> r2(36);

    rep(j,35){
        r[j]=(p2>>j)&1;
    }

    ll ans;
    ans=1;

    if (k!=0){
    rep(i,k-1){
        
        
        r2[0]=i+2;
        rep(j,35){
           
            r2[j+1]=(r2[j]*r2[j])%p;
            if(r[j]==1){
            ans*=r2[j];
            ans=ans%p;
            }
        }
    }
    

   

    rep(i,k){
        ans*=n-i;
        ans=ans%p;
    }
    }
    


    return ans;
}




int main(){
    ll x,y,a,b;
    cin >> x >> y;
    int k;
    k=0;
    if((2*y-x)%3!=0 or (2*x-y)%3!=0){
        k=1;
    }
    ll m;
    a=2*y-x;
    b=2*x-y;

    if(a<0 or b<0){
        k=2;
    }
    a/=3;
    b/=3;
    m=min(a,b);
    

    ll ans;
    
    if(k==0){
        ans=nck(a+b,m);
    }
    if(k==1 or k==2){
        cout << 0 << endl;
    }
    else{
    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
using ll = long long int;
const ll maxs = 1e5+5;

vector<vector<ll>> adj(maxs);
ll dp[maxs],ind[maxs];
bool vis[maxs];

void dfs(ll cur)
{
	vis[cur] = true;
    for(auto ch : adj[cur]) {
		if(dp[ch] < dp[cur] + 1) {
			dp[ch] = dp[cur] + 1;
		}
		ind[ch]--;
		if(ind[ch] == 0)
			dfs(ch);
    }
}

int main()
{
    IOS;
    ll n,m;
    cin >> n >> m;

    while(m--) {
        ll u,v;
        cin >> u >> v;
        adj[u].pb(v);
        ind[v]++;
    }
    
    for(ll i=1;i<=n;i++) {
		if(!vis[i] and ind[i] == 0)
			dfs(i);
	}

    ll mx = 0;
    for(ll i : dp)
        mx = max(mx,i);
    cout << mx;

    return 0;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll oo = 0x3f3f3f3f3f3f3f3f;
int main(){
	ll n,W; cin >> n >> W;
	vector<ll> w(n), v(n);
	for(ll i = 0; i < n; i++) cin >> w[i] >> v[i];
	ll V = accumulate(begin(v),end(v),0LL);
	vector<vector<ll>> dp(n, vector<ll>(V+1, oo));
	dp[0][0] = 0;
	dp[0][v[0]] = w[0];
	for(ll i = 1; i < n; i++) for(ll j = 0; j <= V; j++){
		dp[i][j] = dp[i-1][j];
		if(j - v[i] >= 0) dp[i][j] = min(w[i] + dp[i-1][j - v[i]], dp[i][j]);
	}
	ll res;
	for(res = V; res >= 0; res--) if(dp[n-1][res] <= W){
		cout << res << endl;
		break;
	}
}

Measured memory_bytes: 79488
#include <iostream>

using namespace std;

using ll = long long;

ll gcd(int a, int b) {
    return b?gcd(b, a%b):a;
}

int main() {
    ll x, y;
    while(cin >> x >> y) {
        ll g = gcd(x, y);
        cout << g << " " << x/g*y << endl;
    }
}


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

using namespace std;

using ll = long long;

bool is_prime(int n) {
    if (n % 2 == 0) return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

vector<int> divisor(int n) {
    vector<int> res;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

map<int, int> prime_factor(int n) {
    map<int, int> res;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

vector<int> sieve(int n) {
    vector<int> res;
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (!is_prime[i]) continue;
        res.emplace_back(i);
        for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> d = divisor(m);
    int ans = 1;
    for (int x : d) {
        if (m / x >= n) ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    string s;
    int day;
    cin >> s;
    if(s == "SAT"){
        day = 1;
    }else if(s == "FRI"){
        day = 2;
    }else if(s == "THU"){
        day = 3;
    }else if(s == "WED"){
        day = 4;
    }else if(s == "TUE"){
        day = 5;
    }else if(s == "MON"){
        day = 6;
    }else if(s == "SUN"){
        day = 7;
    }
    cout << day << endl;
}

Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let h: usize = sc.read();
    let w: usize = sc.read();
    let mut edges = vec![];
    for _ in 0..n {
        let r = sc.read::<usize>() - 1;
        let c = sc.read::<usize>() - 1;
        let a: usize = sc.read();
        edges.push((a, r, c + h));
    }

    edges.sort();
    edges.reverse();
    let mut ans = 0;
    let mut uf = UnionFind::new(h + w);
    for (v, r, c) in edges.into_iter() {
        let r = uf.find(r);
        let c = uf.find(c);
        if r == c {
            let edges = uf.edge_count[r];
            let size = uf.sizes[r];
            if edges + 1 <= size {
                uf.edge_count[r] += 1;
                ans += v;
            }
        } else {
            let edges = uf.edge_count[r] + uf.edge_count[c];
            let size = uf.sizes[r] + uf.sizes[c];
            if edges + 1 <= size {
                uf.unite(r, c);
                ans += v;
            }
        }
    }

    println!("{}", ans);
}

pub struct UnionFind {
    parent: Vec<usize>,
    sizes: Vec<usize>,
    edge_count: Vec<usize>,
    size: usize,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {
            parent: (0..n).map(|i| i).collect::<Vec<usize>>(),
            sizes: vec![1; n],
            edge_count: vec![0; n],
            size: n,
        }
    }

    pub fn find(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let px = self.parent[x];
            self.parent[x] = self.find(px);
            self.parent[x]
        }
    }

    pub fn unite(&mut self, x: usize, y: usize) -> bool {
        let parent_x = self.find(x);
        let parent_y = self.find(y);
        if parent_x == parent_y {
            return false;
        }

        let (large, small) = if self.sizes[parent_x] < self.sizes[parent_y] {
            (parent_y, parent_x)
        } else {
            (parent_x, parent_y)
        };

        self.parent[small] = large;
        self.sizes[large] += self.sizes[small];
        self.sizes[small] = 0;

        self.edge_count[large] += self.edge_count[small] + 1;
        self.edge_count[small] = 0;

        self.size -= 1;
        return true;
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 15480
n = gets.chomp.to_i
h_s = gets.split()
h_max = h_s[0].to_i
ryokan = 1
for i in 1..(n-1)
  if h_s[i].to_i >= h_max
    h_max = h_s[i].to_i
    ryokan += 1
  end
end
puts ryokan


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

int main()
{
	string S,T;
	int a[26][26]={};
	
	cin >> S >> T;
	
	for(int i=0;i<S.size();i++)
		a[S[i]-'a'][T[i]-'a']=1;
	
	for(int i=0;i<26;i++)
	{
		int cnt=0;
		for(int j=0;j<26;j++)
			cnt+=a[i][j];
		if(cnt>1)
		{
			cout << "No" << endl;
			return 0;
		}
		cnt=0;
		for(int j=0;j<26;j++)
			cnt+=a[j][i];
		if(cnt>1)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 776
n = int(input())
x = n // 3
y = n // 5
z = n // 15
x = x * (x + 1) // 2
y = y * (y + 1) // 2
z = z * (z + 1) // 2
sum = n * (n + 1) // 2
print(sum - x * 3 - y * 5 + z * 15)

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


int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double len;

    len = sqrt(pow(A * cos(M_PI/6.0 * H + M_PI/360.0 * M) - B* cos(M_PI / 30.0 * M),2) + pow(A * sin(M_PI/6.0 * H + M_PI/360.0 * M) - B* sin(M_PI / 30.0 * M),2));

    cout << fixed << setprecision(15) << len << endl;
}

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

int main() 
{
	int a, b ,c , d, a1, a2;
	cin>>a>>b>>c>>d;
	a1=a*b;
	a2=c*d;
	if(a1>a2)
	{
		cout<<a1;
	}
	else if(a1==a2)
	{
		cout<<a1;
	}
	else
	{
		cout<<a2;
	}
	
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io;
use std::f64;

/// ミンコフスキー距離を計算する関数。
/// n > 100のとき、inf扱いして別計算する
fn minkov(a: &Vec<f64>, b: &Vec<f64>, n: i32) -> f64 {
    assert_eq!(a.len(), b.len());

    let z_iter = a.iter().zip(b.iter());
    if n < 100 {
        let mut dis = 0.0;
        for (x, y) in z_iter {
            dis += (x-y).abs().powi(n);
        }
        dis.powf(1.0/ n as f64)
    } else {
        let mut mx = f64::MIN;
        for (x, y) in z_iter {
            let d = (x-y).abs();
            if mx < d {
                mx = d;
            }
        }
        mx
    }
}

fn main() {
    let sin = io::stdin();

    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let _n = buf.trim().parse::<u32>().unwrap();

    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let x = buf.split_whitespace()
        .map(|v| v.parse::<f64>().unwrap())
        .collect::<Vec<f64>>();

    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let y = buf.split_whitespace()
        .map(|v| v.parse::<f64>().unwrap())
        .collect::<Vec<f64>>();

    let r_1 = minkov(&x, &y, 1);
    let r_2 = minkov(&x, &y, 2);
    let r_3 = minkov(&x, &y, 3);
    let r_inf = minkov(&x, &y, 1000);

    println!("{:.6}", r_1);
    println!("{:.6}", r_2);
    println!("{:.6}", r_3);
    println!("{:.6}", r_inf);
}



Measured memory_bytes: 5172
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
using namespace std;
long H;
long a[500001];
void maxHeapify(long i){
	long l = 2 * i;
	long r = 2 * i + 1;
	long largest = i;
	if (l <= H && a[l] > a[largest]) largest = l;
	if (r <= H && a[r] > a[largest]) largest = r;
	if (largest != i){
		swap(a[i], a[largest]);
		maxHeapify(largest);
	}
}
void buidMaxHeap(){
	for (long i = H / 2; i >= 1; --i) maxHeapify(i);
}
int main(){
	scanf("%ld", &H);
	for (long i = 1; i <= H; ++i) scanf("%ld",&a[i]);
	buidMaxHeap();
	for (long i = 1; i <= H; ++i) cout << ' ' << a[i];
	cout << '\n';
}

Measured memory_bytes: 5112
N=int(input())
l=[]
d={}
ans=0
for i in range(N):
  s=list(str(input()))
  s.sort()
  l.append(s) 
for s in l:
  s=''.join(s)
  if s in d:
    ans+=d[s]
    d[s]+=1
  else:
    d[s]=1
print(ans)

Measured memory_bytes: 39040
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

#include <iostream>
using i64 = long long;
template<i64 M> struct modint { i64 a;
  constexpr modint(const i64 x = 0): a((x%M+M)%M){}
  constexpr i64 value() const { return a; }
  constexpr modint inv() const { return this->pow(M-2); }
  constexpr modint pow(i64 r) const {
    modint ans(1); modint aa = *this;
    while(r) { if(r & 1) ans *= aa; aa *= aa; r >>= 1; }
    return ans;
  }
  constexpr modint& operator=(const i64 r) { a = (r % M + M) % M; return *this; }
  constexpr modint& operator+=(const modint r) { a += r.a; if(a >= M) a -= M; return *this; }
  constexpr modint& operator-=(const modint r) { a -= r.a; if(a < 0) a += M; return *this; }
  constexpr modint& operator*=(const modint r) { a = a * r.a % M; return *this; }
  constexpr modint& operator/=(const modint r) { (*this) *= r.inv(); return *this; }
  constexpr modint operator+(const modint r) const { return modint(*this) += r; }
  constexpr modint operator-(const modint r) const { return modint(*this) -= r; }
  constexpr modint operator*(const modint r) const { return modint(*this) *= r; }
  constexpr modint operator/(const modint r) const { return modint(*this) /= r; }
  constexpr bool operator!=(const modint r) const { return this->value() != r.value(); }
};

template<const i64 M> std::ostream& operator<<(std::ostream& os, const modint<M>& m) { os << m.value(); return os; }

using fp = modint<(i64)(1e9 + 7)>;

template <class T>
void inverse_divisor_transform(vector<T> &a) {
    int n = a.size();
    vector<bool> sieve(n, true);
    for (int p = 2; p < n; ++p) {
        if (sieve[p]) {
            for (int k = (n - 1) / p; k > 0; --k) {
                sieve[k * p] = false;
                a[k * p] -= a[k];
            }
        }
    }
}

int main() {
  i64 N, K;
  cin >> N >> K;
  fp ans(0);

  vector<fp> vec(K + 1);
  rep(i,1,K + 1) {
    vec[i] = fp(i);
  }

  inverse_divisor_transform(vec);

  auto func = [&](i64 x) {
    fp res(0);
    if(x != 1) res += fp(1);
    for(i64 i = 2; i * i <= x; i++) {
      if(x % i == 0) {
        res += fp(i);
        if(x / i != i) {
          res += fp(x / i);
        }
      }
    }
    return res;
  };
  rep(g,1,K + 1) {
    i64 A = K / g;
    ans += fp(A).pow(N) * vec[g];
  }
  std::cout << ans << endl;
}


Measured memory_bytes: 4052
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
A = sorted(A)
MAX = A[-1]
MIN = A[0]
for i in range(1,n-1):
    if abs(MAX/2 - A[i]) <= abs(MAX/2 - MIN):
        MIN = A[i]
print(MAX,MIN)


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

int main(){

    int deg,a,b;
    double rad,s,h,l,c;
    double PI = acos(-1);  // PI = 3.141593...

    scanf("%d %d %d", &a,&b,&deg);
    rad = deg * PI / 180;

    s = a * b * sin(rad) /2;
    c = a*a + b*b - 2*a*b*cos(rad);
    c = sqrt(c);
    l = a + b + c;
    rad = (180 - 90 - deg) * PI / 180;
    h = b * cos(rad);

    //printf("%d degree = %f radian\n", deg, rad);
    //printf("cos(%d) = %f, sin(%d) = %f\n", deg, cos(rad), deg, sin(rad));
    printf("%lf\n", s);
    printf("%lf\n", l);
    printf("%lf\n", h);

    return 0;
}



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

bool qry(int x , int y){cout << "? " << x - 1 << ' ' << y - 1 << endl; char c; cin >> c; return c == 'Y';}

int main(){
	int A , B; cin >> A >> B;
	if(A <= B) cout << "Impossible" << endl;
	else{
		stack < int > stk;
		for(int i = 1 ; i <= A + B ; ++i) if(stk.empty() || qry(stk.top() , i)) stk.push(i); else stk.pop();
		static char str[4003]; for(int i = 1 ; i <= A + B ; ++i) str[i] = qry(stk.top() , i) + '0';
		cout << "! "; for(int i = 1 ; i <= A + B ; ++i) cout << str[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 724
<?php
  fscanf(STDIN,"%d %d",$n,$m);
  $li = [];
  $ac = [];
  $wa = [];
  $pena = 0;
  for($i=0; $i<$m; $i++){
    fscanf(STDIN,"%d %s",$p,$s);
    if($s == "AC"){
      $ac[] = $p;
    }else{
      if(!in_array($p,$ac)){
        $wa[$p]++;
      }
    }
  }
  $ac_uni = array_unique($ac);
  foreach ($ac_uni as $w){
    $pena += $wa[$w];
  }
  
  echo count($ac_uni)." ".$pena."\n";

Measured memory_bytes: 16756
#include<stdio.h>
int main(void)
{
  int a,b;

  scanf("%d %d",&a,&b);

  if(a>b)
    printf("a > b\n");
  else if(a==b)
    printf("a == b\n");
  else if(a<b)
    printf("a < b\n");

  return 0;
}

Measured memory_bytes: 580
using System;

class Problem
{
  public static void Main(string[] args)
  {
    var nums = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    int a = nums[0], b = nums[1], c = nums[2];

    var count = 0;
    while (!(a == b && b == c))
    {
      var max = Math.Max(a, Math.Max(b, c));
      if (max == a)
      {
        var db = a - b;
        var dc = a - c;
        if (db % 2 == 0 && dc % 2 == 1)
        {
          a += 1;
          c += 1;
          count++;
        }
        else if (db % 2 == 1 && dc % 2 == 0)
        {
          a += 1;
          b += 1;
          count++;
        }
        else 
        {
          var divB = db / 2;
          var divC = dc / 2;
          var remB = db % 2;
          var remC = dc % 2;
          b += 2 * divB + remB;
          c += 2 * divC + remC;
          count += divB + divC + remB;
        }
      }
      else if (max == b)
      {
        var da = b - a;
        var dc = b - c;
        if (da % 2 == 0 && dc % 2 == 1)
        {
          b += 1;
          c += 1;
          count++;
        }
        else if (da % 2 == 1 && dc % 2 == 0)
        {
          a += 1;
          b += 1;
          count++;
        }
        else
        {
          var divA = da / 2;
          var divC = dc / 2;
          var remA = da % 2;
          var remC = dc % 2;
          a += 2 * divA + remA;
          c += 2 * divC + remC;
          count += divA + divC + remA;
        }
      }
      else
      {
        var da = c - a;
        var db = c - b;
        if (da % 2 == 0 && db % 2 == 1)
        {
          b += 1;
          c += 1;
          count++;
        }
        else if (da % 2 == 1 && db % 2 == 0)
        {
          a += 1;
          c += 1;
          count++;
        }
        else
        {
          var divA = da / 2;
          var divB = db / 2;
          var remA = da % 2;
          var remB = db % 2;
          a += 2 * divA + remA;
          b += 2 * divB + remB;
          count += divA + divB + remA;
        }
      }
    }
    Console.WriteLine($"{count}");
  }
}

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

"""
input:
3 5
0 0 1
0 1 2
0 2 3
1 0 2
1 1 2

output:
1
2
"""

import sys
from math import ceil, log2, isinf


class SegmentTree(object):
    __slots__ = ('dat', 'tree_range')

    def __init__(self):
        """
        Init a SegmentTree with update and find for RMQ.
        """
        self.tree_range = end
        self.dat = [float('inf')] * (2 * self.tree_range - 1)

    # let A[k]=a
    def update(self, k, a):
        k += self.tree_range - 1
        self.dat[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2])

    # get min(A[s] A[s+1] ... A[t])
    def find(self, s, t, k=0, l=0, r=float('inf')):
        if r <= s or t <= l:
            return float('inf')

        if s <= l <= r <= t:
            return self.dat[k]
        else:
            vl = self.find(s, t, k * 2 + 1, l, (l + r) // 2)
            vr = self.find(s, t, k * 2 + 2, (l + r) // 2, r)
            return min(vl, vr)


def action(cmd_list):
    for query in cmd_list:
        cmd, ele_1, ele_2 = map(int, query)
        if cmd == 0:
            case.update(ele_1, ele_2)
        elif cmd == 1:
            assert ele_1 <= ele_2
            res = case.find(s=ele_1, t=ele_2 + 1, r=end)
            if isinf(res):
                print(INIT_MAX)
            else:
                print(res)

    return case


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n_num, q_num = map(int, _input[0].split())
    q_list = map(lambda x: x.split(), _input[1:])

    end = pow(2, ceil(log2(n_num)))
    INIT_MAX = pow(2, 31) - 1

    case = SegmentTree()

    ans = action(q_list)

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

int main() {
	int n, m; cin >> n >> m;
    int l, r;
    int a=1, b=n;
    int ans;
    
    for (int i = 0; i < m; i++)
    {
        cin >> l >> r;
        a=max(a, l);
        b=min(b,r);
    }
    ans=b-a+1;
    if(ans<0) ans=0;
    cout << ans << endl;
}
//g++ -o c.exe c.cpp

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

int main() {
    int X;
    std::cin >> X;

    int sum = 0;
    for (int i = 1; i <= X; ++i) {
        sum += i;
        if (sum >= X) {
            std::cout << i << std::endl;
            return 0;
        }
    }
    
    return 0;
}


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

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)a.size()
#define pw(n) (1ll << (n))

#define equal equalll
#define less lesss
const int N = 1e5 + 10;
const long long INF = 1e9 + 19;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int w[N];
int n;
vector<int> e[N];
map<pair<int,int>, bool> q;

void read() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &w[i]);
    for (int i = 0; i < n - 1; i++) {
        int v, u;
        scanf("%d%d", &v, &u); v--; u--;
        e[v].pb(u);
        e[u].pb(v);
    }
}

bool isWin(int v, int u) {
    // v -> u;
    if (q.count(mp(v, u)) == 0) {
        bool& res = q[mp(v, u)];
        if (w[u] >= w[v]){
            res = 1;
        } 
        else {
            for (auto h: e[u]) {
                if (h != v && isWin(u, h) == 0) {
                    res = 1;
                    break;
                }
            }

        }
    }
    return q[mp(v, u)];
}

void solve() {
    set<int> ans;
    for (int i = 0; i < n; i++)
        for (auto u: e[i])
            if (!isWin(i, u))
                ans.insert(i);
    //db(isWin(1, 0));
    for (auto x: ans)
        printf("%d ", x + 1);
    puts("");
}

void stress() {

}

int main(){
#ifdef HOME 
    freopen("in", "r", stdin);
#endif
    if (1) {
        read();
        solve();
    }
    else {
        stress();
    }

    return 0;
}



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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n;
string s;
void solve(){
	cin >> n;
	cin >> s;
	
	int cnt = 0;
	int l = 0, r = n-1;
	while(l < r){
		while(l < n && s[l] == 'R') l++;
		while(r >= 0 && s[r] == 'W') r--;
		if(l < r){
			cnt++;
			l++; r--;
		}
	}
	cout << cnt << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3760
W,H,N=map(int,input().split())
W0,H0=0,0
for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        W0=max(x,W0)
    elif a==2:
        W=min(x,W)
    elif a==3:
        H0=max(y,H0)
    else:
        H=min(y,H)
if W-W0<0 or H-H0<0:
    print(0)
else:
    print((W-W0)*(H-H0))

Measured memory_bytes: 9144
import java.util.*;
import java.io.*;

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


Measured memory_bytes: 21076
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
using namespace std;
template<class T>inline void rd(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
string s;
int main()
{
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
    {
        puts("Yes");
    }
    else puts("No");
    return 0;
}

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

using namespace std;
string alp = "abcdefghijklm";
vector<string> ans;
int n;
void dfs(int num,int k,string s){
    if(num==n){
        ans.push_back(s);
        return ;
    }
    string t = s;
    for(int i=1;i<=k + 1;i++){
        t.push_back(alp[i - 1]);
        if(i<=k){
            dfs(num + 1,k,t);
        }else{
            dfs(num + 1,k + 1,t);
        }
        t.pop_back();
    }
}
int main(){
    cin >> n;
    string s;
    dfs(0,0,s);
    sort(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 9332