akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << n/2 * (n-n/2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>

using namespace std;

int main()
{
    struct { int x,y; } p1,p2,p3,p4,v;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    
    v.x = p2.x - p1.x;
    v.y = p2.y - p1.y;
    
    swap(v.x, v.y);
    v.x *= -1;
    
    p3.x = p2.x + v.x;
    p3.y = p2.y + v.y;
    
    swap(v.x, v.y);
    v.x *= -1;
    
    p4.x = p3.x + v.x;
    p4.y = p3.y + v.y;
    
    cout << p3.x << ' ' << p3.y << ' ' << p4.x << ' ' << p4.y << '\n';
    return 0;
}

Measured memory_bytes: 256
n, w = map(int,input().split())
li = []
while True:
    try:
        li.append(list(map(int,input().split())))
    except:
        break

dp=[[0] * (w+1) for _ in range(n+1)]
for i in range(1, n+1):
    for j in range(1,w+1):
        if (j-li[i-1][0]>=0):
            # 品物がひとつ前で重さは同じ所の価値と品物がひとつ前で重さが加える価値を持し品物の重さ分引いたときの価値にひとつ前の品物の価値を加えたもの
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-li[i-1][0]]+li[i-1][1])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[n][w])

Measured memory_bytes: 120172
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> P; // end, start

#define MAX_N 1000000
#define INF 1000000000

int X[MAX_N];
int L[MAX_N];

int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  priority_queue<P, vector<P>, greater<P> > pq;
  
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> X[i] >> L[i];

    int end = min(INF, X[i] + L[i]);
    int start = max(0, X[i] - L[i]);

    pq.push( P(end, start) );
    
  }

  // ---------------------
  // 
 
  int position = 0;
  int cnt = 0;

  while (pq.size() != 0) {

    //cout << "Position = " << position << endl;
    
    P p = pq.top();
    pq.pop();

    if (p.second >= position) {
      position = p.first;
      cnt++;
    }

  }

  
  cout << cnt << endl;
  
  return 0;
  
}


Measured memory_bytes: 5752
#include<bits/stdc++.h>
using namespace std;
#define N 1000
const long inf=1e9+7;
int a[N+5][N+5];
int main() {
  	int n,m; char x;
  	cin>>n>>m;
  	for(int i=1;i<=n;i++) {
    	for(int j=1;j<=m;j++) {
        	cin>>x;
          	a[i][j]=(x=='.')?1:0;
        }
    }
  	int dp[n+1][m+1];
  	for(int i=0;i<=n;i++) {
    	for(int j=0;j<=m;j++) {
        	if(i==0 || j==0) {dp[i][j]=0;}
          	if(i==1 && j==1) {dp[i][j]=1;}
          	else if(a[i][j]==1) {dp[i][j]=(dp[i-1][j]%inf + dp[i][j-1]%inf)%inf;}
          	else {dp[i][j]=0;}
        }
    }
  	cout<<dp[n][m]%inf<<endl;
return 0;
}


Measured memory_bytes: 11432
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[]=new int[N+1];
		int B[]=new int[N+1];
		int C[]=new int[N];
		int ans=0;
		for(int i=1;i<=N;i++){
			A[i]=sc.nextInt();
		}
		for(int i=1;i<=N;i++){
			B[i]=sc.nextInt();
		}
		for(int i=1;i<=N-1;i++){
			C[i]=sc.nextInt();
		}
		for(int i=1;i<=N;i++){
			ans=ans+B[A[i]];
		}
		for(int i=1;i<=N-1;i++){
		if (A[i]+1==A[i+1]) {
				ans=ans+C[A[i]];
			}
		}
		System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    ll a;
    const ll MOD=1e9+7;
    modint(ll a_=0){
        a=((a_%MOD)+MOD)%MOD;
    }
    modint inv()const{
        ll n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y(a+x.a);
        return y;
    }
    modint operator-(const modint& x){
        modint y(a-x.a);
        return y;
    }
    modint operator*(const modint& x){
        modint y(a*x.a);
        return y;
    }
    modint operator/(const modint& x){
        return *this * x.inv();
    }
    modint& operator+=(const modint& x){
        *this=*this+x;
        return *this;
    }
    modint& operator-=(const modint& x){
        *this=*this-x;
        return *this;
    }
    modint& operator*=(const modint& x){
        *this=*this*x;
        return *this;
    }
    modint& operator/=(const modint& x){
        *this=*this/x;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    ll a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(ll a,ll b){
    modint n(1),A(a);
    while(b){
        if(b&1) n*=A;
        A*=A;
        b>>=1;
    }
    return n;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<ll> s(n),t(m);
    for(auto& i:s) cin>>i;
    for(auto& i:t) cin>>i;
    s.emplace_back(0);
    t.emplace_back(0);
    vector<modint> dp(m+1),ndp(m+1),sm(m+1),nsm(m+1);
    modint c;
    Fr(i,n){
        nsm.resize(m+1,0);
        c=0;
        Fr(j,m){
            if(t[j-1]==s[i-1]) c+=1;
            ndp[j]=dp[j]+c+sm[j];
            if(t[j]==s[i]&&j<m) nsm[j+1]=nsm[j]+ndp[j];
            else if(j<m) nsm[j+1]=nsm[j];
        }
        dp.swap(ndp);
        sm.swap(nsm);
    }
    cout<<dp[m]+1<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
// #include <set>
// #include <string>
// #include <cmath>
// #include <map>
// #include <iomanip>

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
// typedef long long ll;

// void p() {
//     cout << "\n";
// }
// template<class Head, class... Body>
// void p(Head head, Body... body) {
//     cout << head << ",";
//     p(body...);
// }

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (const auto i : v) {
        os << i << " ";
    }
    os << "]";
    return os;
}


int main(int argc, char const *argv[]) {
    int N;
    ull W;
    cin >> N >> W;
    vector<ull> w(N), v(N);
    vector<vector<ull>> w2v(4);
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
        w2v[(int)(w[i] - w[0])].push_back(v[i]);
    }

    for (int i = 0; i < 4; ++i) {
        sort(w2v[i].begin(), w2v[i].end(), greater<ull>());
    }
    // cout << w2v << endl;

    vector<vector<ull>> w2v_cum(4);
    for (int i = 0; i < 4; ++i) {
        w2v_cum[i].push_back(0);
        ull sum = 0;
        for (ull item : w2v[i]) {
            sum += item;
            w2v_cum[i].push_back(sum);
        }
    }
    // cout << w2v_cum << endl;

    ull ans = 0;
    for (int i = 0; i <= w2v[0].size(); ++i) {
        ull w0 = (w[0] + 0) * i;
        for (int j = 0; j <= w2v[1].size(); ++j) {
            ull w1 = (w[0] + 1) * j;
            for (int k = 0; k <= w2v[2].size(); ++k) {
                ull w2 = (w[0] + 2) * k;
                for (int l = 0; l <= w2v[3].size(); ++l) {
                    ull w3 = (w[0] + 3) * l;
                    if (w0 + w1 + w2 + w3 > W) break;
                    ull sum = w2v_cum[0][i] + w2v_cum[1][j] + w2v_cum[2][k] + w2v_cum[3][l];
                    if (ans < sum) {
                        ans = sum;
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

struct Node {
  int key;
  Node *prev, *next;
};

Node *nil;

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

void deleteNode(Node *t) {
  if(t == nil)
    return;
  t->next->prev = t->prev;
  t->prev->next = t->next;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

Node* listSearch(int key){
  Node *search = nil->next;
  while (search != nil && search->key != key) {
    search = search->next;
  }
  return search;
}

void printNode() {
  Node *iter = nil->next;
  int isf = 0;
  while (true) {
    if (iter == nil)
    {
      break;
    }
    if (isf++ > 0)
      printf(" ");
    printf("%d", iter->key);
    iter = iter->next;
  }
  printf("\n");
}

int main()
{
  init();
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n;i++) {
    char command[30];
    int value;
    scanf("%s%d", command, &value);
    if (!strcmp(command, "insert"))
    {
      insert(value);
    } else if (!strcmp(command, "delete")) {
      Node *node = listSearch(value);
      deleteNode(node);
    }
    else if (!strcmp(command, "deleteFirst")) {
      deleteFirst();
    }
    else if (!strcmp(command, "deleteLast"))
    {
      deleteLast();
    }
  }
  printNode();
}


Measured memory_bytes: 34012
def dist(P, Q):
    return ((P[0] - Q[0]) ** 2 + (P[1] - Q[1]) ** 2) ** 0.5

n = int(input())
for _ in range(n):
    xa, ya, ra, xb, yb, rb = map(float, input().split())
    A, B = (xa, ya), (xb, yb)
    if dist(A, B) > ra + rb:
        print(0)
    elif dist(A, B) + ra < rb:
        print(-2)
    elif dist(A, B) + rb < ra:
        print(2)
    else:
        print(1)

Measured memory_bytes: 7676
#!/usr/bin/env python3
#ABC62 A

x,y = map(int,input().split())

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
elif x in c and y in c:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
M,D = map(int,input().split())
res = 0
for i in range(1,M+1):
    for j in range(1,D+1):
        d1 = j % 10
        d10 = j //10
        if 2 <= d1 and 2 <= d10 and d1*d10 == i:
            res += 1
print(res)

Measured memory_bytes: 9048
import sys

N, K = map(int, input().split())
HList = list(map(int, input().split()))

if N < K:
    print('0')
    sys.exit(0)

HList.sort()

result = 0
for i in range(N - K - 1, -1, -1):
    result += HList[i]
    

print(result)


Measured memory_bytes: 26024
use std::io;

fn main() {
  let stdin = io::stdin();
  let mut buf = String::new();
  stdin.read_line(&mut buf).unwrap();

  let mut iter = buf.trim().split_whitespace()
    .map(|x| x.parse::<i32>().unwrap());
  let a = iter.next().unwrap();
  let b = iter.next().unwrap();
  let c = iter.next().unwrap();

  let cnt = (a..(b+1)).filter(|x| c % x == 0).count();
  println!("{}", cnt);
}



Measured memory_bytes: 5028
#include <bits/stdc++.h>
using namespace std;
using graph = vector<vector<int>>;

class LCA {
	using pii = pair<int, int>;
	vector<int> depth, par, heavy, head, vid;
	int dfs(int v, int prev, const graph& G) {
		par[v] = prev;
		depth[v] = prev != -1 ? depth[prev] + 1 : 0;
		int ma = 0, cnt = 1;
		for (auto to : G[v]) if (to != prev) {
			int c = dfs(to, v, G);
			if (c > ma) {
				ma = c;
				heavy[v] = to;
			}
			cnt += c;
		}
		return cnt;
	}
public:
	LCA(const graph& G, int rt = 0)
		: depth(G.size()), par(G.size()), heavy(G.size(), -1), head(G.size()), vid(G.size()) {
		dfs(rt, -1, G);
		int id = 0;
		queue<int> q;
		q.push(rt);
		while (!q.empty()) {
			int h = q.front(); q.pop();
			for (int v = h; v != -1; v = heavy[v]) {
				vid[v] = id++;
				head[v] = h;
				for (auto to : G[v]) if (to != par[v] && to != heavy[v]) {
					q.push(to);
				}
			}
		}
	}
	int calc(int u, int v) {
		while (true) {
			if (vid[u] > vid[v]) swap(u, v);
			if (head[u] == head[v]) return u;
			v = par[head[v]];
		}
	}
	int dist(int a, int b) {
		return depth[a] + depth[b] - depth[calc(a, b)] * 2;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	cin >> n;
	graph G(n);
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int c;
			cin >> c;
			G[i].push_back(c);
			G[c].push_back(i);
		}
	}
	LCA lca(G);
	int q;
	cin >> q;
	while (q--) {
		int u, v;
		cin >> u >> v;
		printf("%d\n", lca.calc(u, v));
	}
	return 0;
}



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

void maxHeapify(int H[],int n,int i){//H[i]を根とするmax-heapにする
    int left=0,right=0;//初期化
    if(2*i<n+1)   left = H[2*i];
    if(2*i+1<n+1) right = H[2*i+1];
    //現在のkeyとleft,rightを比べる
    if(left > H[i] && left > right){//左の子がさいつよのとき.
        H[2*i] = H[i];
        H[i] = left;
        maxHeapify(H,n,2*i);
    }else if(right > H[i] && left < right){//右の子がさいつよのとき.
        H[2*i+1] = H[i];
        H[i] = right;
        maxHeapify(H,n,2*i+1);
    }
    //2*iとかがout of rangeしたとしても、その時は条件に引っかかることはないので大丈夫.
}
void buildMaxheap(int H[],int n){
    for(int i = n/2;i>0;i--){
        maxHeapify(H,n,i);
    }
}
void print(int H[],int n){
    for(int j=0;j<n;j++){
        cout<<" "<<H[j+1];
    }
    cout<<endl;
}

int main(){
    int n;cin>>n;
    int H[n+1];for(int i=0;i<n;i++)cin>>H[i+1];//インデックス0は欠番.
    buildMaxheap(H,n);
    print(H,n);
    return 0;
}


Measured memory_bytes: 4956
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll factorial[2010000];
ll invfactorial[2010000];

ll extGCD(ll a, ll b, ll &x, ll &y){
	if (b == 0){
		x = 1;
		y = 0;
		return a;
	}
 
	ll d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

ll nCrM(ll n, ll r){
	ll ret = factorial[n];
	ret *= invfactorial[n - r];
	ret %= MOD;
	ret *= invfactorial[r];
	ret %= MOD; 
	return ret;
}

ll nPrM(ll n, ll r){
    return factorial[n] * invfactorial[n - r] % MOD;
}
int main(void){

    factorial[0] = 1;

    for (int i = 1; i < 2010000; i++){
        factorial[i] = (factorial[i - 1] * i) % MOD;
    }
    for (int i = 0; i < 2010000; i++){
        ll x, y;
        ll g = extGCD(factorial[i], MOD, x, y);
        while (x < 0) x += MOD;
        x %= MOD;
        invfactorial[i] = x;
    }

    ll n, m;
    cin >> n >> m;

    ll ans = nPrM(m, n);
    for(ll i = 1; i <= n; i++){
        ll minus;
        if(i % 2 == 0){
            minus = 1;
        } else {
            minus = -1;
        }
        ans += minus * nCrM(n, i) * nPrM(m - i, n - i);
        ans %= MOD;
    }
    while(ans < 0) ans += MOD;
    ans %= MOD;
    cout << ans * nPrM(m, n) % MOD << endl;
}


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

int main() {
    long long n, k;
    cin >> n >> k;
    
    long long a;
    a = n % k;
    
    if (a <= abs(k-a)) cout << a;
    else cout << abs(k-a);

    return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N,K;
	cin>>N>>K;
	vector<int> H(N);
	rep(i,0,N)cin>>H[i];

	vector<int> DP(N,INF);
	DP[0]=0;

	rep(i,0,N-1)
	{
		rep(j,1,K+1)
		{
			int ni=i+j;
			if(ni>=N)continue;
			chmin(DP[ni],DP[i]+abs(H[ni]-H[i]));
		}
	}

	cout<<DP[N-1]<<endl;
	
	return 0;
}

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

int main() {
    int M, D;
    cin >> M >> D;
    int ans = 0;
    FOR(i, 1, M + 1) {
        rep(j, D + 1) {
            int one = j % 10;
            int ten = j/10;
            if (one >= 2 && ten >= 2) {
                if (one*ten == i) ans += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// atcoder/abc136/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }



int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, k;
  while (cin >> n >> k) {
    vector<lli> a(n);
    cin >> a;

    const lli sum = accumulate(a.begin(), a.end(), 0LL);
    vector<lli> v;
    for (lli i = 1; i * i <= sum; ++i) {
      if (sum % i == 0) {
        v.push_back(i);
        v.push_back(sum / i);
      }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    // cout << v << endl;

    auto fn = [&] (lli x) {
      vector<pair<lli, lli>> v;
      each (i, a) {
        v.push_back(make_pair(i % x, x - (i % x)));
      }
      // cout << x << ": " ;
      sort(v.begin(), v.end(), [] (auto i, auto j) { return i.second - i.first > j.second - j.first; });
      // cout << v << endl;
      lli p = 0;
      each (i, v) p += i.second;
      lli q = 0;
      each (i, v) {
        p -= i.second;
        q += i.first;
        // cout << p << ' ' << q << ' ' << (p == q) << ' ' << (p <= k) << endl;
        if (p == q && p <= k) return true;
      }
      return false;
    };

    lli x = -1;
    each (i, v) {
      if (fn(i)) x = i;
    }
    cout << x << endl;
    // cout << endl;
    // cout << k << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import numpy as np


def calc(n):
#     lim = int((n - 2) ** 0.5 - 1) + 1
    lim = 130

    result = np.zeros(n + 1, dtype=int)
    for x in range(1, lim):
        for y in range(x, lim):
            for z in range(y, lim):
                index = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if index > n:
                    continue
                s = set([x, y, z])
                if len(s) == 1:
                    result[index] += 1
                elif len(s) == 2:
                    result[index] += 3
                else:
                    result[index] += 6

    return result[1:]


for i in calc(int(input())):
    print(i)

Measured memory_bytes: 27268
#include <stdio.h>

#define N 100
#define TLE 10000

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int n, a, b, c, x, y[ N ];
    int res = 0;

    scanf ( "%d%d%d%d%d", &n, &a, &b, &c, &x );
    if ( !( n | a | b | c | x ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      scanf ( "%d", y + i );
    }

    for ( i = 0; i < n; ++i )
    {
      if ( i )
      {
        x = ( a * x + b ) % c;
        ++res;
      }
      for ( ; res <= TLE; ++res )
      {
        if ( x == y[ i ] ) break ;
        x = ( a * x + b ) % c;
      }
    }

    if ( res > TLE )
    {
      puts ( "-1" );
    }
    else
    {
      printf ( "%d\n", res );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
///supercalifragilisticexpialidocious.
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define PB pop_back
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef map<string, int> msi;
typedef pair<int, string> pis;
const int MAXN = 1e5 + 10;
int ans , n , m , x , y , cm[MAXN] , pos[MAXN] , p[MAXN] , q[MAXN];
int Find(int u)
{
    while(cm[u] != u)
        u = cm[u];
    return u;
}
void merg(int u , int v)
{
    u = Find(u) , v = Find(v);
    if(pos[u] > pos[v])
        cm[v] = u , pos[u] = max(pos[u] , pos[v] + 1);
    else
        cm[u] = v , pos[u] = max(pos[u] , pos[v] + 1);
    return;
}
int32_t main()
{
    cin >> n >> m;
    for(int i = 0 ; i < n ; i ++)
        cin >> p[i] , q[p[i]] = i + 1;
    for(int i = 1 ; i <= n ; i ++)
        cm[i] = i;
    for(int i = 0 ; i < m ; i ++)
        cin >> x >> y , merg(x , y);
    ans = 0;
    for(int i = 0 ; i < n ; i ++)
        if (i + 1 == p[i])
            ans ++;
        else
            if(Find(i + 1) == Find(q[i + 1]))
                ans ++;
    return cout << ans << endl , 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y,z;
    cin >> x >> y >>z;
    if(x<y&&y<z)printf("%s\n","Yes");
    //else if(x>y)printf("%s\n","a > b");
    else printf("%s\n","No");
    }


Measured memory_bytes: 3012
N = int(input())
P = [int(x) for x in input().split()]

PIdx = sorted([(i + 1, v) for i, v in enumerate(P)], key = lambda x: x[1])

L = [0]
for i in range(N + 1):
    L.append(i)

R = [i + 1 for i in range(N + 1)]
R.append(N + 1)

ans = 0
for i, v in PIdx:
    l1 = L[i]
    l2 = L[l1]
    r1 = R[i]
    r2 = R[r1]

    ans += v * ((i - l1) * (r2 - r1) + (l1 - l2) * (r1 - i))

    L[r1] = l1
    R[l1] = r1

print(ans)


Measured memory_bytes: 25788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,k; cin >> n >> k;
	ll ans=0;
	for(int i=0;i<=4;i++){
		for(int j=0;j<11;j++){
			int cnt=0;
			for(int x=j;x<j+3;x++){
				for(int y=i;y<i+3;y++){
					cnt+=7*(x+1)+(y+1)+4;
				}
			}
			if(cnt%11==k&&n>=j+3){
				ans+=(n-j-3)/11+1;
			}
		}
	}
	cout << ans << endl;
}

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

main()
{
    int n,a,b,c; cin>>n>>a>>b>>c;
    int v[3]={a,b,c};
    string ch="ABC";
    vector<pair<int,int>> ope(n);
    for(int i=0; i<n; ++i)
    {
        string s; cin>>s;
        ope[i]={s[0]-'A',s[1]-'A'};
    }
    string ans;
    stack<int> bac;

    for(auto i=ope.begin(); i!=ope.end(); ++i)
    {
        auto [x,y]=*i;

        if(v[x]>v[y])
        {
            ans+=ch[y];
            v[x]--;
            v[y]++;
        }
        else
        {
            if(v[x]==v[y] and v[x]==1 and next(i)!=end(ope))
            {
                auto ii=next(i);
                if(y==ii->first or y==ii->second)
                {
                    swap(x,y);
                }
            }
            if(!v[y])
            {
                cout << "No" << "\n";
                return 0;
            }
            v[x]++;
            v[y]--;
            ans+=ch[x];
        }
    }

    cout << "Yes" << "\n";
    for(char c: ans) cout << c << "\n";
}

Measured memory_bytes: 4300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int A, B; cin >> A >> B;
  cout << (A-1)*(B-1) << endl;
  return 0;
}


Measured memory_bytes: 256
import re

S = input()
result = [0] * len(S)
pattern = "R+L+"
str_list = re.findall(pattern, S)
currentIndex = 0
for s in str_list:
    numOfChar = len(s)
    numOfR = s.count('R')
    numOfL = numOfChar - numOfR
    if (numOfR % 2 == 0):
        R = L = numOfR // 2
    else:
        R = numOfR // 2 + 1
        L = numOfR // 2
    if (numOfL % 2 == 0):
        R += numOfL // 2
        L += numOfL // 2
    else:
        R += numOfL // 2
        L += numOfL // 2 + 1
    result[currentIndex + numOfR - 1] = R
    result[currentIndex + numOfR] = L
    currentIndex += numOfChar
print(' '.join(map(str, result)))


Measured memory_bytes: 13812
n = int(input())
a = list(map(int, input().split()))

import collections
c = collections.Counter(a)
unique = list(set(a))

from operator import xor
v = []
for k in c.keys():
    v.append(c[k])
v.sort()

flag = False
if n % 3 == 0:
    if len(v) == 1:
        if v == [n] and unique[0] == 0:
            flag = True
    elif len(v) == 2:
        if v == [n // 3, n // 3 * 2]:
            if c[unique[0]] == n // 3:
                if xor(unique[1], unique[0]) == unique[1] and xor(unique[1], unique[1]) == unique[0]:
                    flag = True
            else:
                if xor(unique[0], unique[1]) == unique[0] and xor(unique[0], unique[0]) == unique[1]:
                    flag = True
    elif len(v) == 3:
        if v == [n // 3, n // 3, n // 3]:
            if xor(unique[0], unique[1]) == unique[2] and xor(unique[1], unique[2]) == unique[0] and xor(unique[2], unique[0]) == unique[1]:
                flag = True
else:
    if v == [n]:
        flag = True

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


Measured memory_bytes: 14228
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	map<lint, lint> m;

	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		m[tmp]++;
	}
	lint ans = 0;
	for (auto out : m)
	{
		if (out.first == out.second)
			continue;

		if (out.first < out.second)
		{
			ans += (out.second - out.first);
		}
		else
		{
			ans += out.second;
		}
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> a(h);
  for(int i=0; i<h; i++) cin>>a[i];
  vector<bool> r(h, false);
  vector<bool> c(w, false);
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(a[i][j] == '#') {
        r[i] = true;
        c[j] = true;
      }
    }
  }
  for(int i=0; i<h; i++){
    if(r[i]) {
      for(int j=0; j<w; j++){
        if(c[j]) cout<<a[i][j];
      }
      cout<<endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;

int main()
{
    ll n;
    cin >> n;
    ll a[n];
    ll max_height = 0;
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        chmax(max_height, a[i]);
        ans += max_height - a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 111;

int x, n;
bool c[N];

void solv()
{
    scanf("%d%d", &x, &n);
    while (n--)
    {
        int y;
        scanf("%d", &y);
        c[y] = true;
    }
    int miny, minu = N * N;
    for (int y = 0; y < N; ++y)
    {
        if (c[y])
            continue;
        if (abs(x - y) < minu)
        {
            minu = abs(x - y);
            miny = y;
        }
    }
    printf("%d\n", miny);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false), cin.tie(0);
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 3792
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

const int MAXN = 1000;

int a[MAXN];
int num[MAXN];

int main () {
//  ios_base::sync_with_stdio(0);
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);

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

	int d = 0;
	for (int i = 0; i < n; ++i) {
		d = max(d, a[i]);
   	}

   	bool key = true;
   	for (int i = 0; i < n; ++i) {
   		if (a[i] < (d + 1) / 2) {
   			key = false;
   			break;
   		}
   		num[a[i]]++;
    }

    if (d % 2 == 0 && num[d / 2] != 1) {
    	key = false;
    }

    if (d % 2 == 1 && num[(d + 1) / 2] != 2) {
    	key = false;
    }

    if (key) {
    	for (int r = (d + 1) / 2 + 1; r <= d; ++r) {
    		if (num[r] < 2) {
    			key = false;
    			break;
    		}
    	}
   	}

   	cout << (key ? "Possible" : "Impossible") << endl;


	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

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

using namespace std;
//    cout << setprecision(20) << ans << "\n";



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

    string s;
    cin >> s;

    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R'){
        cout << 3 << "\n";
        return 0;
    }
    if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')){
        cout << 2 << "\n";
        return 0;
    }
    if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R'){
        cout << 1 << "\n";
        return 0;
    }
    cout << 0 << "\n";
    return 0;
}


Measured memory_bytes: 3648
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


FROM = "Hoshino"
TO = "Hoshina"

P_length = 7

num_case = int(input())

for _ in range(num_case):
    print("%s"%(input().replace(FROM, TO))) #Python3では文字列がイミュータブル


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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 301, inf = 1e9 * 2;

const ll MOD = 1e9 + 7ll, INF = 1e18;

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

int n;

double dp[N][N][N];

bool was[N][N][N];

double calc(int x, int y, int z) {
	double sum = 1.0 * (x + y + z);
	if (!sum) return 0;
	if (was[x][y][z]) return dp[x][y][z];
	was[x][y][z] = 1;
	double &now = dp[x][y][z];
	now = (double) n / sum;
	if (x) now += (double)x * calc(x - 1, y, z) / sum;
	if (y) now += (double)y * calc(x + 1, y - 1, z) / sum;
	if (z) now += (double)z * calc(x, y + 1, z - 1) / sum;
	return now;
}

int main() {
	FREOPEN();
	cin >> n;
	vector<int> cnt(4, 0);
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
	printf("%.9lf", calc(cnt[1], cnt[2], cnt[3]));
	return 0;
}


Measured memory_bytes: 239872
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double PI = acos(-1.0), EPS = 1e-10;

typedef complex<double> P;

double CROSS(const P& a, const P& b) {
	return imag(conj(a) * b);
}

int CCW(const P& a, const P& b) {
	if(CROSS(a, b) > EPS) return 1;
	if(CROSS(a, b) < -EPS) return -1;
	return 0;
}

int main() {
	vector<P> v(4);
	for(string line; getline(cin, line);) {
		rep(i,line.length()) if(line[i] == ',') line[i] = ' ';
		istringstream is(line);
		for(int i = 0; i < 4; i++) {
			is >> v[i].real() >> v[i].imag();
		}

		int ccw[4];
		
		for(int i = 0; i < 4; i++) {
			int cur = i % 4;
			int nc = (i + 1) % 4;
			int nnc = (i + 2) % 4;
			ccw[i] = CCW(v[nc] - v[cur], v[nnc] - v[nc]);
		}
		
#if 0
		debug(v[0]);
		debug(v[1]);
		debug(v[2]);
		debug(v[3]);
#endif

#if 0
		debug(ccw[0]);
		debug(ccw[1]);
		debug(ccw[2]);
		debug(ccw[3]);
#endif
		
		bool f = true;
		for(int i = 0; i < 4; i++) {
			if(ccw[i] != ccw[(i+1)%4]) f = false;
		}
		
		cout << (f ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 0
N=int(input())
c = input()

idxl=-1
idxr=N
cnt=0
# 単独ははじく

while(1):
  while(1):
    idxl=idxl+1
    if(idxl >= N):
      break
    if(c[idxl]=="W"):
      break
  if(idxl >= N):
    break
  while(1):
    idxr=idxr-1
    if(idxr <= 0):
      break
    if(c[idxr]=="R"):
      break
  if(idxr <= 0):
    break
#  print(idxl)
#  print(idxr)
  if(idxl>=idxr):
    break;
  cnt = cnt+1
print(cnt)

Measured memory_bytes: 67752
#include<iostream>
using namespace std;
int a[52][52];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			char c;
			cin>>c;
			if(c=='#')a[i][j]=1;
		}
	bool f=true;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(a[i][j]==1&&a[i-1][j]==0&&a[i][j+1]==0&&a[i+1][j]==0&&a[i][j-1]==0){
				f=false;
				break;
			}
		}
		if(!f)break;
	}
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import collections

def main():
    n,m=map(int,input().split())
    g = [[] for _ in range(n+1)]
    for _ in range(m):
         a,b=map(int,input().split())
         g[a].append(b)
         g[b].append(a)
    q = collections.deque()
    q.append(1)
    #道しるべ
    check=[0]*(n+1)
    check[1]=1
    ans=[0]*(n+1)
    while len(q)!=0:
        v=q.popleft()#リストの左から値を抜く
        for u in g[v]:
            if check[u] == 0:
                check[u] = 1
                ans[u] = v
                q.append(u)

    for i in range(2,n+1):
        if ans[i] == 0:
            print('No')
            return

    print('Yes')
    for i in range(2,n+1):
        print(ans[i])

main()


Measured memory_bytes: 34972
#include<stdio.h>
int main(){
  int i=0,j=0;
  int N=0;
  int A[1000];
  int count=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  count=bbsort(A,N);
  if(N>1){
    for(i=0;i<N;i++){
      if(i<N-1){
	printf("%d ",A[i]);
      }
      if(i==N-1){
	printf("%d",A[i]);
      }
    }
    printf("\n");
    printf("%d\n",count);
  }
  else {
    for(i=0;i<N;i++){
      printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",count);
  }
  return 0;
}
int bbsort(int A[],int N){
  int i=0,j=0;
  int temp=0;
  int count=0;
  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	count++;
      }
    }
  }
  return count;
}



Measured memory_bytes: 2072
def main():
    nk = list(map(int, input().split()))
    s = [0]*nk[0]
    for i in range(nk[1]):
        d = int(input())
        a = list(map(int, input().split()))
        for j in a:
            s[j-1] += 1
    print(s.count(0))

if __name__ == '__main__':
    main()

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;

    int x=100*A,y=0;
    rep(i,0,40) rep(j,0,40) rep(k,0,inf){
        if(C*k>(A*i+B*j)*E) break;
        if(100*A*i+100*B*j+C*k>F) break;
        int l=max(0,min((F-(100*A*i+100*B*j+C*k))/D,((A*i+B*j)*E-C*k)/D));
        int x_=100*A*i+100*B*j+C*k+D*l,y_=C*k+D*l;
        if(y*x_<x*y_){
            x=x_;
            y=y_;
        }
    }

    cout << x << " " << y << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! debug {
  ($($e:expr), *) => {println!(concat!($(stringify!($e), " = {:?}\n"), *), $($e), *)}
}

fn main() {
  let (n, k) = get::tuple::<usize,usize>();
  let xs = get::list::<isize>();
  
  let mut init = 0;
  let mut mid = xs[..k].iter().sum::<isize>();
  let mut tail = xs[k..].iter().filter(|&&x|x.is_positive()).sum::<isize>();
  let mut ans = std::cmp::max(0, mid) + tail;
  for i in 0 .. n-k {
    init += std::cmp::max(0, xs[i]);
    mid = mid - xs[i] + xs[i+k];
    tail -= std::cmp::max(0, xs[i+k]);
    ans = std::cmp::max(ans, init + std::cmp::max(0, mid) + tail)
  }
  
  println!("{}", ans);
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}



Measured memory_bytes: 8444
score = {"taro":0, "hanako":0}
n = int(input())

for i in range(n):
    words = input().split()

    if words[0] > words[1]:
        score["taro"] += 3
    elif words[0] < words[1]:
        score["hanako"] += 3
    else:
        score["taro"] += 1
        score["hanako"] += 1

print(score["taro"], score["hanako"])

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

using namespace std;

int main()
{
    long long int n,s=0,i=-1;
    char mem;
    string str,tmp;
    cin>>n>>str;
    mem = str[0];
    ++i;
    ++s;
    while(str[++i]!='\0'){

        if(mem!=str[i]){

            ++s;
            mem=str[i];

        }
    }
    cout<<s<<endl;

    return 0;

}


Measured memory_bytes: 512