akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size()) {
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] T = new int[N];
		int total = 0;
		for(int i = 0;i<N; i++){
			T[i] = scan.nextInt();
			total += T[i];
		}
		int M = scan.nextInt();
		int[] P = new int[M];
		int[] X = new int[M];
		for(int i = 0;i<M;i++){
			P[i] = scan.nextInt();
		    X[i] = scan.nextInt();
		}
		for(int i = 0;i<M;i++){
			System.out.println(total + X[i] - T[P[i]-1]);
		}
		
		
		
	}
	

}

Measured memory_bytes: 10188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define INF 1e9

double H[1010];

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

    double N, T, A;
    cin >> N >> T >> A;
    REP(i, N) cin >> H[i+1];

    double sub = 1e9;
    int ans = 0;
    REP(i, N) {
        double t = (double)(T - H[i+1]*0.006);
        if (abs(t-A) < sub) {
            sub = abs(t-A);
            ans = i+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from math import factorial
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def MS(): return map(str, input().split())


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = False
show_flg = True

def digsum(n):
    s = 0
    while n:
        s += n % 10
        n //= 10
    return s


def main():
    N, M = MI()
    s = [0] * M
    c = [0] * M
    d = [-1] * N
    d_list = [[] for i in range(N)]

    for i in range(M):
        s[i], c[i] = MI()
        d[s[i] - 1] = c[i]
        if len(d_list[s[i] - 1]) == 0 or d_list[s[i] - 1][-1] != c[i]:
            d_list[s[i] - 1].append(c[i])

    # print(*d)
    # print(d_list)
    for i in range(N):
        if len(d_list[i]) > 1:
            print(-1)
            return

    if len(d) > 1 and d[0] == 0:
        print(-1)
        return

    if len(d) == 1 and d[0] == -1:
        print(0)
        return

    for i in range(N):
        if d[i] == -1 and i == 0:
            d[i] = 1
        elif d[i] == -1:
            d[i] = 0

    print(''.join([str(i) for i in d]))


if __name__ == '__main__':
    main()


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  

bool findNum(ll x[20][10], int y, int z, int& rest, ll& ans)
{
   if(rest <= x[z][y])
   {
     ans = ans * 10 + y;
     return true;
   }
  else
  {
    rest -= x[z][y];
    return false;
  }
}

int main()
{
  ll k;
  cin >> k;
  ll x[20][10];
  int fz,fy;
  bool rflg = false;
  rep(z, 20)
  {
    ll sum;
    rep(y, 10)
    {
      if(z == 0)
      {
      	x[z][y] = 1;
      }
      else
      {
        ll tmp = 0;
        if(y >= 1) tmp += x[z-1][y-1];
        tmp += x[z-1][y];
        if(y <= 8) tmp += x[z-1][y+1];
        
        x[z][y] = tmp;
      }
//cout << x[z][y] << " ";
      if(y != 0)
      {
//cout << "test:" << z << " " << y << " " << x[z][y] << endl;
        if(x[z][y] >= k)
        {
          fz = z;
          fy = y;
//cout << endl;
          rflg = true;
          break;
        }
        else
        {
          k = k - x[z][y];
        }
      }
    }
    if(rflg)
    {
      break;
    }
  }
//cout << "fz = " << fz << " " << fy << endl;
  ll ans = fy;
  int rest = k;
  for(int rz = fz - 1; rz >= 0; rz--)
  {
    bool isFind = false;
//cout << "llop = " << rz << " " << fy << " " << rest << " " << ans << endl;
    if(fy >= 1)
    {
       isFind = findNum(x, fy - 1, rz, rest, ans);
      if(isFind) fy = fy - 1;
//cout << "llop1 = " << rz << " " << fy << " " << rest << " " << ans << endl;
    }
    if(!isFind)
    {
      isFind = findNum(x, fy, rz, rest, ans);
//cout << "llop2 = " << rz << " " << fy << " " << rest << " " << ans << endl;
    }
    if(fy <= 8 && !isFind)
    {
      isFind = findNum(x, fy + 1, rz, rest, ans);
      if(isFind) fy = fy + 1;
//cout << "llop3 = " << rz << " " << fy << " " << rest << " " << ans << endl;    
    }
  }
  
  cout << fixed << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma region template

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

// -type-
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vpii = vector<pii>;
using vpll = vector<pll>;


// -const-
const ll MOD = 1000000007;

const ll INF = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define repsr(i, k, n) \
    for (int i = int(n) - 1, i##_len = (k); i >= i##_len; --i)
#define repr(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(...) debug_args(__LINE__, __VA_ARGS__)


// clang-format off
// -functions-
inline bool in(string s, string c) {return (s.find(c) != string::npos);}
inline bool in(string s,   char c) {return (s.find(c) != string::npos);}

template <class T> T udiv(T a, T b) {return (a + b - 1) / b;}
template <class T> T rdiv(T a, T b) {return (a + b / 2) / b;}

void print_args(ostream&) {}
template <class S, class... T>
void print_args(ostream& out,const S& a,const T&... args) {
    out << ' ' << a;
    print_args(out, args...);
}
template <class S, class... T>
void print(const S& a, const T&... args) {
    std::cout << a;
    print_args(std::cout, args...);
    std::cout << '\n';
}
template <class S, class... T>
void debug_args(const S& a, const T&... args) {
    std::cout << "(L:" << std::setw(3) << a << ")";
    print_args(std::cout, args...);
    std::cout << '\n';
}
// clang-format on

struct setup_main {
    setup_main() {
        std::cin.tie(0);
        std::ios::sync_with_stdio(0);
        std::cout << fixed << setprecision(15);
    }
} setup_main_;

ll ans = 0;
#pragma endregion

void solve(long long N, long long K, std::vector<int> h) {
    vi dp(N, int(INF));

    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    reps(i, 2, N) {
        int n = int(INF);
        reps(ki, 1, K + 1) {
            if (i - ki < 0) continue;
            n = min(n, (dp[i - ki] + abs(h[i] - h[i - ki])));
        }

        // int n2 = dp[i - 2] + abs(h[i] - h[i - 2]);
        dp[i] = n;
    }
    print(dp[N - 1]);
}
signed main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<int> h(N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &h[i]);
    }
    solve(N, K, std::move(h));

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#define int long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define FOR(i,a,b)  for(int i = (a); i < (b); ++i)

using namespace std;
const int MOD = 10e9+7;
const int INF = 1LL << 60;
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  

signed main (){
   int N;
   cin >> N;
   int h[N];
   int dp[100010];
   for(int i = 0; i < N; i++) 
   {
       cin >> h[i];
   }
   fill(dp,dp+N,INF); 
   dp[0] = 0;
   REP(i,N){
       if(i+1 < N) chmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
       if(i+2 < N) chmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
   }
   cout << dp[N-1] <<endl;
}


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

class UnionFind {
public:
    vector<int> uni;
    UnionFind(int s) : uni(s, -1) {}
    int root(int a) {
        return uni[a] < 0 ? a : uni[a] = root(uni[a]);
    }
    bool connect(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] = uni[a] + uni[b];
        uni[b] = a;
        return true;
    }
    bool isConnect(int a, int b) {
        return root(a) == root(b);
    }
    int size(int a) {
        return -uni[root(a)];
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf.connect(a, b);
    }
    set<int> st;
    rep(i, N) st.insert(uf.root(i));
    int mx = 0;
    rep(i, N) mx = max(mx, uf.size(i));
    cout << mx << '\n';
    return 0;
}


Measured memory_bytes: 13488
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	fastio();
	int n;
	string s;
	cin >> n >> s;
	map<char, int> m;
	int ans = 0;
	for (int i = 0; i < s.length(); ++i) {
		map<char, int> temp;
		m[s[i]]++;
		for (int j = i + 1; j < s.length(); ++j) {
			temp[s[j]] ++;
		}

		int sum = 0;
		for (auto i : m) {
			if (m[i.first] && temp[i.first]) {
				sum++;
			}
		}
		ans = max(sum, ans);
	}

	cout << ans << endl;
	sp;
}

Measured memory_bytes: 504
fun main(args: Array<String>) {
    val s = readLine()!!.toString()
    val n = s.length
    var sum = 0
    var before = ""
    var now = ""
    var i = 0
    while (i in 0 until n) {
        now += s[i]
        if (now != before) {
            sum++
            before = now
            now = ""
        }
        i++
    }
    println(sum)
}

Measured memory_bytes: 40060
#include <stdio.h>

int main(void){
	int n;
	int f=0;
	scanf("%d",&n);
	while(n>0){
		if(n%10==7){
			f=1;
		}
		n/=10;
	}
	if(f==1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1620
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>
#include <sstream>

int64_t N, L;
char direc[100][10];
int64_t posion[100];
int64_t posionnow[201];
int64_t H, h, m, s;
std::stringstream sssss;

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

void solve() {

	const int64_t MULMUL = 20 * H * 360;
	//int64_t hdeg = 2 * h;
	//int64_t mdeg = 2 * H * m;
	//int64_t sdeg = 20 * H * 6 * s;
	int64_t hdeg = 20 * 360 * h + 2 * 60 * m + 2 * s;
	int64_t mdeg = 20 * H * 6 * m + 2 * H * s;
	int64_t sdeg = 20 * H * 6 * s;

	int64_t rotate_sum = 0;
	while (true)
	{

		sdeg -= hdeg;
		if (sdeg < 0) {
			sdeg += MULMUL;
		}
		mdeg -= hdeg;
		if (mdeg < 0) {
			mdeg += MULMUL;
		}
		rotate_sum += hdeg;
		hdeg = 0;

		int64_t mid1 = mdeg / 2;
		int64_t mid2 = mid1 + MULMUL / 2;
		int64_t mid = mid1;
		int64_t midsend = mid2;
		if (mid1 < sdeg && sdeg <= mid2) {
			mid = mid2;
			midsend = mid1;
		}

		if (mid < sdeg) {
			mid += MULMUL;
		}
		if (midsend < sdeg) {
			midsend += MULMUL;
		}
		int64_t timedown = (20 * H * 6 - (H + 1));
		int64_t time20H = (mid - sdeg);
		if ((mdeg* timedown + 2 * H * time20H)% (MULMUL* timedown) == (2 * time20H) % (MULMUL * timedown)){

			timedown = (20 * H * 6 - (H + 1));
			time20H = (midsend - sdeg);
			if ((mdeg * timedown + 2 * H * time20H) % (MULMUL * timedown) == (2 * time20H) % (MULMUL * timedown)) {
				assert(false);
			}
		}

		hdeg += 2 * time20H / timedown;
		hdeg += rotate_sum; hdeg %= MULMUL;
		mdeg += 2 * H * time20H / timedown;
		mdeg += rotate_sum; mdeg %= MULMUL;
		sdeg += rotate_sum; sdeg %= MULMUL;

		using namespace std;
		//assert(hdeg % (20 * 360) == 0);
		//assert(mdeg % (20 * H * 6) == 0);
		int64_t sup = (sdeg * timedown + 6*20*H* time20H) % (MULMUL * timedown);
		int64_t sdown = 20 * H * 6 * timedown;
		int64_t ggg = gcd(sup, sdown);

		sssss
			<< hdeg / (20 * 360) << ' '
			<< mdeg / (20 * H * 6) << ' '
			<< sup / ggg		 << ' '
			<< sdown / ggg		
			<< '\n';

		break;
	}
}
int main()
{
	using namespace std;

	while (true)
	{
		cin >> H >> h >> m >> s;

		if (H == 0 && h == 0 && m == 0 && s == 0) {
			break;
		}
		solve();
	}
	cout << sssss.str();
	return 0;

}


Measured memory_bytes: 3156
#include <iostream>
#define SM 3005
using namespace std;
long long n, a[SM], F[SM][SM][3];
long Try(long L, long R, int x)
    {
        if (L>R) return 0;
        if (F[L][R][x]!=0) return F[L][R][x];
        if(x==1)
        {
            F[L][R][x]=Try(L+1,R,(x+1)%2)+a[L];
            F[L][R][x]=max(F[L][R][x],Try(L,R-1,(x+1)%2)+a[R]);
        }
        else
        {
            F[L][R][x]=Try(L+1,R,(x+1)%2)-a[L];
            F[L][R][x]=min(F[L][R][x],Try(L,R-1,(x+1)%2)-a[R]);
        }
        return F[L][R][x];
    }
int main()
    {
        long long i,j,x;
        cin>>n;
        for (i=1;i<=n;++i) cin>>a[i];
        cout<<Try(1,n,1);
        return 0;
    }


Measured memory_bytes: 120436
#include<bits/stdc++.h>
using namespace std;
#define task "atcoder"
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; --i)
#define BIT(x, i) (((x) >> (i)) & 1)
#define lb lower_bound
#define ub upper_bound
#define lla(v) (v).begin(),(v).end()
#define zs(v) int((v).size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ar array
#define endl '\n'
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007; /// 998244353
const int base=311;
const int N=1e3+5;

int n,m,f[N][N];
string s[1005];
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int good(int u, int v)
{
    return (u>=1&&u<=n&&v>=1&&v<=m);
}
void bfs(int x, int y)
{
    priority_queue<ar<int,3>,vector<ar<int,3>>,greater<ar<int,3>>> q;
    for(int i=1;i<=n;++i)
    for(int j=1;j<=m;++j) f[i][j]=1e9;
    f[x][y]=0;
    q.push({f[x][y],x,y});
    while(zs(q))
    {
        ar<int,3> p=q.top(); q.pop();
        int x=p[1],y=p[2],len=p[0];
        if(f[x][y]<len) continue;
        for(int i=0;i<4;++i)
        {
            int u=x+dx[i],v=y+dy[i];
            if(!good(u,v)||s[u][v]=='#') continue;
            if(f[u][v]>f[x][y])
            {
                f[u][v]=f[x][y];
                q.push({f[u][v],u,v});
            }
        }
        for(int u=x-2;u<=x+2;++u)
        for(int v=y-2;v<=y+2;++v)
        {
            if(!good(u,v)||s[u][v]=='#') continue;
            if(f[u][v]>f[x][y]+1)
            {
                f[u][v]=f[x][y]+1;
                q.push({f[u][v],u,v});
            }
        }
    }
}
void solved()
{
    int u,v,x,y;
    cin>>n>>m>>u>>v>>x>>y;
    for(int i=1;i<=n;++i)
    {
        cin>>s[i];
        s[i]=' '+s[i];
    }
    bfs(u,v);
    if(f[x][y]==1e9) cout<<-1;
    else cout<<f[x][y];
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    solved();
}










Measured memory_bytes: 8608
#include<iostream>
#include<cstdio>

using namespace std;

int n,s,cnt;

void solve(int now, int sum, int dep){
	if(sum==s&&dep==n){
		cnt++;
		return;
	}
	else if(sum>s||dep>n) return;
	else{
		for(int i=now+1;i<10;i++){
			solve(i,sum+i,dep+1);
		}
	}
}

int main(){
	while(scanf("%d %d",&n,&s)){
		if(n==0&&s==0)
		break;
		cnt=0;
		for(int i=0;i<10;i++){
			solve(i,i,1);
		}
		printf("%d\n",cnt);
	}
}

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

string d[4] = {"dream","dreamer","erase","eraser"};

int main() {
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  for(int i=0; i<4; i++) reverse(d[i].begin(),d[i].end());
  
  bool j1 = true;
  for(int i=0; i<s.size();){
    bool j2 = false;
    for(int j=0; j<4; j++){
      string t = d[j];
      if(s.substr(i,t.size()) == t){
        j2 = true;
        i += t.size();
      }
    }
    if(!j2){
      j1 = false;
      break;
    }
  }
  if(j1) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <cmath>
#include <iostream>
using namespace std;
using ll = long long;

int f(int a,int b){
    return max(to_string(a).size(),to_string(b).size());
}
int main(){
    ll n;
    cin >> n;
    int ans = to_string(n).size();
    for(ll a = 1LL; a*a <= n; a++){
        if(n%a != 0) continue;
        const ll b = n / a;
        ans = min(ans, f(a,b));
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1e18+1;

signed main() {
	int n, c;
	cin >> n >> c;

	int x[100001], v[100001];
	vector<int> r;
	int sum = 0;
	for ( int i = 0; i < n; i++ ) {
		cin >> x[i] >> v[i];
		sum += v[i];
	}

	int ans = 0;
	int s = 0;

	int ma[100001] = {0};
	for ( int i = n-1; i >= 0; i-- ) {
		s += v[i];
		ma[i] = max(ma[i+1], s-(c-x[i]));
	}

	s = 0;
	for ( int i = 0; i < n; i++ ) {
		s += v[i];
		ans = max(ans, s-(x[i]));
		ans = max(ans, s-(2*x[i]) + ma[i+1]);
	}

	for ( int i = 0; i < 100000; i++ ) ma[i] = 0;
	s = 0;
	
	for ( int i = 0; i < n; i++ ) {
		s += v[i];
		if ( i == 0 ) ma[i] = s-x[i];		
		else ma[i] = max(ma[i-1], s-x[i]);
	}
 
	s = 0;
	for ( int i = n-1; i >= 1; i-- ) {
		s += v[i];
		ans = max(ans, s-(c-x[i]));
		ans = max(ans, s-(2*(c-x[i])) + ma[i-1]);
	}
	

	ans = max(ans, sum-(c-(c-x[n-1])));
	ans = max(ans, sum-(c-x[0]));
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<ll> a;
    rep(i, 3){
        ll inp;
        cin >> inp;
        a.pb(inp);
    }
    sort(all(a));
    
    cout << a[2] - a[0] << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 764
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    D = [0] * (N+1)
    for i in range(1, N+1):
        D[i] = i*(i+1)//2

    index = bisect_left(D, N)
    if N != D[index]:
        print("No")
    else:
        print("Yes")
        print(index+1)
        D2 = Init(index+1, index,0)
        D2[0] = [i for i in range(1, index+1)]
        num = index
        for i in range(1, index+1):
            for j in range(i):
                D2[i][j] = D2[j][i-1]
            for k in range(j+1, index):
                num += 1
                D2[i][k] = num
        for temp in D2:
            temp = [index]+temp
            temp = [str(i) for i in temp]
            print(" ".join(temp))

if __name__ == "__main__":
    main()

Measured memory_bytes: 71700
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;
const long long MINF = LLONG_MIN;

// -------------------------------------------------------

string S;

int main() {
  cin >> S;
  int ans = 0;

  int len = S.size();
  if (len % 2 == 1) {
    int mid = len / 2;
    char midc = S[mid];
    int ii = len / 2;
    repe(i, 0, len / 2) {
      if (S[mid - i] != midc || S[mid + i] != midc) {
        ii = i - 1;
        break;
      }
    }
    ans = mid + ii + 1;
  } else {
    int mid = len / 2;
    char midc = S[mid];
    if (midc != S[mid - 1]) {
      ans = 1;
    } else {
      int ii = len / 2 - 1;
      repe(i, 0, len / 2 - 1) {
        if (S[mid - 1 - i] != midc || S[mid + i] != midc) {
          ii = i - 1;
          break;
        }
      }
      ans = mid + ii + 1;
    }
  }

  int ans2 = 0;
  if (len % 2 == 1) {
    ans2 = len / 2 + 1;
  } else {
    ans2 = len / 2;
  }

  cout << max(ans, ans2);
}


Measured memory_bytes: 3748
#include <iostream>

using namespace std;

int main(void)
{
    int H, W;

    cin >> H >> W;

    while ((H != 0) || (W != 0))
    {
        for (int i=0; i<H; i++)
        {
            for (int j=0; j<W; j++)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
}


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

using namespace std;

long long p[500005];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s;
	long long n, sum = 0;
	cin >> s;
	p[0] = 0;
	n = s.size() + 1;
	for(long long i = 0; i < n - 1; ++i){
		if(s[i] == '<') p[i + 1] = max(p[i + 1], p[i] + 1);
	}
//	for(long long i = 0; i < n; ++i) cout << p[i];
//	cout << endl;
	for(long long i = n - 2; i >= 0; --i){
		if(s[i] == '>') p[i] = max(p[i], p[i + 1] + 1);
	}
	for(long long i = 0; i < n; ++i) sum += p[i];
//	for(long long i = 0; i < n; ++i) cout << p[i];
//	cout << endl;
	cout << sum;

	return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll N; cin >> N;
    ll a[100];
    ll cnt = 0;
    for (int i = 0;i < N;i++){
        cin >> a[i];
        if(a[i] != i+1) cnt++;
    }

    if(cnt <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {
	long long  a = 6;
	while (cin >> a&&a != 0) {
		long long sum = 1,a2=a;
		int i = 2;
		while (a != 1) {
			if (a%i == 0) {
				int j = 1;
				long long sum2 = 1;
				while (a%i == 0) {
					sum2 += (pow(i, j));
					j++;
					a /= i;
				}
				sum *= sum2;
			}
			if(i==2)
				i++;
			else i += 2;
		}
		sum -= a2;
		if (a2 == sum) cout << "perfect number" << endl;
		else if (a2 > sum) cout << "deficient number" << endl;
		else cout << "abundant number" << endl;
	}
}

Measured memory_bytes: 3200
a=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 1/h+1/n>=4/a:continue
        w=(a*h*n)/(4*h*n-a*n-a*h)
        if w==int(w):
            print(h,n,int(w))
            exit()

Measured memory_bytes: 3060
import sys
import os

def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    a = int(sys.stdin.buffer.readline().decode().rstrip())
    s = sys.stdin.buffer.readline().decode().rstrip()

    if a >= 3200:
        print(s)
    else:
        print("red")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(){
  int x,y;
  cin >> x >> y;
  if (x%y==0) {
    cout << -1;
  } else {
    cout << x;
  }
  return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (5006)
ll n,A[MAXN],dp[MAXN][MAXN],sz[MAXN];// if 0 then max, 1 then min
bitset<MAXN> dp2[MAXN];
vector<int>v[MAXN];
void dfs(ll x,ll p){
	sz[x]=1;
	dp[x][0]=A[x];
	for(auto i:v[x]) if(i^p) dfs(i,x), sz[x]+=sz[i];
	FOR(k,1,sz[x]) dp[x][k]=LLINF;
	ll cur = 1;
	if(A[x]>0)dp2[x][0]=1;
	for(auto i:v[x]) if(i^p) {
		cur += sz[i];
		DEC(j,cur,0){
			if(dp[x][j]<LLINF) dp[x][j] += dp[i][0];
			dp2[x][j] = dp2[x][j] & dp2[i][0];
			FOR(k,max(j-(cur-sz[i]),1ll),min(j,sz[i])){
				dp[x][j]=min(dp[x][j],dp[x][j-k]+dp[i][k]);
				if(dp2[i][k-1]) dp[x][j]=min(dp[x][j],dp[x][j-k]);
				dp2[x][j]=dp2[x][j]|(dp2[x][j-k]&dp2[i][k]);
				if(dp[i][k-1] < 0) dp2[x][j]=dp2[x][j]|dp2[x][j-k];
			}
		}
	}
}
int main(){
	FAST
	cin>>n;
	FOR(i,1,n)cin>>A[i];
	FOR(i,2,n){
		ll a,b;cin>>a>>b;
		v[a].eb(b),v[b].eb(a);
	}
	dfs(1,1);
	ll ans = n-1;
	FOR(k,0,n-1) if(dp[1][k] < 0) ans = min(ans, k);
	FOR(k,0,n-1) if(dp2[1][k]) ans = min(ans, k);
	cout<<ans<<'\n';
}



Measured memory_bytes: 199936
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
int n;
struct node{
	int l,r,id;
}a[maxn],b[maxn],c[maxn];
bool vis[maxn];
bool cmp1(const node &A,const node &B){
	return A.r<B.r;
}
bool cmp2(const node &A,const node &B){
	return A.l>B.l;
}
int Abs(int x){
	return x>0?x:-x;
}
long long solve(bool bo){
	memset(vis,0,sizeof(vis));
	int p=0,l1=1,l2=1;
	long long ans=0;
	while(1){
		if(bo){
			if(l2<=n&&vis[c[l2].id])
				l2++;
			if(l2>n) break;
			if(c[l2].l<=p) break;
			ans+=Abs(c[l2].l-p),p=c[l2].l;
			vis[c[l2].id]=1,l2++;
		}
		else{
			if(l1<=n&&vis[b[l1].id])
				l1++;
			if(l1>n) break;
			if(b[l1].r>=p) break;
			ans+=Abs(b[l1].r-p),p=b[l1].r;
			vis[b[l1].id]=1,l1++;
		}
		bo^=1;
	}
	ans+=Abs(p);
	return ans;
}
int main(){
//	freopen("C.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].l,&a[i].r);
		a[i].id=i;
	}
	for(int i=1;i<=n;i++)
		c[i]=a[i],b[i]=a[i];
	sort(b+1,b+n+1,cmp1);
	sort(c+1,c+n+1,cmp2);
	long long ans1=solve(0),ans2=solve(1);
	printf("%lld\n",ans1>ans2?ans1:ans2);
	return 0;
}


Measured memory_bytes: 3840
def sosu(n):
    if n<2:
        return False
    if n==2:
        return True

    if n%2==0:
        return False
    
    for i in range(3,int(n**0.5+1),2):
        if n%i==0:
            return False

    return True
    
n=int(input())
j=0

for i in range(n):
    k=int(input())
    if sosu(k):
        j+=1

print(j)


Measured memory_bytes: 5668
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rep(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define forn(i,n,m) for(int (i)=(n);i<=(int)(m);(i)++)
#define pb push_back
#define mp make_pair
#define re return
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF=1e9;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef queue <int> qi;
int a,b,c; 
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int w, a, b, dis;
    cin >> w >> a >> b;

    if(a<b)
      dis = max(0, b-(a+w));
    else
      dis = max(0, a-(b+w));
    cout << dis << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
struct card{
  char handle;
  int num;
};
void quicksort(struct card *,int,int);
int partition(struct card *,int,int);
void merge(struct card *,int,int,int);
void mergesort(struct card *,int,int);
int main(){
  int n,i;
  char dummy[10];
  struct card A[100000],c[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",dummy,&A[i].num);
    A[i].handle=dummy[0];
    c[i]=A[i];
  }
  mergesort(A,0,n);
  quicksort(c,0,n-1);
  int cnt=0;
  for(i=0;i<n;i++){
    if(A[i].handle!=c[i].handle){
      printf("Not stable\n");
      cnt++;
      break;
    }
  }
  if(cnt==0)printf("Stable\n");
  for(i=0;i<n;i++){
      printf("%c %d\n",c[i].handle,c[i].num);
  }
  return 0;
}
void quicksort(struct card *A,int p,int r){
  int q;
  if(p<r){
    q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}
int partition(struct card *A,int p,int r){
  int i,cnt=p-1,q;
  q=A[r].num;
  struct card j;
  for(i=p;i<r;i++){
    if(A[i].num<=q){
      cnt++;
      j=A[i];
      A[i]=A[cnt];
      A[cnt]=j;
    }
  }
  j=A[cnt+1];
  A[cnt+1]=A[r];
  A[r]=j;
  return cnt+1;
}
void mergesort(struct card *c,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(c,left,mid);
    mergesort(c,mid,right);
    merge(c,left,mid,right);
  }
}
void merge(struct card *c,int left,int mid,int right){
  int n1=mid-left,n2=right-mid;
  struct card *L,*R;
  L=malloc(sizeof(struct card)*(n1+2));
  R=malloc(sizeof(struct card)*(n2+2));
  int i;
  for(i=0;i<n1;i++)L[i]=c[i+left];
  for(i=0;i<n2;i++)R[i]=c[i+mid];
  L[n1].num=R[n2].num=2000000000;
  int j=0,k;
  i=0;
  for(k=left;k<right;k++){
    if(L[i].num<=R[j].num)c[k]=L[i++];
    else c[k]=R[j++];
  }
  free(L);
  free(R);
}




Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long ;

int main(){
    int n; cin >> n;
    vector<ll> a(n),asum(n);
    ll mod = 1000000007 ,sum = 0,ans = 0;
    for(int ix=0;ix<n;ix++){
        cin >> a.at(ix);
    }
    for(int ix=n-1;ix>0;ix--){
        sum += a.at(ix);
        sum %= mod;
        asum.at(ix-1) = sum;
    }
    asum.at(n-1) = 0;
    for(int ix=0;ix<n;ix++){
        ans += a.at(ix)*asum.at(ix);
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6424
N,M=map(int,input().split())
LA=list(map(int,input().split()))
L=[]
for i in LA:
    L.extend([[1,i]])
for m in range(M):
    B,C=map(int,input().split())
    L.extend([[B,C]])
L.sort(key=lambda _:_[1] ,reverse=True)

ans=0
n=0
x=0
while x<=N-1:
    y=0
    while y<=L[n][0]-1:
        ans+=L[n][1]
        y+=1
        x+=1
        if x==N:
            break
        else:
            pass
    n+=1

print(ans)

Measured memory_bytes: 37764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;


int main(){
   int a;
   string s;
   cin >> a >> s;
   if(a>=3200) out(s);
   else out("red");
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Main main = new Main();
		main.exec();

	}

	private void exec() {
		int n;
		int m;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		List<List<Integer>> jobs = new ArrayList<>(m);
		for(int i = 0 ; i < m ; i++) {
			jobs.add(new ArrayList<>());
		}
		int a;
		int b;
		for(int i = 0 ; i < n ; i++) {
			a = sc.nextInt();
			b = sc.nextInt();
			if(m < a) {
				continue;
			}
			List<Integer> vList = jobs.get(m - a);
			if(vList == null) {
				vList = new ArrayList<>();
			}
			vList.add(b);
		}

		long value = 0;
		PriorityQueue<Integer> q = new PriorityQueue<>(new Comparator<Integer>() {

			@Override
			public int compare(Integer o1, Integer o2) {
				return o2 - o1;
			}

		});
		for(int i = m - 1 ; i >= 0 ; i--) {
			for(Integer v : jobs.get(i)) {
				q.add(v);
			}
			if(!q.isEmpty()) {
				value += q.poll();
			}
		}
		System.out.println(value);
		sc.close();
	}

}


Measured memory_bytes: 99424
#include<iostream>
#include<climits>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb         push_back
#define mp         make_pair
#define ALL(C)     (C).begin(),(C).end()


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

int vis[50][50];
char m[50][50];


void dfs(int r,int c,int y,int x,int now){
  if(((1<<now)&vis[y][x]) != 0)return;
  vis[y][x]|=(1<<now);
  rep(i,4){
    int nex=x+dx[i],ney=y+dy[i];
    if (nex==-1||nex==c||ney==r||ney==-1||m[ney][nex]!='.')continue;
    dfs(r,c,ney,nex,now);
  }
}

void solve(int r,int c){
  rep(i,r){
    rep(j,c){
      vis[i][j]=0;
    }
  }
   
  rep(i,r){
    rep(j,c){
      if (m[i][j] == 'B'){
	dfs(r,c,i,j,0);
      }else if (m[i][j] == 'W'){
	dfs(r,c,i,j,1);
      }
    }
  }

  int w=0,b=0;
  rep(i,r){
    rep(j,c){
      if (m[i][j] != '.')continue;
      if (vis[i][j] == 1)b++;
      else if (vis[i][j]==2)w++;
    }
  }
  cout << b << " " << w << endl;
}

main(){
  int r,c;
  while(cin>>c>>r && c){
    rep(i,r){
      rep(j,c)cin>>m[i][j];
    }
    solve(r,c);
  }
}

Measured memory_bytes: 0
//#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)

int main()
{
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
    
    return 0;
}

Measured memory_bytes: 3636
S=list(input())
n=len(S)

S.reverse()
putl=["dream","dreamer","erase","eraser"]
for i in range(4):
  tempstr=putl[i]
  putl[i]=tempstr[::-1]
#print(putl)
pos=0
can=True
while (pos < n):
  ifdivide=False
  for substr in putl:
    substr_size=len(substr)
    chk=S[pos:(pos+substr_size)]
    #print(chk)
    if chk==list(substr):
      ifdivide=True
      #print(chk)
      break
  if ifdivide:
    pos+=substr_size
  else:
    can=False
    break
if can:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}

int start = 3000;
long double memo[3020][6040];
vector<double> P;
int n;
long double dp(int at, int diff) {
    if(at >= n) {
        return diff < 3000;
    }
    if(memo[at][diff] > -0.5) return memo[at][diff];
    long double tots = dp(at+1, diff+1)*P[at] + dp(at+1,diff-1)*(1-P[at]);
    return memo[at][diff] = tots;
}

int main() {
    cin.sync_with_stdio(false);
    cin >> n;
    P = vector<double>(n);
    rep(i,0,n) cin >> P[i];
    rep(i,0,3020) rep(j,0,6040) memo[i][j] = -1;
    cout << setprecision(15) << fixed << (1.0-dp(0,start)) << endl;
    return 0;
}


Measured memory_bytes: 285568
#include <stdio.h>
#include <math.h>
 #define PI 3.14159265358979323846264338327950L

int main(void) {
 int a, b, h, m;
 scanf("%d%d%d%d", &a, &b, &h, &m);

long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b)* cosl(rad);

printf("%20.20Lf\n", sqrtl(rsq));
return 0;
}

Measured memory_bytes: 2508
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;

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

  ll n,m,v,p;
  std::cin>>n>>m>>v>>p;

  std::vector<ll> a(n);
  rep(i,0,n)std::cin>>a[i];
  std::sort(all(a));

  ll ok=0;

  rep(i,n-p+1,n)if(a[i]!=a[n-p])ok++;

  std::vector<ll> sum(n-p,0);

  for(ll i=n-p-2;i>=0;i--){
    sum[i]=sum[i+1]+a[n-p]-a[i+1];
  }

  ll left=-1,right=n-p;

  while(right-left>1){
    ll mid=left+(right-left)/2;

    if(a[mid]+m<a[n-p]){
      left=mid;
    }else{
      if(mid+1+ok>=v){
        right=mid;
      }else{
        if(m*(v-(mid+1+ok))<=sum[mid]+(a[mid]+m-a[n-p])*(n-ok-mid-1)){
          right=mid;
        }else{
          left=mid;
        }
      }
    }
  }

  std::cout<<n-right<<"\n";

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
typedef long long ll;
typedef priority_queue<int> pq;
double calc(int t, int x){
    return t - (x*0.006);
}
int main(void) {
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;
    double dis = 1000000.0;
    int memo = -1;
    for(int i = 0; i < N; i++){
        int h;
        cin >> h;
        if(dis > fabs(A - calc(T,h))){
            dis = fabs(A-calc(T,h));
            memo = i;
        }
    }
    cout << memo+1 << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

bool dfs(int a[],int anum,int bpre,int cpre,int p){
	int ret = 0;
	if(p == anum){
		return 1;
	}
	if(bpre == -1 || a[p] > bpre){
		ret += dfs(a,anum,a[p],cpre,p + 1);
	}
	if(cpre == -1 || a[p] > cpre){
		ret += dfs(a,anum,bpre,a[p],p + 1);
	}
	return ret;
}

bool solve(int a[]){
	return dfs(a,10,-1,-1,0);
}

int main(void){
	int n, i, j, a[10];
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		for(j = 0;j < 10;j++){
			scanf("%d",&a[j]);
		}
		if(solve(a)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1008
N = int(input())
to = [[] for _ in range(N)]

for i in range(N):
    a = list(map(int, input().split()))
    
    for j in range(N):
        if a[j]==1:
            to[i].append(j)
    
dp = [0]*(1<<N)
dp[0] = 1
MOD = 10**9+7

for i in range((1<<N)-1):
    c = 0
    
    for j in range(N):
        if (i>>j)&1:
            c += 1
    
    for j in to[c]:
        if not (i>>j)&1:
            dp[i|(1<<j)] += dp[i]
            dp[i|(1<<j)] %= MOD
    
print(dp[-1])

Measured memory_bytes: 59500
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll n;cin>>n;
    map<ll,ll> mp;
    string ans="No";
    REP(i,n){
        ll a;cin>>a;
        if (a%2==1) mp[1]++;
        if (a%4==0) mp[4]++;
        if (a%4!=0 && a%2==0) mp[2]++;
    }
    if (mp[4] >= n/2)  {
        cout<<"Yes"<<endl;
        return 0;
    }
    
    mp[1] -= mp[4];
    if (mp[1]==1 && mp[2]==0) {cout<<"Yes"<<endl; return 0;}
    else if(mp[1]==1)  {cout<<"No"<<endl; return 0;}
    else if(mp[1]>1) {cout<<"No"<<endl; return 0;}
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

class A {
	int a, b;
public:
	void solve()
	{
		if (a > b)
			std::cout << a - 1 << endl;
		else
			std::cout << a << endl;
	
	}
	A() { cin >> a >> b; }
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    final double EPS = 1.0e-10;
    final int INF = 1 << 28;

    void run() {
        Scanner sc = new Scanner(System.in);
        int cns[] = new int[101];
        int tns[] = new int[101];
        for (int i = 0; i < 101; i++) {
            cns[i] = i * i * i;
            tns[i] = i * (i + 1) * (i + 2) / 6;
        }
        while (true) {
            int f = sc.nextInt();
            if (f == 0)
                break;
            int max = 0;
            for (int i = 0; i < 100; i++) {
                for (int j = 0; j < 100; j++) {
                    if (tns[i] + cns[j] <= f)
                        max = Math.max(max, cns[j] + tns[i]);
                    else
                        break;
                }
            }
            System.out.println(max);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 12000