akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    int x,y;
    cin>>x>>y;
    
    int a[7]={1,3,5,7,8,10,12};
    int b[4]={4,6,9,11};
    int c[1]={2};
    
    for(int i=0;i<7;i++){
        for(int g=0;g<7;g++){
            if(a[i]==x && a[g]==y){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    
    for(int i=0;i<4;i++){
        for(int g=0;g<4;g++){
            if(b[i]==x && b[g]==y){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
            
    }
    
    if(c[0]==x && c[0]==y){
        cout<<"Yes"<<endl;
        return 0;
        
    }
    
    cout<<"No"<<endl;
   
    
    
    
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;  // untility 头文件 untility
#define rep(i,x) for(int i = 0; i < x; i++)
#define pu push
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define fi first
#define sc second
//#define _Debug
const int maxn = 1e5+5;
vector<P> edge[maxn];
ll L[maxn];
void dfs(int cur, int pre, ll sum){
  L[cur] = sum;
  rep(i,edge[cur].size())if(edge[cur][i].fi != pre){
    dfs(edge[cur][i].fi, cur, sum+1LL*edge[cur][i].sc);
  }
}
int main(){
  #ifdef _Debug
  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  #endif // debugger
  int n; scanf("%d", &n);
  rep(i,n-1){
    int a, b, c;  scanf("%d%d%d", &a, &b, &c);
    edge[a].pb(mp(b,c));
    edge[b].pb(mp(a,c));
  }
  int q, k;
  scanf("%d%d", &q, &k);
  dfs(k,-1,0LL);
  rep(i,q){
    int a, b;  scanf("%d%d", &a, &b);
    printf("%lld\n", L[a]+L[b]);
  }
  return 0;
}


Measured memory_bytes: 14336
k, n = map(int, input().split())
data = list(map(int, input().split()))
max_value = 0

for i in range(n):
    if i != n - 1:
        max_value = max(max_value, data[i + 1] - data[i])
    else:
        max_value = max(max_value, k - data[i] + data[0])

print(k - max_value)

Measured memory_bytes: 78668
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 4e5+5, inf = 1e9+7;
int n, k, i, j;
int A[N];
bool cmp(ii&a, ii&b){
    return a.x+a.y<b.x+b.y;
}
int in[N], f[N], dp[N];
inline int expo(int n, int k, int p = inf) {int r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int inv(int a, int p = inf) {return expo(a, p - 2, p);}
inline int cc(int a, int b){ if(a<b || b<0) return 0; return f[a]*in[b]%inf*in[a-b]%inf; }
void fac(){ int i; f[0] = 1; rep(i, 1, N) f[i] = f[i-1]*i%inf; in[N-1] = inv(f[N-1]); sep(i, N-1, 0) in[i-1] = i*in[i]%inf; }
signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0, h, w;
    cin>>h>>w>>n;
    fac();
    vector<ii>v(n+1);
    rep(i, 0, n) cin>>v[i].x>>v[i].y;
    v[n].x= h; v[n].y = w;
    sort(all(v), cmp);
    rep(i, 0, n+1){
        dp[i] = cc(v[i].x+v[i].y-2, v[i].x-1);
        rep(j, 0, i) if(v[j].x<=v[i].x && v[j].y<=v[i].y)
            dp[i] -= cc(v[i].x-v[j].x+v[i].y-v[j].y, v[i].x-v[j].x)*dp[j]%inf;
        dp[i] = (dp[i]%inf+inf)%inf;
    }
    cout<<dp[n];
}

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


int main() {
  int N;
  cin >> N;
  long long A[N];
  for(int i = 0; i < N; i++) cin >> A[i];
  long long MAX = 0;
  long long ans = 0;
  for(int i = 0; i < N; i++){
    if(A[i] < MAX) ans += MAX -A[i];
    MAX = max(MAX, A[i]);
  }
  cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> W(N);

  int W_sum = 0;
  for (int i = 0; i < N; ++i) {
    cin >> W.at(i);
    W_sum += W.at(i);
  }

  int W_min_diff = W_sum;
  int prefix_sum = 0;
  for (int i = 0; i < N; ++i) {
    prefix_sum += W.at(i);
    W_min_diff = min(W_min_diff, abs(prefix_sum - (W_sum - prefix_sum)));
  }

  cout << W_min_diff << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, M, K;
lint a[200001], b[200001], a_idx = 0, b_idx = 0;
lint a_sum[200001], b_sum[200002];
int main() {
	cin >> N >> M >> K;
	REP(i, N) {
		cin >> a[i];
	}
	a[N] = K;
	REP(i, M) {
		cin >> b[i];
	}
	b[M] = K;
	REP(i, N + 1) {
		a_sum[i + 1] = a_sum[i] + a[i];
	}
	REP(i, M + 1) {
		b_sum[i + 1] = b_sum[i] + b[i];
	}
	lint maxv = 0;
	REP(i, N + 1) {
		if (a_sum[i] > K) continue;
		lint cnt = i;
		cnt += (upper_bound(b_sum, b_sum + M + 2, K - a_sum[i]) - b_sum - 1);
		chmax(maxv, cnt);
	}
	cout << maxv;
}


Measured memory_bytes: 9880
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define ff fflush(stdout)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	double one,wo;
	int n;
	cin>>n;
	wo=double((n/2));
	one=n-wo;
	wo=n;
//	if(wo==0) cout<<"1.0000000000";
	printf("%.10f",one/wo);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n;
cin >> n;
ll a[n - 1];
ll ans[n];
for (ll i = 0; i < n;i++){
    ans[i] = 0;
}
    for (ll i = 0; i < n - 1; i++) {
        cin >> a[i];
        ans[a[i] - 1]++;
    }
for (ll i = 0; i < n;i++){
    cout << ans[i] << endl;
}
}


Measured memory_bytes: 6680
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        while(true){
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a==-1&&b==-1&&c==-1) break;
        if(a==-1||b==-1||a+b<30){
            System.out.println("F");
        }else if(a+b>=80){
            System.out.println("A");
        }else if(a+b>=65){
            System.out.println("B");
        }else if(a+b>=50){
            System.out.println("C");
        }else if(a+b>=30){
            if(50>c) {
                System.out.println("D");
            }else{
                System.out.println("C");
            }
        }
        }
        sc.close();
    }
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    ll sum = 0;
    REP(i, n) sum += a[i];

    ll ans = 1;
    auto check = [&](ll r) {
        vector<ll> b(a), c(n);
        REP(i, n) {
            b[i] %= r;
            c[i] = r-b[i];
        }
        sort(ALL(b));
        sort(ALL(c), greater<>());

        FOR(i, 1, n) b[i] += b[i-1];
        for(ll i=n-2; i>=0; --i) c[i] += c[i+1];
        FOR(i, 1, n) {
            if(b[i-1] == c[i] && b[i-1] <= k) {
                chmax(ans, r);
            }
        }
    };

    for(ll i=1; i*i<=sum; i++) {
        if(sum%i==0) {
            check(i);
            if(i*i != sum) check(sum/i);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


A, B = MI()
print(A + B if A + B < 10 else 'error')


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


int main(){
    int n,count=0;
    int *p;
    cin >> n;
    p = new int[n];
    for(int i=0;i<n;i++)scanf("%d",&p[i]);
    for(int i=1;i<n-1;i++){
        if(p[i]<p[i-1] && p[i]>p[i+1])count++;
        if(p[i]<p[i+1] && p[i]>p[i-1])count++;
    }
    
    cout <<count <<endl;


}

Measured memory_bytes: 256
let s = stdin.ReadLine()

let ans =
    let rIntervals, lIntervals =
        let rIntervals = ResizeArray<int * int> []
        let lIntervals = ResizeArray<int * int> []

        let mutable left = ('R', 0)
        for i in 1 .. s.Length - 1 do
            if fst left = 'R' && s.[i] = 'L' then
                rIntervals.Add((snd left, i - 1))
                left <- ('L', i)
                if i = s.Length - 1 then
                    lIntervals.Add((i, i))
            elif fst left = 'L' then
                if s.[i] = 'R' then
                    lIntervals.Add((snd left, i - 1))
                    left <- ('R', i)
                elif i = s.Length - 1 then
                    lIntervals.Add((snd left, i))

        [ for i in rIntervals -> i ], [ for i in lIntervals -> i ]

    List.zip rIntervals lIntervals
    |> List.collect (
        fun ((rl, rr), (ll, lr)) ->
            [rl .. lr]
            |> List.map (
                fun i ->
                    if i = rr then
                        ([rl .. rr].Length + 1) / 2 + [ll .. lr].Length / 2 |> string
                    elif i = ll then
                        ([rl .. rr].Length) / 2 + ([ll .. lr].Length + 1) / 2 |> string
                    else
                        0 |> string ))
    |> List.toSeq
    |> String.concat " "

ans
|> stdout.WriteLine

Measured memory_bytes: 35248
#include <bits/stdc++.h>
using namespace std;
using ll =long long ;
int main() {
  ll a;
  cin>>a;
  vector<char>vec(a);
  vector<char>veco(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  for(ll i=0;i<a;i++){
    cin>>veco.at(i);
  }
  for(ll i=0;i<a;i++){
    cout<<vec.at(i)<<veco.at(i);
  }
  cout<<endl;
  return 0;
}
  

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  bool zero = false;
  for(int i=0; i<N; i++){
    cin >> vec[i];
    if(vec[i] == 0){
      zero = true;
    }
  }
  bool over = false;
  int64_t ans = vec[0];
  int64_t INF = 1e18;
  for(int i=1; i<N; i++){
    if(zero){
      ans = 0;
      break;
    }
    if(vec[i] > INF / ans){
      over = true;
      break;
    }
    else{
      ans *= vec[i];
    }
  }
  
  
  if(over && !zero){
    cout << -1 << endl;
  }
  else{
    cout << ans << endl;
  }
}

Measured memory_bytes: 4052
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    var N = parseInt(input[0], 10)
    tmp = input[1].split(" ");
    var list = []
    for (var i = 0; i < N; i++) {
        var l = parseInt(tmp[i], 10)
        list.push(l)
    }
    list.sort((a, b) => a - b);

    if (list.slice(0, N - 1).reduce((prev, current) => prev + current) > list[N - 1]) {
        console.log('Yes')
    } else {
        console.log('No');
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int N;
map<int, int> F;

int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) {
    int a; cin >> a; ++F[a];
  }
  int el = F.begin()->first, nl = F.begin()->second;
  int eg = F.rbegin()->first;
  if(!((nl == 1 && eg == el * 2) || (nl == 2 && eg == el * 2 - 1))) {
    cout << "Impossible" << endl; return 0;
  } else {
    for(int e = el; e <= eg; ++e) {
      if(F[e] == 0) { cout << "Impossible" << endl; return 0; }
    }
  }
  cout << "Possible" << endl;
  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector <int>> matrix(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> matrix[i][j];
    }
  }
  vector<int> v(m);
  for (int i = 0; i < m; i++) {
    cin >> v[i];
  }
  vector<int> r(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      r[i] += matrix[i][j] * v[j];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << r[i] << endl;
  }
}



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

#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (max(a, max(b, c)) != min(a, min(b, c)) && (a == b || b == c || c == a)) cout << "Yes";
    else cout << "No";
    return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;


void solve()
{
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int x, y;
    x = tx - sx; y = ty - sy;
    REP(i, y) cout << "U";
    REP(i, x) cout << "R";
    REP(i, y) cout << "D";
    REP(i, x) cout << "L";
    x++; y++;
    cout << "L";
    REP(i, y) cout << "U";
    REP(i, x) cout << "R";
    cout << "D";
    cout << "R";
    REP(i, y) cout << "D";
    REP(i, x) cout << "L";
    cout << "U" << endl;
}

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);

    vector<int> takoyaki(n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &takoyaki[i]);
    }

    int sum = 0;

    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            sum += takoyaki[i] * takoyaki[j];
        }
    }

    printf("%d", sum);

    return 0;

}


Measured memory_bytes: 888
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    cout << (n * (n - 1))/2;
    return 0;
}

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

void testCase() {    
    
}

int A[1000000];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 2; i <= n; i++) {
        int a;
        cin >> a;
        A[a]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << A[i] << "\n";
    }
}
















Measured memory_bytes: 4324
"""
 // Author : snape_here - Susanta Mukherjee

"""
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

    
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading



def ii(): return int(input())
def fi(): return float(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

import math
 
def find_gcd(x, y): 
      
    while(y): 
        x, y = y, x % y 
      
    return x
 
def main():
 
    n=ii()
    v=li()
    v.sort()
    a=v[0]
    for i in range(1,n):
        a+=v[i]
        a/=2
    print(a)
    
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()

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

static const int N = 1000;

int lcs(string X, string Y){
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for(int i = 0; i <=m; i++) c[i][0] = 0;
  for(int j = 1; j <=n; j++) c[0][j] = 0;

  for(int i = 1; i <=m; i++){
   for(int j = 1; j <= n; j++){
    if(X[i] == Y[j]){
     c[i][j] = c[i - 1][j - 1] + 1;
    }else{
     c[i][j] = max(c[i - 1][j], c[i][j - 1]);
    }
    maxl = max(maxl, c[i][j]);
    }
}
   return maxl;
}
   int main(){
   string s1,s2;
   int n; cin >> n;
   for(int i = 0;i < n; i++){
    cin >> s1 >> s2;
    cout << lcs(s1,s2) << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

ll N;
ll ans = 0;
ll a, b;

void solve() {
    cin >> a >> b;
    REP(i,1,1000) {
        ll s1 = i*(i+1)/2;
        ll s2 = (i+1)*(i+2)/2;
        if (s2 - s1 == b - a) {
            cout << s2 - b << endl;
            return;
        }
    }
}

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


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	
	for i := len(s)-1; i > 0; i-- {
		if i % 2 != 0 {
			continue
		} else {
			half := i / 2
			if s[0:half] == s[half:i] {
				fmt.Println(i)
				return
			}
		}
	}
}

Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
#define t int t ; cin>>t; while(t--)
#define u(x,a,b) for(int x=a;x<b;x++)
#define what(x) cerr << #x << "=" << x<<endl;
#define lli long long int
#define endl "\n"
lli Mod = 1000000007;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	lli n,d;
	cin>>n>>d;
	lli sum =0,count=0;
	bool flag = false;
	for(int i=0;i<n;i++){
        if(sum<n){
			count++;
		}else{
            break;
        }
		sum += (2*d+1);
	}
	cout<<count<<endl;
    return 0;
}
                                                                                                                                 

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

using std::vector;
using std::string;
using std::cout;
using std::cin;
typedef long long ll;
/*void input(){
    
}*/
/*void output(){
    
}*/

int main() {
	int test=1;
	//cin>>test;
	while(test-->0)
	{   
	  char a,b,c,d,e,f;
	bool flag=false;
	cin>>a>>b>>c>>d>>e>>f;
	if(a==f&&b==e&&c==d)
	    flag=true;
	if(flag){
	    cout<<"YES";
	}
	else
	    cout<<"NO";
	return 0;  
	    
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    String T = sc.next();
    String ans = "";

    char[] cS = S.toCharArray();
    char[] cT = T.toCharArray();

    for(int i = 0; i < N ; i++) {
    	ans += cS[i];
    	ans += cT[i];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 39112
#include<stdio.h>

#define nmax 100000

typedef struct {
  char name[10];
  int time;
}input;

int main() {
  int i=0,j=0,x,n,t,sum=0;
  input in[nmax];

  scanf("%d%d",&n,&t);
  for(i = 0 ; i < n ; i++) {
    scanf("%s%d",&in[i].name,&in[i].time);
  }

  while(n > 0) {
    if(i == nmax)
      i = 0;
    else if(j == nmax)
      j = 0;
    if((x = in[j].time - t) > 0) {
      in[j].time = x;
      in[i] = in[j];
      sum += t;
      i++;
      j++;
    }
    else if((in[j].time - t) <= 0) {
      sum += in[j].time;
      printf("%s %d\n",in[j].name,sum);
      j++;
      n--;
    }
  }
  return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define ll long long
int main()
{
	ll n;
	cin>>n;
	ll t = __gcd(2*1ll,n);
	cout<<n*2/t<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char s[10],t[10],u[10];
    int a, b;
    scanf("%s",&s);
    scanf("%s",&t);
    scanf("%d %d", &a, &b);
    scanf("%s", &u);

   int d1 = strcmp(u,s);
   // int d2 = strcmp(u,t);

    if ( d1==0 )
        printf("%d %d", a-1, b);
    else
        printf("%d %d", a, b-1);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int N, K;
int D[2001];
vector<int> E[2001];
void dfs(int v, int d) {
	D[v] = d;
	for (int to : E[v]) {
		if (D[to] < 0) dfs(to, d + 1);
	}
}

int dfs2(int v, int prev, int d) {
	if (d > K / 2) return 0;
	int ret = 1;
	for (int to : E[v]) {
		if (to != prev) ret += dfs2(to, v, d + 1);
	}
	return ret;
}

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


	cin >> N >> K;
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		E[a].pb(b);
		E[b].pb(a);
	}

	rep1(j, N) D[j] = -1;
	dfs(1, 0);
	int saidai = 0;
	int doko, doko2;
	rep1(i, N) if (saidai < D[i]) {
		saidai = D[i];
		doko = i;
	}
	rep1(j, N) D[j] = -1;
	dfs(doko, 0);
	saidai = 0;
	rep1(i, N) if (saidai < D[i]) {
		saidai = D[i];
		doko2 = i;
	}
	if (saidai <= K) {
		printf("0\n");
		return 0;
	}

	bool muri[2001] = {};
	rep1(i, N) if (D[i] < K / 2) {
		muri[i] = 1;
	}
	rep1(j, N) D[j] = -1;
	dfs(doko2, 0);
	rep1(i, N) if (D[i] < K / 2) {
		muri[i] = 1;
	}

	if (K % 2 == 0) {
		int kotae = N;
		rep1(i, N) {
			if (!muri[i]) {
				int kazu = dfs2(i, -1, 0);
				kotae = min(kotae, N - kazu);
			}
		}
		co(kotae);
	}
	else {
		int kotae = N;
		rep1(i, N) {
			for (int j : E[i]) {
				if (i < j) {
					if (!muri[i] && !muri[j]) {
						int kazu = dfs2(i, j, 0) + dfs2(j, i, 0);
						kotae = min(kotae, N - kazu);
					}
				}
			}
		}
		co(kotae);
	}

	Would you please return 0;
}

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

#define ll long long
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll>
#define pll pair<ll,ll>
int main(){
  int x,y;
  cin>>x>>y;

  int mini=2*x;
  int maxi=4*x;
  if(mini<=y && y<=maxi && y%2==0)
  cout<<"Yes";
  else
  cout<<"No";
}


Measured memory_bytes: 3632
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

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

#define int long long
#define ar array
const int INF = 1e10;


void solve(){
	int n, k;
	cin >> n >> k;
	vector<int> arr(n,0);
	for(auto& e : arr) cin >> e;
	vector<int> dp(n,INF);
	dp[0] = 0;
	for(int i = 1;i < n; i++){
		for(int j = i-1, var = k; j >= 0 && var > 0; j--, var--){
			dp[i] = min(dp[i],dp[j]+abs(arr[i]-arr[j]));
		}	
	}
	cout << dp[n-1] << "\n";
} 

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int TC = 1;
    while(TC--)
        solve();

    return 0;
}



Measured memory_bytes: 4748
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
if a >= 13:
  print(b)
elif a >= 6:
  print(b//2)
else:
  print(0)
















Measured memory_bytes: 27084
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n,k; cin>>n>>k;
    vector<ll> a(n);
    ll s = 0;
    rep(i,n) {
        cin>>a[i];
        s += a[i];
    }

    vector<ll> x;
    for (int i = 1; i*i <= s; ++i) {
        if (s%i == 0) {
            x.push_back(i);
            if (s/i != i) x.push_back(s/i);
        }
    }

    auto check = [&](ll t) -> bool {
        vector<ll> b(a);
        rep(i,n) b[i] = b[i]%t;
        sort(b.begin(), b.end());
        vector<ll> p(n+1),q(n+1);
        rep(i,n) p[i+1] = p[i]+b[i];
        for (int i = n-1; i >= 0; --i) q[i] = q[i+1]+(t-b[i]);
        ll cnt = LINF;
        for (int i = 0; i <= n; ++i) if (p[i]==q[i]) {
            chmin(cnt, p[i]);
        }
        if (k >= cnt) return true;
        else return false;
    };

    ll ans = 0;
    for (auto &&e: x) {
        if (check(e)) chmax(ans, e);
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x;
  int n;
  cin>>x>>n;
  if(n==0){
    cout<<x<<'\n';
    return(0);
  }
  vint q(n);
  rep(i,n){
    cin>>q[i];
  }
  sort(all(q));
  vint p;
  int fg=0;
  REP(i,-150,150){
    if(q[fg]!=i){
      p.push_back(i);
    }
    else{
      fg++;
    }
  }
  int min=INF,minp=0;
  sort(all(p));
  int si=p.size();
  rep(i,si){
    if(chmin(min,abs(x-p[i]))){
      min=abs(x-p[i]);
      minp=p[i];
    }
  }
  cout<<minp<<'\n';
  return(0);
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/







int dp[3030][3030];
int A, B, C, D, E, F;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B >> C >> D >> E >> F;

    double ma = 0;
    int ans1 = 100 * A, ans2 = 0;
    dp[0][0] = 1;
    rep(i, 1, F + 1) rep(j, 0, i + 1) {
        int wa = i - j;
        int sa = j;

        if (100 * A <= i) if (dp[i - 100 * A][j]) dp[i][j] = 1;
        if (100 * B <= i) if (dp[i - 100 * B][j]) dp[i][j] = 1;
        if (C <= i && C <= j) if (dp[i - C][j - C]) dp[i][j] = 1;
        if (D <= i && D <= j) if (dp[i - D][j - D]) dp[i][j] = 1;

        if (sa * 100 <= wa * E && dp[i][j] && 0 < j) {
            double e = 1.0 * 100 * j / i;
            if (ma < e) {
                ma = e;
                ans1 = i;
                ans2 = j;
            }
        }
    }

    printf("%d %d\n", ans1, ans2);
}


Measured memory_bytes: 33536
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"

    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll x,n;
    cin>>x>>n;
    bool m[103]={0};
    ll a[n];
    rep(i,n){
        cin>>a[i];
        m[a[i]]=1;
    }
    // f(i,1,15)cout<<m[i]<<" ";
    // cl;
    ll ans=inf;
    ll id=0;
    f(i,-2,103){
        if(m[i]==0){
            ll dif=abs(x-i);
            
            if(dif<ans){
                ans=dif;
                id=i;
            }
        }
    }
    cout<<id;

}




Measured memory_bytes: 3648
import itertools
import math
N=int(input())
l=list(itertools.permutations(range(1,N+1)))
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
for i in range(math.factorial(N)):
  if P==l[i]:
    p=i
  if Q==l[i]:
    q=i
    
    
print(abs(p-q))
  

Measured memory_bytes: 7972
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

typedef priority_queue<int, vector<int>, greater<int>> priority_queue_asc;

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

    int Q;
    cin >> Q;

    bool isReverse = false;

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

        if (t == 1) {
            isReverse = !isReverse;
        } else if (t == 2) {
            int f;
            cin >> f;
            if ((f == 1 && !isReverse) || (f == 2 && isReverse)) {
                char c;
                cin >> c;
                S = c + S;
            } else if ((f == 2 && !isReverse) || (f == 1 && isReverse)) {
                char c;
                cin >> c;
                S.push_back(c);
            }
        }
    }

    if (isReverse) {
        reverse(S.begin(), S.end());
    }
    cout << S << endl;


    return 0;
}


Measured memory_bytes: 4188
N = gets.to_i
@ans_array = []
def dnf(i)
  if i.to_i <= N
    @ans_array << i if i.chars.uniq.size == 3
    dnf(i+"3")
    dnf(i+"5")
    dnf(i+"7")
  end
end

dnf("3")
dnf("5")
dnf("7")
puts @ans_array.size

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

using namespace std;
int p[100011], rk[100011], sz[100011], fr[100011], bl[100011];
int n;

int FindSet(int x)
{
    if (p[x]!=x)
        p[x] = FindSet(p[x]);
    return p[x];
}

bool isSameSet(int i, int j)
{
    return (FindSet(i)==FindSet(j));
}

void UnionSet(int i, int j)
{
    if (!isSameSet(i, j))
    {
        int x = FindSet(i);
        int y = FindSet(j);
        if (rk[x] > rk[y])
        {
            p[y] = x;
            //int sub = sz[x];
            sz[x] += sz[y];
            //sz[y] += sub;
        }
        else
        {
            p[x] = y;
            if (rk[x] == rk[y])
                rk[y]++;
            //int sub = sz[x];
            sz[y] += sz[x];
            //sz[x] += sub;
        }

    }
    //cerr<<"size: ";
    //for (int i=1;i<=n;i++)
        //cerr<<sz[i]<<" "; //cerr<<endl;
    //cerr<<endl<<"par: ";
    //for (int i=1;i<=n;i++) cout<<p[i]<<" "; cerr<<endl;
}

int main()
{
    cin>>n;
    int m, k; cin>>m>>k;

    for (int i=1;i<=n;i++)
    {
        p[i] = i;
        sz[i] = 1;
    }

    while(m--)
    {
        int A, B;
        cin>>A>>B;
        UnionSet(A, B);
        fr[A]++; fr[B]++;
    }

    while (k--)
    {
        int A, B;
        cin>>A>>B;
        if (isSameSet(A, B))
        {
            bl[A]++;
            bl[B]++;
        }
    }

    for (int i=1;i<=n;i++)
        cout<<sz[FindSet(i)] - fr[i] - bl[i] - 1<<" ";
    //cerr<<endl<<"size: ";
    //for (int i=1;i<=n;i++) cout<<sz[i]<<" ";
    //cerr<<endl<<"par: ";
    //for (int i=1;i<=n;i++) cout<<p[i]<<" ";
    return 0;
}


Measured memory_bytes: 2816
import sys
input = sys.stdin.readline
N = int(input())
a =[0]+ list(map(int, input().split()))
for i in range(N,0,-1):
    a[i] =sum(a[i::i]) %2
print(sum(a))
del a[0]
for i,v in enumerate(a):
    if v==1:
        print(i+1,end=" ")

Measured memory_bytes: 7220
#include <stdio.h>
int main(){
  int N,a,i,j,k,minj;
  int count=0;
  int A[100];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<=N-1;i++){
    minj=i;
    for(j=i;j<=N-1;j++){
      if(A[j]<A[minj]){
        minj=j;
      }
    }
    if(A[i]!=A[minj]){
        a=A[i];
        A[i]=A[minj];
        A[minj]=a;
        count++;
      }
  }
  for(k=0;k<N;k++){
    printf("%d",A[k]);
    if(k<N-1)printf(" ");
  }
  printf("\n");
  printf("%d",count);
  printf("\n");
}





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

int arr[200005];
int n;

long long dnc(int from, int to){
    if(from>=to-1)
        return 0;
    
    long long num=0;
    int mid=(from+to)/2;
    num+=dnc(from, mid);
    num+=dnc(mid, to);
    
    int i=from, j=mid, cnt=0;
    while(i<mid && j<to){
        if(arr[i]>arr[j]){
            num+=j-i-cnt++;
            j++;
        }
        else{
            i++;
        }
    }
    
    sort(arr+from, arr+to);
    return num;
}

int main() {
    ios_base::sync_with_stdio(0);
    
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    
    cout << dnc(0, n) << endl;
    
    return 0;
}

Measured memory_bytes: 3896
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e9 + 5;
int n, ma, mb, dp[405][405];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>ma>>mb;
    
    fill_n(&dp[0][0], 405*405, N);
    dp[0][0] = 0;
    
    int a,b,c;
    for (int i = 0; i < n; i++){
        cin>>a>>b>>c;
        for (int j = 400; j >= 0; j--){
            for (int k = 400; k >= 0; k--){
                if(dp[j][k]!=N){
                    dp[j+a][k+b] = min(dp[j+a][k+b], dp[j][k] + c);
                }
            }
        }
    }
    
    int ans = N;
    for (int i = 1; i <= 400; i++){
        if(i*ma>400 || i*mb>400)break;
        if(dp[i*ma][i*mb] == N)continue;
        ans = min(ans, dp[i*ma][i*mb]);
    }
    
    if(ans == N)cout<<-1<<endl;
    else cout<<ans<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 896
#include <stdio.h>

int main(void) {
  int n,m,i,g=0,ans=0;
  int a[10010];
  
  scanf("%d",&n);
  scanf("%d",&m);
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    g+=a[i];
  }
  for(i=0;i<n;i++)
  {
    if(a[i]*(4*m)>=g)
    {
      ans++;
    }
  }
  if(ans>=m)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  

  return 0;
}


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

//隣接リスト
class graph{
    public:
    int flag=0;//informed or not
    vector<int> vtx;//vertex
    vector<int> dst;//distance
    int color=0;//BFS
    int x;
};

graph g[100001];


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

    for(int i=1;i<=M;i++){
        int L,R,D;
        cin>>L>>R>>D;
        g[L].vtx.push_back(R);
        g[L].dst.push_back(D);
        g[L].flag=1;
        g[R].vtx.push_back(L);
        g[R].dst.push_back(-D);
        g[R].flag=1;
    }

    //BFS
    queue<int> q;
    for(int i=1;i<=N;i++){
        if(g[i].flag && (!g[i].color)){//informed && not visit
            q.push(i);
            g[i].x=0;
            int u;
            while(!q.empty()){
                u=q.front();
                q.pop();
                for(int j=0;j<g[u].vtx.size();j++){
                    if(g[g[u].vtx[j]].color){//訪問済なら検証
                        if(g[g[u].vtx[j]].x!=g[u].x+g[u].dst[j]){cout<<"No"<<endl;return 0;}
                    }else{//そうでないならキューにぶち込む
                        g[g[u].vtx[j]].x=g[u].x+g[u].dst[j];
                        g[g[u].vtx[j]].color=1;
                        q.push(g[u].vtx[j]);
                    }
                }
            }
            g[i].color=1;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 14976
#include <iostream>

using namespace std;

int main(){
    while(true){
        int H,W;
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

int main(){
    int n; cin >> n;
    vector<int> t(n),x(n),y(n);
    for(int i=0;i<n;i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    bool flag = true;
    for(int i=0;i<n;i++){
        if(i==0){
            if(t[i] < x[i]+y[i] || (t[i] - x[i] + y[i])%2 != 0) flag = false;
        }else{
            if(t[i]-t[i-1] < abs(x[i]-x[i-1])+abs(y[i]-y[i-1]) || (t[i]-t[i-1]-(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])))%2 != 0) flag = false;
        }
    }
    if(flag){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

const int M=100006;
ll f[M],inv[M];
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void compute(){
    f[0]=1;
    rep(i,1,M){
        f[i]=(1LL*i*f[i-1])%hell;
    }
    inv[M-1]=expo(f[M-1],hell-2,hell);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%hell;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%hell)*inv[n-r])%hell;
}
void solve()
{
    ll n;
    compute();
    cin>>n;
    ll ans=0;
    ll maxi=n/3;
    rep(i,1,maxi+1)
    {
        ans=(ans+C(n-3*i+i-1,i-1))%hell;
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 5208
#include <stdio.h>

int main(void)
{
  int n, m;
  int s[5], c[5];

  int i, j;
  int ans = 0;
  int oneh = 0, ten = 0, one = 0;

  /*input*/
  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++)
    scanf("%d %d", &s[i], &c[i]);

  /*error search*/
  /*different number*/
  for (i = 0; i < m; i++) {
    for (j = 0; j < m; j++) {
      if (i != j && s[i] == s[j] && c[i] != c[j])
	ans = -1;
    }
  }

  /*first 0*/
  if (n >= 2) {
    for (i = 0; i < m; i++) {
      if (s[i] == 1 && c[i] == 0)
	ans = -1;
    }
  }

  /*display*/
  if (ans == -1)
    printf("%d\n", ans);
  else {
    if (n == 1) {
      for (i = 0; i < m; i++) {
	if (s[i] == 1)
	  one = c[i];
      }
      printf("%d", one);
    }
    else if (n == 2) {
      for (i = 0; i < m; i++) {
	if (s[i] == 1)
	  ten = c[i];
	else if (s[i] == 2)
	  one = c[i];
      }
      if (ten == 0)
	printf("%d", 10 + one);
      else 
	printf("%d", 10 * ten + one);
    }
      else if (n == 3) {
	for (i = 0; i < m; i++) {
	  if (s[i] == 1)
	    oneh = c[i];
	  else if (s[i] == 2)
	    ten = c[i];
	  else if (s[i] == 3)
	    one = c[i];
	}
	if (oneh == 0)
	  printf("%d", 100 + 10 * ten + one);
	else
	  printf("%d", 100 * oneh + 10 * ten + one);
      }
  }

  putchar('\n');

  return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 11 15:58:15 2020

@author: Aruto Hosaka
"""


N = int(input())
n15 = (N-1)//15
d15 = (N-1)%15
A = [1,2,0,4,0,0,7,8,0,0,11,0,13,14,0]
d = sum(A) - sum(A[d15+1:])
n = (n15-1)*n15//2*120+n15*60
ans = d+n
for a in A[:d15+1]:
    if a != 0:
        ans += n15*15
print(ans)

Measured memory_bytes: 9084