akhauriyash/Code-Regression huggingface dataset:
import collections

n = int(input())
l = []

for _ in range(n):
    a = sorted(input())
    l.append("".join(a))
    
ls = collections.Counter(l)
r = list(ls.values())

def cul(n):
    return n*(n-1)/2

ans = 0
for i in r:
    ans += cul(i)
print(int(ans))

Measured memory_bytes: 24032
#include<stdio.h>

int main(){
  
  int i,j,k,l,year,month,day,n,count,max_day;
  int data[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    count=0;
    scanf("%d %d %d",&year,&month,&day);
    for(j=year;j<1000;j++){
      for(k=month;k<=10;k++){
	if( k%2 == 1 || j%3 == 0){
	  max_day = 20;
	}
	else if( k%2 == 0){
	  max_day = 19;
	}
	for(l=day;l<=max_day;l++){
	  count++;
	}
	day=1;
      }
      month=1;
    }
    data[i] = count;
  }
  for(i=0;i<n;i++){
    printf("%d\n",data[i]);
  }
  return 0;
}

Measured memory_bytes: 1024
from sys import stdin
import numpy as np
N=list(map(int,(stdin.readline().strip().split())))[0]
A=list(map(int,(stdin.readline().strip().split())))
num_list=[0]*N
moji=A[0]
i=0
length=len(A)-1
for i in A:
    num_list[i-1]+=1
for num in num_list:
    print(num)

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

int main() {
	// your code goes here
	int x,n,p,c;
	c=0;
	
	string s;
	cin>>s;
	if(s.size()%2!=0){
		x=s.size()/2;
		p=x;
		n=x;
		for(int i =0;i<x;i++){
			p--;
			n++;
			if(s[p]!=s[n])c++;
		}
	}
	else{
		x=s.size()/2;
		p=x-1;
		n=x;
		for(int i =0;i<x;i++){
			
			if(s[p]!=s[n])c++;
			
			p--;
			n++;
		}
		
	}
	cout<<c;
	
	// SUN, MON, TUE, WED, THU, FRI, or SAT, 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
mat g;
mat s;
lli a,b;
vbl vis;
lli e,o;


lli depth(lli x,lli p){
    lli j = -1;
    lli sum = 0;
    s[x] = vll(g[x].size());
    for(lli i = 0;i < g[x].size();i++){
        if(g[x][i] == p){
            j = i;
            continue;
        }
        s[x][i] = depth(g[x][i],x);
        sum += s[x][i];
    }
    if(j >= 0) s[x][j] = n-sum-1;
    return sum + 1;
}



int main(){
    cin >> n;
    g = mat(n+1);
    s = mat(n+1);
    for(lli i = 0;i < n-1;i++){
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if(n%2 == 1){
        cout << "First" << endl;
        return 0;
    }
    depth(1,0);
    for(lli i = 1;i <= n;i++){
        lli t = 0;
        for(lli j = 0;j < s[i].size();j++){
            if(s[i][j] % 2 == 1) t++;
        }
        if(t >= 2){
            cout << "First" << endl;
            return 0;
        }
    }
    cout << "Second" << endl;
    return 0;

}

Measured memory_bytes: 12032
//#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;
using namespace std;
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;
const int N = 2e5 + 123 ;
int n ;
int last[60];
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n ;  	int ans = 0;
	int l = 1;
	for(int i = 1 ; i <= n ; i++){
		int x;
		cin >> x;
	    for(int j = 0 ; j <= 20 ; j++)
	    	if(x & (1 << j))
	    		l = max(l , last[j] + 1) , last[j] = i;
	    ans += i - l + 1;
	}
	cout << ans;
}

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

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

//long mod = 10^^9 + 7;
long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto a = RD;
	auto s = RD!string;

	writeln(a >= 3200 ? s : "red");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main(){
    int x;
    cin >> x;
    if (x >= 30){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 3588
import java.util.*;
import java.text.DecimalFormat;
// warm-up
// Looks the original solution was actually correct
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		double n = sc.nextDouble(), x = sc.nextDouble(), t = 0, no = n;
		double[] a = new double[(int)n];
		int j = 0;
		while (no-->0) a[j++] = sc.nextDouble();
		if (a[0]>x) { t+=(a[0]-x); a[0]=x; } // Except this condition
		for (int i=0; i<n-1; i++) {
			if (a[i]+a[i+1]>x) {
				t+=a[i+1]-(x-a[i]);
				a[i+1] = x-a[i];
			}
		}
		System.out.println(new DecimalFormat("#").format(t));
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 63668
from itertools import product

N = int(input())
L = tuple(tuple(map(int,input().split())) for _ in range(N))

for xc,yc in product(range(101), repeat=2):
  s = set(abs(xc-x)+abs(yc-y)+h for x,y,h in L if h != 0)
  if len(s) == 1:
    H = next(iter(s))
    if all(abs(xc-x)+abs(yc-y) >= H for x,y,h in L if h == 0):
      print(xc,yc,H)
      break

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

using namespace std;

void FAST_IO() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

#define REP(_i, _a) for(int _i = 0; _i < (int)_a; ++_i)
#define FOR(_i, _a, _b) for(int _i = (int)_a; _i <= (int)_b; ++_i)
#define FORD(_i, _a, _b) for(int _i = (int)_a; _i >= (int)_b; --_i)
#define RESET(_a, _value) fill_n(_a,sizeof(_a)/sizeof(_a[0]),_v)
#define ALL(_a) _a.begin(), _a.end()
#define SIZE(_a) _a.size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define newline '\n';

// DEBUG UTIL
#define DEBUG(args...) { cerr << "> "; \
						 string _s = #args; \
						 replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); istream_iterator<string> _it(_ss); \
						 err(_it, args); }

void err(istream_iterator<string> it) { cerr << endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << ": " << a << " ";
	err(++it, args...);
}

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
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<ii> vii;

string format(const string& s, ...) {
    va_list args;
    va_start (args, s);
    size_t len = vsnprintf(NULL, 0, s.c_str(), args);
    va_end (args);
    std::vector<char> vec(len + 1);
    va_start (args, s);
    vsnprintf(&vec[0], len + 1, s.c_str(), args);
    va_end (args);
    return &vec[0];
}

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

void read() {
	int A, B;
	cin >> A >> B;
	if (A <= 8 && B <= 8) cout << "Yay!\n";
	else cout << ":(\n";
}

void solve() {
	
}

int main() {
	FAST_IO();

	int TC = 1;
	// cin >> TC;
	FOR(tc, 1, TC) {
		read();
		solve();
	}

	return 0;
}


Measured memory_bytes: 256
while a = gets
    a = a.split(" ").map{|i| i.to_i}
    b = gets.split(" ").map{|i| i.to_i}
    hit = blow = 0

    4.times do |i|
      if (a[i] == b[i]) then
        hit += 1
      else
        4.times do |j|
          if (a[i] == b[j])
            blow += 1
          end
        end
      end
    end

    puts "#{hit} #{blow}"

end

Measured memory_bytes: 6108
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s=sc.next(),t=sc.next();
    if(t.substring(0, s.length()).equals(s)) {
    	System.out.println("Yes");
    }else {
    	System.out.println("No");
    }
  }
}

Measured memory_bytes: 35728
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
template<class T=ll> 
T in(){T x;cin>>x;return (x);}
template<class T> 
void print(T &x){cout<<x<<"\n";}
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x"="<< (x) << "\n"
#define dbgv(x) cerr<<#x<<"\n";reps(y,x){cerr<<y<<" ";}cerr<<"\n"

inline char tc(){
  static char fl[100],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,100,stdin),A==B)?EOF:*A++;  
}
inline int read(){
  int a=0;static char c;
  while((c=tc())<48||c>57);
  while(c>=48&&c<=57)a=a*10+c-48,c=tc();
  return a;
}
int main(){
  ll n=in(),a;    
  deque<ll> b;
  rep(i,n){
    a=read();
    if(i%2){
      b.push_back(a);
    }else{
      b.push_front(a);
    }
  }
  if(n%2){
    rep(i,n){
      printf("%lld ",b[i]);
    }
  }else{
    rep(i,n){
      printf("%lld ",b[n-1-i]);
    }
  }
  printf("\n");
  return 0;
}

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

int main(){
  string s; ull k;
  cin >> s >> k;
  for(ull i=0;i<k;i++){
    if( s.at(i) != '1' ){
      cout << s.at(i) << endl;
      return 0;
    }
    if( i == k-1 ){
      cout << 1 << endl;
      return 0;
    }
  }
      
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  ll n;
  cin >> n;
  vl v(n);
  for (int i=0; i<n; i++){
    cin >> v[i];
    v[i] -= i+1;
  }
  sort(rng(v));
  ll ans=0;
    for (int i=0; i<n; i++){
      ans += abs(v[i]-v[n/2]);
    }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  int n, t;
  cin >> n >> t;
  vector<int> c(n), d(n);
  REP(i, n) cin >> c[i] >> d[i];

  int ret = INF;
  REP(i, n) {
    if(d[i] <= t) {
      chmin(ret, c[i]);
    }
  }

  if(ret == INF) cout << "TLE" << endl;
  else cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin >> n;
  //素因数分解
  map<int64_t,int64_t> mp;
  int64_t a = 2;
  while(n >= a*a){
    if(n %a == 0){
      if(mp.count(a)){
        mp[a]++;
      }
      else{
        mp[a] = 1;
      }
      n /= a;
    }  
    else{
      a++;
    }
  }
  if(mp.count(n)){
    mp[n]++;
  }
  else{
    mp[n] = 1;
  }
  
  int64_t ans = 0;
  
  for(auto itr = mp.begin(); itr !=mp.end(); itr++){
    int64_t cnt = 1;
    int64_t x = itr->second;
    while(x >= cnt){
      x -= cnt;
      ans++;
      cnt++;
    }
  }
  if(n == 1){
    ans = 0;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var r = int.Parse(Console.ReadLine());
        var contests = new [] 
        { 
            new { limit = 1200, name = "ABC" },
            new { limit = 2800, name = "ARC" },
            new { limit = int.MaxValue, name = "AGC" }
        };
        Console.WriteLine(contests.First(x => r < x.limit).name);
    }
}

Measured memory_bytes: 13268
import numpy as np

def main():
    A, B, H, M = map(int, input().split())
    r = M * 12 - (H * 60 + M)
    theta = (r*np.pi) / 360.0
    C = np.sqrt(A*A + B*B - 2*A*B*np.cos(theta))
    print(C)

if __name__ == '__main__':
    main()

Measured memory_bytes: 27200
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;
 
char str0[105];
char str1[105];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d%s%s", &n, str0, str1);
    vector<char> z;
    int i;
    for(i=0; i<n; i++) {
        z.push_back(str0[i]);
        z.push_back(str1[i]);
    }
    z.push_back('\0');
    printf("%s\n", &z[0]);



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define SZ(x) (int((x).size()))
#define leave_space putchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 2e6 + 20;
const int MOD = 1e9 + 7;
const int MUL = 32323;
string s, t, T;
vector<int> edge[MAXN >> 2];
int dp[MAXN >> 2], OK[MAXN >> 2], que[MAXN >> 2], deg[MAXN >> 2], fail[MAXN >> 2];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> T >> s;
	while (SZ(t) < SZ(s)) t += T; t += t;
	int oo = fail[0] = -1;
	rep (i, 1, SZ(s)) {
		while (~oo && s[i - 1] != s[oo]) oo = fail[oo];
		fail[i] = ++oo;
	}
	oo = 0;
	rep (i, 0, SZ(t) - 1) {
		while (~oo && t[i] != s[oo]) oo = fail[oo];
		if (++oo >= SZ(s)) OK[(i - SZ(s) + 1) % SZ(T)] = 1;
	}
	rep (i, 0, SZ(T) - 1) {
		if (OK[i] && OK[(i + SZ(s)) % SZ(T)]) {
			edge[i].pb((i + SZ(s)) % SZ(T)), ++deg[(i + SZ(s)) % SZ(T)];
		}
	}
	int l = 1, r = 0;
	rep (i, 0, SZ(T) - 1) {
		if (OK[i] && deg[i] == 0) {
			que[++r] = i;
		}
	}
	while (l <= r) {
		int u = que[l++];
		for (auto v : edge[u]) {
			if ((--deg[v]) == 0) {
				que[++r] = v;
			}
		}
	}
	rep (i, 0, SZ(T) - 1) if (deg[i]) {
		cout << -1 << endl; return 0;
	}
	int ans = 0;
	per (i, r, 1) {
		int now = que[i];
		if (edge[now].size() == 0) dp[now] = 1;
		else dp[now] = dp[(now + SZ(s)) % SZ(T)] + 1;
		ans = max(ans, dp[now]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 40264
package main

import "fmt"

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &k, &s)
	for i, c := range s {
		if i == k-1 {
			fmt.Printf("%c", c+0x20)
		} else {
			fmt.Printf("%c", c)
		}
	}
	fmt.Printf("\n")
}


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

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

int main(){
	string S;
	cin >> S;
	
	vector<pair<int,int>> x(S.size());
	vector<pair<int,int>> y(S.size());
	for(int i=0;i<S.size()-1;i++){
		if(S.at(i)=='R'){
			x.at(i+1).first=x.at(i).second+1;
			x.at(i+1).second=x.at(i).first;
			x.at(i).first=0;
			x.at(i).second=0;
		}
	}
	for(int i=S.size()-1;i>=1;i--){
		if(S.at(i)=='L'){
			y.at(i-1).first=y.at(i).second+1;
			y.at(i-1).second=y.at(i).first;
			y.at(i).first=0;
			y.at(i).second=0;
		}
	}
	//for(int i=0;i<S.size();i++)	cout << x.at(i).first << "," << x.at(i).second << "," << y.at(i).first << "," << y.at(i).second << endl;
	for(int i=0;i<S.size()-1;i++){
		if(S.at(i)=='R' && S.at(i+1)=='L'){
			cout << x.at(i+1).first + y.at(i).second << " ";
			cout << y.at(i).first + x.at(i+1).second << " ";
			i++;
		}
		else	cout << "0 ";
	}
	if(S.at(S.size()-2)!='R')	cout << 0;
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main() {
 ios::sync_with_stdio(false);
 cin.tie(0);
 int N,M;
 cin >> N >> M;
 pair<int, int> cor[M];
 int a,b;
 rep(i, M){
   cin >> a >> b;
   cor[i] = mp(min(a,b),max(a,b));
 }
 sort(cor,cor+M);
 int l=cor[0].first;
 int r=cor[0].second;
 int ans=M;
 rep1(i, M-1){
   if(r > cor[i].first){
     l=max(cor[i].first,l);
     r=min(cor[i].second,r);
     ans--;
     //     r=max(r,cor[i].second);
   }
   else{
     l=cor[i].first;
     r=cor[i].second;
   }
   //      cout << ans << endl;
 }
 cout << ans << endl;
  return 0;

}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  double m[2]={100};
  int n[2]={0};
  rep(i,3){
    vector<int>a(8);
	vector<double>b(8);
	rep(j,8)cin>>a[j]>>b[j];
	rep(j,7){
	  rep(k,7-j){
	    if(b[k]>b[k+1]){
		  swap(b[k],b[k+1]);
		  swap(a[k],a[k+1]);
		}
      }
	}
    //cout<<b[2]<<"!"<<b[3]<<endl;
	rep(j,2)printf("%d %.2f\n",a[j],b[j]);
	rep(k,2){
	  rep(j,2){
     	if(m[k]>b[j+2]){
		  if(k==0){
		    m[1]=m[0];
			n[1]=n[0];
		  }
	      m[k]=b[j+2];
	      n[k]=a[j+2];
		  b[j+2]=100;
		}
	  }
	}
	//rep(i,2)cout<<n[i]<<" "<<m[i]<<endl;
  }
  rep(i,2)printf("%d %.2f\n",n[i],m[i]);
}

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

bool warshallfloyd(
        vector<vector<long long>>& dist
        ) {
    for (int k = 0; k < dist.size(); ++k) {
        for (int i = 0; i < dist.size(); ++i) {
            for (int j = 0; j < dist.size(); ++j) {
                if (dist[i][k] == LONG_LONG_MAX || dist[k][j] == LONG_LONG_MAX) continue;
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    for (int i = 0; i < dist.size(); ++i) {
        if (dist[i][i] < 0) return false;
    }
    return true;
}

int main() {
    vector<string> s;
    int H, W;
    cin >> H >> W;
    s.push_back(string(W+2, '#'));
    for (int i = 0; i < H; ++i) {
        string ss;
        cin >> ss;
        ss = '#' + ss + '#';
        s.push_back(ss);
    }
    s.push_back(string(W+2, '#'));

    vector<vector<ll>> dist((H+2)*(W+2), vector<ll>((H+2)*(W+2), LONG_LONG_MAX));
    for (int i = 0; i < dist.size(); ++i) {
        dist[i][i] = 0;
    }
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            if (s[i][j] == '#') continue;
            if (s[i-1][j] == '.') {
                dist[i*W+j][(i-1)*W+j] = 1;
                dist[(i-1)*W+j][i*W+j] = 1;
            }
            if (s[i+1][j] == '.') {
                dist[i*W+j][(i+1)*W+j] = 1;
                dist[(i+1)*W+j][i*W+j] = 1;
            }
            if (s[i][j-1] == '.') {
                dist[i*W+j][i*W+j-1] = 1;
                dist[i*W+j-1][i*W+j] = 1;
            }
            if (s[i][j+1] == '.') {
                dist[i*W+j][i*W+j+1] = 1;
                dist[i*W+j+1][i*W+j] = 1;
            }
        }
    }
    warshallfloyd(dist);
    ll m = 0;
    for (int i = 0; i < dist.size(); ++i) {
        for (int j = 0; j < dist.size(); ++j) {
            if (dist[i][j] == LONG_LONG_MAX) continue;
            m = max(dist[i][j], m);
        }
    }
    cout << m << endl;
}


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

typedef long long ll;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
vector.erase(vector.begin() + index);
}


struct UnionFind{
    vector<int> par;
    vector<int> rank;

    UnionFind(int N):par(N),rank(N){
        for(int i = 0;i < N;i++){
          par[i] = i;
          rank[i] = 0;
        }
    }

    int root(int x){
       while(x != par[x]){
        x =  par[x] = par[par[x]];
       }
       return x;
    }

    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)return;
        if(rank[x] > rank[y]){
          par[y] = rx;
        }
        if(rank[x] < rank[y]){
          par[rx] = ry;
        }else{
          par[ry] = rx;
          if(rank[x] == rank[y]){
            rank[rx]++;
          }
        }
    }

    bool same(int x,int y){
      return root(x) == root(y);
    }
};

int main(){
 ll MOD = 998244353;
 ll N;
 cin >> N;
 vector<ll> D(N);
 vector<ll> cnt(N+10);
 for(ll i = 0;i < N;i++){
   cin >> D[i];
   cnt[D[i]]++;
 }
 if(D[0] != 0){
   cout << 0 << endl;
   return 0;
 }
 if(cnt[0] != 1){
   cout << 0 << endl;
   return 0;
 }
 ll ans = 1;
 for(ll i = 1;i < N+1;i++){
   ll t = 1;
   for(int j = 0;j < cnt[i+1];j++){
     t *= cnt[i];
     t %= MOD;
   }
   ans *= t; 
   ans %= MOD;
 }
 cout << ans % MOD << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int n, k;
  scanf("%d %d", &n, &k);
  
  int snk[n];
  for(int i = 0;i < n;i++){
    snk[i] = 0;
  }
  
  int a, d;
  for(int i = 0;i < k;i++){
    scanf("%d", &d);
    for(int j = 0;j < d;j++){
      scanf("%d", &a);
      snk[a - 1]++;
    }
  }
  
  int cnt = 0;
  for(int i = 0;i < n;i++){
    if(snk[i] == 0){
      cnt++;
    }
  }
  
  printf("%d", cnt);
  
  return 0;
}
  
  

Measured memory_bytes: 1728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] stringArray = br.readLine().split("\\s");

        Stack<Integer> que = new Stack<Integer>();
        int a = 0;
        int b = 0;
        for (int i = 0; i < stringArray.length; i++) {
            if (stringArray[i].equals("+")) {
                a = que.pop();
                b = que.pop();
                que.add(b + a);
                continue;
            }
            if (stringArray[i].equals("-")) {
                a = que.pop();
                b = que.pop();
                que.add(b - a);
                continue;
            }
            if (stringArray[i].equals("*")) {
                a = que.pop();
                b = que.pop();
                que.add(b * a);
                continue;
            }
            if (stringArray[i].equals("/")) {
                a = que.pop();
                b = que.pop();
                que.add(b / a);
                continue;
            }
            // 演算子以外はstackに登録する
            que.push(Integer.parseInt(stringArray[i]));
        }
        System.out.println(que.pop());
    }
}

Measured memory_bytes: 24476
s=input()
if s=='SUN':
  print(7)
elif s=='MON':
  print(6)
elif s=='TUE':
  print(5)
elif s=='WED':
  print(4)
elif s=='THU':
  print(3)
elif s=='FRI':
  print(2)
else:
  print(1)

Measured memory_bytes: 2940
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PocketPager pp;
		while(sc.hasNextLine()){
			pp = new PocketPager();
			System.out.println(pp.getMsg(sc.nextLine()));
		}
	}
}

class PocketPager{
	private static String msg;
	
	PocketPager(){
		msg = "";
	}
	
	public static String getMsg(String str){
		if(str.length()%2 != 0){
			return "NA";
		}
		
		return toMsg(str);
	}
	
	private static String toMsg(String str){
		for(int i=0;i<str.length();i+=2){
			if(str.charAt(i) == '1'){
				if(str.charAt(i+1) == '1'){
					msg += "a";
				}else if(str.charAt(i+1) == '2'){
					msg += "b";
				}else if(str.charAt(i+1) == '3'){
					msg += "c";
				}else if(str.charAt(i+1) == '4'){
					msg += "d";
				}else if(str.charAt(i+1) == '5'){
					msg += "e";
				}else{
					return "NA";
				}
			}else if(str.charAt(i) == '2'){
				if(str.charAt(i+1) == '1'){
					msg += "f";
				}else if(str.charAt(i+1) == '2'){
					msg += "g";
				}else if(str.charAt(i+1) == '3'){
					msg += "h";
				}else if(str.charAt(i+1) == '4'){
					msg += "i";
				}else if(str.charAt(i+1) == '5'){
					msg += "j";
				}else{
					return "NA";
				}
			}else if(str.charAt(i) == '3'){
				if(str.charAt(i+1) == '1'){
					msg += "k";
				}else if(str.charAt(i+1) == '2'){
					msg += "l";
				}else if(str.charAt(i+1) == '3'){
					msg += "m";
				}else if(str.charAt(i+1) == '4'){
					msg += "n";
				}else if(str.charAt(i+1) == '5'){
					msg += "o";
				}else{
					return "NA";
				}
			}else if(str.charAt(i) == '4'){
				if(str.charAt(i+1) == '1'){
					msg += "p";
				}else if(str.charAt(i+1) == '2'){
					msg += "q";
				}else if(str.charAt(i+1) == '3'){
					msg += "r";
				}else if(str.charAt(i+1) == '4'){
					msg += "s";
				}else if(str.charAt(i+1) == '5'){
					msg += "t";
				}else{
					return "NA";
				}
			}else if(str.charAt(i) == '5'){
				if(str.charAt(i+1) == '1'){
					msg += "u";
				}else if(str.charAt(i+1) == '2'){
					msg += "v";
				}else if(str.charAt(i+1) == '3'){
					msg += "w";
				}else if(str.charAt(i+1) == '4'){
					msg += "x";
				}else if(str.charAt(i+1) == '5'){
					msg += "y";
				}else{
					return "NA";
				}
			}else if(str.charAt(i) == '6'){
				if(str.charAt(i+1) == '1'){
					msg += "z";
				}else if(str.charAt(i+1) == '2'){
					msg += ".";
				}else if(str.charAt(i+1) == '3'){
					msg += "?";
				}else if(str.charAt(i+1) == '4'){
					msg += "!";
				}else if(str.charAt(i+1) == '5'){
					msg += " ";
				}else{
					return "NA";
				}
			}else{
				return "NA";
			}
		}
		
		return msg;
	}
}

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

int main() {
  int A, B;
  cin >> A >> B ;

  if( (A*B)%2 == 0 ){
    cout << "Even" << endl;
  }
  if( (A*B)%2 == 1 ){
    cout << "Odd" << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
unsigned long long n,d,fp,i,p,nr;
int main()
{
    cin>>n;
    for(d=2;d*d<=n;d++)
    {
        fp=0;
        while(n%d==0)
        {
            n/=d;
            fp++;
        }
        if(fp)
        {
            i=0;
            p=0;
            while(p<fp)
            {   i++;
                p=i*(i+1)/2;

            }
            if(p==fp)
                i++;
                i--;
                //cout<<fp<<" "<<i<<" ";
            nr+=i;
        }
    }
    if(n!=1)
        nr++;
    cout<<nr;
    return 0;
}


Measured memory_bytes: 3640
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
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))

n,a,b = inpl()
x = inpl()
res = 0
for i in range(n-1):
    if (x[i+1] - x[i])*a > b:
        res += b
    else:
        res += (x[i+1] - x[i])*a
print(res)

Measured memory_bytes: 59372
#include<iostream>
#include<string>
#include<set>
#include<cmath>
using namespace std;
int main()
{
  int n;
  long long ans=1;
  cin>>n;
  for(int i=1;i<=n;i++){
    ans*=i;
    if(ans>100000007)
      ans%=1000000007;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;
#define rep(i,a,b) for(ll i=a;i<b;i++)



void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}

int main(){

//   #ifndef ONLINE_JUDGE
//      freopen("input.txt", "r", stdin);
//   #endif
    ll n;
    cin>>n;
    if(n&1){
        cout<<n/2+1;
    }
    else
        cout<<n/2;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"sort"
	"strconv"
	"strings"
)

type JobList []Job

type Job struct {
	Estimate int
	Deadline int
}

func (jl JobList) Len() int {
	return len(jl)
}

func (jl JobList) Less(i, j int) bool {
	return jl[i].Deadline < jl[j].Deadline
}

func (jl JobList) Swap(i, j int) {
	jl[i], jl[j] = jl[j], jl[i]
}

func (p *problem) solve() {
	t := p.NextInt()
	var jobs JobList
	for i := 0; i < t; i++ {
		in := p.NextInts()
		jobs = append(jobs, Job{Estimate: in[0], Deadline: in[1]})
	}
	sort.Sort(jobs)
	clock := 0
	for _, job := range jobs {
		clock += job.Estimate
		if clock > job.Deadline {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

var (
	debug  bool
	output string
)

func main() {
	flag.BoolVar(&debug, "debug", false, "Print debug logs")
	flag.BoolVar(&debug, "d", false, "Print debug logs")
	flag.StringVar(&output, "output", "stdout", "Specify output target (Default: stdout)")
	flag.StringVar(&output, "o", "stdout", "Specify output target (Default: stdout)")
	flag.Parse()

	if debug {
		out := os.Stdout
		if output != "stdout" {
			logfile, err := os.OpenFile(output, os.O_CREATE|os.O_WRONLY, 0666)
			if err != nil {
				panic(err)
			}
			defer logfile.Close()
			out = logfile
		}
		log.SetOutput(out)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d\n", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) Printfln(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, fmt.Sprintf("%v\n", format), a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


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

int main(){
  int N;
  scanf("%d",&N);
  vector<int> v(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%d",&v[i]);
  }

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

  float ans = v[0];

  for (int i = 1; i <= N-1; i++)
  {
    ans = (ans + v[i]) / 2;
  }

  printf("%f", ans);

  return 0;
}


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

int main()
{


    int c1=0,c2=0,c3=0,c4=0;

    for(int i=0;i<3;i++){
        int ai,bi;
        cin>>ai>>bi;
        
        if(ai==1)
            c1++;
        else if(ai==2)
            c2++;
        else if(ai==3)
            c3++;
        else
            c4++;
        
        if(bi==1)
            c1++;
        else if(bi==2)
            c2++;
        else if(bi==3)
            c3++;
        else
            c4++;
        }


    if(max(max(max(c1,c2),c3),c4)>=3)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        edges: [(Usize1, Usize1); n - 1]
    };

    let mut graph = vec![Vec::new(); n];
    for &(u, v) in &edges {
        graph[u].push(v);
        graph[v].push(u);
    }
    let mut colors = HashMap::new();
    let mut que = VecDeque::new();
    let not_found = std::usize::MAX;
    // (u, parent)
    que.push_back((0, not_found));
    while let Some((u, parent)) = que.pop_front() {
        let pcolor = *colors.get(&(parent, u)).unwrap_or(&not_found);
        let mut color = 1;
        for &v in &graph[u] {
            if v == parent {
                continue;
            }
            if color == pcolor {
                color += 1;
            }
            colors.insert((u, v), color);
            que.push_back((v, u));
            color += 1;
        }
    }
    println!("{}", colors.values().max().unwrap());
    for e in edges {
        println!("{}", colors.get(&e).unwrap());
    }
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 14824
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  char s[LEN + 5]; int len,it;
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(len == LEN) fwrite(s,1,LEN,stdout), len = 0;
    s[len++] = c;
  }
  void flush(){
    fwrite(s,1,len,stdout);
    len = 0;
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get())
    res = (res << 3) + (res << 1) + (c - '0');
  return sig * res;
}
inline void putint(int x){
  if(!x) bufo.put('0');
  else if(x < 0) bufo.put('-'), x = -x;
  char s[15]; int k = 0;
  while(x){
    s[++k] = x % 10 + '0';
    x /= 10;
  }
  for(int i = k;i >= 1;i--) bufo.put(s[i]);
}

int main(){
  int n = getint(), a = getint(), b = getint();
  putint(min(n * a,b));
  bufo.flush();
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#AGC39 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def dfs(v,color):
    colors[v] = color
    for to in es[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and not dfs(to, -color):
            return False
    return True

def is_bipartite():
    return dfs(0,1)

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

n = I()
S = [input() for _ in range(n)]
dist = [[inf]*n for _ in range(n)]
colors = [0]*n
es = [[] for _ in range(n)]
for i in range(n):
    s = S[i]
    for j in range(i+1,n):
        if s[j] == '1':
            dist[i][j] = 1
            dist[j][i] = 1
            es[i].append(j)
            es[j].append(i)

for i in range(n):
    dist[i][i] = 0
d = warshall_floyd(dist)
flg = is_bipartite()
if not flg:
    print(-1)
    quit()
ans = 0
for i in range(n):
    ans = max(ans,max(d[i]))
print(ans+1)



Measured memory_bytes: 56540
import math
import collections

n = int(input())
iwashi = []
sub_ans = 0
for i in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        sub_ans += 1
    else:
        if b == 0:
            iwashi.append('1/0')
        elif b > 0:
            c = math.gcd(a, b)
            iwashi.append('{}/{}'.format(a//c, b//c))
        else:
            c = math.gcd(a, b)
            iwashi.append('{}/{}'.format(-a//c, -b//c))
# print(iwashi)
iwashi = collections.Counter(iwashi)
k_list = list(iwashi.keys())
v = list(iwashi.values())
# k_list.sort(key=lambda x: -x)

mod = 1000000007
ans = 1
for k in k_list:
    a = iwashi[k]
    if k == '1/0':
        anti_k = '0/1'
    elif k == '0/1':
        anti_k = '1/0'
    else:
        c, d = k.split('/')
        if int(c) < 0:
            anti_k = '{}/{}'.format(d, -int(c))
        else:
            anti_k = '{}/{}'.format(-int(d), c)

    b = iwashi[anti_k]
    if a*b != 0:
        ans *= (pow(2, a, mod) + pow(2, b, mod) -1)
    else:
        ans *= pow(2, a, mod)
    iwashi[k] = 0
    iwashi[anti_k] = 0
    # print(k, anti_k ,a, b, ans)
    ans %= mod
print((ans+sub_ans-1)%mod)


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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define y1 dhwjdshg

using namespace std;

const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

ll f(ll n, ll b)
{
    ll v = n / b;
    ll ans = (v - 1) * v / 2 * b;
    ans += (n - n / b * b + 1) * v;
    return ans;
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    rep(b, k + 1, n + 1)
    {
        ans += (b - k);
        ans += f(n - k, b) - f(n - b, b);
    }
    if (k == 0)
        ans -= n;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<tuple>
#include<stack>
#include<cmath>
using namespace std;
#define MAX 110

string T;
stack<tuple<int,int,int,int> > hoge;
stack<int> ans;
int main(){
	int A = 0, k, L, size, h = 0, highest = 0;
	
	cin>>T;
	
	size = T.size();
	
	for(int i = 0; i < size; i++){
		int temp = 0;
		if(T[i] == '/'){
			h++;
			temp = 1;
		} else if(T[i] == '\\'){
			h--;
			temp = -1;
		}
		
		if(highest >= h && temp == 1){
			int th = h-1, s = 1, x = 0;
			while(true){
				tuple<int,int,int,int> fuga = hoge.top(); hoge.pop();
				//cout<<i<<" "<<get<0>(fuga)<<" "<<get<1>(fuga)<<" "<<get<2>(fuga)<<" "<<get<3>(fuga)<<endl;
				if(get<0>(fuga) == -1){
					hoge.push(make_tuple(2,h,s+x,x+2));
					break;
				} else if(get<0>(fuga) == 2){
					s += get<2>(fuga);
					x += get<3>(fuga);
				} else if(get<0>(fuga) == 0){
					x += get<3>(fuga);
					
				}
				
			}
		} else hoge.push(make_tuple(temp,h,0,1));
		
		if(temp == -1) highest = max(h+1,highest);
	}
	
	size = hoge.size();
	
	for(int i = 0; i < size; i++){
		tuple<int,int,int,int> fuga = hoge.top(); hoge.pop();
		if(get<0>(fuga) == 2){
			ans.push(get<2>(fuga));
			A += get<2>(fuga);
			k++;
		}
	}
	
	cout<<A<<endl;
	
	k = ans.size();
	
	cout<<k;
	
	for(int i = 0; i < k; i++){
		int y = ans.top(); ans.pop();
		cout<<" "<<y;
	}cout<<endl;
	
	return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<int,P> PP;

//-----------------------------------------------------------------------------

int n;
set<char> st;

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

	cin>>n;
	REP(i,n) {
		char ch;cin>>ch;
		st.insert(ch);
	}
	if(st.size()==4) cout<<"Four"<<endl;
	else cout<<"Three"<<endl;

	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	int n,x;
	cin>>n>>x;
	int arr[n];
	for(int i = 0 ; i < n ; i++){
		cin>>arr[i];
	}
	int ans = 1;
	int temp = 0;
	for(int i = 0 ; i < n ; i++){
		int temp2 = temp + arr[i];
		if(temp2 > x){
			break;
		}
		ans++;
		temp = 	temp2;	
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include<iostream>

int main()
{
	int a;
	int b;
	int c;
	int d;


	std::cin >> a;
	std::cin >> b;

	c = a * 2 + b * 2;
	d = a*b;

	std::cout << d <<' '<< c << '\n';

	return 0;
}


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

long long dp[110][100110];
int v[110];
int w[110];

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

	for (int i = 1; i <= n; i++) cin >> w[i] >> v[i];
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= 100100; j++) dp[i][j] = 1e18;

	for (int i = 0; i <= n; i++) dp[i][0] = 0;

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= 100100; j++) {
			if (j - v[i] >= 0) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
				dp[i][j] = min(dp[i][j], dp[i - 1][j]);
			} else dp[i][j] = dp[i - 1][j];
		}
	}

	bool ok = false;
	long long ans = 0;
	for (int j = 100100; j >= 0; j--) {
			if (dp[n][j] <= sz) {
				ans = j;
				break;
			}
		
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 80128
#include <stdio.h>
int main(void) {
	int c;

	while (1) {
		c = getchar();
		if (c == EOF)
			break;
		if ('A' <= c && c <= 'Z')
			putchar(c + 0x20);
		else if ('a' <= c && c <= 'z')
			putchar(c - 0x20);
		else
			putchar(c);
	}
	return 0;
}

Measured memory_bytes: 524
/*
 * I won't be broken
 * I won't be tortured
 * I won't be beaten down
 * I have the answer
 * I can take the pressure
 * I will turn it all around
 * Lift me up above this
 * The flames and the ashes
 * Lift me up and help me to fly away
*/
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main(){
        scanf("%d%d",&a,&b);
        int pos = 1, x = b;
        while(x>0){
                pos*=10;
                x/=10;
        }
        x = a*pos+b;
        int sq = sqrt(x);
        if(sq*sq==x)
                printf("Yes\n");
        else
                printf("No\n");
        return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
using namespace std;
int a[200010];
int n;
int can(int x) {
	map<int, int> m;
	for (int i = 1; i < n; i++) {
		if (a[i-1] >= a[i]) {
			if (x == 1) return 0;
			map<int, int>::iterator it = m.lower_bound(a[i]);
			m.erase(it, m.end());
			int c = 1;
			for (int j = a[i]-1; j >= 0; j--) {
				if (!c) break;
				if (++m[j] >= x) {
					m.erase(j);
					c = 1;
				} else {
					c = 0;
				}
			}
			if (c) return 0;
		}
	}
	return 1;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	int lo = 0, hi = n;
	while (lo + 1 < hi) {
		int mid = (lo + hi) / 2;
		if (can(mid)) {
			hi = mid;
		} else {
			lo = mid;
		}
	}
	printf("%d\n", hi);
	return 0;
}


Measured memory_bytes: 1024