akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, K, S; cin >> N >> K >> S;
  REP(i, K) cout << S << ' ';
  REP(i, N-K){
    if(S == 1e9) cout << S-1 << ' ';
    else cout << S+1 << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <numeric>
#include <unordered_map>

using namespace std;
using ll = long long;

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

    string S;
    cin >> S;

    ll white_count = 0;
    ll black_count = 0;

    for (int i = 0; i < N; ++i) {
        if (S[i] == '#') {
            ++black_count;
        } else {
            ++white_count;
        }
    }

    ll bl = 0;
    ll wr = white_count;
    ll ans = bl + wr;

    for (int i = 0; i < N; ++i) {
        if (S[i] == '#') {
            ++bl;
        } else {
            --wr;
        }

        ans = min(ans, bl + wr);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
n = int(input())
a = tuple(map(int, input().split()))

# (a^b)+(a&b)*2==(a+b)

ans = 0

t = 0
l = 0
# [l,r]
for r, x in enumerate(a):
    while t & x != 0:
        # まだ、xを足していないので、t = sum([l,r))
        t -= a[l]
        l += 1
        if l == r:
            break
    ans += r - l + 1
    t += x
print(ans)


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

int N;
pair<int, int> points[8];

double dist(pair<int, int> x, pair<int, int> y){
    double ret = 0;
    double dx2 = (x.first - y.first) * (x.first - y.first);
    double dy2 = (x.second - y.second) * (x.second - y.second);
    ret = sqrt(dx2 + dy2);
    return ret;
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> points[i].first >> points[i].second;
    }

    double ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            ans += dist(points[i], points[j]) * 2 / N;
        }
    }
    cout << setprecision(20);
    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

'''
戦略
すべてのパターンをfor文で回す
'''

A, B, C, D, E, F = map(int, input().split())

V = []
max_water = 0
max_sato = 0
max_ratio = -1

maxA = F//(100*A)
maxB = F//(100*B)

waters = set()

for i in range(0, maxA+1):
    for j in range(0, maxB+1):
        water = 100*A*i + 100*B*j
        waters.add(water)

maxC = F // C
maxD = F // D
satos = set()
for k in range(0, maxC+1):
    for l in range(0, maxD+1):
        sato = C*k + D*l
        satos.add(sato)

for water in waters:
    for sato in satos:
        if water+sato > F or water+sato == 0:
            continue
        if sato > water/100 * E:
            continue
        #print(water, sato)
        ratio = sato/(water+sato)*100
        if ratio > max_ratio:
            max_water = water+sato
            max_sato = sato
            max_ratio = ratio
print(max_water, max_sato)


Measured memory_bytes: 3828
h, w = map(int, input().split())
arr = []
for i in range(h):
    arr.append(input())
dp = [[0] * w for i in range(h)]
dp[0][0] = 1
for r in range(h):
    for c in range(w):
        if arr[r][c] == '.':
            if r > 0:
                dp[r][c] += dp[r - 1][c] if arr[r - 1][c] == '.' else 0
            if c > 0:
                dp[r][c] += dp[r][c - 1] if arr[r][c - 1] == '.' else 0
print(dp[h - 1][w - 1] % 1000000007)

Measured memory_bytes: 157428
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
// static const int max_n = 110;
// static const llong max_cost = 2000000000000000;
// // vector<vector<llong>> matrix(max_n, vector<llong>(max_n, 0));
// // vector<vector<llong>> adj_matrix(max_n, vector<llong>(max_n, max_cost));
// vector<vector<pair<llong, int>>> adj_list(max_n);
// vector<llong> distance_table(max_n, max_cost);
// set<pair<llong, int>> points_sort_x;
// set<pair<llong, int>> points_sort_y;

// int N;



int main(){
    // int u, v;
    // bool updated = false;
    ll N, M;
    scanf("%lld", &N);

    double ans = ((double)N * 2.) * acos(-1);


    printf("%lf\n", ans);

    return 0;

}

Measured memory_bytes: 3228
def main():
    n, k = map(int, input().split(' '))
    result = 0
    for i in range(1, n+1):
        p = n//i
        result += p*max(0,i-k)
        result += max(0, n%i-k+1)
        if k == 0:
            result -= 1
    print(result)
main()

Measured memory_bytes: 2940
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() { 
  ll n;
  cin>>n;
  
  ll num=0,ans=1e15;
  for(int i=1;i<=sqrt(n);i++){
      if(n%i==0){
          num=(i-1)+(n/i-1);
          //cout<<num<<endl;
      }
      ans=min(num,ans);
  }
  cout<<ans<<endl;
}



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

#define ll long long

using namespace std;
 
void solve() {
    int n, w_max;
    cin >> n >> w_max;

    vector<ll> v(n), w(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
    }

    // dp[i][k] -> menor peso possível utilizando até o item i atigindo valor
    //             maior ou igual a k
    vector<vector<ll>> dp(n, vector<ll>(100013, -1ll));

    function<ll(int, int)> calc_dp = [&] (int i, int k) {
        if (i < 0 || k < 0) {
            if (k <= 0)
                return 0ll;
            else
                return 1000000123ll;
        }
        if (dp[i][k] != -1)
            return dp[i][k];

        dp[i][k] = min(w[i] + calc_dp(i-1, k - v[i]), calc_dp(i-1, k));

        return dp[i][k];
    };

    ll ans = 0ll;
    for (int i = 0; i < 100013; ++i) {
        int w = calc_dp(n-1, i);
        if (w <= w_max) 
            ans = i;
    }
    
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 82332
#include <bits/stdc++.h>
#define ff(i, x, y) for(int i = x;i <= y;i++)
#define fs(i, x, y) for(int i = x;i >= y;i--)
#define maxn 100010
using namespace std;
typedef long long ll;
int m1, d1, m2, d2;
int main() {
    scanf("%d%d%d%d", &m1, &d1, &m2, &d2);
    if(m1 != m2)
        printf("1");
    else
        printf("0");
    return  0;
}


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

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = b - a + 1;
    ll cd = lcm(c, d);
    ll cnt = b / c + b / d - ((a - 1) / c + (a - 1) / d) - (b / cd - (a - 1) / cd);
    cout << ans - cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3612
from collections import deque
S = input()
d = deque(S)
Q = int(input())
rev = False
for _ in range(Q):
    Q, *sub = input().split()
    if Q == "1":
        rev = not rev
    else:
        F, C = sub
        if F == "1":
            if rev:
                d.append(C)
            else:
                d.appendleft(C)
        else:
            if rev:
                d.appendleft(C)
            else:
                d.append(C)
if rev:
    d.reverse()
print("".join(list(d)))


Measured memory_bytes: 8564
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

tri = [1]
for i in range(2,30):
    tri.append(tri[-1]+i)
n = int(input())
a = factorize(n)
ans = 0
for num,v in a:
    for k,i in enumerate(tri):
        if i > v:
            ans += k
            break
print(ans)


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

int main(){
	long int a, b, k;
  	cin>>a>>b>>k;
	
  	if(a>=k){
    	a-=k;
    } else {
      if(b>=k-a){
      	b-=k-a;
      } else {
      	b=0;
      }
      a=0;
    }
  	cout<<a<<" "<<b<<endl;;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
typedef long long ll;
#define repran(i, a,b) for (int i = a; i<b;i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using LP = pair<ll,ll>;
using P = pair<int,ll>;
int n;
ll inf = 1e18;

int main()
{
    int n ,q;
    cin >> n >> q;
    vector<vector<int>> G(n, vector<int>());
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> ans(n, 0);
    vector<ll> acc(n, 0);
    rep(i, q){
        int p; ll x;
        cin >> p >>x;
        --p;
        acc[p] += x;
    }
    //dfs
    deque<P> deq;
    deq.emplace_back(0, acc[0]);
    ans[0] = acc[0];
    vector<int> parent(n, -1);
    while(!deq.empty()){
        P now = deq.back();deq.pop_back();
        int node = now.first;
        ll cost = now.second;
        for (int child : G[node]){
            if(child == parent[node]) continue;
            parent[child] = node;
            ans[child] = ans[node]+acc[child];
            deq.emplace_back(child, acc[child]);
        }

    }
    rep(i, n) cout << ans[i] << endl;

}

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

int main() {
  int N;
  cin >> N;
  vector<char> c(N);
  int R = 0;
  for (int i = 0; i < N; i++) {
    cin >> c.at(i);
    if (c.at(i) == 'R') {
      R++;
    }
  }
  int W = 0;
  for (int i = 0; i < R; i++) { 
    if (c.at(i) == 'W') {
      W++;
    }
  }
  cout << W << endl;
}

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

// https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/1/GRL_1_B

using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);++i)
constexpr long long INF = (1LL<<60);
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
using edge = struct edge{ll from,to,cost;edge(ll from,ll to,ll cost):from(from),to(to),cost(cost){}};
using weighted_edge = vector<edge>;

auto Bellman_Ford(weighted_edge& edges,ll n,ll s,ll k=1){
  vector<ll> dist(n,INF);
  dist[s]=0LL;
  rep(i,n*k){
    for(const auto& e:edges){
      if(dist[e.from]==INF)continue;
      chmin(dist[e.to],dist[e.from]+e.cost);
    }
  }
  bool negative_cycle=false;
  rep(i,n*k){
    for(const auto& e:edges){
      if(dist[e.from]==INF)continue;
      if( chmin(dist[e.to],dist[e.from]+e.cost) ){
        negative_cycle=true;
      }
    }
  }
  return make_pair(dist,negative_cycle);
}

void solve(){

  ll v,e,r;
  cin>>v>>e>>r;
  weighted_edge edges;
  rep(i,e){
    ll u,v,w;
    cin>>u>>v>>w;
    edges.emplace_back(u,v,w);
  }
  bool negative_cycle;
  vector<ll> dist;
  tie(dist,negative_cycle) = Bellman_Ford(edges,v,r,2);

  if(negative_cycle)puts("NEGATIVE CYCLE");
  else{
    for(auto d:dist){
      if(d==INF)puts("INF");
      else cout<<d<<endl;
    }
  }

}

main(){
  solve();
}


Measured memory_bytes: 3220
S = list(input())
s_A = [s for s in S if 'A' in s]
s_B = [s for s in S if 'B' in s]

if len(s_A) == 3 or len(s_B) == 3:
    ans = 'No'
else:
    ans = 'Yes'

print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {	 
		Scanner in = new Scanner(System.in);
		int a = in.nextInt(), b = in.nextInt();
		if (a + b == 15) System.out.println("+");
		else if (a * b == 15) System.out.println("*");
		else System.out.println("x");
	}
}	
	


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc061_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            String[] strs = str.Split(' ');
            int[] input = new int[3];
            for(int i=0;i<strs.Length; ++i)
            {
                input[i] = Convert.ToInt32(strs[i]);
            }
            if (input[2]>= input[0] && input[1] >= input[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.Read();
        }
        }
    }





Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int num = stdin.nextInt();
		int day = stdin.nextInt() - 1;
		int sum = num + stdin.nextInt();

		for (int i = 0; i < num; i++) {
			sum += day / stdin.nextInt();
		}

		System.out.println(sum);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#define _USE_MATH_DEFINES
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
#include <cstdlib>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}

#define maxn 3005
ll n, s, a[maxn] = {0}, M = 998244353, dp[maxn][maxn];

void add(ll &a, ll b){
    a+=b;
    if (a>=M) a-=M;
}

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin>>n>>s;
    for (int i = 1; i <= n; ++i){
        cin>>a[i];
    }

    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i){
        for (int j = 0; j <= s; ++j){
            if (a[i]<=j){
                add(dp[i][j],dp[i-1][j-a[i]]);
            }
            add(dp[i][j],(dp[i-1][j]*2)%M);
        }
    }
    cout<<dp[n][s]<<"\n";
    return 0;
}


Measured memory_bytes: 73600
x, n = map(int, input().split())
p = list(map(int, input().split()))
ll = [i for i in range(300)]

if x not in p:
    print(x)
else:
    for num in p:
        ll.remove(num)
    l2 = []
    ans = float('inf')
    for i in ll:
        if abs(i-x) < abs(x-ans):
            ans = i
        if abs(i-x) == abs(ans-x):
            ans = min(i, ans)

    print(ans)


Measured memory_bytes: 9200
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {

  long yen;
    cin >> yen;
     long  g = 0;
    long state = 0;
    for( long  i = 500; i <= yen; i += 500 ){
       state ++;
        g += 1000;
    }
    yen -= state*500;
    for(  long i = 5; i <= yen; i += 5 ){
        g += 5;
    }




    cout << g;
    return 0;
}


Measured memory_bytes: 256
import copy
while True :
    card = list(input())
    if card[0] == "-" :
        break
    
    new_card = [''] * (len(card))
    m = int(input())
    for i in range(m) :
        h = int(input())
        for c in range(len(card)) :
            if c < len(card) - h :
                new_card[c] = card[h + c]
            else :
                new_card[c] = card[c + h - len(card)]
        card = copy.copy(new_card)
    for i in range(len(card)) :
        print(card[i], sep="", end="")
    print()


Measured memory_bytes: 6336
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //cin>>t;
    t=1;
    while(t--){
        ll x,y;
        ll a,b,c;
        cin>>x>>y>>a>>b>>c;
        vector<ll>p,q,r;
        fo(i,a){
            cin>>k;
            p.pb(k);
        }
        p.pb(0);
        fo(i,b){
            cin>>k;
            q.pb(k);
        }
        q.pb(0);
        fo(i,c){
            cin>>k;
            r.pb(k);
        }
        r.pb(0);
        sort(all(p));
        sort(all(q));
        sort(all(r));
        ll t1=a,t2=b,t3=c;
        ll red=0,gr=0,col=0;
        ll sumr=0,sumg=0,sumcol=0;
        while(red+gr+col<x+y){
            if(red==x){
                if(q[t2]>r[t3]){
                    sumg+=q[t2];
                    t2--;
                    gr++;
                }
                else{
                    //cout<<r[t3];
                    sumcol+=r[t3];
                    t3--;
                    col++;
                }
            }
            else if(gr==y){
                if(p[t1]>r[t3]){
                    sumr+=p[t1];
                    t1--;
                    red++;
                }
                else{
                    sumcol+=r[t3];
                    t3--;
                    col++;
                }
            }
            else{
                //cout<<"ff";
                if(p[t1]>r[t3] && p[t1]>=q[t2]){
                    //cout<<"ff1";
                    sumr+=p[t1];
                    t1--;
                    red++;
                }
                else if(q[t2]>r[t3] && q[t2]>=p[t1]){
                    //cout<<"ff2";
                    sumg+=q[t2];
                    t2--;
                    gr++;
                }
                else{
                    //cout<<"ff3";
                    //cout<<r[t3];
                    sumcol+=r[t3];
                    t3--;
                    col++;
                }


            }
        }
        cout<<sumr+sumg+sumcol;
    }

    return 0;
}


Measured memory_bytes: 3316
NK=input().split()
N=int(NK[0])
K=int(NK[1])
D=input().split()

while (True):
    flag=0
    for i in range(K):
        if(D[i] in str(N)):
            flag=1
    if(flag==0):
        print(N)
        break
    else:
        N+=1



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int main(){
    IOS;
    in n,g,ans = 99999999;
    cin >> n >> g;
    vector<in> p(n),c(n);
    rep(i,0,n){
        cin >> p[i] >> c[i];
    }
    set<in> s;
    rep(i,0,1<<n){
        s.clear();
        in res = 0, cur = 0; 
        rep(j,0,n){
            if(1<<j & i){
                s.insert(j);
                cur+=c[j];
                cur+=(1+j)*100*p[j];
                res+=p[j];
            }
        }
        if(cur < g){
            for(in j = n-1;j>=0;j--){
                if(cur >= g) break;
                if(!s.count(j)){
                    rep(l,0,p[j]){
                        cur+=(j+1)*100;
                        res++;
                        if(cur >= g) break;
                    }
                }
            }
        }
        if(cur>=g) ans = min(ans, res);
    }
    cout << ans << "\n";
}

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

void solve()
{
	int n,m;
	cin>>n>>m;
	int a[n];
	int cn = 0;
	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		cin>>a[i];
		sum += a[i];
	}
	double b = sum/(double)(4*m);
	for (int i = 0; i < n; ++i)
	{
		/* code */
		if(a[i]>=b)
			cn++;
	}
	if(cn>=m)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cmath>
#include <algorithm>

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

using namespace std;

int n;
double x[22];
double y[22];
double d[22][22];

bool dfs(int k, int x, double c){
	if(x == (1 << n) - 1){
		return true;
	}
	rep(i, n){
		if(
			!(x & (1 << i)) &&
			c + d[k][i] >= d[i][n + 1]
		){
			return false;
		}
	}
	rep(i, n){
		if(
			!(x & (1 << i)) &&
			dfs(i, x | (1 << i), c + d[k][i])
		){
			return true;
		}
	}
	return false;
}

int main(){
	while(1){
		scanf("%d", &n);
		if(n == 0){
			break;
		}
		scanf("%lf%lf%lf%lf", x + n, y + n,  x + n + 1, y + n + 1);
		rep(i, n){
			scanf("%lf%lf", x + i, y + i);
		}
		rep(i, n + 2){
			rep(j, n + 2){
				double dx = x[i] - x[j];
				double dy = y[i] - y[j];
				d[i][j] = sqrt(dx * dx + dy * dy);
			}
		}
		printf("%s\n", dfs(n, 0, 0) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 1052
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  ll sum = 0;
  rep(i, n) {
    cin >> w[i];
    sum += w[i];
  }
  
  ll ta = 0;
  ll ans = 1000000;
  for (int i = 0; i < n; ++i) {
    ta += w[i];
    sum -= w[i];
    chmin(ans, abs(ta - sum));
  }

  cout << ans << endl;
}


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 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 n;
  cin>>n;
  int count=0;
  int fg=0;
  rep(i,n){
    int d1,d2;
    cin>>d1>>d2;
    if(d1==d2){
      count++;
    }
    else{
      count=0;
    }
    if(count==3){
      fg=1;
    }
  }
  if(fg==1){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;
bool check(string s)
{
  int l=s.length();
  int f=1;
  rep(i,l/2)
  {
    if(s[i]!=s[i+l/2])f=0;

  }
  return f;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int l=s.length();
  rep(i,l/2)
  {
    string ts;
    if(check(ts=s.substr(0,l-2-i*2)))
    {
      cout<<l-2-i*2<<endl;
      return 0;
    }
  }
  return 0;

}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

// 1-indexed
template<typename T>
class BIT{
private:
    vector<T> arr;
    const int n;
public:
    BIT(int _n): arr(_n+1,0),n(_n){}

    T sum(int i) {
        T s = 0;
        while(i > 0) {
            s += arr[i];
            i -= i & -i; // LSB 減算
        }
        return s;
    }

    T sum(int i,int j) {
        auto ri = sum(i-1);
        auto rj = sum(j);
        return rj-ri;
    }
    // 要素の加減算
    void add(int i,T x) {
        while(i <= n) {
            arr[i] += x;
            i += i & -i;
        }
    }

    void print() {
        for(const auto &it: arr) {
            cerr << it << endl;
        }
    }
};

void solve() {
    int N,Q;
    cin >> N >> Q;


    vector<int> v(N);
    REP(i,N) cin >> v[i];

    BIT<int> b(N);
    // r,l,id
    vector<tuple<int,int,int>> vt(Q);
    REP(i,Q) {
        int l,r;
        cin >> l >> r;
        vt[i] = make_tuple(r,l,i);
    }

    sort(ALL(vt));
    vector<int> ans(Q);
    // ballの種類とその場所(v依存、0-indexed)
    map<int,int> m;
    int state = 0; // 最後に作成した場所
    for(const auto tp : vt) {
        auto [r,l,id] = tp;
        FOR(i,state+1,r+1) {
            int val = v[i-1];
            if(m.count(val)) {
                b.add(m[val]+1,-1);
            }
            m[val] = i-1;
            // update
            b.add(i,1);
        }
        state = r;
        ans[id] = b.sum(l,r);
    }

    for(const auto &a: ans) cout << a << endl;



}

int main() {
    solve();
    return 0;
}

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

int main(void){
  char S[10];
  scanf("%s",S);

  int cnt = 0;
  int ans = 0;
  for(int i = 0;i < strlen(S);i++){
    if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
      cnt++;
    }else{
      if(ans < cnt){
        ans = cnt;
      }
      cnt = 0;
    }
  }
  if(ans < cnt){
    ans = cnt;
  }

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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 (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    double D;cin >> D;
    vector<double> X(N);
    vector<double> Y(N);
    rep(i,N){
        cin >> X[i] >> Y[i];
    }

    int ct = 0;
    rep(i,N){
        double t1,t2;
        t1 = X[i]*X[i];
        t2 = Y[i]*Y[i];
        double t = sqrt(t1 + t2);
        if(t <= D)ct++;
    }

    cout << ct << endl;

}

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

typedef long long ll;

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

    int N, M;
    cin >> N >> M;

    int ans = 1;

    for(int i = 1; i * i <= M; i++) {

        if(M % i == 0) {
            int x = M / i;

            if(x >= N) {
                ans = max(ans, i);
            }
            if(i >= N) {
                ans = max(ans, x);
            }
        }

    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,c,k,i;
    scanf("%d",&k);
    for(i=0;i<k;i++){
        scanf("%d %d %d",&a,&b,&c);
        if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==b*b+a*a)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 580
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] n = new int[N+1];

		for (int i = 1; i <= M; i++) {
			int x = sc.nextInt();
			n[x] = 1;
		}
		int cnt = 1;
		long ans = 1;
		for (int i=1;i<=N;i++) {
			if(n[i]!=1) {
				cnt++;
			} else {
				ans = mod(ans * mod(solve(cnt)));
				cnt =0;
			}
		}
		ans = mod(ans * mod(solve(cnt)));
		System.out.println(ans);
	}

	public static long solve(int N) {
		if (N==0) return 0;
		if (N==1||N==2)	return 1;
		long num1 = 1;
		long num2 = 1;
		long tmp = 1;
		for (int i = 1; i < N-1; i++) {
			tmp = mod(num1 + num2);
			num1 = mod(num2);
			num2 = mod(tmp);
		}
		return tmp;

	}

	public static long mod(long N) {

		return (long) N % 1000000007;

	}

}


Measured memory_bytes: 49280
#include<iostream>
#include<stdio.h>
#include<ext/rope>
using namespace std;
struct Q{
   int a,b,c;
}A[100010];
int cmp(Q a,Q b){
   return a.c<b.c;
}
int main(){
    int i,n;
    cin>>n;
    for(i=1;i<=n;i++) cin>>A[i].a>>A[i].b,A[i].c=A[i].a+A[i].b;
    sort(A+1,A+1+n,cmp);
    long long ans=0;
    A[0].b=0;
    for(i=n;i>=1;i-=2) ans+=A[i].a-A[i-1].b;
    //for(i=n/2+1;i<=n;i++) ans+=A[i].a;
    cout<<ans<<endl;
    return 0;


}



Measured memory_bytes: 1408
package main

import "fmt"

func main() {
	// Code for A - Accepted...?
	var S string
	fmt.Scanf("%s", &S)

	var count int
	for i := 0; i < 6; i++ {
		if S[i] == '1' {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 1836
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
B = []
for i in range(1, N):
    len = A[i] - A[i - 1]
    B.append(len)
len = A[0] + K - A[N - 1]
B.append(len)
print(K - max(B))

Measured memory_bytes: 26060
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int n = in();
  vvector<int> nums(3,vector<int>(n));
  foreach(i,nums){
    foreach(j,i)j=in();
    sort(all(i));
  }
  vvector<ll> dp(3,vector<ll>(n,0));
  foreach(i,dp[0])i=1;
  rep(i,2){
    int lp = 0;
    rep(j,n){
      while(lp<n and nums[i][j] >= nums[i+1][lp])++lp;
      if(lp < n)dp[i+1][lp] += dp[i][j];
    }
    rep(j,n-1)dp[i+1][j+1]+=dp[i+1][j];
  }
  ll ans = 0;
  rep(i,n){
    ans += dp[2][i];
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        mp[x]++;
    }

    vector<vector<int>> g(m);
    vector<int> cnt(m);
    for (auto x: mp) {
        g.at(x.first % m).push_back(x.second);
        cnt.at(x.first % m) += x.second;
    }

    int ans = 0;
    for (int i = 0; i <= m / 2; i++) {
        if (i == 0 || (i == m - i)) ans += cnt.at(i) / 2;
        else {
            vector<int> *s;
            int cnt_s, cnt_t;
            if (cnt.at(i) > cnt.at(m - i)) {
                s = &g.at(i);
                cnt_s = cnt.at(i);
                cnt_t = cnt.at(m - i);
            }
            else {
                s = &g.at(m - i);
                cnt_s = cnt.at(m - i);
                cnt_t = cnt.at(i);
            }
            
            for (int j = 0; j < (int)s -> size(); j++) {
                if (cnt_s > cnt_t) {
                    int c = min(s -> at(j) / 2, (cnt_s - cnt_t) / 2);
                    ans += c;
                    cnt_s -= c * 2;
                }
            }
            ans += cnt_t;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 10752
#include <cstdio>
#include <cstdlib>

void movex(int **a, int i,int w){
    for(int j=1;j<w;j++){
        if(a[i][j]){
            a[i][j+1]=(a[i][j+1]+1)%2;
            printf("%d %d %d %d\n",i,j,i,j+1);
        }
    }
    return;
}

void movey(int **a, int h, int j){
    for(int i=1;i<h;i++){
        if(a[i][j]){
            a[i+1][j]=(a[i+1][j]+1)%2;
            printf("%d %d %d %d\n",i,j,i+1,j);
        }
    }
    return;
}

int count(int **a, int h, int w){
    int i,j,c,tmp,total;
    c = 0;
    int *b = (int *)malloc(sizeof(int)*h+1);
    for(i=1;i<h+1;i++){
        tmp = 0;
        for(j=1;j<w;j++){
            tmp = (a[i][j]+tmp)%2;
            if(tmp){
                c++;
            }
        }
        b[i] = (a[i][w]+tmp)%2;
    }
    tmp = 0;
    for(i=1;i<h;i++){
        tmp = (b[i]+tmp)%2;
        if(tmp){
            c++;
        }
    }
    return c;
}

int main(){
    int i,j,h,w,tmp;
    scanf("%d %d",&h,&w);
    int **a = (int **)malloc(sizeof(int*)*(h+1));
    for(i=0;i<h+1;i++)a[i]=(int*)malloc(sizeof(int)*(w+1));
    for(i=1;i<h+1;i++){
        for(j=1;j<w+1;j++){
            scanf("%d",&tmp);
            a[i][j] = tmp%2;
        }
    }
    printf("%d\n",count(a,h,w));
    for(i=1;i<h+1;i++){
        movex(a,i,w);
    }
    movey(a,h,w);
    return 0;
}


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

int main() {
    long long ans = 0;
    int N; cin >> N;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define ll long double
#define pb push_back
#define f first
#define s second
#define pill pair<ll,ll>
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const int N = 3e3 + 1;
ll n,k,dp[N][N],x[N];
bool C[N][N];

ll rec(int c = n - 1,int W = 0){
	if(c == -1){
		return n - W < W;
	}
	if(C[c][W])
		return dp[c][W];
	C[c][W] = 1;
	dp[c][W] = x[c] * rec(c - 1, W + 1) + (1 - x[c]) * rec(c - 1 , W);
	return dp[c][W];	
}

int main() {
	speed;
	cin >> n;
	for(int i = 0 ; i < n ; i++)
		cin >> x[i];
	cout << fixed << setprecision(9) <<  rec();
}
/*
Timus : 288471KD
Atcoder : I_LOVE_TROTT
Codeforces : Zhabka
mail : dzhon.snoudin@mail.ru
*/



Measured memory_bytes: 150016
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;


int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

int main()
{
	long long int n, cnt = 1;
	string s;

	cin >> n;
	cin >> s;

	char c = s[0];

	for (int i = 0; i < n; i++) {
		if (c != s[i]) {
			cnt++;
			c = s[i];
		}
	}

	cout << cnt << endl;
	

	return 0;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

int h,w,k;
string s[6];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w>>k;
    for(int i=0; i<h; i++){
        cin>>s[i];
    }
    int ans=0;
    for(int i=0; i<(1<<h); i++){
        for(int j=0; j<(1<<w); j++){
            int cnt=0;
            for(int I=0; I<h; I++){
                for(int J=0; J<w; J++){
                    if(!(i&(1<<I))&&!(j&(1<<J))){
                        if(s[I][J]=='#'){
                            cnt++;
                        };
                    }
                }
            }
            if(cnt==k) ans++;
        }
    }
    cout<<ans<<endl;    
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF (2e9)
#define EPS (1e-7)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

    int num_zero, num_one;
    num_zero = num_one = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        char ch = s[i];
        ch == '0' ? num_zero++ : num_one++;
    }
    cout << min(num_zero, num_one) * 2 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005;
int n,A[N],x,y;
vector<int> G[N];
int dfs(int x,int y){
    if (G[x].size()==1)return A[x];
    int tot=0,x2=0,x1=0,mm,tm=0;
    for (int i=0;i<G[x].size();i++)
		if (G[x][i]!=y){
	        mm=dfs(G[x][i],x);
    	    tm=max(tm,mm);
        	tot+=mm;
    	}
    x2=tot-A[x];
    x1=A[x]-x2;
    if (x1<0||x2<0||A[x]<tm||(x1>0&&y==-1)){
        puts("NO");
        exit(0);
    }
    return x1;
}
signed main(){
    scanf("%lld",&n);
    for (int i=1;i<=n;i++)scanf("%lld",&A[i]);
    if (n==1){
        puts(A[1]?"NO":"YES");
        return 0;
    }
    for (int i=1;i<n;i++){
        scanf("%lld%lld",&x,&y);
        G[x].push_back(y);
        G[y].push_back(x);
    }
    if (n==2)puts(A[1]==A[2]?"YES":"NO");
    else {
        for (int i=1;i<=n;i++)
            if (G[i].size()>1){
                dfs(i,-1);
                break;
            }
        puts("YES");
    }
    return 0;
}

Measured memory_bytes: 13184
#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);

    while(1) {
        ll t, d, l;
        cin >> t >> d >> l;
        if(!t) break;
        vector<ll> x(t);
        REP(i, t) cin >> x[i];

        ll ret = 0, rest = 0;
        REP(i, t-1) {
            if(x[i] >= l) rest = d;
            if(rest > 0) ret++;
            rest--;
        }

        // cerr << "ans=";
        cout << ret << endl;
    }

    return 0;
}



Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 2e4;
const lli INF = 1e18+10;
const lli MOD = 1e9+7;
const ld EPS = 1e-9;


// ---- コーディングはここから！ ('-')7




int main(){_
	int n; cin>>n;
	int x = n%10;
	if(x==2 or x==4 or x==5 or x==7 or x==9)cout<<"hon"<<ENDL;
	else if(x==3)cout<<"bon"<<ENDL;
	else cout<<"pon"<<ENDL;

}


Measured memory_bytes: 3544
import java.util.Scanner;
import java.lang.Math;

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

        double r = sc.nextDouble();

        String menseki = String.format("%.5f", r*r*Math.PI);
        String hankei = String.format("%.5f", 2*r*Math.PI);

        System.out.println(menseki+" "+hankei);
    }
}

Measured memory_bytes: 28248
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k, d, a;
bool dat[101];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> a;
            dat[a] = true;
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (!dat[i]) cnt++;
    }
    cout << cnt << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
int main() {
	int n;
	cin>>n;
	vector<ll> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vector<ll> suff(n);
	suff[n-1]=a[n-1]%mod;
	for(int i=n-2;i>=0;i--) suff[i]=(a[i]+suff[i+1])%mod;
	ll ans=0;
	for(int i=0;i<=n-2;i++){
	    ans=(ans+(a[i]*suff[i+1])%mod)%mod;
	}
	cout<<ans;
	return 0;
}

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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
ll fact[100005];
ll finv[100005];
void factorial(int n){
    fact[0]=1;
    finv[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=fact[i-1]*i,fact[i]%=MOD,finv[i]=fermat_inv(fact[i]);
}
ll ncr(ll n,ll r)
{
    if(n<r)
        return -1;
    else{
        ll x=finv[r]*finv[n-r]%MOD;
        return fact[n]*x%MOD;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=n-2;i>=0;i--)
        a[i]+=a[i+1],a[i]%=MOD;
    ll ans=0;
    for(int i=0;i<n-1;i++){
        ans+=(a[i]-a[i+1]+MOD)%MOD*a[i+1]%MOD;
        ans%=MOD;
    }
    cout<<ans;
}

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

using namespace std;
long long int ans = 1;
long long int las = 1;
vector<int> aaa;

long long int gcd(long long int x, long long int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

long long int soin(long long int a){
    for(long long int i=2;i<pow(a,0.5)+1;i++){
        if(a%i == 0){
            aaa.push_back(i);
            if(i!=las){
                ans++;
                las=i;
                a /= i;
            }else{
                a /= i;
            }
            i=1;
        }
    }

    if(a != 1){
        ans++;
    }

    for(int i=0;i<aaa.size();i++){
        if(a == aaa[i]){
            ans--;
            break;
        }
    }
}

int main(){
    long long int A,B,C;
    cin >> A >> B;
    C = gcd(A,B);
    soin(C);
    cout << ans << endl;
}

Measured memory_bytes: 384