akhauriyash/Code-Regression huggingface dataset:
n = int(input())

hs = list(map(int,input().split()))

ans = True

hs.reverse()
pre_n = 10 ** 9 + 1
can_sub = True
for n in hs:
    #print("{} {}".format(pre_n, n))
    if n - 1> pre_n:
        ans = False
        break
    elif n - 1 == pre_n:
        if can_sub:
            pre_n = n -1
            can_sub = False
        else:
            pre_n = n -1
            can_sub = False
    elif n == pre_n:
        pre_n = n
        can_sub = False
    else:
        pre_n = n
        can_sub = True

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 63984
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, q; cin >> n >> q;
  string s; cin >> s;
  vector<int> cnt(n, 0);
  REP(i, n - 1) {
    if (s[i] == 'A' && s[i + 1] == 'C') ++cnt[i + 1];
  }
  FOR(i, 1, n) cnt[i] += cnt[i - 1];
  while (q--) {
    int l, r; cin >> l >> r; --l; --r;
    cout << cnt[r] - cnt[l] << '\n';
  }
  return 0;
}


Measured memory_bytes: 1488
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

    int a[3];
    int b[3];
    for(int i=0;i<3;i++)cin>>a[i];
    for(int i=0;i<2;i++)cin>>b[i];
    int res=1000000000;
    for(int i=0;i<3;i++){
        for(int j=0;j<2;j++){
            res=max(0,min(res,a[i]+b[j]-50));
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 0
import itertools

def p(n, m):
    l = range(1, m+1)
    return list(itertools.combinations_with_replacement(l, n))

def require(n, m, e):
    point = 0
    l = p(n, m)
    for i in list(l):
        tmp = 0
        for a,b,c,d in e:
            if i[b-1] - i[a-1] == c:
                tmp += d
        if tmp > point:
            point = tmp
    print(point)

n,m,q  = [int(i) for i in input().split()]
e = []

for _ in range(q):
    e.append([int(i) for i in input().split()])

require(n,m,e)

Measured memory_bytes: 22152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
 
#define rep(i,n) for(long long i=0;i<n;i++)
using namespace std;
 
long long aa(long long cnt)
{
	return cnt * (cnt - 1) / 2;
}
 
 
int main() {
	
 
	long long  n;
	cin >> n;
 
	vector<long long> A(n);
	rep(i, n) cin >> A[i];
	rep(i, n) A[i]--;
 
	vector<long long> cnt(n);
	rep(i, n) cnt[A[i]] += 1;
 
	long long ans = 0;
 
	rep(i, n) ans += aa(cnt[i]);
 
	long long anss;
	rep(i, n)
	{
		anss = 0;
 
		anss = ans + aa(cnt[A[i]] - 1)- aa(cnt[A[i]]);
 
		cout << anss << endl;
	}
	
	
 
	return 0;
}
 
 

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007

long long comb(int n, int r)
{
    if (r == 0) return 1;
    return comb(n, r - 1) * (n + 1 - r) / r;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    vector<long long> v(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int mc = 0;
    double ave = 0;
    for (int i = 0; i < a; ++i)
    {
        ave += v[n - i - 1];
    }
    ave /= a;
    printf("%.9f\n", ave);
    for (int i = 0; i < n; ++i)
    {
        if (v[n - 1] == v[i])
        {
            ++mc;
        }
    }
    if (mc > a)
    {
        long long ans = 0, cmb = comb(mc, a);
        for (int i = a; i <= mc && i <= b; ++i)
        {
            ans += cmb;
            cmb = cmb * (mc - i) / (i + 1);
        }
        cout << ans << "\n";
        return 0;
    }
    int bc = 0, cc = 0;
    for (int i = 0; i < n; ++i)
    {
        if (v[n - a] == v[i])
            ++bc;
        if (v[n - a] < v[i])
            ++cc;
    }
    cout << comb(bc, a - cc) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <cassert>
#include <iostream>
using namespace std;
const int mod = 1000000007;
const int N = 105, M = 8;	int dp[N][M];
int main() {
	int H, W, K;
	cin >> H >> W >> K;
 dp[0][0] = 1;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			for (int k = 0; k < 1 << (W - 1); ++k) {
				// Check if two horizontal lines are connecting
				// 2 つの横線がつながっていないか調べる
				bool ok = true;
				for (int l = 0; l < W - 2; ++l) {
					if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
						ok = false;
					}
				}
				if (ok) {
					if (j >= 1 && ((k >> (j - 1)) & 1)) {
						// The case which goes left
						// 左方向に横線をたどるケース
						dp[i + 1][j - 1] += dp[i][j];
						dp[i + 1][j - 1] %= mod;
					}
					else if (j <= W - 2 && ((k >> j) & 1)) {
						// The case which goes right
						// 右方向に横線をたどるケース
						dp[i + 1][j + 1] += dp[i][j];
						dp[i + 1][j + 1] %= mod;
					}
					else {
						// The case which goes straight
						// 横線をたどらないケース
						dp[i + 1][j] += dp[i][j];
						dp[i + 1][j] %= mod;
					}
				}
			}
		}
	}
	cout << dp[H][K - 1] << '\n';
	return 0;
}


Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <math.h>
#define int long long
using namespace std;

signed main() {
    double a, b, x;
    cin >> a >> b >> x;
    double border = a * a * b / 2;
    double ans;
    if (x > border) {
        double y = 2 * (b - x / pow(a, 2));
        ans = atan(y / a);
    }
    else if (x == border) {
        ans = atan(b / a);
    }
    else {
        double y = 2 * x / a / b;
        ans = atan(b / y);
    }
    ans = ans * 180 / M_PI;
    cout << setprecision(10) << ans << "\n";
}

Measured memory_bytes: 256
import collections
import math

inp = int(input())
A = []
for a in range(inp):
    A.append(input())

def charcnt(s):
    cset = {}
    for c in s:
        if c in cset:
            cset[c] += 1
        else:
            cset[c] = 1
    sortedset = sorted(cset.items(), key=lambda x:x[0])
    s = ""
    for k, v in sortedset:
        s += k + str(v)
    return s

sorted = [charcnt(v) for v in A]    

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


counted = collections.Counter(sorted)
cnt = 0
for v in counted.values():
    if v > 1:
        cnt += cmb(v, 2)
print(int(cnt))


Measured memory_bytes: 27684
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 610

vector<pair<int,int> > G[SIZE], rG[SIZE];

int main(){
  int N, M;

  cin >> N >> M;

  for (int i=0; i<M; i++) {
    int s, t;
    cin >> s >> t;
    s--; t--;
    G[s].push_back({t, i});
    rG[t].push_back({s, i});
  }

  double ans = 1e20;

  for (int j=0; j<N; j++) {
    double dp[SIZE] = {};
    bool flag = true;

    dp[N-1] = 1;
    for (int i=N-1; i>=0; i--) {
      int counter = G[i].size();

      if (i == j && counter > 1) {
        double maxVal = 0;
        for (auto p : G[i]) {
          maxVal = max(maxVal, dp[p.first]);
        }
        dp[i] -= maxVal + 1;
        counter -= 1;
      }

      if (dp[i] < 1e-10)
        flag = false;

      counter = max(counter, 1);
      dp[i] /= counter;

      for (auto p : rG[i]) {
        int to = p.first;
        dp[to] += dp[i] + 1;
      }
    }

    debug(flag);
    debug(dp[0]);

    if (flag)
      ans = min(ans, dp[0]);
  }

  printf("%.10lf\n", ans - 1);

  return 0;
}


Measured memory_bytes: 4864
h,w=map(int,input().split())

a = [input() for _ in range(h)]
dp=[[0 for i in range(w)] for j in range(h)]
MOD=10**9+7
if a[0][0]==".":
    dp[0][0]=1

for i in range(h):
    for j in range(w):
        if a[i][j]==".":
            if j-1>=0 :
                dp[i][j]+=dp[i][j-1]
            if i-1>=0:
                dp[i][j]+=dp[i-1][j]
            dp[i][j]%=MOD
        else:
            continue

print(dp[h-1][w-1]%MOD)

Measured memory_bytes: 54364
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
#define vi vector<int>
long long mod=1000000007;
//int count=INT_MAX;
 
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcases=1;
    //cin>>testcases;
    //cout<<t;
    //scanf("%d",&t);
    while(testcases--){  
        // ll k;
        // cin>>k;
        // if(k%2LL==0LL){
        //     cout<<"-1\n";
        //     continue;
        // }
        // if(k==7){
        //     cout<<"1\n";
        //     continue;
        // }
        // if(k%7==0){
        //     k=k/7;
        // }
        int n;
        cin>>n;
        string s;
        cin>>s;
        int w=0,r=0;
        fori(0,n){
            if(s[i]=='W') w++;
            else r++;
        }
        int ans=min(r,w);
        int c=0;
        fori(0,r){
            if(s[i]=='W') c++;
        }
        ans=min(ans,c);
        cout<<ans<<endl;
    }                                                                                          
    
    return 0;
}

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

using namespace std;

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
#define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

const ll MOD = 1e9 + 7;
const ll maxn = 2e5 + 5;

void solve(){
    ll n,k;
    cin >> n >> k;
    ll ans =0;
    for(ll i=1;i<=n;i++){
	if(((k-2*i)%k+k)%k==0)
	ans += ((n+i)/k - i/k)*((n+i)/k - i/k);
    }
    cout<<ans;
}

int main() {
    IOS
	
        solve();
    cerr << endl << "[ Time : " << (float) clock() / CLOCKS_PER_SEC << " secs ]" << endl;

}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


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

bool check(vector<pair<long long int, long long int>>&ps) {
	long long int  now = 0;
	for (auto p : ps) {
		if (now <= p.first) {
			now += p.second;
		}
		else {
			return false;
		}
	}
	return true;
}
int main() { 
	int N; cin >> N;
	vector<pair<long long int,long long int>>ps;
	for (int i = 0; i < N; ++i) {
		int h, p; cin >> h >> p;
		ps.emplace_back(h, p);
	}
	sort(ps.begin(), ps.end(), [](const pair<long long int, long long int>l, const pair<long long int, long long int>r) {
		return l.second < r.second;
	});
	long long int now = 0;
	int ans = 0;
	vector<pair<long long int, long long int>>used;
	for (auto p : ps) {
	
		auto nextused = used;
		auto it = lower_bound(nextused.begin(), nextused.end(), p, [](const pair<long long int, long long int>l, const pair<long long int, long long int>r) {
			return l.first + l.second < r.first + r.second;
		});
		nextused.insert(it,p);
		if (check(nextused)) {
			used = nextused;
		}
	}
	ans = used.size();
	cout << ans << endl;
	return 0;
}

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

int main()
{
    string s1, s2, s3;
    char dif = 'A' - 'a';
    cin >> s1 >> s2 >> s3;
    char s11 = s1[0] + dif;
    char s22 = s2[0] + dif;
    char s33 = s3[0] + dif;
    cout << s11 << s22 << s33 << endl;
}


Measured memory_bytes: 3644
n, m = io.read("*n", "*n")
x = {}
x[1] = io.read("*n")
y = {}
y[1] = io.read("*n")
for i = 1, n do
  x[i + 1] = io.read("*n")
end
for i = 1, m do
  y[i + 1] = io.read("*n")
end
table.sort(x)
table.sort(y)
f = y[1] <= x[#x]
print(f and "War" or "No War")


Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
//解説AC
int main() {
  int x,y;
  cin >>x>>y;
  int kotae=INT_MAX;
  if(x<=y)kotae=min(kotae,y-x);
  if(-x<=y)kotae=min(kotae,x+y+1);
  if(x<=-y)kotae=min(kotae,-x-y+1);
  if(-x<=-y)kotae=min(kotae,x-y+2);
  cout<<kotae<<endl;
  return 0;
}
 

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;

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

  int32_t K;
  cin >> K;
  for (int i = 0; i < K; i++) {
    cout << "ACL";
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
typedef long long int ll;

double arr[3000];
double dp[3000][3000];
int n;
double find(int i, int h) {
	if (i >= n) {
		if (h >= (n + 1) / 2)
			return 1;
		return 0;
	}

	if (dp[i][h] > -1)
		return dp[i][h];

	return dp[i][h] = arr[i] * find(i + 1, h + 1) + (1 - arr[i]) * find(i + 1, h);
}


int main() {

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		// cout << arr[i] << endl;
	}

	memset(dp, -1, sizeof dp);
	cout << fixed << setprecision(10) << find(0, 0);
	return 0;
}




Measured memory_bytes: 74344
n, ma, mb = map(int, input().split(" "))
info_med = []
for _ in range(n):
  info_med.append(list(map(int, input().split(" "))))
info_med.sort(key=lambda x: x[2])
dp = []
dp.append([(0, 0, [-1])])

for min_c in range(1, n * 100 + 1):
  temp_list = []
  for i, (a, b, c) in enumerate(info_med):
    if min_c - c >= 0:
      for pre_a, pre_b, pre_i in dp[min_c - c]:
        if pre_i[-1] < i:
          if (a + pre_a) * mb == (b + pre_b) * ma:
            print(min_c)
            exit()
          temp_list.append((a + pre_a, b + pre_b, pre_i + [i]))
  dp.append(temp_list)
print("-1")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define INF 0x3f3f3f3f
#define MAX (1<<20)
#define MOD 1000000007
#define i64 long long
#define all(x) (x).begin() , (x).end()
#define sz(x) (int)(x).size()
#define ii pair<i64, i64>
#define fs first
#define sc second
#define eb emplace_back
#define vi vector<i64>
#define vvi vector<vi>
#define vii vector<ii>
#define vvii vector<vii>
#define lsb(x) ((x) & (-x))
#define gcd(x,y) __gcd((x),(y))

using namespace std;

map<ii, i64> f;
vii dir;
vi pot2;
i64 n, xz, yz, zz, a, b, ans, fator;

int main(){_
    cin >> n;
    
    pot2.eb(1);
    for (int i=n; i--;){
        pot2.eb((2*pot2.back())%MOD);
    }

    dir = vii(n);
    for (auto &[x, y] : dir){
        cin >> x >> y;

        if (!x) {
            if (!y){
                ++zz;
                continue;
            }else{
                ++xz;
            }
        }else if (!y){
            ++yz;
        }
        
        if (x<0){
            x = -x; y = -y;
        }

        i64 mdc = abs(gcd(x, y));
        x /= mdc; y/=mdc;
        
        ++f[{x,y}];
    }
    
    ans = 1LL;
    
    fator = (pot2[xz] + pot2[yz] - 1LL + MOD)%MOD;
    ans = (ans * fator) % MOD;

    for (auto [p, c] : f){
        i64 x = p.fs, y=p.sc;

        // cout << x << " " << y << " >> " << c << endl;

        if (!x || !y || !c) continue;

        a = (y > 0 ? y : -y);
        b = (y > 0 ? -x : x);

        fator = (pot2[c] + pot2[f[{a,b}]] - 1LL + MOD) % MOD;
        ans = (ans * fator) % MOD;

        f[{a,b}] *= !(f[{a,b}]);
    }


    cout << (ans-1LL+zz+MOD)%MOD << endl;

    return 0;
}

Measured memory_bytes: 32916
N=int(input())
A=[int(input()) for _ in range(N)]
grundy=0
edible=set()
def solve(grundy, edible):
  ans=0
  while grundy:
    b=(1<<grundy.bit_length())-1
    if b not in edible:
      return -1
    ans+=1
    grundy^=b
  return ans
for a in A:
  grundy^=a
  edible.add(a^(a-1))
print(solve(grundy,edible))

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

int main(){
    int N;
    cin>>N;
    long double x[11];
    string u[11];
    long double ans=0;
    for(int i=0;i<N;i++){
        cin>>x[i]>>u[i];
        if(u[i]=="JPY") ans+=x[i];
        else ans+=x[i]*380000;
    }

    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
H, W, K = map(int, input().split())
s = [list(input()) for _ in range(H)]
a = [[0] * W for _ in range(H)]
c = 0
for i in range(H):
  x = 0
  for j in range(W):
    if s[i][j] == "#":
      c += 1
      x = c
    a[i][j] = x
  if x == 0: continue
  x += 1
  for j in range(W - 1, -1, -1):
    if s[i][j] == "#":
      x -= 1
    if a[i][j] == 0:
      a[i][j] = x
for i in range(1, H):
  for j in range(W):
    if a[i][j] == 0:
      a[i][j] = a[i - 1][j]
for i in range(H - 2, -1, -1):
  for j in range(W):
    if a[i][j] == 0:
      a[i][j] = a[i + 1][j]
for i in range(H):
  print(" ".join(list(map(str, a[i]))))

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

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

    int N=s.length();
    int i, j;
    for (i=0; i<N-1; i++) {
        for (j=0; j<2; j++) {
            if (s[i]==s[i+j+1]) {
                cout << i+1 << " " << i+j+2 << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1\n";
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;

int dp[100010];
int h[100010];
int fuc(int n){
    if(dp[n]==-1){
        dp[n]=min(fuc(n-1)+abs(h[n]-h[n-1]),fuc(n-2)+abs(h[n]-h[n-2]));
    }
    return dp[n];
}

int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&h[i]);
        dp[i]=-1;
    }
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    printf("%d",fuc(n));
    return 0;
}


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

int n;
long long a[100010];
long long b[100010];
long long c[100010];
long long dp[100010][3];

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= 2; ++j) {
      dp[i][j] = 0;
    }
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= 2; ++j) {
      if (j == 0) {
        dp[i][j] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
      } else if (j == 1) {
        dp[i][j] = max(dp[i - 1][2], dp[i - 1][0]) + b[i];
      } else if (j == 2) {
        dp[i][j] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
      }
    }
  }

  cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]) << endl;
  return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define pb push_back

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

void solve() {

}

int dp[110000][110];
int main() {
  int x;
  cin >> x;
  int n = x / 100;
  x %= 100;
  dp[0][0] = 1;
  rep(i,n) {
    rep(j,100) {
      if( dp[i][j] == 0 ) continue;
      rep(k,6) {
	int nex = i + 1;
	int nev = j + k;
	if( nev >= 100 ) {
	  ++nex;
	  nev -= 100;
	}
	dp[nex][nev] = dp[i][j];
      }
    }
  }
  cout << dp[n][x] << endl;
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
int a[100010];
bool boolean = false;
int main()
{
	int n;
	int ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;)
	{
		if(a[i] == i)
		{
			a[i] =0;
			a[i+1]=0;
			ans++;
			i+=2;
		}
		else
		{
			a[i] = 0;
			i+=1;
		}
	}
	if(a[n] !=0 && a[n-1] == 0)
		ans++;
	printf("%d",ans);
	return 0;
}

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

int main()
{
	int num1,num2;

	for(num1=1;num1<=9;num1++){

		for(num2=1;num2<=9;num2++){
			int ans = num1*num2;
			cout << num1 << "x" << num2 << "=" << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
#define d_arr(arr, h, w) rep(i,(h) ){ cout << "["; rep(j,(w) ) { cout << (arr)[i][j] << ", "; } cout << "]" << endl;}
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x);

typedef pair<int ,int> P;

class car
{
    int id;
    int num;
    public:
        car(int x, int y){ id=x; num=y; }
};


int main()
{
    char grid[1000][1000];
    int dp[1000][1000];
    int N;
    int maxn = 0;
    cin >> N;
    while ( N !=0 )
    {
        maxn = 0;
        rep(i,N){
            rep(j,N){
                cin >> grid[i][j];
            }
        }
        

        rep(i,N){
            rep(j,N){
                if(grid[i][j] == '*') { dp[i][j] = 0; continue; }
                if(i == 0 && j == 0){
                    dp[i][j] = 1;
                } else if( i == 0 | j == 0) {
                    dp[i][j] = 1;
                } else {
                    dp[i][j] = 1 + min( min(dp[i-1][j],dp[i][j-1]), dp[i-1][j-1] ) ;
                    //cout << "min(" << dp[i-1][j] << "," << dp[i][j-1] << "," << dp[i-1][j-1] << ") = " << endl;
                    //cout << dp[i][j] << endl;
                }
            }
        }

        rep(i,N){
            rep(j,N){
                if( maxn < dp[i][j]) { maxn = dp[i][j]; }
            }
        }
        cout << maxn << endl;

        cin >> N;
    }
    return 0;
}

Measured memory_bytes: 6040
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
    std::cin >> N;
    std::vector<int64_t> T(N);
    for (auto& v : T) std::cin >> v;

    int64_t ans = T[0];
    for (int64_t i = 1; i < N; i++)
    {
        ans = std::lcm(ans, T[i]);
    }

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

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


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

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

vector<ll> A;
vector<ll> sumtill;

ll judge(ll index){
    ll now = sumtill[index];
    for(ll i = index+1; i<A.size(); i++){
        if((now*2)<A[i]) return false;
        else now += A[i];
    }
    return true;
}

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

    rep(i,N){
        ll inp; cin >> inp;
        A.pb(inp);
    }
    sort(all(A));
    
    ll s = 0;
    rep(i,N){
        s += A[i];
        sumtill.pb(s);
    }
    

    
    ll l = 0;
    ll r = N-1;
    while((l+1) < r){
        ll m = (l+r)/2;
        if(judge(m))r = m;
        else l = m;
    }
    if(judge(l) == true) cout << N << endl;
    if(judge(l) == false) cout << N - r << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 2548
#include <iostream>

int check(int x, int& y) {
  int times = 0;
  while (y <= x) {
    ++times;
    y *= 2;
  }
  return times;
}

int main() {
  int a, b, c, k;
  std::cin >> a >> b >> c >> k;
  int times = 0;
  times += check(a, b);
  times += check(b, c);
  if (times <= k) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

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

  int mingap = 1000;

  for(int i = 0; i < s.size()-2; i++){
   int dummy = ((int)(s[i]-'0'))*100 + ((int)(s[i+1]-'0'))*10 + ((int)(s[i+2]-'0'));

   int com = 753 - dummy;
   if(com < 0) com *= -1;

   if(mingap > com) mingap = com;

  }

  cout << mingap << endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define REP(i,n) for(int i=0;i<signed(n);i++)
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
const ll MOD = 1000000007;
const ll INF = 9e9;
ll N, M, ans = INF;
ll A[300010], S[301000];

using namespace std;
int main() {
	//fill(begin(A), end(A), 0);
	fill(begin(S), end(S), 0);
	//N = M = 0;
	std::ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> A[i];
		S[i] += A[i];
		S[i + 1] = S[i];
	}
	//a:右半分の区切り i:真ん中 b:左半分
	//s:右の和 t:左の和
	ll a = 0, b = 2, s, t;
	REP(i, N - 1) {
		if (i == b)b++;
		s = (S[i] - S[a]) - S[a];
		t = (S[N - 1] - S[b]) - (S[b] - S[i]);
		bool f = true;
		if (i == 0)continue;
		while (f) {
			f = false;
			if (a + 1 == i)continue;
			if (abs(s)>abs(s - A[a + 1] * 2)) {
				s -= A[a + 1] * 2;
				a++; f = true;
			}
		}
		f = true;
		while (f) {
			f = false;
			if (b + 1 == N - 1 || b == N - 1)continue;
			if (abs(t)>abs(t - A[b + 1] * 2)) {
				t -= A[b + 1] * 2;
				b++; f = true;
			}
		}
		ans = min(ans, (max({ S[a],S[i] - S[a],S[b] - S[i],S[N - 1] - S[b] })
			- min({ S[a],S[i] - S[a],S[b] - S[i],S[N - 1] - S[b] })));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define int long long int
    int n,m,sum=0,cn=0,flag=0,cn1=0;
    cin>>n>>m;
    int a[n+1000];
    for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
    int w=4*m;
    float x=(float)sum/(float)w;
    for(int i=0;i<n;i++)
    {
        if(a[i]>=x){cn++;}
    }
   if(cn<m)cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
int q;
vector<ll> qs,x,s,t;
ll f(ll b){
    for(int i=0;i<q;i++){
            if(qs[i]==1){
                if(b>=x[i]){
                    b+=s[i];
                    b*=t[i];
                }
            }else{
                if(b<=x[i]){
                    b-=s[i];
                    b/=t[i];
                }
            }
        }
    return b;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,l,r;cin>>n>>q>>l>>r;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(all(a));
    qs.resize(q);
    x.resize(q);
    s.resize(q);
    t.resize(q);
    for(int i=0;i<q;i++){
        cin>>qs[i]>>x[i]>>s[i]>>t[i];
    }
    int ok=0,ng=n;
    while(ng-ok>1){
        int mid=(ok+ng)/2;
        if(f(a[mid])<l){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    int lb=ok;
    if(f(a[lb])>=l){
        --lb;
    }
    ok=0,ng=n;
    while(ng-ok>1){
        int mid=(ok+ng)/2;
        if(f(a[mid])<=r){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    int rb=ok;
    if(f(a[rb])>r){
        --rb;
    }
    cout<<(rb-lb)<<endl;
}



Measured memory_bytes: 10444
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;

const LL INF=1<<30;
const LL MOD=1000000007;

    const int maxv=210;

    LL d[maxv][maxv];
    int n;

    void warshall(){
    for(int k=0;k<n;++k){
        for(int j=0;j<n;++j){
            for(int i=0;i<n;++i){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    cin>>n;
    int m,r;
    cin>>m>>r;
    VEC rr(r);

    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            if(i==j)d[i][j]=0;
            if(i!=j)d[i][j]=INF;
        }
    }

    for(int i=0;i<r;++i){
        cin>>rr[i];
        rr[i]--;
    }

    sort(rr.begin(),rr.end());

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

    warshall();

    LL ans=INF;

    do{
        LL kari=0;
        for(int i=0;i<r-1;++i){
            kari+=d[rr[i]][rr[i+1]];
        }
        ans=min(ans,kari);
    }while(next_permutation(rr.begin(),rr.end()));

    cout<<ans<<endl;
}



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


int main(){
    while(1){
        vector<int> a(2);
        cin >> a[0] >> a[1];

        if(a[0]==0 && a[1]==0) break;

        if(a[0] < a[1]){
            cout << a[0] << ' ' << a[1] << endl;
        }else{
            cout << a[1] << ' ' << a[0] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3016
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(a[K-1])

Measured memory_bytes: 38384
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d %d %d",&c,&a,&b);
  if(a >= b){
    printf("delicious\n");
  }else if(b - a <= c){
    printf("safe\n");
  }else{
    printf("dangerous\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void)
{
	double h[10000];
	int ptr=0;
	while(cin >> h[ptr]){
		ptr++;
	}
	double max=h[0];
	double min=h[0];
	for(int i=1; i<ptr; i++){
		if(h[i]>max) max = h[i];
		if(h[i]<min) min = h[i];
	}
	cout << max-min<< endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define all(a)	begin(a),end(a)
#define mp(a,b)	make_pair(a,b)
#define fst	first
#define scn second

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;

double dp[110][110] = { { 0 } };
bool L[110] = { 0 }, B[110] = { 0 };

int main() {
	while (true) {
		int n, t, l, b;	cin >> n >> t >> l >> b;
		if (n == 0)	break;
		REP(i, t)	REP(j, n)	dp[i][j] = 0;
		REP(i, n)	L[i] = B[i] = false;
		dp[0][0] = 1;
		rep(i, l) {
			int Lin = 0;	 cin >> Lin;
			L[Lin] = true;
		}
		rep(i, b) {
			int Bin = 0; cin >> Bin;
			B[Bin] = true;
		}
		rep(i, t) {
			rep(j, n) {
				if (dp[i][j] < eps)	continue;
				rep(k, 6) {
					int to = j + k + 1;
					if (to > n)	to = 2 * n - to;
					if (B[to])	dp[i + 1][0] += dp[i][j] / 6.0;
					else if (L[to])	dp[i + 2][to] += dp[i][j] / 6.0;
					else	dp[i + 1][to] += dp[i][j] / 6.0;
				}
			}
			dp[i + 1][n] += dp[i][n];
		}
		printf("%.15lf\n", dp[t][n]);
	}
	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    
    int n = 2*a - 1;
    for (int i = 1; i <= n; i++){
        cout << b -a + i << " ";
    }
    
    return 0 ;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class Task{
		
		public void solve(int numTest, InputReader in, PrintWriter out) {
			int njob = in.nextInt(),mday = in.nextInt();
			pair[] lj = new pair[njob];
			for(int n = -1; ++n < njob;) 
				lj[n] = new pair(in.nextInt(), in.nextInt());
			Arrays.sort(lj);
			PriorityQueue<Integer> que = new PriorityQueue<Integer>(new Comparator< Integer>() {

				@Override
				public int compare(Integer o1, Integer o2) {
					// TODO Auto-generated method stub
					return o2-o1;
				}
			});
			int j = 0, res = 0;
			for(int day = 0; ++day <mday+1;) {
				
				while(j < njob &&lj[j].f == day) {
					que.add(lj[j].s);
					j++;
				}
				if(!que.isEmpty()) res+=que.poll();
			}
			out.print(res);
		}//solve

		
	}//task
	
	
/*


*/		
	static class pair implements Comparable<pair>{
		int f,s;

		public pair(int f, int s) {
			this.f = f;
			this.s = s;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			return f-o.f;
		}
		
	}
	
	static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		public String next() {
			while(tokenizer==null||!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		
	}
		
}

Measured memory_bytes: 44452
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
   ll d,s,t;
   cin >> d >> s >> t;
   if(s*t>=d) cout <<"Yes";
   else cout <<"No";
}

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

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

int main()
{
  int n;
  cin >> n;
  vector<double> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  double res = 0.0;
  for (int i = 0; i < n; i++) {
    res += 1.0 / v.at(i);
  }
  cout << 1.0 / res << '\n';
  return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll n = S.size();
    cout << string(n, 'x') << endl;
    

}

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

int main()
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(S == U){
        A--;
    }else{
        B--;
    }
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

// int gcd(int a, int b){
//   if (a%b==0){
//     return(b);
//   }
//   else{
//     return(gcd(b,a%b));
//   }
// }

int x[110];
int y[110];
int h[110];

int main(){
  int N;
  cin >> N;
  rep(i,N){
    cin >> x[i] >> y[i] >> h[i];
  }
  
  rep(i,101){
    rep(j,101){
      int cx = i;
      int cy = j;
      int id = 0;
      int height = 0;
      while(1){
	if(h[id] != 0){
	  height = h[id] + abs(cx-x[id]) + abs(cy-y[id]);
	  break;
	}
	id++;
      }
      bool f = true;
      rep(i,N){
	if(h[i] != max(0,height - abs(cx - x[i]) - abs(cy - y[i]))){
	  f = false;
	}
      }
      if(f){
	cout << cx << " " << cy << " " << height << endl;
      }
    }
  }
}



Measured memory_bytes: 256
#include <stdio.h>

int N, M;

int visited[10];
int connected[10][10];

int ans;

void dfs(int now,int depth);

int main() {


	scanf("%d %d",&N,&M);

	int i;

	for (i = 0; i < M; i++) {
		int a, b;
		scanf("%d %d",&a,&b);
		connected[a][b] = 1;
		connected[b][a] = 1;
	}
	dfs(1, 1);
	printf("%d\n",ans);

	return 0;
}
void dfs(int now,int depth) {

	if (depth >= N) { ans++; return; }

	visited[now] = 1;

	int i;

	for (i = 1; i <= N; i++) {
		if (connected[now][i] == 1 && visited[i] == 0) {
			visited[i] = 1;
			dfs(i,depth+1);
			visited[i] = 0;
		}
	}

}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const LL inf=1LL<<60;
LL n,a[200010];
int main()
{
	scanf("%lld",&n);
	for(LL i=1;i<=n;i++) scanf("%lld",&a[i]),a[i]-=i;
	sort(a+1,a+n+1);
	LL ans=0;
	for(LL i=1;i<=n;i++) ans+=abs(a[i]-a[n/2+1]);
	printf("%lld",ans);
	return 0;
}

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

typedef long long ll;
using namespace std;

int main(){
  int N;
  string S;
  cin>>N>>S;

  int ans = 0;

  rep(x, 1000){
    string t;
    int y = x;

    rep(i,3){
      t += '0' + y%10;
      y /= 10;
    }

    int flg = 0;

    rep(i,N){
      if(S[i] == t[flg]){
        flg++;
        if(flg == 3) break;
      }
    }
    if(flg == 3) ans++;
  }

  cout<<ans;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

d = [[float('inf')]*n for i in range(n)]

for i in range(n):
    d[i] = list( map(int, input().split()))

for i in range(n):
    if d[i][i] != 0:
        print(-1)
        exit()

for k in range(n):
    for i in range(n):
        for j in range(n):
            if d[i][j] > d[i][k] + d[k][j]:
                print(-1)
                exit()

ans = 0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i==k or k==j :continue
            if d[i][j] == d[i][k] + d[k][j]:
                break
        else:
            ans += d[i][j]

print(ans//2)


Measured memory_bytes: 44892
#include<stdio.h>
#include<string.h>
char s[16];
char s0[16]={"CODEFESTIVAL2016"};
int num;
int main()
{
	int i;
	scanf("%s",s);
	for(i=0;i<=15;i++)
	{
		if(s[i]!=s0[i])
		  num++;
		else continue;
	}
	printf("%d",num);
	return 0;
}

Measured memory_bytes: 128
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<math.h>
#include<list>
#include<complex>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


ll const MOD = 1e9 + 7;
ll mod_p(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return (x + y + MOD) % MOD;
}

ll mod_m(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return x * y%MOD;
}

ll mod_pow(ll x, ll t) {
	x %= MOD;
	if (t == 0) {
		return 1;
	}
	else {
		ll v = mod_pow(x, t / 2);
		if (t % 2 == 0) {
			return v * v % MOD;
		}
		else {
			return v * v%MOD * x %MOD;
		}
	}
}

ll mod_inv(ll x) {
	return mod_pow(x, MOD - 2);
}

struct edge
{
	ll from; long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};

map<ll, ll> mp1, mp2;

ll chll(char x) {
	return x - 'a';
}
ll const alphsize = 25;

int main() {
	ll ans;
	string s;
	cin >> s;
	ll n = SIZE(s);
	ll stt = 0;
	mp2[0] = 1;
	REP(i, 1, n) {
		char c = s[i - 1];
		ll cur = chll(c);
		stt = stt ^ BIT(cur);
		ll tmp = 1e18;
		if (mp2[stt] == 1) {
			tmp = mp1[stt];
		}
		REP(i, 0, alphsize) {
			ll now = stt ^ BIT(i);
			if (mp2[now] == 1) {
				tmp = min(tmp, mp1[now]);
			}
		}
		tmp++;
		if (mp2[stt] == 0) {
			mp2[stt] = 1;
			mp1[stt] = tmp;
		}
		else {
			mp1[stt] = min(mp1[stt], tmp);
		}
		if (i == n) {
			ans = mp1[stt];
		}
	}
	if (ans) {
		cout << ans << endl;
	}
	else {
		cout << 1 << endl;
	}
}

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

int main(){
	int i=0;
	char s[1002];
	scanf("%s",&s);
	while(s[i]!='\0'){
		if(s[i]>='D')s[i]-=3;
		else s[i]+=23;
		i++;
	}
	printf("%s\n",s);
}

Measured memory_bytes: 1100
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;

    int yoko=abs(tx-sx);
    int tate=abs(sy-ty);

    rep(i,yoko){cout<<'R';}
    rep(i,tate){cout<<'U';}
    rep(i,yoko){cout<<'L';}
    rep(i,tate){cout<<'D';}
    cout<<'D';
    rep(i,yoko+1){cout<<'R';}
    rep(i,tate+1){cout<<'U';}
    cout<<"LU";
    rep(i,yoko+1){cout<<'L';}
    rep(i,tate+1){cout<<'D';}
    cout<<'R'<<endl;


    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    X, Y = [0] * N, [0] * N
    for i in range(N):
        X[i], Y[i] = map(int, input().split())
    A=[i for i in range(N)]
    ans = 0
    cnt=0
    for k in permutations(A,N):
        for i in range(N-1):
            ans+=np.sqrt((X[k[i]]-X[k[i+1]])**2+(Y[k[i]]-Y[k[i+1]])**2)
        cnt+=1

    print(ans/cnt)

resolve()

Measured memory_bytes: 12508
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REV(v) reverse(v.begin(),v.end())
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    ll ans = 0;
    ll MOD = 1e9+7;
    FOR(i,k,n+2){
        (ans += (n+n-i+1)*i/2 - (i-1)*i/2 + 1) %= MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; ++ i) {
		int ai;
		cin >> ai;
		N -= ai;
	}
	cout << max(-1, N) << endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  vector<int>A(3);
  for(int i=0;i<3;i++)cin>>A[i];
  int Min=INT_MAX;
  do{
    int res=0;
    for(int i=1;i<3;i++){
      res+=abs(A[i-1]-A[i]);
    }
    Min=min(Min,res);
  }while(next_permutation(rng(A)));
  cout<<Min<<endl;
  return 0;
}


Measured memory_bytes: 256