akhauriyash/Code-Regression huggingface dataset:
//2018.09.15 1.5min

#include <iostream>
using namespace std;

int main() {


    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if(a+b > c+d) cout << "Left" << endl;
    else if(a+b==c+d)cout << "Balanced" << endl;
    else cout << "Right" << endl;

    return 0;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

const li N=1e5;
const li M=1e9+7;

vi graph[N];

// returns {subtree with black as root, subtree with white as root}

pi dfs(li u, li p)
{
    li all_white=1;
    li is_black=0;

    for(li v: graph[u])
    {
        if(v!=p)
        {
            pi tp=dfs(v,u);

            is_black = ((all_white*tp.F)%M + (is_black*(tp.F+tp.S))%M)%M;
            all_white = (all_white*tp.S)%M;
        }
    }

    return {all_white,(all_white+is_black)%M};
}

void solve()
{
    li n;

    cin>>n;

    f(i,0,n-2)
    {
        li u,v;

        cin>>u>>v;

        graph[u].PB(v);
        graph[v].PB(u);
    }

    pi tp = dfs(1,0);

    cout<<(tp.F+tp.S)%M;
}

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 16084
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

const int maxn=2e5+10;

int num[maxn];

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int n;
	
	while(cin>>n)
	{
		
		for(int i=0;i<n;i++)
		{
			cin>>num[i];
		}
		
		sort(num,num+n,greater<int>());
		
		ll int ans=0;
		
		int cnt=0;
		
		for(int i=0;i<n;i++)
		{
			if(cnt==0)
			{
				ans+=num[i];
				cnt++;
			}
			else
			{
				if(cnt+2<=n-1)
				{
					ans+=2*num[i];
					cnt+=2;
				}
				else if(cnt+1<=n-1)
				{
					ans+=num[i];
					cnt+=1;
					break;
				}
				else
				{
					break;
				}
			}
		}
		
		cout<<ans<<endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 4428
import sys
import math
#a,b= map(int,input().split())
#li= [int(x) for x in input().split()]
a=int(input())
i=j=1
for i in range(10):
  for j in range(10):
    if a==i*j:
      print("Yes")
      sys.exit()

print("No")




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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    string S; cin >> S;
    ll N = S.size();

    ll c = 0, acc = 0;
    rep(i, N) {
        if (S[i] == 'W') {
            c++;
            acc += i;
        }
    }
    cout << acc - (c - 1) * c / 2 << endl;
}


Measured memory_bytes: 720
N = int(input())
A_list = [int(e) for e in input().split()]

MOD_BY = 10**9 + 7

#全ループするとTLE
#Ai*(自分の右側の合計)で回す

right_sum = sum(A_list)%MOD_BY
ans = 0
for i in range(N-1):
    right_sum -= A_list[i]
    #print(A_list[i],right_sum)
    ans += A_list[i]*right_sum%MOD_BY
    
print(ans%MOD_BY)

Measured memory_bytes: 31760
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

void bfs(unordered_map<int, unordered_set<int>>& graph, vint& ans, int s) {
    deque<int> node;
    ans[s] = 1;
    node.push_back(s);
    while (1) {
        if (node.size() <= 0) break;
        int now = node.front();
        node.pop_front();
        for (auto& adj : graph[now]) {
            if (ans[adj] != 0) continue;
            ans[adj] = now;
            node.push_back(adj);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    unordered_map<int, unordered_set<int>> graph;
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        graph[A].insert(B);
        graph[B].insert(A);

    }

    vint ans(N + 1, 0);
    bfs(graph, ans, 1);
    cout << "Yes" << endl;
    REP(i, 2, N + 1) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 30808
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
const int N=400005;
int tot=0;
int a[N],b[N],n;
unsigned long long k;
int vis[N];
int main() {
  scanf("%d%llu",&n,&k);
  for (int i=1;i<=n;++i) scanf("%d",&a[i]);
  int now=1;
  while(1) {
    now=a[now];
    b[++tot]=now;
    if(tot==k) {
      printf("%d\n",now);
      return 0;
    }
    if(vis[now]!=0) {
      k-=1ull*(vis[now]-1);
      int len=(tot-vis[now]);
      k%=(1ull*len);
      if(k==0) k=len;
      printf("%d\n",b[k+vis[now]-1]);
      return 0;
    }
    vis[now]=tot;
  }
  return 0;
}




Measured memory_bytes: 5884
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))

def main():
    n = int(input())
    A = readInts()
    Pa = [0 for _ in range(n)]
    for i in range(n):
        Pa[i] = A[i] - 1
    cnt = 0
    for i in range(n):
        if i == Pa[Pa[i]]:
            cnt += 1
    print(cnt//2)
if __name__ == '__main__':
  main()


Measured memory_bytes: 15848
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    int a, b, C;
    double S, L, h, d;
    cin >> a >> b >> C;
    
    d = (acos(-1.0)*C)/180.0;
    S = a*b*sin(d)/2.0;
    L = a + b + sqrt(a*a + b*b - 2*a*b*cos(d));
    h = b*sin(d);
    
    printf("%lf\n%lf\n%lf\n", S, L, h);
    
    return 0;
}


Measured memory_bytes: 3416
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];
  sort(begin(A), end(A));
  sort(begin(B), end(B));
  int ans = N % 2 ? B[N / 2] - A[N / 2] + 1
    : (B[N / 2] + B[N / 2 - 1]) - (A[N / 2] + A[N / 2 - 1]) + 1;
  cout << ans << endl;
}


Measured memory_bytes: 4780
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int a[101001];
bool f[101010];
int main()
{
	int n,m;
	cin>>n>>m;
	int i;
	for(i=0;i<m;i++){
		cin>>a[i];
		f[a[i]]=1;
	}
	int i1=n,i2=n;i=0;
	while(1){
		if(f[i2]==0){
			cout<<i2<<endl;
			return 0;
		}
		if(f[i1]==0){
			cout<<i1<<endl;
			return 0;
		}
		i1++;i2--;
		if(i2<0) i2=0;
	}
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

void solve(){
    ll n, k;
    cin>>n>>k;
    ll dp[k+1];
    for(ll i=k; i>=1; i--){
        ll op = k/i;
        dp[i] =  modexp(op, n, mod);
        for(ll j = 2*i; j <= k; j+=i){
            dp[i] = (dp[i] - dp[j] + mod)%mod;
        }
    }
    ll ans = 0;
    for(ll i=1; i<=k; i++){
        ans = (ans + (dp[i]*i)%mod)%mod;
    }
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int N;
    cin >> N;
    vector<int> cnt(N);
    RPT(i, 2, N)
    {
        int tmp;
        cin >> tmp;
        cnt[tmp - 1]++;
    }

    RPT0(i, N) cout << cnt[i] << endl;
}

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


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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");
 
private:
	using ll = long long;
 
	int v;
 
	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}
 
public:
 
	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
 
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
 
	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
 
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}
 
	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}
 
	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9) + 7>;

const int MAXN = 2e3;
int exps[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	for (int v = 1; v <= N; v++) {
		int x = v;
		for (int p = 2; p * p <= x; p++) {
			while (x % p == 0) {
				x /= p;
				exps[p]++;
			}
		}
		if (x > 1) {
			exps[x]++;
		}
	}

	num ans = 1;
	for (int p = 2; p <= N; p++) {
		ans *= exps[p] + 1;
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
S = str(input())

S = S.split("/")

if int(S[0]) <= 2019:
  if int(S[0])==2019 and (int(S[1])*100+int(S[2]))<=430:
    print("Heisei")
  else:
    print("TBD")
else:
  print("TBD")


Measured memory_bytes: 2940
N=int(input())
list1=list(map(int,input().split()))
list2=[]
def calc(n):
    tempsum=0
    for j in range(1,n+1):
        tempsum+=((-1)**(n-j))*list1[j-1]
    return tempsum
list2.append(calc(N))
for i in range(1,N):
    list2.append(2*list1[i-1]-list2[i-1])
str1=""
for i in range(len(list2)):
    str1+=str(list2[i])
    if i==len(list2)-1:
        print(str1)
    else:
        str1+=" "

Measured memory_bytes: 14104
#include <bits/stdc++.h>
using namespace std;
#define N 210
#define M 200010
#define inf 2147483647
#define col(x) (((x-1)/m)+1)
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
int tot=1;
int fir[N],nex[M],got[M],tak[M];
inline void AddEdge(int x,int y,int z) { 
    nex[++tot]=fir[x],fir[x]=tot,got[tot]=y,tak[tot]=z; 
} 
int a[N][N],b[N][N];
vector <int> v[N][N];
int dep[N],que[N];
inline int bfs(int s,int t) {
	memset(dep,0,sizeof(dep));
	int l=1,r=1;
	dep[s]=1,que[1]=s;
	while (l<=r) {
		int x=que[l++];
		for (int i=fir[x];i;i=nex[i]) {
			int y=got[i];
			if (dep[y] || !tak[i]) continue;
			dep[y]=dep[x]+1,que[++r]=y;
		}
	}
	return dep[t];
}
inline int dfs(int x,int t,int flow) {
	int rest=flow;
	if (x==t) return flow;
	for (int i=fir[x];i && rest;i=nex[i]) {
		int y=got[i];
		if (!tak[i] || dep[y]!=dep[x]+1) continue;
		int k=dfs(y,t,min(rest,tak[i]));
		if (!k) dep[y]=0;
		tak[i]-=k,tak[i^1]+=k,rest-=k;
	}
	return flow-rest;
}
int main() {
    int n=read(),m=read();
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++) {
            a[i][j]=read();
            v[i][col(a[i][j])].push_back(a[i][j]);
        }
    for (int w=1;w<=m;w++) {
        tot=1;
        memset(fir,0,sizeof(fir));
        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++) if (v[i][j].size()) {
                    AddEdge(i,j+n,1),AddEdge(j+n,i,0);
                }
        int s=2*n+1,t=s+1;
        for (int i=1;i<=n;i++)
            AddEdge(s,i,1),AddEdge(i,s,0),
            AddEdge(t,i+n,0),AddEdge(i+n,t,1);
        while (bfs(s,t)) dfs(s,t,inf);
        for (int i=1;i<=n;i++) {
            for (int j=fir[i];j;j=nex[j]) {
                if (got[j]>n && !tak[j]) b[i][w]=v[i][got[j]-n].back(),v[i][got[j]-n].pop_back();
            }
        }
    }
    for (int i=1;i<=n;i++,putchar('\n'))
        for (int j=1;j<=m;j++) printf("%d ",a[col(b[i][j])][j]=b[i][j]);
    for (int i=1;i<=n;i++,putchar('\n'))
        for (int j=1;j<=m;j++) printf("%d ",a[i][j]);
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
 
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
 
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
 
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
str s; int lef,righ;
int main(){
 
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lef = INT_MAX;
    righ = INT_MIN;
    
    cin>>s;
    for(int i=0;i<s.size();i++){
    	if(s[i] == 'A') lef = min(lef,i);
    	if(s[i] == 'Z') righ = max(righ,i);
	}
	
	cout<<righ-lef+1<<newl;
  
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

/*void printNcR(ll n, ll r) 
{ 
 long long p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            long long m = __gcd(p, k); 
            p /= m; 
           k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    cout << p << endl; 
} */
// priority_queue <int, vector<int>, greater<int> >  min priority_queue
 //std:: set<ll> :: iterator it;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, ans = 0,a,x,y;
    cin>>n;
    if(n>=30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(15) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

class Vertex{
public:
    ll value;
    ll parent;
    bool visited;
    Vertex() : visited(false), parent(-1) {};
};

template<class T>
class Edge{
public:
    T dest;
    Edge(const T &dest){this->dest = dest;}
};

template<class T>
class Graph{
public:
    map<T, Vertex> vertices;
    map<T, vector<Edge<T>>> edges;

    void add_edge(const T &vsrc, const T &vdest){
        edges[vsrc].emplace_back(Edge<T>(vdest));
    }

    void add_bidir_edge(const T &v1, const T &v2){
        edges[v1].emplace_back(Edge<T>(v2));
        edges[v2].emplace_back(Edge<T>(v1));
    }
};

template<class T>
void bfs(Graph<T> &G, T start, map<ll,ll> &ret){
    for(pair<T,Vertex> v:G.vertices){
        v.second.visited=false;
    }
    queue<T> queue;
    queue.push(start);
    while(!queue.empty()){
        T top=queue.front(); queue.pop();
        G.vertices[top].visited=true;
        // code here
        // std::cout << top << std::endl;

        for(Edge<T> v:G.edges[top]){
            if(!G.vertices[v.dest].visited){
                G.vertices[v.dest].visited=true;
                ret[v.dest]=top;
                queue.push(v.dest);
            }
        }
    }
}

int main(){
    ll N=ii(), M=ii();
    Graph<ll> G;
    REP(i,0,M){
        ll a=ii(), b=ii();
        G.add_bidir_edge(a, b);
    }
    map<ll, ll> ret;
    bfs<ll>(G,1,ret);
    ose("Yes");
    REP(i,2,N+1){oie(ret[i]);}
    return 0;
}

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

int main()
{
  int N;
  map<string, int> strings;
  priority_queue<string, vector<string>, greater<string>> pq;
  string s;
  int max_n = 0;

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> s;
    if (strings.count(s))
      strings[s]++;
    else
      strings[s] = 1;
    if (max_n < strings[s])
      max_n++;
  }

  for (auto p : strings)
  {
    auto k = p.first;
    auto v = p.second;
    if (v == max_n)
      pq.push(k);
  }
   while (!pq.empty()) {
    cout << pq.top() << endl;
    pq.pop(); 
  }
}

Measured memory_bytes: 26868
from collections import Counter
N, K, L = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(K)]
Y = [list(map(int, input().split())) for _ in range(L)]

class UnionFind:
    def __init__(self, n):
        self.par = list(range(n))
        self.rank = [0] * n
        
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
                
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def __repr__(self):
        return ', '.join(str(x) for x in self.par)

t1 = UnionFind(N)
t2 = UnionFind(N)

for p, q in X:
    t1.unite(p - 1, q - 1)
    
for r, s in Y:
    t2.unite(r - 1, s - 1)

connect = [(t1.find(i), t2.find(i)) for i in range(N)]
ctr = Counter(connect)
print(*[ctr[key] for key in connect])


Measured memory_bytes: 139084
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

#define MOD 1000000007


int main(){
  map<ll,ll> mp;
  ll maxi=0,count=0,n;
  cin >> n;
  std::vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
    mp[a.at(i)]++;
  }

  for(ll i=0;i<=100000;i++){
    count=mp[i-1]+mp[i]+mp[i+1];
    maxi=max(maxi,count);

  }

  cout << maxi << endl ;


  }


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

// #define DEBUG

using namespace std;

const int N = 2e5+7;
const int MOD = 1e9+7;
const long long INF = 1e18;
const double eps = 1e-11;
typedef pair<int, int> pii;

int n;
long long k, zero;
long long a[N];
vector<long long> pos, neg;

// return the number of product <= mid
inline long long count(const long long &mid)
{
    long long cnt = 0;
    for (int i = 1; i < n; ++i)
        cnt += upper_bound(a, a+i, mid/a[i])-a;
    return cnt;
}

inline void solve()
{
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> a[i];

    for (int i = 0; i < n; ++i) {
        if (!a[i]) ++zero;
        else if (a[i] < 0) neg.emplace_back(a[i]);
        else if (a[i] > 0) pos.emplace_back(a[i]);
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    // warning : could it run out of data range?
    long long num_neg = neg.size()*pos.size(),
              // num_pos = pos.size()*(pos.size()-1)/2+neg.size()*(neg.size()-1)/2,
              num_zero = zero*(zero-1)/2+zero*neg.size()+zero*pos.size();
    if (k > num_neg && k <= num_neg+num_zero) { cout << 0 << endl; return; }
    long long l, r, mid, cnt;
    if (k <= num_neg) {
        l = -INF; r = -1;
        while (l < r) {
            mid = (l+r+1)/2;
            cnt = 0;
            // the number < mid
            for (long long i : neg) {
                int p = upper_bound(pos.begin(), pos.end(), mid/i)-pos.begin();
                cnt += pos.size()-p;
            }
            if (cnt < k) l = mid;
            else r = mid-1;
        }
    } else {
        l = 1; r = INF;
        k -= num_neg+num_zero;
        while (l < r) {
            mid = (l+r)>>1;
            cnt = 0;
            // the number <= mid
            for (int i = 1; i < (int)pos.size(); ++i) {
                int p = upper_bound(pos.begin(), pos.begin()+i, mid/pos[i])-pos.begin();
                cnt += p;
            }
            for (int i = 1; i < (int)neg.size(); ++i) {
                int p = lower_bound(neg.begin(), neg.begin()+i, mid/neg[i])-neg.begin();
                cnt += i-p;
            }
            if (cnt < k) l = mid+1;
            else r = mid;
        }
    }
    cout << l << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3956
n,k,s = map(int,input().split())
if s == 10 ** 9:
    a = [s] * k
    b = [1] * (n-k)
    a.extend(b)
    print(*a)
else:
    a = [s] * k
    b = [s+1] * (n-k)
    a.extend(b)
    print(*a)


Measured memory_bytes: 7264
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def exchange(x)
  return x*(Math::PI/180)
end
a,b,c_thita=get_f
s=(0.5*a*b*Math.sin(exchange(c_thita))).round(5)
c=((a**2+b**2-2*a*b*Math.cos(exchange(c_thita)))**0.5).round(5)
l=a+b+c
h=(b*Math.sin(exchange(c_thita))).round(5)
puts [s,l,h].join("\n")


Measured memory_bytes: 6980
#include <bits/stdc++.h>
using namespace std;
int arr[1005][1005];
queue <pair<int,int> > q;
int langkah[1005][1005];
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int x,y; cin >> x >> y;
	char c;
	for(int i=1;i<=x;i++)
		for(int j=1;j<=y;j++){
			cin >> c;
			langkah[i][j]=-1;
			if(c=='#'){
				arr[i][j]=1;
				q.push({i,j});
				langkah[i][j]=0;
			}
			else arr[i][j]=0;
		}
		while(!q.empty()){
			pair<int,int> qq;
			qq=q.front();
			int a = qq.first;
			int b = qq.second;
			q.pop();
			//cout << a <<' '<<b <<' '<<langkah[a][b]<<" LOL "<<endl;
			if(b<y && langkah[a][b+1]==-1){
				q.push({a,b+1}); 
				langkah[a][b+1]=langkah[a][b]+1;
			}
			if(b>1 && langkah[a][b-1]==-1){
				q.push({a,b-1});
				langkah[a][b-1]=langkah[a][b]+1;
			}
			if(a<x && langkah[a+1][b]==-1){
				q.push({a+1,b});
				langkah[a+1][b]=langkah[a][b]+1;
			}
			if(a>1 && langkah[a-1][b]==-1){
				q.push({a-1,b});
				langkah[a-1][b]=langkah[a][b]+1;
			}
		}
		int maxi = -100000;
		for(int i=1;i<=x;i++)
			for(int j=1;j<=y;j++){
				maxi=max(maxi,langkah[i][j]);
			}
		cout << maxi << endl;
}

Measured memory_bytes: 16272
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    for(int i = 0; i < 3; i++){
        char c;
        cin >> c;
        cout << char('9' - c + '1');
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 2e3 + 2;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (u == s)
    cout << a - 1 << ' ' << b;
  else
    cout << a << ' ' << b - 1;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n 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 gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll N; cin >> N;
    ll out=1;
    ll c=1;
    while(true){
        if(c*c>N) break;
        out = c*c;
        c++;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<queue>
#include<map>
using namespace std;

vector<int> va(8);

int main(){
	vector<int> vec(8);
	for(int i = 0; i < 8; i++) vec[i] = i;
	map<vector<int>, int> mpa;
	queue<vector<int> > qa;
	mpa[vec] = 1;
	qa.push(vec);
	while(!qa.empty()){
		vector<int> vb = qa.front();
		qa.pop();
		for(int i = 0; i < 8; i++){
			if(vb[i] == 0){
				if(i != 0 && i != 4){
					vector<int> vc = vb;
					swap(vc[i], vc[i - 1]);
					if(mpa[vc] == 0){
						mpa[vc] = mpa[vb] + 1;
						qa.push(vc);
					}
				}
				if(i != 3 && i != 7){
					vector<int> vc = vb;
					swap(vc[i], vc[i + 1]);
					if(mpa[vc] == 0){
						mpa[vc] = mpa[vb] + 1;
						qa.push(vc);
					}
				}
				if(i >= 0 && i <= 3){
					vector<int> vc = vb;
					swap(vc[i], vc[i + 4]);
					if(mpa[vc] == 0){
						mpa[vc] = mpa[vb] + 1;
						qa.push(vc);
					}
				}
				if(i >= 4 && i <= 7){
					vector<int> vc = vb;
					swap(vc[i], vc[i - 4]);
					if(mpa[vc] == 0){
						mpa[vc] = mpa[vb] + 1;
						qa.push(vc);
					}
				}
			}
		}
	}
	while(cin >> va[0]){
		for(int i = 1; i < 8; i++) cin >> va[i];
		cout << mpa[va] - 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 5684
N = int(input())
E = [[] for _ in range(N)]

for i in range(N-1):
  a,b,c = map(int,input().split())
  a -= 1
  b -= 1
  E[a].append((b,c))
  E[b].append((a,c))

Q,K = map(int,input().split())
K -= 1
costs = [None]*N
costs[K] = 0

stack = [K]

while stack:
  s = stack.pop()
  c = costs[s]
  for t,d in E[s]:
    if costs[t] is None:
      costs[t] = c + d
      stack.append(t)

for i in range(Q):
  x,y = map(int,input().split())
  print(costs[x-1]+costs[y-1])

Measured memory_bytes: 43312
#include <stdio.h>
int main(void){
int m,d;
  int mcount,dcount;
  int out=0;
  scanf("%d",&m);
  scanf("%d",&d);
  for(mcount=1;mcount<=m;mcount++){
  for(dcount=1;dcount<=d;dcount++){
    if((dcount>=10)&&(((dcount/10)*(dcount%10))==mcount)&&((dcount/10)>=2)&&((dcount%10)>=2)){out++;
                                                         }
  }
  }
  printf("%d",out);
return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
	int i, count[26]={}, num;
	char s;
	while(1){
		if(scanf("%c", &s)==EOF) break;
		if(s>='A' && s<='Z') s+=32;
		num = s - 'a';
		count[num]++;
	}
	for(i=0;i<26;i++){
		printf("%c : %d\n",'a'+i, count[i]);
	}
}



Measured memory_bytes: 2056
import sys
S=input()
T=input()
N=len(S)
if S==T:
    print('Yes')
    sys.exit()
for i in range(1,N):
    a=S[-i:]+S[:N-i]
    #print(a)
    if a==T:
        print('Yes')
        sys.exit()
print('No')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int n,m;cin >> n >> m;
    vector<int> path[n+1];
    vector<int> h(n+1);
    for(int i=0; i<m; i++){
        int x,y;cin >> x >> y;
        path[x].push_back(y);
        h[y]++;
    }
    queue<int> q;
    for(int i=1; i<=n; i++){
        if(h[i]==0) q.push(i);
    }
    vector<int> cnt(n+1);
    while(!q.empty()){
        int now=q.front();q.pop();
        for(auto next: path[now]){
            h[next]--;
            if(h[next]==0){
                q.push(next);
                cnt[next]=max(cnt[next],cnt[now]+1);
            }
        }
    }
    sort(cnt.rbegin(),cnt.rend());
    cout << cnt[0] << endl;
    return 0;
}

Measured memory_bytes: 6528
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]

#print(pc)
ans = float("inf")

for i in range(2**D):
    sum = 0
    count = 0
    rem = set(range(1,D+1))
    for j in range(D):
        if (i >> j) & 1:
            sum += pc[j][0]*100*(j+1)+pc[j][1]
            count += pc[j][0]
            rem.discard(j+1)
    if sum < G:
        k = max(rem)-1
        n = min(pc[k][0],-(-(G-sum)//((k+1)*100)))
        count += n
        sum += n*100*(k+1)
    if sum >= G:
        ans = min(ans,count)

print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long A = scan.nextLong();
		long B = scan.nextLong();
		long K = scan.nextLong();

		if(K <= A) {
			System.out.println(A -K  + " "+ B);
		}else if(K <= A + B) {
			System.out.println(0 + " "+( B-(K - A)));
		}else {
			System.out.println(0 + " " +0);
		}
	
	}
}

Measured memory_bytes: 25300
#include <cstdio>
#define N 100005
int n, m, x, y, ans, a[N], pr[N];

int f(int p) {
	if(pr[p]==p) return p;
	return pr[p] = f(pr[p]);
}

int main() {
	int i, tx, ty;
	scanf("%d%d", &n, &m);
	for(i=1; i<=n; i++) scanf("%d", a+i), pr[i] = i;
	while(m--) {
		scanf("%d%d", &x, &y);
		tx = f(x), ty = f(y);
		if(tx != ty) pr[ty] = tx;
	}
	for(i=1; i<=n; i++) if(f(i)==f(a[i])) ans++;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 896
n, m = map(int, input().split())
c = []
for i in range(m):#h:高さ
    c.append([int(m) for m in input().split()])
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        self.par = [-1 for i in range(n+1)]
        # 木の高さを格納する（初期状態では0）
        self.rank = [0] * (n + 1)


    # 検索
    # 根ならその番号を返す
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

        # 併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        #if x != y:
        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if self.par[x] < self.par[y]:
            self.par[x] += self.par[y]
            self.par[y] = x
        else:
            self.par[y] += self.par[x]
            self.par[x] = y
        # 木の高さが同じなら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.par[self.find(x)]
ansli = [((n - 1) * n) // 2]
alln = ((n - 1) * n) // 2
setn = set()
u = UnionFind(n)
aq = 0
for i in range(m - 1, 0, -1):
    if c[i][0] not in setn and c[i][1] not in setn:
        u.union(c[i][0], c[i][1])
        setn.add(c[i][0])
        setn.add(c[i][1])
        aq += 1
    elif c[i][0] in setn and c[i][1] not in setn:
        aq += u.size(c[i][0])
        u.union(c[i][0], c[i][1])
        setn.add(c[i][1])
    elif c[i][0] not in setn and c[i][1] in setn:
        aq += u.size(c[i][1])
        u.union(c[i][0], c[i][1])
        setn.add(c[i][0])
    else:
        if u.same_check(c[i][0], c[i][1]):
            pass
        else:
            aq += u.size(c[i][1]) * u.size(c[i][0])
            u.union(c[i][0], c[i][1])
    ansli.append(alln - aq)
for i in reversed(range(m)):
    print(ansli[i])

Measured memory_bytes: 32552
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int n, a[10], ans = 0;

void dfs(int cur, int flag){
    if(cur == n){
        ans += flag;
        return;
    }
    For(i, a[cur]-1, a[cur]+2){
        dfs(cur+1, flag | (i % 2 == 0));
    }
}

int main(){
    scanf("%d", &n);
    rep(i, n) scanf("%d", &a[i]);
    dfs(0, 0);
    printf("%d\n", ans);
}

Measured memory_bytes: 256
import bisect
n = int(input())
def to_list():
  return list(map(int, input().split()))

a = to_list()
b = to_list()
c = to_list()

a.sort()
c.sort()

ans = 0
for n in b:
  ans += bisect.bisect_left(a, n) * (len(c) - bisect.bisect_right(c, n))

print(ans)

Measured memory_bytes: 23220
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    cout << n*(n-1)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
require "bigdecimal"
require "bigdecimal/util"

def gi() gets.to_i end
def gs() gets.chomp end
def gmi() gets.split.map(&:to_i) end
def gms() gets.split.map(&:chomp) end
def YesNo1(bool, yes="Yes", no="No") puts (bool ? yes : no) end
def YESNO2(bool, yes="YES", no="NO") puts (bool ? yes : no) end


#####
a,b,c = gmi
YesNo1([a,b,c].sort[0..1].inject(:+) == [a,b,c].sort[2])

Measured memory_bytes: 1916
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      a=l[i]
      b=l[j]
      c=l[k]
      if a==b or b==c or a==c:
        continue
      t=[a,b,c]
      t.sort()
      if t[0]+t[1]>t[2]:
        ans+=1
print(ans)

Measured memory_bytes: 68252