akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
 
public class Hello
{
    public static void Main()
    {
        char[] s = Console.ReadLine().ToCharArray();
        char[] t = Console.ReadLine().ToCharArray();
 
        Array.Sort(s);
        Array.Sort(t);
        Array.Reverse(t);
        if (new string(s) == new string(t)) { Console.WriteLine("No"); return; }
        for (int i = 0; i < Math.Min(s.Length, t.Length); i++)
        {
            //Console.WriteLine("s[" + i + "] : " + s[i]);
            //Console.WriteLine("t[" + i + "] : " + t[i]);
            if (s[i] < t[i]) { Console.WriteLine("Yes"); return; }
            else if (s[i] > t[i]) { Console.WriteLine("No"); return; }
            else
            {
                //if(i + 1 >= s.Length) { Console.WriteLine("Yes"); return; }
                if (i + 1 >= Math.Min(s.Length, t.Length)) {
                  if( t.Length > s.Length )
                  	Console.WriteLine("Yes");
                  else
                    Console.WriteLine("No");
                  return;
                }
            }
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll a;
    cin>>a;
    cout<<(3*a*a);

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

int a[100001];
int N;

void input() {
	for (int i = 0; i <= 100000; i++) a[i] = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int tmp;
		scanf("%d", &tmp);
		a[tmp]++;
	}
}

void solve() {
	int ans = 0;
	for (int i = 0; i <= 100000; i++) ans += max(0, a[i] - 1);
	if (ans % 2 == 1) printf("%d\n", N - (ans + 1));
	else printf("%d\n", N - ans);
}

int main() {
	input();
	solve();

	return 0;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}

	sort.Ints(A)

	// for i := 0; i < N; i++ {
	// 	for j := 0; j < N; j++ {
	// 		if i == j {
	// 			continue

	// 		}
	// 		if A[i] != 0 {

	// 			A[j] = A[j] % A[i]
	// 		}
	// 	}
	// 	fmt.Println(A)
	// }

	ans := Gcd(A)

	fmt.Println(ans)
}

func gcdBase(a, b int) int {
	if b == 0 {
		return a
	}

	return gcdBase(b, a%b)
}

// Gcd return Greatest common divisor
func Gcd(args []int) int {
	b := args[0]

	for _, a := range args {
		b = gcdBase(a, b)
	}
	return b
}


Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n, k, q;
int a[100000];

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

	cin >> n >> k >> q;
	rep(i, q)cin >> a[i];

	vector<int> solve(n, 0);
	rep(i, q)solve[a[i] - 1]++;

	rep(i, n) {
		if (k - (q - solve[i]) > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}



	return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  string a, b, c;
  cin >> a >> b >> c;
  bool ans = a.back() == b.front() && b.back() == c.front();
  if (ans) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }

  return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>
#include <string.h>
int main(void) {
	int arr[33] = { 0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	int k;
	scanf("%d", &k);
	printf("%d", arr[k]);

	return 0;
}

Measured memory_bytes: 128
N = int(input())						# 5


ans=0
for j in range(1,N+1, 2):
	count=0
	for i in range(1, j+1):
		if (j/i)==(j//i):
			count+=1
	else:
		if(count==8): 
			ans+=1
#			print(j, end=',')
#print()
print(ans)

Measured memory_bytes: 3060
n = int(input())
a = [tuple(map(int,input().split())) for i in range(n)]

m = dict()


ans = 0


for i in range(n):
    for j in range(n):
        if i !=j:
            x = a[i][0] - a[j][0]
            y = a[i][1] - a[j][1]

            p = (x,y)

            if p not in m:
                m[p] = 0

            m[p] += 1

            ans = max(m[p], ans)



print(n-ans)


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	const int inf = 1e9 + 1e8;
	int n, k; cin >> n >> k;
	vector<int> x(n);
	int pos = 0;
	bool flag = false;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		if (x[i - 1] < 0 && x[i] > 0) pos = i;
		if (x[i] == 0) {
			pos = i;
			k--;
			flag = true;
		}
	}
	if (x[pos] < 0) pos = n;
	if (flag) {
		for (int i = pos; i + 1 < n; i++) x[i] = x[i + 1];
		n--;
	}
	int ans = k == 0 ? 0 : inf;
	for (int i = 0; i < n; i++) {
		if (i < pos) {
			int cnt = pos - i;
			if (cnt >= k) {
				ans = min(ans, -x[i]);
			} else {
				if (k + i - 1 < n) ans = min(ans, -2 * x[i] + x[k + i - 1]);
			}
		} else {
			int cnt = i - pos + 1;
			if (cnt >= k) {
				ans = min(ans, x[i]);
			} else {
				if (i - k + 1 >= 0) ans = min(ans, 2 * x[i] - x[i - k + 1]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n), b(n), c(n); REP(i, n) cin >> a[i] >> b[i] >> c[i];
  vector<vector<long long> > dp(n+1, vector<long long>(3, 0));
  REP(i, n) {
    dp[i+1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
    dp[i+1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
    dp[i+1][2] = max(dp[i][0] + c[i], dp[i][1] + c[i]);
  }
  long long ans = 0;
  REP(j, 3) ans = max(ans, dp[n][j]);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 6912
import numpy as np

n,m = map(int,input().split())

card = list(map(int,input().split()))

d = {}
for c in card:
    if c in d:
        d[c] += 1
    else:
        d[c] = 1

for i in range(m):
    b,c = map(int,input().split())
    if c in d:
        d[c] += b
    else:
        d[c] = b

tot = []

for key in d.keys():
    tot.append([key,d[key]])

tot.sort(key=lambda x:x[0])
flag = True
ind = 1
ans = 0
# print(tot)
while flag:
    if tot[-ind][1] < n:
        ans += tot[-ind][0]*tot[-ind][1]
        n -= tot[-ind][1]
    else:
        ans += tot[-ind][0]*n
        flag = False
    ind += 1

print(ans)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int L;
    string S,T;
    cin>>L>>S>>T;

    if(S>T)swap(S,T);

    if(S.size()<=T.size()&&T.substr(0,S.size())==S){
        if(S+T>T+S)swap(S,T);
    }


    int ma=0;
    for(int i=0;i*S.size()<=L;i++){
        int tmp=L-(int)S.size()*i;
        if(tmp%T.size()==0)ma=i;
    }

    rep(i,ma)cout<<S;
    int tmp=L-ma*(int)S.size();
    tmp/=T.size();
    rep(i,tmp)cout<<T;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1476
#include<bits/stdc++.h>
using namespace std;
#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 per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  int n,k; cin >> n >> k;

  int ans = 0;
  while(n!=0){
    n = n/k;
    ans++;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


/*
                     Keep trying ..!!!!
                     The journey is more important
*/

#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define umapii unordered_map < int , int >
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vs vector<string>
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define FOR(i,a,b) for(int i = a;i <= b; i++)

// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

const ll mod = 1000000007;
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}
void pr(ll x){
    vi dig;
    while(x > 0){
        dig.pb(x % 2);
        x /= 2;
    }
    for(int i = dig.size()-1; i>=0;i--){
             cout << dig[i];
    }
    cout<<'\n';
}
const int N = 3e5 + 7;
ll v[N];
const int inf = 1e9 + 7;
int main(){
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    ll ans=0;
    for(int i = 0; i<63; i++){
            ll on=0 , z=0;           
             on = ((v[n-1]&(1ll<<i))!=0);
             z = (on==0);
            ll cont=0;
           for(int j=n-2;j>=0;--j){
               bool cur=((v[j]&(1ll<<i))!=0);
               if(cur){
                       cont+=z;                  
               } else{
                   cont+=on;
               }
             if(cur)on+=1;
             else z+=1;
           }
           cont %= mod;
           ans = ans + ((1ll<<i)%mod)*cont;
           ans %=mod;
    }
    if(ans < 0) ans+=mod;
    cout<<ans <<'\n';
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(){
    int i, j;
    int h, w;
    
    while(scanf("%d %d", &h, &w), h > 0 && w > 0){
        for(i = 0; i < h; ++i){
            for(j = 0; j < w; ++j){
                putchar((i + j) % 2 == 0 ? '#' : '.');
            }
            
            putchar('\n');
        }
        
        putchar('\n');
    }
    
    return 0;
}


Measured memory_bytes: 2584
N = int(input())


x = []
y = []
for i in range(N):
    tmp = [int(i) for i in input().split()]
    x.append(tmp[0])
    y.append(tmp[1])

d_list = []
for i in range(N):
    for j in range(N):
        dx = x[i] - x[j]
        dy = y[i] - y[j]
        distance = (dx**2 + dy**2)**(0.5)
        d_list.append(distance)

print(sum(d_list)/N)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>


using namespace std;

typedef long long LL;



int main()
{
    int n;
    string s1;
    while (cin >>n)
    {
        cin >>s1;
        int right_e =0;
        for (int i=0; i<n; i++)
        {
            if (s1[i] == 'E')
                right_e++;
        }
        int right_w = n -right_e;
        int left_e = 0;
        int left_w =0;
        int ans =0x3f3f3f3f;
        for (int i=0;i<n; i++)
        {
            if (s1[i] == 'E')
                right_e--;
            else
                right_w--;
            if (i != 0)
            {
                if (s1[i-1] == 'E')
                    left_e++;
                else
                    left_w++;
            }
            ans = min(ans,left_w + right_e);
        }
        printf("%d\n",ans);

    }




#ifdef VSCode
    system("pause");
#endif
    return 0;
}

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

int main(){

    int N;
    cin >> N;
    map<int,long long> mp;
    long long a;
    set<long long> st;
    for(int i = 0; i < N;i++){
        cin >> a;
        st.insert(a);
        if(mp[a]==0)mp[a]++;
        else mp[a]--;
    }
    int sum = 0;
    for(auto itr = st.begin();itr != st.end();itr++){
        sum+=mp[*itr];
    }
    cout << sum <<endl;
    
}

Measured memory_bytes: 11136
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    // private static final long MOD = (long) 1e9 + 7;

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

    private static void solve() {
        int n = in.nextInt();
        int q = in.nextInt();
        char[] ch = in.next().toCharArray();

        // special case
        if (q == 2 || q == 5) {
            long ans = 0;
            for (int i = 0; i < ch.length; i++) {
                int c = ch[i] - '0';
                if (c % q == 0) {
                    ans += (i + 1);
                }
            }
            out.println(ans);
            return;
        }

        int[] counts = new int[q];
        counts[0]++;
        int power10 = 1;
        int current = 0;
        long ans = 0;
        for (int i = ch.length - 1; i >= 0; i--) {
            int c = ch[i] - '0';
            c = multiply(c, power10, q);
            current = add(current, c, q);

            ans += counts[current];
            counts[current]++;

            power10 = multiply(power10, 10, q);
        }

        out.println(ans);
    }

    // a + b (mod m)
    private static int add(int a, int b, int mod) {
        return (a + b) % mod;
    }

    // a * b (mod m)
    private static int multiply(int a, int b, int mod) {
        return (a * b) % mod;
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 27220
def get_one(i)
  ten, one = i.divmod(10)
  if one == 0
    return 10
  else
    return one
  end
end

order = []
5.times do
  order << gets.to_i
end

order.sort!{ |a, b| get_one(b) <=> get_one(a) }

ans = 0
order.each_with_index do |e, idx|
  if idx == 4
    ans += e 
    break
  end
  if get_one(e) == 10
    ans += e
  else
    ans += e + (10 - get_one(e))
  end
end
puts ans

Measured memory_bytes: 14256
import itertools
import math
import fractions
import functools

a, b, k = map(int, input().split())

d = []
for i in range(1,min(a,b)+1):
    if a % i == 0 and b % i == 0:
        d.append(i)

d.sort(reverse=True)
print(d[k-1])    


Measured memory_bytes: 64620
n = int(raw_input())
 
d = [0 for i in range(n)]
f = [0 for i in range(n)]
G = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
col = [0 for i in range(n)]
t = [0]
 
def DFS_visit(u):
    col[u] = 1
    t[0] += 1
    d[u] = t[0]
    for v in range(n):
        if M[u][v] == 1 and col[v] == 0:
            DFS_visit(v)
    col[u] = 2
    t[0] += 1
    f[u] = t[0]
 
def DFS():
    for u in range(n):
        if col[u] == 0:
            DFS_visit(u)
    for u in range(n):
        print'{0} {1} {2}'.format(u+1, d[u], f[u])
     
for i in range(n):
    X = map(int, raw_input().split())
    for j in range(X[1]):
        M[X[0]-1][X[2+j]-1] = 1
 
DFS()

Measured memory_bytes: 6488
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

const int MAX_V = 1<<20;

struct node{
  int first;// [0],1,2,3
  int mid;  // 0,1,[2],3
  int last; // 0,1,2,[3]
  int min;
};

node nodes[MAX_V*2];
int offset;

void update(int i, int x){
  nodes[offset+i].min=x;
  if(offset+i==0) return;
  int p=(offset+i-1)/2;
  while(true){
    int minimum = min(nodes[p*2+1].min,nodes[p*2+2].min);
    if(nodes[p].min!=minimum){
      nodes[p].min=minimum;
      p=(p-1)/2;
    }
    else break;
  }
}
int find(int s, int t, int i){
  if(nodes[i].first==s&&nodes[i].last==t)
    return nodes[i].min;
  if(t<nodes[i].mid)
    return find(s,t,i*2+1);
  if(s>=nodes[i].mid)
    return find(s,t,i*2+2);
  return min(find(s,nodes[i].mid-1,i*2+1),find(nodes[i].mid,t,i*2+2));
}

int main(){ _;
  int n,q; cin>>n>>q;
  int a=1;
  if(n>1)
    for(;a<n;a*=2){}
  offset=a-1;
  for(int i=0;i<a;i++){
    nodes[offset+i].first=nodes[offset+i].mid=nodes[offset+i].last=i;
    nodes[offset+i].min=2147483647;
  }
  for(int i=offset-1;i>=0;i--){
    nodes[i].first=nodes[2*i+1].first;
    nodes[i].mid=nodes[2*i+2].first;
    nodes[i].last=nodes[2*i+2].last;
    nodes[i].min=2147483647;
  }
  REP(i,q){
    int com,x,y;
    cin>>com>>x>>y;
    if(com==0){
      update(x,y);
    }else{
      cout<<find(x,y,0)<<endl;
    }
  }
}

Measured memory_bytes: 7332
#include <iostream>
#include <algorithm>
using namespace std;
int n, p, q, r, a, b, sum[1447];
int main() {
	while (cin >> n >> p >> q, n | p | q) {
		p = p / 100 * 60 + p % 100;
		q = q / 100 * 60 + q % 100;
		fill(sum, sum + 1440, 0);
		for (int i = 0; i < n; i++) {
			cin >> r;
			for (int j = 0; j < r; j++) {
				cin >> a >> b;
				a = a / 100 * 60 + a % 100;
				b = b / 100 * 60 + b % 100;
				for (int k = a; k < b; k++) {
					sum[k]++;
				}
			}
		}
		int ret = 0, cnt = 0;
		for (int i = p; i < q; i++) {
			if (sum[i] == n) ret = max(ret, cnt), cnt = 0;
			else cnt++;
		}
		cout << max(ret, cnt) << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#44 ABC136D
s=input()
n=len(s)
x=[[0,0]]
t=0
for i in range(1,n):
	if s[i]=="R" and s[i-1]=="L":
		x.append([t,i])
	elif s[i]=="L" and s[i-1]=="R":
		t=i
x.append([t,n])
import copy
y=copy.deepcopy(x)
for i in range(1,len(x)):
	x[-i][0]-=x[-i-1][1]
	x[-i][1]-=x[-i-1][1]
	x[-i][1]-=x[-i][0]
del x[0]
res=[0 for _ in range(n)]
y=[y[i][0] for i in range(1,len(y))]
for i in range(len(x)):
	a,b=x[i]
	if (a+b)%2==0:
		res[y[i]-1]=(a+b)//2
		res[y[i]]=(a+b)//2
	elif a%2==1:
		res[y[i]-1]=(a+b)//2+1
		res[y[i]]=(a+b)//2
	else:
		res[y[i]-1]=(a+b)//2
		res[y[i]]=(a+b)//2+1
res=[str(t) for t in res]
print(" ".join(res))

Measured memory_bytes: 96344
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
 #define int long long
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
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;};

class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};


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

  int n;
  Radix r;
  while(true) {
    cin >> n;
    if(n == -1) break;
    cout << r.to(n, 4) << endl;
  }
  return 0;
}



Measured memory_bytes: 3244
n = int(input())
a = [0] + list(map(int, input().split()))
def pi(i):
    global a, n
    s = f"node {i}: key = {a[i]}, "
    if i != 1:
        s += f"parent key = {a[int(i / 2)]}, "
    if i * 2 <= n:
        s += f"left key = {a[2 * i]}, "
        if i * 2 + 1 <= n:
            s += f"right key = {a[2 * i + 1]}, "
    print(s)
 
for i in range(1, n + 1):
    pi(i)



Measured memory_bytes: 5636
fun main(args: Array<String>)
{
    val (n, x) = readNInts()
    val l = readNInts()

    val d = IntArray(n+1)
    d[0] = 0
    for (i in 1..n) {
        d[i] = d[i-1] + l[i-1]
    }

    var cnt = 0
    for (item in d) {
        cnt += if (item <= x) 1 else 0
    }

    println(cnt)
}

// Read an integer
// Usage: val a = readInt()
fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
fun readString() = readLine()!!


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

struct UnionFind{
	int count;
	vector<int> data;
	UnionFind(int n):count(n),data(n,-1){}
	int Find(int i){
		return data[i]<0?i:(data[i]=Find(data[i]));
	}
	bool Unite(int a,int b){
		a=Find(a),b=Find(b);
		if(a==b) return false;
		if(-data[a]<-data[b]) swap(a,b);
		data[a]+=data[b];
		data[b]=a;
		count--;
		return true;
	}
	int Count(){
		return count;
	}
};

typedef tuple<int,int,int> tiii;

int main()
{
	for(int n,m;cin>>n>>m && n|m;){
		vector<tiii> es;
		for(int i=0;i<m;i++){
			int u,v,w; cin>>u>>v>>w; u--,v--;
			es.emplace_back(u,v,w);
		}
		sort(begin(es),end(es),[&](const tiii& a,const tiii& b){return get<2>(a)<get<2>(b);});
		
		vector<int> used(m);
		int weight=0;
		{
			UnionFind uf(n);
			for(int i=0;i<m;i++){
				int u,v,w; tie(u,v,w)=es[i];
				if(uf.Unite(u,v)){
					weight+=w;
					used[i]=1;
				}
			}
		}
		
		int count=0,sum=0;
		for(int i=0;i<m;i++) if(used[i]){
			auto cand=es[i];
			es.erase(begin(es)+i);
			int tmp=0;
			UnionFind uf(n);
			for(auto e:es){
				int u,v,w; tie(u,v,w)=e;
				tmp+=uf.Unite(u,v)*w;
			}
			if(uf.Count()>1 || tmp>weight){
				count++;
				sum+=get<2>(cand);
			}
			es.insert(begin(es)+i,cand);
		}
		cout<<count<<' '<<sum<<endl;
	}
}

Measured memory_bytes: 1984
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
ll power(ll a,ll b)
{ll result=1;
while(b>0)
{if(b%2==1)
 result*=a;
 a*=a;
 b/=2;
}
return result;
}
int main()
{ios_base::sync_with_stdio(false);
	cin.tie(NULL);
int n;
cin>>n;
if(n==0)
cout<<1;
else if(n==1)
cout<<0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define mod 1000000007 
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pii>
using namespace std;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t=1;
    
    while(t--){
       int n;
       cin>>n;int x;vpii a;
        for(int i=0;i<n;i++){
            cin>>x;
            a.pb(mp(x,i));
        }
        sort(a.begin(),a.end());
        for(int i=0;i<n;i++){
            cout<<a[i].S+1<<" ";
        }
       cout<<endl;
    }   
    return 0;
} 

Measured memory_bytes: 1780
#include<stdio.h>






int main()
{
	int i ;

	int n ;
	while( scanf( "%d" ,&n ) != EOF )
	{
		int sum = 0 ;


		for( i = 1 ; i < 1024 ; i <<= 1 )
		{
			if( n & i )
			{
				sum += i ;


				printf( "%d" ,i ) ;

				if( sum == n )
				{
					puts( "" ) ;
				}

				else
				{
					printf( " " ) ;
				}
			}
		}
	}


	return 0 ;
}

Measured memory_bytes: 1744
#include<stdio.h>
int main(void){
    int x,y;
    int h[101],m[101],k[101],g[101];
    int i,j;

    scanf("%d",&x);
    for(i=0;i<x;i++){
	scanf("%d%d",&h[i],&m[i]);
    }
    scanf("%d",&y);
    for(j=0;j<y;j++){
	scanf("%d%d",&k[j],&g[j]);
    }

    i=j=0;
    h[x]=m[x]=k[y]=g[y]=60;
    while(i+j<x+y){
	if(i!=0 || j!=0) printf(" ");
	if(h[i]<k[j]){
	    printf("%d:%02d",h[i],m[i]);
	    i++;
	}else if(h[i]>k[j]){
	    printf("%d:%02d",k[j],g[j]);
	    j++;
	}else{
	    if(m[i]<g[j]){
		printf("%d:%02d",h[i],m[i]);
		i++;
	    }else if(m[i]>g[j]){
		printf("%d:%02d",k[j],g[j]);
		j++;
	    }else{
		printf("%d:%02d",h[i],m[i]);
		i++; j++;
	    }
	}
    }
    printf("\n");

    return 0;
}

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

int main(){
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int count = 0;
    for (int i = 0; i <= A; ++i){
        for (int j = 0; j <= B; ++j){
            for (int k = 0; k <= C; ++k){
                 if(500*i+100*j+50*k==X) ++count;
            }
        }
    }
    cout << count << endl; 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;

signed main() {
	int a, b;
	while (cin >> a >> b) {
		vector<int>V;
		int c = 1, d = 1;
		for (int e = 0; e < a; e++) {
			int f = c + d;
			f %= 1001;
			V.push_back(f);
			c = d;
			d = f;
		}
		sort(V.begin(), V.end());
		int ans = 1;
		for (int i = 1; i < V.size(); i++) {
			if (V[i - 1] + b <= V[i])ans++;
		}
		printf("%d\n", ans);
	}
}

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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int x;
    cin>>x;
    if(x == 0)cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
    
}


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

int main()
{
	int n, m, ans = 0, x;
	int a[210][210];
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			for (int k = 0; k <= 9; k++) {
				a[j][k] = min(a[j][k], a[j][i] + a[i][k]);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			scanf("%d", &x);
			if (x != -1) {
				ans += a[x][1];
			}
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
<?php
function setZero(&$x){
    while(strlen($x) < 80){
        $x = "0" . $x;
    }
    if(strlen($x) > 80) return false;
    return true;
}

fscanf(STDIN, "%d", $T);

while($T-- > 0){
    fscanf(STDIN, "%s", $a);
    fscanf(STDIN, "%s", $b);
    if(!setZero($a) || !setZero($b)){
        echo "overflow\n";
        continue;
    }

    $ans = "";
    $up = 0;
    for($i = 79; $i >= 0; $i--){
        $sum = (int)($a[$i] - '0') + (int)($b[$i] - '0') + $up;
        $ans = (string)($sum % 10 + '0') . $ans;
        $up = (int)($sum / 10);
    }

    if($up != 0){
        echo "overflow\n";
        continue;
    }
    $i = 0;
    while($i < 79 && $ans[$i] == '0') $i++;
    while($i < 80){
        echo $ans[$i];
        $i++;
    }
    echo "\n";
}

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

int main() {
	// your code goes here
	int n,m,i,j,con[607]={0},don[607];
	int s[400005],t[400005];
	double px[607],qx[607],pg[607]={0},qg[607]={0},pm,pmk,pmm,memo,mpt;
	vector<int> g[607],h[607];
	cin >> n >> m;
	for(i=0;i<m;i++){
		cin >> s[i] >> t[i];
		g[s[i]].push_back(t[i]);
		h[t[i]].push_back(s[i]);
	}
	con[n]=1;
	px[n]=0;
	pg[1]=1;
	for(i=n-1;i>=1;i--){
		for(j=0;j<g[i].size();j++){
			con[i]+=con[g[i][j]];
			px[i]+=px[g[i][j]];
		}
		px[i] /= (double)g[i].size();
		px[i] += 1;
	}
	for(i=1;i<n;i++){
		for(j=0;j<g[i].size();j++){
			pg[g[i][j]] += (double)pg[i] / (double)g[i].size();
		}
	}
	don[1]=1;
	qx[1]=0;
	qg[n]=1;
	for(i=2;i<=n;i++){
		for(j=0;j<h[i].size();j++){
			don[i]+=don[h[i][j]];
			qx[i]+=qx[h[i][j]];
		}
		qx[i] /= (double)h[i].size();
		qx[i] += 1.0;
	}
	for(i=n;i>1;i--){
		for(j=0;j<h[i].size();j++){
			qg[h[i][j]] += (double)qg[i] / (double)h[i].size();
		}
	}
	pm = px[1];
	pmk = px[1];
	pmm = px[1] * (double)con[1];
	for(i=0;i<m;i++){
		double pmr;
		pmr=pmk;
		if(g[s[i]].size()==1&&h[s[i]].size()>=1) continue;
		mpt = pg[s[i]]/(double)g[s[i]].size();
		pmr -= mpt;
		pmr -= mpt * px[t[i]];
		memo = (px[s[i]] - (1.0 + px[t[i]]) / (double)g[s[i]].size())/(1.0-1.0/(double)g[s[i]].size());
		pmr += mpt * memo;
		pm=min(pm,pmr);
		
	}
	//printf("%.13lf\n",pmk);
	printf("%.13lf\n",pm);
	return 0;
}

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

using namespace std;


int N, K, A[5000];
bool dp1[5001][5001], dp2[5001][5001];

int main()
{
  cin >> N >> K;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }

  dp1[0][0] = true;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j <= K; j++) {
      dp1[i + 1][min(j + A[i], K)] |= dp1[i][j];
      dp1[i + 1][j] |= dp1[i][j];
    }
  }
  dp2[N][0] = true;
  for(int i = N; i > 0; i--) {
    for(int j = 0; j <= K; j++) {
      dp2[i - 1][min(j + A[i - 1], K)] |= dp2[i][j];
      dp2[i - 1][j] |= dp2[i][j];
    }
  }

  int ret = N;


  for(int i = 0; i < N; i++) {
    bool flag = false;
    int sum[5001] = {};
    for(int j = 0; j < K; j++) sum[j + 1] = sum[j] + dp2[i + 1][j];
    for(int j = 0; j < K; j++) {
      if(dp1[i][j] && sum[K - j] - sum[max(0, K - A[i] - j)] > 0) flag = true;
    }
    ret -= flag;
  }
  cout << ret << endl;
}

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

const int N=1e5+100;
int mod=1e9+7;
typedef long long ll;
int a[N];
map<int,int>mp;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        sum+=x;
        mp[x]++;
    }
    int q;cin>>q;
    while(q--){
        int x,y;cin>>x>>y;
        sum-=1ll*mp[x]*x;
        sum+=1ll*mp[x]*y;
        int k=mp[x];
        mp[x]=0;
        mp[y]+=k;
        cout<<sum<<endl;
    }

    return 0;
}
/*
1e15
*/


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

#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define str string
#define vint vector<int>
#define vvint vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vool vector<bool>
#define vtr vector<str>
#define vvtr vector<vector<str>>
#define pb() pushback
#define elif else if
#define all(x) x.begin(),x.end()

main(){
    int N,X,b,H=0,W=0,count=0,count2=0;
    double d;
    int C='A'-'a';
    char op;
    str S,T;
    cin>>S;
    vint shizuku(N);
    vint A(2*X);
    rep(0,S.size()){
      if(S[i]=='A'||S[i]=='T'||S[i]=='C'||S[i]=='G'){
        count+=1;
      }
      else count=0;
      if(count2<count)count2=count;
    }
    cout<<count2<<endl;
}


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

#define ll long long

int main()
{
    ll X;
    std::cin >> X;

    ll happy = 1000 * (X / 500);
    ll now_money = X % 500;

    happy += 5 * (now_money / 5);

    std::cout << happy << std::endl;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

int main(void){
    for(int i=0;i<1;i++){
        ll x,k,d,ans1,ans2;
        // x = rand();
        // k = rand();
        // d = rand();
        cin >> x;
        cin >> k;
        cin >> d;
        x=abs(x);
        if(x<k*d){
            ll p = x/d+1;
            ll q = x%d;
            if((k-p)%2==0){
                ans1 = d-q;
            }else{
                ans1 = q;
            }
        }else{
            ans1 = x-k*d;
        }
        
        ll st = min(k, x/d);
        ll kr = k-st;
        ll xr = x-st*d;
        if(kr%2==0){
            ans2 = xr;
        }else{
            ans2 = d-xr;
        }
        // cout <<"x:"<<x<<",k:"<<k<<",d:"<<d<<endl;
        // cout << "ans1:"<< ans1<<",ans2:"<<ans2<<endl;
        // if(ans1!=ans2)cout << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        cout <<ans2<<endl;
    
    }
    return 0;
}

Measured memory_bytes: 3632
const input = require("fs").readFileSync("/dev/stdin", "utf8").trim();

const lines = input.split('\n');
const [_, text, ...indexes] = lines;

const acMap = new Array(text.length);
let count = 0, prev = '', char = '', i = 0;
for (; i < text.length; i++) {
    if (text[i-1] === 'A' && text[i] === 'C') {
        count++;
    }
    acMap[i] = count;
}

const results = indexes.map((line) => {
    const [i, j] = line.split(' ').map(Number);
    return acMap[j - 1] - acMap[i - 1];
});

console.log(results.join('\n'));


Measured memory_bytes: 36300
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  int ans = 0;
  while(1){
    int j, b, e;
    for(j = 0; j < n; j++){
      if(h[j] != 0) break;
    }
    b = j;
    if(j == n) break;
    for(j = n - 1; j >= 0; --j){
      if(h[j] != 0) break;
    }
    e = j;
    for(int i = b; i <= e; i++){
      if(i > 0 && h[i] == 0 && h[i - 1] != 0) ans++;
    }
    for(int i = b; i <= e; i++){
      if(h[i] != 0) h[i]--;
    }
    ans++;
    //cout << ans << endl;
    //for(int i = 0; i < h.size(); i++) cout << h[i] << " "; cout << endl;
  }
  cout << ans << endl;

  return;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  while(cin>>n,n){
    int ans=0;
    loop(i,1,n/2+1){
      int tmp=0;
      for(int j=0;tmp<=n;j++){
        tmp+=i+j;
        if(tmp==n)ans++;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3044
N,M = map(int,input().split())
F = [0 for _ in range(N)]
W = [0 for _ in range(N)]
w = 0
for i in range(M):
  p,s = map(str,input().split())
  if F[int(p)-1] == 1:
    continue
  if s == 'WA':
    W[int(p)-1] += 1
  elif s == 'AC':
    F[int(p)-1] = 1
    w += W[int(p)-1]
print(sum(F),w)

Measured memory_bytes: 4656
# Title: Christmas
# Link: https://abc115.contest.atcoder.jp/tasks/abc115_d

import sys


sys.setrecursionlimit(10 ** 6)

read_list_int = lambda: list(map(int, sys.stdin.readline().strip().split(' ')))


def f(n: int, x: int, a: list, p: list):
    if n == 0 and x == 0:
        return 0
    elif n == 0:
        return 1
    elif x == 1:
        return 0
    elif 1 < x <= 1 + a[n-1]:
        return f(n-1, x-1, a, p)
    elif x == 2 + a[n-1]:
        return p[n-1] + 1
    elif 2+a[n-1] < x <= 2+2*a[n-1]:
        return p[n-1]+1+f(n-1, x-(2+a[n-1]), a, p)
    elif x == 3 + 2*a[n-1]:
        return 2*p[n-1]+1


def solution(n: int, x: int):
    a = [1] + [0]*n
    p = [1] + [0]*n

    for i in range(1, n+1):
        a[i] = 2*a[i-1] + 3
        p[i] = 2*p[i-1] + 1
    
    return f(n, x, a, p)



def main():
    n, x = read_list_int()
    print(solution(n, x))


if __name__ == '__main__':
    main()

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

int main(){
    ll mod = 1e9+7;
    ll n,k;cin>>n>>k;
    vector<ll> a(n);
    for(int i=0; i<n; i++)cin>>a[i];
    ll cnt = 0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            if(a[i]>a[j])cnt++;
        }
    }
    ll ans = (cnt*k)%mod;
    sort(a.rbegin(),a.rend());
    ll t_each_pair = 0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            if(a[i]>a[j])t_each_pair++;
        }
    }
    ll a_pair;
    a_pair = (k%2==0)?(k/2)*(k-1):k*((k-1)/2);
    a_pair %= mod;
    cout<<(ans+(a_pair*t_each_pair)%mod)%mod<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    string t;
    cin>>t;
    int n = t.size();
    vector<int> used(n);
    ll ans = 0;
    int sum = 0;
    int len = 0;
    for(int i=0;i<n;i++){
        if(len%2==1 || t[i]=='1'){
            used[i] = true;
            if(len%2==0 && t[i]=='1') sum++;
            ans += sum;
            len++;
        }
    }
    cerr<<ans<<endl;
    int even_one = 0;
    int odd_one = 0;
    for(int i=n-1;i>=0;i--){
        if(used[i]){
            if(t[i]=='1'){
                if(len%2==1){
                    odd_one++;
                    sum--;
                }
                else even_one++;
            }
            len--;
        }
        else{
            swap(even_one,odd_one);
            // cerr<<sum+odd_one<<endl;
            ans+=sum+odd_one;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 4452
#include<bits/stdc++.h>
using namespace std;
int main(){
      char str1[50],str2[50],str3[50];
      scanf("%s %s %s",str1,str2,str3);
      printf("%c%c%c\n",str1[0],str2[0],str3[0]);
      return 0;
}

Measured memory_bytes: 256
money = int(input())

six = [6**i for i in range(1, 8)]
nine = [9**i for i in range(1, 7)]

all = [1] + sorted(six + nine)

dp = [100000 for i in range(100001)]
dp[0] = 0

for i in range(0, 100001):
    for el in all:
        temp = i + el
        if temp < 100001:
            dp[temp] = min(dp[temp], dp[i] + 1)

print(dp[money])

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

using namespace std;

typedef long long ll;

const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int main(){

    int a, b, c;

    cin >> a >> b >> c;

    if(a == b && a == c && b == c) cout << "No";

    else{
        if(a == b || a == c || b == c) cout << "Yes";
        else cout << "No";
    } 

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  string s;cin >> s;
  ll n = s.size(),i,dp[n+1][2];dp[0][0] = 1;dp[0][1] = 0;
  for(i=0;i<n;i++){
    if(s[i]=='1'){
      dp[i+1][0] = (dp[i][0]*2)%mod;
      dp[i+1][1] = (dp[i][0]+dp[i][1]*3)%mod;
    }
    else{
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = (dp[i][1]*3)%mod;
    }
  }
  cout << (dp[n][0]+dp[n][1])%mod << "\n";
}

Measured memory_bytes: 5228
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl '\n'

using namespace std;

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

int main()
{
	int x, n;
	cin>>x>>n;
	if(n == 0)
	{
		cout<<x<<nl;
		return 0;
	}
	int a[n];
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
	}
	for(int j=0; j<2*n; j++)
	{
		int k = x-j;
		bool flag = true;
		for(int i=0; i<n; i++)
		{
			if(a[i] == k)
			{
				flag = false;
				break;
			}
		}
		if(flag) 
		{
			cout<<k<<nl;
			break;
		}
		k = x+j;
		flag = true;
		for(int i=0; i<n; i++)
		{
			if(a[i] == k)
			{
				flag = false;
				break;
			}
		}
		if(flag)
		{
			cout<<k<<nl;
			break;
		}
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define II pair<ll,ll>

const int N=1e5+10;
const ll maxN=1e18+10;

int h[N];
vector <int> connect[N];

int main()
{
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n,m;
    cin >> n >> m;
    FOR(i,1,n) cin >> h[i];
    FOR(i,1,m) {
        int a,b;
        cin >> a >> b;
        connect[a].push_back(b);
        connect[b].push_back(a);
    }
    int ans=0;
    FOR(i,1,n) {
        int q=connect[i].size();
        if (q==0) ans++;
        else {
            bool ck=true;
            FOR(j,0,q-1)
               if (h[connect[i][j]]>=h[i]) {ck=false; break;}
            if (ck) ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
#define ALL(a)  (a).begin(),(a).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    
    int ans=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i+100*j+50*k==x) ans++;
            }
        }
    }
    cout<<ans;
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<string> w(n);
    set<string> st;
    rep(i, w.size()) {
        cin >> w.at(i);
        st.insert(w.at(i));
    }
    if (st.size() != n) {
        puts("No");
        return 0;
    }
//    cout << st.size() << endl;;
    rep(i, w.size()-1) {
        if (w.at(i).at(w.at(i).size()-1) != w.at(i+1).at(0)) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

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

int main() {
    vector<char> str(1200);
    for(int i = 0; i < 1200; i++) {
        cin >> str.at(i);
    }

    for(int i = 0; i < str.size(); i++) {
        if(char(toupper(str.at(i))-str.at(i) == 0)) str.at(i) = char(tolower(str.at(i)));
    }

    vector<int> count(26, 0);

    for(int i = 0; i < 26; i++) {
      	for(int j = 0; j < str.size(); j++) {
        	if(str.at(j) - 'a' == i) count.at(i)++;
        }
    }

    for(int i = 0; i < 26; i++) {
        cout << char('a'+i) << " : " << count.at(i) << endl;
    }
}


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

int n, m, sum, cnt, a[105];
double x;
int main() {
	int i;
	cin >> n >> m;
	for(i=0; i<n; i++) cin >> a[i], sum += a[i];
	x = sum / (4.0*m);
	for(i=0; i<n; i++) if(a[i] >= x) cnt++;
	puts(cnt>=m ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}

int main(){
  int N; cin >> N;
  //cout << 1-N << endl;
  cout << (1^N) << endl;
  return 0;
}


Measured memory_bytes: 3628