akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64_t r, D, cru;
  cin >> r >> D >> cru;
  REP(i,10) {
    int64_t nex = r * cru - D;
    cout << nex << endl;
    cru = nex;
  }
  return 0;
}
//templete by private_yusuke

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

using namespace std;

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

    vector<string> s(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    // cout << " 2222" << endl;
    for (int i = 0; i < N; ++i)
    {
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		
		if(x == 2) {
			System.out.println(2);
			return;
		}
		
		for(int i = x; true; i++) {
			double a = Math.sqrt(x);
			long b = Math.round(a);
			for(int j = 2; j <= b; j++) {
				if(i % j == 0) {
					break;
				} else if(j == b) {
					System.out.println(i);
					return;
				}
			}
		}

	}
}


Measured memory_bytes: 22100
#include <iostream>
#include <climits>

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int h[n+100];
    for (int i = 0; i < n; ++i) cin >> h[i];
    int dp[100100];
    fill(dp, dp + n, INT_MAX);
    dp[0] = 0;
    // for (int i = 0; i < n; ++i)
    for (int i = 0; i < n; ++i) for (int j = 1; j < k+1; ++j) chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    string s = "aaa";
    if(n==1) s = "a";
    if(n==2) s = "aa";   
    FOR(i,0,m){
        ll a,b;
        cin>>a>>b;
        if(s[a-1] != 'a' && s[a-1] != b + '0'){
            s = "-1";
            break;
        }
        s[a-1] = b + '0';
    }
    if(n != 1 && s[0] == '0') s = "-1";

    FOR(i,0,n){
        if(n!=1 && s[0] == 'a') s[0] = '1';
        else if(s[i] == 'a') s[i] = '0';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
//B - Count ABC
#include <bits/stdc++.h>
using namespace std;
int countAbc(int N,string S){
    int ans=0;
    for(int i=0;i<N-2;i++){
        if(S.substr(i,3) == "ABC")
          	ans++;
    }
    return ans;
}
int main(){
    int Number;
    string String;
    cin >> Number;
    cin >> String;
    cout << countAbc(Number,String);
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int num = 0;
		int stop = 0;
		for(int i = 0;i <= n;i++){
			num += i;
			stop = i;
			if(num >= n)break;
		}
		int sa = num - n;
		for(int i = 1;i <= stop;i++){
			if(sa != i)System.out.println(i);
		}
		

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 24148
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int N, K;
	cin >> N >> K;
	vector<double> p(N);
	vector<double> psum(N + 1);
	psum[0] = 0;
	rep(i, N) {
		cin >> p[i];
		p[i] /= 2.0;
		p[i] += 0.5;
		psum[i + 1] = psum[i] + p[i];
	}
	double psummax = 0.0;
	rep(i, N - K + 1) {
		double psumtmp = psum[i + K] - psum[i];
		psummax = max(psummax, psumtmp);
	}
	printf("%.12f", psummax);
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp;
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

ll powMod(ll a, ll n, ll mod){
    if(n == 0) return 1;
    if(n%2 == 0)
        return powMod(a, n/2, mod) * powMod(a, n/2, mod) % mod;
    else
        return a * powMod(a, n-1, mod)% mod;
}

ll ncrMod(ll n, ll r, ll mod){
    ll x=1, y=1;
    for(ll i = 1; i <= r; ++i){
        x *= n-i+1;
        x %= mod;
        y *= i;
        y %= mod;
    }
    return x * powMod(y, mod-2, mod) % mod;
}

int main() {
    string S;
    ll Q;

    cin >> S;
    cin >> Q;

    bool str_dir_is_right = true;

    for (int i = 0; i < Q; i++) {
        int q_type;
        cin >> q_type;

        if (q_type == 1) {
            str_dir_is_right = !str_dir_is_right;
        } else {
            int dir;
            char add;
            cin >> dir >> add;

            if (!str_dir_is_right) dir = (dir == 2) ? 1 : 2;

            if (dir == 1) {
                S.insert(S.begin(), add);
            } else {
                S.push_back(add);
            }
        }

    }

    if (str_dir_is_right) {
        cout << S;
    } else {
        for (auto it = S.rbegin(); it != S.rend(); it++) {
            cout << *it;
        }
    }

    return 0;
}



Measured memory_bytes: 900
H,W = map(int,input().split())
S = ["#"*(W+2)] + ["#" + input() + "#" for _ in range(H)] + ["#"*(W+2)]      

ans_C = [[0] * (W+2) for _ in range(H+2)]
ans_R = [[0] * (W+2) for _ in range(H+2)]


for w in range(1,W+1):              
    for h in range(1,H+1):
        if S[h][w] != "#":
            ans_C[h][w] = ans_C[h-1][w] + 1
            ans_R[h][w] = ans_R[h][w-1] + 1
            
for w in range(W,0,-1):
    for h in range(H,0,-1):
        if S[h][w] != "#":
            ans_C[h][w] = max(ans_C[h][w],ans_C[h+1][w])
            ans_R[h][w] = max(ans_R[h][w],ans_R[h][w+1])

ans_max = 0
for w in range(1,W+1):
    for h in range(1,H+1):
        ans_max = max(ans_max, ans_C[h][w]+ans_R[h][w])
        
print(ans_max-1)


Measured memory_bytes: 123864
#include<bits/stdc++.h>
#define maxn 200100
#define ll long long
using namespace std;
int n,a[maxn],b[maxn];
int main()
{
    scanf("%d",&n);
    bool ok=1;
    int mn=0x3f3f3f3f;
    ll ans=0;
    for(int i=1;i<=n;++i)
    {
        scanf("%d%d",&a[i],&b[i]);
        ok&=(a[i]==b[i]);
        if(a[i]>b[i]) mn=min(mn,b[i]);
        ans+=a[i];
    }
    if(ok) return 0*printf("0\n");
    cout<<ans-mn<<"\n";

    return 0;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int N;
    cin >> N;
    cout << N / 3 << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

twoSquare = [2**i for i in range(21)]

ans = 0
for i in range(N):
    n = i+1
    high = 20
    low = 0
    while high!=low:
        #print(high, low)
        mid = (high+low)//2
        if n*twoSquare[mid] >= K:
            high = mid
        else:
            low = mid + 1
    ans += 1/N/twoSquare[high]
print(ans)

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, ans=0;
	set<string> st;

	cin >> N;
	rep(i,N){
		string S;
		cin >> S;
		st.insert(S);
	}

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

	return 0;
}

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

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> h(n);
	rep(i, n) { cin >> h[i]; }

	sort(h.begin(), h.end(), greater<ll>());

	ll c = 0;
	for (ll i = 0; i < n; i++) {
		if (k > 0) {
			k--;
			continue;
		}
		c += h[i];
	}

	cout << c << endl;
}


Measured memory_bytes: 1792
/* In The Name Of God */
#include <bits/stdc++.h>

# define xx first
# define yy second
# define pb push_back
# define pp pop_back
# define eps 1e-9
# define err(x) cerr << #x << " ::   " << x << endl;

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
int n,m,k;
int main(){
	ios_base::sync_with_stdio (0);
	cin>>n>>m>>k;
	for(int i=0 ; i<=n ; i++)
		for(int j=0 ; j<=m ; j++){
			int tmp = i*j + (n-i)*(m-j);
			if(tmp==k){
				cout<<"Yes\n";
				return 0;
			}
		}
	cout<<"No\n";
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

    int x3, y3, x4, y4;

    x3 = x2 + (y1 - y2);
    y3 = y2 + (x2 - x1);
    x4 = x3 - (x2 - x1);
    y4 = y3 + (y1 - y2);

    printf("%d %d %d %d\n", x3, y3, x4, y4);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int d;
	cin>>d;
	cout<<"Christmas";
	rep(i,25-d)cout<<" Eve";
	cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))

using namespace std;

typedef vector<int> vi;

bool solve2(vi v){
  vi tmp = v;
  for(int i = 1; i <= 9; ++i){
    if(tmp[i] > 2) tmp[i]-=3;
    while(tmp[i] > 0 && i < 8){
      tmp[i]--; tmp[i+1]--; tmp[i+2]--;
    }
    //    REP(i, 1, tmp.size()) printf("%d ", tmp[i]);
    //    puts("");
    if( tmp[i+1] < 0 ||tmp[i+2] < 0) return false;
  }
  REP(i, 1, tmp.size()) if(tmp[i]) return false;
  //  REP(i, 1, tmp.size()) printf("%d ", tmp[i]);
  //  puts("");
  return true;
}

bool solve(vi v){
  vi tmp = v;
  for(int i = 1; i <= 9; ++i){
    if(tmp[i] < 2) continue;
    tmp[i] -= 2;
    //    puts("");
    //    REP(i, 1, tmp.size()) printf("%d ", tmp[i]);
    //    puts("");
    if(solve2(tmp)){
      //      REP(i, 1, tmp.size()) printf("%d ", tmp[i]);
      //      puts("");
   
      return true;
    }
    tmp[i] += 2;
  }
  return false;
}

int main(){
  char in[14];
  while(scanf("%s", in) != EOF){
    vi c(10, 0);
    rep(i, 13) c[in[i]-'0']++;
    //    rep(i, c.size()) printf("%d ", c[i]);
    //    puts("");
    vector<int> res;
    for(int i = 1; i <= 9; ++i){
      //      if(i != 8) continue;      
      if(c[i] > 3) continue;
      c[i]++;
      //      REP(i, 1, c.size()) printf("%d ", c[i]);
      //      puts("");
      if(solve(c)){
	res.push_back(i);
      }
      c[i]--;
    }
    //    printf("res\n");
    if(res.empty()) res.push_back(0);
    rep(i, res.size()) printf(i?" %d":"%d", res[i]);
    puts("");
  }
  return 0;
}

Measured memory_bytes: 1200
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int h, w;
    cin>>h>>w;

    vector<vector<bool>> grid(h, vector<bool>(w));
    fori(h) {
        string s;
        cin>>s;
        forn3(j, 0, w)
            grid[i][j]=(s[j]=='#');     /* walls */
    }

    
    vector<vector<int>> ans(h, vector<int>(w));
    const int MOD=1000000007;

    bool wall=false;
    fori(h) {
        if(grid[i][0])
            wall=true;
        ans[i][0]=wall?0:1;
    }
    wall=false;
    fori(w) {
        if(grid[0][i])
            wall=true;
        ans[0][i]=wall?0:1;
    }

    forn3(i, 1, h)
        forn3(j, 1, w) {
            if(grid[i][j])
                ans[i][j]=0;
            else
                ans[i][j]=(ans[i-1][j]+ans[i][j-1]) % MOD;
        }

    cout<<ans[h-1][w-1]<<endl;
}



Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<set>
#include<iomanip>
using namespace std;
using ll=long long int;

int main() {

	int n;
	while (cin >> n) {
		vector<int>a(n);
		for (int i = 0; i < n; i++)cin >> a[i];

		for (int i = 0; i < n-1; i++) {
			for (int j = i+1; j < n; j++) {
				if (abs(a[i] - a[j]) % (n - 1) == 0) {
					cout << a[i] << " " << a[j] << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}



Measured memory_bytes: 3104
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n;
        
        while(!((n=sc.nextInt())==0)){
            int Max=0;
            int Min=1000;
            int sum=0;
            int a;
            
            for(int i=0;i<n;i++){
                a=sc.nextInt();
                sum+=a;
                if(Max<a){
                    Max=a;
                }
                if(Min>a){
                    Min=a;
                }
            }
            int ave=(sum-Max-Min)/(n-2);
            System.out.println(ave);
        }
    }
}


Measured memory_bytes: 28724
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string S;
  cin >> S;
  ll K;
  cin >> K;
  if (S.size() == 1) {
    cout << S << endl;
    return 0;
  }

  REP(i, 0, min((ll) S.size(), K)) {
    if (S[i] >= '2') {
      cout << S[i] << endl;
      return 0;
    }
  }
  cout << '1' << endl;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
using namespace std;

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


 int ans=0;
 
 for(int i=1;i<n+1;i++){
   int cnt=0;
   for(int j=1;j<i+1;j++){
     if(i%j==0){
       cnt++;
     }
   }
   
   if(cnt==8){
     if(i%2!=0){
     ans++;
     }
   }
   cnt=0;
   }
 
 

 cout<<ans<<endl;



}

Measured memory_bytes: 256
N=int(input())
S = []
for _ in range(N):
    S.append(input())
A=S.count('AC')
W=S.count('WA')
T=S.count('TLE')
R=S.count('RE')
print('AC x '+ str(A))
print('WA x '+ str(W))
print('TLE x '+ str(T))
print('RE x '+ str(R))

Measured memory_bytes: 16296
#include <bits/stdc++.h>
#define res register int
#define inf 0x3f3f3f3f
#define DB long double
#define N 205
const DB pi = acos(-1);
using namespace std;
int n;
DB sumx[N], sumy[N];
DB ans;
inline int read(){
    res w = 0, X = 0; register char ch = 0;
    while(!isdigit(ch)){w |= ch == '-'; ch = getchar();}
    while(isdigit(ch)){X = (X << 1) + (X << 3) + (ch ^ 48); ch = getchar();}
    return w ? -X : X;
}
struct papa{
	DB x, y;
	DB k;
	inline bool operator < (const papa &b) const{
	  return k < b.k;
	}
}a[N]; 
inline DB sqr(DB x){
	return x * x;
}
int main(){
	n = read();
	for(res i = 1; i <= n; i++){
		a[i].x = read(), a[i].y = read();
		a[i].k = atan2(a[i].y, a[i].x);
	}
	sort(a + 1, a + n + 1);
	for(res i = n + 1; i <= n << 1; i++)
	  a[i] = a[i - n];
	for(res i = 1; i <= n << 1; i++)
	  sumx[i] = sumx[i - 1] + a[i].x, sumy[i] = sumy[i - 1] + a[i].y;
	for(res i = 1; i <= n << 1; i++)
	  for(res j = i; j <= n << 1; j++)
	    if(j - i + 1 <= n)
	    ans = max(ans, sqr(sumx[j] - sumx[i - 1]) + sqr(sumy[j] - sumy[i - 1]));
	printf("%.15Lf\n", sqrt(ans));
	return 0;
} 

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

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

	double sum=0;
	for (int i = 1; i <= n; ++i){
		if(i%2==1)sum++;
	}

	cout<<sum/n<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
main(){
	int n,i;
	int x[100],y[100];
	int ab;
	double ichijouwa,nijouwa,sanjouwa;
	double absmax;
	double d1,d2,d3,df;
	ichijouwa = 0;
	nijouwa = 0;
	sanjouwa = 0;
	absmax = 0;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
//		printf("%d\n",x[i]);
	}
	for(i=0;i<n;i++){
		scanf("%d",&y[i]);
//		printf("%d\n",y[i]);
	}

	for(i=0;i<n;i++){
		ab = abs(x[i] - y[i]);
//		printf("%f\n",(double)ab);
		if(ab > absmax){
			absmax = ab;
		}
		ichijouwa = ichijouwa + ab;
		nijouwa = nijouwa + ab * ab;
		sanjouwa = sanjouwa + ab * ab * ab;
	}
	d1 = ichijouwa;
	d2 = pow(nijouwa,(1.0/2.0));
	d3 = pow(sanjouwa,(1.0/3.0));
	df = absmax;

//	printf("%f %f %f\n",ichijouwa,nijouwa,sanjouwa);
	printf("%f\n%f\n%f\n%f\n",d1,d2,d3,df);

	return 0;
}

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

using namespace std;

vector< int > g[150000];
double ee[150000], ans[1500000];

void dfs1(int idx, int par)
{
  double ret = 0;
  int child = 0;

  for(int &to : g[idx]) {
    if(to == par) continue;
    dfs1(to, idx);
    ret += ee[to] + 1.0;
    ++child;
  }
  ee[idx] = 0;
  if(child >= 1) ee[idx] += ret / child;
}

void dfs2(int idx, double d_par, int par)
{
  vector< pair< int, int > > d_child;
  double ret = 0;
  for(int &to : g[idx]) {
    if(to == par) ret += 1.0 + d_par;
    else ret += 1.0 + ee[to];
  }
  ans[idx] = ret / g[idx].size();
  for(int &to : g[idx]) {
    if(to == par) continue;
    dfs2(to, (ret - ee[to] - 1.0) / max(1, (int) g[idx].size() - 1), idx);
  }
}

int main()
{
  int N;
  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);
  }

  dfs1(0, -1);
  dfs2(0, 0, -1);
  for(int i = 0; i < N; i++) {
    cout << fixed << setprecision(10) << ans[i] << endl;
  }
}

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

using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  int D = 0;
  int answer = 0;
  if (D <= X) answer++;
  for (int i = 0; i < N; i++) {
    int L;
    cin >> L;
    D += L;
    if (D <= X) answer++;
  }
  cout << answer;

  return 0;
}


Measured memory_bytes: 256
#include <cassert>
//PXjUXeZStdX
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
// #include <boost/foreach.hpp>
// #include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
//#define INF 1e9
#define LINF (1LL<<40)
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};
typedef pair<int,int> P;

const long long MOD=1000000007LL;
bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}
template<typename T> 
void print(vector<T> v){
    for(int i=0;i<v.size();i++){
        cout<<i<<": ";
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
}
int INF=1e18;

template<typename T>
void printendl(vector<T> v){
    for(auto date:v)cout<<date<<endl;
}

template<typename T>
void printvv(vector<vector<T>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}

struct Edge{
    int to,cost;
};


signed main (){
    int n;
    cin>>n;
    int ans=0;
    rep(i,1,n+1){
        if(to_string(i).size()%2==1)ans++;
    }
    cout<<ans<<endl;
}
/*


*/



Measured memory_bytes: 888
import fractions
n,m = map(int,input().split())
s=input()
t=input()
def answer(n,m,s,t):
    if s[0] != t[0]:
        return -1
    g = fractions.gcd(n,m)
    l = n*m//g
    i = 1
    while l*i < m*n:
        if s[l*i//m] != t[l*i//n]:
            return -1
        else:
            i += 1
    return l
print(answer(n,m,s,t))

Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

const int MAX_N = 1005;
const int MAX_V = MAX_N*(MAX_N-1)/2;
vector<int> to[MAX_V];
int id[MAX_N][MAX_N];
int n;
int toId(int i, int j) {
    if(i > j) swap(i, j);
    return id[i][j];
}

bool visited[MAX_V];
bool calculated[MAX_V];
int dp[MAX_V];  // from vの最長経路を保存する
int dfs(int v) {
    if(visited[v]) {
        if(!calculated[v]) return -1;
        return dp[v];
    }
    visited[v] = true;
    dp[v] = 0;
    for(int u : to[v]) {
        int res = dfs(u);
        if(res == -1) return -1;
        dp[v] = max(dp[v], dfs(u)+1);
    }
    calculated[v] = true;
    return dp[v];
}


int main() {
    cin >> n;
    vector< vector<int> > Amap(n, vector<int>(n-1));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n-1; ++j) {
            cin >> Amap[i][j];
            Amap[i][j]--;
        }
    }
    int V = 0;  // 頂点番号
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            if(i < j) {
                // 試合のセットを頂点としていく
                id[i][j] = V++;
            }
        }
    }
    for(int i = 0; i < n; ++i) {
        // 入力のAmapの数字を頂点番号へ書き換える
        for(int j = 0; j < n-1; ++j) {
            Amap[i][j] = toId(i, Amap[i][j]);
        }
        // 右に行くほど大きくなるように有向辺を張る
        for(int j = 0; j < n-2; ++j) {
            to[Amap[i][j+1]].push_back(Amap[i][j]);
        }
    }

    // トポロジカルソートしてる
    int ans = 0;
    for(int i = 0; i < V; ++i) {
        int res = dfs(i);
        if(res == -1) {
            // ループがある時点でどんなルートでもループにはまるのでエラー
            cout << -1 << endl;
            return 0;
        }
        chmax(ans, res+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 41868
#include <bits/stdc++.h>
using namespace std;
int a[55];
int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d", &a[i]);
    }
    sort(a+1, a+1+n);
    double ans = a[1];
    for(int i=2;i<=n;i++) ans = (ans + a[i])/2;
    printf("%.10lf\n", ans);
}

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

int main(){
    int64_t n, k, q, tmp;
    cin >> n >> k >> q;
    vector<int64_t> v(n, k - q);
    for(int i = 0; i < q; i++){
        cin >> tmp;
        v[--tmp]++;
    }
    for(int i = 0; i < n; i++){
        cout << (v[i] > 0 ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
n,c=map(int,input().split())
table=[0]*220000
chanels=[[]for i in range(c)]
for i in range(n):
    a,s,ch=map(int,input().split())
    chanels[ch-1].append((a,s))
for i in range(c):
    if chanels[i]:
        chanels[i].sort()
        x,y=chanels[i][0]
        for p,q in chanels[i][1:]+[(0,0)]:
            if y==p:y=q
            else:
                table[2*x-1]+=1
                table[2*y]-=1
                x,y=p,q

from itertools import accumulate
print(max(list(accumulate(table))))


Measured memory_bytes: 20700
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B;
  
  int Answer;

  Answer=2*max(A,B)-1; 
  
  if(A==B) Answer=2*A;
  
  cout << Answer << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <climits>
using namespace std;

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

  cout << int((T+0.5) / A) * B << endl;

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0 ; i<n ; i++){
    int b;
    cin >>b;
    a[i]=b;
  }
  sort(a.begin() , a.end() );
  long long ans = 0;
  ans += a[n-1];
  if(n%2 == 1){
  	for(int i=n-2;i>n/2 ; i--) ans += 2*a[i];
  	ans += a[n/2];
  }
  else
    for(int i=n-2;i>=n/2 ; i--) ans += 2*a[i];
  cout << ans << endl;
}


Measured memory_bytes: 4044
#include <iostream>
using namespace std;
int main(){
	int x;
	while(1){
		cin>>x;
		if(x==-1) break;
		else if(0<=x&&x<=10) cout<<4280-1150<<endl;
		else if(11<=x&&x<=20) cout<<4280-1150-125*(x-10)<<endl;
		else if(21<=x&&x<=30) cout<<4280-1150-125*10-140*(x-20)<<endl;
		else if(31<=x) cout<<4280-1150-125*10-140*10-160*(x-30)<<endl;
	}
}

Measured memory_bytes: 1160
from sys import stdin
from bisect import bisect_right, bisect_left


def input():
    return stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort()
    C.sort()

    ans = 0
    for b in B:
        ans += bisect_left(A, b) * (N - bisect_right(C, b))

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22720
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main() {
  int64_t n, k, a, b, c, xm, x0, ans, tmp;
  cin >> n >> k;
  vector<int64_t> v(n), pl, mi;
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  xm = lower_bound(v.begin(), v.end(), 0) - v.begin();
  x0 = upper_bound(v.begin(), v.end(), 0) - v.begin();
  a = xm*(n-x0);
  c = (n-x0)*(n-x0-1)/2 + xm*(xm-1)/2;
  b = n*(n-1)/2 - a - c;
  rep(i, n-x0) pl.push_back(v[x0+i]);
  rep(i, xm) mi.push_back(-1*v[i]);
  reverse(mi.begin(), mi.end());
  if(k > a + b){
    k -= a + b;
    tmp = 576460752303423488;
    rep(i, 59){
      int64_t l = 0;
      rep(j, n-x0){
        l += upper_bound(pl.begin(), pl.end(), tmp/pl[j]) - pl.begin();
        if(pl[j]*pl[j] <= tmp) --l;
      }
      rep(j, xm){
        l += upper_bound(mi.begin(), mi.end(), tmp/mi[j]) - mi.begin();
        if(mi[j]*mi[j] <= tmp) --l;
      }
      if(k > l/2) tmp += int64_t(pow(2, 58-i));
      else tmp -= int64_t(pow(2, 58-i));
    }
    k *= 2;
    rep(j, n-x0){
      k -= upper_bound(pl.begin(), pl.end(), tmp/pl[j]) - pl.begin();
      if(pl[j]*pl[j] <= tmp) ++k;
    }
    rep(j, xm){
      k -= upper_bound(mi.begin(), mi.end(), tmp/mi[j]) - mi.begin();
      if(mi[j]*mi[j] <= tmp) ++k;
    }
    if(k > 0) ++tmp;
    ans = tmp;
  }
  else if(k > a) ans = 0;
  else{
    tmp = 576460752303423488;
    rep(i, 59){
      int64_t l = 0;
      rep(j, n-x0){
        int64_t tmptmp = tmp/pl[j];
        if(tmp % pl[j] == 0) --tmptmp;
        l += xm - (upper_bound(mi.begin(), mi.end(), tmptmp) - mi.begin());
      }
      if(k > l) tmp -= int64_t(pow(2, 58-i));
      else tmp += int64_t(pow(2, 58-i));
    }
    rep(j, n-x0){
      int64_t tmptmp = tmp/pl[j];
      if(tmp % pl[j] == 0) --tmptmp;
      k -= xm - (upper_bound(mi.begin(), mi.end(), tmptmp) - mi.begin());
    }
    if(k > 0) --tmp;    
    ans = tmp * -1;
  }
  cout << ans << endl;
  return 0;
}

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


int main()
{
	int n, m;
	int a[101][101], b[101];
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++){
		cin >> b[i];
	}
	for (int i = 0; i < n; i++){
		int sum = 0;
		for (int j = 0; j < m; j++){
			sum += a[i][j] * b[j];
		}
		cout << sum << endl;
	}
	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i, m) cin >> x[i];
  if(n >= m) {
    cout << 0 << endl;
    return 0;
  }
  sort(ALL(x));
  vector<int> diff;
  rep(i, m-1) diff.push_back(x[i+1]-x[i]);
  sort(ALL(diff));
  int ans = 0;
  rep(i, m-n) ans += diff[i];
  cout << ans << endl;
}

Measured memory_bytes: 4188
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define INF (ll)1e9+5
#define dif 0.0000000001
#define pp pair<ll,ll> 
#define vv vector< pair<ll ,ll> > 
#define vi vector<ll> 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	
	if(a%3==0 || b%3==0 || (a+b)%3==0)
	{
		cout<<"Possible";
	}
	else
	{
		cout<<"Impossible";
	}
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

int calc(ll x) {
  int res = -1;
  for (int i = 0; i <= 60; i++) {
    if ((1LL << i) & x) {
      res = i;
    }
  }
  return res;
}

int main() {
  int n, t, flag;
  string s;
  set<ll> s1, s0;
  ll a[200];
  cin >> t;
  while (t--) {
    cin >> n;
    s0.clear();
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    cin >> s;
    flag = 0;
    for (int i = n - 1; i >= 0 && flag == 0; i--) {
      s1.clear();
      if (s[i] == '0') {
        set<ll>::reverse_iterator it = s0.rbegin();
        while (it != s0.rend()) {
          if (calc(*it) == calc(a[i])) {
            a[i] ^= *it;
          }
          it++;
        }
        if (a[i]) {
          set<ll>::reverse_iterator it = s0.rbegin();
          while (it != s0.rend()) {
            if (calc(*it) == calc(a[i])) {
              a[i] ^= *it;
            }
            it++;
          }
          s0.insert(a[i]);
        }
      } else {
        set<ll>::reverse_iterator it = s0.rbegin();
        while (it != s0.rend()) {
          if (calc(*it) == calc(a[i])) {
            a[i] ^= *it;
          }
          it++;
        }
        if (a[i]) {
          flag = 1;
        }
      }
    }
    cout << flag << endl;
  }
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9;
ll devine(ll x,ll y){
  if(x<0&&y<0){
    if(x%y<0){return (x/y)+1;}
  }
  return x/y;
}
ll amari(ll x,ll y){
  if(x<0&&y<0){
    if(x%y<0){return (x%y)-y;}
  }
  return x%y;
}
int main(){
  ll n,m,ans=0;
  cin>>n>>m;
  vll a(n),sum(n+1,0);
  set<ll> s;
  rep(i,0,n){
    cin>>a[i];a[i]%=m;
    sum[i+1]=sum[i]+a[i];
    sum[i+1]%=m;
    s.insert(sum[i]);
  }
  sort(sum.begin(),sum.end());
  auto itset=s.begin();
  rep(i,0,s.size()){
    auto it=upper_bound(sum.begin(),sum.end(),*(itset))-lower_bound(sum.begin(),sum.end(),*(itset));
    ans+=(it*(it-1))/2;
    itset++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4736
import heapq as hq

N, M = map(int, input().split())
A = []

for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b * (-1)])

A.sort()
# print(A)

ans = 0
j = 0
Q = []
hq.heapify(Q)

for i in range(1, M + 1):
    while j < len(A):
        if A[j][0] <= i:
            hq.heappush(Q, A[j][1])
            # print(Q)
        else:
            break
        j += 1
    if Q:
        ans += hq.heappop(Q) * (-1)


print(ans)


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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
#define fi first
#define se second

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int n, a[100000];
map<int, int> mp;


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        ++mp[a[i]];
    }
    int res = 0;
    rep(i, n) {
        if(a[i] > mp[a[i]]) {
            res += mp[a[i]];
            mp[a[i]] = a[i];
        }
        else if(a[i] < mp[a[i]]) {
            res += mp[a[i]] - a[i];
            mp[a[i]] = a[i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5120
n,a,b = map(int,input().split())

if(n > a*b)|(a+b > n+1):
    print(-1)
    exit()
if(a==1)|(b==1):
    if(b==n):
        ans = list(range(n,0,-1))
        print(' '.join(map(str,ans)))
    elif(a==n):
        ans = list(range(1,n+1))
        print(' '.join(map(str,ans)))
    else:
        print(-1)
    exit()

ans = []
top = n
while(top > 0):
    if(top-a >= b):
        for i in range(top-a+1,top+1):
            ans.append(i)
        top -= a
        b -= 1
        continue
    a = top-b+1
    for i in range(top-a+1,top+1):
        ans.append(i)
    for i in range(b-1,0,-1):
        ans.append(i)
    break

print(' '.join(map(str,ans)))

Measured memory_bytes: 108176
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int cur = 1;
  while(a>0 && c>0){
    if(cur){
      c-=b;
    }
    else a-=d;
    cur^=1;
  }
  if(a>0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }


return 0;
}
///....


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef struct _maze {
  int i;
  int j;
} Maze;

int main(void) {
  int h = 0, w = 0;
  cin >> h;
  cin >> w;
  vector<vector<int>> map(h+2, vector<int>(w+2, 0));
  
  // set map
  for(int i = 0; i < h+2; i++) {
    map[i][0] = -1;
    map[i][w+1] = -1;
  }
  for(int j = 0; j < w+2; j++) {
    map[0][j] = -1;
    map[h+1][j] = -1;
  }
  for(int i = 1; i < h+1; i++) {
    for(int j = 1; j < w+1; j++) {
      char ch;
      cin >> ch;
      if(ch == '.') map[i][j] = 0;
      else if(ch == '#') map[i][j] = -1;
    }
  }
  
  int max = 0;
  
  // BFS
  for(int i = 1; i < h+1; i++) {
    for(int j = 1; j < w+1; j++) {
      if(map[i][j] == -1) continue;
      vector<vector<int>> bfs_map(h+2, vector<int>(w+2, -1));
      queue<Maze> que;
      que.push(Maze{i, j});
      bfs_map[i][j] = 0; // set start position
      while(!que.empty()) {
        Maze m = que.front();
        que.pop();
        if(map[m.i-1][m.j] == 0 && bfs_map[m.i-1][m.j] == -1) {
          bfs_map[m.i-1][m.j] = bfs_map[m.i][m.j]+1;
          if(bfs_map[m.i-1][m.j] > max) max = bfs_map[m.i-1][m.j];
          que.push(Maze{m.i-1, m.j});
        }
        if(map[m.i+1][m.j] == 0 && bfs_map[m.i+1][m.j] == -1) {
          bfs_map[m.i+1][m.j] = bfs_map[m.i][m.j]+1;
          if(bfs_map[m.i+1][m.j] > max) max = bfs_map[m.i+1][m.j];
          que.push(Maze{m.i+1, m.j});
        }
        if(map[m.i][m.j-1] == 0 && bfs_map[m.i][m.j-1] == -1) {
          bfs_map[m.i][m.j-1] = bfs_map[m.i][m.j]+1;
          if(bfs_map[m.i][m.j-1] > max) max = bfs_map[m.i][m.j-1];
          que.push(Maze{m.i, m.j-1});
        }
        if(map[m.i][m.j+1] == 0 && bfs_map[m.i][m.j+1] == -1) {
          bfs_map[m.i][m.j+1] = bfs_map[m.i][m.j]+1;
          if(bfs_map[m.i][m.j+1] > max) max = bfs_map[m.i][m.j+1];
          que.push(Maze{m.i, m.j+1});
        }
      }
    }
  }
  cout << max;
  return 0;
}

Measured memory_bytes: 256
import heapq as hq

N, M = map(int, input().split())
A = [-a for a in list(map(int, input().split()))]
hq.heapify(A)

for _ in range(M):
    target = hq.heappop(A)
    hq.heappush(A, -(-target//2))

print(-sum(A))


Measured memory_bytes: 14180