akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int p = 0, g = 0;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'g') {
            if (p < g) {
                p++;
                ans++;
            } else {
                g++;
            }
        } else {
            if (p < g) {
                p++;
            } else {
                ans--;
                g++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
bool x[4];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int a,b;
	cin>>a>>b;
	x[a]=1,x[b]=1;
	for(int i=1;i<=3;i++) if(x[i]==0) cout<<i<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>
#include <bits/stdc++.h>

using namespace std;


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

    cin>>h>>w;
    char grid[h][w];
    int dp[h+1][w+1]= {};
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
            cin>>grid[i][j];

    dp[h-1][w]=1;

    for(int i=h-1; i>=0; i--)
        for(int j=w-1; j>=0; j--)
            if(grid[i][j]=='.')
                dp[i][j]=(dp[i][j+1]+dp[i+1][j])%1000000007;

    cout<<dp[0][0]<<endl;

}


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

def solve():
    """しゃくとり法で解く"""
    N = int(input())
    As = list(map(int, input().split()))

    # 数列Aの要素aが何個あるかを保持する辞書dic
    dic = {}
    for a in As:
        if not a in dic:
            dic[a] = 0
        dic[a] += 1

    S = sum(As)  # 総和

    # 各クエリでしゃくとりする
    Q = int(input())
    for q in range(Q):
        b, c = list(map(int, input().split()))
        if b in dic:
            if not c in dic:
                dic[c] = 0
            S -= b*dic[b]
            S += c*dic[b]
            dic[c] += dic[b]
            dic[b] = 0
        print(S)


if __name__ == "__main__":
    solve()


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<array<int, 2>> v, w;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        int mini = 0; int curr = 0;
        for (auto &c: s) {
            if (c == '(') curr++;
            else curr--;
            mini = min(mini, curr);
        }
        if (curr >= 0) v.push_back({mini, curr});
        else w.push_back({mini-curr, -curr});
    }
    sort(v.rbegin(), v.rend());
    sort(w.rbegin(), w.rend());
    int curr = 0;
    bool ok = true;
    for (auto &[m, c]: v) {
        if (curr + m < 0) ok = false;
        curr += c;
    }
    int prev = 0;
    for (auto &[m, c]: w) {
        if (prev + m < 0) ok = false;
        prev += c;
    }
    if (curr != prev) ok = false;
    if (ok) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 11248
$n=<>;
chomp($n);
for (my$i=2;$i<=$n;$i++){
    my$p=$i;
    for(my$d=2;$d<=$p;$d++){
        while($p%$d==0){
            $l{$d}++;
            $p/=$d;
        }
    }
}
@m = sort {$l{$b}<=>$l{$a}} keys %l;
foreach my$i (@m){
    $o++ if ($l{$i}>=74); 
    $n24++ if ($l{$i}>=24); 
    $n14++ if ($l{$i}>=14); 
    $n4++ if ($l{$i}>= 4);  
    $n2++ if ($l{$i}>= 2);  
}
$o+=$n24*($n2-1);
$o+=$n14*($n4-1);
$o+=$n4*($n4-1)*($n2-2)/2;
$o//=0;
print ("$o");

Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100000
int main(){
  int n, i;
  int M[MAX+1];
  scanf("%d", &n);
  for(i=1;i<n+1;i++)scanf("%d",&M[i]);
  for(i=1;i<n+1;i++){
    printf("node %d: key = %d, ",i,M[i]);
    if(i/2>=1)printf("parent key = %d, ",M[i/2]);
    if(i*2<=n) printf("left key = %d, ",M[i*2]);
    if(i*2+1<=n) printf("right key = %d, ",M[i*2+1]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2036
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, A, B = list(map(int, sys.stdin.readline().split()))

ans = 0
for i in range(1, N + 1):
    if A <= sum(map(int, list(str(i)))) <= B:
        ans += i

print(ans)


Measured memory_bytes: 13768
package main 

import (
        "fmt"
        "unicode/utf8"
)

func main () {
        var s, t string
        var an int
        fmt.Scan(&s, &t)
        if s == t {
                fmt.Println("Yes")
        }  else if  s != t {
                ko := utf8.RuneCountInString(s)
                ka := ko - 1
                for i := 0 ; i < ko ; i++{
                        s  = s[ka:ko] + s[0:ka]
                        if  s == t {
                                an +=1
                        }
                }
                if an > 0 { 
                        fmt.Println("Yes")
                }  else if an == 0 {
                        fmt.Println("No")
                }
        }
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();

		int thirdPlace = N / 100;
		int secondPlace = (N - thirdPlace*100)/10;
		int firstPlace = N - thirdPlace*100 - secondPlace*10;
		if(thirdPlace == 7 || secondPlace == 7 || firstPlace == 7) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 27008
#include <iostream>
#include <algorithm>
using namespace std;
using ll=long long;
int main(void){
    ll n;
    cin>>n;
    for(ll i=1;i<=3500;i++){
        for(ll j=1;j<=3500;j++){
            ll a=n*i*j,b=4*i*j-n*(i+j);
            if(b<=0)continue;
            ll w=a/b;
            if(a%b==0 && 3500>=w && w>0){
                cout<<i<<" "<<j<<" "<<(int)w<<endl;
                return 0;
            }
        }
    }

}


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

int main(void)
{
	string s, str;
	int count = 0;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if ('A' <= s[i] && s[i] <= 'Z') s[i] += 'a' - 'A';
	}

	while (true)
	{
		cin >> str;
		if (str == "END_OF_TEXT") break;
		for (int i = 0; i < str.size(); i++)
		{
			if ('A' <= str[i] && str[i] <= 'Z') str[i] += 'a' - 'A';
		}
		if (s == str) count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3176
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

int main()
{
    vector<ll> v;
    ll i,j,k,l,n,ans[200005]={0};
    string s;
    cin>>s;
    n=s.size();
    rep(i,1,n-1)
    {
        if(s[i]!=s[i-1] && s[i]=='L')
            v.pb(i);
    }
    rep(i,0,n-1)
    {
        if(s[i]=='R')
        {
            k=upper_bound(all(v),i)-v.begin();
            //cout<<i<<" "<<v[k]<<"::";
            ll x=abs(v[k]-i);
            if(x%2==1)
            {
                ans[v[k]-1]++;
            }
            else
            {
                ans[v[k]]++;
            }
        }
        else
        {
            k=upper_bound(all(v),i)-v.begin();k--;
            //cout<<i<<" "<<v[k]<<"::";
            ll x=abs(v[k]-i);
            //cout<<x<<"|";
            if(x%2==1)
            {
                ans[v[k]-1]++;
            }
            else
            {
                ans[v[k]]++;
            }
        }
    }//cout<<"haha";
    rep(i,0,n-1)cout<<ans[i]<<" ";
    return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

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

int main() {
  int N, M;
  cin >> N >> M;
  string S;
  cin >> S;
  reverse(All(S));
  int cur_idx = 0;
  int next_idx;
  vector<int> ans;
  bool flag = false;
  while (cur_idx < N) {
    next_idx = cur_idx + M;
    if (next_idx >= N) {
      ans.pb(N - cur_idx);
      flag = true;
      break;
    }

    bool flag2 = false;
    for (; next_idx > cur_idx; next_idx--) {
      if (S[next_idx] == '0') {
        flag2 = true;
        break;
      }
    }

    if (!flag2) {
      break;
    }
    ans.pb(next_idx - cur_idx);
    cur_idx = next_idx;
  }

  if (flag) {
    reverse(All(ans));
    rep(i, 0, ans.size() - 1) {
      cout << ans[i] << " ";
    }
    cout << ans[ans.size() - 1] << endl;
  } else {
    cout << -1 << endl;
  }
};


Measured memory_bytes: 1144
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
string s;

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

	priority_queue<double, vector<double>, greater<double> > que;
	for (int i = 0; i != n; i++) {
		double valtmp = 0;
		cin >> valtmp;
		que.push(valtmp);
	}

	double ans = 0.0;
	ans = que.top();
	que.pop();
	while (!que.empty()) {
		double topval = que.top();
		ans = (ans + topval) / 2;
		que.pop();
	}

	cout << setprecision(10) << ans << endl;

	return 0;
}

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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int count = 0;

    if(s.length() >= 3) {
        for(int i = 0; i < s.length() - 2; i++) {
            if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
                count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  long long n,k;
  cin >> n >> k;
  vector<pair<int, int>> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i].first >> a[i].second;
  }
  sort(a.begin(),a.end());
  long long cnt=0;
  for(int i=0;i<n;i++){
    int tmp=a[i].second;
    if(cnt<k&&k<=cnt+tmp){
      cout << a[i].first << endl;
      return 0;
    }
    cnt+=tmp;
  }
}


Measured memory_bytes: 1024
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

ll i,j,k=0,n;string s;
cin>>s;
n=s.length();
vector<ll> dp(2019,0);
dp[s[0]-'0']+=1;
for(i=1;i<n;i++)
{
	ll d=s[i]-'0';
	vector<ll> tdp(2019,0);
	tdp[d]+=1;
	for(j=0;j<2019;j++)
	{
		int r=(j*10+d)%2019;
		if(r==0) k+=dp[j];
		tdp[r]+=dp[j];
	}
	dp=tdp;
}
cout<<k;


return 0;
}

Measured memory_bytes: 3792
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s; cin >> s;
	vector<int> dp(s.size());
	dp[0] = 1;
	bool two = false;
	int i = 0;
	while (i < s.size() - 1)
	{
		if (two)
		{
			dp[i + 1] = dp[i] + 1;
			two = false;
		}
		else
		{
			if (s[i] != s[i + 1])dp[i + 1] = dp[i] + 1;
			else
			{
				dp[i + 1] = dp[i];
				two = true;
				++i;
				if (i + 1 < s.size())dp[i + 1] = dp[i] + 1;
			}
		}
		++i;
	}
	cout << dp[s.size() - 1] << endl;
}

Measured memory_bytes: 4444
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		
		long dif = b - a;
		long ans;
		if (dif % 2 == 0) {
			ans = dif / 2;
		} else {
			ans = Math.min(a - 1 + (dif + 1) / 2, n - b + (dif + 1) / 2);
		}
		
		System.out.println(ans);
		
		sc.close();
	}
	
}



Measured memory_bytes: 27076
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
using lpair = pair<lint,lint>;
using Vecint = vector<lint>;
using Llist = list<lint>;
using vs = vector<string>;
#define all(v) (v.begin(),v.end())
ll pow(ll k,ll l) {
	ll ret = 1;
	rep(i,l) {
		ret *= k;
	}
	return ret;
}

template <typename T>
T sum(vector<T> vec) {
	ll ret = 0;
	rep(i,vec.size()) {
		ret += vec.at(i);
	}
	return ret;
}

void Main() {
	ll n,l;
	cin >> n >> l;
	vs v(n);
	rep(i,n)
		cin >> v[i];
	sort(v.begin(),v.end());
	rep(i,n)
		cout << v[i];
	cout << '\n';
}

signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

vector<ll> Factorial(ll M, ll MOD){
    vector<ll> result = vector<ll>(M + 1);
    for(int i = 0; i <= M; i++){
        if(i == 0){
            result[i] = 1;
        }else{
            result[i] = result[i-1] * i % MOD;
        }
    }
    return result;
}

vector<ll> InvFact(ll M, ll MOD){
    vector<ll> result = vector<ll>(M + 1);
    vector<ll> inv = vector<ll> (M + 1);
    result[0] = 1;
    result[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < M; i++){
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        result[i] = result[i - 1] * inv[i] % MOD;
    }
    return result;
}

ll Combination(ll n,ll k,vector<ll>& fact, vector<ll>& invFact,ll MOD){
    //nCkを計算する
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fact[n] * (invFact[k] * invFact[n - k] % MOD) % MOD;
}

int main() {
    ll n,k;
    cin >> n >> k;
    ll MOD = 1000000007;
    auto fact = Factorial(700000,MOD);
    auto invFact = InvFact(700000,MOD);
    if(k >= n - 1){
        ll result = fact[2 * n - 1];
        result = result * invFact[n-1] % MOD;
        result = result * invFact[n] % MOD;
        cout << result << endl;
        return 0;
    }
    ll sum = 0;
    for (int i = 0; i <= k; ++i) {
        ll tmpA = fact[n];
        tmpA = tmpA * invFact[n - i] % MOD;
        tmpA = tmpA * invFact[i] % MOD;
        ll tmpB = fact[n - 1];
        tmpB = tmpB * invFact[i] % MOD;
        tmpB = tmpB * invFact[n - i - 1] % MOD;
        sum = (sum + (tmpA * tmpB) % MOD) %MOD;
    }
    cout << sum << endl;

}


Measured memory_bytes: 16768
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890l
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define space " "
#define cbr cout << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, dp[MAXN][2]; const ll MOD = (ll)1e9 + 7ll;
vector <int> v[MAXN];
void dfs(ll x, ll p)
{
	dp[x][0] = dp[x][1] = 1;
	for(auto i : v[x])
	{
		if(i==p) continue;
		dfs(i,x);
		dp[x][0] *= (dp[i][0] + dp[i][1]); dp[x][0] %= MOD;
		dp[x][1] *= dp[i][0]; dp[x][1] %= MOD;
	}
	return;
}
int main()
{
	FAST
	cin >> n;
	FOR(i,0,n-1)
	{
		ll a, b;
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}
	dfs(1,1);
	cout << (dp[1][0] + dp[1][1])%MOD << '\n';
}


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

int dist[21][21];

int main() {
    int n, m;
    char cm;
    cin >> n >> m;
    for (int i=0; i<21; ++i) {
        for (int j=0; j<21; ++j) {
            dist[i][j] = 1e6;
        }
    }
    int a, b, c, d;
    for (int i=0; i<m; ++i) {
        cin >> a >> cm >> b >> cm >> c >> cm >> d;
        dist[a][b] = c;
        dist[b][a] = d;
    }
    int x1, x2, y1, y2;
    cin >> x1 >> cm >> x2 >> cm >> y1 >> cm >> y2;
    for (int k=0; k<21; ++k) {
        for (int i=0; i<21; ++i) {
            for (int j=0; j<21; ++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    cout << y1 - y2 - dist[x1][x2] - dist[x2][x1] << endl;
    return 0;
}

Measured memory_bytes: 1160
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=Number(r[0]),n=[],o=[],u=0;u<t;u++){var i=r[u+1].split(" ").map(function(e){return Number(e)-1});o.push(i[0]),n.push(i)}for(var f=t*(t-1)/2,l=new Array(t).fill(0),a=new Array(t).fill(0),c=[],p=0;p<t;p++)c.push(p);for(var s=0,d=0;c.length>0;){var b=c.shift();if(o[o[b]]==b){d+=1;var v=o[b],y=Math.max(a[b],a[v])+1;s<y&&(s=y),a[b]=y,a[v]=y,l[b]+=1,l[v]+=1,l[b]!=t&&(o[b]=n[b][l[b]],o[o[b]]==b&&c.push(b)),l[v]!=t&&(o[v]=n[v][l[v]],o[o[v]]==v&&c.push(v))}}d==f?console.log(s):console.log(-1)}},function(e,r){e.exports=require("fs")}]);

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    string s;
    cin >> s;
    int a = ctoi(s[0]);
    int b = ctoi(s[1]);
    int c = ctoi(s[2]);
    int d = ctoi(s[3]);

    
    int ans = 0;
    
    char p[3];

    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                if(i==0){
                    ans=a+b;
                    p[0]='+';
                }else{
                    ans=a-b;
                    p[0]='-';
                }
                if(j==0){
                    ans+=c;
                    p[1]='+';
                }else{
                    ans-=c;
                    p[1]='-';
                }
                if(k==0){
                    ans+=d;
                    p[2]='+';
                }else{
                    ans-=d;
                    p[2]='-';
                }


                if(ans==7){
                    cout << a << p[0] << b << p[1] << c << p[2] << d <<"=7" << endl; 
                    return 0;
                }
            }
        }
    }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   string s;cin >>s;
   int ans=s.size();
    for (int i = 0; i < s.size(); ++i) {
        if(s[i]=='A'){
            ans-=i;
            break;
        }
    }
    reverse(all(s));
    for (int i = 0; i < s.size(); ++i) {
        if(s[i]=='Z'){
            ans-=i;
            break;
        }
    }
    cout <<ans<<endl;
}


Measured memory_bytes: 3756
def examA():
    O = SI()
    E = SI()
    ans = ""
    for i in range(len(O)+len(E)):
        if i%2==0:
            ans += O[i//2]
        else:
            ans += E[i//2]
    print(ans)
    return

def examB():
    A = LI()
    A.sort()
    ans = (A[2] - A[0]) // 2 + (A[2] - A[1]) // 2
    if (A[2]-A[0])%2==1:
        ans += 1
        if (A[2]-A[1])%2==0:
            ans += 1
    elif (A[2]-A[1])%2==1:
        ans += 2
    print(ans)
    return

def examC():
    S = SI()
    S.replace("RL","A")
    S.replace("LR","B")
    N = len(S)
    A = [0]*N
    print(S)
    l = 0; r = 0
    for i,s in enumerate(S):
        if s=="A":
            A[i] += r
        elif s=="B":
            A[i] += l
    ans = 0
    print(ans)
    return

def examD():
    def warshall_floyd(n, d):
        # d[i][j]: iからjへの最短距離
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j])
        return d
    H, W = LI()
    C = [LI()for _ in range(10)]
    A = [LI()for _ in range(H)]
    C = warshall_floyd(10,C)
    ans = 0
    for i in range(H):
        for j in range(W):
            a = A[i][j]
            if a==-1:
                continue
            ans += C[a][1]
    print(ans)
    return

def examE():
    N, M = LI()
    V = [[]for _ in range(N)]
    for _ in range(M):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)

    def dfs(s,visited):
        #print(s,visited)
        res = 0
        visited.add(s)
        if len(visited)==N:
            visited.remove(s)
            return 1
        for ne in V[s]:
            if ne in visited:
                continue
            res += dfs(ne,visited)
        visited.remove(s)
        return res

    visited = set()
    ans = dfs(0,visited)
    #print(visited)
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examE()

"""

"""

Measured memory_bytes: 5232
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 987654319 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main()
{
	ll n, k;
	cin >> n >> k;
	vector <ll> A(n);
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	sort(all(A));
	vector <ll> F(n);
	for (int i = 0; i < n; i++)
	{
		cin >> F[i];
	}
	sort(all(F));
	reverse(all(F));
	auto check = [&](ll mid)
	{
		ll rem = k;
		for (int i = 0; i < n; i++)
		{
			if(A[i] * F[i] <= mid)
				continue;
			rem -= (A[i] * F[i] - mid + F[i] - 1) / F[i];
		}
		return rem >= 0;
	};
	ll lo = 0, hi = 1e12, ans = -1;
	while(lo <= hi)
	{
		ll mid = (lo + hi) / 2;
		if(check(mid))
		{
			ans = mid;
			hi = mid - 1;
		}
		else
		{
			lo = mid + 1;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3328
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);
#define asc(A) sort(A.begin(),A.end())
#define dsc(A) sort(A.begin(),A.end(),greater<ll>())
#define input(A,N) for(ll i=0;i<N;i++) cin>>A[i];
int main()
{
    fasino
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    #endif
    ll a;
    double b;
    cin>>a>>b;
    ll b2=round(b*100.00);
    // cou<<a<<b;
    auto k = a*b2/100;
    cout<<(long long)k;
    return 0;
}

Measured memory_bytes: 3752
#include <iostream>

using namespace std;

u_int64_t height[51];
u_int64_t pates[51];

u_int64_t solve(int level, u_int64_t x)
{
    u_int64_t result = 0;

    if (x == 0)
    {
        return 0;
    }
    if (level == 0)
    {
        return 1;
    }

    if (x <= 1)
    {
        return result;
    }
    x -= 1;

    if (x <= height[level - 1])
    {
        return solve(level - 1, x);
    }
    result += pates[level - 1];
    x -= height[level - 1];

    result += 1;
    if (x <= 1)
    {
        return result;
    }
    x -= 1;

    if (x <= height[level - 1])
    {
        return result + solve(level - 1, x);
    }
    result += pates[level - 1];
    x -= height[level - 1];

    return result;
}

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

    pates[0] = 1;
    height[0] = 1;
    for (int i = 1; i <= N; i++)
    {
        pates[i] = 2 * pates[i - 1] + 1;
        height[i] = 2 * height[i - 1] + 3;
    }

    u_int64_t result = solve(N, X);
    cout << result << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int S,h,m,s;
    scanf("%d",&S);
    h=S/3600;
    S=S%3600;
    m=S/60;
    s=S%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
   int N,M,K;
   cin>>N>>M>>K;
   vector<int> A (N+1,0);
   for (int i = 0; i < N; i++)
   {
      cin>>A[i+1];
   }
   vector<int> B (M+1,0);
   for (int i = 0; i < M; i++)
   {
      cin>>B[i+1];

   }
   for (int i = 0; i < N; i++)
   {
     A[i+1] += A[i];
   }
   for (int i = 0; i < M; i++)
   {
     B[i+1] += B[i];
   }
   int res = 0;

   for (int i = 0; i <= N; i++)
   {
     int T = A[i];
     if(T > K)continue;
     int D = distance(B.begin(),upper_bound(ALL(B),K - T));
     chmax(res,D + i -1);

   }
   cout<<res<<endl;
   
   
   

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int H,W;
  cin >> H >>W;
  for (int i = 0; i < W+2; i++) {
    cout<<'#';
}
  cout<<endl;
  for (int i = 0; i < H; i++) {
    cout<<'#';
    string s;
    cin>>s;
    cout <<s;
    cout<<'#';
    cout<<endl;
}
  for (int i = 0; i < W+2; i++) {
    cout<<'#';
}
  return 0;
}

Measured memory_bytes: 384
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

fn main() {
    let s = readl!(String);
    let s = s.into_bytes();
    let n = s.len();
    let INF = n+10;
    let mut dp = std::collections::HashMap::new();
    dp.insert(0, 0);
    let mut tmp = 0;
    let mut ans = 0;
    for i in 0..n {
        let c = s[i] -'a' as u8;
        tmp ^= 1<<c;
        let mut val = INF;
        for j in 0..26 {
            let t = tmp^(1<<j);
            if let Some(x) = dp.get(&t) {
                val = std::cmp::min(val, *x+1);
            }
        }
        if let Some(x) = dp.get(&tmp) {
            val = std::cmp::min(val, *x+1);
        }
        ans = val;
        let a = dp.entry(tmp).or_insert(INF);
        *a = std::cmp::min(*a, val);
    }
    println!("{}", ans);
}



Measured memory_bytes: 17172
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

ll f[100000];
ll fib(ll i) {
    if (i == 0)return 0;
    if (i == 1)return 1;
    if (f[i])return f[i];
    return f[i] = (fib(i - 1) + fib(i - 2)) % mod;
}

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

    int n, m;
    cin >> n >> m;
    VI a(m + 2);

    a[0] = -1;
    eFOR(i, 1, m)cin >> a[i];
    a[m + 1] = n + 1;

    VI s;
    eFOR(i, 0, m) {
        if (!(a[i + 1] - a[i] - 1)) {
            cout << 0 << "\n";
            return 0;
        }
        s.push_back(a[i + 1] - a[i] - 1);
    }

    ll ans = 1;
    for (int i : s) {
        ans *= fib(i);
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
import java.util.*;

class Reader {
  Scanner sc = new Scanner(System.in);

  public int ini() {
    return sc.nextInt();
  }

  public int[] vi(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++) a[i] = sc.nextInt();
    return a;
  }
}

public class Main extends Reader {
  public static void main(String[] args) {
    Main main = new Main();
    main.show(main.solve());
  }

  int n;
  int[] a;

  public Main() {
    n = ini();
    a = vi(n);
  }
  
  int solve() {
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        ans += a[i] * a[j];
      }
    }
    return ans;
  }

  void show(int ans) {
    System.out.println(ans);
  }
}


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

#define chmax(x, y) (x = max(x, y))

int n, m;
string s, t;
int a[2010], b[2010];
int dp[2010][2010][2];

int main()
{
  cin >> n >> m >> s >> t;
  for (int i = 0; i < n; i++) a[i] = s[i] == 'O';
  for (int i = 0; i < m; i++) b[i] = t[i] == 'O';

  int res = 0;
  for (int i = 0; i < 2010; i++){
    for (int j = 0; j < 2010; j++){
      dp[i][j][0] = 0;
      dp[i][j][1] = -1001001001;
    }
  }
  for (int i = 0; i <= n; i++){
    for (int j = 0; j <= m; j++){
      if (i < n){
        chmax(dp[i + 1][j][a[i] ^ 1], dp[i][j][a[i]] + 1);
      }
      if (j < m){
        chmax(dp[i][j + 1][b[j] ^ 1], dp[i][j][b[j]] + 1);
      }
      chmax(res, dp[i][j][1]);
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 34784
from sys import stdin

def gcd(a,b):
    if a<b:
        tmp=a
        a=b
        b=tmp
    r=a%b
    while r!=0:
        a=b
        b=r
        r=a%b
    return b

k=int(input())
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            ans+=gcd(i,gcd(j,k))
print(str(ans)+"\n")

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

ll digit(ll num)
{
    ll dig;
    ll sum = 0;
    while(num){
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
    }
    return sum;
}
ll fastpow(ll _x,ll _n)
{
    ll ret = 1;
    while(0 < _n)
    {
        if((_n % 2) == 0)
        {
            _x = (_x*_x);
            _n >>= 1;
        }
        else
        {
            ret = (ret*_x);
            --_n;
        }
    }
    return ret;
}

int atcoder(){
    ll n;
    cin>>n;
  	ll ans = digit(n);
    REPL(i,0,log10(n)) chmax(ans,digit(n-n%fastpow(10,i)-1));
    cout<<ans<<ENT;
    return 0;
}


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


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

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

int gcd(int a,int b)//O(log max(a,b)) 
{
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main()
{
    int a,b, g;
    while(cin >> a >> b)
    {
        g = gcd(a,b);
        cout << g << " " << (a / g) * b << endl;
        
    }
    return 0;

}

Measured memory_bytes: 0
#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 main(){
    string S;
    cin>>S;
    S.at(5)=' ';
    S.at(13)=' ';
    cout << S<<endl;
    return 0;
}

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

using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define CASES int t;cin>>t;for (int tt = 1;tt <= t;tt++)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 1e6 + 5;
const int K = (1 << 17) + 10;	
const ll INF = 2e18 + 500;
const int inf = 0x7fffffff;
const int SQRT = 500;
const int lgN = 20;

ll seen[N];
int h[N];
int n;

ll dfs(int node) {
	if (node == n) return 0;
	int jump = 1;
	// cout << "node " << node << endl;
	if (node + jump > n) return seen[node] = INF;
	if (seen[node] != -1) return seen[node];
	ll a = abs(h[node] - h[node + jump]) + dfs(node + jump);
	ll b = abs(h[node] - h[node + jump + 1]) + dfs(node + jump + 1);
	seen[node] = min(INF, min(a, b));
	return seen[node];
}

int main(int argc, char const *argv[])
{
	fast;

	cin >> n;

	frep(i, 1, n) {
		seen[i] = -1;
		cin >> h[i];
	}

	cout << dfs(1) << '\n';

	return 0;
}

Measured memory_bytes: 7808
N, M = map(int, input().split())  # N頂点, M個のクエリ

counter = [0] * N

for _ in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    counter[a] += 1
    counter[b] += 1

flag = True
for i in range(len(counter)):
    if counter[i] % 2 != 0:
        flag = False


if flag:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
ll mod=1e9+7;
     
ll ceil1(ll n,ll k){
    if(n%k) return n/k+1;
    return n/k;
}
     
ll pow1(ll n,ll k){
        ll ans=1;
        while(k!=0){
            if(k%2) ans=(ans*n)%mod;
            n=(n*n)%mod;
            k=k/2;
        }
        return ans;
}

bool ispal(string s){
    ll i=0;
    ll j=s.size()-1;
    while(i<j){
        if(s[i]!=s[j]) return false;
        i++;
        j--;
    }
    return true;
}

ll gcdd(ll a,ll b){
    if(b==0) return a;
    return gcdd(b,a%b);
}

ll fact(ll n){
    if(n==1 || n==0) return 1;
    else return (n*fact(n-1))%mod;
}

bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

void solve(){
	ll n;
	cin>>n;
	vector<ll> a(n);
	for(ll i=0;i<n;i++) cin>>a[i];
	map<ll,ll> m,mp;
	for(ll i=0;i<n;i++) m[a[i]+i]++;
	for(ll i=0;i<n;i++) mp[i-a[i]]++;
	ll ans=0;
	for(auto i:m){
		ans+=i.second*mp[i.first];
	}
	cout<<ans<<endl;
	return;
}
	
int main(){    
      ios_base::sync_with_stdio(false);
      cin.tie(0);
      cout.tie(0);
      ll q=1;
      //cin>>q;
      while(q--){
        solve();
      }
      return 0;
}

Measured memory_bytes: 38972
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int c = sc.nextInt();
		int[] b1=new int[m];
		int ans=0;
		for(int i = 0; i<m; i++){
			b1[i]=sc.nextInt();
		}
		for(int i = 0; i<n; i++){
			int sum=c;
			for(int j=0; j<m; j++){
				sum+=b1[j]*sc.nextInt();
			}
			if(sum>0){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

int m;
ll k;

int main(){
  cin >> m >> k;
  if(k==0){
    rep(i,0,1<<m){
      if(i!=0) cout << " ";
      cout << i << " " << i;
    }
    cout << endl;
  }else if(m<=1){
    cout << -1 << endl;
  }else if(k<(ll)(1<<m)){
    vector<int> a;
    int kk = (int)k;
    rep(i,0,1<<m) if(kk!=i){
      a.push_back(i);
    }
    a.push_back(kk);
    for(int i=(1<<m)-1;i>=0;i--) if(kk!=i){
      a.push_back(i);
    }
    a.push_back(kk);
    rep(i,0,a.size()){
      if(i!=0)cout <<" ";
      cout << a[i];
    }
    cout << endl;  
  }else{
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 2932
#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 faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;


int main()
{
	faster
	string s,a;
	int i,j,ans,mx=0,l,k;
	cin>>s>>a;
	int x=a.size();
	int y=s.size();
	for(i=0;i<y-x+1;i++)
	{
		k=i;
		ans=0;
		for(j=0;j<a.size();j++)
		{
			if(a[j]==s[k])ans++;
			k++;
		}
		//cout<<ans<<nl;
		mx=max(mx,ans);
	}
	cout<<x-mx<<nl;
	return 0;
}


Measured memory_bytes: 3612