akhauriyash/Code-Regression huggingface dataset:
def numpwr(x, div):
    ans = 0
    while x%div==0:
        ans+=1
        x//=div
    return ans

n = int(input())
a = []
for i in range(n):
    a.append(input())

ints = []
for dec in a:
    loc = dec.find('.')
    need = 9
    if loc != -1:
        need = 9-(len(dec)-loc-1)
    dec = dec.replace('.', '')
    num = int(dec) * 10**need
    ints.append(num)

cnt = {}
for i in ints:
    key = (numpwr(i,2), numpwr(i,5))
    if key in cnt:
        cnt[key]+=1
    else:
        cnt[key] = 1

ans = 0
for p1 in cnt.items():
    for p2 in cnt.items():
        if p1[0][0]+p2[0][0]>=18 and p1[0][1]+p2[0][1]>=18:
            if p1 < p2:
                ans += p1[1]*p2[1]
            elif p1==p2:
                ans += p1[1]*(p1[1]-1)//2
            
print(ans)

Measured memory_bytes: 34464
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%I64d",&x)
#define ss(s)	scanf("%s",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;
const int N = 2e5;
vi g[N];
int a[N] ,cnt[N];

int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n,m,x,y;
	cin>>n>>m;
	clr(cnt);
	a[1] = 1;
	Fo(i, 1, n+1) cnt[i] = 1;
	Fo(i, 2, n+1) a[i] = 0;
	while(m--){
		cin>>x>>y;
		if (cnt[x] and a[x])
			a[y] = 1;
		cnt[x]--;
		cnt[y]++;
		if (!cnt[x] and a[x]) a[x] = 0;
	}
	int ans = 0;
	Fo(i, 1, n+1)
		ans += a[i];
	cout<<ans<<endl;
	
	return 0;
} 

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 6144
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

template <class Weight>
struct Edge {
  size_t src, dst;
  Weight cost;
  Edge(size_t src, size_t dst, Weight cost):
    src(src), dst(dst), cost(cost)
  {}
};

template <class Weight>
using Graph=std::vector<std::vector<Edge<Weight>>>;

template <class Weight>
constexpr Weight inf=(Weight(1)<<(8*sizeof (Weight)-3));

template <class Weight>
std::vector<Weight> bellman_ford(const Graph<Weight> &g, size_t s, bool &nl) {
  std::vector<Weight> dist(g.size(), inf<Weight>);
  dist[s] = 0;
  nl = false;
  for (size_t k=0; k<g.size(); ++k)
    for (size_t i=0; i<g.size(); ++i)
      for (const Edge<Weight> &e: g[i]) {
        if (dist[e.dst] > dist[e.src] + e.cost) {
          dist[e.dst] = dist[e.src] + e.cost;
          if (k+1 == g.size()) {
            dist[e.dst] = -inf<Weight>;
            nl = true;
          }
        }
      }

  return dist;
}

int main() {
  size_t N;
  int M;
  scanf("%zu %d", &N, &M);

  Graph<intmax_t> g(N);
  for (int i=0; i<M; ++i) {
    size_t a, b;
    intmax_t c;
    scanf("%zu %zu %jd", &a, &b, &c);

    --a;
    --b;
    g[a].emplace_back(a, b, -c);
  }

  bool negloop;
  intmax_t cost=bellman_ford(g, 0, negloop)[N-1];
  if (cost == -inf<intmax_t>) {
    printf("inf\n");
  } else {
    printf("%jd\n", -cost);
  }
}


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

int main (){
	int a, b;
	
	cin >> a >> b;
	
	if (a==b) cout << "Draw" << endl;
	else if (a==1) cout << "Alice" << endl;
	else if (b==1) cout << "Bob" << endl;
	else if (a>b) cout << "Alice" << endl;
	else cout << "Bob" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, -1, 1, 1, -1 };

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

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    int n = inp1;
    vector<ll> a = inp(n);

    vector<ll> sum(n + 1, 0LL);
    rep(i, n) sum[i + 1] = sum[i] + a[i];

    ll ans = infll;
    rep(i, n - 1) {
        chmin(ans, abs(sum[n] - 2 * sum[i + 1]));
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int c;
	switch (n%10)
	{
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon";
		break;
	case 3:
		cout << "bon";
		break;
	default:
		cout << "pon";
		break;
	}

	return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

void outputbin(ll x){
	return;
	string res;
	while(x){
		res += '0'+x%2;
		x /= 2;
	}
	res += string(64-res.size(), '0');
	reverse(all(res));
	cerr<<res<<endl;
}

int main(){
	ll a, b;
	cin>>a>>b;
	if(a==b){
		cout<<1<<endl;
		return 0;
	}
	outputbin(a); outputbin(b);
	ll x = 1;
	while((x<<1)<=b) x<<=1;

	while((a&x)==(b&x)){
		if(a&x){
			a ^= x;
			b ^= x;
		}
		x>>=1;
	}
	{
		ll y = x;
		y>>=1;
		while(y && !(y&b)) y>>=1;
		while(y){
			b |= y;
			y >>= 1;
		}
	}
	cerr<<x<<endl;
	outputbin(a); outputbin(b);

	outputbin(a); outputbin(b);
	//cerr<<a<<" "<<b<<endl;
	ll res = 0, c = x;
	ll d = x|a, e = 2*x;
	chmax(d, b+1);
	if(e>d) res = e-d;
	x>>=1;
	cerr<<"x"<<x<<endl;
	ll left = INF, right = 0;
	/*while(x){
		outputbin(c);
		if(a&x) c |= x;
		else {
			ll lb = max(c+x, b+1), ub = c+x*2;
			cerr<<lb<<" "<<ub<<endl;
			outputbin(lb);
			outputbin(ub);
			chmin(left, lb);
			chmax(right, ub);
			//if(lb<ub) res += ub-lb;
		}
		x>>=1;
	}*/
	//chmax(left, b+1);
	//if(right-left>=0) res += right-left+1;
	//cerr<<c<<endl;
	//if(c>b) res++;
	cout<<res+b-a+1<<endl;
	//cerr<<b-a+1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
 int a,b,c,d,l,r;
  cin >>a>>b>>c>>d;
  
  l=a+b; r=c+d;
  
  if(l>r) cout << "Left" << endl;
  else if(l<r) cout << "Right" << endl;
  else cout << "Balanced" << endl;
  
}

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

int main()
{
    int h, w;
    int i, j;
    
    cin >> h >> w;
    
    char a[h][w];
    int judgey[h];
    int judgex[w];
    
    for(i = 0; i < h; i++) { judgey[i] = 0; }
    for(j = 0; j < w; j++) { judgex[j] = 0; }
    
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {
            cin >> a[i][j];
            if(a[i][j] == '#') {
                judgey[i] = 1;
                judgex[j] = 1;
            }
        }
    }
    
    for(i = 0; i < h; i++) {
        if(judgey[i] == 1) {
            for(j = 0; j < w; j++) {
                if(judgex[j] == 1) {
                    cout << a[i][j];
                }
            }
        cout << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
s=list(input())

for i in range(len(s)):
  if i % 2 == 1:
    if s[i] == 'R':
      print("No")
      break
  elif i % 2 == 0:
    if s[i] == 'L':
      print("No")
      break
  if i == len(s)-1:
    print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const int MAXN = 45;
char A[MAXN][MAXN];
ll F[MAXN][MAXN][MAXN][MAXN];
ll G[MAXN][MAXN][MAXN];
int n, n2;
inline int inc(int x) {
	++x;
	if (x == n2) x = 0;
	return x;
}
inline int dec(int x) {
	--x;
	if (x < 0) x = n2 - 1;
	return x;
}
ll f(int, int, int, int);
ll g(int a, int x, int b) {
	ll& ret = G[a][x][b];
	if (ret != -1) return ret;
	if (a == x && b == x) return ret = 1;
	ret = 0;
	for (int i = a; i != x; i = inc(i)) {
		for (int j = b; j != x; j = dec(j)) {
			ret += f(a, i, j, b) * g(inc(i), x, dec(j));
		}
	}
	return ret;
}
ll f(int a, int b, int c, int d) {
	ll& ret = F[a][b][c][d];
	if (ret != -1) return ret;
	ret = 0;
	for (int i = a;; i = inc(i)) {
		for (int j = c;; j = inc(j)) {
			if (A[i][j] == '1') ret += g(a, i, b) * g(c, j, d);
			if (j == d) break;
		}
		if (i == b) break;
	}
	return ret;
}
int main() {
	scanf("%d", &n);
	n2 = n + n;
	for (int i = 0; i < n2; ++i)
		scanf("%s", A[i]);
	memset(F, -1, sizeof(F));
	memset(G, -1, sizeof(G));
	ll ans = 0;
	for (int i = 0; i < n2; ++i)
		for (int j = i + 1; j < n2; ++j) {
			if (A[i][j] == '1') {
				ans += g(inc(i), j, dec(i));
			}
		}
	assert(ans % n == 0);
	ans /= n;
	printf("%lld\n", ans);
}


Measured memory_bytes: 33024
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
void solve()
{
	string s,t;
	cin>>s>>t;
	ll n=t.length();
	s=s+t[n-1];
	if(s==t)
		cout<<"Yes";
	else
		cout<<"No";
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[1000010] , ar[1000100] , n , k ;
ll frog(ll i)
{
    if(i == n) return 0LL ;
    if(dp[i]!=-1)return dp[i] ;
    ll &kk = dp[i] ;
    ll l = 0 , a = 0 , f = 1 ;
    kk = frog(i+1)+abs(ar[i]-ar[i+1]) ;
    for(ll j = 2 ; j <= k ; j++)
    {
        if(j+i <= n)
        {
            kk = min(kk , frog(i+j)+abs(ar[i]-ar[i+j])) ;
        }
    }
  //  cout<<i<<" "<<kk<<endl ;
    return kk ;
}
int main()
{
    memset(dp,-1,sizeof(dp)) ;
    cin>>n>>k ;
    for(ll i = 1 ; i <= n ; i++) cin>>ar[i] ;
    ll kk  = frog(1) ;
  //  for(ll i = 1 ; i <= n ; i++) cout<<dp[i]<<" " ;
 //   cout<<endl ;
    cout<<kk<<endl ;
}


Measured memory_bytes: 13696
k,s = map(int,input().split())
a = ((s+1)*(s+2))//2
b = ((s-k)*(s-k+1))//2
c = (((abs(s-k*3))+1)*((abs(s-k*3))+2))//2

if s <= k:
    print(a)
elif s <= k*2:
    print(a-b*3)
elif s <= k*3:
    print(c)

Measured memory_bytes: 3064
n, m = map(int, input().split())
P = list(map(int, input().split()))

# union-Find##
par = [-1] * (n + 1)


def root(x):
    if par[x] < 0:
        return x
    else:
        par[x] = root(par[x])
        return par[x]


def unite(x, y):
    a = root(x)
    b = root(y)
    if a == b:
        return False
    else:
        if par[a] > par[b]:
            a, b = b, a
        par[a] += par[b]
        par[b] = a
        return True


def is_same(x, y):
    return root(x) == root(y)


def size(x):
    return -par[root(x)]


# union-find##

for _ in range(m):
    x, y = map(int, input().split())
    unite(x, y)

cnt = 0
for i in range(n):
    if is_same(P[i], i + 1):
        cnt += 1
print(cnt)


Measured memory_bytes: 14008
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=233;
const int mod=1e9+7;
int n,k,inv[N],jc[N],jcn[N],a[N],ans;
char str[N];
int C(int x,int y){
	return 1ll*jc[x]*jcn[y]%mod*jcn[x-y]%mod;
}
int cal(int x,int y){
	return C(x+y-1,y-1);
}
void check(int y,int z){
	int lim=0;while(lim<y&&a[lim+1]>1)++lim;
	int cnt_r=0,cnt_b=0,cnt=0;
	for(int i=1;i<=k;++i)
		if(str[i]=='r'&&cnt_r<y)
			++cnt_r;
		else if(str[i]=='b'&&cnt_b<min(cnt_r,lim))
			++cnt_b,cnt+=a[cnt_b]-2;
		else if(cnt)
			--cnt;
	if(cnt_r<y||cnt_b<lim||cnt)return;
	int pos=y+1,res=jc[y];
	for(int i=1,j=1;i<=y;i=j=j+1){
		while(j<y&&a[j+1]==a[i])++j;
		res=1ll*res*jcn[j-i+1]%mod;
		pos+=(j-i+1)*(a[i]+a[i]-1);
	}
	ans=(ans+1ll*res*cal(n-z,pos))%mod;
}
void dfs(int x,int y,int z){
	if(z>n)return;check(y,z);
	for(int i=x;i;--i)a[y+1]=i,dfs(i,y+1,z+(y>0)+(i>1?i+i-3:1));
}
int main(){
	scanf("%d%d%s",&n,&k,str+1);
	jc[0]=jcn[0]=inv[1]=1;
	for(int i=2;i<N;++i)inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	for(int i=1;i<N;++i)jc[i]=1ll*jc[i-1]*i%mod,jcn[i]=1ll*jcn[i-1]*inv[i]%mod;
	dfs(70,0,0);printf("%d\n",ans);return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())
num = list(map(int, input().split()))
kirai = [0]*10
for i in num:
    kirai[i] = 1

MAXX = 100000
for n in range(N, MAXX):
    tmp = n
    good = True
    while tmp > 0:
        d = tmp % 10
        tmp = tmp//10
        if kirai[d]:
            good = False
            break
    if good:
        break

print(n)



Measured memory_bytes: 66772
from collections import Counter
N=int(input())
A=list(map(int, input().split()))
for i in range(N):
    A[i]=0 if A[i]>=3200 else A[i]//400+1
c=len(Counter(A))-(0 in Counter(A))
n=Counter(A)[0]
print(c if c else 1, n+c)


Measured memory_bytes: 3316
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <sstream>
#include <utility>
#include <bitset>
#include <stack>

using namespace std;

#define MP make_pair 
#define PB push_back 
#define INF (1000000007) 
#define eps 1e-8
#define MOD (1000003)
#define IOS ios::sync_with_stdio(false)

typedef pair<int,int> pii ;
typedef long long ll ;

double a,b,c,d,e,f;
int A,B,C,D;
double q;

int main()
{
	cin>>a>>b>>c>>d>>e>>f;
	a*=100,b*=100;
	e=e/(e+100);
	for(int i=0;i<=f/a;i++)
	{
		for(int j=0;j<=f/b;j++)
		{
			if(a*i+b*j>f || i+j==0) break;
			for(int k=0;k<=f/c;k++)
			{
				if(a*i+b*j+c*k>f) break;
				int t=0,w=(f-a*i-b*j-c*k)/d;
				while(t<=w)
				{
					int mid=(t+w)/2;
					double t1=a*i+b*j+c*k+d*mid;
					double t2=c*k+d*mid;
					if(t2/t1<=e) t=mid+1;
					else w=mid-1;
				}
				w=max(w,0);
				double t1=a*i+b*j+c*k+d*w;
				double t2=c*k+d*w;
				if(t2/t1>e) continue;
				if(i+j+k+w==0) continue;
				if((double)t2/(double)t1>=q) 
				{
					q=(double)t2/(double)t1;
					A=i,B=j,C=k,D=w;
				}
			}
		}
	}
//	cout<<A<<" "<<B<<" "<<C<<" "<<D<<endl;
	cout<<C*c+D*d+A*a+B*b<<" "<<C*c+D*d;
	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> cycle = new List<string> { "Sunny", "Cloudy", "Rainy", "Sunny" };
            Dictionary<string, int> weatherName = new Dictionary<string, int>
            {
                { "Sunny", 0 },
                { "Cloudy", 1 },
                { "Rainy",2 }
            };
            string today = Console.ReadLine();
            Console.WriteLine(cycle[weatherName[today] + 1]);
        }

    }
}


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

#define f(i,x,y)			for(int i=x; i<y; i++)
#define ll 					long long 
#define mp 					make_pair
#define F 					first
#define S 					second
#define N 					100005
#define mod 				1000000007

ll dp[22][1<<22];
int n;
ll func(vector <vector <int> > &a, int n, int i, int Women)
{
	if(i == n)
	{
		if(Women==0)
			return 1;
		return 0;
	}
	if(dp[i][Women] != -1)
		return dp[i][Women];

	ll ans = 0;
	for(int w = 0; w<n; w++)
	{
		bool available = Women & (1<<w);
		if(available && a[i][w]==1)
		{
			ans = (ans + func(a,n,i+1,Women^(1<<w)))%mod;
		}
	}
	return dp[i][Women] = ans;
}

int main()
{
	cin>>n;
	vector <vector <int> > a(n, vector <int> (n));
	//int a[n][n];
	memset(dp,-1,sizeof(dp));
	f(i,0,n)
		f(j,0,n)
			cin>>a[i][j];

ll ans = func(a,n,0,(1<<n)-1);
cout<<ans;

	return 0;
}

Measured memory_bytes: 721280
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define N 101000
#define ll long long
using namespace std;
int n,m;
ll a[N],f[N],ans[N];
void dg(ll x,ll l)
{
	if(l==0) return;
	if(l<a[1])
	{
		ans[l]+=x;
		return;
	}
	int q=1,w=m,i;
	while(q+1<w)
	{
		int mid=(q+w)/2;
		if(a[mid]<=l) q=mid;
		else w=mid;
	}
	if(a[w]<=l) q=w;i=q;
	f[i]+=x*(l/a[i]);
	dg(x,l%a[i]);
}
int main()
{
	scanf("%d%d",&n,&m);
	int tot=1;
	a[1]=n;
	fo(i,1,m)
	{
		ll x;scanf("%lld\n",&x);
		while(tot>0&&x<=a[tot]) tot--;
		a[++tot]=x;
	}
	m=tot;f[m]=1;
	fd(i,m,2)
	{
		f[i-1]+=f[i]*(a[i]/a[i-1]);
		dg(f[i],a[i]%a[i-1]);
	}
	fd(i,a[1],1) ans[i]+=ans[i+1];
	fo(i,1,a[1]) ans[i]+=f[1];
	fo(i,1,n) printf("%lld\n",ans[i]);
}

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

using namespace std;

int main(){
	string s;
	int k;
	cin>>k>>s;
	if(s.size()<=k){
		cout<<s<<'\n';
	}
	else{
		for(int i=0;i<s.size()-(s.size()-k);i++){
			cout<<s[i];
		}
		cout<<"..."<<'\n';
	}
	return 0;
} 

Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
 
#define long long long int
 
using namespace std;
 
// @author: pashka
 
int main() {
    ios::sync_with_stdio(false);
 
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(n);
    for (int i = 0; i < n; i++) a[i] = s[i] == 'R' ? i + 1 : i - 1;
    for (int i = 0; i < 100; i++) {
        vector<int> b = a;
        for (int j = 0; j < 9; j++) {
            vector<int> c(n);
            for (int i = 0; i < n; i++) {
                c[i] = a[b[i]];
            }
            b = c;
        }
        a = b;
    }
    vector<int> res(n);
    for (int i = 0; i < n; i++) res[a[i]]++;
    for (int i = 0; i < n; i++) cout << res[i] << " ";
 
    return 0;
}

Measured memory_bytes: 1616
#!/usr/bin/env python3
import sys


def solve(c: "List[str]"):
    ret = c[0][0] + c[1][1] + c[2][2]
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    c = [ next(tokens) for _ in range(3) ]  # type: "List[str]"
    solve(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>

 

using namespace std;

 

int main()
{
    int i, x;
    for(i=1; i<=10000; i++)
    

    {
        cin >> x;
        if(x==0) 
         break;
        cout << "Case " << i <<": " << x << endl;
        
    
    }
}


Measured memory_bytes: 3004
#include <iostream>
#include <bits/stdc++.h>
#include <cstdlib>
#include <string>
using namespace std;

int main()
{
    int x = 0;
    int n = 0, m = 0;

    cin >> x;

    n = x / 500;

    m = (x % 500) / 5;


    cout << n * 1000 + m * 5 << endl;

    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
int main(){
   ll A, B, Q; cin >> A >> B >> Q;
   Vi s(A + 2), t(B + 2), x(Q);
   s[0] = -INF, s[A+1] = INF, t[0] = -INF, t[B+1] = INF;
   REP(i, A) cin >> s[i+1];
   REP(i, B) cin >> t[i+1];
   REP(i, Q) cin >> x[i];

   REP(i, Q){
      ll ans = INF;
      auto lb_s = lower_bound(s.begin(), s.end(), x[i]);
      auto lb_t = lower_bound(t.begin(), t.end(), x[i]);

      ll a[2][2];
      a[0][0] =  *(lb_s - 1);
      a[0][1] = *lb_s;
      a[1][0] = *(lb_t - 1);
      a[1][1] = *lb_t;
      REP(p, 2){
         REP(q, 2){
            REP(r, 2){
               chmin(ans, abs(x[i] - a[p][q]) + abs(a[p][q] - a[1-p][r]));
            }
         }
      }
      cout << ans << endl;
   }

}


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

string S;
void search(string ret, int val, int p, bool &done){
  if (done){return;}
  if (p == S.size() - 1){
    if (val + S[p] - '0' == 7){cout << ret+"+"+S[p]+"=7" << endl;done=true;return;}
    if (val - S[p] + '0' == 7){cout << ret+"-"+S[p]+"=7" << endl;done=true;return;}
    return;
  }
  search(ret+"+"+S[p], val + S[p] - '0', p+1, done);
  search(ret+"-"+S[p], val - S[p] + '0', p+1, done);
  return;
}

int main(){
  cin >> S;
  bool done = false;
  string ret;

  ret = S[0];

  search(ret, S[0] - '0', 1, done);
  if (!done){cout << "error" << endl;}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        List<String> str = new ArrayList<>();
        HashMap<String,String> map = new HashMap<String,String>();
        try{
            while(true){
                str.add(sc.nextLine());    
            }
        } catch(Exception e){
        }
        int count = 0;
        for(int i=1;i<=Integer.parseInt(str.get(0));i++){
            if(!map.containsKey(str.get(i))){
                map.put(str.get(i),"OK");
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 81412
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#include <iostream>
using namespace std;

int main() {
	ll int n,k;
	cin>>n>>k;
	vector<ll int> a(n);
	for(ll int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	ll int dp[n+1][k+1];
	memset(dp,0,sizeof(dp));
	//dp[0][0]=1;
	for(ll int i=0;i<=k;i++){
		dp[1][i]=i>a[0]?0:1;
	}
	
	ll int s=0;
	for(ll int i=2;i<=n;i++){
		s+=a[i-1];
		for(ll int j=0;j<=k;j++){
			if(j==0)dp[i][j]=1;
		//	if(j>s)break;
			else if(j!=0){
				dp[i][j]=((dp[i][j-1]%mod)+(dp[i-1][j]%mod)+dp[i][j]%mod)%mod;
			}
			if(j>a[i-1]){
				ll int t=j-a[i-1];
				dp[i][j]=mod+dp[i][j]%mod-dp[i-1][t-1]%mod;
			}
			dp[i][j]=dp[i][j]%mod;
		}
	}
	cout<<dp[n][k];
	return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    map<char,int> m[n+1];
    for(int i=n-1;i>=0;i--)
    {
        for(char c:"RGB") m[i][c]=m[i+1][c];
        m[i][s[i]]++;
    }
    auto f=[](char a,char b)->char
    {
        string t="RGB";
        for(int i=0;i<3;i++) if(t[i]!=a&&t[i]!=b) return t[i];
    };
    ll res=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(s[i]==s[j]) continue;
            res+=m[j+1][f(s[i],s[j])];
            if(j+(j-i)<n&&s[j+(j-i)]==f(s[i],s[j])) res--;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4540
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n){
        char c = s[i];
        if(s[i]=='?') c = 'D';
        cout << c;
    }
    cout << endl;
}

Measured memory_bytes: 3756
import math
a, b, C = map(float, input().split())
C = math.radians(C)
print(1/2 * a * b * math.sin(C))
c = (a ** 2 + b ** 2 - 2 * a * b * math.cos(C)) ** 0.5
print(a + b + c)
print(b * math.sin(C))


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

int main()
{
   long double a, b, c;
   cin>>a>>b>>c;

   if ((2 * sqrt(a*b) < c - a - b))
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		List<Integer> mochi = new ArrayList<>();

        for (int i = 0; i < N; i++) {
        	mochi.add(scanner.nextInt());
        }
        Collections.sort(mochi);

		int count = 1;
		for (int i = 0; i < N; i++) {
			if (i == 0) {
			    continue;
			}
			if (mochi.get(i) != mochi.get(i-1)) {
			    count++;
			}
		}
		System.out.println(count);

	}

}

Measured memory_bytes: 21716
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	int[] ax = new int[4];
	int[] ay = new int[4];
	int ans;
	int nextNum;
	int[][] board = new int[4][4];

	void dfs(int r, int c) {
		if (r == 4) {
			ans++;
			return;
		}
		if (c == 4) {
			dfs(r + 1, 0);
			return;
		}
		if (board[r][c] != -1) {
			dfs(r, c+1);
			return;
		}
		for (int i = 0; i < 4; i++) {
			int x1 = r;
			int y1 = c;
			int x2 = r + ax[i];
			int y2 = c + ay[i];
			if (0 <= x2 && x2 < 4 && 0 <= y2 && y2 < 4 && board[x2][y2] == -1) {
				board[x1][y1] = board[x2][y2] = nextNum;
				nextNum++;
				dfs(r, c+1);
				board[x1][y1] = board[x2][y2] = -1;
				nextNum--;
			}
		}
	}

	void solve() {
		for (int i = 0; i < 4; i++) {
			int x = sc.nextInt();
			if (x >= 4) return;
			int y = sc.nextInt();
			if (x < 0) {
				x *= -1;
				y *= -1;
			}
			if (x == 0 && y < 0) {
				y *= -1;
			}
			ax[i] = x;
			ay[i] = y;
		}
		ans = 0;
		nextNum = 0;
		for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) board[i][j] = -1;
		dfs(0, 0);
		out.println(ans);
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
bool ischar(char c){
	if('A'<=c&&c<='Z')return true;
	else return false;
}
signed main(){
	int n;
	cin>>n;
	int a[200010];
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	bool ans=true;
	for(int i=0;i<n-1;i++){
		if(a[i]==a[i+1])ans=false;
	}
	if(ans)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;

map<string,int> M;
string s;
int cnt,Max;
int a[105];

int main()
{
	int n,m;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(M[s])
			a[M[s]]++;
		else
		{
			M[s]=++cnt;
			a[M[s]]++;
		}
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		cin>>s;
		if(!M[s])
			continue;
		else
			a[M[s]]--;
	}
	for(int i=1;i<=100;i++)
		Max=max(a[i],Max);
	printf("%d",Max);
	return 0;
}

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

const int mx = 10005;

int v, e, q, scnt = 0;
int b[mx]; // dsu
vector<int> adj[mx], radj[mx], scc[mx], qu;
bool vis1[mx], vis2[mx];

int d_find(int u) {
  if (b[u] == u) return u;
  return b[u] = d_find(b[u]);
}

int d_union(int u, int v) {
  b[d_find(v)] = d_find(u);
}

void dfs(int n) {
  vis1[n] = true;
  for (int h : adj[n]) if (!vis1[h]) dfs(h);
  qu.push_back(n);
}

void rdfs(int n, int k) {
  vis2[n] = true;
  scc[k].push_back(n);
  for (int h : radj[n]) if (!vis2[h]) rdfs(h, k);
}

int main() {
  for (int i = 0; i < mx; i++) b[i] = i;
  cin >> v >> e;
  for (int i = 0; i < e; i++) {
    int s, t; cin >> s >> t;
    adj[s].pb(t); radj[t].pb(s);
  }
  for (int i = 0; i < v; i++) if (!vis1[i]) dfs(i);
  for (int i = v - 1; i >= 0; i--) if (!vis2[qu[i]]) rdfs(qu[i], scnt++);
  for (int i = 0; i < scnt; i++)
    for (int j = 1; j < scc[i].size(); j++)
      d_union(scc[i].front(), scc[i][j]);
  cin >> q;
  for (int i = 0; i < q; i++) {
    int u, v; cin >> u >> v;
    cout << (d_find(u) == d_find(v)) << endl;
  }
}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Sum of gcd of Tuples (Easy)
            int K = int.Parse(Console.ReadLine());
            var nums = new List<int[]>();

            for(int i = 1; i <= K; i++)
            {
                for (int j = 1; j <= K; j++)
                {
                    for (int k = 1; k <= K; k++)
                    {
                        var arr = new int[3];
                        arr[0] = i;
                        arr[1] = j;
                        arr[2] = k;
                        nums.Add(arr);
                    }
                }
            }

            long ans = 0;

            foreach(var n in nums)
            {
                ans += GetGcd(n);
            }

            Console.WriteLine(ans);
        }

        static long GetGcd(int[] nums)
        {
            var a = (long)nums[0];
            var b = (long)nums[1];
            var c = (long)nums[2];

            var lib = new Library.Gcd();
            var gcd = lib.GetGcd(a, b);
            return lib.GetGcd(gcd, c);
        }
    }
}

namespace Library
{
    public class Gcd
    {
        public long GetGcd(long a, long b)
        {
            //[summary]a,b2つの数の最大公約数を求める
            //Gcd: Greatest Common Divisor
            //以下リンクを参考に実装
            //https://qiita.com/gushwell/items/e9614b4ac2bea3fc6486

            if (a < b)
            {
                //引数を入れ替えて自分を呼び出す
                return GetGcd(b, a);
            }
            else
            {
                while (b > 0)
                {
                    long remainder = a % b;

                    a = b;
                    b = remainder;
                }

                return a;
            }
        }
    }
}

Measured memory_bytes: 486120
(defun solve (n s)
  (let ((i 0)
        (count 0))
    (loop
      (when (<= n i)
        (return count))
      (let ((char (aref s i)))
        (incf count)
        (loop for j from (1+ i) below n
              while (char= char (aref s j))
              finally (setf i j))))))

#-swank
(let* ((n (read))
       (s (read-line)))
  (format t "~A~%" (solve n s)))


Measured memory_bytes: 6756
#include<stdio.h>

#define MAX 100005
#define NIL -1

struct Node_struct{

  int p, l, r;   /* p:親　l:一番左の子　r:右の兄弟 */
};
typedef struct Node_struct Node;

Node T[MAX];
int D[MAX];

void print(int);
void calcDepth(int, int);

void print(int u){

  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p == NIL)
    printf("root, ");

  else if(T[u].l == NIL)
    printf("leaf, ");

  else printf("internal node, ");

  printf("[");
  for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

void calcDepth(int u, int p){

  D[u] = p;
  if(T[u].l != NIL)
    calcDepth(T[u].l, p + 1);

  if(T[u].r != NIL)
    calcDepth(T[u].r, p);
}

int main(){

  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    T[i].p = T[i].l = T[i].r = NIL;

 for(i = 0; i < n; i++){
    scanf("%d %d", &id, &k);

    for(j = 0, sib = NIL; j < k; j++){
      scanf("%d", &child);
      T[child].p = id;

      if(j == 0)
        T[id].l = child;

      else T[sib].r = child;

      sib = child;
    }
  }

  for(i = 0; i < n; i++){

    if(T[i].p == -1)
      root = i;
  }
  
   calcDepth(root, 0);

  for(i = 0; i < n; i++)
    print(i);

  return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    long long h[n], dp[n];
    for( int i = 0; i < n; i++  ) {
        cin >> h[i];
    }
    dp[0] = 0;
    for( int i = 1; i < n; i++ ) {
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        for( int j = 2; j <= k; j++)
        if( j <= i ) {
            dp[i] = min( dp[i], dp[i-j] + abs(h[i]-h[i-j]) );
        }
    }
    cout << dp[n-1] << '\n';
    return 0;
}

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

int n, m, ans;

int main() {
	cin >> n >> m;
	for (int i = 1; i * i <= m; ++i)
		if (m % i == 0) {
			int d1 = i, d2 = m / i;
			if (m / d1 >= n) ans = max(ans, d1);
			if (m / d2 >= n) ans = max(ans, d2);
		}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;
template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}

int main()
{
    int n, k = 0;
    cin >> n;
    int now = 1;
    while(now < n){
        now *= 2;
        ++k;
    }
    vector<vint> a(n, vint(n));
    REP(i, n)
    {
        REP(j,n){
            if (i < j){
                REP(m,k){
                    if ((i & (1 << m)) != (j & (1 << m))){
                        a[i][j] = m + 1;
                        break;
                    }
                }
            }
        }
    }
    REP(i,n-1){
        FOR(j, i + 1, n - 1){
            cout << a[i][j] << " ";
        }
        cout << a[i][n - 1] << endl;
    }
}

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

int main() {
  int K,S,ans = 0;
  cin >> K >> S;
  for(int i=0; i<=K; i++){
    for(int j=0; j<=K; j++){
      int z = S-(i+j);
      if(z>=0 && z<=K){
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
//

fun main() {
    arc091b()
}

fun arc091b() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    var count = 0L
    for (b in k + 1..n) {
        val nn = if (k == 0) n else n + 1
        val cycle = nn / b
        var c = cycle * (b - k)
        val remain = nn % b
        if (remain > k) {
            c += (remain - k)
        }
        count += c
    }
    println(count)
}

Measured memory_bytes: 36532
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

d = I()
if d == 25:
    print("Christmas")
elif d == 24:
    print("Christmas Eve")
elif d == 23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")

Measured memory_bytes: 72448
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#include <utility>
#include <iomanip>
#include <sstream> 
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
const ll MOD = 1000000006;
const ll INF = 1LL << 60;

vector<ll> a(110);

int main()
{
    ll n;
    cin >> n;
    
    rep(i, n) {
        cin >> a[i];
    }

    ll ans = 0;

    rep(i, n) {
        if ((i + 1) % 2 == 1 && a[i] % 2 == 1)
            ans++;
    }
    

    

    cout << ans;


}

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

int  main()
{
	int s,h,m;
	
	cin >> s;
	h = s/3600;
	s = s%3600;
	m = s/60;
	s = s%60;

	cout << h <<":" << m << ":" << s << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
int ruisyuku[100003];
using namespace std;
int main(){
    int M,N;
    cin>>M>>N;
    int ans=0;
    for(int i=0;i<M-1;i++){
        int a;
        cin>>a;
        ruisyuku[i+1]=ruisyuku[i]+a;
    }
    int nowp=0;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        ans+=fabs(ruisyuku[nowp]-ruisyuku[nowp+a]);
        nowp+=a;
        ans%=100000;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1552
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int x,y,z;
cin >> x >> y >> z;
int ans = x*y/2;
cout << ans << endl;
return 0;
}


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

int main() {

    int n, d;
    cin >> n >> d;

    vector<vector<int>> X;
    rep(i,n) {
        vector<int> x(d);
        rep(j,d) cin >> x[j];
        X.push_back(x);
    }

    auto isOK = [&](vector<int>& x, vector<int>& y) {
        ll tot = 0;
        rep(i,d) tot += (x[i]-y[i])*(x[i]-y[i]);
        for (int i= 0; i*i <= tot; i++) {
            if (tot == i*i) return true;
        }
        return false;
    };

    int ans = 0;
    for (int i=0; i<n-1; i++) {
        for (int j=i+1; j<n; j++) {
            vector<int> xi = X[i];
            vector<int> xj = X[j];
            if(isOK(xi, xj)) ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,x,l;
    cin >> n >> x;
    int d[n+1];
    d[0]=0;
    for(int i=0;i<n;i++){
        cin >> l;
        d[i+1]=d[i]+l;
    }
    int count=0;
    for(int i=0;i<n+1;i++){
        if(d[i]<=x){
            count++;
        }
    }
    cout << count << '\n';
    return 0;
}


Measured memory_bytes: 256