akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define lb(v,x) lower_bound(all(v),x)
#define ub(v,x) upper_bound(all(v),x)
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }
    return gcd(b%a,a);
}

ll dp[105][100005];
ll pre[100005];

int main(){
    IOS
    
    int n,k;
    cin>>n>>k;
    ll a[n+1];
    FOR(i,1,n+1){
        cin>>a[i];
    }
    dp[0][0]=1;
    FOR(i,1,n+1){
        pre[0]=dp[i-1][0];
        FOR(j,1,k+1){
            pre[j]=(pre[j-1]+dp[i-1][j])%MOD;
        }
        FOR(j,0,k+1){
            ll sum=pre[j];
            int x=j-a[i];
            if(x>0){
                sum=(sum-pre[x-1]+MOD)%MOD;
            }
            dp[i][j]=sum;
        }
    }
    cout<<dp[n][k];
    cerr<<1.0/CLOCKS_PER_SEC<<endl;
    return 0;
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
#define int long long
using namespace std;


int32_t main()
{

	
	int n; cin>>n;
	int ans=n-1;
	for (int i = 1; i*i<=n ; ++i)
	{
		if(n%i==0) ans=min(ans,i+n/i-2);
	}


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,k,s;
	cin>>n>>k>>s;
	int i;
	for(i=1;i<=k;++i)	printf("%lli ",s);
	for(i=k+1;i<=n;++i)
	{
		if(s==1)	printf("%lli ",2);
		else
		{
			if(i%2==0)		printf("%lli ",s-1);
			if(i%2==1)		printf("%lli ",2);	
		}		
	}
}

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

int main(){
    int64_t x;
    cin >> x;
    int cnt = 0;
    int i;
    int64_t mon = 100;
    for(i = 0; i >= 0; i++){
        mon *= 1.01;
        cnt++;
        if(mon >= x){
            break;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>

int main(void) {
    char a, b, c;
    a = getchar();
    b = getchar();
    c = getchar();

    if ((a == b) && (a == c) && (b = c)){
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

/*ここから*/

int V;//頂点の個数
int E;//辺の個数
P e[2000010];//辺の組
int conn=0;//連結数
int t[2000010];//親情報の記録媒体

void Conn(){  
    for(int i=1;i<=V;i++){
        t[i]=i;
    }
    for(int i=0;i<E;i++){
        int a,b;
        a=e[i].first;
        b=e[i].second;
        //同一連結成分か？
        while(t[a]!=t[t[a]]){
            t[a]=t[t[a]];
        }
        while(t[b]!=t[t[b]]){
            t[b]=t[t[b]];
        }
        if(t[a]!=t[b]){
            if(t[a]<t[b]){
                t[t[b]]=t[a];
                t[b]=t[a];
            }
            else{
                t[t[a]]=t[b];
                t[a]=t[b];
            }
        }
    }
    for(int i=1;i<=V;i++){
        while(t[i]!=t[t[i]]){
            t[i]=t[t[i]];
        }
    }
    for(int i=1;i<=V;i++){
        if(t[i]==i){conn++;}
    }
}

/*ここまで*/

int main()
{ 
    int n,m,k;
    cin>>n>>m>>k;
    vector <P> f;
    vector <P> b;
    for(int i=0;i<m;i++){
        int a,c;
        cin>>a>>c;
        e[i].first=a;
        e[i].second=c;
        f.push_back(e[i]);
    }
    for(int j=0;j<k;j++){
        int a,c;
        cin>>a>>c;
        P p;
        p.first=a;
        p.second=c;
        b.push_back(p);
    }

    V=n;E=m;
    Conn();

    int ans[n+1];
    for(int i=0;i<=n;i++){ans[i]=0;}

    for(int i=1;i<=n;i++){
        ans[t[i]]++;
    }
    for(int i=1;i<=n;i++){
        ans[i]=ans[t[i]];
    }
    for(int i=0;i<m;i++){
        P p;
        p=f.back();
        f.pop_back();
        ans[p.first]--;
        ans[p.second]--;
    }
    for(int i=0;i<k;i++){
        P p;
        p=b.back();
        b.pop_back();
        if(t[p.first]==t[p.second]){
            ans[p.first]--;
            ans[p.second]--;
        }
    }
    

    /*for(int i=1;i<=n;i++){cout<<t[i]<<' ';}
    cout<<endl<<endl;*/

    for(int i=1;i<n;i++){
        cout<<ans[i]-1<<' ';
    }
    cout<<ans[n]-1<<endl;
    return 0;
}

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

const int MAXN = 2*1e5;
vector<int> a,f;

// maxがx以下となるようなkの分配が存在する
// ⇒全ての要素についてx以下になる
bool isOK(ll x, int n, ll k){
	ll cnt = 0;
	
	rep(i,n){
          cnt += max(0ll, a[i] - x/f[i]);
	}
	
	if(cnt > k) return false;
	else return true;
}

// 二分探索
ll binsearch(ll max, int n, ll k){
	ll lb = -1; // 0が解の可能性を考慮
	ll ub = max+1; // maxが解の可能性を考慮
	
	while( abs(ub - lb) > 1){
		ll mid = (lb + ub) / 2;
		
		if(isOK(mid, n, k)) ub = mid;
		else lb = mid;
	}
	
	return ub;
}

int main(){
	ll n,k;
	cin >> n >> k;
	rep(i,n){
      int tmp;
      cin >> tmp;
      a.push_back(tmp);
    }
  	rep(i,n){
      int tmp;
      cin >> tmp;
      f.push_back(tmp);
    }
	sort(a.begin(),a.end());
    sort(f.rbegin(), f.rend());
	
	cout << binsearch(1e12, n, k) << endl;
	return 0;
}

Measured memory_bytes: 2548
n,k,c = map(int,raw_input().split())
s = raw_input()
most = [0]*(n+1)
i = n
days = 0
while i > 0:
    if s[i-1] == 'o':
        days += 1
        for j in xrange(min(max(1,c),i-1)):
            #print days
            #print i,j,1,days
            most[i-j-1] = days
        i -= (c+1)
    else:
        i -= 1
        if i<n:
            most[i] = most[i+1]

remain = k
i = 1
while i<=n:
    if s[i-1] == 'o':
        if most[i] < remain:
            print i
        remain -= 1
        i += c+1
    else:
        i += 1

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

using namespace std;

typedef long long ll;

const int N = 1e5 + 1;

int a[N];
bool kek[N];

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#endif
    int n;
    string s;
    cin >> n;
    cin >> s;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'o')
        {
            a[i] = 0;
        }
        else
        {
            a[i] = 1;
        }
    }
    for (int t = 0; t < 2; t++)
    {
        for (int d = 0; d < 2; d++)
        {
            memset(kek, 0, sizeof kek);
            kek[0] = t;
            kek[1] = d;
            for (int i = 1; i < n; i++)
            {
                int cur = kek[i - 1] ^ kek[i] ^ a[i];
                if (i != n - 1)
                {
                    kek[(i + 1) % n] = cur;
                }
                else
                {
                    if (kek[0] == cur && kek[1] == kek[n - 1] ^ kek[0] ^ a[0])
                    {
                        for (int i = 0; i < n; i++)
                        {
                            printf("%c", !kek[i] ? 'S' : 'W');
                        }
                        return 0;
                    }
                }
            }
        }
    }
    puts("-1");
}


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

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

    int N = (int)S.size();
    vector<int> s(26), t(26);
    for (int i = 0; i < N; i++) {
        s[S[i] - 'a']++;
        t[T[i] - 'a']++;
    }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    for (int i = 0; i < 26; i++) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 904
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    const INF: usize = 1_000_000_000_000;
    let mut dp = vec![INF; N + 1];
    dp[N] = 0;
    let mut k = N;
    for i in (0..N).rev() {
        while k > i && (i + M < k || S[k] == '1') {
            k -= 1;
        }
        if S[i] == '0' {
            dp[i] = dp[k] + 1;
        }
    }
    if dp[0] < INF {
        let mut res = vec![];
        let mut j = dp[0] - 1;
        let mut prev = 0;
        for i in 1..(N + 1) {
            if dp[i] == j {
                res.push(i - prev);
                if j > 0 {
                    j -= 1;
                }
                prev = i;
            }
        }
        let ans = res
            .iter()
            .map(|&x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ");
        println!("{}", ans);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 10492
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void get(Args...)(ref Args args)
{
    import std.traits, std.meta, std.typecons;

    static if (Args.length == 1) {
        alias Arg = Args[0];
        
        static if (isArray!Arg) {
            args[0] = readln.split.to!Arg;
        } else static if (isTuple!Arg) {
            auto input = readln.split;
            static foreach (i; 0..Fields!Arg.length) {
                args[0][i] = input[i].to!(Fields!Arg[i]);
            }
        } else {
            args[0] = readln.chomp.to!Arg;
        }
    } else {
        auto input = readln.split;
        assert(input.length == Args.length);

        static foreach (i; 0..Args.length) {
            args[i] = input[i].to!(Args[i]);
        }
    }
}

void get_lines(Args...)(size_t N, ref Args args)
{
    import std.traits, std.range;

    static foreach (i; 0..Args.length) {
        static assert(isArray!(Args[i]));
        args[i].length = N;
    }

    foreach (i; 0..N) {
        static if (Args.length == 1) {
            get(args[0][i]);
        } else {
            auto input = readln.split;
            static foreach (j; 0..Args.length) {
                args[j][i] = input[j].to!(ElementType!(Args[j]));
            }
        }
    }
}

void main()
{
    int H, W, h, w; get(H, W, h, w);
    if (H%h == 0 && W%w == 0) {
        writeln("No");
        return;
    }
    writeln("Yes");

    bool T;
    if (W%w == 0) {
        T = true;
        swap(H, W);
        swap(h, w);
    }

    auto ss = new int[](W+1);
    foreach (i; 0..w) {
        foreach (j; 0..W) {
            if (i+w*j > W) break;
            ss[i+w*j] = -j;
        }
    }
    for (int i = W, j = 1; i >= 0; i -= w, ++j) {
        ss[i] = j;
    }
    int[] as;
    foreach (i; 0..W) as ~= ss[i+1] - ss[i];

    if (T) {
        foreach (a; as) {
            foreach (_; 1..H) write(a, " ");
            writeln(a);
        }
    } else {
        foreach (_; 0..H) writefln!"%(%s %)"(as);
    }
}

Measured memory_bytes: 2860
N = int(input())
S = [input() for _ in range(N)]

R = {}
for i in range(N):
  R[i] = []
  for j in range(N):
    if S[i][j] == "1":
      R[i].append(j)

def dfs(x):
  L = [0] * N
  L[x] = 1
  S = [x]
  K = [0] * N
  cnt = 0
  while S:
    cnt += 1
    T = [0] * N
    ST = []
    while S:
      t = S.pop()
      T[t] = 1
      for i in R[t]:
        if L[i] == 1:
          if K[i] == 0:
            return -1
          else:
            L[i] = 1
        else:
          L[i] = 1
          K[i] = 1
          ST.append(i)
    S = ST
    K = T
  return cnt

ma = -1
for i in range(N):
  ma = max(ma, dfs(i))

print(ma)


Measured memory_bytes: 3444
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val n = readInteger()
    val aList = readIntegerList()
    val backet = IntArray(n)
    for (a in aList) {
        backet[a]++
    }

    if (n % 2 == 0) {
        if (backet[0] != 0) {
            println(0)
            return
        }

        for (i in 1 until n step 2) {
            if (backet[i] != 2) {
                println(0)
                return
            }
        }

        println(pow(2, n.toLong() / 2))
    } else {
        if (backet[0] != 1) {
            println(0)
            return
        }

        for (i in 2 until n step 2) {
            if (backet[i] != 2) {
                println(0)
                return
            }
        }

        println(pow(2, (n.toLong() - 1L) / 2))
    }
}

/** O(log(m)) */
fun pow(n: Long, m: Long, MOD: Long = 1000000007L): Long {
    var ret = 1L
    var x = n
    var k = m
    while (k > 0) {
        if ((k and 1L) == 1L) { ret = (ret * x) % MOD }
        x = (x * x) % MOD
        k = k shr 1
    }
    return ret
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 50096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
	string s,t; cin >> s >> t;
	cout << t << s << endl;
}

Measured memory_bytes: 256
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math

s = input()
l = []
#for i in range(len(s)):
    #l.append(s[i])
for i in range(0, len(s), 2):
    l.append(s[i])

print('{}'.format(''.join(l)))

Measured memory_bytes: 6100
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>
#include <bitset>
#include <cassert>

using namespace std;

template<int MOD>
struct MINT {
    long long val;

    constexpr MINT(long long v = 0) noexcept: val(v % MOD) {
        if (val < 0) val += MOD;
    }

    constexpr int getmod() { return MOD; }

    constexpr MINT operator-() const noexcept {
        return val ? MOD - val : 0;
    }

    constexpr MINT operator+(const MINT &r) const noexcept { return MINT(*this) += r; }

    constexpr MINT operator-(const MINT &r) const noexcept { return MINT(*this) -= r; }

    constexpr MINT operator*(const MINT &r) const noexcept { return MINT(*this) *= r; }

    constexpr MINT operator/(const MINT &r) const noexcept { return MINT(*this) /= r; }

    constexpr MINT &operator+=(const MINT &r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }

    constexpr MINT &operator-=(const MINT &r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }

    constexpr MINT &operator*=(const MINT &r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }

    constexpr MINT &operator/=(const MINT &r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }

    constexpr bool operator==(const MINT &r) const noexcept {
        return this->val == r.val;
    }

    constexpr bool operator!=(const MINT &r) const noexcept {
        return this->val != r.val;
    }

    friend constexpr ostream &operator<<(ostream &os, const MINT<MOD> &x) noexcept {
        return os << x.val;
    }

    friend constexpr MINT<MOD> modpow(const MINT<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = MINT<MOD>;

int main() {

    long long N;
    cin >> N;

    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }

    mint m = mint(1);

    for (int i = 0; i < N; ++i) {
        m *= 10;
    }

    mint m1 = mint(1);
    mint m2 = mint(1);
    for (int i = 0; i < N; ++i) {
        m1 *= 9;
        m2 *= 9;
    }

    mint m3 = mint(1);
    for (int i = 0; i < N; ++i) {
        m3 *= 8;
    }

    m -= (m1 + m2 - m3);

    cout << m << endl;

    return 0;

}

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

int main(){
    vector<int> a(5);
    int k;
    for(int i=0; i<5; i++)cin>>a[i];
    cin>>k;
    int flag=0;
    for(int i=1; i<5; i++)if(a[i]-a[0]>k)flag=1;
    if(flag==1)cout<<":(";
    else cout<<"Yay!";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int L=sc.nextInt();
		sc.close();
		int taste[]=new int[N];
		int alltaste=0;
		int minabs,minnum=0;
		for(int i=0;i<N;i++) {
			taste[i]=Math.abs(L+i);
			alltaste+=L+i;
		}
		minabs=taste[0];
		for(int j=0;j<N;j++) {
			if(minabs>taste[j]) {
				minabs=taste[j];
				minnum=j;
			}
		}
		alltaste=alltaste-(L+minnum);
		System.out.println(alltaste);
	}
}

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

using namespace std;
#define PROBLEM "F"

int disjoint_set[100010];

int find(int x){

	return disjoint_set[x] < 0 ? x : (disjoint_set[x] = find(disjoint_set[x]));
}

void Union(int x, int y){

	x = find(x);
	y = find(y);

	if(x == y)
		return;

	disjoint_set[x] = y;
}

int main(){

	#ifdef DBG
	freopen("problem" PROBLEM ".in", "r", stdin);
	freopen("problem" PROBLEM ".out", "w", stdout);
	#endif

	memset(disjoint_set, -1, sizeof(disjoint_set));
	int N, M;
	cin >> N >> M;

	int A, B, Z;

	for(int i = 0 ; i < M ; i++){

		cin >> A >> B >> Z;
		Union(A, B);
	}
	cout << count(disjoint_set+1, disjoint_set+N+1, -1) << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
#define deb(x) each(x.begin(),x.end(),(int& y){cout << y <<" ";})
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define j1 j1347829 //j1
#define INF2 1000000000000000037
#define INF 1000000007
#define PI (acos(-1))
//#define MOD 1000000007
//#define MOD 10007

using namespace std;
typedef long long ll;

ll MOD;

struct Matrix {
  vector<vector<ll> > val;
  Matrix(ll n, ll m, ll x = 0) : val(n, vector<ll>(m, x)) {}
  void init(ll n, ll m, ll x = 0) {val.assign(n, vector<ll>(m, x));}
  size_t size() const {return val.size();}
  inline vector<ll>& operator [] (int i) {return val[i];}
};

Matrix operator * (Matrix A, Matrix B) {
  Matrix R(A.size(), B[0].size());
  rep(i, A.size())
  rep(j, B[0].size())
  rep(k, B.size())
  R[i][j] = (R[i][j] + A[i][k] * B[k][j] % MOD) % MOD;
  return R;
}

Matrix pow(Matrix A, ll n) {
  Matrix R(A.size(), A.size());
  rep(i, A.size()) R[i][i] = 1;
  while (n > 0) {
    if (n & 1) R = R * A;
    A = A * A;
    n >>= 1;
  }
  return R;
}

Matrix tani(ll n, ll a=1){ //n*nの単位正方行列を作る
  Matrix R(n, n);
  rep(i, n) R[i][i] = a;
  return R;
}

ll modpow(ll a, ll n){ // a^n mod の計算
  ll res = 1;
  while (n>0){
    if(n & 1) res = res * a % MOD;
    a = a * a  % MOD;
    n >>= 1;
  }
  return res;
}


void Main(){

  ll L,A,B,M;
  cin>>L>>A>>B>>M;

  MOD=M;

  // d桁の数がn_d個
  // 初項s

  ll n[19]; n[0]=-1;

  ll X=0;
  ll s=A;

  // a < LLONG_MAX – b
  // a < LLONG_MAX / b


  Matrix ma=tani(3);

  reps(d,1,19){

    ll ok = -1; // 一番小さい値より1つ前 ngとokは場合により入れ替え
    ll ng = L; // 一番でかい値より1つあと
    while (abs(ok - ng) > 1) {
      ll mid = (ok + ng) / 2;

      if(mid>= LLONG_MAX/B){
        ng=mid; continue;
      }
      if(A >= LLONG_MAX - mid*B){
        ng=mid; continue;
      }
      //db(A);
      //db(mid*B);
      ( A+mid*B < (ll)pow(10,d) ? ok : ng ) = mid;
    }

    //db(d);
    //db(pow(10,d));
    //db(ok);

    n[d]=ok;
    ll nn=n[d]-n[d-1];

    //db(nn);

    Matrix temp(3,3);
    temp[0][0]=modpow(10,d);
    temp[1][0]=1;
    temp[1][1]=1;
    temp[2][1]=B%MOD;
    temp[2][2]=1;

/*
    rep(i,3){
      rep(j,3){
        cout<< temp[i][j]<<" ";
      }
      cout<<"\n";
    }
    */

    temp=pow(temp,nn);

    //Matrix temp2=tani(3,modpow(10,d-1));

    //ma=ma*temp2;

    ma=ma*temp;

    //cout<< A*ma[1][0]<<"\n";
  }

  ll ans=((A%MOD)*ma[1][0]+ma[2][0])%MOD;

  cout<< ans<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

int main(){
	string s,t;
	cin >> s >> t;
	int size = s.size();
	int i;
	bool b=1;
	for(i=0;i<size;i++){
		if(s.at(i)==t.at(i)){
		}else{
			b = 0;
		}
	}
	if(t.size()!=(size+1))b=0;
	if(b){
		cout << "Yes" << endl;
		
	}else{
		cout << "No" << endl;
	}
	
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	string s;
	cin >> n >> s;

	if(n%2==1) cout << "No" << endl;
	else{
		for(int i=0;i<n/2;i++){
			if(s.at(i)==s.at(i+n/2))
				continue;
			else{
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc082/tasks/arc087_a

import itertools
import collections
import bisect
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    c = collections.Counter(A)

    ans = 0
    for k, v in c.items():
        if k > v:  # 数が足りないなら取り除く
            ans += v
        else:
            ans += v - k
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18352
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
int a;
cin >> a;
if(a < 1200)cout << "ABC" << endl;
else cout << "ARC" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
int main() {
	ll s;
	scanf("%lld", &s);
	ll mx = 1e9;
	ll x1 = mx;
	ll y2 = (mx - 1 + s) / mx;
	ll x2 = 1;
	ll y1 = x1 * y2 - s;
	assert(abs(x1 * y2 - x2 * y1) == s);
	printf("0 0 %lld %lld %lld %lld\n", x1, y1, x2, y2);
}


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

int main(){
  int a[10];
  for(int i=0; i<10; i++ )
  cin >> a[i] ;
  sort(a,a+10,greater<int>());
  for(int i=0; i<3; i++ )
  cout << a[i]<<endl;
return 0;
}



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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;
template <typename T>
using Matrix = vector<vector<T> >;
const int INF = 1e7;

template <typename T>
void warshall_floyd(Matrix<T> &g, T INF) {
  for (int k = 0; k < g.size(); k++) {
    for (int i = 0; i < g.size(); i++) {
      for (int j = 0; j < g.size(); j++) {
        // if (g[i][k] == INF || g[k][j] == INF) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

void solve() {
  int H, W;
  cin >> H >> W;
  Matrix<int> mat(H * W, vector<int>(H * W, INF));
  vector<string> s(H);
  for (int i = 0; i < H; i++) {
    cin >> s[i];
  }

  auto id = [=](int h, int w) { return h * W + w; };

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '.') {
        mat[id(i, j)][id(i, j)] = 0;
        if (i - 1 >= 0 && s[i - 1][j] == '.') {
          mat[id(i, j)][id(i - 1, j)] = 1;
          mat[id(i - 1, j)][id(i, j)] = 1;
        }
        if (i + 1 < H && s[i + 1][j] == '.') {
          mat[id(i, j)][id(i + 1, j)] = 1;
          mat[id(i + 1, j)][id(i, j)] = 1;
        }
        if (j - 1 >= 0 && s[i][j - 1] == '.') {
          mat[id(i, j)][id(i, j - 1)] = 1;
          mat[id(i, j - 1)][id(i, j)] = 1;
        }
        if (j + 1 < W && s[i][j + 1] == '.') {
          mat[id(i, j + 1)][id(i, j)] = 1;
          mat[id(i, j)][id(i, j + 1)] = 1;
        }
      }
    }
  }
  warshall_floyd(mat, INF);

  int ma = 0;
  for (int i = 0; i < H * W; i++) {
    for (int j = 0; j < H * W; j++) {
      if (mat[i][j] == INF) continue;
      ma = max(ma, mat[i][j]);
    }
  }

  cout << ma << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
 
int main(){
  int n,l;
  cin >> n >>l;
  
  vector<int> a(n);
  rep(i,n) a[i] = l+i;
  int s = 0;
  rep(i,n) s += a[i];
  int ans = 1e9;
  
  rep(i,n){
    int t = s - a[i];
    if(abs(t-s) < abs(ans-s)) ans = t;
  }
  
  cout << ans << endl;
 
  return 0;
  
}

Measured memory_bytes: 256
list = []
count = 0
flag = True

while flag:
    a,op,b=input().split()
    list.append((int(a),op,int(b)))
    if list[count][1]== "?":
        flag = False
    count += 1

for i in range(count):
    if list[i][1] == "+":
        print(list[i][0] + list[i][2])
    elif list[i][1] == "-":
        print(list[i][0] - list[i][2])
    elif list[i][1] == "*":
        print(list[i][0] * list[i][2])
    elif list[i][1] == "/":
        print(int(list[i][0] / list[i][2]))
        

"""
1 + 2
3 / 3
100 ? 100
"""



Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a<=k){
        cout<<"Yay!"<<endl;
    }else{
        cout<<":("<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
vector<vector<char> >tmp;
vector<vector<int> >scr;
int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<int>d(m);
		vector<vi >cost(m,vector<int>(m));
		vector<vi >tim(m,vector<int>(m));
		vector<bool>used(m);
		rep(i,m)rep(j,m){cost[i][j]=inf;tim[i][j]=inf;}
		rep(i,n){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			a--;b--;
			cost[a][b]=cost[b][a]=c;
			tim[a][b]=tim[b][a]=d;
		}
		cin>>n;
		rep(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			a--;b--;
			rep(j,m)d[j]=inf;
			rep(j,m)used[j]=false;
			if(c){
				d[a]=0;
				while(1){
					int v=-1;
					rep(j,m)if(!used[j]&&(v==-1||d[v]>d[j]))v=j;
					if(v==-1)break;
					used[v]=true;
					rep(j,m)d[j]=min(d[j],d[v]+tim[v][j]);
				}
			}else{
				d[a]=0;
				while(1){
					int v=-1;
					rep(j,m)if(!used[j]&&(v==-1||d[v]>d[j]))v=j;
					if(v==-1)break;
					used[v]=true;
					rep(j,m)d[j]=min(d[j],d[v]+cost[v][j]);
				}
			}
			cout<<d[b]<<endl;
		}
	}
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    ll n,i;
    cin>>n;
    vector<ll> a(n),b(n,0);
    for(i=1;i<n;i++) cin>>a[i];
    for(i=1;i<n;i++){
        b[a[i]-1]++;
    }
    for(i=0;i<n;i++) cout<<b[i]<<endl;
    return 0;
}



Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);

ll n,p,ans=1;

template<typename T> 
void factorize(T x){//mapを返す関数
  ll res=0;
  for(ll i=2;i*i<=x;i++){
      res=0;
    while(x%i==0){
      x/=i;
      res++;
      if(res>=n){ans*=i;res=0;}
    }
    
  }
  if(x!=1 && n==1){ans*=x;}//xが素数だった時用
}


signed main(){
    cin>>n>>p;
    factorize(p);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define hell 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
void solve(){
    int a,b;
    cin>>a>>b;
    if(max(a,b)>=10){
        cout<<-1<<endl;
    }
    else{
        cout<<a*b<<endl;
    }
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    int tests = 1;
    //cin>>tests;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=100005;
struct node { int y,next; } a[N<<1];
int head[N],sg[N],i,j,k,n,m;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ char c; int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

void jb(int x,int y)
{
	a[++k]=(node){y,head[x]},head[x]=k,
	a[++k]=(node){x,head[y]},head[y]=k;
}

void dfs(int w,int sp)
{
	for (register int j=head[w];j;j=a[j].next)
		if ((j^1)!=sp)
		{
			int c=a[j].y;
			dfs(c,j),sg[w]^=sg[c]+1;
		}
}

int main()
{
	n=read(),k=1;
	for (i=1;i<n;++i) jb(read(),read());
	dfs(1,0);
	puts(sg[1]?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 8960
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	rep(i, s.size()) s[i] = 'x';
	cout << s << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")

def ok(idx, a_list):
    now = a_list[idx]
    for i in range(len(a_list)):
        if i == idx:
            continue
        else:
            if a_list[i] > now * 2:
                return False
            now += a_list[i]
    return True


def main():
    N = int(input())
    a_list = sorted(list(map(int, input().split())))

    # [low, high)
    low, high, ans = -1, N, -1
    while high - low > 1:
        middle = (low + high) // 2
        if ok(middle, a_list):
            ans = middle
            high = middle
        else:
            low = middle

    print(N - ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14956
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define init(arr,val) memset(arr,val,sizeof(arr))
#define BINF 1000000000001
const int LG = 22;




#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);
    


    int n;
    cin >> n;
    int x = n / 2 + (n & 1);

    double ans = (double)x / (double)n;
    cout << fixed << setprecision(8) << ans;




    

return 0;  
}


Measured memory_bytes: 256
def probB():
    N = int(input())
    count = 0

    try:
        while 1:
            if count == 3:
                print('Yes')
                return

            D1, D2 = map(int, input().split())
            if D1 == D2:
                count += 1
            else:
                count = 0

    except EOFError:
        print('No')


def main():
    probB()


if __name__ == '__main__':
    main()


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

using ll = long long;

ll f(ll a,ll b){
	if(a>b)std::swap(a,b);
	return !a?-b:2*a*(b/a)+f(b%a,a);	
}

int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	ll ans=n+f(n-k,k);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n)                                                              \
    for (int64_t i = 0; i < (int64_t)(n); i++)                                 \
        ;
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;
using namespace std;
int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long int ld;
typedef unsigned long long int lu;
typedef vector< int > vi;
typedef vector < ld > vd;
typedef set <ld> sd;
typedef vector< vi > vvi;
typedef vector< vd > vvd;
typedef pair< int,int > ii;
typedef pair< ld,ld > id;
#define sz(a) ld((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

#define rep(i,a,b) for(i=a;i<b;i++)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define reprev(i,a,b) for(i=a;i>=b;i--)


#define Vi vector
#define pr pair
#define isnum(a) (a>=48 && a<=57)
#define isS(a) (a>='a' && a<='z')
#define isU(a) (a>='A' && a<='Z')
#define toS(a) (isU(a)?a+32:a)
#define toU(a) (isS(a)?a-32:a)
#define toC(a) a&15

vector<char> prime (10000000+1, true);
void sieve(ld n)
{	
	//O(nloglogn) time
	prime[0] = prime[1] = false;
	for (ld i=2; i<=n; ++i)
		if (prime[i])
			if (i * 1ll * i <= n)
				for (ld j=i*i; j<=n; j+=i)
					prime[j] = false;
}


vd v1;
vector <bool> visit;
vvd g;
vvd g1;
vd ar;
vvd final;
//ld mind = 1000000006;
vd mind;
ld c;

//for topological sort of a graph
void dfs(ld i,ld n)
{
	visit[i] = true;
	ld j,k;
	for(j=0;j<g[i].size();j++)
	{
		if(!visit[g[i][j]])
		{
			dfs(g[i][j],n);
		}
	}
	v1.pb(i);
}
//next step
//from transposed graph g1,get strongly connected components
void dfs1(ld i,ld n,ld len)
{
	visit[i] = true;
	ld j,k;
	final[len].pb(i);
	mind[len] = min(mind[len],ar[i]);
	rep(j,0,g1[i].size())
	{
		if(!visit[g1[i][j]])
		{
			dfs1(g1[i][j],n,len);
		}
	}
}

int main(){
	ld n,i,j,k;
	cin >> n >> k;
	ld ar[n];
	for(i=0;i<n;i++)
	{
		cin >> ar[i];
	}
	ld dp[n+1] = {0};
	//cout << dp[2] << endl;
	dp[1]=0;
	dp[2] = dp[1]+abs(ar[1]-ar[0]);
	//cout << dp[2] << endl;
	rep(i,3,n+1)
	{
		dp[i] = 1000000009;
		reprev(j,i-1,i-k)
		{
			if(j<1)break;
			dp[i] = min(dp[i],dp[j]+abs(ar[i-1]-ar[j-1]));
		}
	//	dp[i] = min(dp[i-1]+abs(ar[i-1]-ar[i-2]),dp[i-2]+abs(ar[i-1]-ar[i-3]));
	}
	cout << dp[n] << endl;
	return 0;
}	

Measured memory_bytes: 11520
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	cin >> s;
	
	bool yes = true;
	if( s[2] != s[3] ) { 
		yes = false;
	} else if( s[4] != s[5] ) { 
		yes = false;
	}
	
	if( yes ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;

int main(){

    int k = 0;

    cin>>k;

    for(int i = 0; i < k; i++){
        cout<<"ACL";
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
typedef tuple< int, int, int > Pi;
struct edge
{
  int to, cost;
};

int N, M, C;
vector< vector< edge > > graph;
int min_cost[100][101];

int Dijkstra()
{
  
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;  
  fill_n(*min_cost, 100 * 101, INF);
  que.emplace(0, 0, 0);
  min_cost[0][0] = 0;
  int ret = N;
  while(!que.empty()) {
    int cost, now, zero;
    tie(cost, now, zero) = que.top(); que.pop();
    if(cost > C) break;
    if(now == N - 1) {
      ret = min(ret, zero);
      continue;
    }
    if(cost > min_cost[now][zero]) {
      continue;
    }
    for(auto&& e : graph[now]) { 
      if(cost + e.cost < min_cost[e.to][zero]) {
        min_cost[e.to][zero] = cost + e.cost;
        que.emplace(cost + e.cost, e.to, zero);
      }
      if(zero < N && cost < min_cost[e.to][zero + 1]) {
        min_cost[e.to][zero + 1] = cost;
        que.emplace(cost, e.to, zero + 1);
      }
    }
  }
  return(ret);
}
int main()
{  
  while(cin >> N >> M >> C, N) {
    graph.resize(N);
    while(M--) {
      int x, y, c;
      cin >> x >> y >> c;
      --x, --y;
      graph[x].push_back((edge){y, c});
    }
    cout << Dijkstra() << endl;
    graph.clear();
  }
}

Measured memory_bytes: 3272
from bisect import bisect_left, bisect, insort
def main():
    n = int(input())
    s = list(input())
    q = int(input())
    _is = {chr(i):[] for i in range(ord("a"), ord("a")+27)}
    for i, si in enumerate(s):
        _is[si].append(i)
    for _ in range(q):
        t, i, c = input().split()
        i = int(i)-1
        if t == "1":
            if s[i] != c:
                index = bisect_left(_is[s[i]], i)
                del _is[s[i]][index]
                insort(_is[c], i)
                s[i] = c
        else:
            c = int(c) - 1
            cnt = 0
            for _isi in _is.values():
                if _isi:
                    is_in = bisect(_isi, c)-bisect_left(_isi, i)
                    if is_in:
                        cnt += 1
            print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 108288
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
signed main(){
	int n;
	cin>>n;
	vector<int> a(n);
	bool plus=false,minus=false;
	rep(i,n){ 
		cin>>a[i];
		if(a[i]>0) plus=true;
		if(a[i]<0) minus=true;
	}
	if(!plus&&!minus){ 
		cout<<0<<endl;
		return 0;
	}
	vector<int> tmp=a;
	int m=0;
	vector<P> man;
	while(plus){
		bool ok=true;
		vector<P> b;
		rep(i,n) b.push_back(P(tmp[i],i));
		sort(All(b));
		rep(i,n-1){	
			if(tmp[i]>tmp[i+1]){ 
				tmp[i+1]+=b[n-1].first;
				man.push_back(P(b[n-1].second+1,i+2));
				m++;
				ok=false;
				break;
			}
		}
		if(ok) break;
		if(m>2*n) plus=false;
	}
	if(m<=2*n&&plus){ 
		//cout<<"test"<<endl;
		cout<<m<<endl;
		rep(i,man.size()){
			cout<<man[i].first<<" "<<man[i].second<<endl;
		}
		return 0;
	}
	tmp=a;
	m=0;
	man.clear();
	while(minus){
		bool ok=true;
		vector<P> b;
		rep(i,n) b.push_back(P(tmp[i],i));
		sort(All(b));
		rep(i,1,n){	
			if(tmp[n-i]<tmp[n-i-1]){ 
				tmp[n-i-1]+=b[0].first;
				man.push_back(P(b[0].second+1,n-i));
				m++;
				ok=false;
				break;
			}
		}
		//cout<<m<<endl;
		if(ok) break;
		if(m>2*n) minus=false;
	}
	if(m<=2*n&&minus){ 
		cout<<m<<endl;
		rep(i,man.size()){
			cout<<man[i].first<<" "<<man[i].second<<endl;
		}
		return 0;
	}
	a.at(n);
}


Measured memory_bytes: 256
n,k = gets.chomp.split(' ').map(&:to_i)
members = (1..n).to_a
i = 0
while i < k
  snack = gets.chomp.to_i
  member = gets.chomp.split(' ').map(&:to_i)
  members -= member
  i += 1
end
p members.size

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

main () {
 int a, b, c, k, n, ans;
 cin >> a >> b >> c >> k;
  if(a <= c && b <= c) n=c;
  else if ( a <= b && c <= b) n=b;
  else n=a;
 ans = n;
 for (int i=0;i<k;i++) ans *= 2;
 ans += a+b+c;
 ans -= n;
 cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>
 
#define str string
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  LCIN(n,m);
  if(n==1&&m==1){COUT(1);return 0;}
  if(n>m)swap(n,m);
  if(n==1)
    {COUT(m-2);return 0;}
  if(n==2||m==2){COUT(0);return 0;}
  ll num = 1LL*(n-2)*(m-2);
  COUT(num);


  return 0;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    var s = mutableListOf<String>()
    (1..N).forEach {
        val str = readLine()!!
        s.add(str.toCharArray().sorted().toString())
    }


    val countMap = hashMapOf<String, Long>()
    s.forEach {
        val string = it.toString()
        if (countMap.contains(string)) {
            countMap[string] = countMap[string]!! + 1L
        } else {
            countMap[string] = 1
        }
    }

    var answer = 0L
    countMap.entries
            .filter { it.value > 1 }
            .forEach {
                val size = it.value
                answer += size * (size - 1L) / 2L
            }
    println(answer)
}

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

int main(void) {
  long long answer = 0;
  long long N;
  cin >> N;
  for (long long i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      answer += i;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3624
import java.util.*;
class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int arr[] =new int[n];
        int res[]=new int[n];
        for(int i=0;i<n;i++)
        {
            arr[i]=sc.nextInt();
            res[i]=Integer.MAX_VALUE;
        }
        res[0]=0;
        for(int i=1;i<n;i++)
        {
            for(int j=i-k;j<i;j++)
            {
                if(j>=0) 
                res[i]=Math.min(Math.abs(arr[i]-arr[j])+res[j],res[i]);
            }
        }
        System.out.println(res[n-1]);
    }
}

Measured memory_bytes: 60324
n = int(input())
s = []
t = []
for i in range(n):
    s_, t_ = map(str, input().split())
    s.append(s_)
    t.append(int(t_))
x = input()

for i in range(n):
    if s[i] == x:
        break

ans = 0
for j in range(n-1, i, -1):
    ans += t[j]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dl double long
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rrep(i, m, n) for(ll i = (ll)(m); i > (ll)(n); --i)
const ll MOD = 1000000007;
const ll MMOD = 998244353;
const double pi = 3.14159265358979323846;

int main(void){
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k) cout << s << endl;
    else cout << s.substr(0, k) << "..." << endl; 
    return 0;
}

Measured memory_bytes: 3600