akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define clr(a, b) memset(a, b, sizeof(a))
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

int sq(int x) {
    return x*x;
}

double dist(pair<int, int> p1, pair<int, int> p2) {
    return sqrt(sq((p1.first - p2.first)) + sq((p1.second - p2.second)));
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    vector<int> vv(n);
    forn(i, n) {
        cin >> v[i].first >> v[i].second;
        vv[i] = i;
    }
    double res = 0.0;
    //int c = 0;
    do {
        double p = 0;
        forn(i, n-1) {
            p += dist(v[vv[i]], v[vv[i+1]]);
        }

        //cout << "p: " << p << "\n";
        res += p;
      //  ++c;
    }while(next_permutation(all(vv)));
   // cout << "c: " << c << "\n";
    int p = 1;
    forab(i, 1, n) {
        p = i*p;
    }
    cout << fixed << setprecision(10) << res/(p*1.0) << "\n";
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline().strip()

S = list(input())
T = list(input())

for i in range(len(S)-len(T), -1 ,-1):
	judge = 1
	for j in range(len(T)):
		if S[i + j] != T[j] and S[i + j] != '?':
			judge = 0
			break
	if judge == 1:
		S[i:i+len(T)] = T[0:len(T)]
		for j in range(len(S)):
			if S[j] == '?':
				S[j] = 'a'
		print("".join(S))
		exit()

print("UNRESTORABLE")





Measured memory_bytes: 38256
import sys
sys.setrecursionlimit(10**6)
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
c = list(map(int, input().split()))
ans = [n*(n+1)//2 for _ in range(n)]
for i in range(n):
	c[i] -= 1
adj = [[] for _ in range(n)]
for _ in range(n-1):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)

s = 0
dp = [0 for _ in range(n)]

def dfs(x, p):
	global s
	pres = s + dp[c[x]]
	for v in adj[x]:
		if v == p:
			continue
		dp[c[x]] = -s
		dfs(v, x)
		ans[c[x]] -= (s+dp[c[x]]) * (s+dp[c[x]]+1) // 2
	s += 1
	dp[c[x]] = pres - s
	return

dfs(0, -1)
for i in range(n):
	ans[i] -= (s+dp[i]) * (s+dp[i]+1) // 2

print(*ans, sep="\n")

Measured memory_bytes: 293916
#include<stdio.h>
#include<algorithm>
using namespace std;
int s[100010];
int f(int l,int r,int n)
{
    int m;
    while(r - l >= 1)
    {
        m = (l + r) / 2;
        if(s[m] == n)return 0;
        if(s[m] < n && s[m + 1] > n)return min(n - s[m],s[m + 1] - n);
        if(s[m] > n && s[m - 1] < n)return min(n - s[m - 1],s[m] - n);
        if(s[m] < n)l = m + 1;
        else r = m;
    }
}
int main()
{
    int n,o,n_s,n_o,ans;
    while(scanf("%d",&n),n)
    {
        scanf("%d%d",&n_s,&n_o);
        s[0] = 0;s[n_s] = n;
        for(int i = 1; i < n_s; i++)scanf("%d",&s[i]);
        sort(s,s + n_s);
        ans = 0;
        for(int i = 0; i < n_o; i++)
        {
            scanf("%d",&o);
            ans = ans + f(0,n_s + 1,o);
        }
        printf("%d\n",ans);
    }
}

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int temp=max(max(a,b),c);
	int temp1=min(min(a,b),c);
	int temp2=a+b+c-temp-temp1;
	cout << temp1 << " " << temp2 << " " << temp << endl;

	return 0;
}



Measured memory_bytes: 3108
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
int32_t main()
{
   IOS;
  /* #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);//abcabca
   #endif
   /********************* Code starts here ***********************/	
   //3 5 -1
   //3+2+6+1=12
   //
   int n;
   cin>>n;
   vector<int>a;
   a.pb(0);
   for(int i=1;i<=n;i++)
   {
   	int x;
   	cin>>x;
   	a.pb(x);
   }
   a.pb(0);
   int t=0;
   for(int i=1;i<=n+1;i++)
   {
   	t=t+abs(a[i]-a[i-1]);
   }
   for(int i=1;i<n+1;i++)
   {
   	int ans=t;
   	ans=ans-abs(a[i]-a[i-1]);
   	ans=ans-abs(a[i]-a[i+1]);
   	ans=ans+abs(a[i-1]-a[i+1]);
   	cout<<ans<<endl;
   }
}

Measured memory_bytes: 2164
n = int(input())
s = str(input())

cnt = 0
"""
for i in range(n - 2):
    for j in range(i + 1,n -1):
        for k in range(j + 1,n):
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k] and j - i != k - j:
                cnt += 1
                """

for i in range(n -2):
    num = 1
    while i + (num)* 2 <= n -1:
        if s[i] != s[i + num] and s[i] != s[i + 2 * num] and s[i + num] != s[i + 2 * num]:
            cnt += 1
        num += 1
print(s.count("R") * s.count("G") * s.count("B") - cnt)

Measured memory_bytes: 9200
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    MOD = 10 ** 9 + 7
    S = rl().rstrip()
    
    N = len(S)
    dp = [[0 for _ in range(13)] for _ in range(N + 1)]
    dp[0][0] = 1
    
    for i in range(N):
        if S[i] == '?':
            for j in range(10):
                for k in range(13):
                    dp[i + 1][(k * 10 + j) % 13] += dp[i][k] % MOD
        else:
            num = int(S[i])
            for j in range(13):
                dp[i + 1][(j * 10 + num) % 13] += dp[i][j] % MOD
    print(dp[N][5] % MOD)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 91504
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;
const ll INF = 1000000000;

ll N,X;
vector<ll> B, P;

ll f(int n, ll x) {
    if(x==0) return 0;
    if(n==0) return 1;
    if(x <= B[n-1]+1) return  f(n-1, x-1);
    else if(x == B[n-1]+2) return f(n-1, x-2) + 1;
    else return P[n-1] + 1 + f(n-1, x-B[n-1]-2);
}

int main() {
    ll n, x; cin >> n >> x;
    B.resize(n+1);
    P.resize(n+1);
    B[0] = 1;
    P[0] = 1;
    REPP(i,n) {
        B[i] = 2*B[i-1] + 3;
        P[i] = 2*P[i-1] + 1;
    }
    ll ans = f(n,x);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define si set<int>
#define msi map<string, int>
#define rsz(a) resize(a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;
int digits(int n) {
  n = abs(n);
  if(n < 10) return 1;
  elif(n < 100) return 2;
  elif(n < 1000) return 3;
  elif(n < 10000) return 4;
  elif(n < 100000) return 5;
  elif(n < 1000000) return 6;
  elif(n < 10000000) return 7;
  elif(n < 100000000) return 8;
  elif(n < 1000000000) return 9;
  else return 10;
}


int main() {
  io();
  
  int h, a;
  cin >> h >> a;
  int total = 0;
  fori(i, a) {
  	int a;
    cin >> a;
    total += a;
  }
  if (total >= h) cout << "Yes";
  else cout << "No";
  
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll  n,x,t;cin>>n>>x>>t;
  cout<<((n+x-1)/x)*t<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce

#N個整数
#n, s = list(map(int, input().split()))

# 1整数
n = int(input())

# 空白区切りリスト整数
s = input()

count = 0
for c in s:
    if c=='R':
        count += 1
if n//2 < count:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 4444
def make_array_for_comb(N, mod=10**9+7):
    fact = [1,1]
    fact_inv = [1,1]
    inv = [0,1]
    for i in range(2, N+1):
        fact.append((fact[-1]*i) % mod)
        # モジュラ逆数の性質
        inv.append((-inv[mod%i] * (mod//i)) % mod)
        fact_inv.append((fact_inv[-1]*inv[i]) % mod)
    return fact, fact_inv

def comb(n, r, mod=10**9+7):
  if (r < 0) or (n < r):
      return 0
  r = min(r, n - r)
  return fact[n] * fact_inv[r] * fact_inv[n-r] % mod

import sys
input = sys.stdin.readline
mod = 10**9+7  
n,k = [int(i) for i in input().split()]
fact, fact_inv = make_array_for_comb(n,mod)
a = [int(i) for i in input().split()]
a = sorted(a)
a = tuple(a)

ans = 0
for i in range(0,n-k+1):
  p = a[i]*comb(n-1-i,k-1,mod)
  ans -= (p%mod)
  ans %= mod
for i in range(k-1,n):
  q = a[i]*comb(i,k-1,mod)
  ans += (q%mod)
  ans %= mod
print(ans)

Measured memory_bytes: 23228
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

int main() {
    int n, i;
    map <int, int> mp;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int x;
        
        scanf("%d", &x);
        
        mp[x]++;
    }
    
    if (mp[0] == n) {
        puts("Yes");
    } else if (n % 3 == 0) {
        map <int, int>::iterator it;
        
        if (mp[0] * 3 == n) {
            for (it = mp.begin(); it != mp.end(); it++) {
                if (it->second * 3 == n * 2) {
                    puts("Yes");
                    
                    return 0;
                }
            }
            
            puts("No");
        } else {
            vector <int> v;
            
            for (it = mp.begin(); it != mp.end(); it++) {
                if (it->second * 3 == n) v.push_back(it->first);
            }
            
            if (v.size() == 3 && (v[0] ^ v[1] ^ v[2]) == 0) {
                puts("Yes");
            } else {
                puts("No");
            }
        }
    } else {
        puts("No");
    }
    
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vl a(n+1),b(n);
  rep(i,n+1)cin >> a[i];
  rep(i,n)cin >> b[i];
  ll sum = 0;
  rep(i,n){
    ll l = min(a[i],b[i]);
    b[i]-=l;
    ll r = min(b[i],a[i+1]);
    a[i+1]-= r;
    sum+=(r+l);
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 4716
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    string S, T;
    cin >> S >> T;
    auto G = make_v(26, 26, 0);
    vector<int> IN(26, 0), OUT(26, 0);
    REP(i, 0, S.size()) {
        int a = S[i] - 'a';
        int b = T[i] - 'a';
        G[a][b] = 1;
    }
    REP(i, 0, 26) {
        REP(j, 0, 26) {
            IN[j] += G[i][j];
            OUT[i] += G[i][j];
        }
    }
    REP(i, 0, 26) {
        if (IN[i] >= 2 || OUT[i] >= 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

int main(){
  string S;
  bool flag = false;
  cin >> S;
  for(ll i=1;i<3;i++){
      if(S[0]!=S[i]){
          flag=true;
      }
  }
  if(flag){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }
  
  return 0;
 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n;  cin >> n;
    vector<int>a(n);
    rep(i, n)   cin >> a[i];
    int ans = 0;
    rep(i, n)   ans ^= a[i];
    if(ans == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int[][] A = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                A[i][j] = scan.nextInt();
            }
        }
        int N = scan.nextInt();
        int[] b = new int[N];
        for (int i = 0; i < N; i++) {
            b[i] = scan.nextInt();
        }
        boolean[][] done = new boolean[3][3];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (A[j][k] == b[i]) {
                        done[j][k] = true;
                    }
                }
            }
        }
        boolean bingo = false;
        for (int i = 0; i < 3; i++) {
            if (done[i][0] && done[i][1] && done[i][2]) {
                bingo = true;
            }
            if (done[0][i] && done[1][i] && done[2][i]) {
                bingo = true;
            }
        }
        if (done[0][0] && done[1][1] && done[2][2]) {
            bingo = true;
        }
        if (done[2][0] && done[1][1] && done[0][2]) {
            bingo = true;
        }
        System.out.println(bingo ? "Yes" : "No");
    }
}


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

int main() {
	const char cf[] = "CODEFESTIVAL2016";

	int count = 0;
	for (int i = 0; i < 16; ++i)
		count += static_cast<int>(getchar() != cf[i]);

	std::cout << count << std::endl;
}

Measured memory_bytes: 256
S = gets.chomp
K = gets.to_i

def count(s)
  res = 0
  s.scan(/(.)\1+/){res += $&.size/2}
  res
end

single = count(S)
double = count(S+S)
triple = count(S+S+S)

if double - single == triple - double
  p single + (K - 1) * (double - single)
else
  a = (double - single) * 2 - 1
  p a*K/2
end


Measured memory_bytes: 1788
// Author: pankaj_m05

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define f_in(file) freopen(file, "r", stdin)
#define f_out(file) freopen(file, "w", stdout)
#define sz(a) int((a).size())
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) c.begin(), c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())  // Set and Maps
#define cpresent(c,x) (find(allc,x) != c.end()) // Vectors
using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef long long ll;

const int mod = 1e9 + 7;
const int mxN = 100;
int n, x;
bool a[mxN + 2];

void testcase() {
	cin >> x >> n;
	if (n == 0) {
		cout << x << '\n';
		return;
	}
	for (int i=0;i<n;i++) {
		int t;
		cin >> t;
		a[t] = 1;
	}
	int l=0, r=100;
	for (int i=x; i>=0; --i) {
		if(a[i])
			continue;
		l = i;
		break;	
	}
	for (int i=x; i<102; ++i) {
		if(a[i])
			continue;
		r = i;
		break;	
	}
	cout << (x-l<=r-x?l:r) << '\n';
}

int main(void) { 
	fast
	testcase();
	return 0;
}                                          

Measured memory_bytes: 3556
import java.util.Scanner;
	public class Main
		{ public static void main(String[] args)
			{   
			    Scanner scanner = new Scanner(System.in);
			    int N = scanner.nextInt();
			    int[] a = new int[N];
			    int count = 0;
			    int v = 1;
			    int flg = 0;
			    
			    for (int i = 0; i < N; i++) {
			    	a[i] = scanner.nextInt();
			    } 
			    
			    for (int i = 0; i < N; i++) {
			    	v = a[v-1];
			    	
			    	count ++;
			    	if (v == 2) {
			    		System.out.println(count);
			    		count = 0;
			    		break;
			    	}
			    	
			    }
			    
			    if (count == N) {
			    	System.out.println(-1);
			    }
		}
		}

Measured memory_bytes: 50640
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        double xx = Math.abs(x1 - x2);
        double yy = Math.abs(y1 - y2);
        double xxyy = Math.pow(xx, 2) + Math.pow(yy, 2);
        double result = Math.sqrt(xxyy);
        System.out.println(result);
    }
}



Measured memory_bytes: 28172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数
uintmax_t combination(unsigned int n, unsigned int r){    //組み合わせ
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n);
    rep(i,n){
        cin >> a[i]>> b[i];
    }

    vector<pair<int, int>> ab(n);
    rep(i,n){
        ab[i] = make_pair(a[i], b[i]);
    }
    sort(ab.begin(), ab.end());

    ll ans=0;
    rep(i, n)
    {
        //店で購入する数を決める
        int buy = min(m, ab[i].second);
        ans += (ll)buy * ab[i].first;
        m -= buy;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val edges = mutableListOf<Pair<Int, Int>>()
    val g = Array(n + 1) { mutableListOf<Int>() }
    repeat(m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        edges.add(a to b)
        g[a].add(b)
        g[b].add(a)
    }

    fun dfs(i: Int): Boolean {
        val ignore = edges[i].let { setOf(it.first, it.second) }
        val visited = BooleanArray(n + 1) { false }

        fun rec(u: Int): Int {
            visited[u] = true
            var cnt = 1
            for (v in g[u]) {
                if (visited[v]) continue
                if (ignore.contains(u) && ignore.contains(v)) continue
                cnt += rec(v)
            }
            return cnt
        }

        return rec(1) < n
    }

    println((0 until m).count { dfs(it) })
}

Measured memory_bytes: 38120
#include <iostream>
using namespace std;
int main()
{
  int h,w;
  cin>>h>>w;
  char a[h][w];
  int n[h][w];
  for(int i=0;i<h;i++)
  {
  	for(int j=0;j<w;j++)
  	{
  		a[i][j]=' ';
  		n[i][j]=0;
	  }
  }
  for(int i=0;i<h;i++)
  {
    for(int j=0;j<w;j++)
    {
      cin>>a[i][j];
    }
  }
  for(int i=0;i<h;i++)
  {
  	for(int j=0;j<w;j++)
  	{
  		if(a[i][j]=='#')
  		n[i][j]=0;
  		else
  		{
        if(i==0)
        {
        	if(j==0)
        	n[i][j]=1;
        	else
        	n[i][j]=n[i][j-1];
		}
		else
		{
			if(j==0)
			n[i][j]=n[i-1][j];
			else
			n[i][j]=(n[i][j-1]+n[i-1][j])%1000000007;
		}
	   }
	}
  }
  int x=n[h-1][w-1];
  cout<<x;
}

Measured memory_bytes: 8040
#include <bits/stdc++.h>
using namespace std;
inline int read(int &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
inline void write(int x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}
const int N=305;
int n,m,lim,d[N][N],d2[N][N],q;
signed main(){
	read(n);read(m);read(lim);
	memset(d,60,sizeof d);
	memset(d2,60,sizeof d2);
	for(int i=1,x,y,z;i<=m;i++){
		read(x);read(y);
		d[x][y]=d[y][x]=read(z);
	}
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	for(int i=1;i<=n;i++)
		d2[i][i]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) if(d[i][j]<=lim)
			d2[i][j]=1;
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				d2[i][j]=min(d2[i][j],d2[i][k]+d2[k][j]);
	read(q);
	while(q--){
		int x,y;
		read(x);read(y);
		write(d2[x][y]==d[0][0]?-1:d2[x][y]-1);puts("");
	}
}

Measured memory_bytes: 1280
while True:
    n = int(input())
    if n == 0:
        break

    s = list(map(int,input().split()))
    m = 0
    sum = 0
    for i in range(n):
        sum += s[i]
    m = sum/n

    tmp = 0
    for i in range(n):
        tmp += (s[i]-m)**2
    print((tmp/n)**0.5)

Measured memory_bytes: 7760
#include<stdio.h>

int main(void){
	
	int n,x;
	int i,j,k;
	int S;
	
	while(1){
		
	scanf("%d %d",&n,&x);
	if(n==0 && x==0){
		break;
	}
	S=0;
	
	
	for(i=1;i<n-1;i++){
		for(j=i+1;j<n;j++){
			for(k=j+1;k<n+1;k++){
				
				if(i+j+k==x){
					S=S+1;
				}
			}
		}
	}
		printf("%d\n",S);
	}	
		return 0;
	}

Measured memory_bytes: 1816
n, k = (int(x) for x in input().split())

h = [0] * n
for i in range(n):
    h[i] = int(input())

h.sort()

total = None
for i in range(n - k + 1):
    diff = h[i+k-1] - h[i]
    if total is None or total > diff:
        total = diff

print(total)


Measured memory_bytes: 7472
//O(N)
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int N;//<=10^5
    long long C;//<=10^9
    cin>>N>>C;
    vector<long long> x;//位置記録
    vector<int> v;//カロリー記録
    
    //入力
    for(int i=0;i<N;i++){
        long long x_temp;
        int v_temp;
        cin>>x_temp>>v_temp;
        x.push_back(x_temp);
        v.push_back(v_temp);
    }
    //部分和,O(N)
    vector<long long> right;
    vector<long long> left;
    right.push_back(v[0]);
    left.push_back(v[N-1]);
    for(int i=1;i<N;i++){
        right.push_back(right[i-1]+v[i]);
        left.push_back(left[i-1]+v[N-1-i]);
    }
    reverse(left.begin(),left.end());

    //0<=a<=iのとき,f(a):v[0]+v[1]+...+v[a]-x[a]の最大値,O(N)
    vector<long long> r_col;
    vector<long long> l_col;
    r_col.push_back(right[0]-2*x[0]);
    l_col.push_back(left[N-1]-2*(C-x[N-1]));
    for(int i=1;i<N;i++){
        r_col.push_back(max(r_col[i-1],right[i]-2*x[i]));
        l_col.push_back(max(l_col[i-1],left[N-1-i]-2*(C-x[N-1-i])));
    }
    reverse(l_col.begin(),l_col.end());

    long long ans=0;
    //ans,//右回りのみor左回りのみ,O(N)
    for(int i=0;i<N;i++){
        ans=max(ans,right[i]-x[i]);
        ans=max(ans,left[i]-(C-x[i]));
    }
    //両方のとき,O(N)
    for(int i=0;i<N;i++){
        if(i<N-1)ans=max(ans,right[i]-x[i]+l_col[i+1]);
        if(0<i)ans=max(ans,left[i]-(C-x[i])+r_col[i-1]);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  while(true){
    int a;
    cin >> a;

    if(a == 0){
      break;
    }

    vector<int> b(a);
    int max = -9999;
    int min = 99999;
    int maxi,mini;
    for(int i = 0; i < a; i++){
      cin >> b[i];
      if (max < b[i]) { max = b[i];maxi = i; }
      if (min > b[i]) { min = b[i];mini = i; }
    }
    b[mini] = 0;
    b[maxi] = 0;

    int sum = 0;
    for(int i = 0; i < a; i++){
      sum += b[i];
    }
    cout << sum / (a - 2) << endl;
  }
}

Measured memory_bytes: 2984
// ABC 085

// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0],10);
  const arr = input.slice(1,N+1);
  var flag = 0;
  arr.forEach(function(value,index) {
    var t = parseInt(value.split(" ")[0],10);
    var x = parseInt(value.split(" ")[1],10);
    var y = parseInt(value.split(" ")[2],10);
    var sum = x + y;
    if(t >= sum && sum % 2 == t % 2) {
      flag += 0;
    } else {
      flag += 1;
    }
  })
  if(flag == 0) {
    console.log("Yes")
  } else {
    console.log("No")
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

typedef long long int ll;

int main() 
{
  	ll n;
  	cin >> n;
  	ll a[n];
  	
  	ll fre[200010]={0};
  	for(ll i=0;i<n;i++)
    {
      	cin >> a[i];
      	fre[a[i]]++;
    }
 	
  	ll ans = 0;
  	
  	for(ll i=1;i<=200000;i++)
    {
      	if(fre[i]>=2)
          	ans += (fre[i]*(fre[i]-1))/2;
    }
  
  	for(ll i=0;i<n;i++)
    {
      	if(fre[a[i]]>=2)
        {
          	ll fr = fre[a[i]];
          	fr--;
          	ll tm = ans - (fre[a[i]]*(fre[a[i]]-1))/2;
          	tm =  tm + (fr*(fr-1))/2; 
          	cout << tm << endl;
        }
      	else
          	cout << ans << endl;
    }
  	return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n;cin>>n;
  vector<int> l(2*n);
  rep(i,2*n)cin>>l[i];
  sort(all(l));
  int ans=0;
  for(int i=0;i<2*n;i+=2){
    ans+=min(l[i],l[i+1]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	int t = N;
	int h = 0;
	while(t) {
		h += t % 10;
		t /= 10;
	}
	if(N % h == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
	int n, x; cin >> n >> x;
	vector<int>a(n); for (auto&& xx : a)cin >> xx;
	long long ans = 0;
	if (a[0] > x) { long long dif = a[0] - x; a[0] -= dif; ans += dif; }
	for (int i = 0; i < n - 1; i++) {
		if (a[i] + a[i + 1] > x) { long long dif = (a[i] + a[i + 1]) - x; a[i + 1] -= dif; ans += dif; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
// AOJ 1175: And Then. How Many Are There?
// 2017.12.21 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

typedef struct { int s, del, m; } Q;
Q q[100000]; int top;
typedef struct { int x, y, r; } T;
T d[25];
int col[4][6], clen[4]; char f[5];
int up[25][25], ulen[25];		// ?????????????????????????????°??¨??????
char visited[16777216];

int main()
{
	int n, i, j, k, a, c, cmax, p, r, s, del, m, ans;

	while (scanf("%d", &n) && n > 0) {
		memset(clen, 0, sizeof(clen)), memset(f, -1, sizeof(f)), cmax = 0;
		for (i = 0; i < n; i++) {
			scanf("%d%d%d%d", &d[i].x, &d[i].y, &d[i].r, &c);
			if  (f[c] >= 0)          c = f[c];
			else f[c] = cmax++, c = cmax-1;

			col[c][clen[c]++] = i;
		}

		memset(ulen, 0, sizeof(ulen));
		for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
			if (hypot(d[i].x-d[j].x, d[i].y-d[j].y) < d[i].r+d[j].r) up[j][ulen[j]++] = i;
		}

		ans = 0;
		memset(visited, 0, sizeof(visited));
		q[0].s = 0, q[0].del = 0, q[0].m = n, top = 1;
		while (top) {
			s = q[--top].s, del = q[top].del, m = q[top].m;

			if (m == 1 || visited[s]) continue;
			visited[s] = 1;
			for (c = 0; c < cmax; c++)if (clen[c] >= 2) for (p = 0; p < clen[c]; p++) {
				i = col[c][p];
				if (s & (1<<i)) continue;
				for (k = 0; k < ulen[i]; k++) {
					a = up[i][k];
					if (!(s & (1<<a))) goto next;
				}

				for (r = p+1; r < clen[c]; r++) {
					if (r == p) continue;
					j = col[c][r];
					if (s & (1<<j)) continue;
					for (k = 0; ; k++) {
						if (k == ulen[j]) {
							if (del+2 > ans) ans = del+2;
							q[top].s = s|(1<<i) | (1<<j), q[top].del = del+2, q[top++].m = m-2;
							break;
						}
						a = up[j][k];
						if (!(s & (1<<a))) break;
					}
				}
				next:;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 18192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("settling.in", "r", stdin);
	// freopen("settling.out", "w", stdout);

	string s;
	cin >> s;

	if(s.back() != 's')
		s += "s";
	else
		s += "es";

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 3592
k=int(input())
arr=[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]
print(arr[k-1])

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

int main()
{
	char c;
	int l[11], v1, v2;
	while (cin >> l[1]) {
		for (int i = 2; i <= 10; i++) {
			cin >> c >> l[i];
			l[i] += l[i - 1];
		}
		cin >> c >> v1 >> c >> v2;
		for (int i = 1; i <= 10; i++) {
			if (v2 * l[i - 1] <= v1 * (l[10] - l[i - 1]) && v2 * l[i] >= v1 * (l[10] - l[i])) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);
vector <ll> A,tree;
int n;
void build(ll node, ll start, ll end)
{
    if (start==end)
    {
        tree[node]=A[start];
    }
    else
    {
        ll mid=(start+end)/2;
        build(2*node,start,mid);
        build(2*node+1,mid+1,end);
        tree[node]=__gcd(tree[2*node],tree[2*node+1]);
    }
}

void update(ll node, ll start, ll end, ll ind, ll val)
{
    if (start==end)
    {
        // update
        A[ind]=val;
        tree[node]=val;
    }
    else
    {
        ll mid=(start+end)/2;
        if (ind<=mid && ind>=start)
            update(2*node,start,mid,ind,val);
        else
            update(2*node+1,mid+1,end,ind,val);
        tree[node]=__gcd(tree[2*node],tree[2*node+1]);
    }
}
ll query(ll node, ll start, ll end, ll l , ll r)
{
    if (r<start || l>end)
    {
        return 0;
    }
    else if (l<=start && r>=end) return tree[node];
    ll mid=(start+end)/2;
    return __gcd(query(2*node,start,mid,l,r),query(2*node+1,mid+1,end,l,r));

}

int main()
{
	IOS;
    cout.precision(30);
    cin >> n; A.resize(n+1,0); tree.resize(4*n+4,0);
    for (int i=1;i<=n;i++) cin >> A[i];
    build(1,1,n); ll rep,ans=0;
    for (int i=1;i<=n;i++)
    {
        if (i==1)
        {
            rep=query(1,1,n,2,n);
            //cout << i << " " << rep << endl;
        }
        else if (i==n)
        {
            rep=query(1,1,n,1,n-1);
            //cout << i << " " << rep <<endl;
        }
        else
        {
            ll val1=query(1,1,n,1,i-1);
            ll val2=query(1,1,n,i+1,n);
            rep=__gcd(val1,val2);
            //cout << i << " " << rep << endl;
        }
        ans=max(ans,rep);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef long long ll;

void solve() {
    string s;
    cin >> s;
    if(s[s.size() - 1] == 's') s += "es";
    else s += 's';
    cout << s << endl;
}

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

    ll T;
    T = 1;

    while(T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
using System;

namespace AOJ
{
    class DebtHell
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int m = 100000;
            for (int i = 1; i <= n; i++)
            {
                int debt = (int)Math.Ceiling(m * 0.05 / 1000) * 1000;
                m += debt;
            }
            Console.WriteLine(m);
        }
    }
}

Measured memory_bytes: 5556
#include<stdio.h>
#include<stdlib.h>

typedef struct{
    int num;
    char alp;
}data;

void output(data *,int);
void bubble(data *,int);
void selection(data *,int);
void swap(data *,data *);
int check_stable(data *,data *,int);

int main(void){ 
  int N;
  int i;
  data *bubble_data,*sort_data;

  /* input */
  scanf("%d",&N);

  bubble_data=(data *)malloc(sizeof(data)*N);
  sort_data=(data *)malloc(sizeof(data)*N);

  for(i=0;i<N;i++){
    getchar();
    bubble_data[i].alp=getchar();
    scanf("%d",&bubble_data[i].num);
    sort_data[i]=bubble_data[i];
  }


  /* bubble sort */
  bubble(bubble_data,N);
  output(bubble_data,N);
  printf("\nStable\n");

  /* selection sort */
  selection(sort_data,N);
  output(sort_data,N);
  for(i=0;i<N;i++){
    if(bubble_data[i].alp!=sort_data[i].alp) break;
  }
  if(i==N)printf("\nStable\n");
  else printf("\nNot stable\n");

  free(sort_data);
  free(bubble_data);

  return 0;
}


void output(data *data,int N){
  int i;

  printf("%c%d",data[0].alp,data[0].num);
  for(i=1;i<N;i++){
    printf(" %c%d",data[i].alp,data[i].num);
  }
}


void bubble(data *data,int N){
  int i,j;

  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(data[j-1].num>data[j].num) swap(&data[j-1],&data[j]);
    }
  }
}


void selection(data *data,int N){
  int i,j;
  int min;

  for(i=0;i<N-1;i++){
    min=i;
    for(j=i+1;j<N;j++){
      if(data[min].num>data[j].num) min=j;
    }
    if(min!=i) swap(&data[i],&data[min]);
  }
}


void swap(data *a,data *b){
  data work;
  
  work=*a;
  *a=*b;
  *b=work;
}

Measured memory_bytes: 612
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  double w,h,x,y;
  cin>>w>>h>>x>>y;

  double sq;
  
  /*
  if( x < w/2 && y < h/2 ){
    sq=max( w*y , h*x );
  }
  else if( x > w/2 && y < h/2 ){
    sq=max( w*y , h*(w-x) );
  }
  else if( x < w/2 && y > h/2 ){
    sq=max( w*(h-y) , h*x );
  }
  else{
    sq=max( w*(h-y) , h*(w-x) );
  }

  //cout << std::setprecision(10) << sq << " ";
  cout << sq << " ";
  */

  cout << std::setprecision(10) << (w*h/2.0) << " ";

  if( w/2==x && h/2==y ) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;

}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

vint v = {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};
signed main() {
    int K;
    cin >> K;
    cout << v[K - 1] << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
road = [list(map(int, input().split())) for i in range(M)]
DP = [0 for i in range(N+1)]
DP[0] = -1
kouho = []

for i in range(M):
  Ai = road[i][0]
  Bi = road[i][1]
  if H[Ai - 1] > H[Bi - 1]:
    if DP[Ai] != -1:
      DP[Ai] = 1
    DP[Bi] = -1
  elif H[Ai - 1] == H[Bi - 1]:
    DP[Ai] = -1
    DP[Bi] = -1
  else:
    if DP[Bi] != -1:
      DP[Bi] = 1
    DP[Ai] = -1 

ans = 0
for i in DP:
  if i != -1:
    ans += 1

print(ans)
#print(DP)

Measured memory_bytes: 31740
/*そーなのかー
　　　＿
　 '´　　 ヽ
 ./ ﾉﾉ））)）〉
〈《.! ﾟ ヮﾟﾉ》
　⊂!::V::!つ
　 く::::::::〉
　　 し'ﾉ*/
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long p=1;
  for(int i=0;i<n;i++){
    p*=2;
    if(p>n){
      break;
    }
  }
  cout << p-1 << endl;
}


Measured memory_bytes: 3572
from math import cos, pi
from sys import stdin


def main():
    A, B, H, M = [int(x) for x in stdin.readline().rstrip().split()]
    h_rad = 2 * pi * (360 * (H * 60 + M) / 720) / 360
    m_rad = 2 * pi * (360 * M / 60) / 360
    if h_rad < m_rad:
        rad = m_rad - h_rad
    else:
        rad = h_rad - m_rad
    ans = (A ** 2 + B ** 2 - 2 * A * B * cos(rad)) ** 0.5
    print(ans)


if __name__ == "__main__":
    main()


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

const int N = 5e5 + 7;
int top = 1, n, vis[N];

struct hjt{
    int l, r, sum;
}tree[150 * N];
int a[N];
#define m (l + r) / 2

void update(int v, int pos, int last, int &now, int l, int r) {
    now = top++;
    tree[now] = tree[last];
    if (l == r) {
        tree[now].sum += v;
        return;
    }
    if (pos <= m) update(v, pos, tree[last].l, tree[now].l, l, m);
    else update(v, pos, tree[last].r, tree[now].r, m + 1, r);
    tree[now].sum = tree[tree[now].l].sum + tree[tree[now].r].sum;
}

int query(int ql, int qr, int now, int l, int r) {
    if (ql  <= l && qr >= r) {
        return tree[now].sum;
    }
    int ans = 0;
    if (ql <= m) ans += query(ql, qr, tree[now].l, l, m);
    if (qr > m) ans += query(ql, qr, tree[now].r, m + 1, r);
    return ans;
}
int rt[N];

int main() {
    int q;
    scanf("%d %d", &n, &q);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
        if (vis[a[i]] == 0) {
            update(1, i, rt[i - 1], rt[i], 1, n);
        } else {
            update(-1, vis[a[i]], rt[i - 1], rt[i], 1, n);
            update(1, i, rt[i], rt[i], 1, n);

        }
        vis[a[i]] = i;
    }
    while (q--) {
        int l, r;
        scanf("%d %d", &l, &r);
        printf("%d\n", query(l, r, rt[r], 1, n));
    }

}

Measured memory_bytes: 241208
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int l, r; cin >> l >> r;
	int p = l%2019, q = r%2019;
	if( r-l+1 >= 2019 || p >= q ){
		cout << 0 << endl;
		return 0;
	}
	int ans = 2019;
	for( int i = p; i <= q; ++i ){
		for( int j = i+1; j <= q; ++j ){
			ans = min((i*j)%2019, ans);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
dp = [0 for _ in range(len(A))]
dp[0] = 0 
for i in range(1,N):
    if i - 2>=0:
        dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]),dp[i-2] + abs(A[i] - A[i-2]))
    else:
        dp[i] =dp[i-1] + abs(A[i] - A[i-1])

print(dp[len(A)-1])

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  for (int i = 0; i < max(a, b); ++i) ans = ans * 10 + min(a, b);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
const int MAX = 16;
using D = double;
D dp[MAX+1][1<<MAX];
D pr[MAX][MAX];
signed main(){
  int m,n;
  cin>>m>>n;
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
      cin>>pr[i][j];

  int sz=1<<m;
  for(int i=0;i<n;i++) dp[i][sz-1]=0;
  dp[n][sz-1]=1;

  for(int bit=sz-2;bit>=0;bit--){
    for(int k=0;k<n;k++){
      D &res=dp[k][bit];
      for(int i=0;i<m;i++){
        if((bit>>i)&1) continue;
        int nxt=bit|(1<<i);
        D cur=1,sum=0;
        for(int j=k;j<n;j++){
          sum+=dp[j+0][nxt]*cur*(1.0-pr[i][j]);
          cur*=pr[i][j];
        }
        chmax(res,sum+cur);
      }
    }
    dp[n][bit]=1;
  }
  cout<<dp[0][0]<<endl;
  return 0;
}



Measured memory_bytes: 11952