akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
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; }

map<string, int> cntmap;
vector<int> card(8, 0);
int dx[4] = {1, -1, 4, -4};

void bfs() {
    queue<string> que;
    string first = "01234567";
    que.push(first);
    cntmap[first] = 0;
    while(!que.empty()) {
        string now = que.front(); que.pop();
        int npos = 0;
        for(int i = 0; i < 8; ++i) if(now.at(i) == '0') npos = i;
        for(int i = 0; i < 4; ++i) {
            int nx = npos+dx[i];
            if(nx >= 0 && nx < 8 && !((npos == 3 || npos == 7) && i == 0) && !((npos == 0 || npos == 4) && i == 1)) {
                string ns = now;
                swap(ns.at(npos), ns.at(nx));
                if(cntmap[ns] == 0 && first != ns) {
                    cntmap[ns] = cntmap[now]+1;
                    que.push(ns);
                }
            }
        }
    }
}

int main() {
    bfs();
    while(cin >> card.at(0)) {
        for(int i = 1; i < 8; ++i) cin >> card.at(i);
        string ins;
        for(int i = 0; i < 8; ++i) ins.push_back(card.at(i) + '0');
        // cout << ins << endl;
        cout << cntmap[ins] << endl;
    }
}


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

void Main()
{
    int n, m;
    cin >> n >> m;
    auto ans = n==m ? "Yes" : "No";
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
    int n,w,x,j;
    scanf("%d%d%d",&n,&w,&x);
    memset(a,0,sizeof(a));
    for(int i=0;i<w;i++)
    {
        scanf("%d",&j);
        a[j]=1;
    }
    int s=0;
    for(int i=x;i<n;i++)
    {
        s+=a[i+1];
    }
    int ans=0;
    for(int i=0;i<x;i++)
    {
        ans+=a[i+1];
    }
    int k=min(ans,s);
    printf("%d\n",k);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if (n % 10 == 3)
        cout << "bon";
    else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
        cout << "pon";
    else
        cout << "hon";

    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static int mod = 10000000;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        long h = in.nextLong();
        System.out.println(Long.highestOneBit(h) * 2 - 1);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedInputStream reader = new BufferedInputStream(System.in);
    private byte[] buffer = new byte[0x10000];
    private int i = 0;
    private int length = 0;

    private int read() {
        if (i == length) {
            i = 0;
            try {
                length = reader.read(buffer);
            } catch (IOException ignored) {
            }
            if (length == -1) {
                return -1;
            }
        }
        return buffer[i++];
    }

    String next() {
        StringBuilder builder = new StringBuilder();
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        while ('!' <= b && b <= '~') {
            builder.appendCodePoint(b);
            b = read();
        }
        return builder.toString();
    }

    int nextInt() {
        return (int)nextLong();
    }

    long nextLong() {
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        int i = 0;
        if (b == '-') {
            i = 1;
            b = read();
        }
        long n = 0;
        while ('0' <= b && b <= '9') {
            n = n * 10 + b - '0';
            b = read();
        }
        return i == 0 ? n : -n;
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 22740
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        int h[] = new int[n + 1];
        int m[] = new int[n + 1];
        
        for(int i = 0; i < n; i++){
            h[i] = sc.nextInt();
            m[i] = 0;
        }
        
        int innCounter = 0;
        
        
        for(int idx = 0; idx < n; idx++){
            if(idx == 0){
                innCounter++;
            }else{
                for(int k = 0; k < idx; k++){
                    if(h[idx] < h[k]){
                        m[idx]++;
                    }else{
                        
                    }
                    
                }
                if(m[idx] == 0){
                    innCounter++;
                }
            }
            
        } 
        System.out.println(innCounter);
        
    }
}


Measured memory_bytes: 21844
n,a,b,c,d=map(int,input().split())
s=input()
x='Yes'
if '##' in s[a-1:c]:
  x='No'
elif '##' in s[b-1:d]:
  x='No'
elif c>d:
  if '...' not in s[b-2:d+1]:
    x='No'  
print(x)

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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int check = 0;
    while(a >= b) {
        b *= 2;
        check++;
    }
    while(b >= c) {
        c *= 2;
        check++;
    }
    if(check <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

struct UF{ //O(loga(n))
    int n;
    int m;
    vi d, r;
    UF(int n) : n(n), m(n), d(n, -1), r(n, 0){};
    int root(int i){
        if(d[i] < 0) return i;
        return d[i] = root(d[i]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    bool unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;

        if(r[x] < r[y]) swap(x, y);
        else if(r[x] == r[y]) r[x]++;
        d[x] += d[y];
        d[y] = x;
        --m;
        return true;
    }
    int size(int i){
        return -d[root(i)];
    }
    int size() {
        return m;
    }
};

int main(){
    ll n;
    cin >> n;
    vl x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    vl id(n);
    rep(i, n) id[i] = i;
    auto calc = [&](int i, int j) {
        return min(abs(x[i]-x[j]), abs(y[i] - y[j]));
    };
    using Edge = tuple<ll, int, int>;
    vector<Edge> es;
    sort(all(id), [&](int i, int j){return x[i] < x[j];});
    rep(i, n-1) es.emplace_back(calc(id[i], id[i+1]), id[i], id[i+1]);
    sort(all(id), [&](int i, int j){return y[i] < y[j];});
    rep(i, n-1) es.emplace_back(calc(id[i], id[i+1]), id[i], id[i+1]);
    sort(all(es));
    UF uf(n);
    ll ans = 0;
    for(auto&& e:es) {
        ll x, y, z;
        tie(z, x, y) = e;
        if(uf.same(x, y)) continue;
        uf.unite(x, y);
        ans += z;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8816
#include <iostream>

 

using namespace std;

 

int main()
{
   int a, b,temp,i;
   for(i=1;i<=3000;i++)
   {
       cin>> a>> b;
       
       if(a==0&&b==0)
       break;
       
       if(a>b)
       {
           temp =a;
           a=b;
           b= temp;
       }
       cout<<a<<" "<<b << endl;
   }
   
}
     


Measured memory_bytes: 2996
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }
    ull operator"" _64u(unsigned long long x){ return ull(x); }

    template<class T>
    vector<T> make_vector(int n, T t){
        return vector<T>(n, t);
    }
    template<class ...Ts>
    auto make_vector(int n, Ts ... ts){
        return vector<decltype(make_vector(ts...))>(n, make_vector(ts...));
    }

    template<class T>
    ostream& operator<<(ostream& os, const vector<T>& v){
        for (auto &&x : v) { os << x << ' '; } cout << endl; return os ;
    }
}
using namespace utils;

class solver{
    istream& is;
    ostream& os;

public:
    solver(istream& I, ostream& O) :is(I), os(O) {}
    void run(){
        ll N;
        is >> N;
        if(!is) return;
        vector<ll> A(N), B(N-1, INF);
        for (auto &&b : B) {
            is >> b;
        } // end b
        A[0] = B[0];
        for (int i = 1; i < N-1; ++i) {
            A[i] = min(B[i], B[i-1]);
        } // end i
        A.back() = B.back();

        os << accumulate(ALL(A), 0ll) << endl;



    }
};

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_C.txt";
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int loop = 0;
    while(fs) {
        loop++;
        cout << '#' << loop << "#------\n";
        solver(fs, cout).run();
    }
    if(loop <= 1) {
        cout << "===" << endl;
        while(cin) solver(cin, cout).run();
    }
#else
    solver(cin, cout).run();
#endif
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int i, j;
    int n, q;
    long S[10000], T[10000];
    int count = 0;
    
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%ld", &S[i]);
    }
    scanf("%d", &q);
    for(i=0;i<q;i++){
        scanf("%ld", &T[i]);
    }
    
    for(i=0;i<q;i++){
        for(j=0;j<n;j++){
            if(T[i] == S[j]){
                count++;
                break;
            }
        }
    }
    printf("%d\n", count);
    
    return 0;
}

Measured memory_bytes: 684
a, b = gets.chomp.split(' ').map(&:to_i)

ta = (a / 0.08).floor
ta2 = ((a+1) / 0.08).floor
tb = (b / 0.10).floor
tb2 = ((b+1) / 0.10).floor

tmax = [ta2, tb2].min
tmin = [ta, tb].max
range = [*tmin..tmax]

range.each do |i|
  if (i * 0.08).floor == a && (i * 0.10).floor == b
    puts i
    exit
  end
end
puts '-1'

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string w;

const ll B[2] = {999983, 1000003};
const ll M[2] = {999999937, 1000000007};

ll H[2][500100];
ll pB[2][500100];

bool G[500100];
bool rG[500100];

bool uniq() {
    for (int i = 1; i < (int)w.size(); i++) {
        if (w[0] != w[i])
            return false;
    }
    return true;
}

// return hash[i, j]
pair<ll, ll> query(int i, int j) {
    return make_pair((H[0][j] - H[0][i-1]*pB[0][j-i+1]%M[0] + M[0]) % M[0],
                     (H[1][j] - H[1][i-1]*pB[1][j-i+1]%M[1] + M[1]) % M[1]);
}

void solve() {
    int L = (int)w.size();
    if (uniq()) {
        cout << L << endl;
        cout << 1 << endl;
        return;
    }
    
    for (int i = 0; i < 2; i++) {
        H[i][0] = 0;
        pB[i][0] = 1;
        for (int j = 1; j <= L; j++) {
            H[i][j] = (H[i][j-1] * B[i] + w[j-1]) % M[i];
            pB[i][j] = pB[i][j-1] * B[i] % M[i];
        }
    }
    
    memset(G, true, sizeof(G));
    memset(rG, true, sizeof(rG));
    for (int i = 1; i <= L; i++) {
        pair<ll, ll> v = query(1, i);
        for (int j = i+1; j+i-1 <= L; j+=i) {
            if (query(j, j+i-1) == v) {
                G[j+i-1] = false;
            } else {
                break;
            }
        }
    }
    for (int i = 1; i <= L; i++) {
        pair<ll, ll> v = query(L-i+1, L);
        for (int j = L-i; j-i+1 >= 1; j-=i) {
            if (query(j-i+1, j) == v) {
                rG[j-i+1] = false;
            } else {
                break;
            }
        }
    }
    
    if (G[L]) {
        cout << 1 << endl;
        cout << 1 << endl;
        return;
    }

    int res = 0;
    for (int i = 1; i < L; i++) {
        if (G[i] && rG[i+1])
            res++;
    }
    cout << 2 << endl;
    cout << res << endl;
}

void input() {
    cin >> w;
}

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

    input();
    solve();
}


Measured memory_bytes: 17564
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <vector>
using namespace std;

const int inf = 1e9;
const int mod = 1e9+7;

typedef pair<int, int> P;

int n, m;
bool visited[100];
bool AList[100][100];

void dfs(int u){
    visited[u] = true;
    for(int i=0; i<n; i++){
        if(AList[u][i] && !(visited[i]) ){
            dfs(i);
        }
    }
    return;
}

int main(void){
    int ans = 0;

    queue<pair<int, int> > que; 
    cin >> n >> m;

    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        AList[x][y] = true;
        AList[y][x] = true;
        que.push(P(x, y));
    }

    for(int i=0; i<m; i++){

        bool flag = true;
        fill(visited, visited+n, false);

        P p = que.front();
        que.pop();
        AList[p.first][p.second] = false;
        AList[p.second][p.first] = false;

        dfs(0);
        for(int j=0; j<n; j++){
            if(!(visited[j])){
                flag = false;
            }
        }

        if(!(flag) ){
            ans++;
        }

        AList[p.first][p.second] = true;
        AList[p.second][p.first] = true;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  char in1, in2;
  char tar = 'A';
  while(scanf("%c,%c", &in1, &in2) != EOF){
    if(tar == in1){
      tar = in2; 
    }else if(tar == in2){
      tar = in1;
    }

  } 

  //  printf("\n%c,%c\n", in1, in2);
  printf("%c\n", tar);
 
  return 0;
}

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

int main (void){
  
    int n;
    int x;
    int con[128];

    scanf("%d", &n);
    scanf("%d", &x);
    
    for(int i = 0; i < n; i++){
          scanf("%d", con+i);
    }

    int min = con[0];
    for(int i = 0; i < n; i++){
          x -= con[i];
          if(min > con[i])
            min = con[i];
    }

    printf("%d", x/min + n);

    return 0;   
}


Measured memory_bytes: 128
#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 <climits>
#include <ctime>
#include <cassert>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int
 
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))
 
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;
 
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
 
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;
 
namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n;
    while(cin >> n, n) {
        int m, inp;
        vector<int> p[110];
        rep(i,0,n) {
            cin >> m;
            rep(j,0,m) {
                cin >> inp;
                p[i].pb(inp);
            }
            sort(p[i].begin(), p[i].end());
        }
        int k; cin >> k;
        vector<int> l(k);
        rep(i,0,k) cin >> l[i];
        sort(l.begin(), l.end());
        
        int ans = -1;
        bool ok = true;
        rep(i,0,n) {
            int cnt = 0;
            rep(x,0,p[i].size()) {
                rep(j,0,k) {
                    if(p[i][x] == l[j]) cnt++;
                }
            }
            if(cnt == k) {
                if(ans == -1) ans = i+1;
                else ok = false;
            }
        }
        if(!ok) cout << -1 << endl;
        else cout << ans << endl;
    }
    return 0;
}

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

int main(void){
    int n;cin>>n;
    map<int, int> m;
    bool can=true;
    for(int i=0;i<n;i++){
        int tmp;cin>>tmp;
        m[tmp]++;
        if(m[tmp]>=2){can=false;break;}
    }
    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 9600
#include <cstdio>
int main()
{
  int ret, n, x;
  scanf("%d%d", &n, &x);
  
  int nl = 1, d = 0;
  for (int i = 0; i < n; i++){
    int leap;
    scanf("%d", &leap);
    d += leap;
    if ( d > x ) break;
    nl++;
    
  }
  printf("%d\n", nl);
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#define ll long long
using namespace std;

int main() {
	int n, m;
	while (cin >> n >> m) {
		string s;
		cin >> s;
		int a, b;
		int dp[200005];
		memset(dp, 0, sizeof(dp));
		for (int i = 1; i < s.length(); i++) {
			if (s[i] == 'C' && s[i - 1] == 'A') {
				dp[i] = dp[i - 1] + 1;
			}
			else {
				dp[i] = dp[i - 1];
			}
		}
		while (cin >> a >> b) {
			int count;
			count = dp[b - 1] - dp[a - 1];
			cout << count << endl;
		}
	}
}

Measured memory_bytes: 1792
def solve():
    N = int(input())
    x = []
    y = [] 

    if N == 1:
        print("1")
        return

    ans = float('inf')
    for i in range(N):
        input_x, input_y = map(int,input().split())
        x.append(input_x)
        y.append(input_y)

    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            p = x[i] - x[j]
            q = y[i] - y[j]

            sub = 0
            for i2 in range(N):
                for j2 in range(N):
                    if i2 == j2:
                        continue

                    if x[i2] - x[j2] == p and y[i2] - y[j2] == q:
                        sub += 1
            ans = min(ans, N-sub)
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 40560
#--Balance

number = int(input())
weight = list(map(int, input().split()))

aa = [0] * number
bb = [0] * number
for t in range(number):
  for i in range(number):
    if(i <= t):
      aa[t] += weight[i]
    else:
      bb[t] += weight[i]

cc = [0] * number
for i in range(number):
  cc[i] = abs(aa[i] - bb[i])

print(min(cc))



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
using namespace std;

int main(){

    int a, b, k;
    cin >> a >> b >> k;

    int itemp = min(a, b);
    int ktemp = 0;

    for(int i=itemp; i>0; i--){
        if(a%i == 0 && b%i == 0){
            ktemp++;
            if(ktemp == k){
                cout << i;
                break;
            }
        }
    }

    return 0;
}

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

n,q = map(int, input().split())
# stx = [tuple(map(int, input().split())) for _ in range(n)]
stx = [0]*n
for i in range(n):
    stx[i] = tuple(map(int, input().split()))
# d = [int(input()) for _ in range(q)]
d = [0]*q
for i in range(q):
    d[i] = int(input())

#これはセグ木 * bisect
import bisect
inf = 10**9 + 100

# 定数倍高速化
b_left = bisect.bisect_left
b_right = bisect.bisect_right

def init(n,init_num=0):
    num = len(str(bin(n-1))) + 1
    seg = [init_num] * (2**num)
    # seg[0] = 2**(num-1)
    seg0 = 2**(num-1)
    return(seg,seg0)

def update(head, tail, x):
    # print('{} {} {}'.format(head, tail, x))
    head += seg0
    tail += seg0
    points = []
    while(head <= tail):
        if(head == tail):
            points.append(head)
            break

        if(head % 2 ==1):
            points.append(head)
            head += 1
        head = head//2

        if(tail % 2 == 0):
            points.append(tail)
            tail -= 1
        tail = (tail-1)//2

    for point in points:
        seg[point] = min(seg[point], x)

def execute_all():
    for i in range(2,len(seg)):
        seg[i] = min(seg[i], seg[i//2])


seg,seg0 = init(q, init_num = inf)

for i in range(n):
    left = b_left(d, stx[i][0] -stx[i][2])
    right = b_right(d, stx[i][1] - stx[i][2] -1) -1
    update(left, right, stx[i][2])
    # print('{} {} {}'.format(left, right, stx[i][2]))

execute_all()

for i in seg[seg0: seg0 + q]:
    if(i == inf):
        print(-1)
    else:
        print(i)

Measured memory_bytes: 105040
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n,x;
    double output;
    while(cin >> n){
        rep(i,n){
            cout << "Case " << i + 1 << ":" << endl;
            cin >> x;
            rep(j,10){
                x *= x;
                while(x >= 1000000)
                    x -= 1000000;
                output = static_cast<double>(x) / 100;
                cout << static_cast<int>(output) << endl;
                x = static_cast<int>(output);
            }
        }
    }
}

Measured memory_bytes: 1160
import sys

H, W = [int(x) for x in input().split()]

grid = [[c for c in input()] for i in range(H)]
visited = [[False for i in range(W)] for j in range(H)]
dist = [[0 for i in range(W)] for j in range(H)]

# 白の数
nw = sum([line.count('.') for line in grid])

# 最短ルートの探索(幅優先探索)
start = (0, 0)
goal = (H - 1, W - 1)

visited[start[0]][start[1]] = True
dist[start[0]][start[1]] = 1
queue = [start]
while len(queue) > 0:
    v = queue[0]
    queue.remove(v)

    if v == goal:
        print(nw - dist[v[0]][v[1]])
        sys.exit()
    else:
        if (v[0] > 0 and not visited[v[0] - 1][v[1]]
                and grid[v[0] - 1][v[1]] == '.'):
            queue.append((v[0] - 1, v[1]))
            visited[v[0] - 1][v[1]] = True
            dist[v[0] - 1][v[1]] = dist[v[0]][v[1]] + 1

        if (v[0] < H - 1 and not visited[v[0] + 1][v[1]]
                and grid[v[0] + 1][v[1]] == '.'):
            queue.append((v[0] + 1, v[1]))
            visited[v[0] + 1][v[1]] = True
            dist[v[0] + 1][v[1]] = dist[v[0]][v[1]] + 1

        if (v[1] > 0 and not visited[v[0]][v[1] - 1]
                and grid[v[0]][v[1] - 1] == '.'):
            queue.append((v[0], v[1] - 1))
            visited[v[0]][v[1] - 1] = True
            dist[v[0]][v[1] - 1] = dist[v[0]][v[1]] + 1

        if (v[1] < W - 1 and not visited[v[0]][v[1] + 1]
                and grid[v[0]][v[1] + 1] == '.'):
            queue.append((v[0], v[1] + 1))
            visited[v[0]][v[1] + 1] = True
            dist[v[0]][v[1] + 1] = dist[v[0]][v[1]] + 1

print(-1)


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

int main(){
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    if(s=="Cloudy") cout << "Rainy" << endl;
    if(s=="Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2] && s[0] == s[2]) cout << "No";
    else cout << "Yes";
}


Measured memory_bytes: 3616
import heapq
N = int(input())
st = input()
n, a, b = map(int,st.split())

minvalue = b
left = [-a]
right = [a]
ptnum = 1
for i in range(N-1):
  st = input()
  if st[0] == '1':#入力クエリ
    n, a, b = map(int,st.split())
    if ptnum%2 == 1:#lrは一致
      l = - heapq.heappop(left)
      r = heapq.heappop(right)
      le = min(l,a)
      ri = max(a,r)
      heapq.heappush(left, -le)
      heapq.heappush(right, ri)
      minvalue += abs(l-a)
    else:#lr は必ずしも一致しない
      if a < -left[0]:#中央がlに
        heapq.heappush(left, -a)
        heapq.heappush(right, -left[0])
        minvalue -= a+left[0]
      elif a > right[0]:#中央がrに
        heapq.heappush(left, -right[0])
        heapq.heappush(right, a)
        minvalue += a-right[0]
      else:
        heapq.heappush(left, -a)
        heapq.heappush(right, a)
        
    minvalue += b
    ptnum += 1

  else:
    print(- left[0], minvalue)  

Measured memory_bytes: 11156
N, M = map(int, input().split())
data = {}
canMake = True
if M == 0:
  if N == 1:
    print(0)
  if N == 2:
    print(10)
  if N == 3:
    print(100)
  exit()

for _ in range(M):
  s, c = map(int, input().split())
  if s in data:
    if data[s] != c:
      canMake = False
  else:
    data[s] = c

keta = N
pad = min(data)
if N != 1 and min(data) == 1 and data[min(data)] == 0:
  canMake = False

if not canMake:
  print(-1)
  exit()

res = 0
for i in range(1, keta+1):
  if i in data:
    res += data[i]*10**(keta-i)
  elif i == 1:
    res += 10**(keta-i)

print(res)

Measured memory_bytes: 38256
while True:
	try:
		a,b,c = map(str, raw_input().replace("+","=").split("="))
		i = 1 if a!=a[0]=="X" or b!=b[0]=="X" or c!=c[0]=="X" else 0
		for x in range(i,10):
			if eval((a+"+"+b).replace("X",str(x)))==int(c.replace("X",str(x))):
				print x
				break
		else:
			print "NA"
	except:
		break

Measured memory_bytes: 4256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
//#define INF 1000000007
#define MOD 1000000007
#define MAX_N 105
#define MAX_V 1005
const ll INF = LLONG_MAX/2;

ll n,weight_maxi;
ll weight[MAX_N];
ll value[MAX_N];//重さ、価値
ll dp[MAX_N][MAX_N*MAX_V];//dp[i][j]:i番目までの品物で作れる価値jの組み合わせの重さの最小値

ll solve(){

    fill(dp[0],dp[0]+MAX_N*MAX_V,INF);
    dp[0][0] = 0;
    for(ll i = 0;i < n;i++){
        for(ll j = 0;j <= MAX_N*MAX_V;j++){
            if(j < value[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = min(dp[i][j],dp[i][j-value[i]]+weight[i]);
            }
        }
    }

    ll ans = 0;
    for(ll i = 0;i < MAX_N*MAX_V;i++){
        if(dp[n][i] <= weight_maxi){
            ans = i;
        }
    }
    return ans;
}

int main(){    

    cin >> n >> weight_maxi;
    for(ll i = 0;i < n;i++){
        cin >> weight[i] >> value[i];
    }
    cout << solve() << endl;

    return 0;
}

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

typedef long long lint;
typedef unsigned long long ulint;
#define MOD 1000000007

int main(){
    lint Q,H,S,D;
    cin >> Q >> H >> S >> D;
    lint LL[4]={Q*8,H*4,S*2,D};
    lint L[3]={Q*4,H*2,S};

    sort(LL,LL+4);
    sort(L,L+3);

    lint N;
    cin >> N;
    cout << (LL[0]*(N/2)+L[0]*(N%2)) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int D=sc.nextInt(), N=sc.nextInt();
		
		int[] T=new int[D];
		int[] A=new int[N];
		int[] B=new int[N];
		int[] C=new int[N];
		int[] curr=new int[N];
		int[] next=new int[N];
		
		for(int i=0; i<D; i++)
			T[i]=sc.nextInt();
		
		for(int i=0; i<N; i++)
		{
			A[i]=sc.nextInt();
			B[i]=sc.nextInt();
			C[i]=sc.nextInt();
		}
		
		for(int i=0; i<D-1; i++)
		{
			for(int j=0; j<N; j++)
			for(int k=0; k<N; k++)
			{
				if( A[j]<=T[i]   && T[i]  <=B[j] &&
					A[k]<=T[i+1] && T[i+1]<=B[k]  )
				{
					int currNext=0;
					currNext += curr[j];
					currNext += Math.abs(C[j]-C[k]);
					if(currNext > next[k])
						next[k] = currNext;
				}
			}
			for(int j=0; j<N; j++)
			{
				curr[j] = next[j];
				next[j] = 0;
			}
		}
		
		int max=curr[0];
		for(int i=1; i<N; i++)
			max = Math.max(max, curr[i]);
		System.out.println(max);
	}
}

Measured memory_bytes: 21308
import math

while True:
    n = float(input())
    if n == 0:
        break
    nums = list(map(int, input().split()))

    avg = sum(nums) / n
    a = []
    for s in nums:
        a.append(abs(s - avg) ** 2)
    print(math.sqrt(sum(a) / n))



Measured memory_bytes: 5708
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean[] nwse = new boolean[4];
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if ('N' == c) {
                nwse[0] = true;
            } else if ('W' == c) {
                nwse[1] = true;
            } else if ('S' == c) {
                nwse[2] = true;
            } else {
                nwse[3] = true;
            }
        }
        if (!Boolean.logicalXor(nwse[0], nwse[2])
                && !Boolean.logicalXor(nwse[1], nwse[3])) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int main(){

	int a, b, ans=0;
	cin >> a >> b;

	for (int i = 0; i < 2; i++){

		if (a < b){
			ans += b;
			b--;
		}

		else if (a > b){
			ans += a;
			a--;
		}

		else{
			ans += a;
			a--;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N,A,B,C;
	int t[101];
	int i,j,k,w,s,temp;
	int pizza;
	int max;
	cin>>N;
	cin>>A>>B;
	cin>>C;
	max=C/A;
	pizza=0;
	k=0;
	for(i=0;i<N;i++){
		cin>>t[i];
	}
	for(i=0;i<N;i++){
		for(j=N-1;j>i;j--){
			if(t[i]<t[j]){
				temp=t[i];
				t[i]=t[j];
				t[j]=temp;
			}
		}
	}
	max=C/A;
	k=0;
	pizza=C;
	for(i=0;i<N;i++){
		pizza=pizza+t[i];
		k++;
		w=A+k*B;
		if(max<pizza/w){
			max=pizza/w;
		}
	}
	cout<<max<<endl;
	return 0;
}
	

Measured memory_bytes: 3096
use whiteread::parse_line;

fn main() {
    let _n: usize = parse_line().unwrap();
    let a: Vec<usize> = parse_line().unwrap();
    let mut cnt = [0; 100000];
    let mut ans = 0;

    for ai in a {
        cnt[ai] += 1;
    }
    for i in 1..99999 {
        ans = ans.max(cnt[i - 1] + cnt[i] + cnt[i + 1]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 3588
#include <stdio.h>
 
int main(void){
    int x, y;
     
    while(1){
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) break;
         
        if(x > y){
            int tmp;
            tmp = x;
            x = y;
            y = tmp;
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", x, y);
        }
    }
     
    return 0;
}


Measured memory_bytes: 1932
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, t, a[100009]; long long b[100009], c[100009];
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> t;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) b[i] = a[i] + (i >= 1 ? b[i - 1] : 0);
	for (int i = 0; i < n; i++) {
		c[i] = b[i] + a[i];
		if (i >= 1) c[i] = max(c[i], c[i - 1] + a[i]);
	}
	for (int i = 0; i < n; i++) {
		if (t < b[i]) cout << 1 << '\n';
		else if (t < c[i]) cout << 2 << '\n';
		else cout << (t - b[i]) / (c[i] - b[i]) + 2 << '\n';
	}
	return 0;
}

Measured memory_bytes: 5172
#include <iostream>

int main() {
	int A, B, K;
	std::cin >> A >> B >> K;
	for (int i = 1; i <= K; ++i) {
		((i%2)?B:A) += (((i % 2) ? A : B) /= 2);
	}
	printf("%d %d", A, B);
}

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

int main() {
    int k, h, l;
    cin>>k;
    if(k%2==0 || k%5==0){
        cout<<-1<<endl;
        return 0;
    }
    int x=10;
    int ans=1;
    if(k%7==0){
        int l=9*k/7;
        while(x%l!=1){
            x=x%l*10;
            ans++;
        }
        cout<<ans<<endl;
    }else{
        int l=9*k;
        while(x%l!=1){
            x=x%l*10;
            ans++;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3628
//
//  main.c
//  ITP1_6_C
//
//  Created by k16031kk on 2018/05/24.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int n, b, f, r, v;
    int count[4][3][10];
    scanf("%d", &n);//全部で何棟の情報数か
    for(int i=0; i<4; i++) {
        for(int j=0; j<3; j++) {
            for(int k=0; k<10; k++) {
                count[i][j][k]=0;
            }
        }
    }
    for(int i=0; i<n; i++) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        count[b-1][f-1][r-1]+=v;
    }
    for(int i=0; i<4; i++) {//1〜4棟
        for(int j=0; j<3; j++) {//1〜3階
            for(int k=0; k<10; k++) {//1~10部屋
                printf(" %d",count[i][j][k]);
            }
            printf("\n");
        }
        if(i!=3) printf("####################\n");
    }
    
    return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back
using namespace std;
typedef long long int ll;
int  main(){
	ll n,m;
	cin>>n>>m;
	map<ll,ll>mp;
	ll c=0,p1=0;
	for(int i=1;i<=n;i++){
		mp[i]=0;
	}
	for(int i=0;i<m;i++){
		int p;string s;
		cin>>p>>s;
		// cout<<mp[p]<<" "<<c<<" "<<p1<<endl;
		if(mp[p]!=-1){
			if(s=="WA"){
				mp[p]++;
			}
			else{
				c++;
				p1+=mp[p];
				mp[p]=-1;
			}
		}
	}
	cout<<c<<" "<<p1<<endl;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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 main(){

    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> west(n, 0);
    vector<int> east(n, 0);
    for(int i = 0; i < n; i++){
        if(i > 0){
            west[i] = west[i-1];
            east[i] = east[i-1];
        }
        if(s[i] == 'W') west[i]++;
        else if(s[i] == 'E') east[i]++;
    }
    int ans = INF;
    for(int i = 0; i < n; i++){
        int v;
        if(i > 0){
            v = west[i-1] + (east[n-1] - east[i]);
        }
        else{
            v = east[n-1] - east[i];
        }
        ans = min(ans, v);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3076
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: usize = s.trim().parse().unwrap();
    let mut v: Vec<usize> = vec![0; n];
    for i in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        v[i] = s.trim().parse().unwrap();
    }
    let mut i: usize = 0;
    let mut x: usize = 0;
    loop {
        if i >= n {println!("-1"); return}
        if v[x] == 2 {println!("{}", i+1); return}
        x = v[x] - 1;
        i += 1;
    }
}



Measured memory_bytes: 4352
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                 as IM
import           Data.List
import qualified Data.Map                    as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  readInt
  a <- getLine
  b <- getLine
  c <- getLine
  print $ solve a b c 0

solve :: String -> String -> String -> Int -> Int
solve [] [] [] acc = acc
solve (a:as) (b:bs) (c:cs) acc = solve as bs cs (acc + length (group $ sort [a, b, c]) - 1)


Measured memory_bytes: 636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
typedef struct st{
	ll a,b;
	bool operator<(const st&key)const{
		ll vl=this->a*key.b;
		ll vr=this->b*key.a;
		return vl>vr;
	}
}st;
vector<st> v;
int main(){
	ll n,T;
	cin>>n>>T;
	rep(i,n){
		ll a,b; cin>>a>>b;
		b++;
		v.push_back((st){a,b});
	}	
	sort(all(v));
	//rep(i,n)cerr<<v[i].a<<" "<<v[i].b<<endl;
	ll dp[40],cop[40];
	rep(i,40)dp[i]=1e18;
	dp[0]=1;
	ll pnt=n;
	rep(i,n){
		if(v[i].a==0){
			pnt=i;
			break;
		}
		rep(k,40)cop[k]=dp[k];
		rep(k,39)if(cop[k]<1e18){
			ll res=(v[i].a+1)*cop[k]+v[i].b;
			if(res<=T+1)chmin(dp[k+1],res);
		}
	}
	vector<ll> bs;
	for(int i=pnt;i<n;i++)bs.push_back(v[i].b);
	sort(all(bs));
	for(int i=1;i<bs.size();i++)bs[i]+=bs[i-1];
	ll ans=0;
	rep(k,40)if(dp[k]<1e18){
		ll rem=T+1-dp[k];
		ll cnt=upper_bound(all(bs),rem)-bs.begin();
		chmax(ans,cnt+k);
	}
	cout<<ans<<endl;
}


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

using namespace std;

int gcd(int a, int b){
	return b == 0 ? a : gcd(b, a % b);
}

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int a, b, t;
	cin >> a >> b >> t;
	cout << (t / a) * b; 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
    int n;
    while (1)
    {
        cin >> n;
        if (n == 0) break;
        double score[n];
        double sum = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> score[i];
            sum += score[i];
        }
        double avg = 1.0*sum/n;
        double sum2 = 0.0;
        for (int i = 0; i < n; i++)
        {
            sum2 += pow(avg-score[i], 2);
        }
        printf("%lf\n", sqrt(sum2/n));
    }
    return 0;
}


Measured memory_bytes: 3192
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

alias sread = () => readln.chomp();

void main()
{
    auto nm = aryread;
    auto n = nm[0];
    auto m = nm[1];

    long result = long.min;

    for (long i = 1; i * i <= m; i++)
    {
        if (i <= m / n && m % i == 0)
        {
            result = result.max(i);
            if (m / i <= m / n)
                result = result.max(m / i);
        }
    }
    writeln(result);
}


Measured memory_bytes: 256
def frog2(H,N,K):
    #print(H)
    DP = [10**10]*N
    #DP = [0]*N
    DP[0] = 0
    DP[1] = abs(H[1]-H[0])
    for i in range(2,N):
        for j in range(1,K+1):
            DP[i] = chmin(DP[i],DP[i-j]+abs(H[i]-H[i-j]))
    return DP[-1]

def chmin(a,b):
    if a < b:
        return a
    else:
        return b

if __name__ == '__main__':
    N,K = map(int,input().split())
    H = list(map(int,input().split()))
    ans = frog2(H,N,K)
    print(ans)
    

Measured memory_bytes: 52448
n=int(input())
from collections import Counter
cc=Counter()
for _ in range(n):
    cc[input()]+=1
m=int(input())
ans=0
for _ in range(m):
    x=input()
    if cc[x]==0:
        continue
    else:
        cc[x]-=1
for i in cc:
    ans=max(ans,cc[i])
print(ans)



Measured memory_bytes: 3316
import math
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

ans=0
for j in range(1,N+1,2):
    count = make_divisors(j)
    if len(count)==8:
        ans +=1

print(ans)


Measured memory_bytes: 38384
s = input()


def op(n):
    if n == 0:
        return '+'
    else:
        return '-'

for i in range(2):
    for j in range(2):
        for k in range(2):
            eq = s[0]+op(i)+s[1]+op(j)+s[2]+op(k)+s[3]
            if eval(eq) == 7:
                print(eq+'=7')
                exit()


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxn=1e6+5;

int tree[16*maxn],n,m,f[maxn],q;
int r1,r2,c1,c2;

void ini0(int pos1,int pos2,int begin,int end,int r)
{
    if(begin==end)tree[pos1*m*4+pos2]=f[r*m+begin];
    else
    {
        int mid=(begin+end)>>1;
        ini0(pos1,pos2<<1,begin,mid,r);
        ini0(pos1,(pos2<<1)|1,mid+1,end,r);
        if(tree[pos1*m*4+(pos2<<1)]<tree[pos1*m*4+((pos2<<1)|1)])tree[pos1*m*4+pos2]=tree[pos1*m*4+(pos2<<1)];
        else tree[pos1*m*4+pos2]=tree[pos1*m*4+((pos2<<1)|1)];
    }
}

void ini1(int pos1,int pos2,int begin,int end)
{
    if(tree[(pos1<<1)*m*4+pos2]<tree[((pos1<<1)|1)*m*4+pos2])tree[pos1*m*4+pos2]=tree[(pos1<<1)*m*4+pos2];
    else tree[pos1*m*4+pos2]=tree[((pos1<<1)|1)*m*4+pos2];
    if(begin!=end)
    {
        int mid=(begin+end)>>1;
        ini1(pos1,pos2<<1,begin,mid);
        ini1(pos1,(pos2<<1)|1,mid+1,end);
    }
}

void ini(int pos,int begin,int end)
{
    if(begin==end)ini0(pos,1,0,m-1,begin);
    else
    {
        int mid=(begin+end)>>1;
        ini(pos<<1,begin,mid);
        ini((pos<<1)|1,mid+1,end);
        ini1(pos,1,0,m-1);
    }
}

int find2(int pos1,int pos2,int begin,int end)
{
    if(c1<=begin && end<=c2)return tree[pos1*4*m+pos2];
    else
    {
        int mid=(begin+end)>>1;
        if(c2<=mid)return find2(pos1,pos2<<1,begin,mid);
        else if(c1>mid)return find2(pos1,(pos2<<1)|1,mid+1,end);
        else return min(find2(pos1,pos2<<1,begin,mid),find2(pos1,(pos2<<1)|1,mid+1,end));
    }
}

int find(int pos,int begin,int end)
{
    if(r1<=begin && end<=r2)return find2(pos,1,0,m-1);
    else
    {
        int mid=(begin+end)>>1;
        if(r2<=mid)return find(pos<<1,begin,mid);
        else if(r1>mid)return find((pos<<1)|1,mid+1,end);
        else return min(find(pos<<1,begin,mid),find((pos<<1)|1,mid+1,end));
    }
}

int main()
{
    while(scanf("%d%d%d",&n,&m,&q)==3 && (n||m||q))
    {
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                scanf("%d",&f[i*m+j]);
        ini(1,0,n-1);
        for(int i=0;i<q;i++)
        {
            scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
            printf("%d\n",find(1,0,n-1));
        }
    }
    return 0;
}

Measured memory_bytes: 56316