akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

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

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n, m;
	cin >> n >> m;

	vector<ll> a(m), b(m), c(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
		c[i] *= -1;
	}

	vector<ll> dist(n, INF64);
	dist[0] = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < m; j++) {
			if (dist[a[j]] == INF64) {
				continue;
			}

			dist[b[j]] = min(dist[b[j]], dist[a[j]] + c[j]);
		}
	}
	
	ll ans = dist[n - 1];
	vector<bool> negative(n);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (dist[a[j]] == INF64) {
				continue;
			}

			if (dist[b[j]] > dist[a[j]] + c[j]) {
				dist[b[j]] = dist[a[j]] + c[j];
				negative[b[j]] = true;
			}

			if (negative[a[j]]) {
				negative[b[j]] = true;
			}
		}
	}

	cout << (negative[n - 1] ? "inf" : to_string(-ans)) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  int a,b,c;

  cin >> a >> b >> c;
  
  cout << max(b+c-a, 0) << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n;
  cin>>n;
  //ここをintにするとm*a*hがオーバーフローするのでWA
  long long m=0,a=0,r=0,c=0,h=0;
  rep(i,n){
    string s;
    cin>>s;
    if(s[0]=='M') m++;
    if(s[0]=='A') a++;
    if(s[0]=='R') r++;
    if(s[0]=='C') c++;
    if(s[0]=='H') h++;
  }
  
  long long ans=0;
  ans+=m*a*r;
  ans+=m*a*c;
  ans+=m*a*h;
  ans+=m*r*c;
  ans+=m*r*h;
  ans+=m*c*h;
  ans+=a*r*c;
  ans+=a*r*h;
  ans+=a*c*h;
  ans+=r*c*h;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k; cin >> h >> w >> k;
    V< V<int> > s(h + 1, V<int>(w + 1, 0));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c; cin >> c;
            s[i + 1][j + 1] = c - '0';
        }
    }

    for (int i = 0; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            s[i][j] += s[i][j - 1];
        }
    }
    for (int i = 1; i <= h; i++) {
        for (int j = 0; j <= w; j++) {
            s[i][j] += s[i - 1][j];
        }
    }

    int ans = INF;
    for (int state = 1 << (h - 1); state < (1 << h); state++) {
        int prevw = 0;
        int tmp = __builtin_popcount(state) - 1;
        bool ok = true;
        for (int i = 1; i <= w; i++) {
            bool cutok = true;
            int prevh = 0;
            for (int j = 0; j < h; j++) {
                if ((state >> j) & 1) {
                    // cout << "status: " << state << ' ' << prevw << ' ' << i << ' ' << prevh << ' ' << j + 1 << '\n';
                    // cout << "s: " << s[j + 1][i] + s[prevh][prevw] - s[j + 1][prevw] - s[prevh][i] << '\n';
                    if (s[j + 1][i] + s[prevh][prevw] - s[j + 1][prevw] - s[prevh][i] > k) {
                        cutok = false;
                        break;
                    } else {
                        prevh = j + 1;
                    }
                }
            }

            if (!cutok) {
                if (prevw == i - 1) {
                    ok = false;
                    break;
                } else {
                    tmp++;
                    i--;
                    prevw = i;
                }
            }
        }
        
        if (ok) {
            chmin(ans, tmp);
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC131_a solver = new ABC131_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC131_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            String[] spri = S.split("");
            for (int i = 1; i < spri.length; i++) {
                if (spri[i].compareTo(spri[i - 1]) == 0) {
                    out.println("Bad");
                    return;
                }

            }
            out.println("Good");
        }

    }
}



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

class Dice{
    private:
        std::vector<int> d;
    public:
        Dice(std::vector<int> a) {
            d = a;
            d.push_back(0); // tmp用
        }

        void N() {
            d.at(6) = d.at(1 - 1);
            d.at(1 - 1) = d.at(2 - 1);
            d.at(2 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(5 - 1);
            d.at(5 - 1) = d.at(6);
        }

        void S() {
            d.at(6) = d.at(1 - 1);
            d.at(1 -1 ) = d.at(5 - 1);
            d.at(5 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(2 - 1);
            d.at(2 - 1) = d.at(6);
        }

        void W() {
            d.at(6) = d.at(1 - 1);
            d.at(1 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(6);
        }

        void E() {
            d.at(6) = d.at(1 - 1);
            d.at(1 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(6);
        }

        void R() {
            // 右回転
            d.at(6) = d.at(2 -1);
            d.at(2 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(5 - 1);
            d.at(5 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(6);
        }

        void L() {
            // 左回転
            d.at(6) = d.at(2 - 1);
            d.at(2 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(5 - 1);
            d.at(5 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(6);
        }

        int get_dice(int i) {
            return d.at(i - 1);
        }
 };

int main(void) {
    using namespace std;

    int n;
    cin >> n;

    vector<int> a(6);
    for (int i = 0; i < 6; i++) {
        cin >> a.at(i);
    }

    Dice dice(a);

    bool flg1 = false;
    bool flg_tmp = false;
    for (int h = 0; h < n; h++) {
        vector<int> b(6);
        for (int i = 0; i < 6; i++) {
            cin >> b.at(i);
        }
        Dice dice2(b);
        // まずは縦回転させる
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                if (dice.get_dice(1) == dice2.get_dice(1)) {
                    // 1面があったら2面目にとりかかる
                    // 1面は合ったので、あとは右回転させ続ける
                    for (int k = 0; k < 4; k++) {
                        if (dice.get_dice(2) == dice2.get_dice(2)) {
                            // 2面目も合った場合は判定する
                            if (dice.get_dice(3) == dice2.get_dice(3) &&
                                dice.get_dice(4) == dice2.get_dice(4) &&
                                dice.get_dice(5) == dice2.get_dice(5) &&
                                dice.get_dice(6) == dice2.get_dice(6)) {
                                flg1 = true;
                            }
                        }
                        dice2.R();
                    }
                } 
                dice2.N();
            }
            // 横回転させる
            dice2.W();
        }
    }

    if (flg1) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }

    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

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

    string s; int x, y;
    cin >> s >> x >> y;

    int dir = 2;
    vector<int> xsec, ysec;
    REP(i, s.size()){
        if(s[i] == 'F'){
            if(dir == 2) x--;
            else if(dir == 0) xsec.back()++;
            else if(dir == 1) ysec.back()++;
        }else{
            dir = (dir + 1) % 2;
            (dir == 0 ? xsec : ysec).pb(0);
        }
    }

    vector<vector<bool>> dp1(xsec.size() + 1, vector<bool>(40000, 0));
    dp1[0][20000 + x] = true;
    REP(i, xsec.size()){
        for(int j = 0; j < 40000; j++){
            if(dp1[i][j]){
                dp1[i+1][j-xsec[i]] = true;
                dp1[i+1][j+xsec[i]] = true;
            }
        }
    }

    vector<vector<bool>> dp2(ysec.size() + 1, vector<bool>(40000, 0));
    dp2[0][20000 + y] = true;
    REP(i, ysec.size()){
        for(int j = 0; j < 40000; j++){
            if(dp2[i][j]){
                dp2[i+1][j-ysec[i]] = true;
                dp2[i+1][j+ysec[i]] = true;
            }
        }
    }

    if(dp1[xsec.size()][20000] && dp2[ysec.size()][20000]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 39424
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] =new int[N];
        int sum=0;
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt();
        }
        
        Arrays.sort(a);
        
        for(int i=0;i<N-1;i++){
            sum+=a[i];
        }
        
        if(sum>a[N-1]){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35736
char buf[1800000],f[5];
sz,osz;
#define rd(x)x=0;for(;;){k=buf[sz++];if(k<'0')break;x=x*10+k-'0';}
N,M,L,Q;
D[301][301];
i,j,k;
a,b,c;
main()
{
	read(0,buf,1800000);
	rd(N);rd(M);rd(L);
	for(i=0;i<N;i++)for(j=0;j<N;j++)D[i][j]=1000000001;
	for(i=0;i<M;i++)
	{
		rd(a);rd(b);rd(c);
		--a;
		--b;
		D[a][b]=D[b][a]=c;
	}
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)
		if(D[i][j]>D[i][k]+D[k][j])D[i][j]=D[i][k]+D[k][j];
	for(i=0;i<N;i++)for(j=0;j<N;j++)D[i][j]=D[i][j]>L?1000000000:1;
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)
		if(D[i][j]>D[i][k]+D[k][j])D[i][j]=D[i][k]+D[k][j];
	rd(Q);
	for(i=0;i<Q;i++)
	{
		rd(a);rd(b);
		--a;
		--b;
		if(D[a][b]<1000000000)
		{
			c=D[a][b]-1;
			k=0;
			do{
				f[k++]=c%10+'0';
				c/=10;
			}while(c);
			for(;k--;)buf[osz++]=f[k];
		}
		else buf[osz++]='-',buf[osz++]='1';
		buf[osz++]='\n';
	}
	write(1,buf,osz);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  string s; cin >>s;
  int n = s.size();
  int res = 1;
  bool one = true;
  for (int i=1; i<n; i++){
    if (one){
      if (s[i] == s[i-1]){
        if (i < n-1) res++;
        i++;
        one = false;
      }else{
        res++;
      }
    }else{
      one = true;
      res++;
    }
  }
  cout <<res <<endl;

}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i = 0; i < 600; i += n) {
      ans += i * i * n;
    }
    cout << ans << '\n';
  }
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 1000000007
ll n,m,i,j,k,l,t,a,b;
int main()
{
    scanf("%lld %lld",&n,&m);
    j=2*m;
    if(j==n)
    {
        printf("%lld\n",n+m);
        return 0;
    }
    if(j<=n)
    {
        t=n+j;
        a=m;
        b=n-j;
        while(b>0 && a%b!=0)
        {
            n=a/b;
            n*=b;
            t+=(n*2);
            n=a%b;
            a=b;
            b=n;
        }
        n=a/b;
        m=((n-1)*2)+1;
        t+=(m*b);
        printf("%lld\n",t);
    }
    else
        {
          t=n+((n-m)*2);
          a=n-m;
          b=n-((n-m)*2);
           while(b>0 && a%b!=0)
        {
            n=a/b;
            n*=b;
            t+=(n*2);
            n=a%b;
            a=b;
            b=n;
        }
        n=a/b;
        m=((n-1)*2)+1;
        t+=(m*b);
        printf("%lld\n",t);
        }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	nextInt()
	K := nextInt()
	S := []rune(nextString())
	S[K-1] += 'a' - 'A'
	fmt.Println(string(S))
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

using namespace std;


int main() {
	ll n;
	ll k;
	cin >> n >> k;
	ll min_v = n;
	n = n % k;
	min_v = min(n, min_v);


	for (int i = 0; i < 100; i++) {
		n = abs(n - k);
		min_v = min(n, min_v);
	}
	cout << min_v << endl;



	return 0;

}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

typedef unsigned long long int ll;

ll X, Y;

ll pw(ll i) {
  ll a = 1;
  for(ll k = 0; k < i; k++) {
    a *= 2;
  }
  return a;
}

int main() {
  cin >> X >> Y;
  ll i = 0, a = X;
  while(1) {
    a = X * pw(i);
    if(a > Y) break;
    i++;
  }
  cout << i << endl;
}


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

const long long MOD = 1e9+7;
string s;
vector< vector<long long> > dp(100100, vector<long long>(13, 0));

int main() {
    cin >> s;
    int slen = s.length();
    if(s.at(0) == '?') {
        for(int i = 0; i < 10; ++i) dp[0][i] = 1;
    }else {
        dp[0][s.at(0) - '0'] = 1;
    }

    // 前から順にその桁の数+13をしていくことでチェックをしていく
    for(int k = 0; k < slen-1; ++k) {
        if(s.at(k+1) == '?') {
            // 次の桁が決まっていないとき、0~9を全て試してみる
            // 一つ前の余りが0~12のときその桁にとっては10倍のあまり
            for(int i = 0; i < 13; ++i) {
                for(int j = 0; j < 10; ++j) {
                    dp[k+1][(i*10 + j) % 13] += dp[k][i];
                    dp[k+1][(i*10 + j) % 13] %= MOD;
                }
            }
        }else {
            for(int i = 0; i < 13; ++i) {
                dp[k+1][(i*10 + (s.at(k+1) - '0')) % 13] += dp[k][i];
                dp[k+1][(i*10 + (s.at(k+1) - '0')) % 13] %= MOD;
            }
        }
    }

    cout << dp[slen-1][5] << endl;
}

Measured memory_bytes: 13824
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N,count =0;
    cin >> N;
    vector<int> arr(N,0);

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

    for (int j = 0; j < N; j++)
    {
        int num;

        num = arr[j];

        if (j + 1 == arr[num - 1])
        {
            count = count + 1;
        }
    }

    cout << count / 2 <<endl;

    return 0;
}

Measured memory_bytes: 640
n, k = map(int, raw_input().split(' '))

m = n -2
ans = 5*int(m/11)
for i in xrange(m % 11):
    i += 1
    for j in xrange(7-2):
        j += 1
        s = 9*(7*i+j+1)

        if ((s % 11) == k):
            ans +=1
print ans


Measured memory_bytes: 2696
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

// O(√n) 
bool primeNumber(int n){  
    if(n < 2) return false;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}

int main() {
  ll n,k,m,x=0,y=0,z = 0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string t;
  bool ok=true; 
  VL p(100002);
  VB b(100001,false);
  for(int i=2; i<100001; i++){
    if(primeNumber(i)){
      b[i]=true;
    }
  }
  for(int i=3; i<100001; i+=2){
    if(b[i]&&b[(i+1)/2])
      p[i]++;
  }
  for(int i=3; i<100001; i++){
    p[i] += p[i-1];
  }
  cin >> n;
  while(n--){
    cin >> x >> y;
    pri(p[y]-p[x-1]);
  }
  return 0;
}

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

int main(){
  int64_t N, A, B; cin >> N >> A >> B;
  int64_t k=(B-A+1)/2;
  if(A%2!=B%2){
    k+=min(A-1,N-B);
  }
  cout << k << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <algorithm>
using namespace std;
int main()
{
        char s[52][52];
        int h,w;
        scanf("%d%d ",&h,&w);
        for(int i=0;i<h;i++)
        {
                for(int j=0;j<w;j++)
                {
                        scanf("%c",&s[i][j]);
                }
                int c=getchar();
        }
        for(int i=0;i<h;i++)
        {
                for(int j=0;j<w;j++)
                {
                        int count=0;
                        if(s[i][j]=='.')
                        {
                                if(i>0&&j>0){if(s[i-1][j-1]=='#') count++;}
                                if(i>0){if(s[i-1][j]=='#') count++;}
                                if(i>0&&j<w-1){if(s[i-1][j+1]=='#') count++;}
                                if(j>0){if(s[i][j-1]=='#') count++;}
                                if(j<w-1){if(s[i][j+1]=='#') count++;}
                                if(i<h-1&&j>0){if(s[i+1][j-1]=='#') count++;}
                                if(i<h-1){if(s[i+1][j]=='#') count++;}
                                if(i<h-1&&j<w-1){if(s[i+1][j+1]=='#') count++;}
                                s[i][j]=(char)(count+'0');
                        }
                }
        }
        for(int i=0;i<h;i++)
        {
                for(int j=0;j<w;j++)
                {
                        printf("%c",s[i][j]);
                }
                printf("\n");
        }
        return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))

E = []
for i in P:
    E.append((i+1)/2)
# print(E)

sum_E = [0, ]
for i in range(N):
    sum_E.append(sum_E[i] + E[i])
# print(sum_E)

sum_K = []
ans = 0
for i in range(N-K+1):
    if sum_E[i+K] - sum_E[i] > ans:
        ans = sum_E[i+K] - sum_E[i]
print(ans)


Measured memory_bytes: 24700
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

bool gpair(int a, int b, int c){
    vi nu;
    nu.push_back(a);
    nu.push_back(b);
    nu.push_back(c);
    sort(nu.begin(),nu.end());
    if(nu[0] == 1 && nu[1] == 2 && nu[2] == 3) return true;
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vi nums(n+1);
    F0R(i,1,n){
        char a; cin >> a;
        if(a == 'R') nums[i] = 1;
        else if(a == 'G') nums[i] = 2;
        else if(a == 'B') nums[i] = 3;
    }
    ll pre[4005][4];
    ll suf[4005][4];
    m0(pre); m0(suf);
    F0R(i,1,n){
        F0R(j,1,3) pre[i][j] += pre[i-1][j];
        F0R(j,1,3) suf[n-i+1][j] += suf[n-i+2][j];
        pre[i][nums[i]]++;
        suf[n-i+1][nums[n-i+1]]++;
    }
    ll total = 0;
    F0R(i,1,n){
        F0R(j,1,3){
            F0R(k,1,3){
                if(gpair(nums[i],j,k)){
                    total += pre[i][j]*suf[i][k];
//                    cerr << "hi" << endl;
                }
            }
        }
        F0R(j,1,min(i-1,n-i)){
            if(gpair(nums[i],nums[i-j],nums[i+j])) total--;
        }
    }
    cout << total << endl;
    return 0;
}


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

#define MOD 1000000007
typedef long long ll;

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

ll divmod(ll a, ll b) {
  return (a * 1LL * mod_pow(b, MOD - 2)) % MOD;
}

ll factorial(ll n) {
  if (n > 0) {
    return n * factorial(n-1) % MOD;
  } else {
    return 1LL;
  }
}

ll nCr(ll n, ll r) {
  if (n < r) return 0;
  return divmod(factorial(n), factorial(r) * factorial(n-r) % MOD);
}

int main() {
  int K, N;
  cin >> N >> K;
  for (int i = 1; i <= K; i++) {
    cout << (nCr(K-1, i-1) * nCr(N-K+1, i)) % MOD << endl;
  }
  return 0;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    const S  = arg.split("\n")[0].split(" ");
    let tail = S[0].split("").pop();

    for(let i=1; i<S.length; i++) {
        if(tail == S[i].split("")[0]) {
            tail = S[i].split("").pop();
        } else {
            console.log("NO");
            return;
        }
    }
    
    console.log("YES");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
solve :: Int -> [[Int]] -> Int
solve n [] = n
solve n ([a,b]:xs)
  | f a b /= 0 = solve (n + b - f a b) xs
  | otherwise =	solve n xs
    where f a b = mod (a+n) b

main = getContents >>= print . solve 0 . map (map read . words) . reverse . tail . lines


Measured memory_bytes: 78204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

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

  ll ans = abs(N - 2) * abs(M - 2);
  cout << ans << endl;
}

Measured memory_bytes: 256
import scala.collection.mutable
import scala.io.StdIn._

object Main extends App {

  val n = readInt
  val aList = readLine.split(" ").map(_.toInt)

  val numToCount = mutable.Map.empty[Int, Int]
  aList.foreach { n =>
    val existing = numToCount.getOrElse(n, 0)
    numToCount.put(n, existing+1)
  }

  val all = numToCount.map { case (_, count) => {
    count.toLong * (count - 1) / 2
  }}.sum

  val ans = aList.map { n =>
    val minus = numToCount(n) - 1
    all - minus
  }

  println(ans.mkString("\n"))
}



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

using namespace std;

const int N = 1e6+10;

struct Edge {
	int v, next;
} edge[N<<1];

int h[N], edge_cnt;
int mp[1010][1010], num, deg[N], dp[N];

void add(int u, int v) {
	edge[edge_cnt].v = v;
	edge[edge_cnt].next = h[u];
	h[u] = edge_cnt++;
}

int main(void)
{
	int n;
	cin >> n;
	memset(h, -1, sizeof(h));
	memset(mp, -1, sizeof(mp));
	memset(deg, 0, sizeof(deg));
	memset(dp, 0, sizeof(dp));
	edge_cnt = num = 0;
	int tmp, last;
	for(int i = 1; i <= n; ++i) {
		last = -1;
		for(int j = 1; j <= n-1; ++j) {
			cin >> tmp;
			if(mp[i][tmp] == -1) mp[i][tmp] = mp[tmp][i] = ++num;
			if(last != -1) add(last, mp[i][tmp]), deg[mp[i][tmp]]++;
			last = mp[i][tmp]; 
		}
	}
	int tot = 0, ans = -1;
	queue <int> qu;
	for(int i = 1; i <= num; ++i) if(!deg[i]) qu.push(i);
	while(!qu.empty()) {
		tmp = qu.front(); qu.pop();
		tot++;
		for(int i = h[tmp]; ~i; i = edge[i].next) {
			Edge &e = edge[i];
			if(--deg[e.v] == 0) {
				qu.push(e.v); dp[e.v] = dp[tmp]+1;
				ans = max(ans, dp[e.v]);
			}
		}
	}
	if(tot != num) puts("-1");
	else cout << ans+1 << endl;
	return 0;
 } 

Measured memory_bytes: 24832
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;

ll N, M, color[100001], A, B, C;
vector<int> G[100001];

bool dfs(int now, int c){
	color[now] = c;
	for(int i=0; i<G[now].size(); i++){
		if(color[G[now][i]] != -1){
			if(color[G[now][i]] == c) return false;
			continue;
		}else{
			if(!dfs(G[now][i], 1-c)) return false;
		}
	}
	return true;
}

void dfs2(int now){
  color[now] = 2;
  for(int i=0; i<G[now].size(); i++){
    if(color[G[now][i]] != 2)
      dfs2(G[now][i]);
  }
  return;
}

int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++){
		int u, v; cin >> u >> v;
		u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=0; i<N; i++) color[i] = -1;
	for(int i=0; i<N; i++){
		if(!G[i].size()) A++;
		else{
			if(color[i] != -1) continue;
			if(dfs(i, 0)) B++;
			else{C++;
                       dfs2(i);

                    }
		}
	}
	ll ans = 2*B*B + A*A + 2*A*(N-A) + 2*B*C + C*C;
	cout << ans << endl;
	return 0;
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n % 2 == 0) {
        print(0.5);
    } else {
        double N = n;
        print(((N + 1) / 2) / N);
    }

    return 0;
}


Measured memory_bytes: 256
// ABC_136_C

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

#define forn(i, n) for(int i = 0; i < (int)n; ++i)
#define fornll(i, n) for(ll i = 0; i < (ll)n; ++i)
int main()
{
	int n;
	cin >> n;

	vector<ll> v(n);
	forn(i, n) cin >> v[i];

	bool flag = true;

	for(int i = 1; i < n; ++i) {
		if(v[i] - v[i-1] >= 1) --v[i];
		else continue;
	}

	//fornll(i, n) cout << v[i] << " ";
	//cout << "\n";

	forn(i, n-1) {
		if(v[i] > v[i+1]) {
			flag = false;
		}
		else continue;
	}



	if(flag) cout << "Yes"<< "\n";
	else cout << "No" << "\n";
}

Measured memory_bytes: 1024
from collections import deque
V, E, R = map(int, input().split())
inf = float('inf')
graphs = [[] for _ in range(V)]

for _ in range(E):
    s, t, d = map(int, input().split())
    graphs[s].append([t, d])

start_point = R

dps = [inf for _ in range(V)]
dps[R] = 0

queue = deque([[R, 0]])
while queue:
    now_point, prev_cost = queue.popleft()
    if dps[now_point] < prev_cost:
        continue
    for next_point, cost in graphs[now_point]:
        if dps[next_point] < prev_cost + cost:
            continue
        dps[next_point] = prev_cost + cost
        queue.append([next_point, prev_cost + cost])

for ans in dps:
    if ans == inf:
        print("INF")
    else:
        print(ans)



Measured memory_bytes: 100796
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,W; cin>>N>>W;
    vector<int> value(110,0);
    vector<int> weight(110,0);
    vector<vector<Int>> cost(110,vector<Int>(100100,0));
    for(int i=1; i<=N; i++) cin>>value[i]>>weight[i];
    cost[0][0]=0;
    for(int i=1; i<=N; i++){
        for(int j=0; j<=W; j++){
        if (j-weight[i]>=0) cost[i][j]=max(cost[i-1][j],cost[i-1][j-weight[i]]+value[i]);
        cost[i][j]=max(cost[i][j],cost[i-1][j]);
        }
    }
    Int ans=0;
    for(int i=0; i<=N; i++){
        for(int j=0; j<=W; j++){
        ans=max(ans,cost[i][j]);
    }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 90016
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        circle(r);
    }
    public static void circle(double r){
    
        System.out.printf("%.6f %.6f", r*r*Math.PI, r*2*Math.PI);
    }
}


Measured memory_bytes: 28272
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int A, B; cin >> A >> B;
    REP(i, 10001){
        int a = i * 8 / 100;
        int b = i * 10 / 100;
        if(a == A && b == B){
            Out(i);
            return 0;
        }
    }
    Out(-1);

    return 0;
}


Measured memory_bytes: 256
def binary_search(lst, value):
    l = 0
    r = len(lst) - 1
    while l <= r:
        mid = (r + l) // 2
        guess = lst[mid]
        if guess == value:
            return True
        elif guess > value:
            r = mid - 1
        else:
            l = mid + 1
    return False


def main():
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))
    ans = 0

    for value in T:
        if binary_search(S, value):
            ans += 1
    
    print(ans)
    return


if __name__ == "__main__":
    main()



Measured memory_bytes: 16712
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gsort(arr) sort(arr, arr+n, greater<ll>()); 
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sync2 cout<<fixed<<setprecision(10)
const ll inf=1e9+7;
const ll inf2=inf*inf;
#define pi 3.14159265358979323846
#define for0(i,n) for (int i = 0; i <(int)n; i++)
#define for1(i,n) for (int i = 1; i<=(int)n; i++)
#define all(vv) vv.begin(),vv.end()
priority_queue <ll, vector<ll>, greater<ll>> mnheap;
priority_queue <ll> mxheap;
#define vc(vv) vector<ll> vv;
ll gcd(ll x,ll y){if (x == 0)return y;return gcd(y%x, x);}
int is_prime(ll x) {if(x<2)return 0;for(ll i=2;i*i<=x;i++){if(x%i==0)return 0;}return 1;}
inline ll modpw(ll x, ll y, ll z) {ll res=1;x=x%z;while(y){if(y&1) res=(res*x)%z;x=(x*x)%z;y/=2;}return res;}
inline ll modinv(ll x,ll z){return modpw(x,z-2,z);}
ll lcm(ll x,ll y){return (x*y)/gcd(x,y);}
#define pYES cout<<"YES"<<endl
#define pNO cout<<"NO"<<endl

ll dp[100005];
int main()
{
     sync;
     int t;
     //cin>>t;
     t=1;
     while(t--)
     {
          int n,k;
          cin>>n>>k;
          ll a[n];
          for0(i,n)cin>>a[i];
          for(int i=1;i<n;i++)
          {
               dp[i]=inf2;
               for(int j=0;j<=min(i,k);j++)
               {
                    dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
               }
          }
          cout<<dp[n-1]<<endl;
     }
}

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

const int N = 3000;

long long a[N+5][N+5], dp[N+5][N+5][4];

int main(){
    int r, c, k;
    scanf("%d %d %d", &r, &c, &k);
    for (int i = 1; i <= k; ++i){
        int x, y, v;
        scanf("%d %d %d", &x, &y, &v);
        a[x][y] = v;
    }
    for (int i = 1; i <= r; ++i){
        for (int j = 1; j <= c; ++j){
            long long _max = max(max(dp[i-1][j][0], dp[i-1][j][1]), max(dp[i-1][j][2], dp[i-1][j][3]));
            dp[i][j][0] = max(_max, dp[i][j-1][0]);
            dp[i][j][1] = max(dp[i][j-1][1], max(_max, dp[i][j-1][0]) + a[i][j]);
            dp[i][j][2] = max(dp[i][j-1][2], dp[i][j-1][1] + a[i][j]);
            dp[i][j][3] = max(dp[i][j-1][3], dp[i][j-1][2] + a[i][j]);
        }
    }
    long long ans = max(max(dp[r][c][0], dp[r][c][1]), max(dp[r][c][2], dp[r][c][3]));
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 355784
import numpy as np
n,w=map(int,input().split())
wv=[]
for _ in range(n):
    wv.append(list(map(int,input().split())))
dp=np.zeros(w+1,np.int64)
for i in range(n):# i番目までの商品について全ての重さについて調べる
    w_=wv[i][0]
    v_=wv[i][1]
    dp[w_:]=np.maximum(dp[w_:],dp[:-w_]+v_)

print(dp[-1])


Measured memory_bytes: 15492
MAX_N = 2000
a = [ord(char) for char in input()]
b = [ord(char) for char in input()]
c = [ord(char) for char in input()]


len_a = len(a)
len_b = len(b)
len_c = len(c)

a = a + [63] * (MAX_N - len_a + 10)
b = b + [63] * (MAX_N - len_b + 10)
c = c + [63] * (MAX_N - len_c + 10)

ab = [True] * (2 * MAX_N + 10)
ba = [True] * (2 * MAX_N + 10)
bc = [True] * (2 * MAX_N + 10)
cb = [True] * (2 * MAX_N + 10)
ca = [True] * (2 * MAX_N + 10)
ac = [True] * (2 * MAX_N + 10)


for length in range(MAX_N + 1):
    for i in range(MAX_N + 1):
        if i + length > MAX_N:
            break

        if a[i + length] != b[i] and a[i + length] != 63 and b[i] != 63:
            ab[length] = False
        if b[i + length] != a[i] and b[i + length] != 63 and a[i] != 63:
            ba[length] = False

        if b[i + length] != c[i] and b[i + length] != 63 and c[i] != 63:
            bc[length] = False
        if c[i + length] != b[i] and c[i + length] != 63 and b[i] != 63:
            cb[length] = False

        if c[i + length] != a[i] and c[i + length] != 63 and a[i] != 63:
            ca[length] = False
        if a[i + length] != c[i] and a[i + length] != 63 and c[i] != 63:
            ac[length] = False


ans = MAX_N * 6
for len1 in range(MAX_N + 1):
    for len2 in range(MAX_N + 1):
        if ab[len1] and bc[len2] and ac[len1 + len2]:
            tmp = max(len_a, len_b + len1, len_c + len1 + len2)
            ans = min(ans, tmp)
        if ba[len1] and ac[len2] and bc[len1 + len2]:
            tmp = max(len_b, len_a + len1, len_c + len1 + len2)
            ans = min(ans, tmp)

for len1 in range(MAX_N + 1):
    for len2 in range(MAX_N + 1):
        if bc[len1] and ca[len2] and ba[len1 + len2]:
            tmp = max(len_b, len_c + len1, len_a + len1 + len2)
            ans = min(ans, tmp)
        if cb[len1] and ba[len2] and ca[len1 + len2]:
            tmp = max(len_c, len_b + len1, len_a + len1 + len2)
            ans = min(ans, tmp)

for len1 in range(MAX_N + 1):
    for len2 in range(MAX_N + 1):
        if ca[len1] and ab[len2] and cb[len1 + len2]:
            tmp = max(len_c, len_a + len1, len_b + len1 + len2)
            ans = min(ans, tmp)
        if ac[len1] and cb[len2] and ab[len1 + len2]:
            tmp = max(len_a, len_c + len1, len_b + len1 + len2)
            ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 85032
using System;

namespace algorithm
{
	class Program
	{
		
		static void Main(string[] args)
		{

			string[] s = Console.ReadLine().Split(' ');
			var N = int.Parse(s[0]);
			var Y = int.Parse(s[1]);
			for (int i = 0; i <= N; ++i)
			{
				for (int j = 0; j <= N - i; ++j)
				{
					var k = N - i - j;
					var sum = 10000 * i + 5000 * j + 1000 * k;
					if (sum == Y)
					{
						Console.WriteLine($"{i} {j} {k}");
						return;
					}
				}
			}
			Console.WriteLine("-1 -1 -1");
		}

	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define INF 1001001001
typedef long long ll;
typedef pair<int, int> P;

int main(){
  long long n;
  cin >> n;
  vector<long long> a(n);
  for(int i=0;i<n;i++)cin >> a[i];
  
  map<long long, long long> mp;
  long long ans=0;
  for(int i=0;i<n;i++){
    ans += mp[i-a[i]];
    mp[a[i]+i]++;
  }

  cout << ans;
  
  return 0;
}


Measured memory_bytes: 27388