akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct Po{ll x,y;}a[110];
int ansn,n;
map<pair<ll,ll>,int> s;
int main(){
	cin>>n;
	for (int i=1;i<=n;i++)cin>>a[i].x>>a[i].y;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (i!=j)s[make_pair(a[i].x-a[j].x,a[i].y-a[j].y)]++;
	for (auto i:s)ansn=max(ansn,i.second);
	cout<<n-ansn<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll k, a, b, ans;

int main(){
	cin >> k >> a >> b;
	
	ans = 1;
	if(a+2 >= b){ans += k;}
	else{
		ans += a-1;
		k -= a-1;
		if(k%2 == 0){ans += (b-a)*(k/2);}
		else{ans += (b-a)*(k/2)+1;}
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  for (auto &a : A) {
    cin >> a;
  }
  auto f = [&](int64_t x) {
    int64_t cnt = 0;
    for (auto a : A) {
      cnt += (a - 1) / x;
    }
    return cnt <= K;
  };
  int64_t lo = 1, hi = *max_element(A.begin(), A.end());
  while (lo < hi) {
    auto mi = (lo + hi) / 2;
    if (f(mi)) {
      hi = mi;
    } else {
      lo = mi + 1;
    }
  }
  cout << hi << '\n';
  return 0;
}


Measured memory_bytes: 4776
import numpy as np


S = [True if i == '1' else False for i in list(input())]

pat1 = [True, False] * (len(S) // 2)
pat2 = [False, True] * (len(S) // 2)
if len(S) % 2 == 1:
    pat1.append(True)
    pat2.append(False)

print(min(
    np.sum(np.logical_xor(S, pat1) == False),
    np.sum(np.logical_xor(S, pat2) == False)
))


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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}



int main() {
    int64_t N,total=0,c=0,naname=0;
    int64_t MOD =1000000007;
    cin >> N;
    vector<int64_t>A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    for(int i=0;i<N;i++){
        c+=A.at(i);

    }
    c%=MOD;
    for(int i=0;i<N;i++){
        total+=(c*A.at(i))%MOD;
        naname+=(A.at(i)*A.at(i))%MOD;
        total%=MOD;
        naname%=MOD;
    }
    total%=MOD;
    naname%=MOD;
    total=(total-naname)%MOD;
    if(total<0)
        total+=MOD;
    cout<<total * modinv(2, MOD) % MOD<<endl;
}

Measured memory_bytes: 4776
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	string S;
	cin >> N >> S;
	int res = 0;
	int x = 0;
	REP(i, N) {
		if (S[i] == 'I') {
			x++;
			res = max(res, x);
		}
		else if (S[i] == 'D') x--;
	}
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e20);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a>b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a<b ? : a = b; }



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

    vint wei(N + 1);
    vint val(N + 1);

    rep(i, N) {
        int w, v;
        cin >> w >> v;
        wei[i+1] = w;
        val[i+1] = v;
    }

    v2ll dp(N + 1, vll(W + 1, 0));
    ll max_value = 0;
    REP(i, 1, N + 1) {
        REP(j, 1, W + 1) {
            if (j - wei[i] >= 0)
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wei[i]] + val[i]);
            else
                dp[i][j] = dp[i - 1][j];
            if (i == N)
                max_value = max(max_value, dp[i][j]);
        }
    }
    cout << max_value << endl;

    return 0;
}

Measured memory_bytes: 80256
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
	}

	pw := true
	pm := make(map[int]bool)
	for i := range as {
		m := prime(as[i])
		for k, _ := range m {
			if _, ok := pm[k]; ok {
				pw = false
				break
			}
			pm[k] = true
		}
	}

	if pw {
		fmt.Println("pairwise coprime")
		return
	}

	sg := gcd(as[0], as[1])
	for i := 2; i < n; i++ {
		sg = gcd(sg, as[i])
		if sg == 1 {
			break
		}
	}

	if sg == 1 {
		fmt.Println("setwise coprime")
	} else {
		fmt.Println("not coprime")
	}
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	r := a % b
	for r != 0 {
		a = b
		b = r
		r = a % b
	}
	return b
}

func prime(a int) map[int]bool {
	m := make(map[int]bool)
	for i := 2; i <= sqrt(a); i++ {
		for a%i == 0 {
			a /= i
			m[i] = true
		}
	}
	if a > 1 {
		m[a] = true
	}
	return m
}

func sqrt(a int) int {
	return int(math.Sqrt(float64(a)))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 23032
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	for i := 0; i < y + 2; i++{
		fmt.Print("#")
	}
	fmt.Printf("\n")
	for i := 0; i < x; i++{
		fmt.Print("#")
		var s string
		fmt.Scan(&s)
		fmt.Printf("%s#\n",s)
	}
	for i := 0; i < y + 2; i++{
		fmt.Print("#")
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
  int n,temp,b;
  long long int ans=0;
  vector<int> v;
  cin>>n;
  rep(i,n){
    cin>>temp;
    temp=temp-i-1;
    v.pb(temp);
  }
  VSORT(v);
  b=v[(n-1)/2];
  rep(i,n){
    ans+=abs(v[i]-b);
  }
cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(){
    
   set<string> names;

   int N;
   string S;
   cin >> N;
   for(int i = 0; i < N; i++){
       cin >> S;
       names.insert(S);
   }
   cout << names.size() << endl;
   
   return 0;
}

Measured memory_bytes: 19116
s=input()
if len(s)==2:
  if s[0]==s[-1]:
    print(1,2)
    exit()
  else:
    print(-1,-1)
    exit()
    
for i in range(len(s)-2):
  a=s[i:i+3]
  if len(set(a))!=3:
    print(i+1,i+3)
    exit()
print(-1,-1)


Measured memory_bytes: 3188
sta=list(input())
stb=list(input())
max=0
for a in range(len(sta)-len(stb)+1):
    max1=0
    for b in range(len(stb)):
        if sta[a+b]==stb[b]:
            max1+=1
    if max1>max:
        max=max1
print(len(stb)-max)


Measured memory_bytes: 64992
#include <iostream>

using namespace std;

bool search(int S[], int n, int key) {
    S[n] = key;
    int i = 0;
    while(1) {
        if(S[i] == key) break;
        i++;
    }
    return i != n;
}

int main() {
    int n, q;
    cin >> n;
    int S[n + 1];
    for(int i = 0; i < n; i++) cin >> S[i];
    cin >> q;

    int cnt = 0;
    for(int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if(search(S, n, t)) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3116
#include <cstdio>

int check[30];

int main() {

  for (int bit = 29; bit >= 0; bit--) {
    check[bit] = 0;
  }

  int n;
  scanf("%d", &n);
  int xor_sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    xor_sum ^= a;
    a = a ^ (a - 1);

    switch (a) {
    case 1073741823:
      check[29] = 1;
      break;
    case 536870911:
      check[28] = 1;
      break;
    case 268435455:
      check[27] = 1;
      break;
    case 134217727:
      check[26] = 1;
      break;
    case 67108863:
      check[25] = 1;
      break;
    case 33554431:
      check[24] = 1;
      break;
    case 16777215:
      check[23] = 1;
      break;
    case 8388607:
      check[22] = 1;
      break;
    case 4194303:
      check[21] = 1;
      break;
    case 2097151:
      check[20] = 1;
      break;
    case 1048575:
      check[19] = 1;
      break;
    case 524287:
      check[18] = 1;
      break;
    case 262143:
      check[17] = 1;
      break;
    case 131071:
      check[16] = 1;
      break;
    case 65535:
      check[15] = 1;
      break;
    case 32767:
      check[14] = 1;
      break;
    case 16383:
      check[13] = 1;
      break;
    case 8191:
      check[12] = 1;
      break;
    case 4095:
      check[11] = 1;
      break;
    case 2047:
      check[10] = 1;
      break;
    case 1023:
      check[9] = 1;
      break;
    case 511:
      check[8] = 1;
      break;
    case 255:
      check[7] = 1;
      break;
    case 127:
      check[6] = 1;
      break;
    case 63:
      check[5] = 1;
      break;
    case 31:
      check[4] = 1;
      break;
    case 15:
      check[3] = 1;
      break;
    case 7:
      check[2] = 1;
      break;
    case 3:
      check[1] = 1;
      break;
    case 1:
      check[0] = 1;
      break;
    }
  }

  int ans = 0;
  for (int bit = 29; bit >= 0; bit--) {
    if (((1 << bit) & xor_sum) == 0) {
      continue;
    }
    int x = (1 << (bit + 1)) - 1;

    if (check[bit] > 0) {
      xor_sum ^= x;
      ans += 1;
    }
  }

  if (xor_sum != 0) {
    printf("-1\n");
  } else {
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#include <queue>

int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  std::priority_queue<int> A;
  for (int i = 0; i < N; ++i) {
    int a;
    scanf("%d", &a);
    A.push(a);
  }
  while (M > 0) {
    for (int i = 0; i < N; ++i) {
      if (M <= 0) break;
      --M;
      int top = A.top();
      A.pop();
      A.push(top/2);
    }
  }
  long long sum = 0;
  while (!A.empty()) {
    sum += A.top();
    A.pop();
  }
  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int INF = 1e9 + 3;
const int MOD = 1e9 + 7;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    priority_queue<  double, vector<double>, greater<double> > pq;
    vi a(n); for (int &x : a) {
        cin >> x;
        pq.push(x);
    }
    while ((int)pq.size() > 1) {
        double a = pq.top(); pq.pop();
        double b = pq.top(); pq.pop();
        pq.push((a + b) / 2);
    }
    cout << fixed << setprecision(20) << pq.top() << '\n';
    return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200

vector<int> G[SIZE];
vector<int> query[SIZE];
int N, M;
ll dp[1<<20];

int dfs(int now, int back = -1) {
  int res = 0;

  for (int to : G[now]) {
    if (to == back) continue;
    int b = dfs(to, now);

    for (int i=(1<<M)-1; i>=0; i--) {
      dp[i|b] = dp[i|b] + dp[i];
    }

    res ^= b;
  }

  for (int q : query[now]) {
    res ^= 1 << q;
  }

  return res;
}

int main() {

  cin >> N;

  for (int i=0; i<N-1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  cin >> M;

  for (int i=0; i<M; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    query[u].push_back(i);
    query[v].push_back(i);
  }


  dp[0] = 1;

  dfs(0);

  cout << dp[(1<<M)-1] << endl;

  return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define     int                 ll
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for(int i = 0; i < n; ++i){
    	cin >> a[i].xx >> a[i].yy;
    }
    sort(all(a),[&](pair<int, int> a, pair<int, int> b){
    	return a.xx+a.yy > b.xx+b.yy;
    });
    int ans = abs(a[n-1].xx-a[0].xx) + abs(a[n-1].yy-a[0].yy);
    sort(all(a),[&](pair<int, int> a, pair<int, int> b){
    	return a.xx-a.yy > b.xx-b.yy;
    });
    cout << max(ans, abs(a[n-1].xx-a[0].xx) + abs(a[n-1].yy-a[0].yy)) << '\n';
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 6368
#include <iostream>
#include <cmath>

int main() {
	int x = 1 , i = 1;
	do {
		std::cin >> x;
		if (x != 0) {
			std::cout << "Case " << i << ":" << " " << x << std::endl;
		}

		i++;

	}while(x != 0);
 }


Measured memory_bytes: 2988
N,P=map(int,input().split())
if N==1:
    print(P)
else:
    a=1
    for i in range(2,10**6+1):
        s=0
        while True:
            if P%i==0:
                P//=i
                s+=1
            else:
                if s>=N:
                    a*=i**(s//N)
                break
    print(a)

Measured memory_bytes: 3064
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> X(N), Y(N), Z(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i] >> Z[i];
  }

  ll ans = -(1LL << 61);
  for (int i = 0; i < 8; i++) {
    vector<ll> S(N);
    for (int j = 0; j < N; j++) {
      int x = (i >> 2 & 1) ? -1 : 1;
      int y = (i >> 1 & 1) ? -1 : 1;
      int z = (i >> 0 & 1) ? -1 : 1;
      S[j] = x * X[j] + y * Y[j] + z * Z[j];
    }
    sort(S.begin(), S.end(), [](ll a, ll b){return a > b;});
    ll sum = 0;
    for (int j = 0; j < M; j++) {
      sum += S[j];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

struct LazySegTree { //参照は + sz - 1;
	ll sz;
	vector<ll> node, lazy;
	vector<bool> lazyFlag;
	LazySegTree(ll n) {
		sz = 1;
		while (sz < n) sz *= 2;
		node.resize(2 * sz - 1, (1 << 31) - 1);
		lazy.resize(2 * sz - 1);
		lazyFlag.resize(2 * sz - 1);
	}
	void eval(ll k, ll l, ll r) {
		if (lazyFlag[k]) {
			node[k] = lazy[k];
			if (r - l > 1) {
				lazy[2 * k + 1] = lazy[k];
				lazy[2 * k + 2] = lazy[k];
				lazyFlag[2 * k + 1] = lazyFlag[2 * k + 2] = true;
			}
			lazyFlag[k] = false;
			lazy[k] = 0;
		}
	}
	void update(ll a, ll b, ll x, ll k = 0, ll l = 0, ll r = -1) {
		if (r < 0) r = sz;
		eval(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			lazyFlag[k] = true;
			eval(k, l, r);

		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}
	void update(ll a, ll x) {
		update(a, a + 1, x);
	}
	ll query(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
		if (r < 0) r = sz;
		eval(k, l, r);
		if (b <= l || r <= a) return (1 << 31) - 1;
		if (a <= l && r <= b) return node[k];
		ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
	void init() {
		REPR(i, sz - 2) node[i] = node[2 * i + 1] + node[2 * i + 2];
	}
};

int main() {
	ll n, q;
	cin >> n >> q;
	LazySegTree seg(n);
	REP(i, q) {
		ll t;
		cin >> t;
		if (t == 0) {
			ll a, b, c;
			cin >> a >> b >> c;
			b++;
			seg.update(a, b, c);
		}
		else {
			ll a, b;
			cin >> a >> b;
			b++;
			cout << seg.query(a, b) << endl;
		}
	}
}



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

int total;
vector<int> values;
vector<vector<int>> boxes;
vector<vector<int>> records;
int MAX = 100000000+10;

int choose(int key, int box_map){

    if(box_map == ((1 << total) - 1))
        return 0;

    if(key < 0)
        return MAX;

    if(records[key][box_map] != -1)
        return records[key][box_map];

    int updated_map = box_map;
    for(int i = 0; i < (int)boxes[key].size(); i++)
        updated_map |= (1 << boxes[key][i]);

    int yes = values[key] + choose(key - 1, updated_map);
    int no = choose(key - 1, box_map);
    int cost = min(yes, no);

    records[key][box_map] = cost;
    
    return cost;
}

int main(){
    int n, m;
    cin >> n >> m;
    total = n;

    values = vector<int>(m);
    boxes = vector<vector<int> >(m, vector<int>());
    for(int i = 0; i < m; i++){
        int num;
        cin >> values[i] >> num;
        for(int j = 0; j < num; j++){
            int box;
            cin >> box;
            boxes[i].push_back(box-1); 
        }

    }

    records = vector<vector<int>>(m, vector<int>(4096, -1));

    int result = choose(m-1, 0);
    if(result == MAX)
        cout << "-1";
    else
        cout << result;
    cout << "\n";


    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	unordered_set<int> no_snacks;
	cin >> n >> k;
	for(int i = 0; i < n; ++i) {
		no_snacks.insert(i);
	}
	for(int i = 0; i < k; ++i) {
		int d;
		cin >> d;
		for(int j = 0; j < d; ++j) {
			int s;
			cin >> s;
			no_snacks.erase(s - 1);
		}
	}
	cout << no_snacks.size() << "\n";
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h> 
using namespace std; 
typedef long long LL;
const LL INF = 1e18; 
const int MAX_N = 3e5 + 5; 
int N, M, a[MAX_N]; 
LL s[MAX_N]; 
int stk[MAX_N], top; 
LL F[MAX_N], G[MAX_N], H[MAX_N], y[MAX_N]; 
long double slope(int i, int j) { return 1.0 * (y[j] - y[i]) / (j - i); } 
void Init(LL f[]) { 
    for (int i = 1; i <= N; i++) s[i] = s[i - 1] + a[i];
    top = 0; 
    for (int i = 1; i <= N; i++) { 
        while (top && slope(stk[top - 1], stk[top]) <= 1.0 * i) --top; 
        int j = stk[top]; 
        f[i] = f[j] - s[i - 1] + s[j] + 1ll * (i - j) * (i - j - 1) / 2; 
        y[i] = f[i] + s[i] + 1ll * (i + 1) * i / 2; 
        while (top && slope(i, stk[top]) >= slope(stk[top], stk[top - 1])) --top;
        stk[++top] = i; 
    } 
} 
void chkmax(LL &x, LL y) { if (x < y) x = y; } 
LL t[MAX_N]; 
void Div(int l, int r) { 
    if (l == r) return chkmax(H[l], max(1ll - a[l], F[l] + G[l] - a[l] + 1)); 
    int mid = (l + r) >> 1; 
    Div(l, mid), Div(mid + 1, r);
    stk[top = 1] = 0; 
    for (int i = l - 1; i <= mid; i++) { 
        y[i] = F[i] + s[i] + 1ll * (i - 1) * i / 2; 
        while (top > 1 && slope(stk[top], i) >= slope(stk[top - 1], stk[top])) --top; 
        stk[++top] = i; 
    } 
    for (int i = mid + 1; i <= r; i++) { 
        while (top > 1 && slope(stk[top - 1], stk[top]) <= 1.0 * i) --top; 
        int j = stk[top]; 
        t[i] = F[j] - s[i] + s[j] + 1ll * (i - j + 1) * (i - j) / 2; 
    } 
    t[r] += G[r + 1]; 
    for (int i = r - 1; i > mid; i--) 
        t[i] += G[i + 1], chkmax(t[i], t[i + 1]); 
    for (int i = mid + 1; i <= r; i++) chkmax(H[i], t[i]); 
    stk[top = 0] = N + 1; 
    for (int i = mid + 1; i <= r + 1; i++) { 
        y[i] = G[i] - s[i - 1] + 1ll * (i + 1) * i / 2; 
        while (top > 1 && slope(stk[top], i) >= slope(stk[top - 1], stk[top])) --top;
        stk[++top] = i; 
    } 
    for (int i = l; i <= mid; i++) { 
        while (top > 1 && slope(stk[top - 1], stk[top]) <= 1.0 * i) --top; 
        int j = stk[top]; 
        t[i] = G[j] - s[j - 1] + s[i - 1] + 1ll * (j - i) * (j - i + 1) / 2;
    } 
    t[l] += F[l - 1]; 
    for (int i = l + 1; i <= mid; i++) 
        t[i] += F[i - 1], chkmax(t[i], t[i - 1]); 
    for (int i = l; i <= mid; i++) chkmax(H[i], t[i]); 
} 
int main() { 
    scanf("%d", &N); 
    for (int i = 1; i <= N; i++) scanf("%d", a + i); 
    Init(F); 
    reverse(&a[1], &a[N + 1]); 
    Init(G); 
    reverse(&G[1], &G[N + 1]); 
    reverse(&a[1], &a[N + 1]); 
    for (int i = 1; i <= N; i++) s[i] = s[i - 1] + a[i]; 
    for (int i = 1; i <= N; i++) H[i] = -INF; 
    Div(1, N); 
    scanf("%d", &M);
    while (M--) { 
        int p, x; scanf("%d %d", &p, &x); 
        printf("%I64d\n", max(F[p] + G[p], H[p] + a[p] - x)); 
    } 
    return 0; 
} 

Measured memory_bytes: 35264
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[10][10];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++)scanf("%s",in[i]);
	int ret=0;
	for(int i=0;i<(1<<a);i++){
		for(int j=0;j<(1<<b);j++){
			int tmp=0;
			for(int k=0;k<a;k++){
				for(int l=0;l<b;l++){
					if(i&(1<<k))continue;
					if(j&(1<<l))continue;
					if(in[k][l]!='#')continue;
					tmp++;
				}
			}
			if(tmp==c)ret++;
		}
	}
	printf("%d\n",ret);
}

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

using namespace std;

#define LL long long
#define N 320000
#define INF 0x3f3f3f3f3f3fLL

LL n,m,x,y,a[N],f[N],g[N],h[N],pre[N],ff[N],dp[N],stk[N];

inline double calc(LL x,LL y){return 1.0*(ff[x]-ff[y])/(x-y);}

void dp1(LL a[],LL f[]){
	pre[0]=a[0]; for (LL i=1;i<=n;++i) pre[i]=pre[i-1]+a[i];
	f[0]=0; ff[0]=2*pre[0]; stk[1]=0;
	for (LL i=1,tp=1;i<=n+1;++i){
		for (;tp>1&&calc(stk[tp-1],stk[tp])<i*2;--tp);
		f[i]=-2*pre[i-1]+i*i-i+ff[stk[tp]]-2*i*stk[tp];
		ff[i]=f[i]+i*i+i+2*pre[i];
		for (;tp>1&&calc(stk[tp-1],stk[tp])<calc(stk[tp],i);--tp);
		stk[++tp]=i;
	}
}

void solve(LL l,LL r){
	if (l==r){h[l]=max(h[l],f[l]+g[l]+2-a[l]*2); return;}
	LL mid=(l+r)>>1,tp=0;
	for (LL i=l;i<=mid;++i){
		ff[i]=f[i-1]+i*i-3*i+2*pre[i-1];
		for (;tp>1&&calc(stk[tp-1],stk[tp])<calc(stk[tp],i);--tp);
		stk[++tp]=i;
	}
	for (LL i=mid+1;i<=r;++i){
		for (;tp>1&&calc(stk[tp-1],stk[tp])<i*2;--tp);
		dp[i]=ff[stk[tp]]+g[i+1]+i*i+3*i-2*pre[i]+2-2*i*stk[tp];
	}
	dp[r+1]=-INF;
	for (LL i=r;i>mid;--i) h[i]=max(h[i],dp[i]=max(dp[i],dp[i+1]));
	tp=0;
	for (LL i=mid+1;i<=r;++i){
		ff[i]=g[i+1]+i*i+3*i-2*pre[i];
		for (;tp>1&&calc(stk[tp-1],stk[tp])<calc(stk[tp],i);--tp);
		stk[++tp]=i;
	}
	for (LL i=l;i<=mid;++i){
		for (;tp>1&&calc(stk[tp-1],stk[tp])<i*2;--tp);
		dp[i]=ff[stk[tp]]+f[i-1]+i*i-3*i+2*pre[i-1]+2-2*i*stk[tp];
	}
	dp[l-1]=-INF;
	for (LL i=l;i<=mid;++i) h[i]=max(h[i],dp[i]=max(dp[i],dp[i-1]));
	solve(l,mid); solve(mid+1,r);
}

int main(){
	scanf("%lld",&n);
	a[0]=a[n+1]=INF; for (LL i=1;i<=n;++i) scanf("%lld",a+i);
	dp1(a,f);
	reverse(a,a+n+2);
	dp1(a,g);
	reverse(g,g+n+2); reverse(a,a+n+2);
	pre[0]=a[0]; for (LL i=1;i<=n;++i) pre[i]=pre[i-1]+a[i];
	memset(h,0xcf,sizeof h);
	solve(1,n);
	scanf("%lld",&m);
	while (m--){
		scanf("%lld%lld",&x,&y);
		printf("%lld\n",max(f[x]+g[x],h[x]+a[x]*2-y*2)/2);
	}
	
	return 0;
}
			

Measured memory_bytes: 20352
n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]
d_bool = [d1==d2 for d1,d2 in d]
for b1,b2,b3 in zip(d_bool,d_bool[1:],d_bool[2:]):
    if b1&b2&b3:
        print("Yes")
        break
else:
    print("No")

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

int main() {
	string S;
	vector<char> station(3);

	cin >> S;

	for (int i = 0; i < 3; i++) {
		station.at(i) = S.at(i);
	}

	if ((station.at(0) == station.at(1)) &&
		 station.at(1) == station.at(2)) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 128
char s[N];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	bool ok = true;
	REP(i, n){
		if(i%2){
			if(s[i] == 'R') ok = false;
		} else {
			if(s[i] == 'L') ok = false;
		}
	}
	if(ok) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
main = getLine >>= putStrLn . toFmt . toTime . read
  where
    toTime s = map show ((s`div`60`div`60) : (s`div`60`mod`60) : (s`mod`60) : [])
    toFmt (x:y:z:w) = x ++ ":" ++ y ++ ":" ++ z

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    string s; cin >> s;
    int n = s.size();
    vector<vector<ll>> dp(n+5, vector<ll>(2, 0));
    dp[0][0] = 1;

    rep(i, n) rep(j, 2) {
        int lim = j? 1:s[i]-'0';
        rep(d, lim+1) {
            (dp[i+1][j || d<lim] += dp[i][j] * (d == 1? 2:1)) %= mod;
        }
    }
    ll ans = 0;
    rep(j, 2) ans += dp[n][j];
    chmod(ans);
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 5840
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=200005;
int head[maxn],t[maxn<<1],ne[maxn<<1],num,rd[maxn];
const int mod=1e9+7;
inline void addedge(int x,int y){
	ne[++num]=head[x];head[x]=num;t[num]=y;rd[x]++;
	ne[++num]=head[y];head[y]=num;t[num]=x;rd[y]++;
}
inline int powmod(int a,int b){
	int res=1;for(;b;b>>=1){
		if(b&1)res=1ll*res*a%mod;
		a=1ll*a*a%mod;
	}return res;
}
int n,fac[maxn],facinv[maxn];
inline int C(int n,int m){
	if(m<0||n<m)return 0;
	return 1ll*fac[n]*facinv[m]%mod*facinv[n-m]%mod;
}
inline void prprpr(){
	fac[0]=1;
	rep(i,1,200000)fac[i]=1ll*fac[i-1]*i%mod;
	facinv[200000]=powmod(fac[200000],mod-2);
	per(i,199999,0)facinv[i]=1ll*facinv[i+1]*(i+1)%mod;
}
bool vis[maxn];
int Queue[maxn],f[maxn];
inline int calc(int st){
	int front=0,finish=0;
	Queue[++finish]=st;vis[st]=1;
	while(front!=finish){
		int x=Queue[++front];
		forE(i,x)if(!vis[t[i]])
			vis[Queue[++finish]=t[i]]=1;
	}return finish;
}
int Q2[maxn],fr,ed;
inline void topsort(){
	while(fr!=ed){
		int x=Q2[++fr];
		forE(i,x){
			rd[t[i]]--;
			if(rd[t[i]]==1){
				Q2[++ed]=t[i];
			}
		}
	}
}
int size=0,sz[maxn],myt;
inline void dp(int x,int fa,int rt){
	forE(i,x){
		if(t[i]==rt||t[i]==fa)continue;
		dp(t[i],x,rt);
	}
	f[x]=1;sz[x]=0;
	forE(i,x){
		if(t[i]==rt||t[i]==fa)continue;
		if(t[i]<fa){
			f[x]=1ll*f[x]*f[t[i]]%mod*C(sz[x]+sz[t[i]],sz[t[i]])%mod;
			sz[x]+=sz[t[i]];
		}else{
			myt=1ll*myt*f[t[i]]%mod*C(size+sz[t[i]],sz[t[i]])%mod;
			size+=sz[t[i]];
		}
	}sz[x]++;
}
inline pin solve(int x){
	int res=0,tot=calc(x),m=0;
	fr=ed=0;
	rep(k,1,tot){
		int x=Queue[k];
		forE(i,x)m++;//,rd[t[i]]++;
		if(rd[x]==1)Q2[++ed]=x;
	}
	if(2*tot!=m)return mk(res,tot);
	topsort();ed=0;int rt=0;
	rep(i,1,tot)if(rd[Queue[i]]>1)rt=max(rt,Queue[i]);
	forE(i,rt)if(rd[t[i]]>1)Q2[++ed]=t[i];
	rep(i,1,ed){
		myt=1;size=0;
		dp(rt,Q2[i],rt);
		myt=1ll*myt*f[rt]%mod*C(size+sz[rt],sz[rt])%mod;
		res=(res+myt)%mod;
	}
	return mk(res,tot);
}
int main(){
	prprpr();
	read(n);
	rep(i,1,(n<<1))head[i]=-1;
	rep(i,1,n<<1){
		int x,y;read(x);read(y);
		addedge(x,y+n);
	}
	int ans=1;int sum=0;
	rep(i,1,n)if(!vis[i]){
		pin w=solve(i);
		ans=1ll*ans*w.w1%mod*C(sum+w.w2,w.w2)%mod;
		sum+=w.w2;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 11264
import itertools
N,M = map(int,input().split())
A = list(map(int,input().split()))
acc = itertools.accumulate(A)
acc = [e % M for e in acc]
cnt_dict = {}
ans = 0
for e in acc:
    if e == 0:
        ans += 1
    if e in cnt_dict:
        cnt_dict[e] += 1
    else:
        cnt_dict[e] = 0
    ans += cnt_dict[e]
print(ans)

Measured memory_bytes: 17236
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "l    ", long, "r");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto a = new long[](n);
    auto b = new long[](n);
    foreach (i; iota(n))
    {
        long a_, b_;
        scan(a_, b_);
        a[i] = a_;
        b[i] = b_;
    }
    long count;
    foreach_reverse (i; iota(n))
    {
        auto m = ((a[i] + count) % b[i]);
        if(m)
            count += b[i] - m;
    }
    count.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

class UnionFindTree {
private:
  vector<int> data;
  
  auto root(int x) -> int {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  auto size(int x) -> int {
    return -data[root(x)];
  }
  
public:
  UnionFindTree(int size) : data(size, -1) {}
  
  auto uniteTree(int x, int y) -> bool {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }

    return x != y;
  }
  
  auto isSameTree(int x, int y) -> bool {
    return root(x) == root(y);
  }
};

int main() {
  int n, q;

  cin >> n >> q;
  UnionFindTree ufTree = UnionFindTree(n);

  for (int i = 0; i < q; ++i) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 0) ufTree.uniteTree(x, y);
    else        cout << (ufTree.isSameTree(x, y) ? 1 : 0) << endl;
  }

  return 0;
}


Measured memory_bytes: 3136
#include<string.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int Ans, Temp, Data[100005];
int main() {
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> Data[i];
    Ans = Temp = 1;
    for(int i = 2; i <= N; i++)
        if(Data[i] <= Data[i - 1])
            Temp ++;
        else if(Data[i] > Data[i - 1])
            Ans = max(Ans, Temp), Temp = 1;
    Ans = max(Ans, Temp);
    cout << Ans - 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#DEBUG = ""


def _p(*obj):
    if "DEBUG" not in globals():
        return
    import inspect
    l = inspect.stack()[1].lineno
    print("[{}]: ".format(l), end='')
    from pprint import pprint
    pprint(*obj)


def isConnected(edges):
    _p(edges)
    nodes_from = []
    for n in range(N):
        nodes_from.append(
            [e[1] if e[0] == n else e[0] for e in edges if n in e]
        )
    _p(nodes_from)

    visited_nodes = set()
    next_nodes = set([0])
    while len(next_nodes) != 0:
        visited_nodes |= set(next_nodes)
        new_next_nodes = set()
        for n in next_nodes:
            new_next_nodes |= set(nodes_from[n])
        next_nodes = new_next_nodes - visited_nodes
    _p(visited_nodes)
    return len(visited_nodes) == N


def main():
    global N, M
    N, M = [int(i) for i in input().split()]
    edges = []
    for m in range(M):
        edges.append([int(i) - 1 for i in input().split()])

    count = 0
    for m in range(M):
        es = edges[:]
        es.pop(m)
        if not isConnected(es):
            count += 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<stdio.h>
  #define MAX 100000

  int parent(int);
  int left(int);
  int right(int);

  int main(){
    int H,i,A[MAX+1];

    scanf("%d",&H);
    for(i=1;i<=H;i++)scanf("%d",&A[i]);

    for(i=1;i<=H;i++){
      printf("node %d: key = %d, ",i,A[i]);
      if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);
      if(left(i)<=H)printf("left key = %d, ",A[left(i)]);
      if(right(i)<=H)printf("right key = %d, ",A[right(i)]);
      printf("\n");
    }
    return 0;
  }

  int parent(int i){return i/2;}
  int left(int i){return i*2;}
  int right(int i){return i*2+1;}

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

N = int(input())
h = list(map(int, input().split()))

#dp = {}
NOT_FOUND = pow(10, 4) + 1
def sget(i):
    if i in dp:
        return dp[i]
    return NOT_FOUND

#dp = {0: 0, 1: abs(h[0] - h[1])}
#for i in range(2, N):
#    dp[i] = min(sget(i-2) + abs(h[i] - h[i-2]),
#                sget(i-1) + abs(h[i] - h[i-1]))
#print(dp[N-1])

dp = {0: 0}
for i in range(1, N):
    #dp[i] = min(sget(i), sget(i-1) + abs(h[i] - h[i-1]))
    dp[i] = sget(i-1) + abs(h[i] - h[i-1])
    if i > 1:
        dp[i] = min(sget(i), sget(i-2) + abs(h[i] - h[i-2]))
print(dp[N-1])

#def main(N, hs):
#    dp[0] = 0
#    #for i in range(1, N):
#    #    dp[i] = chmin(sget(i), sget(i - 1) + abs(hs[i] - hs[i - 1]))
#    #    if i > 1:
#    #        dp[i] = chmin(sget(i), sget(i - 2) + abs(hs[i] - hs[i - 2]))
#    #def rec(i):
#    #    if sget(i) < NOT_FOUND:
#    #        return sget(i)
#    #    if i == 0:
#    #        return 0
#    #    res = NOT_FOUND
#    #    res = chmin(res, rec(i-1) + abs(hs[i] - hs[i-1]))
#    #    if (i > 1):
#    #        res = chmin(res, rec(i-2) + abs(hs[i] - hs[i-2]))
#    #    dp[i] = res
#    #    return dp[i]
#    #return rec(N-1)
#    return dp[N-1]


Measured memory_bytes: 23216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mx = 1e5+10,p = 1e2+10;
ll n,w;
ll weight[mx];
ll cost[mx];
ll dp[p][mx];
ll solve(ll i,ll we)
{
    ll profit,profit1;
    if(i==n)
        return 0;
    if(dp[i][we]!=-1)
        return dp[i][we];
    if(we+weight[i]<=w)
    {
        profit = cost[i]+solve(i+1,we+weight[i]);
    }
    else profit = 0;

    profit1 = solve(i+1,we);
    return dp[i][we] = max(profit,profit1);
}
int main()
{
    cin>>n>>w;
    for(int i=0;i<n;i++)
    {
        cin>>weight[i]>>cost[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<(ll)solve(0,0)<<endl;
}


Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n; cin>>n;
	VL a(3*n); rep(i,3*n) cin>>a[i];
	priority_queue<ll, VL, greater<ll>> q;
	priority_queue<ll> r;
	VL s(3*n), t(3*n);
	ll sum=0LL;
	rep(i,n){
		sum+=a[i]; q.push(a[i]);
		s[i]=sum;
		// cerr<< i SP sum <<endl;
	}
	rep(i,n){
		q.push(a[n+i]);
		sum+=a[n+i]-q.top(); q.pop();
		s[n+i]=sum;
	}

	sum=0LL;
	rep(i,n){
		sum+=a[3*n-i-1]; r.push(a[3*n-i-1]);
		t[3*n-i-1]=sum;
		// cerr<< i SP sum <<endl;
	}
	rep(i,n){
		r.push(a[2*n-i-1]);
		sum+=a[2*n-i-1]-r.top(); r.pop();
		t[2*n-i-1]=sum;
	}
	// rep(i,3*n){
	// 	cerr<<i SP s[i] SP t[i]<<endl;
	// }
	ll ans=-LINF;
	for(int i=n-1;i<2*n;i++){
		chmax(ans,s[i]-t[i+1]);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 9588
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<double, double > pi; 
typedef pair<pair<ll ,ll >,ll > pii; 
//辞書順最小
//なるべく後ろにあるハテナに文字列を入れる
int main(){
    
    string S, T;
    cin >> S >> T;
    
    if(S.length() < T.length()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    ll posi = -1;
    for(ll i = 0; i <= S.length() - T.length(); i++){
        bool fin = true;
        //cout << i << " " << S[i] << endl;
        for(ll j = i; j < i + T.length(); j++){
            //cout << j - i << endl;
            if(S[j] == '?' || S[j] == T[j - i]){
                continue;
            }else{
                fin = false;
                break;
            }
        }
        
        //復元
        if(fin == true){
            posi = i;
        }
    }

    if(posi != -1){
        string ans;
        //前半穴埋め
        for(ll j = 0; j < posi; j++){
            if(S[j] == '?'){
                ans += 'a';
            }else{
                ans += S[j];
            }
        }
        ans += T;
        //後半穴埋め
        for(ll j = posi + T.length(); j < S.length(); j++){
            if(S[j] == '?'){
                ans += 'a';
            }else{
                ans += S[j];
            }
        }
        cout << ans << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>  
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
#include <cmath>
#include <cstdlib>
#include <map>

using namespace std;  
typedef long long ll;
int main()
{
	ll n;
	ll a, b;
	while(~scanf("%lld %lld %lld", &n, &a, &b))
	{
		ll sum1 = 0;
		ll c, d, e, f, g, wa = 0 ;
		for(ll i = 0; i <= n; i++)
		{
			int j= i;
			/*c = i % 10;
			d = i / 10;
			e = i / 100;
			f = i / 1000;
			g = i / 10000;
			h = c + d + e + f + g; */
		wa+=j%10;
        j=j/10;
        wa+=j%10;
        j=j/10;
        wa+=j%10;
        j=j/10;
        wa+=j%10;
        j=j/10;
        wa+=j%10;
			if( wa >= a && wa <= b)
				sum1 += i;
			wa= 0;
	//		h = 0;
		}		
		printf("%lld\n", sum1);
	}
}

Measured memory_bytes: 256