akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

const int N=2e5+5;
int32_t main(){
    char a,b,c;
    cin>>a>>b>>c;
    cout<<a<<b<<c<<'\n';

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define fi first 
#define se second 
const int maxn = 2e5 + 100 ;
set < pair < int , int  > > s ;
ll a[maxn] , n, r , l , mid  ;
void add ( int i ) 
{
	if ( s.rbegin()->se!= 0) 
		s.insert ( { a[i-1] + 1 , 0 } ) ;
}
bool check( int x ) 
{
	s.clear() ;
	s.insert ( { 0 , 0 } ) ;
	for ( int i = 1 ; i<n ; i++)
	{
		if ( a[i] > a[i-1] ) 
			add ( i ) ;
		else
		{
			
			while ( s.rbegin()->fi > a[i] ) 
				s.erase( *s.rbegin() ) ;
			if ( s.rbegin()->se != x ) 	
			{	
				int col = s.rbegin()->se ;
				if ( s.rbegin()->fi == a[i]  ) 
					s.erase ( *s.rbegin() ) ;
				if ( s.empty() || (!s.empty() && s.rbegin()->se!=col+1))
					s.insert ( { a[i] , col+1 } ) ;
			}
			else
			{
				int ind = s.rbegin()->fi ;
				if ( ind == 0 )
					return false ;
				s.erase( *s.rbegin() ) ;
				int col = s.rbegin()->se ;
				if ( s.rbegin()->fi == ind-1 ) 
					s.erase ( *s.rbegin() ) ;
				if ( s.empty() || (!s.empty() && s.rbegin()->se != col + 1 ) ) 
					s.insert ( { ind-1 , col+ 1 } ) ;
				s.insert ( {ind , 0 } ) ;			
			}
		}
	}
	return true ;
}
void bs()
{
	l = -1 , r = n+1 ;
	while ( r-l > 1 ) 
	{
		 mid = ( l+r) /2 ;
		if ( check ( mid ) ) 
			r = mid ;
		else
			l = mid ;
	}
	cout << r+1 << endl;
}
int main()
{
	 cin >> n ;
	 for ( int i = 0 ;i<n ; i++)
		 cin >> a[i] , a[i] -- ;
	bs() ; 
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long sum=0,count=0;
		double[] a=new double[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextLong();
			if(a[i]%2==0) {
				while(a[i]%2==0) {
					a[i]/=2;
					count++;
				}
				sum+=count;
				count=0;
			}
		}
		System.out.println(sum);
	}
}



Measured memory_bytes: 35280
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)'''

a=list(map(str, [0,1,2,3,4,5,6,7,8,9]))
n,k=map(int, input().split())
d=list(map(str, input().split()))
for item in d:
    a.remove(item)
#print(a)

from collections import deque

q=deque()
q.extend(a)
for i in range(len(a)):
    if int(a[i])>=n:
        print(a[i])
        sys.exit()

while True:
    qq=q.popleft()
    #print(q)
    for item in a:
        qqq=qq+item
        #print(qqq[::-1])
        if int(qqq)>=n:
            print(qqq)
            sys.exit()
        q.append(qqq)


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

const int N = 1e5 + 5;

long long dp[N];
int n, k;
int arr[N];

void read() {
  scanf("%d", &n);
  k = 2;
  for (int i = 1 ; i <= n ; i++) {
    scanf("%d", &arr[i]);
  }
}

long long work() {
  dp[n] = 0;
  for (int i = n-1 ; i >= 1 ; i--) {
    dp[i] = 4e18;
    for (int j = 1 ; j <= k && i + j <= n ; j++)
      dp[i] = min(dp[i], dp[i+j] + abs(arr[i] - arr[i+j]));
  }
  return dp[1];
}

int main() {
  read();
  cout << work() << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int div(int x) {
  int count = 0;
  while (x % 2 == 0) {
    x /= 2;
    count++;
  }
  return count;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    int ans = 0;
    rep(i, n) {
      int a;  cin >> a;
      ans += div(a);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef int64_t ll;

int main()
{
    while (1) {
        int n; cin >> n;
        if (!n) return 0;
        int SCHED[60][30] = {};
        loop (n, i) {
            int f; cin >> f;
            loop (f, j) {
                int d; cin >> d;
                SCHED[i][d - 1] = 1;
            }
        }

        ll MAPS[60] = {};
        loop (n, i) MAPS[i] = 1LL << i;

        int ans = -1;
        loop (30, i) {
            if (ans != -1) break;
            vector<int> HIT;
            ll mask = 0;
            loop (n, j) {
                if (!SCHED[j][i]) continue;
                HIT.push_back(j);
                mask |= MAPS[j];
            }
            for (int j : HIT) MAPS[j] = mask;

            loop (n, j) {
                if (MAPS[j] == (1LL << n) - 1) ans = i + 1;
            }
        }

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

Measured memory_bytes: 2988
#include<bits/stdc++.h>
	using namespace std;
	#define ll       long long
	#define ull       unsigned long long
	#define  sci(x)   scanf("%d", &x)
	#define  scl(x)   scanf("%lld", &x)
	#define  scd(x)   scanf("%lf", &x)
	#define l0(i,n)   for(ll i=0; i<n; i++)
	#define MAX                 100000


	int main ()
	{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		ll t, k;
		cin >> t >> k;
		map<ll, bool> mp;
		ll inp;
		for(ll i=0; i<k; i++)
		{
    	cin >> inp;
    	mp[inp] = 1;
		}
		for(ll i=0; ; i++)
		{
    	if(mp[t-i] == 0){
    		cout << t-i;
    		break;
    	}
    	if(mp[t+i] == 0)
    	{
    		cout << t+i;
    		break;
    	}
    }
		return 0;
}


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

int main(void) {
    int N;
    cin >> N;
    bool flag = false;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i * j == N) {
                flag = true;
                break;
            }
        }
    }
    if (flag) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


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

count = 0
flag = True
while flag == True:
  for i in range(N):
    if A[i] % 2 == 1:
      flag = False
  if flag == True:
    count += 1
 
    A = list(map(lambda x: int(x / 2), A))

print(count)
  

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  
  int64_t s = 0;
  
  vector<vector<int>> v(100001, vector<int>(0));
  
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    s += a.at(i);
    v.at(a.at(i)).push_back(i);
  }
  
  int q;
  cin >> q;
  
  for (int i = 0; i < q; i++) {
    int b, c;
    cin >> b >> c;
    if (b != c) {
      int z = v.at(b).size();
      for (int j = 0; j < z; j++) {
        v.at(c).push_back(v.at(b).at(j));
      }
      for (int j = 0; j < z; j++) {
        v.at(b).pop_back();
      }
      
      s += (c - b) * z;
      cout << s << endl;
    }
    
    else
      cout << s << endl;
  }
}

Measured memory_bytes: 29908
import java.util.*;

public class Main {
    static int n;
    static PriorityQueue<List<Integer>> que = new PriorityQueue<>();
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        
        String str = "";
        dfs(0, str, 0, 0);
        
        
    }
    
    public static void dfs(int x, String str, int count, int max) {
        char c = (char)(x + 'a');
        str += c;
        count++;
        if (count == n) {
            System.out.println(str);
            return;
        }
        
        max = Math.max(x, max);
        for (int i = 0; i <= max + 1; i++) {
            dfs(i, str, count, max);
        }
        
        // if (max > x) {
        //     for (int i = 0; i <= Math.max(max, x + 1); i++) {
        //         max = Math.max(max, i);
        //         dfs(i, str, count, max);
        //     }
        // } else {
        //     for (int i = 0; i <= Math.max(max, x + 1); i++) {
        //         max = Math.max(max, i);
        //         dfs(i, str, count, max);
        //     }
        // }
    }
}


Measured memory_bytes: 41208
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            int m = sc.nextInt();
            while(m-- != 0) {
            	int a = sc.nextInt();
            	int t = sc.nextInt();
            	int n = sc.nextInt();
            	int max = a;
            	while(n-- != 0) {
            		int k = sc.nextInt();
            		double r = sc.nextDouble();
            		int b = sc.nextInt();
            		if(k == 0) {
            			int x = a;
            			int ris = 0;
            			for(int i=0; i<t; i++) {
            				ris += x*r;
            				x -= b;
            			}
            			max = Math.max(max, x+ris);
            		}
            		else {
            			int x = a;
            			for(int i=0; i<t; i++) {
            				x = (int)(x + x*r - b);
            			}
            			max = Math.max(max, x);
            		}
            	}
            	System.out.println(max);
            }
        }
    }
}



Measured memory_bytes: 53744
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using static System.Math;


class P
{
    static void Main()
    {
        int[] tx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine((double)tx[0] / (double)tx[1]);
    }
}


Measured memory_bytes: 13268
import Control.Applicative
import Data.List
import qualified Data.Set as Set

main = do
    [n,m] <- map read . words <$> getLine
    print $ solve n m

solve :: Int -> Int -> Int
solve n m | abs (n-m) > 1 = 0
            | n' == m' = mp 2 (mp nf' nf')
            | otherwise = mp nf' mf'
            where n' = max n m
                  m' = min n m
                  nf' = mf n'
                  mf' = mf m'

mprod x y m = mod ((mod x m) * (mod y m)) m

mfact 0 _ = 1
mfact n m = mprod n (mfact (n-1) m) m

mm = 1000000007

mf n = mfact n mm
mp x y= mprod x y mm


Measured memory_bytes: 3964
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        long a = sc.nextInt();
        long b = sc.nextInt();
        if(n == 1){
            System.out.println(a == b ? 1 : 0);
        }else if(a > b){
            System.out.println(0);
        }else{
            System.out.println((n-2)*(b-a)+1);
        }
        
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    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: 23124
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<int> L(M), R(M);
	for (int i = 0; i < M; i++) cin >> L[i] >> R[i];

	cout << max(*min_element(R.begin(), R.end()) - *max_element(L.begin(), L.end()) + 1,0) << "\n";

	return 0;
}

Measured memory_bytes: 1024
/**                                                     **\
 *    author:       Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
**/                                                     
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int max3(int a,int b,int c){
    return max(a,max(b,c));
}
int min3(int a,int b,int c){
    return min(a,min(b,c));
}
void under_rated(){
fast;
}
int32_t main(){
    under_rated();
    int n,k;
    cin>>n>>k;
    int tot=0;
    vector<int> v(n);
    for(int i=0;i<n;++i){
        cin>>v[i];
    }
    for(int i=0;i<n;++i){
        int pre=0,next=0;
        for(int j=0;j<n;++j){
            if(v[i]<=v[j]){
                continue;
            }
            if(i<j){
                ++next;
            }
            else{
                ++pre;
            }
        }
        int x = (k*(k+1))/2;
        x%=MOD;
        int y = (k*(k-1))/2;
        y%=MOD;
        tot+=(next*x)%MOD;
        tot+=(pre*y)%MOD;
    }
    cout<<tot%MOD;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 29);
ll k, m, n,h,w,v;
const ll MOD= 1000000007;
const ld PI = acos(-1);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main() {
    cin >> n >> h >> w;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    ll sum = 0,co;
    rep(i, n - 1) {
        co = min((x[i + 1] - x[i])*h, w);
        sum += co;
    }cout << sum << endl;
}

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

vector <int> V;
int n,x,y,k;
int dp[100010];

int main()
{
    cin >> n >> k;
    for (int i=0;i<n;i++){
        cin >> x;
        V.push_back(x);
    }

    for (int i=1;i<n;i++){
        dp[i]=INT_MAX;
        x=V[i];
        for (int j=1;j<=k;j++){
            if (i-j<0) break;
            y=V[i-j];
            dp[i]=min(dp[i],dp[i-j]+abs(x-y));
        }
    }
    cout << dp[n-1];
}


Measured memory_bytes: 4152
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;
int main()
{
	int n, l;
	cin >> n >> l;
	int a = 999;
	int ans = 0;
	for (int i = l; i < n + l; i++)
	{
		if (abs(a) > abs(i) || i == 0)
		{
			a = i;
		}
		ans += i;
	}
	cout << ans - a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

ll pal(ll s){
	return s*(s-1)/2;
}
int main(){
	IOS;
	
	ll n;cin>>n;
	ll a[n],f[n+1]={0};
	ll b[n+1];
	ll tot=0;
	rep(i,0,n)cin>>a[i],f[a[i]]++;
	rep(i,1,n+1){
		tot += pal(f[i]);
	}
	rep(i,0,n) cout << tot - f[a[i]] + 1 << "\n";
	return 0;
}



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

using namespace std;;

int main(){

	long long n,w;
	cin>>n>>w;
	
	long long berat[n],value[n];
	
	for (long long i=1;i<=n;i++){
		cin>>berat[i]>>value[i];
	}
	
	long long dp[n+1][w+1];
	
	memset(dp,0,sizeof dp);
	
	for (long long i=1;i<=n;i++){
		for (long long j=0;j<=w;j++){
			dp[i][j]=dp[i-1][j];
			if (j-berat[i]>=0){
				dp[i][j]=max(dp[i][j],dp[i-1][j-berat[i]]+value[i]);
			}
		}
	}

	cout<<dp[n][w]<<endl;

	return 0;
}


Measured memory_bytes: 82272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

ll power(ll x,ll n){
    if(n==0) return 1;
    ll res=power(x*x%mod,n/2);
    if(n&1) res=res*x%mod;
    return res;
}

int main() {
  ll n,m,k;
  cin>>n>>m>>k;
  ll a[n*m+1];
  a[0]=1;
  rep(i,1,n*m+1) a[i]=a[i-1]*i%mod;
  ll b[n*m+1];
  b[0]=1;
  rep(i,1,n*m+1) b[i]=power(a[i],1e9+5);
  ll ans=((n-1)*n*(n+1)/6)%mod*m%mod*m%mod+((m-1)*m*(m+1)/6)%mod*n%mod*n%mod;
  ans%=mod;
  ans=ans*(a[n*m-2]*b[k-2]%mod*b[n*m-k]%mod)%mod;
  cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  string s; cin>>s;

  string t;
  vector<int> a;
  int tmp = 0;
  for (auto c:s) {
    if (c != 'x') {
      t.push_back(c);
      a.push_back(tmp);
      tmp = 0;
    } else {
      tmp++;
    }
  }
  a.push_back(tmp);

  string u = t;
  reverse(t.begin(), t.end());
  if (t != u) {
    cout << -1 << endl;
    return 0;
  }

  int n = a.size();
  int ans = 0;
  for (int i=0; i<n/2; i++) {
    ans += abs(a[i]-a[n-i-1]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3964
import math

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


all_list = []

for i in range(n):
    x = input()
    x = x.split(' ')

    # x = list(x)
    # print(x)
    x = [float(v) for v in x] # to float

    all_list.append(x)  # list of list

# print(all_list)

cnt = 0

for i in range(n):
    target = all_list[i]

    for j in range(n - (i + 1)):
        target2 = all_list[j + i + 1]

        # sum_1 = [u ** 2 + v ** 2 for u, v in zip(target, target2)]
        sum_1 = [(target[q] - target2[q]) ** 2 for q in range(d)]
        sum_2 = sum(sum_1)
        dis = math.sqrt(sum_2)

        # print('---')
        # print(target)
        # print(target2)

        if dis.is_integer():
            cnt += 1

print(cnt)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vi vector < ll  int >
#define CLR(a) memset((a),0,sizeof(a))
#define mp make_pair
#define hell 1000000007
#define pc __builtin_popcount
using namespace std;

void solve()
{
  int  i,j=0,r=200,p,q,k=1,ans=0,d,y=0,x,n,h,flag=0,m=0,id,c=0,h1,h2,a1,b1,w,b,a;
  string s1,s2;
 cin>>n>>k;
 string s;
 cin>>s;
 rep(i,0,n-1)
 {
     if(s[i]==s[i+1]) y++;
     else c++;
 }
 d=min(c,2*k);
 cout<<y+d;

}


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    solve();
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>b(N);
	rep(i, 0, N) {
		cin >> b[i];
	}
	bool ok = true;
	vector<int>ans(N);
	rep(i, 0, N) {
		int cnt = -INF;
		rep(j, 0, b.size()) {
			if (j + 1 == b[j])chmax(cnt, j);
		}
		if (cnt == -INF) {
			cout << -1 << "\n";
			return 0;
		}
		ans[i] = cnt + 1;
		b.erase(b.begin() + cnt);
	}
	rREP(i, 0, N)cout << ans[i] << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int main(void){
   int X,N;
   cin>>X>>N;
   vector<int> p(N);
   for(int i=0;i<N;i++){
      cin>>p[i];
   }
   sort(p.begin(),p.end());
   vector<int> number;
   for(int i=-200;i<=200;i++){
      bool flag=true;
      for(int j=0;j<N;j++){
         if(i==p[j]){
            flag=false;
            break;
         }
      }
      if(flag) number.push_back(i);
   }
   int mini=101;
   for(int i=0;i<number.size();i++){
      mini=min(mini,abs(number[i]-X));
   }
   for(int i=0;i<number.size();i++){
      if(abs(number[i]-X)==mini){
         cout<<number[i]<<endl;
         return 0;
      }
   }
   return 0;
}


Measured memory_bytes: 3628
#coding: utf-8
import math

def main():
    line_input = input()
    line_split = line_input.split()
    A = int(line_split[0])
    B = int(line_split[1])
    K = int(line_split[2])

    if A < B:
        mini = A
    else:
        mini = B
    num_list = [mini - i for i in range(mini)]
    
    counter = 0
    for i in num_list:
        if A%i is 0 and B%i is 0:
            counter += 1
        if counter == K:
            print(i)
            return

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for _ in range (D)]
M = 26
INF = 10**20

def judge(t,idx,val):
    last = [0]*M
    minus = [0]*M
    score = 0
    for i in range(D):
        ti = t[i]
        if i==idx:
            ti = val
        score += S[i][ti-1]
        last[ti-1] = i+1
        for m in range(M):
            temp = C[m]*(i+1-last[m])
            score -= temp
            minus[m] = -temp
    return score, minus

from random import randint
import time
start = time.time()
ans = [0]*D
lasts = [0]*(M+1)


score = 0
for i in range(D):
    contest = 0
    max_score = -INF
    for m in range(M):
        new_score = score
        new_score += S[i][m]
        for m2 in range(M):
            if m==m2:continue
            new_score -= C[m2]*(i+1-lasts[m2])
        if new_score>max_score:
            contest = m+1
            max_score = new_score
    
    ans[i] = contest
    lasts[contest-1] = i+1
    score = max_score

key = [i+1 for i in range(M)]
minus = [0]*M
while (time.time()-start<1.7):
    # 解を変更
    idx = randint(0,D-1)

    # マイナスの寄与が大きいmを選択
    mc = zip(minus, key)
    mc = sorted(mc)
    minus, key = zip(*mc)
    val_ = randint(0, 7)
    val = key[val_]
    # スコアが上がっているか？
    new_score, minus = judge(ans, idx, val)
    if new_score>score:
        score = new_score
        ans[idx] = val  

for a in ans:
    print(a)

Measured memory_bytes: 82748
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  string s;
  cin >> s;
  string k = "hi";
  bool ans = false;
  for (int i = 0; i < 11; i++) {
    if (s == k) ans = true;
    k += "hi";
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
let s=ref(read_line())open Bytes;;for _=1to read_int()do match Scanf.scanf"%s "(fun i->i)with"print"->Scanf.scanf"%d %d
"(fun a b->print_endline(sub!s a(b-a+1)))|"reverse"->Scanf.scanf"%d %d
"(fun a b->s:=mapi(fun i c->if i>=a&&i<=b then!s.[a+b-i]else c)!s)|_->Scanf.scanf"%d %d %s
"(fun a b p->s:=sub!s 0a^p^sub!s(b+1)(length!s-1-b))done

Measured memory_bytes: 2372
#include<bits/stdc++.h>
using namespace std;
int k,x;
int main() {
	scanf("%d%d",&k,&x);
	for(int i=max(x-k+1,-1000000);i<=x;i++)
		printf("%d ",i);
	for(int i=x+1;i<=min(x+k-1,1000000);i++)
		printf("%d ",i);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, count, ans=0, reg, reg2;
  std::cin >> N;
  std::vector<int> A(N);
  std::vector<int> li(N, 0);
  range(i, N) std::cin >> A[i];
  sort(A.begin(), A.end());

  for(int i=N-1;i>=0;i--){
    int a = lower_bound(A.begin(), A.end(), A[i]) - A.begin();
    int b = upper_bound(A.begin(), A.end(), A[i]) - A.begin();
    if(li[a] >= b - a) continue;
    count = 0;
    reg = A[i];

    while(reg >= 2){
      reg = reg >> 1;
      count++;
    }
    range(j, count+1) reg = reg << 1;

    reg2 = A[i];
    li[a]++;
    if(binary_search(A.begin(), A.end(), reg - reg2)){
      int mm = lower_bound(A.begin(), A.end(), reg - reg2) - A.begin();
      int m = upper_bound(A.begin(), A.end(), reg - reg2) - A.begin();
      if(li[mm] >= m - mm) continue;
      li[mm]++;
      ans++;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

	if (A > 8 || B > 8) cout << ":(" << endl;
	else cout << "Yay!" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

// 最大公約数を返す
constexpr long long gcd(long long a, long long b) {
	if(a < b) {
		std::swap(a, b);
	}

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

	return b;
}

int main() {
	ll n, k;
	cin >> n >> k;
	VLL a(n);
	REP(i, n) { cin >> a[i]; }
	ll a_max = 0;
	REP(i, n) { chmax(a_max, a[i]); }
	if(k > a_max) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	ll result = a[0];
	REP(i, n) { result = gcd(result, a[i]); }
	if(k % result == 0) {
		cout << "POSSIBLE" << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}


Measured memory_bytes: 3900
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve(){
    int a, p;
    cin >> a >> p;
    cout << (a*3+p)/2 << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

ll ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main(){

    string s;
    cin >> s;

    ll n=s.size();
    ll p=2019;
    ll ans=0;

    vec a(n+1);
    ll d=1;
    for(ll i=0;i<n;i++){
      ll b=ctoi(s[n-1-i]);
      if(i!=0)d=(d*10)%p;
      a[i+1]=a[i]+d*b%p;
      a[i+1]%=p;
    }

    vec b=a,c=a;
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    c.erase(unique(c.begin(),c.end()),c.end());
    for(ll i=0;i<c.size();i++){
      ll e=upper_bound(b.begin(),b.end(),c[i])-lower_bound(b.begin(),b.end(),c[i]);
      ans+=e*(e-1)/2;
    }

    cout << ans << endl;

}

Measured memory_bytes: 8352
import java.util.*;
import java.io.*;
import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException {
        //BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        System.out.println(Math.min(c,b/a));
    }
}

Measured memory_bytes: 21972
#include<stdio.h>

int main(){
	int N, T , A;
	scanf("%d%d%d",&N ,&T ,&A);
	int H[N];
	for(int i=0;i<N;i++){
		scanf("%d",&H[i]);
	}
	int x[N];
	int min = 0;
	for(int j=0;j<N;j++){
		x[j] = 1000*A - (1000*T - H[j]*6);
		if(x[j]<0){
			x[j] *= -1;
		}
	}
	for(int k=0;k<N;k++){
		if(x[k] < x[min]){
			min = k;
		}
	}
	printf("%d",min+1);
	return 0;
}	

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 17 21:11:38 2020

@author: liang
"""

"""
【２番目の取得】
"""
n = int(input())
E = list()
O = list()
i = 0
for v in input().split():
    if i%2 == 0:
        E.append(int(v))
    else:
        O.append(int(v))
    i += 1
#print(E)
#print(O)
edic = {}
odic = {}
for e in E:
    if e not in edic.keys():
        edic[e] = 1
    else:
        edic[e] += 1

for o in O:
    if o not in odic.keys():
        odic[o] = 1
    else:
        odic[o] += 1
        
etmp = [(-1,0),(-1,0)]
otmp = [(-1,0),(-1,0)]

for key in edic.keys():
    #first
    if edic[key] > etmp[0][1]:
        etmp[1] = etmp[0]
        etmp[0] = (key, edic[key])
    #second
    elif edic[key] > etmp[1][1]:
        etmp[1] = (key,edic[key])

for key in odic.keys():
    #first
    if odic[key] > otmp[0][1]:
        otmp[1] = otmp[0]
        otmp[0] = (key, odic[key])
    #second
    elif odic[key] > otmp[1][1]:
        otmp[1] = (key,odic[key])

if etmp[0][0] == otmp[0][0]:
    ans = max(etmp[0][1]+otmp[1][1],etmp[1][1]+otmp[0][1])
else:
    ans = etmp[0][1]+otmp[0][1]
print(n-ans)

Measured memory_bytes: 22264
N, M = map(int, input().split())
G = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append(b)
    G[b].append(a)

def bridge(G, N):
    result = set()
    label = [None] * N
    gen = 0
    cost = [0] * N
    
    def dfs(u, p):
        nonlocal gen
        res = 0
        for v in G[u]:
            if v == p:
                continue
            if label[v] is not None:
                if label[v] < label[u]:
                    cost[v] += 1
                    res += 1
            else:
                label[v] = gen
                gen += 1
                r = dfs(v, u)
                if r == 0:
                    result.add((u, v) if u < v else (v, u))
                res += r
        res -= cost[u]
        return res

    for v in range(N):
        if not label[v]:
            label[v] = gen
            gen += 1
            r = dfs(v, -1)
            assert r == 0, r
    return result

res = bridge(G, N)
print(len(res))


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

int main()
{
    ll n; cin >> n;
    vector<ll> s, v;
    s.push_back(0);
    v.push_back(0);
    ll d = 0;
    while(1){
        d++;
        v.push_back((ll)powl(26, d));
        s.push_back(s[d-1] + (ll)powl(26, d));
        if(n <= s[d]) break;
    }

    rep(i, d){
        n -= v[i];
    }

    // pr(n);
    string ans;

    ll inc = 0;
    while(d>0){
        ll t;
        if(d!=1) t = ((n-1) / v[d-1]);
        else t = n - 1;
        // printf("%ld %ld\n", n, t);
        ans.push_back(t + 'a');
        n -= (t)*v[d-1];
        d--;
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3756
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

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

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int powa[100010] = {}, powb[100010] = {};
  powa[0] = 1;
  REP(i, 100009){
    powa[i+1] = powa[i]*3;
    powa[i+1] %= MOD;
  }
  powb[0] = 1;
  REP(i, 100009){
    powb[i+1] = powb[i]*2;
    powb[i+1] %= MOD;
  }
  string L; cin >> L;
  int ans = 0, cnt = 0, tmp = 1;
  REP(i, L.size()){
    if(L[i] == '1') {
      cnt++;
      ans += powa[((int)L.size()-i-1)]*tmp;
      tmp*=2; tmp %= MOD;
      ans %= MOD;
    }
  }
  ans += powb[cnt];
  cout << ans % MOD << endl;
}

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

int main(){
  int N;
  cin >> N;
  
  if (N < 10){
    cout << N << endl;
  }
  else if (10 <= N && N < 100){
    cout << 9 << endl;
  }
  else if (100 <= N && N < 1000){
    cout << 9 + N - 99 << endl;
  }
  else if (1000 <= N && N < 10000){
    cout << 9 + 900 << endl;
  }
  else if (10000 <= N && N < 100000){
    cout << 9 + 900 + N - 9999 << endl;
  }
  else if (100000 <= N){
    cout << 9 + 900 + 90000 << endl;
  }
}


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

void fnMaxHeapifyUp(vector<int>& rvnPrtyHeap, int nx)
{
  int nParnt = nx / 2;
  int nLrge = nx;

  if (nParnt > 0  &&
      rvnPrtyHeap[nParnt] < rvnPrtyHeap[nLrge])
  {
    swap(rvnPrtyHeap[nParnt], rvnPrtyHeap[nLrge]);
    fnMaxHeapifyUp(rvnPrtyHeap, nParnt);
  }
}

void fnMaxHeapifyDown(vector<int>& rvnPrtyHeap, int nx)
{
  int nLeft = nx * 2;
  int nRigt = nLeft + 1;
  int nLrge = nx;

  if (nLeft < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nLeft])  
    nLrge = nLeft;
  if (nRigt < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nRigt])
    nLrge = nRigt;

  swap(rvnPrtyHeap[nx], rvnPrtyHeap[nLrge]);
  if (nx != nLrge)
    fnMaxHeapifyDown(rvnPrtyHeap, nLrge);
}

void fnPriorityQueue(vector<int>& rvnPrtyHeap)
{
  rvnPrtyHeap.push_back(-1);
  string sCmd;
  while (cin >> sCmd && sCmd != "end")
  {
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      rvnPrtyHeap.push_back(nNo);
      int nx = rvnPrtyHeap.size() - 1;
      fnMaxHeapifyUp(rvnPrtyHeap, nx);
    }
    else if (sCmd[0] == 'e')
    {
      cout << rvnPrtyHeap[1] << endl;
      rvnPrtyHeap[1] = rvnPrtyHeap.back();
      rvnPrtyHeap.pop_back();
      if (rvnPrtyHeap.size() > 1)
        fnMaxHeapifyDown(rvnPrtyHeap, 1);
    }
    else;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPrtyHeap; 

  fnPriorityQueue(vnPrtyHeap);
  return 0;
}

Measured memory_bytes: 6972
### main

loop do
  $n, $m = gets.strip.split(' ').map{|s| s.to_i}
  break if $n == 0 && $m == 0

  target = []
  for k in (0..2)
    cs = gets.strip.split(' ').map{|s| s.to_i}
    cs.shift

    for c in cs
      target[$n - c] = k
    end
  end

  count0 = 0
  p = 0

  ($n - 1).downto(0) do |k|
    if p != target[k]
      d = (target[k] - p).abs
      count0 += d * (3 ** k)
      if d == 1
        p = 2 - p
      end
    end
  end

  count1 = (3 ** $n) - 1 - count0
  count = [count0, count1].min

  puts (count > $m ? -1 : count)
end

Measured memory_bytes: 6120
#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;};

bool overlap(int A, int B, int C, int D) {
  if(D <= A) return false;
  if(B <= C) return false;
  return true;
}

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

  int a, b;
  cin >> a >> b;
  int n;
  cin >> n;
  int s, f;
  rep(i, n) {
    cin >> s >> f;
    if(overlap(a, b, s, f)) {
      cout << 1 << endl;
      return 0;
    }
  }

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



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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m ;
	cin >>n >>m;
	VL a(n), b(m), c(m);
	rep(i, n) cin >>a[i];
	rep(i, m){
		cin >>b[i] >>c[i];
	}
	
	map<ll, ll> mp;
	rep(i, n) mp[-a[i]]++;
	rep(i, m){
		mp[-c[i]] += b[i];
	}
	ll zn = n;
	ll ans = 0;
	for(auto z: mp){
		if(zn <=0) break;
		ll qu = min(z.second, zn);
		if(qu > 0){
			//dbg(z.first, qu, z.second);
			ans -= z.first * qu;
			zn -= qu;
		} 
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 15104
N = int(input())
n, p, score = N, 2, 0
while p ** 2 <= N:
  e = 1
  while n % (p ** e) == 0:
    n //= (p ** e)
    score += 1
    e += 1
  else:
    while n % p == 0:
      n //= p
    p += 2 - (p == 2)
else:
  score += n > 1
print(score)

Measured memory_bytes: 9200
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
void call(int n)
{
    int i = 1;
    int x;
 
    do {
        x = i;
        if (x % 3 == 0) {
            printf(" %d", i);
        }
        else {
            do {
                if (x % 10 == 3) {
                    printf(" %d", i);
                    x = 0;
                }
                else x /= 10;
            } while (x);
        }
    } while (++i <= n);
    putchar('\n');
}
 
#if 1
int main()
{
    int n;
 
    scanf("%d", &n);
    call(n);
    return 0;
}
#endif


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int n, k;

int main(){
	cin >> n >> k;
	
	ll cnt = k;
	for(int i = 1; i < n; i++){
		cnt *= k-1;
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256