akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

MOD = 1000000007

n = int(input())
alst = list(map(int, input().split()))
dic = defaultdict(list)
for i in range(n + 1):
    dic[alst[i]].append(i)

for v in dic.values():
    if len(v) == 2:
        left, right = v
        break

rem = n + 1 - (right - left + 1)


factMem = {}
def fact(x):
    if x <= 0:return 1
    if x in factMem:return factMem[x]
    factMem[x] = x * fact(x - 1) % MOD
    return factMem[x]

for x in range(n + 1):
    fact(x)

inverseMem = {}
def inverse(x):
    if x in inverseMem:return inverseMem[x]
    inverseMem[x] = pow(x, MOD - 2, MOD)
    return inverseMem[x]

def comb(x, y):
    if x < y or y < 0:return 0
    return (fact(x) * inverse(fact(y)) * inverse(fact(x - y))) % MOD

for i in range(n + 1):
    print((comb(n + 1, i + 1) - comb(rem, i)) % MOD)


Measured memory_bytes: 55616
#include <iostream>
using namespace std;
int main() {
 int K;
  int Kcount;
  int Gcount;
  
  
  cin >> K;
  
  Gcount = K/2;
  
  Kcount = K-Gcount;
  
  cout << Gcount*Kcount;
  cout << endl;
  
  
  
  
  
}

Measured memory_bytes: 256
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<class T>void put_double(T a){cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    int n; cin >> n;
    vstr w(n); vin(w);
    set<string> s;
    s.insert(w[0]);
    rep(i, n - 1) {
        if(s.count(w[i + 1]) == 0 && w[i + 1][0] == w[i].back()) {
            s.insert(w[i + 1]);
        } else {
            println("No");
            return 0;
        }
    }
    println("Yes");
    return 0;

}


Measured memory_bytes: 256
H, W = map(int,input().split())
grid = [input() for _ in range(H)]
dp = [[float('inf')]*(W) for _ in range(H)]
dp[0][0] = 0 if grid[0][0] == '.' else 1
for i in range(H):
    for k in range(W):
        if i+1 < H:
            if grid[i][k] == '.' and grid[i+1][k] == '#':
                dp[i+1][k] = min(dp[i][k]+1,dp[i+1][k])
            else:
                dp[i+1][k] = min(dp[i][k],dp[i+1][k])
        if k+1 < W:
            if grid[i][k] == '.' and grid[i][k+1] == '#':
                dp[i][k+1] = min(dp[i][k]+1,dp[i][k+1])
            else:
                dp[i][k+1] = min(dp[i][k],dp[i][k+1])
print(dp[-1][-1])

Measured memory_bytes: 74104
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n,k;
  while(1){
    cin>>n>>k;
    if(n==0 && k==0)break;
    vi v(n+1);
    v[0]=0;
    rep(i,n)
      cin>>v[i+1];
    rep(i,n)
      v[i+1]+=v[i];
    int ans=-INF;
    loop(i,k,n+1)
      ans=max(ans,v[i]-v[i-k]);
    cout<<ans<<endl;
  }
}

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

int main(){
  int N;
  cin >> N;
  vector<pair<int, int> > xy(N);
  for(int i = 0; i < N; i++) cin >> xy[i].first >> xy[i].second;
  long double ans = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(i == j) continue;
      int tmpx, tmpy, tmpL2;
      tmpx = xy[i].first - xy[j].first;
      tmpy = xy[i].second - xy[j].second;
      tmpL2 = tmpx*tmpx + tmpy*tmpy;
      ans += sqrt(tmpL2);
    }
  }
  ans /= N;
  cout << fixed;
  cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 256
def mulmod(x,y,p):
    return x*y % p

def test(n):
    if n<1:
        return 1
    memo = [0]*(n+1)
    memo[0] = 1
    memo[1] = 1
    for i in range(2,n+1):
        memo[i] = (memo[i-1] + memo[i-2])%1000000007
    return memo[n]

n,m = map(int,input().split())
a =[]
pos = 0
result = 1
last = -1
for i in range(m):
    x = int(input())
    if (last+1) == x:
        print(0)
        exit(0)
    last = x
    a.append(x)

for i in a:
    result = mulmod(test(i-pos-1),result,1000000007)
    pos = i+1
 
result = mulmod(test(n-pos),result,1000000007)
print(result)

Measured memory_bytes: 6900
#include<iostream>
using namespace std;
int main(){
int N, p,ans;
cin >> N;
if(N < 10) p = 1;
else if(N < 100) p = 2;
else if(N<1000) p = 3;
else if(N < 10000) p = 4;
else if(N < 100000) p = 5;
else p = 6;

if(p == 1) ans = N;
if(p == 2) ans = 9;
if(p == 3) ans = 9+N-99;
if(p == 4) ans = 909;
if(p == 5) ans = 909 + N - 9999;
if(p == 6) ans = 90909;
  
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> as;
vector<int> bs;

vector<ll> ss_a;
vector<ll> ss_b;

int main(void) {
    int N, M;
    ll K;
    cin >> N >> M >> K;

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    bs.resize(M);
    for (int i = 0; i < M; i++) {
        cin >> bs[i];
    }

    ss_a.resize(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        ss_a[i] = ss_a[i - 1] + as[i - 1];
    }

    ss_b.resize(M + 1, 0);
    for (int i = 1; i <= M; i++) {
        ss_b[i] = ss_b[i - 1] + bs[i - 1];
    }

    int ans = 0;

    int num_b = M;
    for (int num_a = 0; num_a <= N; num_a++) {
        ll rem = K - ss_a[num_a];
        if (rem < 0) {
            break;
        }
        while (num_b > 0 && ss_b[num_b] > rem) {
            num_b--;
        }
        // printf("num_a: %d, num_b: %d\n", num_a, num_b);
        chmax(ans, num_a + num_b);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7908
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int h, w, n; cin >> h >> w >> n;
	VI a(n); rep(i, n)cin >> a[i];

	VVI ans(h, VI(w));
	int i = 0, j = 0, ai = 0;
	rep(loop, h * w) {
		ans[i][j] = ai + 1; a[ai]--;
		if (a[ai] == 0)ai++;

		//move
		if (j == w - 1&&i%2==0)i++;
		else if (j == 0 && i % 2 == 1)i++;
		else if (i % 2 == 0)j++;
		else j--;
	}

	rep(x, h)rep(y, w) {
		cout << ans[x][y];
		printf(y == w - 1 ? "\n" : " ");
	}
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 競プロ_Csharp {
    class Program {
        static void Main(string[] args) {

            int[] a = NextInts();
            
            if (a[0] < a[1]) {
                Println("a < b");
            }
            else if (a[0] > a[1]) {
                Println("a > b");
            }
            else {
                Println("a == b");
            }

        }

        public static void Println (Object o) {
            Console.WriteLine(o);
        }

        public static string NextString() {
            return Console.ReadLine();
        }

        public static int NextInt () {
            return int.Parse(Console.ReadLine());
        }

        public static int[] NextInts () {
            string[] a = Console.ReadLine().Split();
            int[] b = new int[a.Length];
            for (int i = 0; i < a.Length; i++) {
                b[i] = int.Parse(a[i]);
            }
            return b;
        }
    }
}



Measured memory_bytes: 15972
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int L[110];

int main(){
  int W, H, x, y;
  cin >> W >> H >> x >> y;

  int mult = 0;
  if(W == x * 2 && H == y * 2) mult = 1;

  float s = W /2.0 * H;
  cout << s << " " << mult << endl;

  return 0;
}



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

#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define endl "\n"

#define for0(i, n) for (int i = 0; i < n; i++)
#define loop(i, a, b) for(int i = a;i <= b; i++)
#define forrev(i, n) for(int i = n; i >= 0; i--)
#define test_case(t) int t; cin >> t; while (t--)
#define debug(x) cout<< #x << "=" << x <<"\n";
#define debug(x, y) cout << #x << "=" << x << "," << #y << "=" << y << "\n";

typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

#define prec(n) fixed<<setprecision(n)
#define inf (int)(1e18)
#define MAX 1000002
#define MOD 1e9 + 7

long long int max(long long int a,long long int b){if(a>b) return a; else return b;}
long long int min(long long int a,long long int b){if(a<b) return a; else return b;}
bool isPrime(int N){
    for(int i=2;i*i<=N;++i){
        if(N%i==0) return false;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

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

    vi h(n+1);

    for(int i = 1; i<=n;i++)
        cin>>h[i];

    vi dp(n+1, 1000000005);

    dp[1] = 0;

    for(int i = 2;i<=n;i++)
    {
        for(int j = 1;j<=k;j++)
        {
            if((i-j) >= 1)
             dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }

    cout<<dp[n]<<endl;

    return 0;
}
//g++ -std=c++17 -Wshadow -Wall -O2 -Wno-unused-result



Measured memory_bytes: 3972
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
  double A,B,H,M,ans,th,tm,t;
  cin>>A>>B>>H>>M;
  
  th=30*(H+M/60); tm=6*M;
  
  t=(th-tm)*3.14159265359/180;
  cerr<<t<<" "<<th-tm<<" ";
  ans=A*A+B*B-2*A*B*cos(t);
  cerr<<ans;
  
  ans=sqrt(ans);
  cout<<fixed<<setprecision(10)<<ans;
}

Measured memory_bytes: 4228
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}


int main() {
	string a, b;
	cin >> a >> b;
	string s = a + b;
	ll unko = atol(s.c_str());
	double t = sqrt(unko);
	if ((ceil(t) == floor(t)))cout << "Yes" << endl;
	else cout << "No" << endl;
}



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

int main() {

    int a,b;

    cin >> a >> b;

    

    if(a * b == 2){

        cout << "3 " << endl;
    }else if(a * b == 3){

        cout << "2 " << endl;
    }else if(a * b == 6){

        cout << "1"  << endl;
    }

    return 0;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,j;
  string s;
  cin>>s;
  bool flag=true;
  for(i=0;i<s.size();i++){
    for(j=0;j<s.size();j++){
      if(i!=j&&s[i]==s[j]){
        flag=false;
      }
    }
  }
  if(flag){
    cout<<"yes"<<endl;
  }else{
    cout<<"no"<<endl;
  }
	return 0;
	}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int A,B;
    int tasu,hiku,seki;
    int max;
    scanf("%d %d",&A,&B);
    
    tasu=A+B;
    hiku=A-B;
    seki=A*B;
    max=tasu;
    if(hiku>max)max=hiku;
    if(seki>max)max=seki;
    
    printf("%d",max);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

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

    int cnt = 0;
    int n = s.length();
    for (int a = 0, b = 1; a < n && b < n;) {
        if (s[a] != s[b]) {
            s[a] = '2';
            s[b] = '2';
            cnt += 2;

            int p = min(a, b) - 1;

            while (s[p] == '2') p--;
            if (a < b) {
                b++;
                if (0 <= p) a = p;
                else a = b + 1;
            } else {
                a++;
                if (0 <= p) b = p;
                else b = a + 1;
            }
        } else {
            if (a < b) a = b + 1;
            else b = a + 1;
        }

    }

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


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

int main(){
    ll n, k, in;
    cin >> n >> k;
    vector<int> ns(200001);
    vector<int> nss(200001);
    int ko = 0;
    int ans = 0;
    rep(i, n+1){
        ns.at(i) = 0;
        nss.at(i) = 0;
    }
    rep(i, n){
        cin >> in;
        ns.at(in)++;
    }
    rep(i, 200001){
        if(ns.at(i) != 0) ko++;
    }
    rep(i, 200001){
        nss.at(ns.at(i))++;
    }
    for(int i=1; i<200001; i++){
        if(ko <= k) break;
        while(!(nss.at(i) == 0 || ko == k)){
            nss.at(i)--;
            ans += i;
            ko--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define fin for(i=0;i<n;i++)
#define vec vector<ll>
#define pb push_back
#define vecit vector<ll>::iterator
#define vecp vector<pair<ll,ll> >
#define vecpit vector<pair<ll,ll> >::iterator
#define mapp map<ll,ll>
#define mapr map<pair<ll,ll>,ll >
#define maprit map<pair<ll,ll>,ll >::iterator
#define mapit map<ll,ll>::iterator
#define mod1 1000000007
#define INF 1000000000000
using namespace std;
int main()
{
    ll n,w;
    cin>>n>>w;
    ll i,j,k,l;
    vec v1;
    vec w1;
    for(i=0;i<n;i++)
    {
        cin>>j>>k;
        w1.pb(j);
        v1.pb(k);
    }
    ll map1[n+1][w+1];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=w;j++)
        {
            if((i==0)||(j==0))
            {
                map1[i][j]=0;
                continue;
            }
            if(j>=w1[i-1])
            {
                map1[i][j]=max(map1[i-1][j],v1[i-1]+map1[i-1][j-w1[i-1]]);
            }
            else
                map1[i][j]=map1[i-1][j];
            //cout<<map1[{i,j}]<<"  ";
        }
        //cout<<"\n";
    }
    cout<<map1[n][w]<<"\n";

}



Measured memory_bytes: 82436
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#include <set>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int n;

set<string> a;

void input() {
  a.clear();

  cin >> n;

  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;

    a.insert(s);
  }
}

void solve() {
  cout << a.size() << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 3;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 19056
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M,ans;
  cin>>N>>M;
  for(int i=1;i*i<=M;i++){
    if(M%i==0){
      int j=M/i;
      if(i<=M/N){
        ans=max(ans,i);
      }
      if(j<=M/N){
        ans=max(ans,j);
      }
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
/*----- || Hare Krishna || -----*/

/*  "WHY DO WE FALL, BRUCE?"  */

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define elif else if
#define pb push_back
#define pf push_front
#define PI 3.1415926535897932384
#define MOD 1000000007
using namespace std;

char alpha[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

string s;
int t;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> t;
    cout << !t;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
main()
{
	ll a, b, c;
	while (cin >> a >> b)
		{
			if (a == b) puts("Draw");
			else if (a == 1) puts("Alice");
			else if (b == 1) puts("Bob");
			else if (a < b) puts("Bob");
			else puts("Alice");
		}

}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define lli long long int

class ManyFomulas{
private:
	lli sum;
public:
	ManyFomulas();
	lli getSum();
	void calculate(string s,lli before,lli ans);
};

ManyFomulas::ManyFomulas(){
	sum=0;
}

lli ManyFomulas::getSum(){
	return sum;
}

void ManyFomulas::calculate(string s,lli before,lli ans){
	if(s.size()==0){
		//cout<<before<<" "<<ans<<endl;
		sum += (before+ans);
	}
	else{
		calculate(s.substr(1),before*10+s.at(0)-'0',ans);
		calculate(s.substr(1),s.at(0)-'0',before+ans);
	}
}

int main(){

	string s;

	ManyFomulas m;

	cin>>s;
	m.calculate(s.substr(1),s.at(0)-'0',0);

	cout<<m.getSum()<<endl;

	return 0;

}

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

using namespace std;

int main() {
   int a,b;
   cin >> a >> b;
   if(a+b>=10)
   cout << "error" << endl;
   else 
   cout << a+b << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){

int a,b;
int d=0,r=0;

double x,y,f=0;

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

x=a;
y=b;

 d = a/b;
 r = a%b;
 f = x/y;

printf("%d %d %f\n",d,r,f);

return 0;
}


Measured memory_bytes: 2044
//
//  main.cpp
//  bignner20200404_1
//
//  Created by zer0 on 2020/04/04.
//  Copyright © 2020 zer0. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {
    int a, b, c;
    
    std::cin >> a >> b >> c;
    
    int temp;
    
    temp = a;
    a = b;
    b = temp;
    
    temp = a;
    a = c;
    c = temp;
    
    // insert code here...
    std::cout << std::to_string(a) + " " + std::to_string(b) + " " + std::to_string(c);
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

int dx4[4]={1,-1,0,0};
int dy4[4]={0,0,1,-1};

bool *plfl;

long long lim=3000000;
void sieve_of_erat(){
  plfl=malloc(sizeof(bool)*(lim+5));
  long long i,j;
  for(i=0;i<lim+5;i++){plfl[i]=true;}
  plfl[0]=false;
  plfl[1]=false;
  for(i=2;i<lim;i++){
    if(!plfl[i]){continue;}
    for(j=2*i;j<lim;j+=i){
      plfl[j]=false;
    }
  }
  return;
}

int main(){
  sieve_of_erat();
  int i,n,r;
  while(scanf("%d",&n)!=EOF){
    r=0;
    for(i=1;i<=n;i++){
      if(plfl[i]&plfl[n+1-i]){r++;}
    }
    printf("%d\n",r);
  }
  return 0;
}



Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    int n,A[200001];
    cin>>n;
    rep(i,n) cin>>A[i];
    int ans=0,a=1;
    rep(i,n) if(A[i]==a) ans++,a++;
    if(!ans) cout<<-1;
    else cout<<n-ans;
}

Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val S = mutableListOf<Int>()
    repeat(n) {
        S.add(scanner.nextInt())
    }
    val q = scanner.nextInt()
    val T = mutableListOf<Int>()
    repeat(q) {
        T.add(scanner.nextInt())
    }
    var count = 0
    for (t in T) {
        for (s in S) {
            if (s == t) {
                count++
                break
            }
        }
    }
    println(count)
}



Measured memory_bytes: 40720
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <iterator>

using namespace std;

const int INF = 1000000;
typedef pair<int, int> P;
int w, h, n;
char f[1001][1001];
int d[1001][1001];
int ans;
int sx, sy;
int gx, gy;

int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
int chx[10], chy[10];

void bfs()
{
   ans = 0;
   for (int i = 0; i < n; i++){
      queue<P> que;
      for (int y = 0; y < h; y++){
         for (int x = 0; x < w; x++){
            d[x][y] = INF;
         }
      }
      sx = chx[i];
      sy = chy[i];
      gx = chx[i+1];
      gy = chy[i+1];
      que.push(P(sx, sy));
      d[sx][sy] = 0;
      while (que.size()){
         P p = que.front(); que.pop();
         if (p.first == gx && p.second == gy) break;
         for (int j = 0; j < 4; j++){
            int nx = p.first + dx[j], ny = p.second + dy[j];
            if (0 <= nx && nx <= w && 0 <= ny && ny <= h && d[nx][ny] == INF && f[nx][ny] != 'X'){
               que.push(P(nx, ny));
               d[nx][ny] = d[p.first][p.second] + 1;
            }
         }
      }
      ans += d[gx][gy];
   }
   cout << ans << endl;
}


int main()
{
   cin >> h >> w >> n;
   for (int y = 0; y < h; y++){
      for (int x = 0; x < w; x++){
         cin >> f[x][y];
         if (f[x][y] == 'S'){
            chy[0] = y;
            chx[0] = x;
         } else if ('1' <= f[x][y] && f[x][y] <= '9'){
            chy[f[x][y] - '0'] = y;
            chx[f[x][y] - '0'] = x;
         }
      }
   }
   bfs();
   return 0;
}


Measured memory_bytes: 7996
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int main() {
    int N, * A1, * A2, sum, ans = 0;
    cin >> N;
    A1 = new int[N];
    A2 = new int[N];

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

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

    for (int i = 0; i < N; i++) {
        sum = 0;
        for (int j = 0; j < N; j++) {
            if (j < i) {
                sum += A1[j];
            }
            else if (j == i) {
                sum += A1[j] + A2[j];
            }
            else {
                sum += A2[j];
            }
            ans = max(ans, sum);
        }
    }

    cout << ans;

    return 0;

}



Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int d,n;
  cin >> d >> n;
  int ans = pow(100,d);
  if(n == 100) cout << 101*ans << endl;
  else cout << n*ans << endl;
}

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	vl a(n), c(n + 1);
	rep(i, n) cin >> a[i], c[i + 1] += c[i] + a[i];

	ll res = INF;
	rep(i, n) {
		int low = 0, high = i;
		while (high - low > 1) {
			int mid = (high + low) / 2;
			if (c[mid] >= c[i] - c[mid]) high = mid;
			else low = mid;
		}

		ll p = c[low], q = c[i] - c[low];
		ll p2 = c[high], q2 = c[i] - c[high];
		ll left_min = min(p, q), left_max = max(p, q);
		if (abs(p2 - q2) < abs(p - q)) left_min = min(p2, q2), left_max = max(p2, q2);

		low = i, high = n;
		while (high - low > 1) {
			int mid = (high + low) / 2;
			if (c[mid] - c[i] >= c[n] - c[mid]) high = mid;
			else low = mid;
		}

		long long R = c[low] - c[i], S = c[n] - c[low]; // 候補1
		long long R2 = c[high] - c[i], S2 = c[n] - c[high]; // 候補2
		long long right_min = min(R, S), right_max = max(R, S);
		if (abs(R2 - S2) < abs(R - S)) right_min = min(R2, S2), right_max = max(R2, S2);

		// 真ん中の切れ目が i であるときの暫定解
		long long tmp = max(left_max, right_max) - min(left_min, right_min);
		res = min(res, tmp);
	}
	cout << res << endl;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x, ll n, int md) {
    if (n == 0)return 1;
    if (n % 2 == 0)return modexp((x * x) % md, n / 2, md);
    return (x * modexp((x * x) % md, n / 2, md)) % md;
}


int main(){
    fastio;
    //clock_t tm = clock();
    ll n,d,x,y;
    cin>>n>>d;
    ll ans=0;
    f(i,0,n){
        cin>>x>>y;
        if(x*x+y*y<=d*d)ans++;
    }
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 3652
def dfs(s,flag):
    if s>N:
        return 0
    ret =1 if flag==7 else 0
    ret+=dfs(s*10+3,flag|1)    
    ret+=dfs(s*10+5,flag|2)
    ret+=dfs(s*10+7,flag|4)
    return ret

N=int(input())
print(dfs(0,0))


Measured memory_bytes: 42352
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
// #define mod  1000000007
#define N 100005
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
const int inf = (int)1e18 + 10;
const int mod = 1e9 + 7;


int p[N] , x[N] , y[N] , sz[N];
vec ans;
int par(int x){
    while(p[x] != x)
      x = p[p[x]];

    return x;
}
signed main(){
  fast;
  int  n , m;
   cin >> n >> m;
   for(int i = 1 ; i<=m ; i++)
      cin >> x[i] >> y[i];

   for(int i = 1 ; i <=n ; i++)
        p[i] = i , sz[i] = 1;
   int tot = n*(n-1)/2;
   for(int i = m ; i> 0 ; i--){
        ans.pb(tot);
        int px = par(x[i]);
        int py = par(y[i]);
        if(px == py) continue;
        tot -= sz[px] * sz[py];
        if(sz[px] > sz[py])
          p[py] = px , sz[px] += sz[py];
        else
          p[px] = py , sz[py] += sz[px];

   }

   reverse(ans.begin() , ans.end());
   for(int i = 0 ; i <  m ; i++)
   cout << ans[i] << endl;      
}


Measured memory_bytes: 5364
import java.util.Scanner;

public class Main {

	
	static Scanner scan = new Scanner(System.in);
		public static void main(String[] args){
			//判定
			boolean flag = true;

			//長方形
			int rec_x = scan.nextInt();
			int rec_y = scan.nextInt();
//			int rec_x = Integer.parseInt(args[0]);
//			int rec_y = Integer.parseInt(args[1]);

			//円
			int cir_x = scan.nextInt();
			int cir_y = scan.nextInt();
			int r = scan.nextInt();
//			int cir_x = Integer.parseInt(args[2]);
//			int cir_y = Integer.parseInt(args[3]);
//			int r = Integer.parseInt(args[4]);

			int r_y_min = cir_y -r;
			int r_y_max = cir_y + r;
			int r_x_min = cir_x -r;
			int r_x_max = cir_x +r;

			if(r_x_max > rec_x){
				flag = false;
			}
			if(r_x_min < 0){
				flag = false;
			}
			if(r_y_min < 0){
				flag = false;
			}
			if(r_y_max > rec_y){
				flag = false;
			}
			if(flag){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}

		}
}


Measured memory_bytes: 26212
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (int)(n) ; i++)

void solve(string S){
	S[3] = '8';
	cout << S << endl;
}

int main(){	
	string S;
	cin >> S;
	solve(S);
	return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] A = new int[N];
    
    for (int i = 0; i < N; i++) {
      A[i] = Integer.parseInt(sc.next());
    }
    
    double sum = 0;
    for (int i = 0; i < N; i++) {
      sum += (1.0 / A[i]);
    }
    
    System.out.println(1.0/sum);
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N ((ll)301*1000)

ll n;

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(int i=1;;i++)
		if(i*(i+1)/2>=n)
			return cout<<i,0;
	
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    while(1) {
        int M, Nmin, Nmax;
        cin >> M >> Nmin >> Nmax;
        if(!(M || Nmin || Nmax)) break;

        vector<int> P(M);
        for(int i=0; i<M; i++) {
            cin >> P[i];
        }
        sort(P.rbegin(), P.rend());

        int max_gap = -INF, ans = 0;
        for(int i=Nmax; i>=Nmin; i--) {
            // さかいめ
            if(i < 1 or i >= M) continue;
            int mi = P[i];
            int ma = P[i-1];
            int gap = ma - mi;
            if(max_gap < gap) {
                max_gap = gap;
                ans = i;
            }
        }
        cout << ans << endl;
    }
    return 0;
}



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

int main(){
    vector<int> v;
    for(int i=0;i<3;i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    cout << v.at(0) << ' ' <<  v.at(1) << ' ' <<  v.at(2) << endl;
}



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

int main(){

    cout<<setprecision(9)<<fixed;

    int w,h,x,y; cin>>w>>h>>x>>y;

    int way = 0;

    // if(x == (w/2) && y == (h/2)) way = 1;
    //これだと誤差が出る
    //商じゃなくて積を考えたほうがよし

    if( (2 * x == w ) && (2 * y == h) ) way = 1; 

    cout<<(double)w * h / 2<<" "<<way<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
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;
    rep(i,10){
        rep(j,10){
            if(N==i*j){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>

#define PII std::pair<int, int>

class BinaryTree
{
	int* tree, size, initVal;

public:
	BinaryTree(int dataSize, int initVal) : initVal(initVal)
	{
		for (size = 1; size < dataSize; size *= 2);
		tree = (int*)calloc(size * 2, sizeof(int));
		for (int idx = 1; idx < size * 2; idx++)
			tree[idx] = initVal;
	}

	void clear() { free(tree); }

	int decideValue(int x, int y) // Write your function
	{
		return x > y ? x : y;
	}

	void insert(int val, int idx)
	{
		tree[size + idx] = val;
		idx = (idx + size) / 2;
		while (idx)
		{
			tree[idx] = decideValue(tree[idx * 2], tree[idx * 2 + 1]);
			idx /= 2;
		}
	}

	int getValue(int left, int right)
	{
		if (right < left)
			return initVal;
		int ret = initVal;
		left += size;
		right += size;
		while (left <= right)
		{
			if (left % 2 == 1) ret = decideValue(ret, tree[left]);
			if (right % 2 == 0) ret = decideValue(ret, tree[right]);
			left = (left + 1) / 2;
			right = (right - 1) / 2;
		}
		return ret;
	}

	void printTree()
	{
		for (int jump = 2, idx = 1; idx < 2 * size; idx++)
		{
			printf("%d ", tree[idx]);
			if (idx == jump - 1)
			{
				jump *= 2;
				printf("\n");
			}
		}
	}
};

int main()
{
	int n;
	scanf("%d", &n);

	std::vector<int> a(n);
	std::vector<PII> d(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		d[i].first = a[i];
		d[i].second = -i;
	}

	std::sort(d.begin(), d.end());

	std::unordered_map<int, int> h;
	for (int i = 0; i < n; i++)
		h[-d[i].second] = i;

	BinaryTree b(n, 0);
	int c = 0;
	for (int i = 0; i < n; i++)
	{
		int p = h[i];
		int m = b.getValue(0, p - 1);
		if (m == 0) c++;
		else b.insert(0, m - 1);
		b.insert(p + 1, p);
		//b.printTree();
	}

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

	return 0;
}



Measured memory_bytes: 6564
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#define show(...) cerr << #__VA_ARGS__ << " = ",debug(__VA_ARGS__);
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T, typename S>
ostream &operator<<(ostream &os,pair<T,S>a){
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, vector<T> v){
    for(auto x:v)os << x << ' ';
    return os;
}
void debug(){cerr << '\n';}
template<typename H, typename... T>
void debug(H a, T... b){
    cerr << a;
    if(sizeof...(b))cerr << ", ";
    debug(b...);
}
int main(){
    int a,b,k;
    cin >>a >> b >> k;
    int ans = min(a,b);
    while(1){
        if(a % ans == 0 and b % ans == 0)k--;
        if(k==0){
            cout << ans << endl;
            return 0;
        }
        ans--;
    }
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}


fn main(){
    let line = read_as_vec::<usize>();

    let (n, t) = (line[0], line[1]);

    let mut dishes = vec![];

    for _ in 0..n{
        let line = read_as_vec::<usize>();
        dishes.push((line[0], line[1] as u64));
    }

    dishes.sort();

    let mut dp: Vec<Vec<u64>> = vec![vec![0;t+3000];n];

    if dishes[0].0 < t+3000{
        dp[0][dishes[0].0] = dishes[0].1;
    }

    for i in 1..n{
        for j in 0..t{
            //not eat dish[i]
            dp[i][j] = cmp::max(dp[i][j], dp[i-1][j]);

            //eat dish[i] if it finishes in t-1
            if j + dishes[i].0 < t+3000{
                dp[i][j + dishes[i].0] = cmp::max(dp[i][j + dishes[i].0], dp[i-1][j] + dishes[i].1);
            }
        }
    }

    let mut ans: u64 = *dp[n-1].iter().max().unwrap();

    for i in 0..n{
        for j in t..t+3000{
            ans = cmp::max(ans, dp[i][j]);
        }
    }
    println!("{}", ans);

}


Measured memory_bytes: 166140
from math import *
n,h=map(int,input().split())
a=[]
b=[]
for i in range(n):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
aa=max(a)
b.sort(reverse=True)
ans=0
for i in range(n):
    if b[i]>aa:
        h-=b[i]
        ans+=1
        if h<=0:
            print(ans)
            exit()
print(ans+ceil(h/aa))

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

int main(){
	int N, T;
	cin >> N >> T;
	int ans = 1001;
	int c, t;
	for(int i=0; i<N; i++){
		cin >> c >> t;
		if(t<=T && ans>c){
			ans = c;
		}
	}
	if(ans==1001){
		cout << "TLE" << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int a,b;
  int i = 1;
  scanf("%d %d", &a,&b);
  if(b == 1){
      i = 0;
  }else if(a > b){

  }else{
    while(a * i - i  + 1< b){
        i++;
    }
  }
  printf("%d\n", i);
  return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//


ll solve(int N,string& s1,string& s2) {
    vector<int> a;
    for (int i=0; i<N; ) {
        if (s1[i] == s2[i]) {
            a.pb(1);
            ++i;
        } else {
            a.pb(2);
            i+=2;
        }
    }

    int M = a.size();
    ll pat = (a[0] == 1)? 3 : 6; // 3C1 x 1!, 3C2 x 2!
    for (int i=1; i<M; ++i) {
        if (a[i-1] == 1) {
            if (a[i] == 1) {
                // 1 - 1 他の色ならOK
                pat = MUL(pat, 2); // 2C1 x 1!
            } else {
                // 1 - 2
                pat = MUL(pat, 2); // 2C2 x 2!
            }
        } else {
            if (a[i] == 1) {
                // 2 - 1
                pat = pat; // 3C1 x 1!
            } else {
                // 2 - 2
                pat = MUL(pat, 3); // 3C2x2! - 1 - 2
            }
        }
    }
    return pat;
}

int main() {
    int N;string s1,s2;
    cin>>N>>s1>>s2;
    cout << solve(N,s1,s2) << endl;
    // cout << (solve(N,a) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	//a,b?????£?¨?
	int a,b;
	//a,b?????????????????????
	scanf("%d",&a);
	scanf("%d",&b);
	//?¨??????????
	int x=a*b;
    int	y=2*(a+b);
	//????????????
	printf("%d ",x);
	printf("%d\n",y);
	
	return 0;
}

Measured memory_bytes: 2684
/*
 *  stay hungry, stay foolish, stay home.
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define ml cout<<"\n"
 
#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define in insert
#define ff first
#define ss second
#define mod 1000000007

#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	ios_base::sync_with_stdio(false);
     	cin.tie(NULL);
    	cout.tie(NULL);    
	long double n;
	cin>>n;
	
	long double p = ((long double)22 / 7 ) * 2 * n;
	cout<<fixed<<setprecision(20)<<p<<endl;
	return 0;
}

Measured memory_bytes: 3812