akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct SegmentTree {
  using T = int;
  static T op(const T& x, const T& y) { return max(x, y); }
  static constexpr T e() { return 0; }

  const int n;
  V<T> t;
  SegmentTree(int n) : n(n), t(2 * n, e()) {}
  T& operator[](int i) { return t[i + n]; }
  void build() { for (int i = n - 1; i; --i) t[i] = op(t[2 * i], t[2 * i + 1]); }
  T acc(int l, int r) const {
    T resl = e(), resr = e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = op(resl, t[l++]);
      if (r & 1) resr = op(t[--r], resr);
    }
    return op(resl, resr);
  }
  void set(int i, const T& x) {
    t[i += n] = x;
    while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (auto&& e : a) cin >> e;
  V<> idx(n);
  iota(begin(idx), end(idx), 0);
  sort(begin(idx), end(idx), [&](int i, int j) { return make_pair(a[i], -i) < make_pair(a[j], -j); });
  SegmentTree dp(n);
  for (int i : idx) {
    dp.set(i, dp.acc(i + 1, n) + 1);
  }
  int res = dp.acc(0, n);
  cout << res << '\n';
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	char c1[3],c2[3],tmp;
	
	scanf("%s",c1);
	scanf("%s",c2);
	
	tmp=c2[0];
	c2[0]=c2[2];
	c2[2]=tmp;
	
	if(strcmp(c1,c2)==0) printf("YES");
	else printf("NO");
	
	return 0;
}

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


int main(void){

  int n;
  double x[2], y[2], r[2];
  double d;


  scanf("%d", &n);
  while(n>0){
   
    scanf("%lf %lf %lf %lf %lf %lf", &x[0], &y[0], &r[0], &x[1], &y[1], &r[1]);

    d=pow(pow(x[1]-x[0], 2)+pow(y[1]-y[0], 2), 0.5);
    
    if(r[0]+r[1]<d){
      printf("0\n");
    }
    else if(d<r[0]-r[1]){
      printf("2\n");
    }
    else if(d<r[1]-r[0]){
      printf("-2\n");
    }
    else{
      printf("1\n");
    }

    n--;
  }

  return(0);
}



Measured memory_bytes: 1924
#include <stdio.h>
#include <math.h>
#include <string.h>


int main()
{
    int A,B,X;
    scanf("%d%d%d",&A,&B,&X);
    if(X>(A+B))
        printf("NO\n");
    else
    {
        if(X<A)
            printf("NO\n");
        else

            printf("YES\n");
    }
    return 0;
}


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

int main() {
  int i, n, m, a;
  int sum = 0;

  cin >> n >> m;
  
  for(i = 0; i < m; i++)
  {
    cin >> a;
    sum += a;
  }
  
  if(n - sum < 0)
    cout << -1 << endl;
  else
    cout << n - sum << endl;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SMI(): return input().split()
def SLI(): return list(input())

def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')

# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    S = SLI()
    l = len(S)
    MOD = 1000000007
    dp = [[0]*13 for _ in range(l+1)]
    dp[0][0] = 1
    mul = 1
    S = S[::-1]
    for i in range(l):
        # s = S[-(i + 1)]
        # s = S[i]
        if S[i] == '?':
            for q in range(10):
                for j in range(13):
                    dp[i+1][(q*mul + j)%13] += dp[i][j]
                    dp[i+1][(q*mul + j)%13] %= MOD
        else:
            for j in range(13):
                k = int(S[i])
                dp[i+1][(k*mul + j)%13] += dp[i][j]
                dp[i+1][(k*mul + j)%13] %= MOD

        mul = mul * 10 % 13
    # print(dp[-1])
    print(dp[-1][5] % MOD)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 66040
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> pll;
typedef long long ll;
const ll inf=4000000000000000000;
ll t,n,a,b,c,d,i,z,cur,r;
priority_queue<pll,vector<pll>,greater<pll>> s;
map<ll, ll> dst;
inline void upd(ll i, ll d) {
  if (dst.count(i)==0 || d<dst[i]) {
    dst[i]=d;
    s.push({d,i});
  }
}
int main() {
  cin>>t;
  while (t--) {
    cin>>n>>a>>b>>c>>d;
    r=inf;
    dst.clear();
    upd(n,0);
    while (!s.empty()) {
      cur=s.top().first;
      i=s.top().second;
      s.pop();
      if (dst[i]!=cur || cur>=r) continue;
      if (cur+(long double)(i)*d<inf) r=min(r,cur+i*d);
      if (i%2) {
        upd((i-1)/2,cur+a+d);
        upd((i+1)/2,cur+a+d);
      } else upd(i/2,cur+a);
      z=i%3;
      if (z) {
        upd((i-z)/3,cur+b+d*z);
        upd((i-z)/3+1,cur+b+d*(3-z));
      } else upd(i/3,cur+b);
      z=i%5;
      if (z) {
        upd((i-z)/5,cur+c+d*z);
        upd((i-z)/5+1,cur+c+d*(5-z));
      } else upd(i/5,cur+c);
    }
    cout<<r<<'\n';
  }
  return 0;
}


Measured memory_bytes: 4284
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;


int main(){
    int N; cin>>N;
    vector <int> H;
    bool ans = true;

    for(int i=0;i<N;i++){
        int h;
        cin>>h;
        H.push_back(h);

        if(i == 0) {H[0]--;continue;}

        if(H[i] == H[i-1]) continue;

        if(H[i] > H[i-1]) H[i]--;

    }

    for(int i=1;i<N;i++){
        if(H[i] < H[i-1]) ans = false;
    }

    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  
    return 0 ;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
using namespace std;

int main() {
    int k, n;
    cin >> k >> n;
    vector<long long> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    long long tmp_dist = v.front() + k - v.back();
    for (int i = 0; i < n - 1; ++i) {
        if (tmp_dist < v[i + 1] - v[i]) {
            tmp_dist = v[i + 1] - v[i];
        }
    }
    cout << k - tmp_dist << endl;
    return 0;
}

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


int main() {

  int a,sum ; cin >> a >> sum ;
  int ans = 0 ; 
  
  if ( 3*a < sum ) ans = 0 ;
  else {
  
  for ( int i = 0 ; i <= a ; i++ ) {
  	 for ( int j = 0 ; j <= a ; j++ )
     	if (  0 <= (sum - i - j) && (sum - i - j) <= a  ) ans++ ;
  	   }
     }
  
  cout << ans ; 

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define name(x) #x
using namespace std;


const int INF = INT_MAX;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

const int MAX_SIZE = 100005;
bool memo[MAX_SIZE];
vector<int> a;
int N,K;


int main() {

    cin >> N >> K;
    
    a.resize(N+5);
    for(auto i = 1; i<=N; i++) cin >> a[i];
    
    for(auto i = 1; i<=K;i++){
        memo[i] = false;
    }
    
    
    for(auto i = 1; i<=K; i++){
        for(auto j = 1; j <=N; j++){
            if (i - a[j] >= 0){
                if (memo[i-a[j]] == false) {
                    memo[i] = true;
                    break;
                }
            }
        }
    }
    
    
    if (memo[K]){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }

    
    return 0;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

const int N=55;
const int MAX_S=5004;
vector<tuple<int,int,int>>edges[N];
int n,m,S;
vector<pair<int,int>>_exchange;

void dijkstra(int s)
{
  vector<vector<ll>>dist(n,vector<ll>(MAX_S,1e15));
  dist[s][S]=0;
  priority_queue< pair<ll,pair<int,int>>, vector<pair<ll,pair<int,int>>>,greater< pair<ll,pair<int,int>> > >pq; //{dist,{src,silver_coins}}
  pq.push({0,{s,S}});

  while(!pq.empty()){
    int curr_dist=pq.top().first;
    int node=pq.top().second.first;
    int silver=pq.top().second.second;
    pq.pop();
    if(dist[node][silver]<curr_dist)  continue;

    for(auto x:edges[node]){
      if(get<1>(x)<=silver){
        if( dist[get<0>(x)][silver-get<1>(x)] > dist[node][silver]+get<2>(x) ){
          dist[get<0>(x)][silver-get<1>(x)] = dist[node][silver]+get<2>(x);
          pq.push({dist[get<0>(x)][silver-get<1>(x)],{get<0>(x),silver-get<1>(x)}});
        }
      }
    }
    int new_s=min(MAX_S-1,silver+_exchange[node].first);
    if(dist[node][new_s]>dist[node][silver]+_exchange[node].second){
      dist[node][new_s]=dist[node][silver]+_exchange[node].second;
      pq.push({dist[node][new_s],{node,new_s}});
    }
  }

  for(int i=1;i<n;i++){
    int ans=1e15;
    for(int k=0;k<MAX_S;k++){
      ans=min(ans,dist[i][k]);
    }
    cout<<ans<<"\n";
  }
}
signed main(){
  fastio
  cin>>n>>m>>S;
  S=min(S,MAX_S);  //check with bigger limits
  for(int i=0;i<m;i++){
    int u,v,cost_req,time_req;cin>>u>>v>>cost_req>>time_req;
    u--;v--;
    edges[u].emplace_back(v,cost_req,time_req);
    edges[v].emplace_back(u,cost_req,time_req);
  }
  for(int i=0;i<n;i++){
    int silver,time;cin>>silver>>time;
    _exchange.emplace_back(silver,time);
  }
  dijkstra(0);
  return 0;
}

Measured memory_bytes: 11380
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	vector<int> a(N + 1);
	int mx = -1e7, mi = 1e7, idx = 0, idi = 0;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		if (mx < a[i]) mx = a[i], idx = i ;
		if (mi > a[i]) mi = a[i], idi = i;
	}


	cout << 2 * N - 2 << endl;
	if (abs(mx) >= abs(mi)) {
		for (int i = 1; i <= N; i++) {
			if (i == idx)continue;
			cout << idx << " " << i << endl;
		}
		mi = 100;
	}

	else {
		for (int i = 1; i <= N; i++) {
			if (i == idi)continue;
			cout << idi << " " << i << endl;
		}
		mi = -100;
	}

	if (mi >= 0) {
		for (int i = 1; i <= N - 1; i++) {
			cout << i << " " << i + 1 << endl;
		}
	}

	else  {
		for (int i = N; i >= 2; i--) {
			cout << i << " " << i - 1 << endl;
		}
	}

}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const long long mod = 1e9 + 7;

void solve(){
	ll n; cin>>n;
	ll dp[2001]={0};
	dp[3]=1,dp[4]=1,dp[5]=1,dp[6]=2,dp[7]=3,dp[8]=4;
	for(int i=9;i<=n;i++){
		dp[i] = (dp[i-1]%mod + dp[i-3]%mod)%mod;
	}
	cout<<dp[n]<<"\n";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	//int t; cin>>t;
	//while(t--)
		solve();
		
    return 0;
}

Measured memory_bytes: 3576
N,X,Y = map(int, input().split())
ans = [0]*(N-1)

X = X-1
Y = Y-1

for i in range(N-1):
    for j in range(N-i-1):
        k = i + j + 1
        if k <= X+1 or Y-1 <= i:
            ans[k-i-1] = ans[k-i-1] + 1
        else:
            xy = abs(i-X)+1+abs(k-Y)
            if xy < k-i:
                ans[xy-1] = ans[xy-1] + 1
            else:
                ans[k-i-1] = ans[k-i-1] + 1

for ii in range(N-1):
    print(ans[ii])

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

using namespace std;

const int md = int(1e9) + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

const int N = 50, M = 1 << 17;
int dp[N][M];

int main() {
  int n, x, y, z, mask, haiku = 0;
  cin >> n >> x >> y >> z;
  haiku = (haiku << x) | (1 << (x - 1));
  haiku = (haiku << y) | (1 << (y - 1));
  haiku = (haiku << z) | (1 << (z - 1));

  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < M; j++) {
      for (int d = 1; d <= 10; d++) {
        mask = (j << d) | (1 << (d - 1));
        mask &= (M - 1);
        if ((mask & haiku) != haiku) {
          add(dp[i + 1][mask], dp[i][j]);
        }
      }
    }
  }

  int ans = power(10, n);
  for (int i = 0; i < M; i++) {
    sub(ans, dp[n][i]);
  }
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 22272
#
# abc051 b
#
import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    K, S = map(int, input().split())

    ans = 0
    for x in range(K+1):
        for y in range(K+1):
            z = S - x - y
            if z >= 0 and z <= K:
                ans += 1
    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 2"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5 15"""
        output = """1"""
        self.assertIO(input, output)


if __name__ == "__main__":
    #unittest.main()
    resolve()


Measured memory_bytes: 5876
#include <bits/stdc++.h>
#define int long long
#define Matrix vector<vector<int> >
// #define Matrix vector<vector<int> >
#define double long double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9+7;
const long long INF = 5e18;
const double pi = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
 
inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}
 
double rad(double x){
    return x*pi/180.0;
}
 
bool isleft(pair<int,int> a, pair<int,int> b, pair<int,int> c){
    int det = (b.first-a.first)*(c.second-a.second) - (c.first-a.first)*(b.second-a.second);
    if(det>=0) return true;
    if(det<0) return false;
    return false;
}
 
int exp(int a, int b){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = mod(result*a,MOD);
 
        b >>= 1;
        a = mod(a*a,MOD);
    }
    return result;
}
bool ok(int n, vector<vector<int> >&adj){
    for(int i=0;i<adj.size();i++){
        bool ok = false;
        for(int &j : adj[i]){
            if((j|n)==n){
                ok=true;
            }
        }
        if(!ok) return false;
    }
    return true;
}
int memo[123456];
int v[123456];
int n;
int dp(int pos){
    if(pos>n) return INF;
    if(pos==n) return 0;
    int &ans = memo[pos];
    if(ans!=-1) return ans;
    ans = min(abs(v[pos]-v[pos+1])+dp(pos+1),abs(v[pos]-v[pos+2])+dp(pos+2));
    return ans;
}
void solve(){
    memset(memo,-1,sizeof(memo));
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    cout<<dp(1)<<endl;
}
 
signed main(){
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 7720
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

string rStr(string str) {
  reverse(str.begin(), str.end());
  return str;
}

void solve() {
  set<string> dict;
  string train; cin>>train;
  
  for (int i = 1; i < train.size(); i += 1) {
    string lhs = train.substr(0,i), rhs = train.substr(i);
    string rLhs = rStr(lhs), rRhs = rStr(rhs);
    

    dict.insert(lhs + rhs);
    dict.insert(lhs + rRhs);
    dict.insert(rLhs + rhs);
    dict.insert(rLhs + rRhs);
    
    dict.insert(rhs + lhs);
    dict.insert(rhs + rLhs);
    dict.insert(rRhs + lhs);
    dict.insert(rRhs + rLhs);
  }
  cout<<dict.size()<<endl;
}

int main (int argc, char const* argv[]) {
  int n; cin>>n;
  
  for(int i=0;i<n;i++)
  solve();
  return 0;
}

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

#define ll long long
#define an "\n"
#define pb push_back
#define pob pop_back

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int sum=0, sum1=0, sum2=0, sum3=0;
	int n;
	cin >> n;
	while(n--) {
		string a;
		cin >> a;
		if(a=="AC") {
			sum++;
		}else if(a=="WA") {
			sum1++;
		}else if(a=="TLE" ){
			sum2++;
		}else if(a=="RE") {
			sum3++;
		}
	}
	cout << "AC x " << sum << an;
	cout << "WA x " << sum1 << an;
	cout << "TLE x " << sum2 << an;
	cout << "RE x " << sum3 << an;
}


Measured memory_bytes: 3632
class lazy_segtree:
  #遅延評価セグメント木
  def __init__(s, op, e, mapping, composition, id, v):
    if type(v) is int: v = [e()] * v
    s._n = len(v)
    s.log = s.ceil_pow2(s._n)
    s.size = 1 << s.log
    s.d = [e()] * (2 * s.size)
    s.lz = [id()] * s.size
    s.e = e
    s.op = op
    s.mapping = mapping
    s.composition = composition
    s.id = id
    for i in range(s._n): s.d[s.size + i] = v[i]
    for i in range(s.size - 1, 0, -1): s.update(i)
  
  # 1点更新
  def set(s, p, x):
    p += s.size
    for i in range(s.log, 0, -1): s.push(p >> i)
    s.d[p] = x
    for i in range(1, s.log + 1): s.update(p >> i)
 
  # 1点取得
  def get(s, p):
    p += s.size
    for i in range(s.log, 0, -1): s.push(p >> i)
    return s.d[p]
 
  # 区間演算
  def prod(s, l, r):
    if l == r: return s.e()
    l += s.size
    r += s.size
    for i in range(s.log, 0, -1):
      if (((l >> i) << i) != l): s.push(l >> i)
      if (((r >> i) << i) != r): s.push(r >> i)
    sml, smr = s.e(), s.e()
    while (l < r):
      if l & 1: 
        sml = s.op(sml, s.d[l])
        l += 1
      if r & 1:
        r -= 1
        smr = s.op(s.d[r], smr)
      l >>= 1
      r >>= 1
    return s.op(sml, smr)
 
  # 全体演算
  def all_prod(s): return s.d[1]
 
  # 1点写像
  def apply(s, p, f):
    p += s.size
    for i in range(s.log, 0, -1): s.push(p >> i)
    s.d[p] = s.mapping(f, s.d[p])
    for i in range(1, s.log + 1): s.update(p >> i)
 
  # 区間写像
  def apply(s, l, r, f):
    if l == r: return
    l += s.size
    r += s.size
    for i in range(s.log, 0, -1):
      if (((l >> i) << i) != l): s.push(l >> i)
      if (((r >> i) << i) != r): s.push((r - 1) >> i)
    l2, r2 = l, r
    while l < r:
      if l & 1: 
        sml = s.all_apply(l, f)
        l += 1
      if r & 1:
        r -= 1
        smr = s.all_apply(r, f)
      l >>= 1
      r >>= 1
    l, r = l2, r2
    for i in range(1, s.log + 1):
      if (((l >> i) << i) != l): s.update(l >> i)
      if (((r >> i) << i) != r): s.update((r - 1) >> i)
 
  def update(s, k): s.d[k] = s.op(s.d[2 * k], s.d[2 * k + 1])
  def all_apply(s, k, f):
    s.d[k] = s.mapping(f, s.d[k])
    if k < s.size: s.lz[k] = s.composition(f, s.lz[k])
  def push(s, k):
    s.all_apply(2 * k, s.lz[k])
    s.all_apply(2 * k + 1, s.lz[k])
    s.lz[k] = s.id()
  def ceil_pow2(s, n):
    x = 0
    while (1 << x) < n: x += 1
    return x

import sys
    
def e():
  return N - 1

def op(s, t):
  return min(s, t)

def mapping(f, a):
  return min(f, a)

def composition(f, g):
  return min(f, g)

def id():
  return N - 1

N, Q = list(map(int, input().split()))
Query = [list(map(int, input().split())) for _ in range(Q)]

v = [N - 2] * ((N - 2) * 2)


ans = (N - 2) * (N - 2)
seg = lazy_segtree(op, e, mapping, composition, id, v)

for q, x in Query:
  x -= 2
  l = 0
  r = 0
  t = 0
  if q == 1:
    t = N - 2
  if q == 2:
    l += N - 2
    r += N - 2
  g = seg.get(x + t)
  ans -= g
  r += g
  seg.apply(l, r, x)

print(ans)

Measured memory_bytes: 127076
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
       Scanner scan= new Scanner(System.in);
       int max=20000;

       for(int i=0;i<max;i++){
           int a=scan.nextInt();
           String op=scan.next();
           int b=scan.nextInt();

           if(op.equals("?")){
               break;
           }else if(op.equals("+")){
               System.out.println(a+b);
           }else if(op.equals("-")){
               System.out.println(a-b);
           }else if(op.equals("*")){
               System.out.println(a*b);
           }else if(op.equals("/")){
               System.out.println(a/b);
           }else {

           }
       }

    }
}



Measured memory_bytes: 26400
import java.util.*;
import static java.lang.System.*;

public class Main{
	static int R, S, P;
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int K = sc.nextInt();
	  //「自分が」それぞれの手を出して勝った時の得点
	  R = sc.nextInt(); 
	  S = sc.nextInt();
	  P = sc.nextInt();
	  String s = sc.next();
	  char[] T = s.toCharArray();
	  //出した手を記録 '?' は2通りの手を選べることを示す
	  char[] hands = new char[N+10]; 
	  long score = 0;
	  char myHand, forbiddenHand;
	  
	  //過去に出した手を考慮しなくていいパターン
	  for(int i=0; i<K; i++) {
		  myHand = victryHand(T[i]);
		  hands[i] = myHand;
		  score += (long)returnScore(myHand);
	  }
	  //過去に出した手を考慮するパターン
	  for(int i=K; i<N; i++) {
		  forbiddenHand = hands[i - K];
		  char hand = victryHand(T[i]);
		  //勝てる手と禁止されている手が同じ
		  if( forbiddenHand == hand) {
			  hands[i] = '?';
		  //違う
		  } else {
			  hands[i] = hand;
			  score += (long)returnScore(hand);
		  }
		  
	  }
	  
	  out.println(score);	  
	}
    //相手の出した手に勝てる手を返す
  	public static char victryHand(char enemyHand) {
  		if (enemyHand == 'r')
  			return 'p';
  		else if (enemyHand == 's')
  		  return 'r';
  		  else if(enemyHand == 'p')
  		return 's';
  		else 
  		   return ' ';
  	}
  	//自分の出した手に応じた得点を返す
  	public static int returnScore(char myHand) {
  		if(myHand == 'r')
  			return R;
  		else if(myHand =='s')
  			return S;
  		else if(myHand =='p')
  			return P;
  		else
  			return 0;
  	}
  }	  

Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n, k;
	cin >> n >> k;
	long long x[n];
	for (int i = 0; i < n; i++)
		cin >> x[i];
	long long m = -1;
	for (int i = 0; i <= n-k; i++) {
		if ((x[i] * x[i+k-1]) < 0) {
			if (m == -1)
				m = min(x[i+k-1]-x[i]+abs(x[i]), x[i+k-1]-x[i]+abs(x[i+k-1]));
			else
				m = min(m, min(x[i+k-1]-x[i]+abs(x[i]), x[i+k-1]-x[i]+abs(x[i+k-1])));
		} else {
			if (m == -1)
				m = max(abs(x[i]), abs(x[i+k-1]));
			else
				m = min(m, max(abs(x[i]), abs(x[i+k-1])));
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 4276
# 貪欲+山登り
import time

d = int(input())
dd = d * (d + 1) // 2
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
T = []
L = [-1 for j in range(26)]
for i in range(d):
    max_diff = -10**7
    arg_max = 0
    for j in range(26):
        memo = L[j]
        L[j] = i
        diff = S[i][j] - sum([C[k] * (i - L[k]) for k in range(26)])
        if diff > max_diff:
            max_diff = diff
            arg_max = j
        L[j] = memo
    T.append(arg_max)
    L[arg_max] = i


def calc_score(T):
    L = [-1 for j in range(26)]
    X = [0 for j in range(26)]
    score = 0
    for i in range(d):
        score += S[i][T[i]]
        X[T[i]] += (d - i) * (i - L[T[i]])
        L[T[i]] = i
    for j in range(26):
        score -= C[j] * (dd - X[j])
    return score


score = calc_score(T)
start = time.time()
cnt = 0
while True:
    now = time.time()
    if now - start > 1.8:
        break
    i = (cnt // 26) % d
    arg_max = 0
    max_diff = 0
    for j in range(26):
        memo = T[i]
        T[i] = j
        new_score = calc_score(T)
        if new_score - score > max_diff:
            max_diff = new_score - score
            arg_max = j
        T[i] = memo
    if max_diff > 0:
        T[i] = arg_max
        score += max_diff
    cnt += 1

for t in T:
    print(t + 1)


Measured memory_bytes: 76200
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  int N, x, ans = 0, a[1000];
  cin >> N >> x;

  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);

  for (int i = 0; i < N; i++) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    }
  }
  if (x > 0 && ans == N) ans--;

  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
double pie=3.14159265358979;
long long mod=998244353;
//
int main(){
	long long a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}

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

int main(){
    int a, b, i, c = 0;
    cin >> a >> b;
    for(i=a; i<=b; i++){
        if(i/10000 == i%10 && (i/1000)%10 == (i%100)/10){
            c++;
        }
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 3005;

int main() {
   ll x, k, d;
   cin >> x >> k >> d;
   x = abs(x);
   ll fuc = min(x / d, k);
   x -= fuc * d;
   k -= fuc;

   k &= 1;
   if(k) {
      ll y = x + d;
      ll z = x - d;
      x = min(abs(y), abs(z));
   }
   cout << x << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	if(a<=c)
	{
		c=c-a;
		a=0;
		
	 } 
	 if(a>c)
	 {
	 	a-=c;
	 	c=0;
	 }
	 if(b<=c)
	 {
	 	c-=b;
	 	b=0;
	 	
	 }
	 if(b>c)
	 {
	 	b-=c;
	 	c=0;
	 }
	 cout<<a<<' '<<b;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())))
l = [int(i) for i in range(-200, 201)]
ll = []
for idx in l:
    if idx not in p:
        ll.append(idx)
mn = 1000
if len(ll) == 0:
    print("")
else:
    mn = 1000
    for i in range(len(ll)):
        if abs(ll[i] - x) < mn:
            mn = abs(ll[i] - x)
            ans = ll[i]
    print(ans)

Measured memory_bytes: 9212
<?php
# 入力部
fscanf(STDIN, "%d", $r);
// fscanf(STDIN, "%d %d", $s, $w);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
// fscanf(STDIN, "%d", $n);
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%s", $s2);

# 処理部
// $arr1 = str_split($s1);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// for ($i = $a; $i <= $b; $i++) {
//   if ($i % $k == 0) {
//     $r = "OK";
//   }
// }
// $r = "safe";
// if ($s <= $w) {
//   $r = "unsafe";
// }

# 出力部
echo $r * 2 * M_PI . "\n";
// echo ($i * 1000) - $n . "\n";

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

typedef long long ll;

const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

ll ways[5001];
ll dp[5000][5001][2];
ll sub[2][5001][2];
vector<int> G[5000];
int cnt[5000];
void solve(int v, int par) {
	cnt[v] = 1;
	vector<int> child;
	for (int to : G[v]) {
		if (to == par) continue;
		solve(to, v);
		child.push_back(to);
		cnt[v] += cnt[to];
	}
	fill((ll*)sub, (ll*)(sub + 2), 0);
	sub[0][1][0] = 1;
	int sum = 1;
	for (int i = 0; i < child.size(); i++) {
		int c = child[i];
		for (int j = 1; j <= sum; j++) {
			for (int k = 0; k < 2; k++) {
				for (int l = 1; l <= cnt[c]; l++) {
					for (int m = 0; m < 2; m++) {
						// つなぐ
						(sub[(i + 1) % 2][j + l][(k + m) % 2] += sub[i % 2][j][k] * dp[c][l][m]) %= MOD;
						// つながない
						ll add = sub[i % 2][j][k] * dp[c][l][m] % MOD;
						(add *= ways[l]) %= MOD;
						(sub[(i + 1) % 2][j][(k + m + 1) % 2] += add) %= MOD;
					}
				}
			}
		}
		for (int j = 0; j <= cnt[v]; j++) sub[i % 2][j][0] = sub[i % 2][j][1] = 0;
		sum += cnt[c];
	}
	for (int i = 1; i <= cnt[v]; i++) for (int j = 0; j < 2; j++) dp[v][i][j] = sub[child.size() % 2][i][j];
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	ways[0] = 1;
	for (int i = 1; i <= N; i++) {
		if (i % 2 == 1) ways[i] = 0;
		else ways[i] = (ways[i - 2] * (i - 1)) % MOD;
	}
	solve(0, -1);
	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		(ans += dp[0][i][0] * ways[i] % MOD) %= MOD;
		(ans += MOD - (dp[0][i][1] * ways[i] % MOD)) %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 390400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

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

    vector<ll> ls(N);
    rep(i, N)
    {
        cin >> ls[i];
        if(ls[i]==0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    ll bans = 1;
    ll limit = powl(10, 18);
    rep(i, N)
    {
        bans = ans;
        ans*=ls[i];
        if(ans > limit || bans >= LONG_MAX/ls[i])
        {
            cout << - 1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3940
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int r=0,w=0;
	for(int i=0;i<s.size();i++)
		if(s[i]=='R')
			r++;
	for(int i=0;i<s.size();i++){
		if(w>=r){
			cout<<r<<endl;
			return 0;
		}
		if(s[i]=='W')
			w++;
		else
			r--;
	}
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define mp              make_pair
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define nl			    "\n"
#define w(x)            int x; cin>>x; while(x--)
#define fr(i,n)         for (int i = 0; i < n; ++i)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


int32_t main()
{
	FIO;

	int n, weight;int val=0;
	cin >> n >> weight;
	int v[n], w[n];
	fr(i,n){cin>>w[i]>>v[i];}
    val=n*1000;
	int dp[n+1][val+1];
	fr(i,n+1){fr(j,val+1) dp[i][j]=inf;}
	dp[0][0]=0;
	fr(i,n+1) dp[i][0]=0;

	int i,j;
	for(i=1;i<n+1;i++){

		for(j=1;j<val+1;j++){
			if(v[i-1]<=j){
				dp[i][j]=min(dp[i-1][j-v[i-1]]+w[i-1],dp[i-1][j]);
			}
			else {dp[i][j]=dp[i-1][j];};
		}
	}
	//fr(i,n+1){fr(j,val+1) {cout<<dp[i][j]<<" ";}cout<<nl;}
	i=0;
int pos=0;
	for( i=0;i<val+1;i++){
		if(dp[n][i]==inf) continue;
		if(dp[n][i] <= weight) 
            pos=i;
	}
	cout<<pos;
}


Measured memory_bytes: 79232
#include <stdio.h>
#define N 250

main(){
  int i, x, heap[N];
  
  scanf("%d", &x);
  
  for(i = 1; i <= x; i++){
    scanf("%d", &heap[i]);
  }
  
  for(i = 1; i <= x ; i++){
    printf("node %d: key = %d, ", i, heap[i]);
    
    if(i != 1){
      printf("parent key = %d, ", heap[i / 2]);
    }
    
    if(x >= i * 2){
      printf("left key = %d, ", heap[2 * i]);
    }
    
    if(x >= 1 + i * 2){
      printf("right key = %d, ", heap[2 * i + 1]);
    }
    
    printf("\n");
    
  }
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main()
{
    int a,b,x,y,sum;
    scanf("%d %d %d %d",&a,&b,&x,&y);
    if(a>b)
        sum=b;
    else
        sum=a;
    if(x>y)
        sum=sum+y;
    else
        sum=sum+x;
    printf("%d",sum);
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int depth[100000];
void dfs(const VVI& G, int u, int p, int d, VVI& dps){
  depth[u] = d;
  dps[d].PB(u);

  for(int to: G[u]){
	if(to == p) continue;
	dfs(G, to, u, d+1, dps);
  }
}

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

  int N;
  cin >> N;
  VVI G(N);
  REP(i,N-1){
	int a, b;
	cin >> a >> b;
	G[a].PB(b);
	G[b].PB(a);
  }

  VI rs;
  REP(i,N) if(SZ(G[i]) == 1){ rs.PB(i); }

  int ans = N;
  random_shuffle(ALL(rs));
  REP(loop,min(SZ(rs),100)){
	int r = rs[loop];
	VVI dps(N+1);
	dfs(G, r, -1, 0, dps);

	//cout<<r<<endl;
	//REP(d,N+1) cout << d<<": "<<dps[d]<<endl;

	int sum = 0;
	vector<bool> mkd(N);
	for(int d=N;d>=0;--d){
	  for(int u: dps[d]){
		int sz = 0;
		for(int to: G[u]){
		  if(depth[to] == d+1){
			if(!mkd[to]) ++sz;
		  else mkd[u] = true;
		  }
		}
		
		if(sz > 1){
		  sum += sz-1;
		  mkd[u] = true;
		}
	  }
	}
	mini(ans, sum);
  }
  
  cout << 1+ans << endl;

  return 0;
}


Measured memory_bytes: 19456
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll x;
    cin >> x;

    //本文
    ll ans = 0;
    if(x%11==0){
    ans = (x/11)*2;
    }
    else if(x%11!=0){
      ans = (x/11)*2+1;
      if(x%11>6){
        ans ++;
      }
    }
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3500
#include <iostream>
using namespace std;
int main(){
    string c;
    cin >> c;
    if(c == "a" || c == "i" || c == "u" || c == "e" || c == "o"){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }
    
}

fn main(){
    let line: Vec<usize> = read_as_vec();
    let (n, m) = (line[0], line[1]);


    let mut bridges: Vec<(usize, usize)> = Vec::new();
    for _ in 0..m{
        let line: Vec<usize> = read_as_vec();
        bridges.push((line[0], line[1]));
    }

    let mut ans_vec: Vec<usize> = vec![];
    let mut ans = n*(n-1)/2;

    let mut uf = UnionFind::new(n+1);
    let mut sizes: Vec<usize> = vec![1;n+1];
    for &(i, j) in bridges.iter().rev(){
        let root_i = uf.find(i);
        let root_j = uf.find(j);
        ans_vec.push(ans);
        if root_i != root_j{
            uf.union(i, j);
            let i_size = sizes[root_i];
            let j_size = sizes[root_j];
            sizes[uf.find(i)] = i_size + j_size;
            ans -= i_size*j_size;
        }
    }
    ans_vec.reverse();
    for ans in ans_vec{
        println!("{}", ans);
    }
}


Measured memory_bytes: 11644
package main

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

func main() {
	X, A := sc.nextInt(), sc.nextInt()
	if X < A {
		fmt.Println(0)
	} else {
		fmt.Println(10)
	}
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b = inpl()
if a < 10 and b < 10:
    print(a*b)
else:
    print(-1)

Measured memory_bytes: 38764
N,M = map(int,input().split())
es = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]

degs = [0] * N
for a,b in es:
    degs[a] += 1
    degs[b] += 1

if any(d%2 for d in degs):
    print('No')
    exit()
if any(d>=6 for d in degs):
    print('Yes')
    exit()

fours = degs.count(4)
if fours <= 1:
    print('No')
    exit()
elif fours >= 3:
    print('Yes')
    exit()

assert fours == 2
u = degs.index(4)
v = degs[u+1:].index(4) +u+1

g = [[] for i in range(N)]
for a,b in es:
    g[a].append(b)
    g[b].append(a)

for s in g[u]:
    visited = [0] * N
    stack = [s]
    first = True
    while stack:
        p = stack.pop()
        if p==u:
            print('Yes')
            exit()
        elif p==v:
            break
        visited[p] = 1
        for q in g[p]:
            if visited[q]: continue
            if first and q==u:
                first = False
                continue
            stack.append(q)
print('No')

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

int main() {
    string N;
    cin >> N;
    bool f = false;
    for (int i=0; i<3; i++){
        if (N[i] == '7'){
            f = true;
        } 
    }
    cout << (f?"Yes":"No") << endl;
}

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

#define itn long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define debug(x) cout << #x << "=" << (x) << endl;
const ll MOD=1e9+7;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
  while(1){
    string s;
    cin>>s;
    if(s=="#")return;
    string q="qwerttasdfgzxcvb";
    int st=0,res=0;
    if(q.find(s[0])==string::npos)
      st=1;
    for(int i=1;i<s.size();i++)
      if(q.find(s[i])!=string::npos){
        if(st){res++;st=0;}
      }else{
        if(!st){res++;st=1;}
      }
    cout<<res<<endl;
  }
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  solve();
  return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const ll Mod = 1e9 + 7;
const ll Inf = 2242545357980376863LL;
const ll Log = 20;
const ll N = 1ll << Log;
const int Maxn = 1e6 + 10;
const int Base = 101;

ll dp[Maxn];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	ll n;
	cin >> n;
	
	ll s = 0;
	dp[0] = 1;
	dp[1] = 1;
	s = 2;
	ll cnt, ans = 0;
	for(int i = 0; i <= n; i++){
		if(i >= 2){
			dp[i] = s - dp[i - 2];
			s = (s + dp[i]) % Mod;
		}
		if(i == n){
			ans += dp[i];		
		}
		if(i == n - 1){
			ans += dp[i] * (n - 1);
		}
		if(i < n - 1){
			cnt = (n-1) * (n - 1) + (i + 1);
			cnt %= Mod;
			//cerr << "!" <<  << '\n';
			ans += dp[i] * cnt;
		}
		ans %= Mod;
		//cout << ans << '\n';
	}
	cout << (ans + Mod) % Mod;
	
	
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int ans;
int h, w;
int ttm[30][30];

int c;

bool ok(int x, int y){
    return x == 0 ||
        y == 0 ||
        ttm[y][x] == ttm[y][x - 1] ||
        ttm[y][x - 1] == ttm[y - 1][x - 1] ||
        ttm[y - 1][x - 1] == ttm[y - 1][x] ||
        ttm[y - 1][x] == ttm[y][x];
}

void dfs(int x, int y){
    if (x == w){
        if (y == h - 1){
            ans++;
        }
        else dfs(0, y + 1);
        return;
    }

    if (ttm[y][x]){
        dfs(x + 1, y);
        return;
    }
    if (x + 1 != w && ttm[y][x + 1] == 0){
        ttm[y][x] = ttm[y][x + 1] = c++;
        if (ok(x, y)) dfs(x + 2, y);
        ttm[y][x] = ttm[y][x + 1] = 0;
    }
    if (y + 1 != h && ttm[y + 1][x] == 0){
        ttm[y][x] = ttm[y + 1][x] = c++;
        if (ok(x, y)) dfs(x + 1, y);
        ttm[y][x] = ttm[y + 1][x] = 0;
    }
}

int main(){
    while (cin >> h >> w && h){
        ans = 0;
        c = 1;
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                ttm[i][j] = 0;
        dfs(0, 0);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1172