akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};

struct UnionFind{
    vl par;
    UnionFind(ll N) : par(N){
        for(int i = 0; i < N; i++) par[i] = i;
    }
    
    ll root(ll x){
        if(par[x] == x) return x;
        else{
            par[x] = root(par[x]);
            return par[x];
        }
    }
    
    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
    }
    
    bool same(ll x, ll y){
        return root(x) == root(y);
    }
};
    
int main(){
    ll N, M; cin >> N >> M;
    vl as(M, 0), bs(M, 0);
    REP(i, M){
        ll a, b; cin >> a >> b;
        as[i] = a - 1;
        bs[i] = b - 1;
    }
    
    ll ret = 0;
    REP(i, M){
        auto uf = UnionFind(N);
        REP(j, M){
            if(j != i){
                uf.unite(as[j], bs[j]);
            }
        }
        bool ok = true;
        REP(j, N){
            if (!uf.same(0, j)) {
                ok = false; break;
            }
        }
        if(!ok) ret++;
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;


int ar[N];
int main() {
    fast;

    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> ar[i];

    unordered_map<int, int> M;
    for(int i = 0; i < n; i++) M[ar[i]]++;


    int maxE = *max_element(ar, ar + n);
    for(int i = 0; i < n; i++) {
        for(int j = 2 * ar[i]; j <= maxE; j += ar[i]) {
            if(M.find(j) != M.end())
                M[j]++;
        }
    }
    // cout << M.size() << "\n";

    int cnt = 0;
    for(int i = 0; i < n; i++) {
        if(M[ ar[i] ] == 1) cnt++;
    }

    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 12120
import java.util.Scanner;

object Main extends App {

  def sub(a: Int, b: Int, mx: Int): Int = {
    (1 to 6).map { n =>
      sub2(a, b, mx, n);
    }.sum;
  }

  def sub2(a: Int, b: Int, mx: Int, n: Int): Int = {
    if (n == 1) {
      if (a == b) {
        if (a <= mx) {
          1;
        } else {
          0;
        }
      } else {
        0;
      }
    } else if (n == 2) {
      if (a * 10 + b <= mx) {
        1;
      } else {
        0;
      }
    } else {
      val t1 = (1 until (n-1)).foldLeft(1)((s1, s2) => s1 * 10);
      if (t1 * 10 * (a + 1) <= mx) {
        t1;
      } else {
        val c = (mx / t1 - a * 10) min 9;
        (0 to c).map { i =>
          sub2(a * 10 + i, b, mx, n - 1);
        }.sum;
      }
    }
  }

  val sc = new Scanner(System.in);
  val mx = sc.nextInt();

  val count1 = (1 to 9).map { i =>
    ((i+1) to 9).map { j =>
      sub(i, j, mx) * sub(j, i, mx);
    }.sum;
  }.sum;
  val count2 = (1 to 9).map { i =>
    val s = sub(i, i, mx);
    s * s;
  }.sum;
  val answer = count1 * 2 + count2;
  println(answer);
}

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

int main() {
    int n;cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    for (int i = 0; i < n; ++i) cin >> s[i] >> t[i];
    string x; cin >> x;
    int ans = 0;
    bool ok = false;
    for (int i = 0; i < n; ++i) {
        if (ok) ans += t[i];
        if (s[i] == x) ok = true;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll a,b;cin>>a>>b;
	ll cnt=(b-a)/2,ans;
	if(a%2==0){
		if(b%2==1){
			cnt++;
			if(cnt%2==0) ans=0;
			else ans=1;
		}
		else{
			ans=b;
			if(cnt%2==1) ans^=1;
		}
	}
	else{
		if(b%2==1){
			ans=a;
			if(cnt%2==1) ans=ans^1;
		}
		else{
			ans=a^b;
			if(cnt%2==1) ans^=1;
		}
	}

	cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

    int n, k, i, j=0, c_seg=1, c_seq=0, f01=-1, ans=0, max_ans=0;
    scanf("%d %d", &n, &k);

    char s[n];
    scanf("%s", s);
    // printf("%s\n", s);

    for(i=0; i<n; i++) {
        if(s[i]=='0') {
            if(f01==1) {
                c_seg += 1;
            }

            f01 = 0;

        } else {
            if(f01==0) {
                c_seg +=1;
            }

            f01 = 1;

        }
    }

    // printf("%d\n", c_seg);

    int a[c_seg][2];
    f01 = -1;

    for(i=0; i<n; i++) {
        if(s[i]=='0') {
            if(f01==1) {
                a[j][0] = c_seq;
                a[j][1] = 1;
                j += 1;
                c_seq = 0;
            }

            f01 = 0;
            c_seq += 1;

        } else {
            if(f01==0) {
                a[j][0] = c_seq;
                a[j][1] = 0;
                j += 1;
                c_seq = 0;
            }

            f01 = 1;
            c_seq += 1;

        }
    }
    a[j][0] = c_seq;
    if(f01==0) {
        a[j][1] = 0;
    } else {
        a[j][1] = 1;
    }

    // for(i=0; i<c_seg; i++) {
    //     printf("%d", a[i][0]);
    //     printf("%d", a[i][1]);
    // }
    // printf("\n");

    if(a[0][1]==0) {
        for(j=0; j<2*k; j++) {
            if(c_seg<=j) {
                break;
            }
            max_ans += a[j][0];
        }

        for(i=1; i<c_seg/2+1-k+1; i++) {
            for(j=0; j<2*k+1; j++) {
                if(j+i*2-1 >= c_seg) {
                    break;
                }
                ans += a[j+i*2-1][0];
            }
            if(ans > max_ans) {
                max_ans = ans;
            }
            ans = 0;
        }
    } else if(c_seg==1 && a[0][1]==1) {
        max_ans = a[0][0];
    } else {
        for(i=0; i<c_seg/2-k+1; i++) {
            for(j=0; j<2*k+1; j++) {
                if(j+i*2 >= c_seg) {
                    break;
                }
                ans += a[j+i*2][0];
            }
            if(ans > max_ans) {
                max_ans = ans;
            }
            ans = 0;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

#define N 36

int main(){
  int n,i,j,t,min;
  char ac1[N],ac2[N],tc;
  int a1[N],a2[N];

  //input
  scanf("%d\n",&n);
  for(i=0; i<n; i++){
    scanf("%c%d ",&ac2[i],&a2[i]);
  }

  for(i=0; i<n; i++){
    a1[i]=a2[i];
    ac1[i]=ac2[i];
  }
  
  //bubble
  for(i=0; i<n-1; i++){
    for(j=n-1; j>i; j--){
      if(a1[j]<a1[j-1]){
	 t=a1[j];  a1[j]=a1[j-1];  a1[j-1]=t;
	tc=ac1[j];ac1[j]=ac1[j-1];ac1[j-1]=tc;
      }
    }
  }
  for(i=0; i<n-1; i++){
    printf("%c%d ",ac1[i],a1[i]);
  }
  printf("%c%d\n",ac1[i],a1[i]);
  printf("Stable\n");

  //selection
  for(i=0; i<n-1; i++){
    min=i;
    for(j=i+1; j<n; j++){
      if(a2[j]<a2[min]) min=j;
    }
    if(i!=min){
       t=a2[i];  a2[i]=a2[min];  a2[min]=t;
      tc=ac2[i];ac2[i]=ac2[min];ac2[min]=tc;
    }
  }
  for(i=0; i<n-1; i++){
    printf("%c%d ",ac2[i],a2[i]);
  }
  printf("%c%d\n",ac2[i],a2[i]);
  //check
  t=0;
  for(i=0; i<n; i++){
    if(ac1[i]!=ac2[i]){
      t=1;
      break;
    }
  }
  if(t==0) printf("Stable\n");
  else printf("Not stable\n");
  return 0;
}



Measured memory_bytes: 2144
#include <stdio.h>

int main(void)
{
    int x[5], i, count;

    for (i = 0; i < 5; i++)
    {
        scanf("%d", &x[i]);
    }

    for (i = 0; i < 5; i++)
    {
        if (x[i] == 0) printf("%d", i + 1);
    }
    
    return 0;
}


Measured memory_bytes: 1704
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  LL A, B, K; std::cin >> A >> B >> K;

  LL A2 = std::max(0LL, A-K);
  LL K2 = std::max(0LL, K-A);
  LL B2 = std::max(0LL, B-K2);
  std::cout << A2 << " " << B2 << std::endl;
}


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


def judge(x, phase):
    if x < phase // 2 or (x - phase // 2) % 2 == 1:
        return 0
    else:
        return 1


result = []

if (B // 2 + B % 2 - ((A - 1) // 2 + (A - 1) % 2)) % 2 == 0:
    result.append("0")
else:
    result.append("1")

for i in range(2, len(bin(B)[2:]) + 1):
    phase = 2**i
    b = B % phase
    a = (A - 1) % phase
    if judge(a, phase) == judge(b, phase):
        result.append("0")
    else:
        result.append("1")

result.reverse()
print(int("".join(result), 2))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 99999999;
  bool black = false;
  bool tmp = false;
  int i;
  vector<int>b(n);
  vector<int>w(n);
  for(i=0;i<n;i++){
    if(s[i]=='#')b[i]++;
    else w[i]++;
  }
  for(i=1;i<n;i++){
    b[i]=b[i-1]+b[i];
    w[i]=w[i-1]+w[i];
  }
  if(s[0]=='#')black = true;
  else black = false;
  for(i=0;i<n;i++){
    if(ans>b[i]+w[n-1]-w[i])ans = b[i]+w[n-1]-w[i];
  }
  if(w[n-1]<ans)ans = w[n-1];
  if(b[n-1]<ans)ans = b[n-1];


  cout << ans << endl;
}


Measured memory_bytes: 2180
import java.util.*;import java.math.*;class Main{public static void main(String[]e){int n,i,j;BigInteger c,r;for(Scanner s=new Scanner(System.in);(n=s.nextInt())>0;){BigInteger[]a=new BigInteger[n];for(i=n,r=a[--i]=s.nextBigInteger();i-->0;)r=r.min(a[i]=s.nextBigInteger());for(i=n;i-->0;)for(j=i+1,c=BigInteger.ZERO;j-->0;)r=r.max(c=c.add(a[j]));System.out.println(r);}}}

Measured memory_bytes: 13000
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int ans[105][105];
int cnt[10005];

int32_t main()
{
    #ifdef DEBUG
    freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    for0(i,n) {
        read(cnt[i+1]);
    }
    
    int y=0,x=0;
    for (int c=1; c<=n; c++) {
        while (cnt[c] > 0) {
            ans[y][x] = c;
            if (y%2 == 0) {
                x++;
                if (x == w) {
                    y++;
                    x = w-1;
                }
            }
            else {
                x--;
                if (x == -1) {
                    y++;
                    x = 0;
                }
            }
            cnt[c]--;
        }
    }
    
    for0(y,h) {
        for0(x,w) {
            printf("%lld ",ans[y][x]);
        }
        printf("\n");
    }
    return 0;
}


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

  vector<string> s = {};
  string x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    s.push_back(x);
  }

  map<string, long> s_map;

  for(auto &x : s) {
    sort(x.begin(), x.end());
    s_map[x]++;
  }

  long count = 0;

  for(auto &x : s_map) {
    if (x.second > 0) {
      count += x.second * (x.second - 1) / 2;
    }
  }

  cout << count;
}

Measured memory_bytes: 18164
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 200002;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()
#define biton(x, y) (((x>>y)&1ll) == 1)
#define bitoff(x, y) (((x>>y)&1ll) == 0)

int32_t main()
{ 
   IOS
 
  int n;
  cin >> n;
  int a[n+1];
  a[0] = 0;
  for(int i = 1;i<=n;i++){
    cin >> a[i];
  }
  int dp[n+1] = {0};
  dp[0] = 1000;
  for(int i =  1;i<=n;i++){
    dp[i] = dp[i-1];
    for(int j = 1;j<i;j++){
      dp[i] = max(dp[i], (dp[j-1]/(a[j]))*a[i] + dp[j-1]%a[j]);
    }
  }

  cout << dp[n] << endl;


 
}

Measured memory_bytes: 3648
#include<iostream>

int main(){

    int W, H, x, y, r;
    std::cin >> W >> H >> x >> y >> r;

    bool vertical = 0 <= y - r && y + r <= H;
    bool horizontal = 0 <= x - r && x + r <= W;
    if(vertical && horizontal){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
vector<int> nodeCount;

// 木上の探索
// v: 現在探索中の頂点、p: v の親 (v が根のときは -1)
void dfs(const Graph &G, int v, int p=-1) {
	for (auto new_v : G[v]) {
		if (new_v == p) continue; // new_v が親 p なら除外
		nodeCount[new_v] += nodeCount[v];
		dfs(G, new_v, v); // v は新たに new_v の親になります
	}
}

int main() {

	int n; cin >> n; // 頂点数 (木なので辺数は n-1 で確定)
	int q; cin >> q;

	nodeCount.assign(n, 0);
		
	Graph G(n);
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	for (int i = 0; i < q; ++i) {
		int p, x;
		cin >> p >> x;
		nodeCount[--p] += x;
	}

	int root = 0;
	dfs(G, root);

	for (int i = 0; i < n; ++i)
		cout << nodeCount[i] << " ";

	return 0;
}


Measured memory_bytes: 26624
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

void exchange(int A[], int a, int b) {
    int temp = A[a];
    A[a] = A[b];
    A[b] = temp;
}

int partition(int A[], int p, int r) {
    int x = A[r];
    int i = p-1;
    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            exchange(A, i, j);
        }
    }
    exchange(A, i+1, r);
    return i+1;
}

int main() {
    int n;
    cin >> n;
    int A[n];
    REP(i,n) {
        cin >> A[i];
    }
    int p = partition(A, 0, n-1);
    REP(i,p) {
        cout << A[i] << " ";
    }
    cout << "[" << A[p] << "]";
    FOR(i,p+1,n) {
        cout << " " << A[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1552
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

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

int main(){

        int n[3],o[3];
        memset(o,0,sizeof(o));

        scanf("%d %d %d",&n[0],&n[1],&n[2]);
        o[0] = n[0];

        for(int i=1;i<3;i++){
                if(o[i-1] > n[i]){
                        for(int j=0;j<3;j++){
                                if(o[j] > n[i]) {
                                        memmove(&o[j+1],&o[j],(2-j)*sizeof(int));
                                        o[j] = n[i];
                                        break;
                                }
                        }
                } else {
                        o[i] = n[i];
                }

        }
        printf("%d %d %d\n",o[0],o[1],o[2]);

        return 0;
}


Measured memory_bytes: 3224
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextLong()
    println(problem160b(x))
}

fun problem160b(x: Long): Long {
    return (x / 500) * 1000 + x % 500 / 5 * 5
}

Measured memory_bytes: 31512
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  int n, tt;
  cin >> n >> tt;
  vector<int> t(n);
  for (int i = 0; i < n; i++) cin >> t[i];
  ll ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (t[i + 1] - t[i] >= tt)
      ans += tt;
    else
      ans += t[i + 1] - t[i];
  }
  ans += tt;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const ll INF = 10e17;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
ll func(ll n)
{
	if (n == 0) return 0;
	int k = to_string(n).size();
	ll cnt = 0, mn = 1;
	REP(i, k-1)
	{
		if (i == 0) cnt += 21;
		else
		{
			ll mx = mn * 10 - 1;
			ll c3 = mx / 3 - (mn - 1) / 3;
			ll c5 = mx / 5 - (mn - 1) / 5;
			ll c15 = mx / 15 - (mn - 1) / 15;
			ll ot = (mx - mn + 1) - c3 - c5 + c15;
			cnt += ot*(i + 1) + (c3 + c5) * 4;
		}
		mn *= 10;
	}
	ll mx = n;
	ll c3 = mx / 3 - (mn - 1) / 3;
	ll c5 = mx / 5 - (mn - 1) / 5;
	ll c15 = mx / 15 - (mn - 1) / 15;
	ll ot = (mx - mn + 1) - c3 - c5 + c15;
	cnt += ot*k + (c3 + c5) * 4;
	return cnt;
}

int main()
{
	ll n; cin >> n;
	n--;
	ll lb = 0, ub = INF;
	while (ub - lb > 1)
	{
		ll mid = (ub + lb) / 2;
		if (func(mid) >= n) ub = mid;
		else lb = mid;
	}
	ll tmp = n - func(lb);
	string ans;
	for (ll i = ub;i<=ub+30;i++)
	{
		string t;
		if (i % 15 == 0) t = "FizzBuzz";
		else if (i % 3 == 0) t = "Fizz";
		else if (i % 5 == 0) t = "Buzz";
		else t = to_string(i);
		ans += t;
	}
	cout << ans.substr(tmp, 20) << endl;
	return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
int main()
{
    long long int a,b,c=0,o,e,d=1,i,t,j,n,y,k,m,l,r=0;
    scanf("%lld",&n);
    n=n%10;
    if(n==2||n==4||n== 5||n== 7||n==9){printf("hon\n");}
    else if(n== 0||n==  1||n==  6 ||n==  8){printf("pon\n");}
    else {printf("bon\n");}

}


Measured memory_bytes: 1600
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		String cards = sc.next();
		int h,m;
		while(!cards.equals("-")){
			m = sc.nextInt();
			for(int i = 0; i < m; i++){
				h = sc.nextInt();
				cards = cards.substring(h,cards.length()) + cards.substring(0,h);
			}
			System.out.println(cards);
			cards = sc.next();
		}
	}
}

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

int main(){
    int s;
    cin >> s;
    int count=1;
    while(true){
        if(s==4||s==2||s==1)break;
        if(s%2==0)s/=2;
        else s=3*s+1;
        count++;
    }
    cout << count+3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long int ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

ll modpow(ll a, ll n, ll MOD) {
  ll res = 1;
  while(n>0){
    if(n&1) res = res * a % MOD;
    a = a * a % MOD; // a を 2乗したものに置き換える。（2進数だと1桁上がる）
    n >>= 1; // 2進数で1桁下げる
  }
  return res;
}

int main(void) {
  int n,k;cin>>n>>k;
  const int MOD=pow(10,9)+7;
  ll res[k+20];
  ll sum=0;
  for(int i=k;i>0;--i) {
    int t = k/i;
    res[i-1]=modpow(t,n,MOD);
    rep(j,2,t) {
      res[i-1]-=res[j*i-1];
    }
    sum=(sum+(i*res[i-1])%MOD)%MOD;
    // pr(res[i-1],i,t);
  }
  pr((sum+2*MOD)%MOD);
  return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

string s,t;

signed main() {
    cin >> s >> t;
    cout << t << s << endl;
}



Measured memory_bytes: 256
#include "cstdio"
unsigned long long gcd(unsigned long long a,unsigned long long b){
	if(b==0)return a;
	gcd(b,a%b);
}
unsigned long long lcm(unsigned long long a,unsigned long long b){
	return a/gcd(a,b)*b; 
}
unsigned long long ss,n,s;
int main(){
	scanf("%llu",&n);
	scanf("%llu",&ss);n--;
	while(n--){
		scanf("%llu",&s);
		ss=lcm(ss,s);
	}
	printf("%llu\n",ss);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){

  int a,b,w,diff;

  scanf("%d %d %d",&w,&a,&b);

  if(a<b){
    diff = b - ( a + w );
  }else{
    diff = a - ( b + w );
  }
  if(diff<=0){
    printf("0\n");
  }else{
    printf("%d\n",diff);
  }

  return 0;

}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

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

  bool flag = true;
  int c = 0;
  for (int i = 0; i < int(s.size()); ++i) {
    flag = true;
    c = 0;
    for (int j = 0;; ++j) {
      if (s[i + j] != t[j]) {
        flag = false;
        break;
      }
      ++c;

      if (i + j == int(s.size()) - 1) {
        break;
      } else if (j == int(t.size()) - 1) {
        flag = false;
        break;
      }
    }
    if (flag)
      break;
  }

  cout << max(int(s.size() + t.size()) - c, n) << endl;
}


Measured memory_bytes: 3624
int main()
{
    long long int A;
    double B;
    scanf("%lld %lf", &A, &B);

    long long int result;
    B = (B + 0.005) * 100 ;
    result = (long long int) (A * (long long int) B);
    result = result / 100 ;
    printf("%lld\n",result);
}


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

int main(){

  char c[3];

  for(int i=0; i<3; i++){
    cin >> c[i];
  }
  
  char cha;

  for(int i=0; i<3; i++){
    cin >> cha;
    if(cha != c[2-i]){
      cout << "NO" << endl; 
      return 0;
    }
  }
  
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,m,H,W,h;
    scanf("%d%d",&H,&W);
    char a[W];
    for(n=1;n<=W+2;n++){
        printf("#");}
        printf("\n");
    for(h=0;h<=H-1;h++){
    scanf("%s",a);
    printf("#%s#\n",a);}
    for(m=1;m<=W+2;m++){
        printf("#");}
        printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	vector<int64_t> as(n); for (auto& a : as) { cin >> a; }
	sort(as.begin(), as.end(), greater<int64_t>());

	multiset<int64_t, greater<int64_t>> vals;
	int64_t ans = 0;
	FOR_LT(i, 0, n) {
		int64_t a = as[i];
		if (!vals.empty()) {
			ans += *vals.begin();
			vals.erase(vals.begin());
			vals.insert(a);
		}
		vals.insert(a);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 14280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    int n,k,ans=pow(10,9);
    cin >> n >> k;
    vector<int> v(n);
    for(ll i=0;i < n;i++)
    {
        cin >> v.at(i);
    }
    sort(v.begin(),v.end());
    
    for(int i=0;i+k-1 <(int)v.size();i++)
    {
        ans = min(ans,-v.at(i)+v.at(i+k-1));
    }

    cout << ans << endl;
}
//

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/rope"
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
#define lambdify(x) [&](auto &&...args){ return x(forward<decltype(args)>(args)...); }
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T, typename BO>
struct segment{
	int n;
	BO bin_op;
	T id;
	vector<T> val;
	vector<int> roots;
	template<typename IT>
	segment(IT begin, IT end, BO bin_op, T id): n(distance(begin, end)), bin_op(bin_op), id(id), val(n << 1, id){
		for(int i = 0; i < n; ++ i) val[i + n] = *(begin ++);
		for(int i = n - 1; i > 0; -- i) val[i] = bin_op(val[i << 1], val[i << 1 | 1]);
	}
	segment(int n, BO bin_op, T id): n(n), bin_op(bin_op), id(id), val(n << 1, id){ }
	void init_roots(){
		vector<int> roots_r;
		for(auto l = n, r = n << 1; l < r; l >>= 1, r >>= 1){
			if(l & 1) roots.push_back(l ++);
			if(r & 1) roots_r.push_back(-- r);
		}
		roots.insert(roots.end(), roots_r.rbegin(), roots_r.rend());
	}
	template<bool increment = true>
	void update(int p, T x){
		for(p += n, val[p] = increment ? bin_op(val[p], x) : x; p >>= 1; ) val[p] = bin_op(val[p << 1], val[p << 1 | 1]);
	}
	T query(int l, int r){
		if(l >= r) return id;
		T resl = id, resr = id;
		for(l += n, r += n; l < r; l >>= 1, r >>= 1){
			if(l & 1) resl = bin_op(resl, val[l ++]);
			if(r & 1) resr = bin_op(val[-- r], resr);
		}
		return bin_op(resl, resr);
	}
};

int main(){
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	int n = int(s.size());
	vector<vector<int>> pos(1 << 7);
	vector<int> p(n, -1);
	for(auto i = 0; i < n; ++ i){
		pos[s[i]].push_back(i);
	}
	if(accumulate(pos.begin(), pos.end(), 0, [&](int x, vector<int> &y){ return x + int(y.size()) % 2; }) != n % 2){
		cout << "-1\n";
		return 0;
	}
	int h = -1;
	for(auto c = 'a'; c <= 'z'; ++ c){
		for(auto i = 0, j = int(pos[c].size()) - 1; i <= j; ++ i, -- j){
			i == j ? h = pos[c][i] : p[pos[c][i]] = pos[c][j];
		}
	}
	segment<int, plus<int>> tr(n, plus<int>(), 0);
	long long res = 0;
	for(auto i = 0; i < n; ++ i){
		if(i < p[i]){
			if(~h){
				res += h < i || p[i] < h;
			}
			res += tr.query(i, p[i]) + 2 * tr.query(0, i);
			tr.update(p[i], 1);
		}
	}
	cout << res;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n, y;
    cin >> n >> y;
    y /= 1000;
    y -= n;
    int a = -1;
    int b = -1;
    int c = -1;
    //debug(y);
    rep(i, n+1) rep(j, n+1) {
        if (i+j>n) continue;
        if (4*i+9*j==y) {
            b = i;
            c = j;
        }
    }
    if (b!=-1) {
        a = n-b-c;
    }
    
    cout << c << " " << b << " " << a << endl;
    return 0;
}


Measured memory_bytes: 3592
# -*- coding: utf-8 -*-
'import sys'
c={
    'S':[0]*13,
    'H':[0]*13,
    'C':[0]*13,
    'D':[0]*13
}
n=int(input())
for i in range(n):
    s,num=input().split()
    c[s][int(num)-1]=1
for i in["S","H","C","D"]:
    for j in range(13):
        if c[i][j]==0:
            print(i,j+1)

Measured memory_bytes: 7684
N,M = map(int, input().split())
List = []
for i in range(M):
    List.append([int(a) for a in input().split()])
    
for j in range(M):
    List[j].append(j)

List.sort(key=lambda x:x[1])
dic = {}

for k in range(M):
    dic[List[k][0]] = 0

ans = []

for l in range(M):
    dic[List[l][0]] += 1
    ans.append([List[l][0]*10**6+dic[List[l][0]],List[l][2]])

ans.sort(key=lambda x:x[1])

for m in range(M):
    num = str(ans[m][0])
    print(num.zfill(12))

Measured memory_bytes: 47496
def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    cnt = [-1] * n
    cnt[0] = 0
    ary = []
    now = 0
    for i in range(n):
        a[i] -= 1

    ary.append(now)
    if k <= n:
        for i in range(1,k+1):
            now = a[now]
            if i == k:
                print(now+1)
                return
    else:
        for i in range(1,k+1):
            now = a[now]
            if cnt[now] != -1:
                break
            else:
                cnt[now] = i
                ary.append(now)
        loop_s = cnt[now]

        print(ary[cnt[now] +((k-cnt[now]) % (i - cnt[now]))] + 1)
        # print(cnt)
        # print(now)
        # print(ary)

if __name__=='__main__':
    main()


Measured memory_bytes: 33400
#include<stdio.h>
#include<string.h>

#define MAX 14
#define N 1046527

char H[N][MAX];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else  return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1;
  int i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % N; }
int h2(int key){ return 1+key % (N-1); }

int Insert(char *word){
  long long key;
  int i,h;

  key=getKey(word);

  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%N;
    if(strcmp(H[h],word)==0)return 1;
    else if (strlen(H[h])==0){
      strcpy(H[h],word);
      return 0;
    }
  }
  return 0;
}

long long Find(char *word){
  long long key;
  int i,h;

  key=getKey(word);

  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%N;
    if(strcmp(H[h],word)==0)return 1;
    else if (strlen(H[h])==0)return 0;
  }
  return 0;
}

int main(){
  int n,i,flag;
  char order[10],words[12];

  for(i=0;i<N;i++){
    H[i][0]='\0';
  }

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %s",order,words);

    if(strcmp(order,"insert")==0)
    Insert(words);

    else if(strcmp(order,"find")==0){
      flag=Find(words);

      if(flag==1)
      printf("yes\n");

      else
      printf("no\n");

    }

    else
    printf("miss order!!\n");


  }
  return 0;
}



Measured memory_bytes: 16044
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <list>
#include <queue>
using namespace std;

int N, K;
vector<int> V;


int main() {

    cin >> N >> K;

    int v;
    for (int i = 0; i < N; i++) {
        cin >> v;
        V.push_back(v);
    }
    vector<int> aa;
    int R = min(N, K);
    
    for (int r = 1; r <= R; r++) {
        
        for (int A = 0; A <= r; A++) {
            priority_queue<int> PQ;
            for (int i = 0; i < A; i++) {
                PQ.push(-V[i]);
            }
            for (int j = N-1; j > N - 1 - (r - A); j--) {
                PQ.push(-V[j]);
            }
            for (int i = 0; i < K - r; i++) {
                if (!PQ.empty())
                    if(PQ.top() > 0)
                        PQ.pop();
            }
            int a = 0;
            while (!PQ.empty()) {
                a += -PQ.top(); PQ.pop();
            }
            aa.push_back(a);
        }
    }

    int ans = *max_element(aa.begin(), aa.end());
    cout << ans << '\n';
}



Measured memory_bytes: 256
#include<iostream> 
#include<cstring>
using namespace std;
int main()
{
	int k;cin>>k; 
	string s;cin>>s;
	if(s.size()<=k)
		cout<<s<<endl;
	else
	{
		for(int i=0;i<k;i++)
		{
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
	return 0; 
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    string s;
    cin >> s;
    bool c = false;
    if(s[0]!='A'){
        cout << "WA" << endl;
        return 0;
    }

    for(int i=1;i<s.size();i++){
        char x = s[i];
        if(x=='C'&&i!=1&&i!=s.size()-1&&!c){
            c = true;
            continue;
        }else if(x=='C'&&c){
            cout << "WA" << endl;
            return 0;
        }
        if(isupper(x)){
            cout << "WA" << endl;
            return 0;
        }
    }

    if(c){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
}

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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> m(n);
	for (int i = 0; i < n; ++i) {
		cin >> m[i];
	}
	x -= accumulate(m.begin(), m.end(), 0);
	cout << n + x / (*min_element(m.begin(), m.end())) << endl;

	return 0;
}

Measured memory_bytes: 256
#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    // 1つの数字
    let n: usize =  {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    // 1行ベクトル
    let d: Vec<usize> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.split_whitespace().map(|x| x.parse().unwrap()).collect()
    };

    let mut sum = 0;
    for i in 0..n {
        for j in i+1..n {
            sum += d[i] * d[j];
        }
    }

    println!("{}", sum)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;
 
signed main()
{
    fast;
    int n;
    cin>>n;

    int a[n][3];

    for ( int i = 0 ; i < n ; i++ )
    {
        for ( int j = 0 ; j < 3 ; j++ )
        {
            cin>>a[i][j];
        }
    }

    int dp[n][3] = {0};

    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    for ( int i = 1 ; i < n ; i++ )
    {
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i][0];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + a[i][1];
        dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + a[i][2];
    }

    cout<<max( dp[n-1][0] , max( dp[n-1][1] , dp[n-1][2] ) )<<endl;
    
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(void){
	long a, b;
	cin >> a >> b;
	long c = __gcd(a, b);
	long t = 0;
	for(long i = 2; i * i <= c; i++){
		if(c % i == 0){
			t++;
			while(c % i == 0) c /= i;
		}
	}
	if(c != 1) t++;
	cout << t + 1 << endl;
	return 0;
}

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

const int km = 1e5, mod = 1e9 + 7;
long long s[km + 1];
int n, k;
long long ans = 0;
int pow(int x, int y) { //x^y
	int rv = 1;
	for (; y > 0; y >>= 1, x = (long long) x * x % mod)
		if (y & 1)
			rv = (long long) rv * x % mod;
	return rv;
}

int main() {
	cin >> n >> k;
	for (int i = 1; i <= k; i++) {
		ans += (long long) pow(k / i, n) * (i - s[i]) % mod;
		for (int j = i * 2; j <= k; j += i) {
			s[j] += i - s[i];
		}
	}
	ans %= mod;
	if (ans < 0)
		ans += mod;
	cout << ans << endl;

}


Measured memory_bytes: 4348
#include <bits/stdc++.h>
typedef long long       ll;
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define mt                make_tuple
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define fore(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define forr(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define deb(x)			  cerr << "# " << (#x) << " = " << (x) << endl;
#define sz(x)             (int)x.size()
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int INF = 1234567890;

const int tam = 3e5 + 10;

int T[4*tam];
#define index int L = 2*nodo+1, R = L+1, mid = (b + e) / 2;

void update(int b, int e, int nodo, int pos, int val) {
    index;
    if (b == e) {
        T[nodo] = val;
        return;
    }
    if (pos <= mid) update(b, mid, L, pos, val);
    else update(mid+1, e, R, pos, val);
    T[nodo] = max(T[L], T[R]);
}

int query(int b, int e, int nodo, int i, int j) {
    index;
    if (j < b || e < i) return 0;
    if (i <= b && e <= j) return T[nodo];
    return max(
        query(b, mid, L, i, j),
        query(mid+1, e, R, i, j)
    );
}

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    int n, k;
    cin >> n >> k;
    int a[n];
    fore(i, 0, n) {
        cin >> a[i];
    }
    for (int i = n-1; i >= 0; i--) {
        int l = max(a[i] - k, 0);
        int r = min(a[i] + k, tam-1);
        int val = 1 + query(0, tam-1, 0, l, r);
        update(0, tam-1, 0, a[i], val);
    }
    cout << T[0] << '\n';
    return 0;
}
// Dinosaurs are cool!

Measured memory_bytes: 8880
import numpy as np
n,A,B,C=list(map(int,input().split(" ")))
l_list = [0]*n
for i in range(n):
    l_list[i] = int(input())
    
flags = [0]*n

anss = []

def f(d):
    if d < n:
        for i in [0,1,2,3]:
            flags[d] = i
            f(d+1)
    else:
        if not (flags.count(1)>0 and flags.count(2)>0 and flags.count(3)>0):
            return
        tA = A
        tB = B
        tC = C
        for i in range(n):
            if flags[i] == 1:
                tA -= l_list[i]
            elif flags[i] == 2:
                tB -= l_list[i]
            elif flags[i] == 3:
                tC -= l_list[i]
        ans = 0
        ans += max(0,(flags.count(1)-1)*10)
        ans += max(0,(flags.count(2)-1)*10)
        ans += max(0,(flags.count(3)-1)*10)
        ans += abs(tA)+abs(tB)+abs(tC)
        anss.append(ans)
f(0)
print(min(anss))
        
        

Measured memory_bytes: 14260
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<string,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n;cin >> n;
    vector<P> v;
    string s[n];
    int c[n];
    map<P,int> ma;
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> c[i];
        v.push_back(mp(s[i],c[i]));
        ma[mp(s[i],c[i])]=i+1;
    }
    sort(ALL(v),[&](P p,P q){
            if(p.fs<q.fs) return true;
            else if(p.fs>q.fs) return false;
            else{
                if(p.sc<q.sc) return false;
                else return true; 
                }
            });
    for (int i = 0; i < n; i++) {
        cout << ma[mp(v[i].fs,v[i].sc)]<< endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}


	return 0;
}


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

result = []
for i in range(n + 1):
    count = 0
    a, b = i , n - i
    while a > 0:
        count += a % 6
        a //= 6
    while b > 0:
        count += b % 9
        b //= 9
    result.append(count)
print(min(result))

Measured memory_bytes: 3864
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
  int a, b;
  while(cin >> a >> b,  a){
    bool flag = true;
    for(int i = 0 ; i < b ; i++ ){
      int foo;
      cin >> foo;
      flag &= foo != 1;
    }
    cout << fixed << setprecision(7) << a / 2.0 * flag << endl;
  }
}

Measured memory_bytes: 1232
#include<stdio.h>
#include<limits.h>

int main(void){
  int n, i, a;
  long max = LONG_MIN;
  long min = LONG_MAX;
  long sum = 0;
    
  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%d", &a);

    if(a < min) min = a;
    if(a > max) max = a;
    sum += a;
  }

  printf("%ld %ld %ld\n", min, max, sum);

  return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        ans+=(n/i);
        if(!(n%i))ans--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <sstream>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int a, b ,c , d;
  cin >> a >> b >> c >> d;
  if (a* b >= c*d ){
  cout << a*b << endl;} else{
  cout << c* d << endl;
  }
  return 0;
}


Measured memory_bytes: 256