akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <iomanip>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
#define MOD 1000000007
using namespace std;
 
int main(){
  string S;
  cin >> S;
  int count1 = 0, count2 = 0;
  for (int i = 0; i < S.length(); i += 2){
    if (S.at(i) != 'R' && S.at(i) != 'U' && S.at(i) != 'D'){
      count1++;
    }
  }
  for (int i = 1; i < S.length(); i += 2){
    if (S.at(i) != 'L' && S.at(i) != 'U' && S.at(i) != 'D'){
      count2++;
    }
  }
  if (count1 == 0 && count2 == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" <<  endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
//#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
signed main() {
    int N, M;
    cin >> N >> M;
    int sum = 0;
    rep(i, M) {
        int a;
        cin >> a;
        sum += a;
    }
    cout << max((int)-1, N - sum) << endl;
}


Measured memory_bytes: 3636
N = int(input())
A = []

for i in range(N):
  A.append(int(input()))

next_num = A[0]
ans = 0


for i in range(N):
  ans += 1
  if next_num == 2:
    break
  else:
    if i != N-1:
      next_num = A[next_num-1]
    else:
      ans = -1
      break

print(ans)


Measured memory_bytes: 7084
#include<iostream>

using namespace std;

int main(){
    long long n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        long long ai;
        cin >> ai;
        n -= ai;
    }
    cout << (n < 0 ? -1 : n) << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <time.h>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int, int> Pii;
const int inf = 0x3f3f3f3f;
const LL INF = (1uLL << 63) - 1;
const LL mod = 1000000007;
const int N = 150 + 5;
const double Pi = acos(-1.0);
const int maxn = 2e5 + 5;
LL a[maxn];
int main() {
#ifdef local
    freopen("in", "r", stdin);
    //  freopen("w","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    LL del = 0;
    LL d = 1LL * (1 + n) * n / 2;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        del += a[i];
    }
    if(del % d != 0) {
        cout << "NO" << endl;
    } else {
        LL time = del / d;
        LL cut = 0;
        bool flag = 0;
        if(a[0] - a[n - 1] > time || a[0] - a[n - 1] < time * (1 - n)) {
            flag = 1;
        }
        for(int i = 1; i < n; i++) {
            cut += a[i] - a[i - 1];
            if(a[i] - a[i - 1] > time || a[i] - a[i - 1] < time * (1 - n)) {
                flag = 1;
            }
        }
        if((cut + time) % n == 0 && (cut + time) / n <= time && !flag) {
            cout << "YES" << endl;
        } else cout << "NO" << endl;
    }
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

		// 入力値の取得
		int H = sc.nextInt();
		int N = sc.nextInt();
		
		// 必殺技のダメージ合計値
		int sum = 0;
		for (int i=0; i<N; i++) {
			sum += sc.nextInt();
		}
		
		// 結果の出力
		System.out.println(H - sum > 0? "No": "Yes");
		
		sc.close();
	}

}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3
#define MOD 1000000007LL

ll fact[100002], factInv[100002];

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

void factrial() {
    fact[0] = factInv[0] = 1;
    repl(i, 1, 100002) {
        fact[i] = (fact[i - 1] * i) % MOD;
        factInv[i] = power(fact[i]);
    }
}

int main(){
    cin.sync_with_stdio(false);
    ll n;
    cin >> n;
    int a, b[n] = {};
    rep(i, n) b[i] = -1;
    int l, r;
    rep(i, n + 1) {
        cin >> a;
        if (b[a - 1] != -1) l = b[a - 1], r = i;
        else b[a - 1] = i;
    }
    factrial();
    int p = n + 1 - (r - l + 1);
    repl(i, 1, n + 2) {
        ll g = (((fact[n + 1] * factInv[i]) % MOD) * factInv[n + 1 - i]) % MOD;
        ll h = (p < i - 1) ? 0 : (((fact[p] * factInv[i - 1]) % MOD) * factInv[p - i + 1]) % MOD;
        cout << (g - h + MOD) % MOD << endl;
    }
    return 0;
}

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

#define N_MAX 100001

int desc(const void *a, const void *b){
  if(*(long *)a > *(long *)b){
    return -1;
  }else if(*(long *)a == *(long *)b){
    return 0;
  }else{
    return 1;
  }
}

int main(void){
  int i, j;

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

  priority_queue<long> q;

  long a;
  for(i = 0; i < n; i++){
    cin >> a;
    q.push(a);
  }

  for(i = 0; i < m; i++){
    a = q.top();
    q.pop();
    a /= 2;
    q.push(a);
  }

  long ans=0;
  for(i = 0; i < n; i++){
    a = q.top();
    q.pop();
    ans += a;
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long LONG;

LONG sum1[21];
LONG sum2[21];

int main(void)
{
	int N, n;
	int i;
	int j;
	
	scanf("%d", &N);
	scanf("%d", &n);
	sum1[n] = 1;
	for (i = 1; i < N - 1; i++){
		scanf("%d", &n);

		memset(sum2, 0, sizeof(sum2));
		for (j = 0; j <= 20; j++){
			if (sum1[j] != 0){
				if (j + n <= 20){
					sum2[j + n] += sum1[j];
				}
				if (j - n >= 0){
					sum2[j - n] += sum1[j];
				}
			}
		}
//	printf("%d=[", n);
//	for (j = 0; j <= 20; j++){
//		printf("%d=%d ", j, sum2[j]);
//	}
//	printf("]\n");
		memcpy(sum1, sum2, sizeof(sum1));
	}
	scanf("%d", &n);
	printf("%lld\n", sum1[n]);

	return (0);
}

Measured memory_bytes: 600
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
// #define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    ll x;
    cin>>x;
    if(x==7||x==5||x==3) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

########関数部分##############
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
############################
 
n,m,q = myinput()
abcd = mylistinput(q)

ls = list( combinations_with_replacement(list(range(1,m+1)),n) )
# print(len(ls))
# pprint(ls)

ls_ans = []
for i in range(len(ls)):
    A = list(ls[i])
    # print(A)
    score = 0
    for j in range(q):
        a = abcd[j][0] - 1
        b = abcd[j][1] - 1
        c = abcd[j][2]
        d = abcd[j][3]
        if A[b]-A[a]==c:
            score += d
        else:
            pass
    ls_ans.append(score)
# print(ls_ans)
ans = max(ls_ans)
print(ans)

Measured memory_bytes: 86088
# AOJ 2006: Keitai Message
# Python3 2018.6.20 bal4u

tbl = [0, ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"]

for _ in range(int(input())):
	ans = []
	s, i = list(input()), 0
	while i < len(s):
		if s[i] != '0':
			id, k = int(s[i]), 0
			i += 1
			while s[i] != '0':
				i += 1
				k += 1
			ans.append(tbl[id][k % len(tbl[id])]);
		i += 1
	print(*ans, sep='')


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

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

	int table[] = {
		1,100,10000
	};

	if (N == 100) {
		cout << table[D] * N + table[D] << endl;
	}
	else {
		cout << table[D] * N << endl;
	}

	return 0;
}

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

int n;
int p[25];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> p[i];

    long long ans = 0;
    for(int i = 1; i < n-1; i++) {
        int mi = min({p[i-1], p[i], p[i+1]});
        int ma = max({p[i-1], p[i], p[i+1]});

        if(mi < p[i] && p[i] < ma)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// ・#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rrep(i, n) RREP(i, 0, n)
#define RREP(i, x, n) for(int i = (int)(n) - 1 - (int)(x); i >= 0; i--)

void printv(vector<int> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << *it << ",";
    }
    cout << endl;
}

int N,M;
vector<int> H(10e5+1),A(10e5+1),B(10e5+1);

int main(void){
    // Your code here!
    cin >>N>>M;
    REP(i,1,N+1){
        int h;
        cin>>h;
        H[i] = h;
    }
    // 道
    REP(i,1,M+1){
        int a,b;
        cin >> a>>b;
        A[i] = a;
        B[i] = b;
    }
    vector<vector<int>> e(10e5+1, vector<int>());
    REP(i,1,M+1){
        //A[i], B[i]は道のエッジ、山の番号
        //cout << A[i] << " " << B[i] << endl;
        e[A[i]].push_back(H[B[i]]);
        e[B[i]].push_back(H[A[i]]);
    }
    int count = 0;
    //山
    REP(i,1,N+1){
        //cout << "i:" << i << endl;
        //周りの山
        rep(j,e[i].size()){
            // cout << "j:" << j << endl;
            // cout << "H:" << H[i] << endl;
        
            if(H[i] <= e[i][j]){
                goto A;
            }
        }
        count++;
A:
    true;
    }
    // printv(e[1]);
    // printv(e[2]);
    // printv(e[3]);
    // printv(e[4]);
    cout << count;
    
    return 0;
}


Measured memory_bytes: 40840
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
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);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    string ans = "";
    
    rep(i,tx-sx) ans += "R";
    rep(i,ty-sy) ans += "U";
    rep(i,tx-sx) ans += "L";
    rep(i,ty-sy) ans += "D";
    ans += "D";
    rep(i,tx-sx+1) ans += "R";
    rep(i,ty-sy+1) ans += "U";
    ans += "LU";
    rep(i,tx-sx+1) ans += "L";
    rep(i,ty-sy+1) ans += "D";
    ans += "R";
    
    pr(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

int main()
{
    int n, x, t;
    cin >> n >> x >> t;

    int total_make = 0, i = 1;
    int time = 0;

    while(total_make < n)
    {
        time = t * i;
        total_make = x * i;

        i ++;
    }

    cout << time << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

map<string, int> frequency(const vector<string> &s) {
  map<string, int> ret;
  REP(i, 0, s.size()) {
    ret[s[i]] += 1;
  }
  return ret;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  vector<string> pal, nonpal;
  REP(i, 0, n) {
    cin >> s[i];
    string rev(s[i]);
    reverse(rev.begin(), rev.end());
    if (rev == s[i]) {
      pal.push_back(s[i]);
    } else {
      nonpal.push_back(s[i]);
    }
  }
  map<string, int> fpal = frequency(pal), fnonpal = frequency(nonpal);
  vector<string> peri;
  const string dummy = "\x7e";
  string centre = dummy;
  for (map<string, int>::iterator it = fpal.begin(); it != fpal.end(); ++it) {
    pair<string, int> v = *it;
    string s = v.first;
    int f = v.second;
    if (f % 2 == 1) {
      centre = min(centre, s);
    }
    REP(i, 0, f / 2) {
      peri.push_back(s);
    }
  }
  for (map<string, int>::iterator it = fnonpal.begin(); it != fnonpal.end(); ++it) {
    pair<string, int> v = *it;
    string s = v.first;
    string rev = s;
    reverse(rev.begin(), rev.end());
    if (s >= rev) {
      continue;
    }
    // s < rev
    int f = min(fnonpal[s], fnonpal[rev]);
    REP(i, 0, f) {
      peri.push_back(s);
    }
  }
  sort(peri.begin(), peri.end());
  REP(i, 0, peri.size()) {
    cout << peri[i];
  }
  if (centre != dummy) {
    cout << centre;
  }
  REP(i, 0, peri.size()) {
    string rev = peri[peri.size() - 1 - i];
    reverse(rev.begin(), rev.end());
    cout << rev;
  }
  cout << "\n";
}

Measured memory_bytes: 3384
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> dp(3, vector<int>(n+1, 0));

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

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


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

#define FOR(i, a, b)   for(int i = (a); i <= (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i >= (b); --i)

typedef long long ll;

int meth1(int n)
{
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    
    return sum;
}


int main()
{
    int N,A,B;
    int ans =0;
  	cin >> N >> A >> B;

    FOR(i,0,N){
      	int sum = meth1(i);
        if(sum >= A && sum <= B) ans += i;
    }
    
  	cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<vector<ll>> p (n,vector<ll> (2));
  for (int i=0;i < n;i++){
    int x,y;
    cin >> x >> y;
    p[i][0]=x;
    p[i][1]=y;
  }
  ll taka=1,ao=1;
  for (int i=0;i < n;i++){
    ll x,y;
    x=(taka+p[i][0]-1)/p[i][0];
    y=(ao+p[i][1]-1)/p[i][1];
    ll tmp;
    tmp=max(x,y);
    taka=p[i][0]*tmp;
    ao=p[i][1]*tmp;
  }
  
  cout << ao + taka << endl;  
  
   return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	long double ans = 0, sum = 0;
	int con = 0;
	int N;
	vector<pair<int,int>> in;
	vector<int> num;
	
	cin>>N;
	
	in.resize(N);
	num.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>in[i].first>>in[i].second;
		num[i] = i;
	}
	
	do{
		// for(int i = 0; i < N; i++){
			// cout<<num[i]<<" ";
		// }cout<<endl;
		
		for(int i = 1; i < N; i++){
			long double dis;
			
			dis = sqrt((in[num[i]].first - in[num[i-1]].first)*(in[num[i]].first - in[num[i-1]].first)+(in[num[i]].second - in[num[i-1]].second)*(in[num[i]].second - in[num[i-1]].second));
			
			sum += dis;
		}
		
		con++;
		
		
	}while(next_permutation(num.begin(), num.end()));
	
	// cout<<sum<<" "<<con<<endl;
	
	ans = sum/con;
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import itertools
import numpy as np

N,K = map(int,input().split())
l = np.array(list(map(int,input().split())))

ans = 0
for i in range(K):
    max_i = np.argmax(l)
    ans += l[max_i]
    l = np.delete(l,max_i)

print(ans)


Measured memory_bytes: 21544
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    double n;
    cin >> n;
    for( LL i = 1; i <= 3500; ++i ) {
        bool flg = false;
        for( LL j = 1; j <= 3500; ++j ) {
            double cp = ( i * j * n ) / ( 4 * i * j - ( i * n + j * n ) );
            LL t = cp;
            if( cp == (double)t && cp > 0 ) {
                cout << i << " " << j << " " << t << endl;
                flg = true;
                break;

            }
        }
        if( flg ) break;

    }

    return 0;
}


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

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main() {
    int n;
    cin >> n;
    n %= 10;
    if (n == 3) {
        cout << "bon" << endl;
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int list[32] = {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};

int main() {
  int K;
  cin >> K;

  cout << list[K-1] << endl;
  return 0;
}


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

treat_l = [0 for i in range(N)]

for i in range(K):
	in_dk = int(input())
	in_t_list = list(map(int, input().split()))

	for j in range(in_dk):
		treat_l[in_t_list[j]-1] += 1

# おかし0の数を出力
cnt = 0
for i in treat_l:
	if(i == 0):
		cnt += 1
print(cnt)

Measured memory_bytes: 9192
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
x = [LIST() for i in range(n)]
 
a = []
for i in range(n):
    for j in range(n):
        if i != j:
            a.append((x[j][0]-x[i][0], x[j][1]-x[i][1]))
 
a.sort()
count = 1
reg = 1

for i in range(1, len(a)):
    if a[i][:] == a[i-1][:]:
        count += 1
        reg = max(reg, count)
    else:
        count = 1

if n == 1:
    ans = n
else:
    ans = n - reg

print(ans)

Measured memory_bytes: 10492
using Base.Collections
function main()
	lines=readlines()
	A=Array{Tuple{Int,Int,Int}}(0)
	N,Q=map(x->parse(Int,x),split(shift!(lines)))
	X=Array{Int}(0)
	for i=1:N
		s,t,x=map(x->parse(Int,x),split(shift!(lines)))
		push!(A,(s-x,t-x,x))
	end
	for i=1:Q
		d=parse(Int,shift!(lines))
		push!(A,(d,10^10,i))
	end
	sort!(A)
	P=PriorityQueue(Int,Int)
	ans=Array{Int}(Q)
	for (t,id,x)=A
		if id==10^10
			while !isempty(P)&&peek(P).first<=t
				dequeue!(P)
			end
			if isempty(P)
				ans[x]=-1
			else
				ans[x]=peek(P).second
			end
		else
			P[id]=min(get(P,id,10^10),x)
		end
	end
	for a=ans
		println(a)
	end
end
main()


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

int main()
{
  string S ;
  cin>>S ;
  
  if(S=="Sunny") cout<<"Cloudy"<<endl ;
  else if(S=="Cloudy") cout<<"Rainy"<<endl ;
  else cout<<"Sunny"<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
#include<cstdio>
#define reg register

int n,k;

int main(void){
	reg int i,ans=0;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;++i){
		static int x;
		scanf("%d",&x);
		if(x>=k)
			++ans;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int id(int i,int j) {
	return j<=i?i+1:i;
}

int main(void) {
	int n,i,j,ok;
	int nae[101];
	while(scanf("%d",&n)==1 && n>0) {
		if(n<4 || n>100)return 1;
		for(i=0;i<=n;i++) {
			scanf("%d",&nae[i]);
			if(nae[i]<1 || nae[i]>1000000000)return 1;
		}
		ok=0;
		for(j=0;j<=n;j++) {
			ok=1;
			for(i=1;i<n;i++) {
				if(nae[id(1,j)]-nae[id(0,j)]!=nae[id(i,j)]-nae[id(i-1,j)]) {
					ok=0;break;
				}
			}
			if(ok) {
				printf("%d\n",nae[j]);
				break;
			}
		}
		if(!ok)return 1;
	}
	return 0;
}

Measured memory_bytes: 600
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)

class UnionFind:
    """素集合を木構造として管理する。"""
    def __init__(self, n):
        self.parent = [-1] * n
        self.n = n
        self.cnt = n
 
    def root(self, x):
        """要素xの代表元を求める。O(α(N))"""
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]
 
    def merge(self, x, y):
        """要素xを含む集合と要素yを含む集合を併合する。O(α(N))"""
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.parent[x] > self.parent[y]:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        self.cnt -= 1
        return True
 
    def is_same(self, x, y):
        """要素x, yが同じ集合に属するかどうかを求める。O(α(N))"""
        return self.root(x) == self.root(y)
 
    def size(self, x):
        """要素xを含む集合の要素数を求める。O(α(N))"""
        return -self.parent[self.root(x)]
 
    def count(self):
        """集合の個数を求める。O(1)"""
        return self.cnt
 
    def groups(self):
        """集合を列挙する。list[list[int]]で返す。O(N)"""
        res = [[] for _ in range(self.n)]
        for i in range(self.n):
            res[self.root(i)].append(i)
        return [group for group in res if group]

N,Q = map(int,readline().split())
uf = UnionFind(N)

for _ in range(Q):
    x,y = map(int,readline().split())
    x-=1; y-=1
    uf.merge(x,y)

print(uf.count()-1)

Measured memory_bytes: 78276
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
int main() {
	long long n,a,b;
	int i=0;
	int h = 0, d = 0;

	string s = "Yes";
	cin >> a>>b;
	while (true) {
		i++;
		h = floor(i*0.08);
		d = floor(i*0.10);
		if (h == a && d == b) {
			break;
		}
		if (h > a || d > b) {
			i = -1;
			break;
		}
	}
	cout <<i << endl;
}


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> P(A);
  vector<ll> Q(B);
  vector<ll> R(C);
  ll ans = 0;
  rep(i, A) cin >> P.at(i);
  rep(i, B) cin >> Q.at(i);
  rep(i, C) cin >> R.at(i);
  sort(P.begin(), P.end());
  reverse(P.begin(), P.end());
  sort(Q.begin(), Q.end());
  reverse(Q.begin(), Q.end());
  rep(i, X) R.push_back(P.at(i));
  rep(i, Y) R.push_back(Q.at(i));
  sort(R.begin(), R.end());
  reverse(R.begin(), R.end());
  rep(i, X + Y) ans += R.at(i);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int n,m;
  cin >> n >> m;
  priority_queue<ll> q;

  rep(i,n){
    ll a;
    cin >> a;
    q.push(a);
  }

  while(m>0){
    ll t = q.top(); q.pop();
    t /= 2;
    q.push(t);
    m--;
  }
  ll ans = 0;
  while(!q.empty()){
    ll t = q.top(); q.pop();
    ans += t;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int a,b,n,count1 = 0,count2 = 0;
    string s;
    cin >> n >> a >> b >> s;
    rep(i, n){
        if (s[i] == 'a' && a + b > count1) {
            Yes;
            ++count1;
        }else if (s[i] == 'b' && a + b > count1 && b > count2){
            Yes;
            ++count1;
            ++count2;
        }else{
            No;
        }
    }
    return 0;
}


Measured memory_bytes: 896
import           Data.Char

main :: IO ()
main = do
    [a,b] <- fmap read . words <$> getLine :: IO [Int]
    s <- filter (not .  isSeparator) <$> getLine
    putStrLn $ solve (a,b) s

solve :: (Int,Int) -> String -> String
solve (a,b) s   | length s /= a + b + 1 = "No"
                | s !! a == '-' = solve' (take a s) (take b $ drop (a+1) s)
                | otherwise = "No"

solve' :: String -> String -> String
solve' a b = if chk a && chk b then "Yes" else "No" where
    chk ls = and $ isDigit <$> ls


Measured memory_bytes: 508
#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() {
	fastio;
	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);
	double dp[n + 1][n + 1];
	memset(dp, 0, sizeof dp);
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i][j] = dp[i - 1][j] * (1.0 - arr[i - 1]);
			if (j) {
				dp[i][j] += dp[i - 1][j - 1] * arr[i - 1];
			}
		}
	}
	double res = 0;
	for (int i = (n + 1) / 2; i <= n; i++)
		res += dp[n][i];

	cout << fixed << setprecision(10) << res;
	return 0;
}




Measured memory_bytes: 74096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int H,W; 

int Dfs(vector<vector<char>> M,int x,int y,int dx,int dy){
    if(x+dx<0 || x+dx>=H || y+dy<0 || y+dy>=W) return 0;
    if(M.at(x+dx).at(y+dy)=='#') return 0;
    return Dfs(M,x+dx,y+dy,dx,dy)+1;
}

int main(){
    cin>>H>>W;
    vector<vector<char>> M(H,vector<char>(W));
    rep(h,0,H)rep(w,0,W) cin>>M.at(h).at(w);

    vector<vector<int>> nW(H,vector<int>(W,0)),nH(H,vector<int>(W));
    rep(h,0,H){
        rep(w,0,W){
            if(M.at(h).at(w)=='.'){
                if(w==0) nW.at(h).at(w)=1;
                else nW.at(h).at(w)=nW.at(h).at(w-1)+1;
            }else nW.at(h).at(w)=0;
        }
    }
    rep(h,0,H){
        int v=0;
        _rep(w,W-1,0){
            if(nW.at(h).at(w)){
                if(v==0) v=nW.at(h).at(w);
                else nW.at(h).at(w)=v;
            }else v=0;
        }
    }

    rep(w,0,W){
        rep(h,0,H){
            if(M.at(h).at(w)=='.'){
                if(h==0) nH.at(h).at(w)=1;
                else nH.at(h).at(w)=nH.at(h-1).at(w)+1;
            }else nH.at(h).at(w)=0;
        }
    }
    rep(w,0,W){
        int v=0;
        _rep(h,H-1,0){
            if(nH.at(h).at(w)){
                if(v==0) v=nH.at(h).at(w);
                else nH.at(h).at(w)=v;
            }else v=0;
        }
    }

    int ans=0;
    rep(h,0,H){
        rep(w,0,W){
            if(M.at(h).at(w)=='#') continue;

            ans=max(ans,nW.at(h).at(w)+nH.at(h).at(w)-1);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 37632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;

    if (n + 1 > 24) {
        cout << 0 << endl;
        return 0;
    }

    int c[13] = {};
    c[0] = 1;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        c[d]++;
    }

    int xx = 0;
    if (c[0] >= 2 || c[12] >= 2) {
        cout << 0 << endl;
        return 0;
    }
    if (c[0] == 1) xx |= 1 << 0;
    if (c[12] == 1) xx |= 1 << 12;
    for (int i = 1; i < 12; i++) {
        if (c[i] > 2) {
            cout << 0 << endl;
            return 0;
        }
        if (c[i] == 2) {
            xx |= 1 << i;
            xx |= 1 << (24 - i);
        }
    }

    int r = 0;
    for (int i = 0; i < 1 << 12; i += 2) {
        int x = xx;
        int b = 0;
        for (int j = 1; j < 12; j++) {
            if (c[j] != 1) continue;
            int t = 1 << j;
            if (i & t) t = j; else t = 24 - j;
            t = 1 << t;
            if (x & t) {
                b = 1;
                break;
            }
            x |= t;
        }
        if (b == 0) {
            int s = 1 << 30, u = 0;
            for (int j = 0; j < 24; j++) {
                if (!(x & 1 << j)) continue;
                for (int k = j + 1; k < 24; k++) {
                    if (!(x & 1 << k)) continue;
                    u = min(k - j, j - k + 24);
                    s = min(s, u);
                }
            }
            r = max(r, s);
        }
    }

    cout << r << endl;

    return 0;
}

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

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

  sort(a,a+n);
  int l=a[n/2-1],r=a[n/2];
  for(int i=0;i<n;++i){
    if(b[i]<=l){
        cout << r << endl;
    }else{
        cout << l << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int a,b,c,d;
  	cin>>a>>b>>c>>d;
  	if(a+b>c+d){
    cout<<"Left";
    }else if(a+b<c+d){
      cout<<"Right";
    }else{
      cout<<"Balanced";
    }
  	cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int N; scanf("%d", &N);
    int min = 200010;
    int ans = 0;
    for(int i = 0; i < N; ++i) {
        int p; scanf("%d", &p);
        if(min >= p) {
            ++ans;
            min = p;
        }
    }
    
    printf("%d\n", ans);
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0;
	sort(a.rbegin(), a.rend());
	ans += a[0];
	if (n % 2 == 0) {
		int cnt = (n - 2) / 2;
		rep(i, cnt) ans += (ll)2 * a[i + 1];
	}
	else {
		int cnt = (n - 2) / 2;
		rep(i, cnt) ans += (ll)2 * a[i + 1];
        ans+=a[cnt+1];
	}
	cout << ans << endl;
}

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


int main() {
    int N;
    cin >> N;
    int arr[100000];
    for (int i = 0; i < N; i++) {
        cin >> arr[i];
    }
    int heights[100000];
    heights[0] = 0;
    heights[1] = abs(arr[1]-arr[0]);
    for (int i = 2; i < N; i++) {
        heights[i] = min(abs(arr[i]-arr[i-1])+heights[i-1],abs(arr[i]-arr[i-2])+heights[i-2]);
    }
    cout << heights[N-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    priority_queue<pair<int,int>> pq;
    rep(i,n){
        if(a[i] > b[i]){cout << -1 << endl; return 0;}
        if(a[i] < b[i])pq.push({b[i],i});
    }
    ll ans = 0;
    while(!pq.empty()){
        int i = pq.top().second;
        pq.pop();
        int l = (i+n-1)%n, r = (i+1)%n;
        if(b[l]+b[r] > b[i] - a[i]){cout << -1 << endl; return 0;}
        int k = (b[i] - a[i]) / (b[l] + b[r]);
        ans += k;
        b[i] -= k*(b[l]+b[r]);
        if(a[i] < b[i])pq.push({b[i],i});
    }
    cout << ans << endl;
}

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

#ifdef SG
	#include <debug.h>
#else
	template<typename T> struct outputer;
	struct outputable {};
	#define PRINT(...)
	#define OUTPUT(...)
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
	#define fbegin(...)
	#define fend
	#define pbegin(...)
	#define pend
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb emplace_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef int64_t ll;
typedef uint64_t ull;
typedef uint32_t ui;
typedef uint16_t us;
typedef uint8_t uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 200000;

struct Input {
	int n, t;
	int a[N];
	
	bool read () {
		if (!(cin >> n >> t)) {
			return 0;
		}
		forn (i, n) {
			scanf("%d", &a[i]);
		}
		return 1;
	}

	void init (const Input &input) {
		*this = input;
	}
};


struct Data: Input {
	int ans;

	void write () {
		cout << ans << endl;
	}
};


namespace Main {
	
	struct Solution: Data {
		
		void solve () {
			int r = 0;
			ans = 0;
			forn (i, n) {
				umx(r, a[i]);
				ans -= r;
				umx(r, a[i] + t);
				ans += r;
			}
		}
		
		void clear () {
			*this = Solution();
		}
	};
}


Main::Solution sol;

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);

	#ifdef SG
		freopen((problemname + ".in").c_str(), "r", stdin);
//		freopen((problemname + ".out").c_str(), "w", stdout);
		while (sol.read()) {
			sol.solve();
			sol.write();
			sol.clear();
		}
	#else
		sol.read();
		sol.solve();
		sol.write();
	#endif
	
	/*
	int t;
	cin >> t;
	forn (i, t) {
		sol.read();
		sol.solve();
		sol.write();
		sol.clear();
	}
	*/
	
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  for (int i = 1; i <= n; i++) {
    ans *= i;
    if (ans >= 1e9 + 7) ans %= 1000000007;
  }
  cout << ans << endl;
}

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

int N, a[100], b[100], c[100], d[100];

int main(){
    cin >> N;
    for(int i=0;i<N;i++)    cin >> a[i] >> b[i];
    for(int i=0;i<N;i++)    cin >> c[i] >> d[i];
    
    vector< pair<int, int> > blue(N), red(N);
    for(int i=0;i<N;i++){
        blue[i] = make_pair(c[i], d[i]);
        red[i] = make_pair(b[i], a[i]);
    }
    
    sort(blue.begin(), blue.end());
    sort(red.begin(), red.end(), greater< pair<int,int> >());
    
    vector<bool> used(N);
    for(int i=0;i<N;i++)    used[i] = true;
    
    int ans = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(red[j].first < blue[i].second && red[j].second < blue[i].first && used[j]){
                ans++;
                used[j] = false;
                break;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;

void main() {
	auto N = readln.chomp.to!int;
	auto A = readln.split.to!(int[]);
	auto q = readln.chomp.to!int;
	auto m = readln.split.to!(int[]);
	bool solve(int i, int j) {
		if(j < 0) return false;
		if(j == 0) return true;
		if(i == N) return false;
		return solve(i+1, j) || solve(i+1, j - A[i]);
	}
	m.map!(i => solve(0, i) ? "yes" : "no").each!writeln;
}



Measured memory_bytes: 2464
#include<stdio.h>
int main()
{
    int i,j,l,n,x,y,temp=0,count=0;
    scanf("%d",&n);
    int p[n];
    for(i=1;i<=n;i++)
    {
        scanf("%d",&p[i]);
    }
    for(i=1;i<=n;i++)
    {
        if(p[i]!=i)
        {
            x=p[i];
            break;
            }
    }
    for(j=i+1;j<=n;j++)
    {
        if(p[j]!=j)
        {
            y=p[j];
            break;
            }
    }
    temp=p[i];
    p[i]=p[j];
    p[j]=temp;
    for(l=1;l<=n;l++)
    {
        if(p[l]==l)
            {
            count++;
        }
    }
    if(count==n)
        {
        printf("YES\n");
    }
    else
        printf("NO\n");

    return 0;
}

Measured memory_bytes: 1600
#include <bits/stdc++.h>
using namespace std;
// それぞれのスタジアムの間隔が異なるように配置すればよい
// (Nが偶数のときは,間隔がN/2にならないようにケア)

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

  int Mremain= M;
  int lower= N/2;
  int upper= lower+ 1;
  while(Mremain > 0){
    if(N==2*(upper- lower) || N==2*(upper- lower- 1)){ upper++; }

    cout << lower <<" "<< upper << endl;
    lower--; upper++;
    Mremain--;
  }
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    if(a + b > 23)
        cout << a + b - 24 << endl;
    else
        cout << a + b << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = list(map(int, input().split()))

S = np.zeros(N+1, dtype='int64') # 累積和
D = {0: 1} # ディクショナリ（連想配列） 各値が何回出てくるか
for i in range(1,N+1): # 1 から N まで
    S[i] = S[i-1] + A[i-1]
    if S[i] in D: D[S[i]] += 1
    else: D[S[i]] = 1

ans = 0
for i in D:
    ans += int(D[i]*(D[i]-1)/2) # 同じ値を2つ選ぶ選び方
print(ans)

Measured memory_bytes: 59564
n, m, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

pos = x
cost1 = 0
while pos > 0
    cost1 += 1 if a.include?(pos)
    pos -= 1
end

pos = x
cost2 = 0
while pos < n
    cost2 += 1 if a.include?(pos)
    pos += 1
end

puts [cost1, cost2].min


Measured memory_bytes: 3836
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    sort(all(a));
    int ng=0;
    rep(i,n-1){
        if(a[i]==a[i+1]) ng++;
    }
    if(ng==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;cin>>S;
  int m=0,n=0;
  for(int i=0;i<3;i++){
    if(S[i]=='R')n++;
    else {
      m=max(n,m);
      n=0;
    }
  }
  m=max(n,m);
  cout<<m<<endl;
}


Measured memory_bytes: 3624
a, b, c = map(int, input().split())
res = 'NO'
if a == 5:
    if b==5:
        if c==7:
            res = 'YES'
    if b==7:
        if c==5:
            res = 'YES'
if b == 5:
    if a==5:
        if c==7:
            res = 'YES'
    if a==7:
        if c==5:
            res = 'YES'
if c == 5:
    if a==5:
        if b==7:
            res = 'YES'
    if a==7:
        if b==5:
            res = 'YES'
if res != 'YES':
    print('NO')
else:
    print(res)

Measured memory_bytes: 3064