akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int emod(long long x, long long p = mod) {
  return (x % p + p) % p;
}
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<long long> x(n); for (int i = 0; i < n; i++) cin >> x[i];
  vector<long long> y(m); for (int i = 0; i < m; i++) cin >> y[i];
  long long sumx = 0, sumy = 0;
  for (int i = 1; i < n; i++) {
    sumx = (sumx + (x[i] - x[i - 1]) * i % mod * (n - i) % mod) % mod;
  }
  for (int i = 1; i < m; i++) {
    sumy = (sumy + (y[i] - y[i - 1]) * i % mod * (m - i) % mod) % mod;
  }
  cout << emod(sumx * sumy) << '\n';
  return 0;
}

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

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

int main(){
    int n;
    cin>>n;
    set<string>s;
    while(n--){
        string str;
        cin>>str;
        s.insert(str);
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 19084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
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; }

int main() {
  int N; cin >> N;
  vector<int> a(N);
  rep(i, 0, N) cin >> a[i];
  vector<int> cnt(100000);
  rep(i, 0, N) cnt[a[i]]++;
  int ans = 0;
  rep(i, 2, 100000) {
    int sum = cnt[i] + cnt[i-1] + cnt[i-2];
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int N;cin>>N;
  int a[110];
  for(int t=0;t<N;t++)cin>>a[t];

  sort(a,a+N,greater<int>());

  int al=0,bo=0;
  for(int t=0;t<N;t++){
    if(t%2==0)al+=a[t];
    else bo+=a[t];
  }

  cout<<al-bo<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  if(!(s.find("A") == string::npos) and !(s.find("B") == string::npos))
    cout << "Yes" << "\n";
  else
    cout << "No" << "\n";

}


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/04  Problem: ABC 042 C / Link: http://abc042.contest.atcoder.jp/tasks/abc042_c  ----- */


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

	LL N, K; cin >> N >> K;
	VI NG(10, 0);
	FOR(i, 0, K) {
		int a; cin >> a;
		NG[a] = 1;
	}
	LL ans = 0LL;
	auto f = [&](LL x) {
		bool ok = 1;
		while (x) {
			ok &= !NG[x % 10];
			x /= 10;
		}

		return ok;
	};
	FOR(i, N, 1000000) {
		if (f(i)) {
			ans = i;
			break;
		}
	}



	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  priority_queue<Int> pq(as.begin(),as.end());
  while(m--){
    Int x=pq.top();pq.pop();
    pq.emplace(x/2);
  }

  Int ans=0;
  while(!pq.empty())
    ans+=pq.top(),pq.pop();

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


Measured memory_bytes: 1792
import java.util.Scanner;

/**
 * https://abc051.contest.atcoder.jp/tasks/abc051_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		
		System.out.println(s.replaceAll(","," "));

	}

}

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

int main(){
    int n,m,a[100][100],b[100],c[100]={};
    cin >> n >> m;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    for(int i=0; i<m; i++){
        cin >> b[i];
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            c[i] += a[i][j]*b[j];
        }
    }
    for(int i=0; i<n; i++){
        cout << c[i] << endl;
    }
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
#define ft first
#define sd second
#define pb(a) push_back(a)
#define PII std::pair<int,int>
#define PLL std::pair<ll,ll>
#define mp(a,b) std::make_pair(a,b)
#define ITR(a,b) for(auto a:b)
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
const int MAXN=200000+10,inf=0x3f3f3f3f;
int n,e=1,beg[MAXN<<1],cur[MAXN<<1],s,t,nex[MAXN<<2],to[MAXN<<2],out[MAXN<<2],cap[MAXN<<2],vis[MAXN<<1],level[MAXN<<1],mh[MAXN],clk;
PII side[MAXN];
std::queue<int> q;
std::vector<int> V[MAXN];
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(ch!='\0')putchar(ch);
}
template<typename T> inline bool chkmin(T &x,T y){return y<x?(x=y,true):false;}
template<typename T> inline bool chkmax(T &x,T y){return y>x?(x=y,true):false;}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
inline void insert(int x,int y,int z)
{
	to[++e]=y;
	nex[e]=beg[x];
	beg[x]=e;
	out[e]=x;
	cap[e]=z;
	to[++e]=x;
	nex[e]=beg[y];
	beg[y]=e;
	out[e]=y;
	cap[e]=0;
}
inline bool bfs()
{
	memset(level,0,sizeof(level));
	level[s]=1;
	q.push(s);
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(register int i=beg[x];i;i=nex[i])
			if(cap[i]&&!level[to[i]])level[to[i]]=level[x]+1,q.push(to[i]);
	}
	return level[t];
}
inline int dfs(int x,int maxflow)
{
	if(x==t||!maxflow)return maxflow;
	int res=0;
	vis[x]=clk;
	for(register int i=beg[x];i;i=nex[i])
		if((vis[x]^vis[to[i]])&&cap[i]&&level[to[i]]==level[x]+1)
		{
			int f=dfs(to[i],min(cap[i],maxflow));
			res+=f;
			cap[i]-=f;
			cap[i^1]+=f;
			maxflow-=f;
			if(!maxflow)break;
		}
	return res;
}
inline int Dinic()
{
	int res=0;
	while(bfs())clk++,memcpy(cur,beg,sizeof(cur)),res+=dfs(s,inf);
	return res;
}
inline bool solve()
{
	int cnt=0;
	q.push(1);
	REP(i,1,n-1)vis[i]=0;
	while(!q.empty())
	{
		int x=q.front();
		q.pop();cnt++;
		ITR(v,V[x])if(!vis[v])
			side[v]=mp(mh[v],x),vis[v]=1,q.push(mh[v]);
	}
	return cnt==n;
}
int main()
{
	read(n);s=n+n;t=s+1;
	REP(i,2,n)insert(s,i,1);
	REP(i,1,n-1)
	{
		int k,x;read(k);
		REP(j,1,k)
		{
			read(x);
			V[x].pb(i);
			if(x!=1)insert(x,i+n,1);
		}
		insert(i+n,t,1);
	}
	if(Dinic()!=n-1)
	{
		puts("-1");
		return 0;
	}
	REP(i,2,e)
	{
		if(out[i]>to[i]||cap[i]||out[i]==s||to[i]==t||out[i]==t||to[i]==s)continue;
		mh[to[i]-n]=out[i];
	}
	if(!solve())
	{
		puts("-1");
		return 0;
	}
	REP(i,1,n-1)printf("%d %d\n",side[i].ft,side[i].sd);
	return 0;
}


Measured memory_bytes: 33280
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var s = ReadLine();
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                var d = new Dictionary<char, long>();
                long c = 0;
                for (int j = 0; j < i; j++)
                {
                    if (!d.ContainsKey(s[j])) d.Add(s[j],1);
                }
                for (int j = i; j < n; j++)
                {
                    if (d.ContainsKey(s[j]) && d[s[j]] == 1)
                    {
                        c++;
                        d[s[j]]++;
                    }
                }

                ans = Math.Max(ans, c);
            }
            WriteLine(ans);



            

            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 18104
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
V = {'r':p, 's':r, 'p':s}
ans = 0

for i in range(k):
    check = t[i]
    ans += V[check]
    while True:
        i += k
        if i >= n:
            break
        if check == t[i]:
            check = '-1'
        else:
            ans += V[t[i]]
            check = t[i]
print(ans)


Measured memory_bytes: 3316
// Problem: D - Friends
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_d
// Parsed on: 2020-08-29 17:30:05
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

#define fastio  ios_base::sync_with_stdio(false); cin.tie(0);

using namespace std;

int main()
{
	int d,t,s;
	cin>>d>>t>>s;
	cout << (((t*s) >= d) ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
const int N=2020;
int p[N],a[N];
int s[N]={0};
bool ok[N]={false};
int color[N];

void o(int v){
	if(v==0)return;
	o(p[v]);
	swap(a[v],a[p[v]]);
}
vector<int> ans;
void op(int v){
	// cerr<<"OP "<<v<<endl;
	if(v==0)return;
	ans.push_back(v);
	o(v);
}
void output(){
	printf("%d\n",(int)ans.size());
	for(vector<int>::iterator it=ans.begin();it!=ans.end();++it){
		printf("%d\n",*it);
	}
}

vector<int> sons[N];
#define Fs(x) for(vector<int>::iterator it=sons[x].begin();it!=sons[x].end();++it)

int po[N];
int bot[N];
int dep[N];
bool done[N];

int main(){
	int n;
	scanf("%d",&n);
	p[0]=-1;
	for(int i=1;i<n;i++){
		scanf("%d",&p[i]);
		sons[p[i]].push_back(i);
		s[p[i]]++;
	}
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		dep[i]=i==0?0:dep[p[i]]+1;
		// cerr<<i<<" "<<dep[i]<<endl;
	}
	while(!ok[0]){
		memset(color,0,sizeof color);
		memset(po,0,sizeof po);
		int cnt=0;
		for(int i=0;i<n;i++){
			if(s[i]==0&&!ok[i]){
				cnt++;
				bot[cnt]=i;
				for(int x=i;s[x]<=1;x=p[x]){
					// cerr<<x<<" "<<cnt<<endl;
					color[x]=cnt;
					if(x==0){
						break;
					}
				}
			}
		}
		int cr=0;
		for(int i=0;i<n;i++){
			if(color[i]&&!ok[i])cr++;
		}
		while(cr>0){
			int x=a[0];
			int c=color[x];
			if(c){
				// cerr<<"c"<<" "<<x<<endl;
				int v=bot[c];
				for(int i=0;i<=po[c];i++){
					if(dep[x]>dep[a[v]]||i==po[c]){
						op(v);
						break;
					}
					v=p[v];
				}
				po[c]++;
				cr--;
			}
			else{
				memset(done,false,sizeof done);
				for(int i=1;i<=cnt;i++){
					int v=bot[i];
					for(int j=0;j<po[i];j++){
						// cerr<<v<<endl;
						done[v]=true;
						v=p[v];
					}
				}
				int md=0;
				for(int i=0;i<n;i++){
					if(ok[i]||done[i]){
						continue;
					}
					if(color[a[i]]&&dep[i]>dep[md]){
						md=i;
					}
				}
				op(md);
			}
		}
		for(int i=0;i<n;i++){
			if(color[i]){
				assert(a[i]==i);
				ok[i]=true;
				color[i]=0;
				if(i!=0){
					s[p[i]]--;
				}
			}
		}
	}
	output();
	return 0;
}

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

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

int main()
{
    int n;

    std::cin >> n;

    std::vector<int> s1(n), s2(n), s3(n), s4(n);

    rep(i, n)
    {
        int x, y;
        std::cin >> x >> y;
        s1[i] = x + y;
        s2[i] = x - y;
        s3[i] = y - x;
        s4[i] = -x - y;
    }

    int m1 = *std::max_element(rag(s1));
    int m2 = *std::max_element(rag(s2));
    int m3 = *std::max_element(rag(s3));
    int m4 = *std::max_element(rag(s4));

    std::cout << std::max(m1 + m4, m2 + m3) << std::endl;

    return 0;
}

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

int main(){
	string s,t;
	cin >> s >> t;
	vector<int> sm(26,-1),tm(26,-1);
	rep(i,s.size()){
		if(sm[s[i] - 'a'] >= 0 && sm[s[i] - 'a'] != (t[i] - 'a')){
			cout << "No" << endl;
			return 0;
		}
		if(tm[t[i] - 'a'] >= 0 && tm[t[i] - 'a'] != (s[i] - 'a')){
			cout << "No" << endl;
			return 0;
		}
		if(s[i] != t[i]){
			if(sm[s[i] - 'a'] == (t[i] - 'a') && tm[t[i] - 'a'] == (s[i] - 'a')) continue;
			if(sm[s[i] - 'a'] == -1 && tm[t[i] - 'a'] == -1){
				sm[s[i] - 'a'] = t[i] - 'a';
				tm[t[i] - 'a'] = s[i] - 'a';
			}else{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 776
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

int main() {
    long long A, B, N;
    cin >> A >> B >> N;

    long long x = B - 1;
    if (x >= N) {
        x = N;
    }
    // cout << A * x / B << endl;
    // cout << A * (x / B) << endl;
    cout << A * x / B - A * (x / B) << endl;

    return 0;
}


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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

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

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

int n;
int solve(){
    int ans=0;
    int mxnum=1;
    rrep(i,n){
        int tmp=i;
        int cnt=0;
        while(tmp%2 == 0){
            cnt++;
            tmp/=2;
        }
        if(chmax(ans,cnt))mxnum=i;
    }
    return mxnum;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    while(cin >> n){
        int ans = 0;
        cout << solve() << endl;
        //cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)

const fn = (x) => {
    let ans = 1
    for(let i = 1; i<=x; i++){
        ans *= i
    } 
    return ans
}
const Main = () => {
    const [n, m ] = nextIntArray()
    if(Math.abs(n-m) > 1){
        console.log(0)
        return
    }
    const MOD = 1e9 + 7
    let ans = 1
    for(let i = 1; i<= n;i++){
        ans = (ans % MOD) * (i % MOD)
    }
    for(let i = 1; i<= m;i++){
        ans = (ans % MOD) * (i % MOD)
    }
    if(n == m){
        console.log(2*ans%MOD)
    } else {
        console.log(ans%MOD)
    }
}
Main()



Measured memory_bytes: 33128
//
// Created by Hideaki Imamura on 2020-03-21.
//
# include <bits/stdc++.h>

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
const ll mod = 1000000007;

string S;
ll dp[100100][13]; // dp[i][j] = 先頭i文字まで見る。13でわって余りが5となるものの場合の数。

int main() {
    cin >> S;

    dp[0][0] = 1;
    for (int i = 0; i < S.length(); ++i) {
        int c = S[i] == '?' ? -1 : S[i] - '0';
        for (int j = 0; j < 10; ++j) {
            if (c != -1 && c != j) continue;
            for (int ki = 0; ki < 13; ++ki) dp[i+1][(ki * 10 + j) % 13] += dp[i][ki];
        }
        for (int j = 0; j < 13; ++j) dp[i+1][j] %= mod;
    }
    cout << dp[S.length()][5] << endl;
    return 0;
}

Measured memory_bytes: 10624
// Problem : B - Multiple of 9
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vint vector<int>
#define sint set<int>
#define mint map<int,int>
#define pint pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define precision(x) cout<<fixed<<setprecision(x);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void solve(){
	int rem=0;
	string s;
	rd(s);
	FOR(i,s.size()){
		rem+=(s[i]-'0')%9;
		rem%=9;
	}
	if(rem==0){
		pp("Yes");
	}
	else pp("No");
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 3708
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

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

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

signed main()
{
  ll n;
  cin >> n;

  ll a = n % 10;
  switch (a)
  {
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    cout << "hon" << endl;
    break;
  case 0:
  case 1:
  case 6:
  case 8:
    cout << "pon" << endl;
    break;
  case 3:
    cout << "bon" << endl;
    break;
  default:
    break;
  }

  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	string a, b, c;
	int x;
	cin >> a >> b;
	c = a + b;

	x = stoi(c);
	
	for (int b = 4; b < x; b++) {
		int power = 0;
		power = b * b;
		if (power == x) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

import numpy as np

nrow = input()
k = int(input())

l = len(nrow)

dp = np.zeros((l, 2, 4), int)
topmax = int(nrow[0])
dp[0, 0, 1] = 1  # =topmax
dp[0, 1, 0] = 1  # =0
dp[0, 1, 1] = topmax-1  # <topmax

for i in range(1, l):
  topmax = int(nrow[i])

  dp[i, 1, 0] = dp[i-1, 1, 0]  # =0
  for j in range(1,4):
    dp[i, 1, j] = dp[i-1, 1, j] + dp[i-1, 1, j-1] * 9  # =0,any

  if topmax == 0:
    for j in range(1, 4):
      dp[i, 0, j] = dp[i-1, 0, j]  #=0
  else:
    dp[i, 0, 2] = dp[i-1, 0, 1]  # =topmax,
    dp[i, 0, 3] = dp[i-1, 0, 2]  # =topmax,
    dp[i, 1, 1] += dp[i-1, 0, 1] # =0,<topmax
    dp[i, 1, 2] += dp[i-1, 0, 2]+dp[i-1, 0, 1] * (topmax-1)  # =0,<topmax
    dp[i, 1, 3] += dp[i-1, 0, 3]+dp[i-1, 0, 2] * (topmax-1)  # =0,<topmax

print(dp[l-1,0,k]+dp[l-1,1,k])


Measured memory_bytes: 12504
n,a = map(int,input().split())
x = [int(i) for i in input().split()]
dp = [[[0]*(n+1) for _ in range(n*a+1)] for _ in range(n+1)] 
for k in range(n+1): dp[0][0][k] = 1

for i in range(1,n+1):
    for j in range(1,n*a+1):
        for k in range(1,n+1):
            dp[i][j][k] = dp[i][j][k-1]
            if j - x[k-1] >= 0:
                dp[i][j][k] += dp[i-1][j-x[k-1]][k-1]
ans = 0
for i in range(1,n+1): ans += dp[i][a*i][n]
print(ans)

Measured memory_bytes: 103516
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

// x^n
ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

// x^{-1}
ll mod_inv(ll x) { return mod_pow(x, MOD - 2); }

vector<ll> fact;
vector<ll> fact_inv;

void init_fact(int n) {
  fact.resize(n + 1);
  fact_inv.resize(n + 1);
  fact[0] = fact_inv[0] = 1;
  for (int i = 0; i < n; ++i) {
    fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_inv[i + 1] = fact_inv[i] * mod_inv(i + 1) % MOD;
  }
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = mod_pow(2, n);
  ans = (ans + MOD - 1) % MOD;
  ll sub1 = 1, sub2 = 1;
  for (int i = 0; i < a; ++i) {
    sub1 = (sub1 * (n - i)) % MOD;
    sub1 = (sub1 * mod_inv(a - i)) % MOD;
  }
  for (int i = 0; i < b; ++i) {
    sub2 = (sub2 * (n - i)) % MOD;
    sub2 = (sub2 * mod_inv(b - i)) % MOD;
  }
  ans = (ans + MOD - sub1) % MOD;
  ans = (ans + MOD - sub2) % MOD;
  cout << ans << endl;
  return 0;
}

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

int binary( int a)
{
    int l =1;
    int r = 2000;
    while( l< r)
    {
        int mid = (l+r)/2;
        if( int(mid *0.08 )>= a)
        {
            r= mid;
            int temp = mid-1;
            if( int(temp*0.08) != a && int(mid*0.08) == a)
                return mid;
        } else
        {
            l = mid+1;
        }
    }
}

int binary2( int b)
{
    int l =1;
    int r = 2000;
    while( l< r)
    {
        int mid = (l+r)/2;
        if( int(mid *0.1) >= b)
        {
            r= mid;
            int temp = mid-1;
            if( int(temp*0.1) != b &&int( mid*0.1) == b)
                return mid;
        } else
        {
            l = mid+1;
        }
    }
}
int main()
{
    int a , b;
    cin>>a>>b;
    int ta = binary(a);
    int tb = binary2(b);
    int temp = max( ta , tb);

    if( int(temp*0.08) == a && int(temp*0.1) == b)
    {
        cout<<temp;
    }
    else cout<<-1;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
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; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

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

int main() {
	ll n, m, x, y;
	cin >> n >> m;
	extgcd(n, m, x, y);
	cout << x << " " << y << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
typedef long long ll;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    string s, t;
    cin >> s >> t;
    int ss = s.size();
    int ts = t.size();
    for(int i=ss-ts; i>=0; i--){
        bool flg = true;
        string ans = s;
        rep(j, ts){
            char si = s.at(i+j);
            char tj = t.at(j);
            if(!(si==tj || si=='?')){
                flg = false;
                break;
            }
            ans.at(i+j) = t.at(j);
        }
        if(flg){
            rep(j, ss){
                if(ans.at(j)=='?')
                    ans.at(j) = 'a';
            }
            out(ans);
            return;
        }
    }
    out("UNRESTORABLE");
}

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




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int comp(const void* a, const void* b)
{
	return strcmp((char*)a, (char*)b);
}

int main()
{
	int hist[26];
	int i, j, k, n, status;
	long ans = 0;
	long cont;
	char str[100000][11];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < 26; j++) hist[j] = 0;
		scanf("%s", str[i]);
		for (j = 0; j < 10; j++) {
			hist[str[i][j] - 'a']++;
		}
		k = 0;
		for (j = 0; j < 26; j++) {
			while (hist[j]) {
				str[i][k] = 'a' + j;
				k++;
				hist[j]--;
			}
		}
	}
	qsort(str, n, sizeof(char) * 11, comp);
	status = -1;
	for (i = 0; i < n-1; i++) {
		if (strcmp(str[i], str[i+1]) == 0) {
			if (status < 0) status = i;
		}
		else {
			if (status >= 0) {
				cont = i - status + 1;
				ans += cont * (cont - 1) / 2;
				status = -1;
			}
		}
	}
	if (status >= 0) {
		cont = n - status;
		ans += cont * (cont - 1) / 2;
	}
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 2300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n){
        if(n % 2){
            ans = ans * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return ans;
}

ll gcd(ll a,ll b){
    if(a == 0 && b == 0) return 0;
    else if(a == 0) return b;
    else if(b == 0) return a;
    else{
        if(a < 0) a = -a;
        if(b < 0) b = -b;
        if(a < b) swap(a,b);
        while(true){
            ll p = a % b;
            a = b;
            b = p;
            if(p == 0)break;
        }
        return a;
    }
}

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed < cin >> N;
    vector<int> A,B;
    int N; cin>>N;
    ll none = 0;
    map<pll,pll> iwashi;
    REP(i,N){
        ll a,b;
        cin >> a >> b;
        if(a == 0 && b == 0) none++;
        else if(a == 0){
            iwashi[pll(0,0)].second++;
        }
        else if(b == 0){
            iwashi[pll(0,0)].first++;
        }
        else{
            ll g = gcd(a,b);
            a = a/g;
            b = b/g;
            if(b < 0){  //全ての点のy座標を正に
                a = -a; b = -b;
            }
            //else if(b == 0 && a < 0)a = -a;
            if(a<0){
                ll tmp = a;
                a = b;
                b = -tmp;
                iwashi[pll(a,b)].second++;
            }
            else{
                iwashi[pll(a,b)].first++;
            }
        }
    }
    ll ans = 1;
    for(auto i : iwashi){
        //i->
        ll now = (mpow(2,i.second.first) + mpow(2,i.second.second) + mod-1) % mod;
        ans = ans* now % mod;
    }
    ans+=mod - 1 + none;
        
    cout << ans % mod << endl;
    //cout << __gcd(10,-10) << endl;
}


Measured memory_bytes: 19164
var
n,k,z,c,p,i:int64;
function pw(x,y:int64):int64;
var re:int64;
begin
    re:=1;
	while y>0 do
	begin
		if (y and 1=1) then begin re:=(re*x) mod 998244353; end;
		x:=x*x mod 998244353;
		y:=y div 2;
	end;
	pw:=re;
end;
begin
	n:=1; k:=1; z:=1; c:=1;
	p:=998244353;
	readln(k,n);
	z:=pw(2,n-1);
	while i<k do
	begin
		if ((k-i) mod 2=0) then
		begin
			z:=(z+p-c) mod p;
		end;
		c:=c*(n-i)mod p * pw(i+1,p-2) mod p;
                inc(i);
	end;	
	writeln(z);
end.



Measured memory_bytes: 128
#include <stdio.h>

int ice[11];

int main(void)
{
	int n, k;
	int i, j;
	
	while (1){
		for (i = 0; i < 10; i++){
			ice[i] = 0;
		}
		scanf("%d", &n);
		if (n == 0){
			return (0);
		}
		for (i = 0; i < n; i++){
			scanf("%d", &k);
			ice[k]++;
		}
		for (i = 0; i < 10; i++){
			if (ice[i] == 0){
				printf("-\n");
			}
			else {  
				for (j = 0; j < ice[i]; j++){
					printf("*");
				}	
				printf("\n");
			}
		}
	}
	return (0);
}
				

Measured memory_bytes: 568
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
signed main(){
    int N,M,C;
    int ans=0;
    cin >>N>>M>>C;
    int B[M];
    REP(i,M){
        cin>>B[i];
    }
    int A[N][M];
    REP(i,N){
        int sum=0;
        REP(j,M){
            cin>>A[i][j];
            sum+=A[i][j]*B[j];
        }
        if(sum+C>0) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: i64,
        alist: [i64; n]
    };
    let mut dict: HashMap<i64, i64> = HashMap::new();
    for &a in &alist {
        let cnt = dict.entry(a).or_insert(0);
        *cnt += 1;
    }
    let sum: i64 = dict.values().map(|x| x*(x-1)/2).sum();
    for a in alist {
        let cnt = dict[&a];
        println!("{}", sum-cnt+1);
    }
}


Measured memory_bytes: 11464
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("mmx,avx,fma")
//#pragma GCC optimize ("unroll-loops")

using namespace __gnu_pbds;
using namespace std;

template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, set<T>& v){ for(auto& e : v){ out << e << d; } return out; }

#define pb push_back
#define mk make_pair
#define X first
#define Y second
#define cont continue
#define ret return
#define For(i, a, b) for (int i = a; i < b;i++)
#define forn(i, a) for (int i = 0;i < a;i++)
#define ford(i, a, b) for (int i = b - 1;i >= a;i--)
#define fordn(i, a) for (int i = a - 1;i >= 0;i--)
#define forr(x, arr) for(auto &x: arr)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define REE(s_) {cout << s_ << '\n';exit(0);}
#define endl '\n'
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())

#define int long long
typedef double dd;
typedef long double ldd;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef set<int> si;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template <typename T> std::string toString(T val){std::ostringstream oss; oss << val; return oss.str();}

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1};
//const int dy[8] = {1, -1, 1, 0, -1, 1, 0, -1};
//const int dx[8] = {2, 2, 1, 1, -1, -1, -2, -2};
//const int dy[8] = {1, -1, 2, -2, 2, -2, 1, -1};

const int mod = 1e9 + 7;

//int powq(int a, int n) {
//    int res = 1;
//    while (n){
//        if (n & 1) {
//            res *= a;
//            res %= mod;
//            --n;
//        }
//        else {
//            a *= a;
//            a %= mod;
//            n >>= 1;
//        }
//
//    }
//    res %= mod;
//    return res;
//}

signed main(){
//    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #ifdef KULA
        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
    #else
//        freopen("input.in", "r", stdin);
//        freopen("output.out", "w", stdout);
    #endif
    char x;
    cin >> x;
    deque<char> q;
    q.pb(x);
    int gg = 0;
    while(cin >> x){
        if (q.size() && q.back() != x){
            gg += 2;
            q.pop_front();
        }
        else q.pb(x);
    }
    cout << gg;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

#define MAX 10000
#define NIL -1

typedef struct node_{
  int p,l,r;
}node;

struct node_ T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int, int);
int setHeight(int);
int getSibling(int);
void print(int);

int main() {
  int i,v,l,r,root=0;
  scanf("%d",&n);

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

  for(i=0;i<n;i++)
  {
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL) T[l].p=v;
    if(r!=NIL) T[r].p=v;
  }

  for(i=0;i<n;i++)
  {
    if(T[i].p==NIL) root =i;
  }

  setDepth(root,0);
  setHeight(root);

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

  return 0;
}

void setDepth(int x, int d){
  if(x ==NIL) return;

  D[x]= d;
  setDepth(T[x].l,d+1);
  setDepth(T[x].r,d+1);
}

int setHeight(int x){
  int H1=0,H2=0;

  if(T[x].l!=NIL) H1=setHeight(T[x].l)+1;
  if(T[x].r!=NIL) H2=setHeight(T[x].r)+1;

  return H[x]=(H1>H2 ? H1 : H2);
}

int getSibling(int x){
  if(T[x].p==NIL) return NIL;
  if(T[T[x].p].l!=x && T[T[x].p].l!=NIL) return T[T[x].p].l;
  if(T[T[x].p].r!=x && T[T[x].p].r!=NIL) return T[T[x].p].r;

  return NIL;
}

void print(int x){
  int deg = 0;
  printf("node %d: ",x);
  printf("parent = %d, ",T[x].p);
  printf("sibling = %d, ",getSibling(x));

  if(T[x].l!=NIL) deg++;
  if(T[x].r!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[x]);
  printf("height = %d, ",H[x]);

  if(T[x].p ==NIL) printf("root\n");
  else if(T[x].l ==NIL && T[x].r == NIL) printf("leaf\n");
  else printf("internal node\n");


}



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

using namespace std;

int main() {
	string s;
	cin >> s;
	int n = (int)s.length();
	int a = 0, b = 0;

	for (int i = 0; i < n; i++) {
		if (s[i] == 'A') a++;
		else b++;
	}

	if (a == 0 || b == 0) cout << "No";
	else cout << "Yes";
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
	mod int = 1e9 + 7
)

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	array := []string{"Sunny", "Cloudy", "Rainy"}
	s := getString()

	var next int
	for index, v := range array {
		if v == s {
			next = (index + 1) % 3
		}
	}

	fmt.Println(array[next])
}

func getInt() int {
	sc.Scan()
	str := sc.Text()
	value, _ := strconv.Atoi(str)
	return value
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 640
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int n, i;
int main() {
	cin >> n >> i;
	cout << n + 1 - i << endl;
	return 0;
}


Measured memory_bytes: 256
using System;


namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            

            while (true)
            {
                String[] s = Console.ReadLine().Split(' ');
                int a = int.Parse(s[0]);
                int c = int.Parse(s[2]);

                switch (s[1])
                {
                    case "+":
                        Console.WriteLine(a + c);
                        break;
                    case "-":
                        Console.WriteLine(a - c);
                        break;
                    case "*":
                        Console.WriteLine(a * c);
                        break;
                    case "/":
                        Console.WriteLine(a / c);
                        break;
                    case "?":
                        break;

                }
                if (s[1] == "?") break;
            }
        }
    }
}

Measured memory_bytes: 9240
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define me(a,x) memset(a,x,sizeof a)
using namespace std;
typedef long long LL;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0' && ch<='9'){x=(x<<1)+(x<<3)+ch-'0'; ch=getchar();}
	return x*f;
}
const int N=100005;
struct E{int y,next;}a[N<<1]; int len,first[N];
void ins(int x,int y){
	a[++len]=(E){y,first[x]},first[x]=len;
	a[++len]=(E){x,first[y]},first[y]=len;
}
int u,v,c[N],o,f[N],g[N],p[N],pl; LL ans;
void dfs(int x,int fa){
	for(int k=first[x];k;k=a[k].next){
		int y=a[k].y; if(y==fa)continue;
		if(!c[y]){c[y]=-c[x]; dfs(y,x);}
		else u=x,v=y,o=c[x]==c[y];
	}
}
void dp(int x,int fa){
	f[x]=c[x];
	for(int k=first[x];k;k=a[k].next){
		int y=a[k].y;
		if(y==fa ||(x==u&&y==v)||(x==v&&y==u))continue;
		dp(y,x);
		f[x]+=f[y],g[x]+=g[y];
	}
}
int main()
{
	int T=1;
	while(T--){
		int n=read(),m=read(),x,y,i;
		u=v=len=0; me(first,0);
		for(i=1;i<=n;i++)c[i]=f[i]=g[i]=0;
		for(i=1;i<=m;i++)
			x=read(),y=read(),ins(x,y);
		ans=0; 
		c[1]=1; dfs(1,0);
		if(m==n-1){
			dp(1,0);
			if(f[1]){printf("-1\n"); continue;}
			for(i=1;i<=n;i++)ans+=abs(f[i]);
			printf("%lld\n",ans);
		}
		else if(o){
			dp(1,0);
			if(f[1]&1){printf("-1\n"); continue;}
			int t=f[1]>>1;
			ans+=abs(t),c[u]-=t,c[v]-=t;
			dp(1,0);
			for(i=1;i<=n;i++)ans+=abs(f[i]);
			printf("%lld\n",ans);
		}
		else{
			g[u]++,g[v]--; dp(1,0);
			if(f[1]){printf("-1\n"); continue;}
			pl=1,p[1]=0;
			for(i=1;i<=n;i++)
				if(!g[i])ans+=abs(f[i]);
				else if(g[i]<0)p[++pl]=f[i];
				else p[++pl]=-f[i];
			sort(p+1,p+1+pl);
			int t=p[(pl+1)>>1];
			for(i=1;i<=pl;i++)ans+=abs(p[i]-t);
			printf("%lld\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 8320
v_num = int(input())
adjacent = [[0 for n in range(v_num)] for m in range(v_num)]
for _ in range(v_num):
    inp = [int(n) for n in input().split(" ")]
    for i in inp[2:]:
        adjacent[inp[0] - 1][i - 1] = 1
for i in range(v_num):
    print(*adjacent[i])

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  string s;
  cin >> n >> s;
  
  /*
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  */
  
  string ans = "Yes";
  if (n % 2 == 1)
    ans = "No";
  else {
    rep (i, n/2) {
      if (s.at(i) != s.at(i+ n/2)) {
        ans = "No";
        break;
      }
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
function main(arg) {
	arg = arg.trim().split(' ').map(str => parseInt(str, 10));
  	var a = arg[0], b = arg[1], k = arg[2];
	a = a - k;
    if (a < 0){
      b = b + a;
      a = 0;
    }
  	if (b < 0) {
      b = 0;
    }
	console.log(a, b)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int a,b,tap=1,count=0;
  cin >> a >> b;
  while(tap<b){
    tap += a-1;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256