akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int a, b; cin >> a >> b;
	cout << 6 - a - b << endl;
}

Measured memory_bytes: 256
// TEMPLATE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a, b) for (int i=(a);(i)<(b);(i)++)
#define REP(i, n) for (int i=0;(i)<(n);(i)++)
#define print(x) (cout<<(x)<<"\n")

// LIBRARY


// SOLVE
ll dp[51][51][3001];

signed main() {
    ll n, a; cin>>n>>a;
    vector<ll> x(n);
    REP(i, n) {
        cin>>x[i];
    }
    dp[0][0][0] = 1;
    REP(i, n) {
        REP(j, n) {
            REP(k, 2501) {
                dp[i+1][j+1][k+x[i]] += dp[i][j][k];
                dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    FOR(i, 1, n+1) {
        ans += dp[n][i][i*a];
    }
    print(ans);
}


Measured memory_bytes: 60032
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,t,u,v,l;
  cin>>n>>k>>t>>u>>v>>l;
  int i,j;
  set<int> s;
  for(i=0;i<n;i++){
    cin >> j;
    s.insert(j);
  }
  int p=0,h=0,x=0;
  double ans=0;
  for(i=1;i<=l;i++){
    
    if(x==0){
      if(h>0){
	x=v*t-1;h--;
	ans+=1.0/v;
      }else ans+=1.0/u;
    }else{
      ans+=1.0/v;
      x--;
    }
    if(s.find(i)!=s.end()){
      if(h<k) h++;
      else{
	x=v*t;
      }
    }
    
    //cout << i << ":" << h << "/";
    //printf("%.9lf\n",ans);
  }

  printf("%.9lf\n",ans);
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
char str[5005];
int main() {
	int n, k;
	scanf("%d%d%s", &n, &k, str);
	string s = str;
	string t(s.rbegin(), s.rend());
	s += t;
	string ans(n, 'z');
	for (int i = 0; i <= n; ++i) {
		t = s.substr(i, n);
		int c = 1;
		for (; c < n && t[n - c - 1] == t[n - 1]; ++c);
		for (int j = 1; c < n && j < k; ++j) {
			string tt(t.rbegin(), t.rend());
			t += tt;
			if (j == k - 1) t = t.substr(n - c, n);
			else t = t.substr(c, n);
			c = min(n, c * 2);
		}
		ans = min(ans, t);
	}
	printf("%s\n", ans.c_str());
}


Measured memory_bytes: 384
#include<stdio.h>
main()
{
    int i,j,k,l,t,t1,b,c;
    scanf("%d",&t);
    int a[t];
    for(i=0; i<t; i++)
        scanf("%d",&a[i]);
    scanf("%d",&t1);
    for(i=0; i<t1; i++)
    {
        scanf("%d %d",&b,&c);
        int sum=0;
        for(j=0; j<t; j++)
        {
            if(j==b-1)
                sum+=c;
            else
                sum+=a[j];
        }
        printf("%d\n",sum);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
#include <boost/multiprecision/cpp_int.hpp>
#endif

#define p std::pair
#define ll long long
#define ull unsigned long long
#define pi (acos(-1))
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
void stat();
constexpr ll mod = 1000000000 + 7;

int main()
{
    int n;
    cin >> n;
    vec<p<p<string, int>, int>> v(n);
    rep(i, n)
    {
        cin >> v[i].first.first >> v[i].first.second;
        v[i].second = i + 1;
    }
    sort(all(v), [](p<p<string, int>, int> l, p<p<string, int>, int> r) {
        if (l.first.first != r.first.first) { return l.first.first < r.first.first; }
        else
        {
            return l.first.second > r.first.second;
        }
    });
    for (auto const &s : v) { cout << s.second << endl; }
    return 0;
}
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat()
{
#ifdef local
    rep(i, 2) { std::cout << "local enable" << std::endl; }
#endif
#ifdef hacks
    rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<string>
#define x first
#define y second

using namespace std;
string s = "ACL";
int k;
int main()
{
	cin >> k;
	string res;
	for(int i = 0; i < k; ++i) res+=s;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3544
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

char dpy[4001][16001];
char dpx[4001][16001];

int tX, tY;

vector<int> v; //vertical
vector<int> h; //horizontal

int targetX;
int targetY;

char solveX(int cur, int x)
{
    if (cur == targetX)
    {
        if (x == tX) return 1;
        return 0;
    }
    
    if (dpx[cur][x] != -1) return dpx[cur][x];
    
    return dpx[cur][x] = (solveX(cur+1, x+h[cur]) || solveX(cur+1,x-h[cur]));
}

char solveY(int cur, int y)
{
    if (cur == targetY)
    {
        if (y == tY) return 1;
        return 0;
    }
    
    if (dpy[cur][y] != -1) return dpy[cur][y];
    
    return dpy[cur][y] = (solveY(cur+1, y+v[cur]) || solveY(cur+1,y-v[cur]));
}

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    
    memset(dpx, -1, sizeof dpx);
    memset(dpy, -1, sizeof dpy);
    
    string s;
    cin >> s;
    
    cin >> tX >> tY; //targets
    
    tX += 8000;
    tY += 8000;
    
    vector<int> path;
    
    int cntF = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'F')
        {
            cntF++;
            if (i == s.size()-1) path.push_back(cntF);
        }
        else if (s[i] == 'T')
        {
            if (cntF)path.push_back(cntF);
            path.push_back(0);
            cntF = 0;
        }
        
    }
    
    //for (int i = 0; i < path.size(); i++) cout << path[i] << ' ';
    
    bool vert = 0;
    
    int x, y;
    x = y = 8000;
    
    if (path[0]) //start moving, then position vertically
    {
        x += path[0];
        path.erase(path.begin());
    }
    
    for (int i = 0; i < path.size(); i++)
    {
        if (!path[i]) //turn
        {
            vert = !vert;
        }
        else //forward
        {
            if (vert) v.push_back(path[i]);
            else h.push_back(path[i]);
        }
    }
    
    targetX = h.size();
    targetY = v.size();
    
    if (solveX(0,x) && solveY(0,y)) cout << "Yes\n";
    else cout << "No\n";
    
    return 0;
    
}



Measured memory_bytes: 125440
#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>;

int main(){
    int N;
    cin >> N;
    int ans = 0;
    int tmp;
    rep(i,N){
        cin >> tmp;
        if((i + 1) % 2 == 1 and tmp % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
ll n,a[200005],s,ans=1000000000000000;
int main(void){
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        a[i]-=i;
    }
    sort(a,a+n);
    s=a[n/2];
    ll r=0;
    for(int i=0;i<n;i++)r+=abs(a[i]-s);
    ans=min(ans,r);
    if(n/2-1>0)s=a[n/2-1];
    r=0;
    for(int i=0;i<n;i++)r+=abs(a[i]-s);
    ans=min(ans,r);
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
n = int(input())
a,b,c = [list(map(int,input().split())) for i in range(3)]
x = 0
d = -10
for i in range(n):
    y = b[a[i]-1]
    x += y
    if a[i]-1 == d:
        x+= c[d-1]
    d = a[i]
print(x)

Measured memory_bytes: 9164
import java.util.*;
class Main{
     public static void main(String []args){
        Scanner sc= new Scanner(System.in);
        int S=sc.nextInt();
        if(S<0){
                System.out.println("NA");
                return;
            }
        if(S%100<13&&S%100!=0){
            
            if(S/100<13&&S/100!=0){
                System.out.println("AMBIGUOUS");
                return;
            }
            System.out.println("YYMM");
            return;
        }
        if(S/100<13&&S/100!=0){
            System.out.println("MMYY");
        
            return;
        }
        System.out.println("NA");
        
        
        
        
        
     }
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define print(x) cout << x << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;


int main()
{
    ll H, W;
    cin >> H >> W;
    if (H == 1 || W == 1) {
        print(1);
    } else {
        print((H * W + 1) / 2);
    }
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
ab = []
n.times do 
    a, b = gets.split.map(&:to_i)
    b *= -1
    ab << [a, b]
end
ab.sort_by!{|e| e[1] - e[0]}

puts n.times.with_object([0]) {|i, obj| obj[0] += ab[i][i % 2]}

Measured memory_bytes: 12664
function Main(input) {
    input = input.split("\n");
    var N =Number(input[0]);
    var inputA = input[1].split(' ').map(Number);
    var inputB = input[2].split(' ').map(Number);
    var inputC = input[3].split(' ').map(Number);
    var count = 0;
    for(var i=0; i < N;i++){
        count +=  inputB[ inputA[i] - 1 ] ;
            //if( inputA[i-1] === inputA[i] -1  ){
        if( inputA[i] === (inputA[i-1]+1)  ){
            //count += inputC[  inputA[i-1] -1 ];
            count += inputC[inputA[i] -2];
        }
    }
    console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

	vector<int>W(n+1), E(n+1);
	for (int i = 0; i < n; i++) {
		W[i+1] = W[i] + (s[i] == 'W');
		E[i+1] = E[i] + (s[i] == 'E');
	}
	int ans = (int)1e9;
	for (int i = 0; i < n; i++) {
		ans = min(ans, W[i] +E[n] - E[i+1]);
	}
	cout << ans << endl;

	return 0;
}

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

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = x * 10 + _c - '0'; _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))

const int MOD = (int) 1e9 + 7;
const int inf = (int) 1e9;
const int maxn = (int) 3e5 + 20;
const int maxm = (int) 5e5 + 20;

int n;
char str[2222];

vector<int> G[2222];


struct Item
{
    int mx, mn, sz;
};

Item dfs(int u, int f)
{
    Item res;
    res.mx = 0;
    res.sz = str[u] == '1';

    vector<Item> vec;

    for(int v : G[u])
    {
        if(v == f) continue;
        Item tmp = dfs(v, u);
        tmp.mx += tmp.sz;
        tmp.mn += tmp.sz;
        vec.push_back(tmp);
    }

    for(auto x : vec)
    {
        res.mx += x.mx;
        res.sz += x.sz;
    }

    res.mn = res.mx % 2;

    for(auto x : vec)
    {
        if(x.mn > res.mx - x.mx)
            Max(res.mn, x.mn - (res.mx - x.mx));
    }


    return res;
}

void work()
{
    cin >>n;
    cin >>(str + 1);
    for(int i = 1; i < n; i++)
    {
        int x, y; cin >>x >>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    int ans = inf;
//    dfs(6, 6);
    for(int i = 1; i <= n; i++)
    {
        Item tmp = dfs(i, i);
        if(tmp.mn == 0)
            Min(ans, tmp.mx / 2);
    }

    if(ans == inf) ans = -1;
    cout <<ans <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
    int tc = 1;
//    cin >>tc;
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
        string s;
        cin>>s;
        for(int i=0; i<s.size(); i++){
                if(s[i]=='1') cout<<'9';
                else cout<<'1';
        }

        cout<<endl;

        return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n,k;
    cin>>n>>k;
    vector<in> a(n);
        rep(i,n) cin>>a.at(i);
    vector<in> full(n);
    in cnt=0ll;
    rep(i,n){
        cnt=0ll;
        rep(j,n){
            if(i==j) continue;
            if(a[i]>a[j]) cnt ++;
        }
        full[i]=cnt;
    }
    vector<in> part(n,0ll);
    rep(i,n){
        cnt=0ll;
        REP(j,i+1ll,n){
            if(a[i]>a[j]) cnt ++;
        }
        part[i]=cnt;
    }
    in ans=0ll;
    rep(i,n) ans=(ans+k*part[i])%MOD;
    k=(k-1)*k/2ll%MOD;
    rep(i,n) ans=(ans+full[i]*k)%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  bool flag = false;
  REP(i,n){
    int a;
    cin >> a;
    if(a%2==1) flag = true;
  }
  if(flag) cout << "first\n";
  else cout << "second\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define PI 2*acos(0)
#define INF 1e18
#define mx 200005
using namespace std;
//const ll int p=1000000007;
//vector<ll > prime;
//bool mark[mx];
ll int mod(ll int a,ll int b)
{
    ll int m=a%b;
    if(m<0) m=(b<0)?(m-b):(m+b);
    return m;
}
ll maxpow(ll n)
{
    return (n & (~(n-1)));
}
bool isPrime(ll n)
{
    if(n<2) return false;
    if(n==2) return true;
    if(n%2==0) return false;
    for(ll i=3;i*i<=n;i+=2){
        if(n%i==0) return false;
    }
    return true;
}
/*void init()
{
    mark[1]=1;
    int i,j,limit=sqrt(mx*1.0)+2;
    prime.push_back(2);
    for(i=4;i<mx;i+=2) mark[i]=1;
    mark[2]=0;
    for(i=3;i<mx;i+=2){
        if(!mark[i]){
            prime.push_back(i);
            if(i<=limit){
                for(j=i*i;j<mx;j+=2*i){
                    mark[j]=1;
                }
            }
        }
    }
}
/*
ll maxdiv(ll n)
{
    ll i,ans=1;
    for(i=0;i<prime.size();i++){
        if(n%prime[i]==0){
            ans=n/prime[i];break;
            //return ans;
        }
    }
    return ans;
}*/
ll lcm(ll a,ll b)
{
    ll ans=a*b;
    return (ans/__gcd(a,b));
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    ll i,j,k,z,x,sum,cnt,ans;
    cnt=0;
    for(i=0;i<s.size();i++){
        z=s[i]-'0';
        cnt+=z;
    }
    if(cnt%9 == 0) cout<<"Yes";
    else cout<<"No";
    return 0;
}
//1028C


Measured memory_bytes: 3756
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n, tp = 0, hp = 0, p;
	char taro[104], hana[104];

	scanf("%d", &n);
	while (n--) {
		scanf("%s %s", taro, hana);
		p = strcmp(taro, hana);
		if (p > 0) tp += 3;
		if (p < 0) hp += 3;
		if (p == 0) tp++, hp++;
	}
	printf("%d %d\n", tp, hp);

	return 0;
}



Measured memory_bytes: 2040
arr_ball_str = gets.chomp.split(' ').map(&:to_s)
arr_ball_cnt = gets.chomp.split(' ').map(&:to_i)
ball_str = gets.chomp.to_s

arr_output = []
arr_ball_str.each_with_index do |str, index|
  if str == ball_str
    arr_output[index] = arr_ball_cnt[index] - 1
  else
    arr_output[index] = arr_ball_cnt[index]
  end
end

puts arr_output.inject {|output, item| output.to_s + ' ' + item.to_s}

Measured memory_bytes: 3836
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    S = input()
    N = len(S) - 1
    ans = 0

    for i in range(2**N):
        bi = bin(i)[2:].zfill(N)
        # print(bi)
        ans += calc(S, bi)

    print(ans)

def calc(S, bi):
    ret = 0
    k = 0

    for i in range(len(S)):
        if i == 0:
            continue
        else:
            if bi[i-1] == '1':
                ret += int(S[k:i])
                k = i

    ret += int(S[k:])

    return ret

if __name__ == '__main__':
    solve()

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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,m,a,b,ans,z;
vector<pair<int,int>> v;
priority_queue<int> pq;

signed main() {
    cin >> n >> m;
    rep(i,n) {
        cin >> a >> b;
        v.pb(mp(a,b));
    }
    sort(all(v));
    rep1(i,m) {
        while (z < v.size() && v[z].fi == i) pq.push(v[z].se), ++z;
        if (pq.size()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3568
N, M, X, Y = map(int, input().split())
a = list(map(int, input().split()))
for i in range(N):
    if(i == 0):
        mx= a[i]
    else:
        mx = max(a[i],mx)
a = list(map(int, input().split()))
if(mx >= Y):
    print("War")
    quit()
for i in range(M):
    if(i == 0):
        my = a[i]
    else:
        my = min(a[i],my)
if(my <= X):
    print("War")
    quit()
if(mx >= my):
    print("War")
else:
    print("No War")


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

const int N = 2048;

char mx[N][N];
int up_same[N][N], height[N], links[N], rechts[N];

int n, m;


static int histogram() {
	static vector<int> stk;
	int ant = 0;

	stk.push_back(0);
	for (int i = 1; i < m; ++i) {
		while (height[stk.back()] >= height[i])
			stk.pop_back();

		links[i] = stk.back() + 1;
		stk.push_back(i); }

	stk.clear();
	stk.push_back(m);
	for (int i = m - 1; i > 0; --i) {
		while (height[stk.back()] >= height[i])
			stk.pop_back();

		rechts[i] = stk.back() - 1;
		stk.push_back(i); }

	for (int i = 1; i < m; ++i)
		ant = max(ant, (rechts[i] - links[i] + 2) * height[i]);

	return ant; }

static int solve() {
	int ant = 0;

	height[0] = height[m] = -1;
	for (int i = 1; i < m; ++i)
		up_same[1][i] = 1;

	for (int i = 2; i <= n; ++i) {
		for (int j = 1; j < m; ++j)
			height[j] = up_same[i][j] = 1 + (((mx[i][j] == mx[i][j + 1]) == (mx[i - 1][j] == mx[i - 1][j + 1])) ? up_same[i - 1][j] : 0);

		ant = max(ant, histogram()); }

	return ant; }

int main() {
#ifdef HOME
	freopen("arc81d.in", "r", stdin);
	freopen("arc81d.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int ant;

	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		cin >> (mx[i] + 1);

	ant = max(n, m);
	ant = max(ant, solve());
	for (int i = 1; i <= n; ++i)
	for (int j = 1; j <= m; ++j)
		mx[i][j] = mx[i][j] == '.' ? '#' : '.';
	ant = max(ant, solve());

	cout << ant << endl;

	return 0; }


Measured memory_bytes: 20864
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,s,a;
  cin>>k>>s;
  for(int i=0;i<k+1;++i){
    for(int j=0;j<k+1;++j){
      if(s-(i+j)>=0&&s-(i+j)<=k) a+=1;
    }
  }
  cout<<a;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
N=int(input())

graph=[[] for _ in range(N)]
for i in range(N-1):
  u,v,w=map(int,input().split())
  u,v=u-1,v-1
  graph[u].append([v,w])
  graph[v].append([u,w])

check=[0]*N
ans=[0]*N
def solve(x):
  check[x]=1
  for i,d in graph[x]:
    if check[i]==0:
      ans[i]=(ans[x]+d)%2
      solve(i)
solve(0)
for i in range(N):
  print(ans[i])

Measured memory_bytes: 85848
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner cin = new Scanner(System.in);
        
        int t = 0;
        int x = 0;
        
        for(int i = 0; cin.hasNext(); i++){
	        String line = cin.nextLine();
	        
	        if(i == 0) {
	            String[] tx = line.split(" ", 0);
	            t = Integer.parseInt(tx[0]);
	            x = Integer.parseInt(tx[1]);
	            
	        } else {
	            
	        }
	        
        }
        
        double res = (double)t / (double)x;
        
        System.out.printf("%.10f", res);
        
    }
    
}


Measured memory_bytes: 24916
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define Alint(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1ll << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 998244353, INF = 1e9;

struct edge { lint to, cap, rev; };

vector<edge> Graph[20005];
int level[20005];
int iter[20005];
void add_edge(lint from, lint to, lint cap) {
	Graph[from].push_back({ to, cap, SZ(Graph[to]) });
	Graph[to].push_back({ from, 0, SZ(Graph[from]) - 1 });
}
void bfs(lint s) {
	memset(level, -1, sizeof(level));
	queue<lint> que;
	que.push(s);
	level[s] = 0;
	while (!que.empty()) {
		lint v = que.front(); que.pop();
		REP(i, SZ(Graph[v])) {
			edge& e = Graph[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

lint dfs(lint v, lint t, lint f) {
	if (v == t) return f;
	for (int& i = iter[v]; i < SZ(Graph[v]); i++) {
		edge& e = Graph[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			lint d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				Graph[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

lint max_flow(lint s, lint t) {
	lint flow = 0;
	for (;;) {
		bfs(s);
		if (level[t] < 0) return flow;
		memset(iter, 0, sizeof(iter));
		lint f;
		while ((f = dfs(s, t, INF)) > 0) {
			flow += f;
		}
	}
}

lint gcd(lint a, lint b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}

lint N, M;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> M;
	vector<lint> ans;
	while (!(N == 0 && M == 0)) {
		lint b[500], r[500];
		lint s = N + M, t = s + 1;
		REP(i, t + 1) {
			Graph[i].clear();
		}
		REP(i, N) {
			cin >> b[i];
			add_edge(s, i, 1);
		}
		REP(i, M) {
			cin >> r[i];
			add_edge(i + N, t, 1);
		}
		REP(i, N) {
			REP(j, M) {
				if (gcd(b[i], r[j]) != 1) {
					add_edge(i, j + N, 1);
				}
			}
		}
		ans.push_back(max_flow(s, t));	
		cin >> N >> M;
	}
	REP(i, SZ(ans)) {
		cout << ans[i] << endl;
	}
}



Measured memory_bytes: 16344
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
ll x[200005],ind[200005],res[200005];
vector<p2> v(200005);
bool comp(ll i,ll j){
    if(x[i]<x[j]||(x[i]==x[j]&&v[i].first<v[j].first)||(x[i]==x[j]&&v[i].first==v[j].first&&v[i].second<v[j].second))
    return true;
    return false;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,q;
    cin>>n>>q;
    for(ll i=0;i<n;i++){
        cin>>v[i].first>>v[i].second>>x[i];
        v[i].first-=x[i];
        v[i].second-=x[i];
        ind[i]=i;
    }
    sort(ind,ind+n,comp);
    set<p2> s;
    for(ll i=0;i<q;i++){
        ll x;
        cin>>x;
        s.insert({x,i});
    }
    for(ll qc=0;qc<n;qc++){
        ll i=ind[qc];
        if(v[i].second<=0)
        continue;
        auto it=s.lower_bound({v[i].first,-1});
        while(it!=s.end()){
            if(it->first<v[i].second){
                res[it->second]=x[i];
                s.erase(it);
            }
            else
            break;
            it=s.lower_bound({v[i].first,-1});
        }
        if(s.empty())
        break;
    }
    for(ll i=0;i<q;i++)
    if(res[i])
    cout<<res[i]<<endl;
    else
    cout<<"-1\n";
}


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

using namespace std;

int main(void)
{
  int n;
  string input;
  vector<string> s;
  int count=0;

  cin>>n;
  cin>>input;
  s.push_back(input);
  for(int i=1;i<n;i++)
  {
    cin>>input;
    s.push_back(input);
  }

  sort(s.begin(),s.end());
  for(int i=1;i<s.size();i++)
  {
    if(s[i] != s[i-1])
    {
      count++;
    }
  }
  cout<<count+1<<endl;
}


Measured memory_bytes: 11600
#include <cassert>
#include <iostream>
#include <vector>

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int H;
    std::cin >> H;
    std::vector<int> A(H+1);
    for(std::size_t i = 1; i <= H; ++i){
        int Value;
        std::cin >> Value;
        A[i] = Value;
    }
    for(std::size_t i = 1; i <= H; ++i){
        // node 2: key = 8, parent key = 7, left key = 2, right key = 3,
        int Parent = i/2;
        int Left   = i * 2;
        int Right  = i * 2 + 1;
        std::cout << "node " << i << ": key = " << A[i] << ", ";
        if(Parent)     std::cout << "parent key = " << A[Parent] << ", ";
        if(Left <= H)  std::cout << "left key = "   << A[Left]   << ", ";
        if(Right <= H) std::cout << "right key = "  << A[Right]  << ", ";
        std::cout << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3072
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

ll n, m;
ll a[400], b[400];
ll p[410][410], q[410][410];
ll dp[410][410];

int main(){
  cin >> n >> m;
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, 410){
    p[i][0] = 1;
    rep(j, 1, 410) p[i][j] = p[i][j - 1] * i % mod;
  }
  rep(i, 409) rep(j, 410){
    q[i + 1][j] = (p[i][j] + q[i][j]) % mod;
  }
  dp[0][0] = 1;
  rep(i, n) rep(j, m + 1) rep(k, m - j + 1){
    dp[i + 1][j + k] = (dp[i + 1][j + k] + dp[i][j] * ((q[b[i] + 1][k] - q[a[i]][k] + mod) % mod) % mod) % mod;
  }
  cout << dp[n][m] << endl;
}


Measured memory_bytes: 4224
peak, road = map(int, input().split())
high_list = list(map(int, input().split()))
peak_set = {i for i in range(peak)}
for i in range(road):
  a, b = map(int, input().split())
  if high_list[a-1] == high_list[b-1]:
    peak_set.discard(a-1)
    peak_set.discard(b-1)
  elif high_list[a-1] > high_list[b-1]:
    peak_set.discard(b-1)
  else:
    peak_set.discard(a-1)
print(len(peak_set))

Measured memory_bytes: 22612
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    n, *a = map(int, read().split())
    r = 0
    for i1, ae in enumerate(a):
        if (i1+1)&1 and ae&1:
            r += 1
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9088
#include <stdio.h>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, a[300], x[9], y[9], z[9], p[9], sum[300][301], dp[300][301];
int calc(int a, int b) {
	for (int i = 0; i < 9; i++) {
		x[i] = (a / p[i]) % 10;
		y[i] = (b / p[i]) % 10;
	}
	z[0] = 0;
	for (int i = 1; i < 9; i++) {
		if (x[i - 1] + y[i - 1] + z[i - 1] < 10) {
			z[i] = 0;
		}
		else
		{
			z[i] = 1;
		}
	}
	int ret = 0;
	for (int i = 0; i < 9; i++) {
		ret += x[i] * y[i] + z[i];
	}
	return ret;
}
int main() {
	scanf("%d", &n);
	p[0] = 1; for (int i = 1; i < 9; i++) p[i] = p[i - 1] * 10;
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 0; i < n; i++) {
		sum[i][i] = 0;
		for (int j = i + 1; j <= n; j++) {
			sum[i][j] = sum[i][j - 1] + a[j - 1];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			if (i + 1 >= j) {
				dp[i][j] = 0;
			}
			else {
				dp[i][j] = 999999999;
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			int l = j;
			int r = i + j;
			for (int k = l + 1; k < r; k++) {
				dp[l][r] = min(dp[l][r], dp[l][k] + dp[k][r] + calc(sum[l][k], sum[k][r]));
			}
		}
	}
	printf("%d\n", dp[0][n]);
	return 0;
}

Measured memory_bytes: 3452
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func gets() string {
	sc.Scan()
	return sc.Text()
}

func toInt(value string) int {
	num, _ := strconv.Atoi(value)
	return num
}

func toFloat64(value string) float64 {
	num, _ := strconv.ParseFloat(value, 64)
	return num
}

// B
func main()  {
	N := toInt(gets())
	var sum float64
	for i := 0; i < N; i++ {
		in := strings.Split(gets(), " ")
		if strings.TrimRight(in[1], "\n") == "BTC" {
			sum += toFloat64(in[0]) * 380000.0
		} else {
			sum += toFloat64(in[0])
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  int n,ans,W[310000] = {},E[310000] = {};
  string s;
  cin >> n >> s;
  
  for(int i = 1; i <= n-1; i++) {
    if(s[i-1] == 'W') 
      W[i] = W[i-1] + 1;
    else W[i] = W[i-1];
  }
  for(int i = n-2; i >= 0; i--) {
    if(s[i+1] == 'E') 
      E[i] = E[i+1] + 1;
    else E[i] = E[i+1];
  }

  int m = n;
  for(int i = 0; i < n; i++)
    m = min(m,W[i]+E[i]);
  
  cout << m << endl;
}

Measured memory_bytes: 6240
N=int(input())
height=[int(i) for i in input().split()]
height.append(0)
count=0
for i in range(N):
  while height[i]>0:
    j=0
    while height[i+j]>0:
      height[i+j]=height[i+j]-1
      j=j+1        
    count+=1
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PA;
int main(){
  int w,h,a[102][102]={};
  scanf("%d %d",&w,&h);
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      scanf("%d",&a[i][j]);
    }
  }
  queue<PA> que;
  PA p;
  int x,y;
  int dx1[6] = {0,1,-1,1,0,1};
  int dx2[6] = {-1,0,-1,1,-1,0};
  int dy[6] = {-1,-1,0,0,1,1};
  que.push(PA(0,-1));
  while(!que.empty()){
    p = que.front();
    que.pop();
    for(int i=0;i<6;i++){
      if(p.first % 2 == 1){
	y = p.first + dy[i];
	x = p.second + dx1[i];
      } else {
	y = p.first + dy[i];
	x = p.second + dx2[i];
      }
      if(x<0||y<0||x>w+1||y>h+1||a[y][x]!=0) continue;
      a[y][x] = 2;
      que.push(PA(y,x));
    }
  }
  int cnt = 0;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(a[i][j] == 1){
	for(int k=0;k<6;k++){
	  if(i%2 == 1 && a[i + dy[k]][j + dx1[k]] == 2) cnt++;
	  if(i%2 == 0 && a[i + dy[k]][j + dx2[k]] == 2) cnt++;
	}
      }
    }
  }
  printf("%d\n",cnt);
  return (0);
}

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

int main() {
	int x, y;
	for (x = 1; x <= 9; x = x + 1) {
		for (y = 1; y <= 9; y = y++) {
			cout << x << "x" << y << "=" << x*y << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 1112
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    int n; cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];

    vector<int> perm(n);
    rep(i, n) perm[i] = i + 1;
    int pNum, qNum, cnt = 0;
    do {
        cnt++;
        bool pJudge = true;
        bool qJudge = true;
        rep(i, n) {
            if(perm[i] != p[i]) pJudge = false;
            if(perm[i] != q[i]) qJudge = false;
        }
        if(pJudge) pNum = cnt;
        if(qJudge) qNum = cnt;
    } while(next_permutation(perm.begin(), perm.end()));

    COUT(abs(pNum - qNum));
}



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

using namespace std;

int main() {
	long long n, x;
	cin >> n >> x;
	
	vector<long long> a(n);
	
	for (auto &&e : a) {
		cin >> e;
	}
	
	sort(a.begin(), a.end());
	
	long long result = 0;
	for (long long i = 0; i < n; ++i) {
		if (x - a[i] >= 0) {
			++result;
			x -= a[i];
		} else {
			x = 0;
			break;
		}
	}
	
	if (x) {
		--result;
	}
	
	cout << result << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = (1ll << 31) - 1;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct RMQandRUQ {
	int n;
	vector<int>d, lazy;
	RMQandRUQ(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
		lazy.assign(2 * n, -1);
	}
	void eval(int k, int l, int r) {
		if (lazy[k] != -1) {
			d[k] = lazy[k];
			if (r - l > 1)lazy[2 * k] = lazy[2 * k + 1] = lazy[k], lazy[k] = -1;
			lazy[k] = -1;
		}
	}
	void update(int a, int b, int x, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = x;
			eval(k, l, r);
			return;
		}
		else {
			update(a, b, x, 2 * k, l, (l + r) / 2);
			update(a, b, x, 2 * k + 1, (l + r) / 2, r);
			d[k] = min(d[2 * k], d[2 * k + 1]);

		}
	}
	int find(int a, int b, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;

		eval(k, l, r);

		if (r <= a || b <= l)return INF;
		if (a <= l&&r <= b) {
			return d[k];
		}
		else {
			int vl, vr;
			vl = find(a, b, 2 * k, l, (l + r) / 2);
			vr = find(a, b, 2 * k + 1, (l + r) / 2, r);
			return min(vl, vr);
		}

	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RMQandRUQ seg(n);
	rep(z, 0, q) {
		int com; cin >> com;
		if (com) {
			int s, t; cin >> s >> t;
			cout << seg.find(s, t + 1) << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			seg.update(s, t + 1, x);
		}
	}
	return 0;
}

Measured memory_bytes: 4856
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {	
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.nextLine());
		ArrayList<Integer> result = new ArrayList<Integer>();
		ArrayList<Integer> res = new ArrayList<Integer>();
		String tmp = sc.nextLine();
		String[] s = tmp.split(" ");
		
		for(int i=0;i<n;i++) {
			res.add(Integer.parseInt(s[i]));
		}
		
		
		for(int i=1;i<=n;i++) {
			for(int j=res.size();j>0;j--){
				if(res.get(j-1) == j) {
					result.add(j);
					res.remove(j-1);
					break;
				}
				
				
			}
			
		}
		if(res.size()==0) {
			for(int i=n-1;i>=0;i--) {
				System.out.println(result.get(i));
			}
			
		}else {
			System.out.println(-1);
		}
		
		
		
		
	}
	
	
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int m = s.length();
	for (int i = 0; i + 1 < s.length(); i++) {
		if (s[i] != s[i + 1]) {
			int n = max(i + 1, (int)s.length() - i - 1);
			if (n < m)
				m = n;
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 512
/*  I love Cara Delevingne */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e6 + 5;

int n, h[MAXN], dp[MAXN];

int main() {
    
    cin >> n;
    for (int i = 1; i <= n; i++) {
    	cin >> h[i];
    	dp[i] = inf;
    }
    dp[1] = 0;
    for (int i = 1; i <= n; i++) {
    	dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
    	dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2])); 
    }
	cout << dp[n];
	return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);

string str;
cin>>str;
int n=str.size();

int dp[n]={};
int prev=0;
map<int,int> mp;
mp[0]=1;
int ans=0;
prev=str[n-1]-'0';
mp[prev]=1;
dp[n-1]=prev;
int x=10;
for(int i=n-2;i>=0;i--)
{prev+=(str[i]-'0')*x;
prev%=2019;
x*=10;
x%=2019;
ans+=mp[prev];
  mp[prev]+=1;
  dp[i]=prev;
}
cout<<ans<<endl;















    return 0;
}


Measured memory_bytes: 5320
#include <iostream>

int main() {
    int n, T; std::cin >> n >> T;
    unsigned long long X = 0;

    int head = 0, tail = 0;

    for (int i = 0; i < n; i++) {
        int t; std::cin >> t;
        if (t <= tail) {
            tail = t + T;
        } else {
            X += tail - head;
            head = t;
            tail = t + T;
        }
    }
    X += tail - head;

    std::cout << X << std::endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

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 INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	int x,n;
	cin >> x >> n;
	if(n == 0){
		cout << x << endl;
		return 0;
	}
	vector<int> ps(n);
	rep(i, n){
		cin >> ps[i];
	}
	sort(ps.begin(), ps.end());
	int index = 0;
	int ans = 1000;
	rep(i, 102){
		if(i == ps[index]){
			index++;
		}else{
			if(abs(x-i)<abs(ans-x)){
				ans = i;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int n, x[100];
    cin >> n;
    for(int i=0;i<n;++i) cin >> x[i];

    int ans = INT32_MAX;
    for(int p=0;p<=101;++p){
        int cand = 0;
        for(int i=0;i<n;++i) cand += (x[i] - p) * (x[i] - p);
        ans = min(ans, cand);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
  string s;
  int count1, count2 ;

  while(cin >> s){

    count1 = 0;
    count2 = 0;    
  
    if(s.length() == 2 || s.length () == 1) cout<<0<<"\n"<<0<<endl;

    for(int i = 0; i< s.length() -2 ; ){
      if(s[i] == 'J' && s[i+1] =='O' && s[i+2] == 'I') count1++;
      if(s[i] == 'I' && s[i+1] =='O' && s[i+2] == 'I') count2++;

      while(1){
	//cout<<s[i] <<endl;
	i++;
	if(i == s.length()-2) break;
	if(s[i] == 'J' || s[i] == 'I') break;
      
	}
    }

    cout <<count1 <<"\n"<<count2<<endl;
    }
  
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    using namespace std;

    int N;
    cin >> N;

    vector<int> d;
    for (int i=0; i<N; i++) {
        int di;
        cin >> di;
        d.push_back(di);
    }

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

    auto it = unique(d.begin(), d.end());
    d.erase(it, d.end());

    cout << d.size() << endl;

    return 0;
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,ans=0;
	string a;
	cin>>a;
	for (i=0;i<a.size();i++){
		if (a[i]=='1'){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    double p[n];
    REP(i,n){
        cin >> p[i];
    }
    double dp[n + 2];
    memset(dp, 0.0, sizeof(dp));
    dp[0] = 1.0;
    for(int i = 0; i < n; i++){
        for(int j = n; j >= 0; j--){
            dp[j] *= (1.0 - p[i]);
            if(j - 1 < 0) continue;
            dp[j] += dp[j - 1] * p[i];
        }
    }
    double ans = 0.0;
    for(int i = n / 2 + 1; i <= n; i++){
        ans += dp[i];
    }
    printf("%.12lf\n", ans);
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  string s;
  cin >> n >> s;

  int cnt = 0;
  for (int i = 0; i < 1000; i++) {
    int c[3] = {i / 100, (i / 10) % 10, i % 10};
    int f = 0;
    for (int j = 0; j < n; j++) {
      if (s[j] == ('0' + c[f])) f++;
      if (f == 3) break;
    }
    if (f == 3) cnt++;
  }
  cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 384
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
const int MAXN = (int)2e5 + 10;

int n;
int a[MAXN];
set<int> st;
int mx[MAXN];
const int INF = (int) 0x3f3f3f3f;

int lowbit(int x){
    return x&-x;
}

void update(int x,int d){
    while(x<MAXN){
        mx[x]=max(mx[x],d);
        x+=lowbit(x);
    }
}

int query(int x){
    int ret=-1;
    while(x){
        ret=max(mx[x],ret);
        x-=lowbit(x);
    }
    return ret;
}

void work(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    update(n,a[n]);
    int ans=-INF;
    for(int i=n-1;i>=1;i--){
//        printf("i = %d , mx = %d\n",i,query(n));
        ans=max(ans,query(n)-a[i]);
        update(i,a[i]);
    }
    printf("%d\n",ans);
}

int main(){
    work();
    return 0;
}




Measured memory_bytes: 4324