akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  // abs() for integer
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;

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

    if (B==1) cout<<0;
    else if (B -A<=0) cout<<1;
    else if ((B-A)%(A-1)==0) cout << (B-A)/(A-1)+1;
    else cout <<(B-A)/(A-1)+2;
        
    
    
}


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

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

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;

  for(int i = 0; i < n; ++i){
    bool bfind = true;
    for(int j = 0; j < n - i; ++j){
      if(s[i+j] != t[j]){
        bfind = false;
        break;
      }
    }
    if(bfind){
      for(int j = n-i; j < n; ++j){
        s += t[j];
      }
      cout << s.size() << endl;
      return 0;
    }
  }
  cout << s.size() + t.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    for ( int i = 1; i <= n; i++ ){
        int x = i;
        if ( x % 3 == 0 ){
            cout << " " << i;
        } else {
            while( x ){
                if ( x % 10 == 3 ){
                    cout << " " << i;
                    break;
                } else if ( x ){
                   x /= 10;
                } else {
                    break;
                }                     
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  vector<int> A;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    A.push_back(a);
  }
  for (int i = 0; i < A.size(); i++)
  {
    if (A.at(i) % 2 == 0)
    {
      if (A.at(i) % 3 != 0 && A.at(i) % 5 != 0)
      {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
/*
In every question first approach must be basic, atleast give 15 mins for try to solve in basic approach
*/
 #include<iostream>
 #include<cstring>
 #include<string>
 #include<vector>
 #include<utility>
 #include<stdlib.h>
 #include<limits.h>
 #include<cmath>
 #include<set>
 #include<initializer_list>
 #include<unordered_set>
 #include<unordered_map>
 #include<map>
 #include<iomanip>
 #include<algorithm>
 #include<queue>
 #include<stack>
  
 #define sze 1000005
 #define ld long double
 #define ull unsigned long long
 #define ll long long
 #define endl "\n"
 #define pb push_back
 #define mkp make_pair
 #define mod 1000000007
 #define ff first
 #define ss second
 #define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
 #define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
 #define all(c) (c).begin(),(c).end()
  
 using namespace std;
 //const ll inf=1ll<<60;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res%mod * a%mod)%mod;
        a = (a%mod * a%mod)%mod;
        b >>= 1;
    }
    return res;
}
//const int N=300005;


 int main()
 {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     
     string s,t; cin>>s>>t;
     int f=0;
     F(i,0,s.length()-1)
     {
         if(s[i]!=t[i])
         {
             f=1;
             cout<<"No"<<endl;
             break;
         }
     }
     if(f==0)
     {
         cout<<"Yes"<<endl;
     }
 }


Measured memory_bytes: 3644
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

int Scc(const vector<vector<int>>& adj, vector<int>& color) {
    const int n = adj.size();
    vector<int> num(n, 0), low(n, 0), sta;
    color.assign(n, 0);
    vector<bool> inS(n, 0);
    int t = 0, colnum = 0;
    function<void(int)> visit = [&](int cur) {
        low[cur] = num[cur] = ++t;
        sta.emplace_back(cur); inS[cur] = 1;
        for(int nxt : adj[cur]) {
            if(num[nxt] == 0) {
                visit(nxt);
                low[cur] = min(low[cur], low[nxt]);
            } else if(inS[nxt])
              low[cur] = min(low[cur], num[nxt]);
        }
        if(low[cur] == num[cur]) {
            while(true) {
                int nxt = sta.back(); sta.pop_back(); inS[nxt] = false;
                color[nxt] = colnum;
                if(cur == nxt) break;
            }
            ++colnum;
        }
    };
    for(int v : in(n))
      if(num[v] == 0)
        visit(v);
    return colnum;
}

using i64 = long long;
const i64 MOD = 1e9 + 7;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<vector<int>> __adj(n);
    for(int _ : in(m)) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        __adj[u].emplace_back(v);
    }
    vector<int> color;
    int col = Scc(__adj, color);
    vector<vector<int>> radj(col);
    vector<int> deg(col, 0);
    for(int v : in(n))
      for(int u : __adj[v])
        if(color[v] != color[u])
          radj[color[u]].emplace_back(color[v]), ++deg[color[v]];
    for(auto& a : radj) {
        sort(a.begin(), a.end());
        a.erase(unique(a.begin(), a.end()), a.end());
    }
    vector<i64> dp(col, -1LL);
    i64 ans = 1LL;
    function<i64(int)> dfs = [&](int v) {
        assert(v != -1);
        i64& res = dp[v];
        if(res != -1LL) return res;
        res = 1LL;
        for(int u : radj[v])
          res = res * dfs(u) % MOD;
        return ++res;
    };
    for(int v : in(col)) {
        if(dp[v] != -1LL || deg[v] != 0) continue;
        ans = ans * dfs(v) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3244
#include <cstdio>
#include <map>
#include <string>
#include <iostream>

using namespace std;
#define mkp make_pair
#define maxn 110
typedef long long ll;
int n, ans;
char str[maxn], a[maxn], b[maxn];
char s[maxn];
map<pair<string, int>, int> mp;
void insert(int num)
{
	string a; a = "";
	for (int i = 1; i <= n; ++i)
		a = a + s[i];
//	cout << a << endl;
	++mp[mkp(a, num)];
}
int query(int num)
{
	string a; a = "";
	for (int i = 1; i <= n; ++i)
		a = a + s[i];
	return mp[mkp(a, num)];
}
int main()
{
	scanf("%d", &n);
	scanf("%s", str);
	for (int i = 0, _ = 1 << n; i < _; ++i)
	{
		int pa = 0, pb = n, num = 0;
		for (int j = 0; j < n; ++j)
			if (i & (1 << j))
				s[++pa] = str[j], ++num;
			else
				s[pb--] = str[j];
		insert(num);
	}
	ll ans = 0;
	for (int i = 0, _ = 1 << n; i < _; ++i)
	{
		int pa = 0, pb = n, num = 0;
		for (int j = n - 1; j >= 0; --j)
			if (i & (1 << j))
				s[pb--] = str[j + n], ++num;
			else
				s[++pa] = str[j + n];
		ans += query(n - num);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 65792
#include<stdio.h>
#define INF 100000000
typedef struct{
  int r;
  int c;
}GYORETSU;

int matrixChainOrder(int *,int);

int main(){
  int i,n,size,p[100];
  GYORETSU M[100];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&M[i].r,&M[i].c);
    p[i-1]=M[i].r;
    p[i]=M[i].c;
  }

  printf("%d\n",matrixChainOrder(p,n));
 
  
  return 0;
}



int matrixChainOrder(int *p,int n){
  int i,j,k,l,q,m[100][100];
 
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(m[i][j]>q){
	  m[i][j]=q;
	}
      }
    }
  }
  return m[1][n];
}



Measured memory_bytes: 2048
package main

import (
	"bufio"
	"fmt"
	"os"
)

func generated_alib_swap(a int, b int) (int, int) {
	return b, a
}
func (u generated_alib_UnionFind) Size(x int) int {
	return -u.par[u.Find(x)]
}
func (u generated_alib_UnionFind) Same(x, y int) bool {
	return u.Find(x) == u.Find(y)
}
func (u generated_alib_UnionFind) Union(x, y int) {
	xr := u.Find(x)
	yr := u.Find(y)
	if xr == yr {
		return
	}
	if u.Size(yr) < u.Size(xr) {
		yr, xr = generated_alib_swap(yr, xr)
	}
	u.par[yr] += u.par[xr]
	u.par[xr] = yr
}
func (u generated_alib_UnionFind) Find(x int) int {
	if u.par[x] < 0 {
		return x
	}
	u.par[x] = u.Find(u.par[x])
	return u.par[x]
}
func generated_alib_NewUnionFind(N int) *generated_alib_UnionFind {
	u := new(generated_alib_UnionFind)
	u.par = make([]int, N)
	for i := range u.par {
		u.par[i] = -1
	}
	return u
}

type generated_alib_UnionFind struct{ par []int }

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var n, m int
	fmt.Fscan(r, &n, &m)
	uf := generated_alib_NewUnionFind(n)
	for i := 0; i < m; i++ {
		var t, a, b int
		fmt.Fscan(r, &t, &a, &b)
		if t == 0 {
			uf.Union(a, b)
		} else {
			if uf.Same(a, b) {
				fmt.Fprintln(w, 1)
			} else {
				fmt.Fprintln(w, 0)
			}
		}
	}
}
/* this code was generated by the code below
package main

import (
	"bufio"
	"fmt"
	"os"

	alib "a/lib"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n, m int
	fmt.Fscan(r, &n, &m)
	uf := alib.NewUnionFind(n)

	for i := 0; i < m; i++ {
		var t, a, b int
		fmt.Fscan(r, &t, &a, &b)

    if t == 0 {
      uf.Union(a, b)
    } else {
      if uf.Same(a, b) {
        fmt.Fprintln(w, 1)
      } else {
        fmt.Fprintln(w, 0)
      }
    }
	}
}

*/


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int h,w;
    cin >>h >>w;
    string s[26][26];
    rep(i,h)rep(j,w) cin >>s[i][j];

    rep(i,h)rep(j,w)
    {
        if(s[i][j]=="snuke")
        {
            printf("%c%d\n", j+'A',i+1);
            break;
        }
    }

    return 0;
}


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

#define ln "\n"
#define SORT(X) sort(X.begin(), X.end())
#define SORTi(X) sort(X.begin(), X.end(), greater<ll>())
#define REP(x, a, b) for (auto x = a; x <= b; x++)
#define REPi(x, b, a) for (auto x = b; x >= a; x--)
#define REPit(x, A) for (auto x = A.begin(); x != A.end(); x++)
#define REPr(x, A) for (auto x : A)
#define ll long long
#define ull unsigned long long
#define PB push_back
#define EB emplace_back
#define UMP unordered_map
#define UST unordered_set

using namespace std;

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

    int A, B, C;
    cin>>A>>B>>C;
    if (C >= A && C <= B)
        cout << "Yes" << ln;
    else
        cout << "No" << ln;
    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 200001;
const int MOD = 1000000007;

        signed main() {
        int a,b,c;
        cin>>a>>b>>c;
        if(a+b>=c)cout<<"Yes";
        else cout<<"No";
      

        
        
        


      }


        


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

int64_t getVal(int64_t d){
  int64_t ans = 1;
  for(int i=1;i<d;i++){
    ans *= 10;
  }
  return ans;
}



signed main() {
  int x,y;
  cin >> x >> y;
  //n+2m=X,2n+m=Y
  // 2n+4m=2x
  // 2n+m=y
  // m = (2x-y)/3
  // n+2m=x
  // 4n+2m=2y
  // n = (2y-x)/3
  
  if( (x+y)%3 != 0){
    cout << "0" << endl;
    return 0;
  }
  int m = (2*x-y)/3;
  int n = (2*y-x)/3;
  if(m<0||n<0){
    cout << "0" << endl;
    return 0;
  }
  const int64_t MOD = 1000000007;
  int64_t ans = 1;
  int a = m+n;
  int b = n;
  for(int i=0;i<n;i++){
    ans *= (a-i);
    ans %= MOD;
    ans *= modinv(b-i, MOD);
    ans %= MOD;
  }
  
  cout << ans%MOD << endl;
  return 0;
  
}




Measured memory_bytes: 3656
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
typedef long long ll;
int n,temp;
ll a[1000009],b[1000009];
ll ans=0;
bool check(ll sum,ll k)
{
  temp=1;
  for (int i=n;i>=1;i--)
  {
    if (a[temp]*b[i]<=sum) {temp++;continue;}
    if ((a[temp]-sum/b[i])>k) return false;
    k-=a[temp]-sum/b[i];
    temp++;
  }
  return true;
}
int main()
{
  ll k;
  scanf("%d%lld",&n,&k);
  for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
  for (int i=1;i<=n;i++) scanf("%lld",&b[i]);
  sort(a+1,a+1+n); sort(b+1,b+1+n);
  ll l=0,r=0;
  r=b[n]*a[n];ans=r;
  while (l<=r)
  {
      ll mid=(l+r)/(ll)2;
      if (check(mid,k)) ans=mid,r=mid-1;
      else l=mid+1;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 5888
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>

using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))
#define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ?	true : false)
map<string, int> roma_time = { { "I",1 },{ "II",2 },{ "III",3 },{ "IIII",4 },{ "V",5 },{ "VI",6 },{ "VII",7 },{ "VIII",8 },{ "IX",9 },{ "X",10 },{ "XI",11 },{ "XII",12 } };

typedef vector<int> Ivec;
typedef pair<int, int> pii;

int main() {
	int n;
	while (scanf("%d", &n)) {
		if (n == 0)
			return 0;
		char step[3];
		int cou = 0;
		bool l = 0, r = 0, stat = 0;
		for (int i = 0; n > i; i++) {
			scanf("%s", step);
			if (step[0] == 'r') {
				r = 1 - r;
			}
			else if (step[0] == 'l') {
				l = 1 - l;
			}
			if (l == r && stat != l) {
				cou++;
				stat = l;
			}
		}
		printf("%d\n", cou);
	}
	
	return 0;
}

Measured memory_bytes: 3292
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		int A[][] = new int[n][m];
		int B[][] = new int[m][l];
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < m ; j++){
				A[i][j] = scan.nextInt();
			}
		}
		for(int i = 0 ; i < m ; i++){
			for(int j = 0 ; j < l ; j++){
				B[i][j] = scan.nextInt();
			}
		}
		long output[][] = new long[n][l];

		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < m ; j++){
				for(int k = 0 ; k < l ; k++){
					output[i][k] += A[i][j]*B[j][k];
				}
			}
		}

		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < l-1 ; j++){
				System.out.print(output[i][j]+" ");
			}
			System.out.println(output[i][l-1]);
		}
	}
}

Measured memory_bytes: 53644
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    if (n == 0L) {
        println(0)
        return
    }
    var base = 2L
    var plusFlg = if (n > 0) 1L else -1L
    var rest = n
    val result = mutableListOf<Int>()

    while (rest != 0L) {
        if (rest % base != 0L) {
            rest -= (rest % base) * plusFlg
            result.add(1)

        } else {
            result.add(0)
        }
        plusFlg *= -1L
        base *= -2
    }
    result.reversed().forEach { print(it) }
    println()
}

Measured memory_bytes: 33652
input = input()
num = 0
max = 0
for j in range(len(input)):
    i = input[j]
    if i == "A" or i == "T" or i == "C" or i == "G":
        num += 1
        max = num if num > max else max
    else: 
        num = 0
print(max)

Measured memory_bytes: 3060
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  H,W,K = readint()
  S = Vector{String}(undef,H)
  C = Array{int,2}(undef,W,H)
  C .= 0
  for i in 1:H
    s = readline()
    for j in 1:W
      if s[j]=='#'
        C[j,i] = 1
      end
    end
  end
  #println(C)
  D = copy(C)

  cout = 0
  for i in 0:2^H-1, j in 0:2^W-1
    D .= C
    for k in 1:H
      if i >> (k-1) & 1 == 1
        D[:,k] .= 0
      end
      for l in 1:W
        if j >> (l-1) & 1 == 1
          D[l,:] .= 0
        end
      end
    end
    if sum(D) == K
      cout += 1
    end
  end
 
        
  
  println(cout)
  #println(S)

end

main()

Measured memory_bytes: 239840
import numpy as np
N,M=map(int,input().split())
A=np.zeros((N+1,M+1))
A[0]=np.ones(M+1)
for i in range(1,N+1):
    B=list(map(int,input().split()))
    for m in range(1,B[0]+1):
        A[i][B[m]]=A[i-1][B[m]]
a=sum(A[N])
print(int(a))

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

string str;
string ans[6];

char c[6] = {'U','F','R','D','B','L'};

int v[6][48] = {{
     0,  1, 10,  2,  4,  5,  6,  7,
     8,  9, 11,  3, 12, 13, 14, 15,
    18, 19, 20, 21, 22, 23, 16, 17,
    24, 25, 26, 27, 28, 29, 30, 31,
    32, 33, 34, 35, 36, 37, 38, 39,
    40, 41, 42, 43, 44, 45, 46, 47
  },{
     0,  1,  2,  3,  4,  5,  6,  7,
     8,  9, 25, 17, 12, 13, 14, 15,
    16, 34, 26, 18, 10, 21, 22, 23,
    24, 35, 27, 19, 11, 29, 30, 31,
    32, 33, 28, 20, 36, 37, 38, 39,
    40, 41, 42, 43, 44, 45, 46, 47
  },{
     0,  1,  2, 19,  4,  5,  6,  7,
     8,  9, 10, 27, 12, 13, 14, 15,
    16, 17, 18, 35, 28, 20, 11, 23,
    24, 25, 26, 43, 29, 21,  3, 31,
    32, 33, 34, 30, 36, 37, 38, 39,
    40, 41, 42, 22, 44, 45, 46, 47
  },{
     0,  1,  2,  3,  4,  5,  6,  7,
     8,  9, 10, 11, 12, 13, 14, 15,
    16, 17, 18, 19, 20, 21, 22, 23,
    30, 31, 24, 25, 26, 27, 28, 29,
    32, 33, 42, 34, 36, 37, 38, 39,
    40, 41, 43, 35, 44, 45, 46, 47
  },{
     0,  1, 21, 29,  4,  5,  6,  7,
     8,  9, 10, 11, 12, 13, 14, 15,
     3, 17, 18, 19, 20, 43, 30, 22,
     2, 25, 26, 27, 28, 42, 31, 23,
    32, 33, 34, 35, 36, 37, 38, 39,
    40, 41, 16, 24, 44, 45, 46, 47
  },{
     0,  1, 31,  3,  4,  5,  6,  7,
     8,  9, 23, 11, 12, 13, 14, 15,
    24, 16,  2, 19, 20, 21, 22, 42,
    25, 17, 10, 27, 28, 29, 30, 34,
    32, 33, 18, 35, 36, 37, 38, 39,
    40, 41, 26, 43, 44, 45, 46, 47
  }
};

void solve(){
  for(int i=0;i<str.size();i++){
    for(int j=0;j<6;j++){
      if(str[i] == c[j]){
        int tmp[6][8];
        for(int k=0;k<48;k++) tmp[k/8][k%8] = ans[v[j][k]/8][v[j][k]%8];
        for(int k=0;k<48;k++) ans[k/8][k%8] = tmp[k/8][k%8];
        break;
      }
    }
  }
}

int main(){
  while(cin >> str){
    for(int i=0;i<2;i++) ans[i] = "..rr....";
    for(int i=2;i<4;i++) ans[i] = "ggyybbww";
    for(int i=4;i<6;i++) ans[i] = "..oo....";
    solve();
    for(int i=0;i<6;i++) cout << ans[i] << endl;
  }
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n;
  cin >> n;
  ll sum = 0;
  for(int i = 1; i <= n; ++i) {
    if(i % 3 == 0 || i % 5 == 0) continue;
    else sum+=i;
  }
  cout << sum<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int K, N;
	cin >> K >> N;

	if (K % 2) {
		ll A[300001] = {};
		A[0] = 1;
		ll S[300001] = {};
		S[0] = A[0] * (K / 2) + 1;
		int doko;
		rep(i, N) {
			if (S[i] >= N / 2) {
				doko = i;
				break;
			}
			A[i + 1] = (A[i] * K) + 1;
			S[i + 1] = S[i] + A[i + 1] * (K / 2) + 1;
		}
		ll kazu = S[doko] - N / 2;
		
		vector<int> kotae;
		for (int i = N - 1; i >= 0; i--) {
			if (i > doko) kotae.pb((K + 1) / 2);
			else {
				if (kazu == 0) break;
				else {
					kazu--;
					ll kari = kazu / A[i];
					if (kari > K - 1) kari = K - 1;
					kazu -= kari * A[i];
					kotae.pb(kari + 1);
				}
			}
		}
		for (auto itr = kotae.begin(); itr < --kotae.end(); itr++) {
			cosp(*itr);
		}
		co(kotae.back());

	}
	else {
		if (N > 1) {
			cosp(K / 2);
			rep(i, N - 2) cosp(K);
			co(K);
		}
		else co(K / 2);
	}

	Would you please return 0;
}

Measured memory_bytes: 8304
#include <iostream>
using namespace std;
int main()
{
  int t;
  int h,m,s;
  cin >> t;
  s = t % 60;
  int r = (t - s) / 60;
  m = r % 60;
  r = (r - m) / 60;
  cout << r << ":" << m << ":" << s << endl;
  return 0;
}

Measured memory_bytes: 1164
from collections import defaultdict
n, t = [int(x) for x in input().split()]
a_list = [int(x) for x in input().split()]
d = defaultdict(int)
a_min = a_list[0]
p_max = 0
for i in range(1, n):
    if a_list[i] < a_min:
        a_min = a_list[i]
        continue
    p = a_list[i] - a_min
    if p >= p_max:
        d[p] += 1
        p_max = p
print(d[p_max])

Measured memory_bytes: 24544
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int n,x=0,y=0,ans=100000,c=0;
  cin>>n;
  double a[n];
  double b=0;
  rep(i,0,n){
    cin>>a[i];
    b+=1/a[i];
  }
  cout<<fixed<<setprecision(9);
  co(1/b);
  
  return 0;
}

Measured memory_bytes: 384
//
// Created by kapildd on 10/4/17.
//

#include <bits/stdc++.h>
using namespace std;

int main() {
    int a, b, c, d, e, f;
    cin>>a>>b>>c>>d>>e>>f;
    map<int, int> water_poss, sugar_poss;
    for(int i=0; i<=f; i++) {
        if(i*100*a > f) break;
        for(int j=0; j<=f; j++) {
            if(i*100*a+j*100*b > f) break;
            water_poss[i*100*a+j*100*b] = 1;
        }
    }
    for(int i=0; i<=f; i++) {
        if(i*c > f) break;
        for(int j=0; j<=f; j++) {
            if(i*c+j*d > f) break;
            sugar_poss[i*c+j*d] = 1;
        }
    }
    int best_sugar , best_water;
    double best_density = -1;
    for(map<int, int>::iterator it1 = water_poss.begin(); it1!=water_poss.end(); it1++) {
        for(map<int, int>::iterator it2 = sugar_poss.begin(); it2!=sugar_poss.end(); it2++) {
            int sugar = it2->first, water = it1->first;
            if((sugar+water<=f) && ((water/100.0) * e >= sugar)) {
                if(best_density < (100.0*sugar)/(sugar+water)) {
                    best_density = (100.0*sugar)/(sugar+water);
                    best_sugar = sugar;
                    best_water = water;
                }
            }
        }
    }
    cout << best_water+best_sugar << " " << best_sugar << endl;
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e3 + 5);
const int MAX_SIZE = (int)(MAX_N * MAX_N);

/////////////////////////////////////////////////////////////
// node in { 0, ... }
class TopologicalSort {
  using ts_graph = vector<vector<int>>;

 public:
  static const int MAX_N = (int)(8e5 + 100);

  int n;
  ts_graph graph;
  vector<int> topological_sorted;
  vector<int> flg;  // 0: not-visited, 1: done, -1, temporary

  bool no_loop;

  TopologicalSort(ts_graph graph, int n) {
    this->flg = vector<int>(n, 0);
    this->graph = graph;
    this->n = n;
    init();
  }

  void init() {
    topological_sort();
  }

  bool visit(int i) {
    if (flg[i] == -1) {
      return false;
    }

    if (flg[i] == 0) {
      flg[i] = -1;

      for (auto &e : graph[i]) {
        if (!visit(e)) {
          return false;
        }
      }

      flg[i] = 1;

      topological_sorted.push_back(i);

      return true;
    }

    return true;
  }

  void topological_sort() {
    for (int i = 0; i < n; ++i) {
      flg[i] = 0;
    }

    for (int i = 0; i < n; ++i) {
      if (flg[i] == 0) {
        if (!visit(i)) {
          no_loop = false;
          return;
        }
      }
    }

    reverse(topological_sorted.begin(), topological_sorted.end());

    no_loop = true;
    return;
  }

  bool contains_loop() {
    return !no_loop;
  }

  vector<int> &get_sorted() {
    return topological_sorted;
  }
};
/////////////////////////////////////////////////////////////

int n;

int tmp[MAX_N];
vector<vector<int>> graph(MAX_SIZE);
map<int, int> memo;

int make_key(int a, int b) {
  return min(a, b) * n + max(a, b);
}

int depth(int cur) {
  if (memo.find(cur) != memo.end()) return memo[cur];

  if (graph[cur].size() == 0) {
    return memo[cur] = 1;
  }

  int ret = -1;

  for (auto &e : graph[cur]) {
    ret = max(ret, depth(e));
  }

  ret += 1;

  return memo[cur] = ret;
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= n - 1; ++j) {
      scanf("%d", &(tmp[j]));
      tmp[j] -= 1;
    }

    int last = make_key(i, tmp[1]);

    for (int j = 2; j <= n - 1; ++j) {
      int cur = make_key(i, tmp[j]);
      graph[last].push_back(cur);
      last = cur;
    }
  }

  TopologicalSort ts(graph, MAX_SIZE);

  if (ts.contains_loop()) {
    printf("-1\n");
    return 0;
  }

  int ans = -1;

  for (int i = 0; i < MAX_SIZE; ++i) {
    ans = max(ans, depth(i));
  }

  printf("%d\n", ans);

  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  string a, b;
  cin >> a >> b;
  ll v = stoll(a + b);

  REP(i, 1000) {
    if (i * i == v) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
  int N, h[100], count = 0, k;
  cin >> N;
  for(int i = 0; i<N; i++){
    cin >> h[i];
  }
  
  for(int j = 0; j<N; j++){
    while(h[j] > 0){
      count++;
      k = j;
      while(h[k] > 0 && k < N){
        h[k]--;
        k++;
      }
    }  
  }
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
using namespace std;
lo int n,a,b;
int main(){
	scanf("%lld %lld %lld",&n,&a,&b);
	if(a>b || (n==1 && a!=b)){
		printf("0\n");
		return 0;
	}
	if(n==1){
		printf("1\n");
		return 0;
	}
	n-=2;
	lo int gg1=n*b-n*a+1;
	printf("%lld\n",gg1);
	return 0;
}


Measured memory_bytes: 256
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

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


Measured memory_bytes: 3636
#include<iostream>

using namespace std;

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

  unsigned int N;
  cin >> N;

  unsigned int S = 0;
  unsigned int buf = N;
  while(buf != 0) {
    S += buf % 10;
    buf /= 10;
  }

  if (N % S == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

int main(){
        int i;
        cin >> i;
        int num[i];
        int max ,min;
        long long sum;
        sum = 0;
        for(int k =0;k < i; k++){
                cin >> num[k];
                sum += num[k];
        }
        max = min = num[0];
        for(int j = 1;j < i; j++){
                if(max < num[j]) max = num[j];
                if(min > num[j]) min = num[j];
        }
        cout << min <<" " << max << " " << sum << endl;

        return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size()+1;
    vector<ll> v(n);
    for(int i=0; i<n-1; i++){
        if(s.at(i) == '<'){
            v.at(i+1) = v.at(i)+1;
        }
    }
    for(int i=n-2; i>=0; i--){
        if(s.at(i) == '>'){
            v.at(i) = max(v.at(i),v.at(i+1)+1);
        }
    }
    ll ans = 0;
    for(auto x : v){
        ans += x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4740
#include <cstdio>
#include <math.h>
#include <utility>

using namespace std;

int main ()
{
  int n, m;
  int b[100];
  int c[100];

  scanf("%d %d", &n, &m);
  int A[100][100];


  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &A[i][j]);
    }
  }

  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }

  for (int i = 0; i < n; i++) {
    c[i] = 0;
    for (int j = 0; j < m; j++) {
      c[i] += A[i][j] * b[j];
    }
  }

  for (int i = 0; i < n; i++) {
    printf("%d\n", c[i]);
  }

  return 0;
}

Measured memory_bytes: 2760
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		boolean[] tri = new boolean[1000001];
		for (int i = 1; i * (i + 1) / 2 <= 100000; i++) {
			int a = i * (i + 1) / 2;
			tri[a] = true;
		}
		loop: while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int sum = 0;
			List<Integer> list = new ArrayList<Integer>(1000000);
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				list.add(a);
				sum += a;
			}
			if (tri[sum]) {
				int res = 0;
				while (res <= 10000) {
					if (slove(list)) {
						System.out.println(res);
						continue loop;
					}
					int size = list.size();
					for (ListIterator<Integer> it = list.listIterator(); it
							.hasNext();) {
						int a = it.next();
						if (a == 1)
							it.remove();
						else
							it.set(a - 1);

					}
					list.add(size);

					res++;
				}
			}
			System.out.println(-1);
		}
	}

	private boolean slove(List<Integer> list) {
		for (int i = 0; i < list.size(); i++)
			if (i + 1 != list.get(i))
				return false;
		return true;
	}
}

Measured memory_bytes: 66696
#include <iostream>
#include <cstdio>
         
int main() {
    int h, w = 0;
    while(true) {
        std::cin >> h >> w;
        if(!h && !w) break;
         
        for(int i = 0; i < h; i++) {        
            for(int j = 0; j < w; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }    
    return 0;
}

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

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n, T, t;
  cin >> n >> T >> t;
  int ans = 0;
  int abriu_em = t;
  int fecha_em = t+T;
  while (cin >> t) {
    if (t <= fecha_em)
      fecha_em = t+T;
    else { //vai fechar em algum momento
      ans += fecha_em - abriu_em;
      abriu_em = t;
      fecha_em = t + T; 
    }
  }
  ans += fecha_em - abriu_em;
  cout << ans << ende;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int n=s.size();
  vector<long> vec(2020,0);
  int sum=0;
  long ans=0;
  vec[0]++;
  int Pow=1;
  for(int i=n-1;i>-1;i--){
    sum=(sum+(s[i]-'0')*Pow)%2019;
    vec[sum]++;
    Pow=(10*Pow)%2019;
  }
  for(int i=0;i<2019;i++) ans+=vec[i]*(vec[i]-1)/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 3652
n=int(input())
li=[]
for i in range(n):
    s=input()
    li.append(s)

ac=0
wa=0
tle=0
re=0
for i in li:
    if i=="AC":
        ac+=1
    elif i =="TLE":
        tle+=1
    elif i=="WA":
        wa+=1
    else:
        re+=1
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

Measured memory_bytes: 16324
N = int(input().strip())
M = pow(10, 9) + 7
a = 1
g = 1
ag = 0
agg = 0
agt = 0
atg = 0
ac = 0
at = 0
aa = 0
ga = 0

al = 4
nal = 0

for i in range(N-1):
    nal = (al * 4) % M
    nal = (nal + M - (ag + ac + ga + agg + agt + atg) ) % M

    agg = ag
    agt = ag
    atg = at
    ag = a
    aa = a
    at = a
    nac = (a + M- ga) % M
    ga = g
    a = al
    g = (al + M - ac) % M
    ac = nac
    al = nal
print(al)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {    long long t = a / b;    a -= t * b; swap(a, b);    u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
//MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}
 
int main(){
    string S,T;cin >> S >> T;
    int len = S.length();
    map<char,char> ma;
    map<char,char> m;
    rep(i,len){
        if(ma.find(T[i])== ma.end()){
            ma[T[i]] = S[i];
        }else{
            if(ma[T[i]] != S[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    rep(i,len){
        if(m.find(S[i])== m.end()){
            m[S[i]] = T[i];
        }else{
            if(m[S[i]] != T[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3904
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin >> n >> k;
	long long int arr[n];
	int i,j;
	for(i=0;i<n;i++)
	cin >> arr[i];
    long long int dp[n]={0};
	long long int temp;
    for(i=1;i<n;i++)
    {
    	temp=10000000000;
    	for(j=max(0,i-k);j<i;j++)
    	temp=min(dp[j]+abs(arr[i]-arr[j]),temp);
    	dp[i]=temp;
	}
    cout << dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
//#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(false);cin.tie();cout.tie();
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
ll DP[105][5],S[105][5];
int main()
{
    speed
    string napis;
    cin>>napis;
    reverse(napis.begin(),napis.end());
    int n=napis.size();
    napis='#'+napis;
    int k;
    cin>>k;
    S[0][0]=1;
    DP[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        int a=napis[i]-'0';
        for(int j=0;j<=k;j++)
        {
            S[i][j]=S[i-1][j];
            if(j!=0)
                S[i][j]+=(ll)9*S[i-1][j-1];
            if(a!=0)
            DP[i][j]=S[i-1][j];
            else
                DP[i][j]=DP[i-1][j];
            if(j!=0)
            {
                if(a!=0)
                    DP[i][j]+=(ll)(a-1)*S[i-1][j-1]+DP[i-1][j-1];
            }

      //  cout<<i<<" "<<j<<" "<<DP[i][j]<<" "<<S[i][j]<<endl;
        }
    }
    cout<<DP[n][k];
    return 0;
}


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

int main(void){
    int N, L;
    cin >> N >> L;
    vector<string> word(N);
    for(int i = 0; i < N; i++){
        cin >> word[i];
    }
    sort(word.begin(), word.end());
    for(int i = 0; i < N; i++){
        cout << word[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
main(){
  int a,b,c;
  scanf("%d%d%d\n",&a,&b,&c);
  if(a<b){
    if(b<c){
      printf("%d %d %d\n",a,b,c);
    }else if(a<c){
      printf("%d %d %d\n",a,c,b);
    }else{
      printf("%d %d %d\n",c,a,b);
    }
  }else{
    if(a<c){
      printf("%d %d %d\n",b,a,c);
    }else if(b<c){
      printf("%d %d %d\n",b,c,a);
    }else{
      printf("%d %d %d\n",c,b,a);
    }
  }
}

Measured memory_bytes: 1028
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    if(A==1&&B==2||B==1&&A==2)
        printf("%d\n",A+B);
    else if(A==3&&B==1)
        printf("%d\n",A-B);
  else if(B==3&&A==1)
        printf("%d\n",B-A);
  else if(A==2&&B==3)
        printf("%d\n",B-A);
  else if(A==3&&B==2)
        printf("%d\n",A-B);
        else
        printf("do not print\n");
    return 0;

}



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

int main(){
    long long int a,b,k;
    cin >> a >> b >> k;
    if(k > a){
        cout << 0 << " ";
        if(a-k+b < 0){
            cout << 0 << endl;
        }else{
            cout << a-k+b << endl;
        }
    }else{
        cout << a-k << " " << b << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main(){
    int n;
    cin >> n;
    map<string,int>mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << mp.size() <<endl;
    return 0;
}


Measured memory_bytes: 19128
#include <stdio.h>
 
int main() {
 
int al[30] = {0};
char b[2000]= {0};
int i,j,n;
 
i=0;
 
while( scanf("%c",&b[i]) != EOF) {
 
if (b[i] >= 'A' && 'Z' >= b[i] ) {
n = b[i] - 'A';
al[n] += 1;
 
} else if(b[i] >=  'a' && b[i] <= 'z' ) {
n = b[i] - 'a';
al[n] += 1;
}
i=i+1;
}
 
for(j=97; j<=122; j++) {
n = j - 'a';
printf("%c : %d\n",j,al[n]);
}
 
return 0;
 
}


Measured memory_bytes: 2764
# D - Div Game
from collections import defaultdict
from math import sqrt
from typing import Dict


def prime_factorize_naive(n: int) -> Dict[int, int]:
    """Prime factorization of n (trial division)."""
    if n < 1:
        raise ValueError

    prime_factors = defaultdict(int)
    while n % 2 == 0:
        n //= 2
        prime_factors[2] += 1

    for i in range(3, int(sqrt(n)) + 1, 2):
        while n % i == 0:
            n //= i
            prime_factors[i] += 1
        if n == 1:
            break

    if n > 2:  # n is prime
        prime_factors[n] += 1

    return prime_factors


def main():
    N = int(input())
    calc = lambda n: int((sqrt(8 * n + 1) - 1) / 2)
    print(sum(calc(e) for e in prime_factorize_naive(N).values()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 10192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)


int main() {
  string s;
  int n,q; cin >> n >> s >> q;
  vector<int> A(n);
  loop(i,0,n) A[i] = s[i] - 'a';
  set<int> S[26];
  loop(i,0,n) {
    S[A[i]].insert(i);
  }
  loop(i,0,q) {
    int t, l, r, x;
    char c;
    cin >> t;
    if (t == 1) {
      cin >> x >> c;
      x--;
      int y = c - 'a';
      int a = A[x];
      A[x] = y;
      S[a].erase(x);
      S[y].insert(x);
    } else {
      cin >> l >> r; l--;r--;
      int ans = 0;
      loop(j,0,26) {
        auto it = S[j].lower_bound(l);
        if (it == S[j].end()) continue;
        ans += *it <= r;
      }
      cout << ans << endl;
    }
  }
  return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n+1);
  rep(i,n+1) cin>>a[i];
  vll b(n);
  rep(i,n) cin>>b[i];
  
  ll ans=0;
  rrep(i,n){
    ll tmp;
    if(a[i+1]>0){
      tmp=a[i+1];
      a[i+1]-=b[i];
      if(a[i+1]>0){
        ans+=b[i];
        continue;
      }
      ans+=tmp;
      b[i]-=tmp;
    }
    
    tmp=a[i];
    a[i]-=b[i];
    if(a[i]<=0) ans+=tmp;
    else ans+=b[i];
    // cout<<ans<<endl;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
#define par pair<pair<int,int>, int>
#define f first
#define s second
    
int x,n,a[105],w[105],c, mn=oo;

int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++) scanf("%d",a+i);
    for(int i=1; i<=n; i++) w[i] = a[i] + w[i-1];
    for(int i=1; i<n ;i++) mn = min(mn, abs(w[n] - w[i] - w[i]));
    printf("%d",mn);
    return 0;
}

Measured memory_bytes: 256