akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

int dp[201][201], d, n, t[201], a[201], b[201], c[201], mx = 0;

int abs(int x, int y)
{
	if (x >= y) return x - y;
	else return y - x;
}

int main()
{
	cin >> d >> n;
	for (int i = 1; i <= d; i++){
		cin >> t[i];
	}
	for (int i = 1; i <= n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	memset(dp, -1, sizeof dp);

	for (int i = 1; i <= n; i++){
		if (a[i] <= t[1] && t[1] <= b[i]){
			dp[1][i] = 0;
		}
	}

	//dp
	for (int today = 2; today <= d; today++){
		for (int n1 = 1; n1 <= n; n1++){
			if (dp[today - 1][n1] == -1) continue;
			for (int n2 = 1; n2 <= n; n2++){
				if (a[n2] > t[today] || t[today] > b[n2]) continue;
				dp[today][n2] = max(dp[today][n2], dp[today - 1][n1] + abs(c[n1], c[n2]));
			}
		}
	}

	for (int i = 1; i < n; i++){
		mx = max(dp[d][i], mx);
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 1328
#include<iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  switch (n % 10) {
    case 3 :
      cout << "bon\n";
      break;
    case 0 :
    case 1 :
    case 6 :
    case 8 :
      cout << "pon\n";
      break;
    default :
      cout << "hon\n";
      break;
  }
}

Measured memory_bytes: 3580
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


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


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = True
show_flg = False


class UnionFind(object):
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        # ret = x
        # stack = [x]
        # while True:
        #     data = self.parents[stack[-1]]
        #     if data < 0:
        #         break
        #     stack.append(data)

        # while len(stack) > 1:
        #     ret = stack.pop()
        #     self.parents[data] = data

        # return ret

        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M = MI()
    # node_list = [UnionFindNode(i) for i in range(N+1)]
    uf = UnionFind(N+1)
    U = [0] * M
    V = [0] * M
    ans = [0] * M
    ans[M-1] = N * (N - 1) // 2

    for i in range(M):
        U[i], V[i] = MI()

    for i in range(M-1, 0, -1):
        u = U[i]
        v = V[i]

        if uf.same(u, v):
            ans[i-1] = ans[i]
        else:
            ans[i-1] = ans[i] - uf.size(u) * uf.size(v)
            uf.union(u, v)

    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 112728
"use strict";
function main(input) {
  let args = input.split('\n');
  let N = parseInt(args[0], 10);
  let items = [];
  var i = 0;
  for (i = 1; i <= N; i++) {
    let pair = args[i].split(' ');
    if (pair.length >= 2) {
      items.push({ number: i, name: pair[0], point: parseInt(pair[1], 10) });
    }
  }
  items.sort(function(item1, item2) {
    if (item1.name !== item2.name) {
      if (item1.name < item2.name) {
        return -1;
      }
      if (item2.name < item1.name) {
        return 1;
      }
      return 0;
    }
    return item2.point - item1.point;
  });
  for (i = 0; i < items.length; i++) {
    console.log(items[i].number);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main()
{
    string a,b;
    cin>>a>>b;
    
    int n = a.length(),m = b.length();
    int arr[m+1][n+1];
    
    for(int i=0;i<m+1;i++){
        for(int j=0;j<n+1;j++){
            arr[i][j] = 0;
        }
    }
    
    for(int i=1;i<m+1;i++){
        for(int j=1;j<n+1;j++){
           if(a[j-1] == b[i-1]){
               arr[i][j] = 1+arr[i-1][j-1];
               //cout<<arr[i][j]<<endl;
           }
           else{
               arr[i][j] = max(arr[i-1][j],arr[i][j-1]);
           }
        }
    }
    
    string s ="";
    int i = m,j = n;
    while(i > 0 && j > 0){
        if(arr[i][j] == arr[i-1][j]){
            i = i-1;
        }
        else if(arr[i][j] == arr[i][j-1]){
            j = j-1;
        }
        else{
            s.push_back(a[j-1]);
            i--;
            j--;
        }
    }
    if(arr[m][n] == 0){
        cout<<s;
        return 0;
    }
    
    reverse(s.begin(),s.end());
    cout<<s;
    
    
    
}


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

bool correct(char ver, int i, string answer, char ins){
    if(ver=='o'){
        if((answer[(i-1<0?i-1+answer.size():i-1)]=='S'&&answer[i]=='S')||(answer[(i-1<0?i-1+answer.size():i-1)]=='W'&&answer[i]=='W')){
            return ins=='S';
        }
        else{
            return ins!='S';
        }
    }
    else{
        if((answer[(i-1<0?i-1+answer.size():i-1)]=='S'&&answer[i]=='S')||(answer[(i-1<0?i-1+answer.size():i-1)]=='W'&&answer[i]=='W')){
            return ins!='S';
        }
        else{
            return ins=='S';
        }
    }
}

int main(){
    int n; string s, option[4] = {"SS", "SW", "WS", "WW"};
    cin>>n>>s;
    for( int i = 0; i < 4; i++ ){
        string answer = option[i];
        for( int j = 1; j < s.size()-1; j++ ){
            if(s[j]=='o'){
                if(correct('o',j, answer, 'S')){
                    answer+='S';
                }
                else{ answer+='W';}
            }
            else{
                if(correct('x',j, answer, 'S')){
                    answer+='S';
                }
                else{ answer+='W';}
            }
        }
        if((correct(s[s.size()-1], s.size()-1, answer, answer[0]))&&(correct(s[0], 0, answer, answer[1]))){
            cout<<answer<<endl; return 0;
        }
    }
    cout<<-1;
    return 0;
}

Measured memory_bytes: 796
using System;

class program
{
    static void Main(string[] args)
    {
        string[] inputs = Console.ReadLine().Split();
        long N = long.Parse(inputs[0]);
        long M = long.Parse(inputs[1]);
        long[] count = new long[N];
        bool ans = true;

        for(long i = 0; i < M; i++)
        {
            inputs = Console.ReadLine().Split();
            long p = long.Parse(inputs[0]) - 1;
            long q = long.Parse(inputs[1]) - 1;
            count[p]++;
            count[q]++;
        }
        
        for(long i = 0; i < N; i++)
        {
            if (count[i] % 2 != 0)
            {
                ans = false;
                break;
            }
        }

        if (ans) Console.WriteLine("YES");
        else Console.WriteLine("NO");

    }
}

Measured memory_bytes: 15712
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string N;
ll dp[1000010][2][2];
int main(){
    cin>>N;
    for(ll i=0;i<=N.length();i++){
        for(ll j=0;j<2;j++){
            for(ll k=0;k<2;k++){
                dp[i][j][k]=INF;
            }
        }
    }
    dp[0][0][1]=0;
    dp[0][1][0]=2;
    for(ll i=0;i<N.length();i++){
        for(ll j=0;j<2;j++){
            for(ll k=0;k<2;k++){
                for(ll d=0;d<10;d++){
                    ll nextI=i+1;
                    ll nextJ=j;
                    ll nextK=k;
                    if(j==0){
                        if(d<N[i]-'0')continue;
                        if(d>N[i]-'0'){
                            nextJ=1;
                            nextK=0;
                        }
                    }
                    ll plusNum=d;
                    if(j==0 && nextJ==1){
                        plusNum+=d-(N[i]-'0');
                        nextK=0;
                    }else if(j==1 && nextJ==1){
                        if(d<N[i]-'0'){
                            if(k==0){
                                plusNum+=10+d-(N[i]-'0')-1;
                            }else continue;
                        }else if(d>N[i]-'0'){
                            plusNum+=d-(N[i]-'0');
                            nextK=0;
                        }else{
                            nextK=1;
                        }
                    }
                    dp[nextI][nextJ][nextK]=min(dp[nextI][nextJ][nextK],dp[i][j][k]+plusNum);
                }
            }
        }
    }
    cout<<min({dp[N.length()][0][0],dp[N.length()][1][0],dp[N.length()][0][1],dp[N.length()][1][1]})<<endl;
    return 0;
}

Measured memory_bytes: 32644
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()

int main() {
  int n;
  cin >> n;
  map<int, int> Map;

  for(int i=2; i<=n; i++){
    ll num = i;
    for (long long a = 2; a * a <= num; ++a) {
      if (num % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (num % a == 0) {
            ++ex;
            num /= a;
        }

        // その結果を push
        Map[a] = Map[a] + ex;
    }

    // 最後に残った数について
    if (num != 1) Map[num] = Map[num] + 1;
  }
  ll ans = 1;
  for(int i=2; i<=n; i++){
      if(Map[i] > 0) ans = ans * (Map[i] + 1) % MOD;
  }
  cout << ans % MOD << ln;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
vector<int> G[100000];
int A[100000];
int B[100000];

void dfs(int pos,int prev,int d[100000]){
  for(int to:G[pos]){
    if(to==prev)continue;
    d[to]=d[pos]+1;
    dfs(to,pos,d);
  }
}

int main(){
  cin>>N;
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  dfs(0,-1,A);
  dfs(N-1,-1,B);
  
  int bc=0,wc=0;
  for(int i=0;i<N;i++){
    if(A[i]<=B[i])bc++;
    else wc++;
  }

  if(bc>wc)cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
  return 0;
}


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

typedef long long lli;

const int M = 6000011;
const int P = 151;

lli C[128];
lli X[M];

lli convert(const char s[]) {
  lli j = 0;
  for(lli i = 0; s[i] != '\0'; ++i) {
    j |= C[s[i]]<<(i*3LL);
  }
  return j;
}

void insert(const char s[]) {
  int x = convert(s);
  int p = x%M;
  while(X[p] != -1LL) p = (p+P)%M;
  X[p] = x;
}

bool find(const char s[]) {
  int x = convert(s);
  int p = x%M;
  while(X[p] != -1LL) {
    if(X[p] == x) return true;
    p = (p+P)%M;
  }
  return false;
}

int main() {
  int n;
  char s[100];
  C['A'] = 1LL;
  C['C'] = 2LL;
  C['G'] = 3LL;
  C['T'] = 4LL;
  fill(X,X+M, -1LL);
  scanf("%d", &n);
  while(n--) {
    scanf("%s", s);
    if(s[0] == 'f') {
      scanf("%s", s);
      if(find(s))
        printf("yes\n");
      else
        printf("no\n");
    } else {
      scanf("%s", s);
      insert(s);
    }
  }
  return 0;
}

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

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> D(N);

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

    sort(D.begin(), D.end());

    int r = D.at((N+1)/2);
    int l = D.at((N-1)/2);

    cout << r-l << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,int> ii;
ll L;
vector<int> arr;
vector<ii> sums;

struct sum {
    vector<ll> data;
    sum(vector<int>& arr) {
        data.resize(arr.size());
        data[0] = arr[0];
        for(int i = 1; i < (int)arr.size(); ++i)
            data[i] = data[i - 1] + ((ll)arr[i]);
    }
    ll query(int i, int j) {
        return !i ? data[j-1] : data[j-1] - data[i - 1];
    }
};

bool ok() {
    sum s(arr);
    set<int> limits;
    limits.insert(0);
    limits.insert(arr.size());
    set<int>::iterator it;
    for(int i = 0; i < (int)sums.size(); ++i) {
        s.query(4, 2);
        it = (limits.lower_bound(sums[i].second+1));
        int l = *(--it);
        int r = *(limits.upper_bound(sums[i].second+1));
        ll sum = s.query(l, r);
        if(sum < L) return false;
        limits.insert(sums[i].second+1);
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    ii mini = ii(0,-1);
    cin >> N >> L;
    arr.resize(N);
    for(auto& c: arr) cin >> c;
    for(int i = 1; i < (int)arr.size(); ++i) {
        mini = max(mini, ii(arr[i - 1] + arr[i],i-1));
    }
        sums.push_back(mini);
    ll sus = mini.first;
    for( int i = mini.second-1 ; i >= 0 ; i-- )
    {
        sus += ((ll)arr[ i ]);
        sums.push_back(ii(sus, i ));
    }
    sus = mini.first;
    for( int i = mini.second+2 ; i < (int)arr.size() ; ++i )
    {
        sus += ((ll)arr[ i ]);
        sums.push_back(ii(sus,i-1));
    }
    sort(sums.rbegin(), sums.rend());
    if(mini.first < L ) cout << "Impossible" << '\n';
    else {cout << "Possible\n";for(int i = 0; i < (int)sums.size(); ++i)
        cout << 1 + sums[i].second << '\n';
    }
    return 0;
}


Measured memory_bytes: 2928
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;

struct Task{
    string name;
    int time;
};

struct TaskQueue{
    int head;
    int tail;
    vector<Task> tasks;

    void initialize() {head=0;tail=0;tasks.resize(1000001);}
    void enqueue(Task x) {tasks[tail++] = x;}
    Task dequeue() {return tasks[head++];}
    bool isEmpty() {return tail-head==0;}
    bool isFull() {return tail==1000000;}
};

int main() {
    int n, q;
    cin >> n >> q;
    TaskQueue tQ;
    tQ.initialize();
    rep(i,n){
        Task task;
        cin >> task.name >> task.time;
        tQ.enqueue(task);
    }
    int finish = 0;
    while(!tQ.isEmpty()){
        Task t = tQ.dequeue();
        finish += min(q,t.time);
        t.time -= q;
        if(t.time <= 0) cout << t.name << " " << finish << endl;
        else tQ.enqueue(t);
    }
    return 0;
}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            if ((N[0]==N[1] && N[1] == N[2])||
                (N[1] == N[2] && N[2] == N[3]))
            {
                Console.WriteLine("Yes");
            }
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define N 110
int a[N];
int n;
int main(){
    cin>>n;
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            for(int k = j + 1; k <= n; k++){
                if(a[i] != a[j] && a[i] != a[k] && a[j] != a[k] && a[i] + a[j] > a[k]) ++ans;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
    int a, b, c;
    cin >> a >> b >> c;

    if(c >= a and c <= b)cout << "Yes";
    else cout << "No";
}

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

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

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
l = []
for i in range(M):
    ks = list(map(int, input().split()))
    k, s = ks[0], ks[1:]
    l.append(s)
    
p = list(map(int, input().split()))

ans = 0
for j in range(2**N):
    n = 0  
    for m in range(M):
        t = 0
        for sw in l[m]:
            if (j>>(sw-1)&1):
                t += 1
        if t%2 == p[m]:
            n += 1
        else:
            break
    if n == M:
        ans += 1
print(ans)
 

Measured memory_bytes: 3064
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t K;

void solve()
{
    std::cin >> K;

	int64_t ans = 0;
	for (int64_t a = 1; a <= K; a++)
	{
		for (int64_t b = 1; b <= K; b++)
		{
			for (int64_t c = 1; c <= K; c++)
			{
				ans += std::gcd(a, std::gcd(b, c));
			}
		}
	}

	std::cout << ans << std::endl;
}

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


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

#define N_DIGITS 5
int d[N_DIGITS];

int main() {
  int N, A, B; scanf("%d%d%d", &N, &A, &B);
  int res = 0;
  for(int i = 1; i <= N; ++i) {
    for(int j = 0; ; ++j) {
      if(d[j] < 9) { ++d[j]; break; }
      else d[j] = 0;
    }
    int sum = 0;
    for(int j = 0; j < N_DIGITS; ++j) sum += d[j];
    if(A <= sum && sum <= B) res += i;
  }
  printf("%d\n", res);
  return 0;
}


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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int D, T, S;
    cin >> D >> T >> S;
    if (D <= T * S)
        cout << "Yes";
    else
        cout << "No";
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int ppow(int x,int y)
{
    if (y==0) return 1;
    int ret=ppow(x,y/2);
    ret=ret*ret%mod;
    if (y&1) ret=ret*x%mod;
    return ret;
}

int p[maxn],invp[maxn];

int C(int n,int m)
{
    return p[n]*invp[m]%mod*invp[n-m]%mod;
}

int32_t main()
{
    IOS
    p[0]=invp[0]=1;
    for (int i=1;i<=500000;i++)
        p[i]=p[i-1]*i%mod,invp[i]=ppow(p[i],mod-2);

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

    int ans=0,x=1;
    for (int i=0;i<=n;i++)
    {
        ans=(ans+mod+C(n,i)*p[m]%mod*invp[m-n]%mod*p[m-i]%mod*invp[m-n]%mod*x)%mod;
        x*=(-1);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 11452
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def cmb_mod(N, mod=10**9+7):
    N1 = N + 1
    g1 = [0] * N1
    g2 = [0] * N1
    inv = [0] * N1
    g1[0] = g1[1] = g2[0] = g2[1] = inv[1] = 1

    for i in range(2, N1):
        g1[i] = g1[i-1] * i % mod
        inv[i] = -inv[mod % i ] * (mod//i) % mod
        #inv[i] = pow(g1[i-1], mod-2, mod)
        g2[i] = g2[i-1] * inv[i] % mod

    def cmb(n, a):
        if a < 0 or a > n:
            return 0
        return g1[n] * g2[a] * g2[n-a] % mod
    return cmb

def resolve():
    mod = 10**9 + 7
    S = int(input())

    if S < 3:
        print(0)
        return
    elif S < 6:
        print(1)
        return

    cmb = cmb_mod(S - 3 * 2 + 3)

    ans = 1
    for i in range(2, S//3+1):
        n = S - 3 * i + i - 1
        tmp = cmb(n, i - 1)
        ans = (ans + tmp) % mod
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 64644
#include <bits/stdc++.h>
#define LL long long
#define ri register int
#define pii pair<int, int>
#define pll pair<LL, LL>
using namespace std;
inline int read()
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9')
		ch = getchar();
	do {
		ret = ret * 10 + ch - '0';
		ch = getchar();
	} while('0' <= ch && ch <= '9');
	return ret;
}
inline void write(int x) // x > 0 (x != 0) ***
{
	if(!x)
		return ;
	write(x / 10);
	putchar(x % 10 + '0');
}
#define mod 1000000007
#define maxn 100100
inline LL fpow(LL x, LL a)
{
	LL ret = 1;
	while(a)
	{
		if(a & 1)
			ret = ret * x % mod;
		a >>= 1;
		x = x * x % mod;
	}
	return ret;
}
int n;
LL ni[maxn];
LL peng = 1;
LL sum[maxn];
LL a[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i ++)
		ni[i] = fpow(i, mod - 2);
	for(int i = 1; i <= n; i ++)
		peng = peng * i % mod;
	for(int i = 1; i <= n; i ++)
		sum[i] = (sum[i - 1] + peng * ni[i]) % mod;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	LL Ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		Ans = (Ans + a[i] * (sum[i] - sum[1] + sum[n - i + 1])) % mod;
	}
	cout << Ans << endl;
	return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  priority_queue<ll> ql;
  priority_queue<ll,vector<ll>,greater<ll> > qr;
  int q;
  cin>>q;
  ll sb=0,sql=0,sqr=0;
  ll t,a,b;
  for(i=0;i<q;i++){
    cin>>t;
    if(t==1){
      cin>>a>>b;
      sb+=b;
      if(ql.size()==0){
        ql.push(a);
        qr.push(a);
        sql+=a;
        sqr+=a;
      }
      else if(a<=ql.top()){
        int u=ql.top();
        ql.pop();
        qr.push(u);
        ql.push(a);
        ql.push(a);
        sql+=2*a-u;
        sqr+=u;
      }
      else if(qr.top()<=a){
        int u=qr.top();
        qr.pop();
        ql.push(u);
        qr.push(a);
        qr.push(a);
        sqr+=2*a-u;
        sql+=u;
      }
      else {
        ql.push(a);
        qr.push(a);
        sql+=a;
        sqr+=a;
      }
    }
    else {
      cout<<ql.top()<<" "<<sb+(sqr-sql)/2<<endl;
    }
  }

  
  return 0;
}

Measured memory_bytes: 4588
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> mp;
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        mp[a[i]]++;
        sum += a[i];
    }
    ll q;
    cin >> q;
    vector<ll> ans(q);
    rep(i, q) {
        ll b, c;
        cin >> b >> c;
        if (mp.count(b)) {
            ll tmp = mp[b];
            sum -= b * tmp;
            sum += c * tmp;
            mp.erase(b);
            if (mp.count(c)) {
                mp[c] += tmp;
            }
            else {
                mp.insert(make_pair(c, tmp));
            }
        }
        ans[i] = sum;
    }
    rep(i, q) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
  	string s;
  	string arr[] = {"dreamer", "dream", "eraser", "erase"};
  	regex re("[bcfghijklnopqtuvwxyz]");
  	smatch m;
  	cin >> s;
  	if (regex_search(s, m, re)) {
     	cout << "NO" << endl;
      	return 0;
    }
  	int i = 0;
  	while (true) {
      	if(s.size() == 0) {
         	break; 
        }
      	int pos = s.rfind(arr[i]);
      	if(((pos + arr[i].size()) == s.size()) && pos >= 0) {
            s = s.erase(pos, arr[i].size());
            i = 0;
            continue;
        }
      	i++;
      	if (i > 3) {
            cout << "NO" << endl;
            return 0;
        }
    }
  
  	cout << "YES" << endl;
	return 0;  
}

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

long long baseW;
long long N, W;
vector<long long> val[4];

long long getval(long long A, long long B, long long C, long long D){
	long long ret = 0;

	if(baseW * A + (baseW + 1) * B + (baseW + 2) * C + (baseW + 3) * D > W){
		return -1;
	}

	for(long long i = 0; i < A; i++){
		ret += val[0][i];
	}

	for(long long i = 0; i < B; i++){
		ret += val[1][i];
	}

	for(long long i = 0; i < C; i++){
		ret += val[2][i];
	}

	for(long long i = 0; i < D; i++){
		ret += val[3][i];
	}
	return ret;
}

int main(){
	cin >> N >> W;
	for(long long i = 0; i < N; i++){
		long long tmpw, tmpv;
		cin >> tmpw >> tmpv;
		if(i == 0){
			baseW = tmpw;
		}
		val[tmpw - baseW].push_back(tmpv);
	}
	for(int i = 0; i < 4; i++){
		sort(val[i].begin(), val[i].end(), greater<long long>());
	}

	long long ans = 0;
	for(long long i = 0; i <= val[0].size(); i++){
		for(long long j = 0; j <= val[1].size(); j++){
			for(long long k = 0; k <= val[2].size(); k++){
				for(long long l = 0; l <= val[3].size(); l++){
					ans = max(ans, getval(i, j, k, l));
				}
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;


public class Main{ 

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		AdjacencyMatrices am = new AdjacencyMatrices(scan.nextInt());
		am.readList(scan);
		am.printMatrix();
	}

}
class AdjacencyMatrices{
	int pointNum;
	int[][] matrix;
	public AdjacencyMatrices(int n){
		pointNum = n;
		matrix = new int[n][];
		for(int i=0; i<n; i++)
			matrix[i] = new int[n];
	}
	public void readList(Scanner scan){
		for(int i=0; i<pointNum; i++){
			int index = scan.nextInt()-1;
			int dim = scan.nextInt();
			for(int j=0; j< dim; j++)
				matrix[index][scan.nextInt()-1] = 1;
		}
	}
	public void printMatrix(){
		StringBuilder temp = new StringBuilder();
		for(int i=0; i<pointNum; i++){
			for(int j=0; j<pointNum; j++){
				temp.append(matrix[i][j]);
				if(j!=pointNum-1)
					temp.append(" ");
			}
			temp.append("\n");
		}
		System.out.print(new String(temp));
	}

}

Measured memory_bytes: 21000
#include<iostream>
using namespace std;
int main(){
	int r,c,a[101][101];
	cin>>r>>c;
	for(int i=0;i<r+1;i++){
		for(int j=0;j<c+1;j++){
			a[i][j]=0;
		}
	}
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin>>a[i][j];
			a[r][c]=a[i][j]+a[r][c];
			a[i][c]=a[i][j]+a[i][c];
		}
	}
	for(int j=0;j<c;j++){
		for(int i=0;i<r;i++){
			a[r][j]=a[i][j]+a[r][j];
		}
	}
	for(int i=0;i<=r;i++){
		for(int j=0;j<=c;j++){
			if(j==c)cout<<a[i][j];
			else cout<<a[i][j]<<" ";

		}cout<<endl;
	}
	return 0;
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define C 6
#define L 8

int main() {
  string D;
  cin >> D;
  string aidunyan = "AIDUNYAN", aizunyan = "AIZUNYAN";
  int lst[C], len = 0;
  int pattern[C] = {2, 1, 1, 1, 2, 1};
  rep(i, C) lst[i] = 0;
  rep(i, D.length()) {
    if(len == L) {
      rep(j, C) if(aidunyan[j]==D[i-L]) { --lst[j]; break; }
      --len;
    }
    rep(j, C) if(aidunyan[j]==D[i]) { ++lst[j]; break; }
    ++len;
    if(len == L) {
      bool isOK = true;
      rep(j, C) if(pattern[j]!=lst[j]) { isOK = false; break; }
      if(isOK) {
        len = 0;
        rep(j, C) lst[j] = 0;
        rep(j, L) D[i-L+j+1] = aizunyan[j];
      }
    }
  }

  cout << D << endl;
  return 0;
}

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

using namespace std;

int N, A[100000];
deque< int > vv[100000];

int rec(int idx)
{
  vector< int > s;
  for(auto &to : vv[idx]) s.push_back(rec(to));
  sort(begin(s), end(s));
  reverse(begin(s), end(s));
  int res = s.size();
  for(int i = 0; i < s.size(); i++) {
    res = max(res, s[i] + i);
  }
  return (res + 1);
}

int main()
{
  cin >> N;
  for(int i = 1; i < N; i++) {
    cin >> A[i];
    vv[--A[i]].push_back(i);
  }
  cout << rec(0) - 1 << endl;
}


Measured memory_bytes: 77184
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using p = pair<int,int>;
static const long long INF = 1000000007;

int main(){
    long long min = INF;
    int ans = 0;
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n) cin >> vec[i];
    rep(i,n){
        if (min >= vec[i]){
            ans ++;
            min = vec[i];
        }
    
    }
    cout << ans << endl;
}

Measured memory_bytes: 3964
#include<bits/stdc++.h>
#define ll long long

using namespace std;
const int MAXN = 100005;
const int MOD = 1000000007;

vector<int> g[MAXN];
ll arr[MAXN];

int dfs(int a,int p){
	if(g[a].size() == 1) return arr[a];
	ll sum = 0,mx = -1;
	for(int i:g[a]){
		if(i != p){
			ll k = dfs(i,a);
			sum += k;
			mx = max(mx,k);
		}
	}
	ll ans = arr[a] * 2 - sum;
	ll x = sum - arr[a];
	if(ans < 0 or x < 0 or arr[a] < mx){
		cout << "NO\n";
		exit(0);
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	for(int i=1;i<=n;i++) cin >> arr[i];
	for(int i=0;i<n-1;i++){
		int a,b; cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	if(n == 2){
		if(arr[1] == arr[2]) cout << "YES\n";
		else cout << "NO\n";
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(g[i].size() > 1){
			ll k = dfs(i,0);
			if(k == 0) cout << "YES\n";
			else cout << "NO\n";
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 13184
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARatedForMe solver = new ARatedForMe();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARatedForMe {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int r = in.nextInt();
            if (r < 1200) {
                out.println("ABC");
                return;
            }
            if (r < 2800) {
                out.println("ARC");
                return;
            }
            out.println("AGC");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

int main()
{
    int n;cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++) {
        cin >> a[i];
    }
    vector<int> b(n);
    for (int i=0;i<n;i++) {
        b[i] = a[i] - (i+1);
    }
    sort(b.begin(),b.end());
    int med;
    med = b[b.size()/2];
    long acc = 0;
    for (int i=0;i<n;i++) {
        acc += abs(a[i] - (med + i+1));
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  int flag=0;
  cin>>a;
  for(int i=0;i<3;i++){
    if(a[i]==a[i+1])
      flag=1;
  }
  if(flag==1) cout<<"Bad"<<endl;
  else cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    Int A, V, B, W, T; cin >> A >> V >> B >> W >> T;
    if (V <= W) {
        cout << "NO\n";
        return 0;
    }
    Int S = V - W;
    if (S * T >= abs(A - B)) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 3640
#!/bin/bash

typeset -i A=0
VALUES="1 10 12 14 15 16 18 2 20 21 24 25 27 28 3 30 32 35 36 4 40 42 45 48 49 5 54 56 6 63 64 7 72 8 81 9"
read A
for V in $VALUES
do
        if [[ $A -eq $V ]]; then
                echo "Yes"
                exit
        fi
done
echo "No"


Measured memory_bytes: 376
def cost(a,y)
    a.inject(0){|s,x|s+(x-y)**2}
end
N = gets.to_i
A = gets.split.map(&:to_i)
min=A.min
max=A.max
ans=10**10
(min..max).each do |y|
    ans = [ans,cost(A,y)].min
end
puts ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define QS ios_base::sync_with_stdio(false);
typedef long long ll;
const ll INF = 1e18;
const int MOD = 1e9+7;
using namespace std;

int main(){
//freopen("output.txt", "w", stdout);
    QS
    int n; string s; cin >> n >> s;
    int t = n/2;
    if(n&1){
        cout << "No\n";
        return 0;
    }
    for(int i = 0; i < t; ++i){
        if(s[i] != s[i+t]){
           // cout << i << " " <<i + t;
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            //n SHCD
            var cards = int.Parse(Console.ReadLine());

            var suits = new[] { "S", "H", "C", "D" };
            var dic = new Dictionary<string, bool>();

            for (var i = 0; i < cards; ++i)
            {
                var key = Console.ReadLine();
                if (!dic.ContainsKey(key)) dic.Add(key, true);
            }
            for (var i = 0; i < 4; ++i)
            {
                for(var k = 1; k <= 13; ++k)
                {
                    var s = $"{suits[i]} {k}";
                    if (!dic.ContainsKey(s)) Console.WriteLine(s);
                }
            }
        }
    }
}


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

#define ll long long
#define db double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				ans += __gcd(__gcd(i, j), k);
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 3644
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int l,r,d,ans;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(l);in(r);in(d);
	for(int i=l;i<=r;i++)
	if(i%d==0)ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3676
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <cstdio>
#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>
#include <complex>

using namespace std;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
#define PB push_back
#define MP make_pair
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int a[20];
int n;

bool DFS(int k, int m, double r){
	int s = ceil(a[k]-a[k]*r);
	if(s==0)s=1;
	int e = ceil(a[k]+a[k]*r);
	for(int p = ((s-1)/m+1)*m; p<e; p+=m)
		if(k==n-1)return true;
		else if(DFS(k+1, p, r))return true;

	return false;
}

bool C(double r){
	return DFS(0,1,r);
}

int main(){
	cin>>n;
	REP(i,n)scanf("%d", &a[i]);
	double u=1.0, l=0.0;
	while(u-l>1e-9){
		double mid = (u+l)*0.5;
		if(C(mid))u=mid;
		else l = mid;
	}
	printf("%.10f\n", u);
	return 0;
}

Measured memory_bytes: 1264
#include "bits/stdc++.h"
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/10/16  Problem: nagoya_19_01  / Link:   ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;
int dir[4];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	string S;
	cin >> S;
	FOR(i, 0, SZ(S)) {
		if (S[i] == 'N')dir[0]++;
		if (S[i] == 'S')dir[1]++;
		if (S[i] == 'W')dir[2]++;
		if (S[i] == 'E')dir[3]++;
	}

	int f = 1;
	FOR(i, 0, 2) {
		if (dir[2 * i] > 0 && dir[2 * i + 1] == 0)f = 0;
		if (dir[2 * i] == 0 && dir[2 * i + 1] > 0)f = 0;
	}
	cout << (f?"Yes":"No")<< "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define Mod 1000000007

int main()
{
	int N, K;
	scanf("%d %d", &N, &K);
	
	int i;
	long long ans = 0;
	for (i = K; i <= N + 1; i++) ans = (ans + ((long long)N * 2 - i + 1) * i / 2 - (long long)i * (i - 1) / 2 + 1) % Mod;
	printf("%lld\n", ans); 
	fflush(stdout);
	return 0;
}

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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << (a == c ? 0 : 1);
  return 0;
}


Measured memory_bytes: 3604
N, M = map(int, input().split())
A, B = [], []
graph = [[] for i in range(N+1)]
for i in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    graph[a].append(b)
    graph[b].append(a)

class Rs():
    def __init__(self):
        self.Rs = []

    def append(self, R):
        self.Rs.append(R)

    def search(self):
        count = 1
        new_nodes, count = self._search(1, count)
        while count < N:
            _new_nodes = set()
            for num in new_nodes:
                _new_node, count = self._search(num, count)
                _new_nodes.update(_new_node)
            new_nodes = _new_nodes

        return [ self.Rs[i].fastest_room for i in range(1,len(self.Rs)) ]

    def _search(self, num, count):
        r = self.Rs[num-1]
        cons = r.connection
        new_nodes = set()
        cons -= r.searched_from

        for con in cons:
            if len(self.Rs[con-1].searched_from) == 0:
                self.Rs[con-1].fastest_room = num
                self.Rs[con-1].searched_from.add(num)
                new_nodes.add(con)
                count += 1
            else:
                continue
        return new_nodes, count

class R():
    def __init__(self, num, connection):
        self.num        = num
        self.connection = connection
        self.searched_from = set([])
        self.fastest_room = None

r = Rs()
for i in range(N):
    r.append(R(i+1, set(graph[i+1])))

l = r.search()
print("Yes")
for room in l:
    print(room)



Measured memory_bytes: 120224
n,A,B = map(int, input().split(' '))
S = input()

j=0
f=0

for  s in S:
    yosentoppa = False
    if s == "c":
        pass
    elif j+f < A+B:
        if s == "a":
            j+=1    
            yosentoppa = True
        else:
            if f<B:
                yosentoppa = True
                f+=1
    print (['No','Yes'][yosentoppa])



Measured memory_bytes: 4016
#include<bits/stdc++.h>
    using namespace std;
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define ll long long
    #define int long long
    #define lb long double
    #define f(i,a,b) for(int i=a;i<=b;i++)
    #define fd(i,a,b) for(int i=a;i>=b;i--)
    #define vi vector<int>
    #define mii map<int,int>
    #define pii pair<int,int>
    #define si set<int>
    #define pb push_back
    #define mk make_pair
    #define fi first
    #define se second
    #define fv(i,v) for(auto i=v.begin();i!=v.end();++i)
    #define fdv(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
    #define print(a,n) f(i,1,n) cout<<a[i]<<" "; cout<<endl;
    #define printv(v) for(auto iv: v) cout<<iv<<" "; cout<<endl;
    #define all(v) v.begin(),v.end()
    #define r(a,n) ll a[n+1]; f(i,1,n) cin>>a[i];
    #define pi 3.141592653589793238
    const int mod=998244353;
    const int inf=1e18;
    //bool vis[1000+1]={};
    const int MAXN=1e6+1;
    int spf[MAXN];
    ll power(ll x, unsigned ll y)
    {
        ll res = 1;
        while (y > 0)
        {
            if (y & 1)
                res = res*x;
            y = y>>1;
            x = x*x;
        }
        return res;
    }

    bool isPrime(int n)
    {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }
        void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;
        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)
                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }

    int lcm(int a, int b)
    {
        return (a*b)/__gcd(a,b);
    }
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int t=1;
       // cin>>t;
        while(t--)
        {
            char s;
            cin>>s;
            if(islower(s))cout<<"a"<<endl;
            else cout<<"A"<<endl;
        }
    }


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
char a[5];
int book[30],ans;
int main()
{
	cin>>a;
	for(int i=0;i<4;i++)book[a[i]-'A']++;
	for(int i=0;i<26;i++) if(book[i]==2) ans++;
	if(ans==2) printf("Yes\n");
	else printf("No\n");
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k;
    int a[100005],dp[100005];
    cin>>n>>k;
    for(i=0;i<n;i++)
    cin>>a[i];
    dp[0]=0;
    for(i=1;i<n;i++)
    dp[i]=INT_MAX;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<=i+k;j++)
        {
            if(j<n)
            dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
        }
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
        long k=sc.nextLong();
        int q=sc.nextInt();
		// 文字列の入力
        long[] p=new long[n];
      for(int i=0;i<n;i++){
      	p[i]=k-q;
      }
        for (int i=0;i<q;i++){
        	int a=sc.nextInt();
            p[a-1]++;
        }
      
      for(int i=0;i<n;i++){
      	if(p[i]>0){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
      }
          // 出力
      
          //System.out.println(o[n]);
      }
}

Measured memory_bytes: 64252
using System;
public class Hello{
    public static void Main(){
        var n = int.Parse(Console.ReadLine());
        var arr = new long[1001];
        
        var ans = 1L;
        for(var i = 2;i <= n;i++){
            var temp = i;
            for(var j = 2;j <= i;j++){
                while(temp % j == 0){
                    arr[j]++;
                    temp /= j;
                }
            }
        }
        
        for(var i = 2;i <= 1000;i++){
            if(arr[i] != 0){
                ans *= arr[i] + 1;
                ans %= 1000000007;
            }
        }        Console.WriteLine(ans);
        
    }
}


Measured memory_bytes: 13252