akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;

int main(){
    long long h, w;
    cin >> h >> w;

    char maze[h][w];

    for(long long i = 0; i < h; i++){
        for(long long j = 0; j < w; j++){
            cin >> maze[i][j];
        }
    }

    long long maxv = 0;
    for(long long sy = 0; sy < h; sy++){
        for(long long sx = 0; sx < w; sx++){
            for(long long gy = 0; gy < h; gy++){
                for(long long gx = 0; gx < w; gx++){
                    if(maze[gy][gx] == '#' || maze[sy][sx] == '#') continue;
                    queue<pair<long long, long long> > q;
                    vector<vector<long long> > distance(h, vector<long long> (w, -1));
                    q.push(make_pair(sy, sx));
                    distance[sy][sx] = 0;
                    long long dy[] = {1, -1, 0, 0};
                    long long dx[] = {0, 0, 1, -1};

                    while(!q.empty()){
                        pair<long long, long long> top;
                        top = q.front();
                        q.pop();

                        for(long long i = 0; i < 4; i++){
                            if(0 <= top.first+dy[i] and top.first+dy[i] < h and 0 <= top.second+dx[i] and top.second+dx[i] < w and distance[top.first+dy[i]][top.second+dx[i]] == -1 and maze[top.first+dy[i]][top.second+dx[i]] == '.'){
                                distance[top.first+dy[i]][top.second+dx[i]] = distance[top.first][top.second] + 1;
                                q.push(make_pair(top.first+dy[i], top.second+dx[i]));
                            }
                        }
                    }
                    maxv = max(maxv, distance[gy][gx]);
                }
            }
        }
    }

    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 3620
n = gets.chomp.to_i
h_arr = gets.chomp.split(" ").map(&:to_i)

count = 0
h_arr.each_cons(2) do |h1, h2|
  if h1 - h2 >= 2 then
    puts "No"
    exit 0
  end
  if h1 > h2 then
    count += 1
  elsif h1 < h2
    count = 0
  end
  if count == 2 then
    puts "No"
    exit 0
  end
end

puts "Yes"


Measured memory_bytes: 11652
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll at[30][200010];
ll bt[30][200010];
ll rt[30];

void solv() {
	ll n;
	cin >> n;

	for (size_t i = 0; i < n; i++)
	{
		ll v;
		cin >> v;
		for (size_t j = 0; j < 30; j++)
		{
			at[j][i] = v % (1 << (j + 1));
		}
	}
	for (size_t i = 0; i < n; i++)
	{
		ll v;
		cin >> v;
		for (size_t j = 0; j < 30; j++)
		{
			bt[j][i] = v % (1 << (j + 1));
		}
	}

	for (size_t i = 0; i < 30; i++)
	{
		sort(bt[i], bt[i] + n);
	}

	ll res = 0;
	for (size_t i = 0; i < 30; i++)
	{
		for (size_t j = 0; j < n; j++)
		{
			ll a = at[i][j];
			ll t = 1 << i;
			ll t2 = t * 2;
			ll t3 = t * 3;
			ll t4 = t * 4;
			int ran1 = lower_bound(bt[i],bt[i] + n,t2 - a) - lower_bound(bt[i], bt[i] + n, t - a);
			int ran2 = lower_bound(bt[i], bt[i] + n, t4 - a) - lower_bound(bt[i], bt[i] + n, t3 - a);
			rt[i] += ran1 + ran2;
		}
		if (rt[i] % 2)
			res += 1 << i;
	}
	cout << res << endl;
}


int main() {
	solv();

	return 0;
}


Measured memory_bytes: 93952
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
long long int __lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
 //__gcd 最大公約数
 //__lcm 最小公倍数

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  cout<<min(a*b,c);
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a, b, c, S;

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

  if (a > b) {
    S = a;
    a = b;
    b = S;
  }

  if (b > c) {
    S = b;
    b = c;
    c = S;
  }

  if (a > b) {
    S = a;
    a = b;
    b = S;
  }

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

  return 0;
}
   

Measured memory_bytes: 1796
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = LI()
    if len(A) == len(list(set(A))):
        print('YES')
    else:
        print('NO')

main()



Measured memory_bytes: 27896
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

const int INF = INT_MAX / 4;
const double EPS = 1e-12;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int main()
{
	while ( true )
	{
		int n, s;
		cin >> n >> s;

		if ( !( n | s ) )
		{
			break;
		}

		VI rs( n );

		EACH( r, rs )
		{
			cin >> r;
		}

		int res = 0;

		REP( i, 0, n )
		{
			REP( j, i + 1, n )
			{
				if ( s < rs[i] + rs[j] )
				{
					res++;
				}
			}
		}

		cout << res << endl;
	}


	return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
int main(void)
{
    int w,h,c,i,a,b;
	scanf("%d %d %d",&w,&h,&c);
	for(i=1;i<=w;i++){
	    if(w%i==0&&h%i==0){
		    a=i;
		}
	}
	b=(w/a)*(h/a)*c;
	printf("%d\n",b);
	return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

template <typename OM>
struct DualSegmentTree {
  using H = function<OM(OM,OM)>;
  int n,lev;
  H h;
  OM OM0;
  vector<OM> lz;
  DualSegmentTree() {}
  DualSegmentTree(H h, OM OM0) : h(h), OM0(OM0) {}
  void init(int n_) {
    for (n = 1, lev = 0; n < n_; n <<= 1, lev++);
    lz.assign(n << 1, OM0);
  }
  inline void eval(int k) {
    if (lz[k] == OM0) return;
    lz[(k << 1) | 0] = h(lz[(k << 1) | 0], lz[k]);
    lz[(k << 1) | 1] = h(lz[(k << 1) | 1], lz[k]);
    lz[k] = OM0;
  }
  inline void thrust(int k) {
    for (int i = lev; i > 0; i--) eval(k >> i);
  }
  void update(int a, int b, OM x) {
    thrust(a += n);
    thrust(b += n - 1);
    for (int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if (l & 1) lz[l] = h(lz[l], x), l++;
      if (r & 1) --r, lz[r] = h(lz[r], x);
    }
  }
  void set(int k, OM x) {
    thrust(k += n);
    lz[k] = x;
  }
  OM operator[] (int k) {
    thrust(k += n);
    return lz[k];
  }
};

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N,Q;
  cin >> N >> Q;
  vector<int> S(N),T(N),X(N),D(Q),ord(N,0);
  iota(ALL(ord),0);
  REP(i,N) cin >> S[i] >> T[i] >> X[i];
  REP(i,Q) cin >> D[i];
  sort(ALL(ord),[&](int a, int b) {
    return X[a] > X[b];
  });
  auto h = [](int a, int b) { return b; };
  DualSegmentTree<int> DST(h,-1);
  DST.init(Q);
  REP(i,N) {
    int s = S[ord[i]];
    int t = T[ord[i]];
    int x = X[ord[i]];
    int L = lower_bound(ALL(D),s-x) - D.begin();
    int R = lower_bound(ALL(D),t-x) - D.begin();
    DST.update(L,R,x);
  }
  REP(i,Q) cout << DST[i] << endl;

  return 0;
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

ll mpow(ll x,ll t,ll m){
   ll res=1;
   while(t){
      if(t&1)res=(__int128_t(res)*x)%m;
      x=(__int128_t(x)*x)%m; t>>=1;
   } return res;
}

bool isp(ll n){
   if(n<2 or n%2==0)return (n==2);
   ll d=n-1; while(d%2==0)d>>=1;
   for(ll x:{2,325,9375,28178,450775,9780504,1795265022}){
      if(n<=x)break;
      ll t=d,y=mpow(x,t,n);
      while(t!=n-1 and y!=1 and y!=n-1){
         y=(__int128_t(y)*y)%n; t<<=1;
      }
      if(y!=n-1 and t%2==0)return 0;
   } return 1;
}

vector<ll> pollard(ll n){
   if(n<=1)return {};
   if(isp(n))return {n};
   if(n%2==0){
      vector<ll> v=pollard(n/2); v.push_back(2);
      return v;
   }
   for(ll c=1,x=2,y=2,d;;c++){
      do{
         x=(__int128_t(x)*x+c)%n;
         y=(__int128_t(y)*y+c)%n;
         y=(__int128_t(y)*y+c)%n;
         d=__gcd(x-y+n,n);
      }while(d==1);
      if(d<n){
         vector<ll> lb=pollard(d),rb=pollard(n/d);
         lb.insert(lb.end(),ALL(rb)); return lb;
      }
   }
}

int cnt[1010101]={};

int main(){
   int n; cin>>n;
   vector<int> a(n);
   rep(i,0,n)cin>>a[i];
   rep(i,0,n){
      auto v=pollard(a[i]);
      sort(ALL(v)); v.erase(unique(ALL(v)),v.end());
      for(auto& x:v){
         if(cnt[x]>0){
            goto fail;
         }
         cnt[x]++;
      }
   }
   puts("pairwise coprime"); return 0;
   fail:;

   int t=a[0];
   rep(i,1,n)t=gcd(t,a[i]);
   if(t==1)puts("setwise coprime");
   else puts("not coprime");
   return 0;
}

Measured memory_bytes: 7572
/*
* @author:  codancer
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
int main(){
	int n;
	cin>>n;
	cout<<(n+1)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
class Combination {
    //a^p%mod
    ll powmod(ll a, ll p) {
        ll ans = 1LL;
        ll mul = a;
        // p >>=1 <-> p=(p >> 1)
        for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }

        return ans;
    }
public:
    int N;
    ll mod;
    vector<ll> fact;
    vector<ll> revFact;

    Combination(int n, ll m) : N(n), mod(m), fact(n+1), revFact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i-1] * i;
            fact[i] %= mod;
        }

        // Fermat's little theorem
        revFact[N] = powmod(fact[N], mod - 2);

        for (int i = N-1; i >= 0; i--) {
            revFact[i] = revFact[i+1] * (i+1);
            revFact[i] %= mod;
        }
    }

    ll get(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a) return 0;
        return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
    }
};


ll MOD = 1e9 + 7;

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

    Combination cm = Combination(2000000, MOD);

    ll ans = 0;
    if((x + y) % 3 == 0){
        int m = (2 * x - y) / 3;
        int n = (x + y) / 3 - m;

        if(m >= 0 && n >= 0){
            ans = cm.get((x + y) / 3, m);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 31488
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        int m = sc.nextInt();

        int[][] reqs = new int[m][2];

        for (int i = 0; i < m; i++) {
            reqs[i] = new int[]{sc.nextInt(), sc.nextInt()};
        }

        Arrays.sort(reqs, (a1, a2) -> a1[1] - a2[1]);
//        debug(reqs);

        int count = 0;
        int max = 0;
        for (int i = 0; i < m; i++) {
            int[] req = reqs[i];
            if (max <= req[0]) {
                max = req[1];
                count++;
            }
        }
        System.out.println(count);

        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 64036
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char x;
  cin >> x;
  if(x == 'a' || x == 'i' || x == 'u' || x == 'e' || x == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

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

int main() {
    long N, T[5];
    cin >> N;
    for (int i = 0; i < 5; i++){
        cin >> T[i];

        
    }
    long min = T[0];
    for (int i = 0; i < 5; i++){

        if (min > T[i]) {
            min = T[i];
        }
    }

    cout << 4 + (N + min -1)/min << endl; 
    return 0;
}


Measured memory_bytes: 256
a = gets.to_i

s = gets.chomp.split("").map(&:to_s)

red = 0
blue = 0
a.times do |i|
  if s[i] == "R"
   red = red + 1
  else
   blue = blue + 1
  end

  end
if red > blue
 puts "Yes"
else
 puts "No"
 end


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

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

ll binpow(ll a, ll n) {
    ll res = 1;
    for (; n; n >>= 1) {
        if (n & 1LL) {
            res = (res * a) % MOD;
        }
        a = (a * a) % MOD;
    }
    return res;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<ll> c(k + 1);
    c[1] = 1;
    for (int i = 2; i <= k; ++i) {
        c[i] = binpow(i, n);
        for (int j = 1; j * 1LL * j <= i; ++j) {
            c[i] -= c[j] * (i / j - i / (j + 1));
        }
        for (int j = 2; (i / j) * 1LL * (i / j) > i; ++j) {
            c[i] -= c[i / j];
        }
        c[i] = (c[i] % MOD + MOD) % MOD;
    }
    ll res = 0;
    for (int i = 1; i <= k; ++i) {
        res += c[k / i] * i;
    }
    cout << res % MOD;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);

    solve();
}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,30};
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int ans=0;
    for(int i=1;i<=a;i++)
    {
        if(i==a)
        {
            for(int j=1;j<=b;j++)
                if(j==i) ans++;
        }
        else
        {
            for(int j=1;j<=day[i];j++)
                if(j==i) ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(a,b) for(ll i=a;i<=b;i++)
#define show(x) cout<<x<<"\n"
#define vr vector<ll> 
ll fact(ll n); 
  
ll nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
// Returns factorial of n 
ll fact(ll n) 
{ 
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
int main()
{
	ll n,m;
	cin>>n>>m;
	if(n<2 && m>=2)
	{
		ll temp=(m-1)*m/2;
		show(temp);
	}
	else if(m<2 && n>=2)
	{
		ll temp=(n-1)*n/2;
		show(temp);
	}
	else if(n<2 && m<2)
	{
		show("0");
	}
	else
	{
		ll temp=((n-1)*n+(m-1)*m)/2;
		show(temp);
	}


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		String s = sc.next();
		
		if(a  >= 3200){
			System.out.println(s);
		} else {
			System.out.println("red");
		}
	}
}

Measured memory_bytes: 22356
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <limits>
#include <numeric>

using ld = long double;
using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	/* constant */
	constexpr double epsilon = std::numeric_limits<double>::epsilon();

	/* math */
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	ul inline digit(const ul &num){ return static_cast<ul>(std::log10(num+epsilon))+1; }

	/* algorithm */
	ul gcd(const ul &a,const ul &b) { return (!b) ? a : gcd(b,a%b); }
	ul lcm(const ul &a,const ul &b) { return (a/gcd(a,b))*b; } // a/gcd(a,b)*b <=> (a*b)/gcd(a,b)
	std::vector<bool> eratosthenes(const ul &n)
	{
		std::vector<bool> prime_candidate(n,true);
		prime_candidate[0] = prime_candidate[1] = false;
		for(ul i = 2;i*i < n;++i)
		{
			if(!prime_candidate[i]) continue;
			for(ul j = 2;i*j < n;++j) prime_candidate[i*j] = false;
		}
		return prime_candidate;
	}
	ll rho_method(const ll &n)
	{
		auto f = [&](const ll &xi){ return (xi*xi+1)%n; };
		ll x = 2, y = 2, d = 1;
		while(d == 1)
		{
			x = f(x);
			y = f(f(y));
			d = lamlib::gcd(lamlib::abs(x-y),n);
		}
		return d;
	}
	// 素因数分解(試し割)
	std::vector<ll> prime_factorization_trial(const ll &n)
	{
		ll num = n;
		std::vector<ll> prime;
		for(ll i = 2;i*i <= n;++i)
		{
			while((num%i) == 0)
			{
				prime.emplace_back(i);
				num /= i;
			}
		}
		if(num > 1) prime.emplace_back(num);
		return prime;
	}

	/* string */
	inline ul same_char_count(const std::string s,const char &ch){ return std::count(std::cbegin(s),std::cend(s),ch); }
}

// std::cout << std::fixed << std::setprecision(15) << std::endl;

int main(int argc,char *argv[])
{
	ll n;
	std::cin >> n;

	auto prime = lamlib::prime_factorization_trial(n);

	std::map<ll,ll> m;
	for(auto itr = prime.begin();itr != prime.end();++itr)
		++m[*itr];

	ll ans = 0;
	for(auto itr = m.begin();itr != m.end();++itr)
	{
		ll tmp = itr->second;
		for(ll e = 1;e <= tmp;++e)
		{
			tmp -= e;
			++ans;
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        String s = sc.next();
        int min = 999;
        for (int i = 0; i < s.length() - 2; i++) {
            min = Math.min(min, Math.abs(753 - Integer.valueOf(s.substring(i, i + 3))));
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 23892
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>

template<typename T>inline bool check_min(T a,T &b){return a<b?b=a,1:0;}

namespace RongChi
{
	typedef long long ll;
	typedef std::pair<ll,int> pii;
	const int N=101000,M=N*4,MOD=1000000007;
	const ll INF=1000000000000000ll;
	inline void inc(int a,int &b){b=(a+b)%MOD;}

	int begin[N],next[M],to[M],w[M];
	int n,m,e;

	void work(int S,ll *dis,int *f)
	{
		static std::priority_queue<pii,std::vector<pii>,std::greater<pii> > Q;
		static bool vis[N];

		while(!Q.empty())Q.pop();
		for(int i=1;i<=n;i++)
			dis[i]=INF,f[i]=vis[i]=0;

		dis[S]=0,f[S]=1;
		Q.push(pii(0,S));

		for(int p,q;!Q.empty();)
		{
			p=Q.top().second,Q.pop();
			if(vis[p])continue;
			vis[p]=1;

			for(int i=begin[p];i;i=next[i])
			{
				if(check_min(dis[p]+w[i],dis[q=to[i]]))
					f[q]=f[p],Q.push(pii(dis[q],q));
				else if(dis[p]+w[i]==dis[q])
					inc(f[p],f[q]);
			}
		}
	}

	void add(int x,int y,int z,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		w[e]=z;
		if(k)add(y,x,z,0);
	}

	int S,T;
	void initialize()
	{
		scanf("%d%d",&n,&m);
		scanf("%d%d",&S,&T);
		for(int i=1,u,v,k;i<=m;i++)
		{
			scanf("%d%d%d",&u,&v,&k);
			add(u,v,k);
		}
	}

	ll ds[N],dt[N];
	int fs[N],ft[N];

	int calc(int p)
	{
		return (ll)fs[p]*ft[p]%MOD*fs[p]%MOD*ft[p]%MOD;
	}
	int calc_e(int u,int v)
	{
		return (ll)fs[u]*ft[v]%MOD*fs[u]%MOD*ft[v]%MOD;
	}

	void solve()
	{
		initialize();
		work(S,ds,fs),work(T,dt,ft);

		ll len=ds[T];
		int ans=(ll)fs[T]*fs[T]%MOD;
		
		for(int p=1;p<=n;p++)
		{
			if(ds[p]*2==len)inc(-calc(p),ans);

			for(int i=begin[p],q;i;i=next[i])
			{
				q=to[i];
				if(ds[p]*2<len && dt[q]*2<len && ds[p]+dt[q]+w[i]==len)
				{
					inc(-calc_e(p,q),ans);
				}
			}
		}

		ans=(ans+MOD)%MOD;

		printf("%d\n",ans);
		
	}
}

int main()
{
//	freopen("in","r",stdin);
	RongChi::solve();
	return 0;
}


Measured memory_bytes: 9456
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int dp[450][450] = {};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, ma,mb; cin >> N >> ma >> mb;
    VI a(N), b(N), c(N);
    REP(i,N) cin >> a[i] >> b[i] >> c[i];

    REP(i,450) REP(j,450) dp[i][j] = INF;
    dp[0][0] = 0;
    REP(i,N){
        //REP(j,450) REP(k,450){
        for(int j = 449; j >= 0; j--) for(int k = 449; k >= 0; k--){
            if(j-a[i] >= 0 && k - b[i] >= 0){
                dp[j][k] = min(dp[j][k],dp[j-a[i]][k-b[i]]+c[i]);
            }
        }
    }
    bool ok = 0;
    int Ma = ma;
    int Mb = mb;
    int ans = INF;
    while(Ma < 450 && Mb < 450){
        if(dp[Ma][Mb] != INF){
            ok = 1;
            if(dp[Ma][Mb] < ans) ans = dp[Ma][Mb];
        }
        Ma += ma;
        Mb += mb;
    }
    if(ok) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		if (x % 11 == 0) {
			System.out.println(x/11 * 2);
		} else if (x % 11 > 6) {
			System.out.println(((x / 11)) * 2 + 2);
		} else {
			System.out.println((x / 11) * 2 + 1);
		}
	}

}


Measured memory_bytes: 22996
MOD=10**9+7
L=input()

dp_eq=[2]+[-1]*(len(L)-1)
dp_ne=[1]+[-1]*(len(L)-1)

for i in range(1,len(L)):
  if L[i]=="0":
    dp_eq[i]=dp_eq[i-1]
    dp_ne[i]=3*dp_ne[i-1]%MOD
  elif L[i]=="1":
    dp_eq[i]=2*dp_eq[i-1]%MOD
    dp_ne[i]=(3*dp_ne[i-1]+dp_eq[i-1])%MOD
    
#print(dp)
print((dp_eq[-1]+dp_ne[-1])%MOD)

Measured memory_bytes: 11784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, Y;
    cin >> N >> Y;

    if (Y % 1000 != 0)
    {
        cout << -1 << " " << -1 << " " << -1 << endl;
    }
    else
    {
        Y /= 1000;

        for (int i = 0; i <= N; i++)
        {
            for (int j = 0; j <= N-i; j++)
            {
                for (int k = 0; k <= N-i-j ; k++)
                {
                    if (i + j + k == N && 10*i + 5*j + k == Y)
                    {
                        cout << i << " " << j << " " << k << endl;
                        goto LAST;
                    }
                    
                }
                
            }
            
        }

        cout << -1 << " " << -1 << " " << -1 << endl;
        
    }
    
LAST:
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/perl

my ($a,$b,$c,$d) = map {$_ - 0} split(/\s+/o,<STDIN>);

my $r = 'No';
$r = 'Yes' if abs($a-$c)<=$d or ( abs($a-$b)<=$d and abs($b-$c)<=$d );

print "$r\n";



Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main(){
    const int n = 5;
    int time[n];
    for(int i = 0; i < n; i++) std::cin >> time[i];
    std::vector<int> order(n);
    int minTime = 10000000;
    for(int i = 0; i < n; i++) order[i] = i;

    do{
        int now = 0;
        for(int i = 0; i < n; i++){
            now += time[order[i]];
            if(i != n - 1 && now % 10 != 0){
                now += 10 - now % 10;
            }
        }
        minTime = std::min(now, minTime);
    }while(std::next_permutation(order.begin(), order.end()));

    std::cout << minTime << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int sh,w;
        sh=s.nextInt();
        w=s.nextInt();
        if(sh>w)
            System.out.println("safe");
        else
            System.out.println("unsafe");
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 25396
#include <iostream>
using namespace std;
main () {
	int n, a[4][3][10] = {0};
	cin >> n;
	for (int i=0; i<n; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		a[b-1][f-1][r-1] += v;
	}
	for (int i=0; i<4; i++) {
		for (int j=0; j<3; j++) {
			for (int k=0; k<10; k++) {
				cout << " " << a[i][j][k];
			}
			cout << endl;
		}
		if (i < 3) cout << "####################" << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
const int MAX = 1e5 + 5;
const int MOD = 1e9 + 7;

vector<int>graph[MAX];

int mul(int a, int b)
{
    return (ll) a * b % MOD;
}

pair<int, int>dfs(int nod, int dad)
{
    int all_whites = 1;
    int sth_is_black = 0;

    for(int &x : graph[nod])
        if(x != dad)
        {
            pair<int, int>aux = dfs(x, nod);

            int memo_all_whites = all_whites;
            all_whites = mul(all_whites, aux.second);
            sth_is_black = (mul(memo_all_whites, aux.first) + mul(sth_is_black, aux.first + aux.second)) % MOD;
        }

    return {all_whites, (all_whites + sth_is_black) % MOD};
}
int main()
{
    int n;

    cin >> n;

    for(int i = 1; i < n; i++)
    {
        int a, b;

        cin >> a >> b;

        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    pair<int, int>sol = dfs(1, - 1);

    cout << (sol.first + sol.second) % MOD;

    return 0;
}


Measured memory_bytes: 15864
d = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

int_x = int(d[0])
int_n = int(d[1])




ans = 100000
tmp = abs(int_x - ans)
for i in range(102):
  if tmp > abs(int_x - i):
    if not i in p:
      ans = i
      tmp = abs(int_x - ans)
  

# if len(p) == 0:
#   ans = int_x

print(ans)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define ff first
#define ss second
#define vll vector<ll>
#define vpll vector<pll>
#define eb emplace_back
#define MAX 999999999999999
int main(){
	ll n, m, ans = 0;
	cin >> n >> m;
	ll a[10][10], b;
	for (int i = 0; i < 10; i++){
		for (int j = 0; j < 10; j++){
			cin >> a[i][j];
		}
	}
	for (int k = 0; k < 10; k++){
		for (int i = 0; i < 10; i++){
			for (int j = 0; j < 10; j++){
				if (a[i][j] > a[i][k] + a[k][j]) a[i][j] = a[i][k] + a[k][j];
			}
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> b;
			if (b == -1) continue;
			ans += a[b][1];
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3768
s = input()
def dfs(i,f,sum):
  if i == 3:
    if sum == 7:
      print(f + "=7")
      exit()
  else:
    dfs(i+1,f + "+" + s[i+1],sum+int(s[i+1]))
    dfs(i+1,f + "-" + s[i+1],sum-int(s[i+1]))
dfs(0,s[0],int(s[0]))

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

int main(void){
    int n, count = 0;
    string s;
    
    cin >> n >> s;
    
    for(int i = 0; i < n-2; i++){
        if(s[i] == 'A'){
            if(s[i+1] == 'B'){
                if(s[i+2] == 'C'){
                    count++;
                }
            }
        }        
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	s := make(map[string]int, 4)
	
	tmp := ""
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		s[tmp]++
	}
	
	fmt.Printf("AC x %d\n", s["AC"])
	fmt.Printf("WA x %d\n", s["WA"])
	fmt.Printf("TLE x %d\n", s["TLE"])
	fmt.Printf("RE x %d\n", s["RE"])	
}

Measured memory_bytes: 6332
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int n, m, a[N], b[N], A[N * 10], B[N * 10];
ll ans = 1, s, row, col;
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		if (A[a[i]]) {
			puts("0");
			return 0;
		}
		A[a[i]] = i;
	}
	for (int i = 1; i <= m; ++i) {
		scanf("%d", b + i);
		if (B[b[i]]) {
			puts("0");
			return 0;
		}
		B[b[i]] = i;
	}
	for (int i = n * m; i >= 1; --i) {
		if (A[i] && B[i]) {
			row++;
			//s += n - row;
			col++;
			//s += m - col;
		} else 
		if (A[i]) {
			(ans *= row) %= mod;
			col++;
			//s += n - row - 1;
		} else 
		if (B[i]) {
			(ans *= col) %= mod;
			row++;
			//s += m - col - 1;
		} else {
			s = row * col - (n * m - i);
			if (s == 0) {
				puts("0");
				return 0;
			}
			(ans *= s) %= mod;
			//s--;
		}
	}
	cout << ans;
}

Measured memory_bytes: 6400
#include<iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n, m , A[100][100] , b[100] , c[100];

    cin >> n >> m;
    rep (i,n)
      rep(j,m) cin >> A[i][j];
    rep(i,m) cin >> b[i];

    rep(i,n){
        c[i] = 0;
        rep(j,m){
            c[i] += A[i][j] *b[j];
        }
    }
    rep(i,n) cout << c[i] << endl;

    return 0;
}


Measured memory_bytes: 3112
a = int(input())
 
b=0#約数の個数
 
for num in range(1,a+1):#i:1~inputまで,奇数だけ
  if num % 2 == 1:
  #ある数Niについて約数を数える
    yakusuu = 0
    for i in range(1,num):
      if num % i == 0:
        yakusuu += 1
    if yakusuu == 7:
      b += 1
print(b)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
int a , b , c;
cin >> a >> b >> c;
if (a > b) swap (a, b) ;
if (b > c) swap (b, c);
if (a > b) swap (a, b);
cout << a << " " << b << " " << c << endl;
return 0;
}


Measured memory_bytes: 3084
import java.util.ArrayList;
import java.util.Scanner;

class Main{

	static long[] a;
	static	int N ;
	static	int M ;


	public static void main(String[] args) {
		
		
		Scanner scanner = new Scanner(System.in);

		 String s[] = scanner.next().split("T", -1);
	        int x = scanner.nextInt();
	        int y = scanner.nextInt();
	        
	        ArrayList<Integer> tate = new ArrayList<>();
	        ArrayList<Integer> yoko = new ArrayList<>();
	        
	        
	        for (int i = 1; i < s.length; i++) {
	            if (i % 2 == 0) {		
	                yoko.add(s[i].length());
	            } else {
	                tate.add(s[i].length());
	            }
	        }
	        
	        
	        boolean yokodp[][] = new boolean[yoko.size() + 1][16001];
	        yokodp[0][s[0].length() + 8000] = true;						//マイナスにも対応できるように16000あらかじめ用意しておき、8000を初期位置にする
	        int i = 0;
	        for (Integer dx : yoko) {						//yokoに入っている全ての要素をだす
	            for (int j = 0; j < 16000; j++) {
	                if (yokodp[i][j]) {
	                    if (j + dx <= 16000) {
	                       yokodp[i + 1][j + dx] = true;
	                    }
	                    if (j - dx >= 0) {
	                        yokodp[i + 1][j - dx] = true;
	                    }
	                }
	            }
	            i++;
	        }
	        
	        
	      boolean[][] tatedp = new boolean[tate.size() + 1][16001];
	      tatedp[0][8000] = true;
	        i = 0;
	        for (Integer dy : tate) {
	            for (int j = 0; j < 16000; j++) {
	                if (tatedp[i][j]) {
	                    if (j + dy <= 16000) {
	                       tatedp[i + 1][j + dy] = true;
	                    }
	                    if (j - dy >= 0) {
	                        tatedp[i + 1][j - dy] = true;
	                    }
	                }
	            }
	            i++;
	        }
	        
	        System.out.println(yokodp[yoko.size()][x + 8000] & tatedp[tate.size()][y + 8000] ? "Yes" : "No");






	}


}




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

/// read the question correctly (is y a vowel?)
/// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
#define fi first
#define se second
#define SZ 1000005
const int mx = 1234567;
const double eps = 1e-6;
const int md = 1e9+7;
const double pi = acos(-1.0);

typedef long long ll;

int dr[8] = {-1,-1,+0,+1,+1,+1,+0,-1};// counter clockwise
int dc[8] = {+0,-1,-1,-1,+0,+1,+1,+1};

int ar[mx],xar[mx],uses[mx];
ll arr[mx];
int tab[1000][1000];
string st[1000];
map<int ,int>mpii;
map<int ,char>mpic;
map<char ,int>mpci;
pair<int, int>pr[mx];

int ar1[mx],ar2[mx],ar3[mx],ar4[mx];


int main(){

    int tk=1,n,m;
//    freopen("in.txt","r", stdin);
//    freopen("out.txt","w", stdout);

    while(scanf("%d%d%d",ar + 0,ar + 1, ar + 2) == 3){

        sort(ar, ar + 3);
        if((ar[0]==ar[1] && ar[1] != ar[2]) ||(ar[0]!=ar[1] && ar[1] == ar[2])){
            cout<<"Yes"<<endl;
            continue;
        }
        cout<<"No"<<endl;
    }




    return 0;
}


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    string str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    map<char, int> mpdic;
    for(int i = 0; i < str.size(); i++){
        mpdic[str[i]] = i;
    }
    int tmpNum;
    string ans = "";
    string tmp1, tmp2;
    for(int i = 0; i < s.size(); i++){
        tmpNum = mpdic[s[i]];
        tmpNum = tmpNum + n;
        if(tmpNum >= 26)tmpNum = tmpNum-26;
        ans = ans + str[tmpNum];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// 2016/05/23 Tazoe

#include <iostream>
using namespace std;

// Node?????????
class Node{
public:
	Node* prev;	// ?????????????????????????????????
	Node* next;	// ?¬???????????????????????????????
	int data;	// ?????????
	Node(){prev = 0; next = 0; data = 0;}		// ????????????????????????????????????
};

// List?????????
class List{
public:
	Node head;	// ?????????????????????????????????
	Node* btn;
	List(){head.prev = &head; head.next = &head; head.data =-1;}	// ????????????????????????????????????
	int append(int nd);		// ??????
	int del(int a);			// ??????
	bool search(int d);		// ??¢?´¢
};

// append????????????????????????
int List::append(int nd)
{
	Node* p = new Node();

	if(p==0)
		return -1;		// ?????¢????¢??????¨??????

	Node* q = head.prev;
	Node* r = &head;

	p->prev = q;
	p->next = r;
	p->data = nd;

	q->next = p;
	r->prev = p;

	return 0;			// ??£?????????
}

// del????????????????????????
int List::del(int a)
{
	if(a%2==0){	// ??¶??°
		for(int i=0; i<a; i++){
			btn = btn->next;
			if(btn==&head){
				btn = btn->next;
			}
		}
	}
	else{		// ?\???°
		for(int i=0; i<a; i++){
			btn = btn->prev;
			if(btn==&head){
				btn = btn->prev;
			}
		}
	}

	Node* p = btn;
	btn = btn->next;
	if(btn==&head){
		btn = btn->next;
	}

	Node* q = p->prev;
	Node* r = p->next;

	q->next = r;
	r->prev = q;

	delete p;

	return 0;			// ??£?????????
}

// search?????????????????¢?´¢???
bool List::search(int d)
{
	for(Node* p=head.next; p!=&head; p=p->next){
		if(p->data==d)
			return true;	// ???????????£???
	}

	return false;			// ????????????????????£???
}

// main??¢??°
int main()
{
	int N, M, Q;
	cin >> N >> M >> Q;

	List L;

	for(int i=0; i<N; i++){
		L.append(i);
	}

	L.btn = L.head.next;

	for(int i=0; i<M; i++){
		int a;
		cin >> a;

		L.del(a);
	}

	for(int i=0; i<Q; i++){
		int q;
		cin >> q;

		if(L.search(q)){
			cout << 1 << endl;
		}
		else{
			cout << 0 << endl;
		}
	}

	return 0;
}

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

int main () {
  vector<long long> x(2); 
  rep(i,2) {
    cin >> x[i];
  }
  vector<long long> y(2); 
  rep(i,2) {
    cin >> y[i];
  }
  
  long long ans=-1e18;
  rep(i,2) {
    rep(j,2) {
      if (x[i]*y[j] > ans) {
        ans = x[i]*y[j];
      }
    }
  }
  
  cout << ans << endl;
}

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

int main(){
  using idx= tuple<size_t,size_t,size_t>;
  using Vld  = vector<long double>;
  using VVld = vector<Vld>;
  using VVVld= vector<VVld>;
  using Vb  = vector<bool>;
  using VVb = vector<Vb>;
  using VVVb= vector<VVb>;
  constexpr int Amax= 3;

  size_t N;
  cin >> N;

  vector<size_t> freq(Amax+1);
  int buf;
  for(size_t i=0; i<N; i++){
    cin >> buf;
    freq.at(buf)++;
  }
  const idx goal= make_tuple(freq.at(1),freq.at(2),freq.at(3));

  VVVld dp(N+1, VVld(N+1, Vld(N+1)));
  queue<idx> bfs;
  VVVb pushed(N+1, VVb(N+1, Vb(N+1)));
  dp.at(0).at(0).at(0)= 0.0;
  bfs.push(make_tuple(1,0,0));
  pushed.at(1).at(0).at(0)= true;
  while(!bfs.empty()){
    idx p= bfs.front();
    auto [n1,n2,n3]= p;
    size_t n0= N- (n1+ n2+ n3);
    bfs.pop();

    long double ev= (long double)N/ (long double)(N- n0);
    if(n1 > 0){ ev+= dp.at(n1-1).at(n2).at(n3)  * n1/ (N- n0); }
    if(n2 > 0){ ev+= dp.at(n1+1).at(n2-1).at(n3)* n2/ (N- n0); }
    if(n3 > 0){ ev+= dp.at(n1).at(n2+1).at(n3-1)* n3/ (N- n0); }

    dp.at(n1).at(n2).at(n3)= ev;

    if(p==goal){ break; }
    else{
      if(n0 > 0 && !pushed.at(n1+1).at(n2).at(n3)){
        bfs.push(make_tuple(n1+1,n2,n3));
        pushed.at(n1+1).at(n2).at(n3)= true;
      }
      if(n1 > 0 && !pushed.at(n1-1).at(n2+1).at(n3)){
        bfs.push(make_tuple(n1-1,n2+1,n3));
        pushed.at(n1-1).at(n2+1).at(n3)= true;
      }
      if(n2 > 0 && !pushed.at(n1).at(n2-1).at(n3+1)){
        bfs.push(make_tuple(n1,n2-1,n3+1));
        pushed.at(n1).at(n2-1).at(n3+1)= true;
      }
    }
  }

  long double ans= dp.at(freq.at(1)).at(freq.at(2)).at(freq.at(3));

  cout << fixed;
  cout << setprecision(9) << ans << endl;
}

Measured memory_bytes: 441492
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>g[210];
int p[210];
int z[210];
int v[110][210][210];
int val[110][210][210];
int sz=0;
int dp[2][110][210][210];
int con[31000];
int A=15000;
int calc(int at,int l,int r,int dep){
	if(v[at][l][r])return val[at][l][r];
	if(g[at].size()==0){
		dp[0][at][l][r]=dp[1][at][l][r]=1;
		return val[at][l][r]=p[at]*dep;
	}
	int perm[10];
	for(int i=0;i<g[at].size();i++){
		perm[i]=i;
	}
	int len=g[at].size();
	int best=z[0];
	for(int i=0;i<len;i++){
		best=max(best,-calc(g[at][i],0,sz-1,dep));
	}
	val[at][l][r]=best;
	int r1=9999999;
	int r2=0;
	do{
		int t1=0;
		int t2=0;
		int va=z[l];
		int vb=z[r];
		for(int i=0;i<len;i++){
			int tmp=-calc(g[at][perm[i]],con[A-vb],con[A-va],dep);
			t1+=dp[0][g[at][perm[i]]][con[A-vb]][con[A-va]];
			t2+=dp[1][g[at][perm[i]]][con[A-vb]][con[A-va]];
			if(tmp>va){
				va=tmp;
			}
			if(va>=vb)break;
		}
		r1=min(r1,t1);
		r2=max(r2,t2);
	}while(next_permutation(perm,perm+len));
	dp[0][at][l][r]=r1;
	dp[1][at][l][r]=r2;
	v[at][l][r]=1;
	return val[at][l][r];
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<a;i++){
		int b;scanf("%d",&b);
		for(int j=0;j<b;j++){
			int c;scanf("%d",&c);c--;
			g[i].push_back(c);
		}
	}
	for(int i=0;i<a;i++){
		z[sz++]=p[i];
		z[sz++]=-p[i];
	}
	z[sz++]=11111;
	z[sz++]=-11111;
	std::sort(z,z+sz);
	for(int i=0;i<sz;i++){
		con[z[i]+A]=i;
	}
	for(int i=0;i<a;i++)for(int j=0;j<sz;j++)for(int k=0;k<sz;k++){
		dp[0][i][j][k]=dp[1][i][j][k]=-1;
	}
	calc(0,0,sz-1,1);
	//for(int i=0;i<a;i++)printf("%d\n",val[i][0][sz-1]);
	printf("%d %d\n",dp[0][0][0][sz-1],dp[1][0][0][sz-1]);
}

Measured memory_bytes: 76700
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int x;
	cin >> x;
	if (x <= 599){
		cout << "8" << endl;
	}
	else if (x <= 799){
		cout << "7" << endl;
	}
	else if (x <= 999){
		cout << "6" << endl;
	}
	else if (x <= 1199){
		cout << "5" << endl;
	}
	else if (x <= 1399){
		cout << "4" << endl;
	}
	else if (x <= 1599){
		cout << "3" << endl;
	}
	else if (x <= 1799){
		cout << "2" << endl;
	}
	else if (x <= 1999){
		cout << "1" << endl;
	}
	return 0;
}

Measured memory_bytes: 3612
k = int(input())

x = 7 % k
cnt = 1

while 10000:
    if k % 2 ==0 or k%5==0:
        print('-1')
        break
        
    if x == 0:
        print(cnt)
        break
        
    x = x*10+7
    x = x % k
    
    cnt += 1

Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int k, n;
    cin >> k >> n;
    vector<int> A(n + 1);
    rep(i, n) cin >> A[i];
    A[n] = k + A[0];
    int ans = INF;
    rep(i, n) {
        chmin(ans, k - (A[i + 1] - A[i]));
    }
    cout << ans << endl;
}

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


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main(){
  int n;
  cin >> n;
  vl L(n);
  rep(i, 0, n)
    cin >> L[i];
  
  ll cnt = 0;
  
  rep(i, 0, n){
    rep(j, i, n){
      rep(k, j, n){
        if(L[i] == L[j] || L[i] == L[k] || L[k] == L[j])
          continue;
        ll mx = max(L[i], L[j]);  
        mx = max(mx, L[k]);
        if(L[i] + L[j] + L[k] > 2*mx)
          cnt++;
      }
    }
  }
  
  cout << cnt << endl;
  
  return 0;
  
}

Measured memory_bytes: 3632