akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
using namespace std;

int main() {
  int N, R, B;
  cin >> N;
  R=0;
  B=0;
  string s;
  cin >> s;
  for (int i=0; i<N; i++) {
    if (s[i]=='R') {
      R=R+1;
    }
    else {
      B=B+1;
    }
  }
  if (R>B) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3556
mod0 = []
lst = []
for i in range(5):
    inp = int(input())
    if inp % 10 == 0:
        mod0.append(inp)
    else:
        lst.append([inp, inp % 10])
ans = sum(mod0)
lst.sort(key= lambda x :x[1])

if len(lst) != 0:
    last = lst.pop(0)
    ans = sum(mod0)
    for i,imod in lst:
        ans += (i//10 +1)*10
    ans+=last[0]

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{int n;
 cin>>n;
 if(n%2==0){
 cout<<n<<endl;}
 else{
 cout<<n*2<<endl;} 
 system("pause");
 return 0;
}

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

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

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

/* -----  2018/01/21  Problem: ARC 089 C / Link: http://arc089.contest.atcoder.jp/tasks/arc089_c  ----- */
/* ------問題------



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



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

LL N;

LL ans = 0LL;

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

	cin >> N;
	VI t(N), x(N), y(N);
	VL p(N);
	int f = 1;
	FOR(i, 0, N) {
		cin >> t[i] >> x[i] >> y[i];
		LL sum = x[i] + y[i];
		if (sum % 2 != t[i] % 2) {
			f = 0;
		}
		p[i] = sum;
		if (i) {
			LL sa = t[i] - t[i - 1];
			if (sa < p[i] - p[i - 1]) {
				f = 0;
			}
		}
		else {
			if (t[i] < sum)f = 0;
		}

	}
	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



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

using namespace std;

int main()
{
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if(abs(a-c) <= d)
            printf("Yes\n");
        else
        {
            if(abs(a-b)<= d &&abs(b-c)<=d)
                printf("Yes\n");
            else printf("No\n");
        }

       return 0;
}


Measured memory_bytes: 256
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int N, M, A[600][600];

int ans[259999][7], C = 0;

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> N >> M;
  for(int i = 0;i < N;i++) {
    for(int j = 0;j < M;j++) {
      cin >> A[i][j];
    }

    for(int j = 0;j < (M-1);j++) {
      if(A[i][j] % 2 != 0) {
        A[i][j+1]++;
        ans[C][0] = j+1;
        ans[C][1] = i+1;
        ans[C][2] = j+2;
        ans[C][3] = i+1;
        C++;
      }
    }
  }

  for(int i = 0;i < (N-1);i++) {
    if(A[i][M-1] % 2 != 0) {
      A[i+1][M-1]++;
      int j = M-1;
      ans[C][0] = j+1;
      ans[C][1] = i+1;
      ans[C][2] = j+1;
      ans[C][3] = i+2;
      C++;
    }
  }

  cout << C << endl;
  for(int i = 0;i < C;i++) {
    cout << ans[i][1] << " " <<
    ans[i][0] << " " << ans[i][3] << " " << ans[i][2] << endl;
  }

  return 0;
}


Measured memory_bytes: 8320
S = str(input())
a = b = c = 0
for s in S:
    if s == 'a':
        a += 1
    elif s == 'b':
        b += 1
    elif s == 'c':
        c += 1

if abs(a-b) <= 1 and abs(b-c) <= 1 and abs(c-a) <= 1:
    print('YES')
else:
    print('NO')

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

using namespace std;

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define aim_cpo do{ios::sync_with_stdio(false);\
cin.tie(nullptr);cout.precision(10);cout<<fixed;}while(0)
#define LOCAL_INPUT do{FILE *stream1;\
stream1=freopen("/Users/aim_cpo/CLionProjects/competitive/in.txt","r",stdin);\
if(stream1==nullptr)return 0;}while(0)

#ifdef LOCAL_DEFINE
#define show(x) cerr << #x << " = " << x << endl
#else
#define show(x)
#endif

typedef long long ll;
typedef unsigned long long ull;

constexpr const int INT_INF=0x3f3f3f3f; // 1061109567
constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f; // 4557430888798830399

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

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

// INT
#define GCD(a, b) __gcd(a, b)
template <typename T> T LCM(T a, T b) {return a / GCD(a, b) * b;}
template <typename T> T EXTGCD(T a, T b, T& x, T& y) {
    T d = a;
    if (b != 0) {d=EXTGCD(b,a%b,y,x);y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> bool is_prime(T a) {
    for(int i=2;i*i<=a;i++)if(a%i==0)return 1;
    return 0;
}

// MOD
const ll MOD = (ll)1e9 + 7;
#define add(a, b) ((a % MOD) + (b % MOD)) % MOD
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define sub(a, b) ((a % MOD) + MOD - (b % MOD)) % MOD
template <typename T> T mod_inverse(T a, T mod, bool prime){ // if mod is prime, "prime" is true.
    if(prime){
        T tmp=mod-2,now=a,res=1;while(tmp){if(tmp&1)res=mul(res,now);now=mul(now,now);tmp>>=1;}
        return res;
    }else{T x,y;EXTGCD(a,mod,x,y);return (mod+x%mod)%mod;}
}
#define divide(a, b) ((a % MOD) * (mod_inverse(b, MOD, true))) % MOD

//LLの数値をつかう時は最後にLをつける癖をつけよう
//
//  ┏┓┏┓　┓　┏┓
//  ┏┛┃┃　┃　┗┫
//  ┗┛┗┛　┻　┗┛
//
//   謹┃賀┃新┃年┃
//   ━┛━┛━┛━┛
//WWWWWWWWWWWWWWWWWWWWWW

int w, h;
vector < pair<ll, int> > v;

int main() {
    aim_cpo; // インタラクティブのときは消すように.
#ifdef LOCAL_DEFINE
    LOCAL_INPUT; // インタラクティブのときは消すように.
    show(MOD);
//    FILE *stream2;
//    stream2 = freopen("out.txt", "w", stdout);
//    if (stream2 == NULL) return 0;
#endif
    // テキトー考察
    //
    // 最小全域木だから辺の重みが小さい順にとっていけばいい
    // つなぐ辺の数は今までにどれだけつなげてきたかを持っていれば良い(は?)
    // そんな感じ.テキトーすぎてゴメンな未来の俺...
    cin >> w >> h;
    for (int i = 0; i < w; i++) {
        ll p; cin >> p;
        v.emplace_back(p, 0);
    }
    for (int i = 0; i < h; i++) {
        ll q; cin >> q;
        v.emplace_back(q, 1);
    }
    sort(all(v));
    ll ans = 0L;
    ll width = w + 1L, height = h + 1L;
    for (auto &i : v) {
        if (i.se == 0) {
            if (height == 0) continue;
            ans += i.fi * height;
            width--;
        } else {
            if (width == 0) continue;
            ans += i.fi * width;
            height--;
        }
    }
    cout << ans << endl;
#ifdef  LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
    return 0;
}

Measured memory_bytes: 6512
#include <stdio.h>
#define TRUE 1
#define FALSE 0

int main(void)
{
    char A, B;
    char snake[256];
    int n;
    int cnt;
    int i, j, len1, len2;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++){
        A = B = FALSE;
        scanf("%s", snake);
        
        if (snake[0] == '>' && snake[1] == '\''){
            j = 2;
            len1 = 0;
            while (snake[j] == '='){
                len1++;
                j++;
            }
            if (snake[j] == '#'){
                j++;
                len2 = 0;
                while (snake[j] == '='){
                    len2++;
                    j++;
                }
                if (len1 == len2 && len1 > 0 && snake[j] == '~' && snake[j + 1] == '\0'){
                    A = TRUE;
                }
            }
        }
        else if (snake[0] == '>' && snake[1] == '^'){
            j = 2;
            len1 = 0;
            len2 = 1;
            while (snake[j] != '~'){
                if (j % 2 == 0 && snake[j] != 'Q'){
                    len2 = 0;
                    break;
                }
                if (j % 2 == 1 && snake[j] != '='){
                    len2 = 0;
                    break;
                }
                j++;
                len1++;
            }
            
            if (len2 && snake[j + 1] == '~' && len1 > 0 && len1 % 2 == 0 && snake[j + 2] == '\0'){
                B = TRUE;
            }
        }
        
        if (A){
            printf("A\n");
        }
        else if (B){
            printf("B\n");
        }
        else {
            printf("NA\n");
        }
    }
    
    return (0);
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  string s;
  cin >> s;
  rep(i, 4)
  {
    if (s[i] == '+')
      ans++;
    else
      ans--;
  }
  pr(ans);
  return 0;
}


Measured memory_bytes: 3600
import Control.Monad

main :: IO ()
main = do
  n:m:c:_ <- fmap (\x -> read x :: Int) <$> words <$> getLine
  bs <- fmap (\x -> read x :: Int) <$> words <$> getLine
  as <- replicateM n $ fmap (\x -> read x :: Int) <$> words <$> getLine
  print $ length $ [ s | s <- [sum (zipWith (*) a bs) | a <- as], (s + c) > 0]


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int n=nxt();
    int m=nxt();
    VVI gra(n+1,VI());
    REP(i,m){
        int a=nxt();
        int b=nxt();
        gra.at(a).push_back(b);
        gra.at(b).push_back(a);
    }
    queue<int> q;
    int dep[n+1];
    int sign[n+1];
    bool vis[n+1];
    REP(i,n+1){
        sign[i]=1000000;
        dep[i]=1000000;
        vis[i]=0;
    }
    dep[1]=0;
    vis[1]=1;
    q.push(1);

    while(!q.empty()){
        for(int i:gra[q.front()]){ //for each edge
            if(dep[q.front()]+1<=dep[i]){ //if new path is shortest
                dep[i]=dep[q.front()]+1; 
                sign[i]=q.front(); 
            }
            if(!vis[i]){ //if edge unvisited
                vis[i]=1; //edge TO BE visited
                q.push(i); //add to queue
            }
        }
        q.pop(); //remove vert from queue
    }
    bool connected=1;
    for(int i=2;i<n+1;i++){
        if(vis[i]==0){
            connected=0;
        }
    }
    if(!connected){
        printf("No");
    } else{
        printf("Yes\n");
        for(int i=2;i<n+1;i++){
            printf("%d\n",sign[i]);
        }
    }
    return 0;
}



Measured memory_bytes: 10712
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int A, B;
	cin >> A >> B;
	int max = A + B;
	if (max < A - B)max = A - B;
	if (max < A*B) max = A * B;
	print(max);
}

Measured memory_bytes: 256
from collections import Counter

S = input()
T = input()

s = list(Counter(S).values())
t = list(Counter(T).values())
s.sort(reverse=True)
t.sort(reverse=True)

for i,j in zip(s,t):
    if i != j:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 4144
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> transpose(vector<string> a)
{
	const int h = a.size();
	const int w = a[0].size();
	vector<string> t(w, string(h, '*'));
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			t[j][i] = a[i][j];
		}
	}
	return t;
}

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	for (auto& s : a) {
		cin >> s;
	}

	string w1(a[0].size(), '.');
	a.erase(remove(a.begin(), a.end(), w1), a.end());

	a = transpose(a);
	string w2(a[0].size(), '.');
	a.erase(remove(a.begin(), a.end(), w2), a.end());

	a = transpose(a);
	for (auto& s : a) {
		cout << s << endl;
	}
}


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

#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long lint;
#define SZ(x) ((int)(x).size())

int main()
{
	int n;
	int k;
	vector<int> v;
	cin >> n >> k;
	for (int i = 0; i < k; i++) v.push_back(0);
	int cnt = 0;
	int i = 0;
	while (cnt != n) {
		
		v[i]++;
		i++;
		if (i == k)  i = 0;
		cnt++;
	}
	
	cout << abs(v[0] - v[k - 1]) << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
array = list(map(int, input().split()))
ans = 0
next = 1
a = True
while (a):
    a = False
    b = False
    for i in range(next,len(array)):
        if array[i] < array[i-1]:
            ans += array[i-1] - array[i]
            array[i] = array[i - 1]
            a = True
            if b == False:
                b= True
                next = i

print(ans)


Measured memory_bytes: 32332
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main(){
	int x, y, z;
	int s, ans;
	scanf("%d %d", &x, &y);
  ans=(y+x-3)/(x-1);

	printf("%d\n", ans);


	return 0;
}


Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C, D = MAP()

Icm = C*D//gcd(C, D)
a = B//C - (A-1)//C
b = B//D - (A-1)//D
I = B//Icm - (A-1)//Icm
print((B-A+1) - (a+b-I))

Measured memory_bytes: 5400
n = int(input())

def sieve(n):
    # 1.9 seconds.

    # 1 and n are divisors for every n.
    is_prime = [2]*(n + 1)
    is_prime[0], is_prime[1] = 0, 0

    # is_prime holds the number of positive divisors of N. Instead of being a bool of 0/1 for prime/not prime. for example of N=24--->  is_prime[24] = 6 (1, 2, 3, 4, 6 ,24)

    for num in range(2, n+1//2):
        for mult in range(2*num, n+1, num):
            is_prime[mult] += 1
        
    ans = 1

    # i is N. elem is f(N)
    for i, elem in enumerate(is_prime[2:]):
        ans += (elem)*(i + 2)

    print(ans)

sieve(n)




Measured memory_bytes: 230048
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    ll t1,t2,a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    ll loopa=t1*a1+t2*a2,loopb=t1*b1+t2*b2;
    if(loopa==loopb){
        cout<<"infinity"<<endl;
        return 0;
    }

    ll A1=t1*a1,A2=t2*a2,B1=t1*b1,B2=t2*b2;
    // cout<<A1<<' '<<A2<<' '<<loopa<<endl;
    // cout<<B1<<' '<<B2<<' '<<loopb<<endl;

    ll d1=A1-B1,d2=A2-B2;
    if( (d1>0&&d2>0) or (d1<0&&d2<0) or (d1==0&&d2!=0) or (d1!=0&&d2==0) or (abs(d1)>abs(d2)) ){
        cout<<0<<endl;
        return 0;
    }

    d1=abs(d1);
    d2=abs(d2);

    ll ans=2*(d1/(d2-d1))+1-(d1%(d2-d1)==0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s; cin >> s;
	s += "##";
	for (int i = 0; i < s.size() - 2; i++) {
		if (s[i] == s[i + 1]) {
			i++;
			cout << i << ' ' << i + 1 << endl;
			return 0;
		}
		else if (s[i] == s[i + 2]) {
			i++;
			cout << i << ' ' << i + 2 << endl;
			return 0;
		}
	}
	cout << "-1 -1\n";
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll mod = 1000000007;

// 階乗逆元
ll inv_mod(ll n,ll mod){
  ll a = n%mod,b = mod-2,ret=1;
  while(b>0){
    if(b&1) ret = (ret*a)%mod;
    a = (a*a)%mod;
    b >>= 1;
  }
  return ret;
}

ll comb(ll x,ll y, ll z){
  return (((x*y)%mod)*z)%mod;
}

int main(){
  ll H,W,A,B;
  cin >> H >> W >> A >> B;
  vector<ll> x(H+W-2),invx(H+W-2);
  x[0] = 1;
  invx[0] = 1;
  // 0 ~ H+W-3までの階乗を計算しておく
  for(int i=1;i<H+W-2;i++){
    x[i] = (x[i-1]*i)%mod;
    invx[i] = inv_mod(x[i],mod);
  }
  ll ret = 0;
  for(int i=B;i<W;i++){
    int c = H-A-1;
    int d = A-1;
    ret += (comb(x[i+c],invx[i],invx[c]) * comb(x[W-1-i+d],invx[W-1-i],invx[d])) % mod;
  }
  cout << ret%mod << endl;
  return 0;
}


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

const int N = 16;

int a[N], x[N][N], y[N][N];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a+i);
        for (int j = 0; j < a[i]; ++j) {
            scanf("%d %d", &x[i][j], &y[i][j]);
            --x[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        bool cont = false;
        for (int j = 0; j < n; ++j) {
            if (!((1 << j) & i)) continue;
            for (int k = 0; k < a[j]; ++k) {
                if (y[j][k] != ((i >> x[j][k])&1)) cont = true;
            }
        }
        if (!cont) ans = max(ans, __builtin_popcount(i));
    }
    
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for A - Two Rectangles
	var A, B, C, D int
	fmt.Scanf("%d %d %d %d", &A, &B, &C, &D)
	fmt.Println(int(math.Max(float64(A*B), float64(C*D))))
}


Measured memory_bytes: 1840
#include<stdio.h>

int main(){
	char a[4];
	scanf("%s",a);
	if (a[1]=='B')
	{
		a[0]='A';
		a[1]='R';
		a[2]='C';
		printf("%s",a);
	}
	else if (a[1]=='R')
	{
		a[0]='A';
		a[1]='B';
		a[2]='C';
		printf("%s",a);
	}
	
	return 0;
}

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

int main() {
    int n;  cin >> n;
    if (n / 10 == 9 || n % 10 == 9)  cout << "Yes" << endl;
    else  cout << "No" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

int main()
{
    string b;
    cin >> b;

    for (ll i = 0; i < b.size(); i++)
    {
        if (b[i] == 'A') {
            b[i] = 'T';
        }
        else if (b[i] == 'T') {
            b[i] = 'A';
        }
        else if (b[i] == 'C') {
            b[i] = 'G';
        }
        else if (b[i] == 'G') {
            b[i] = 'C';
        }
    }
    cout << b << endl;
}

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

int main() {
	int a,b,c,d,a1,b1,c1;
	int tag = 0;
	cin >> a1 >> b1 >> c1 >> d;

	a = a1;
	b = b1;
	c = c1;
	for(int i=0; i<=d;i++){

		
		if(c > b && b > a){
			
			tag = 1;
		}
		for(int j=0;j<=d-i;j++){
			
			if(c > b && b > a){
				
				tag = 1;
			}
			for(int k=0;k<=d-i-j;k++){
				
				if(c > b && b > a){
					
					tag = 1;
				}
				c *= 2;
			}
			c = c1;
			b *= 2;
		}
		b = b1;
		a *= 2;

	}
	if (tag == 0){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 3632
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	long long int ans = 0;
	cin >> K >> N;
	vector<long long int>v(N + 1);
	vector<long long int>w(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
		w[N - i + 1] = K - v[i];
	}
	for (int i = 1; i <= N; i++) {
		v[i] += v[i - 1];
		w[i] += w[i - 1];
	}
	long long int box = v[N] - v[N - 1];
	ans = box;
	for (int i = N - 1; i >= 1; i--) {
		box += K;
		box -= v[i + 1];
		box += v[i];
		box += v[i];
		box -= v[i - 1];
		box += v[i];
		box -= v[i - 1];
		if ((N - i) & 1) {
			int minus = N - (N - i) / 2;
			box -= v[minus];
			box += v[minus - 1];
			if (N - i > 2) {
				box -= v[minus];
				box += v[minus - 1];
				box += v[minus - (N - i) / 2];
				box -= v[minus - 1 - (N - i) / 2];
			}
		}
		else {
			int minus = N - (N - i - 1) / 2;
			box -= v[minus];
			box += v[minus - 1];
			if (N - i > 3) {
				box -= v[minus - 1];
				box += v[minus - 2];
				box += v[minus - 1 - (N - i - 1) / 2];
				box -= v[minus - 2 - (N - i - 1) / 2];
			}
		}
		//	cout << box << endl;
		ans = max(ans, box);
	}
	box = w[N] - w[N - 1];
	for (int i = N - 1; i >= 1; i--) {
		box += K;
		box -= w[i + 1];
		box += w[i];
		box += w[i];
		box -= w[i - 1];
		box += w[i];
		box -= w[i - 1];
		if ((N - i) & 1) {
			int minus = N - (N - i) / 2;
			box -= w[minus];
			box += w[minus - 1];
			if (N - i > 2) {
				box -= w[minus];
				box += w[minus - 1];
				box += w[minus - (N - i) / 2];
				box -= w[minus - 1 - (N - i) / 2];
			}
		}
		else {
			int minus = N - (N - i - 1) / 2;
			box -= w[minus];
			box += w[minus - 1];
			if (N - i > 3) {
				box -= w[minus - 1];
				box += w[minus - 2];
				box += w[minus - 1 - (N - i - 1) / 2];
				box -= w[minus - 2 - (N - i - 1) / 2];
			}
		}
		//	cout << box << endl;
		ans = max(ans, box);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
from copy import deepcopy
s = input()
length = len(s)

ans = 0
def solve(s_split, s, i):
    if i == length:
        # print(s_split)
        global ans
        ans += sum(list(map(int, s_split)))
    else:
        tmp1 = deepcopy(s_split)
        tmp1[-1] += s[0]
        solve(tmp1, s[1:], i+1)

        tmp2 = deepcopy(s_split)
        tmp2.append(s[0])
        solve(tmp2, s[1:], i+1)
        
solve(['0'], s, 0)
print(int(ans/2))

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 10000000

using namespace std;

bool cc[maxn+5];
vi prime;
void ciur () {
  int i, j;
  cc[0] = cc[1] = 1;
  for (i = 2; i*i <= maxn; i++)
    if (!cc[i])
      for (j = i*i; j <= maxn; j += i) cc[j] = 1;
  for (i = 2; i <= maxn; i++)
    if (!cc[i]) prime.pb(i);
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  ll n; cin >> n;
  ciur();
  int i, j, cnt, z, pas, ans = 0;
  for (int x: prime) {
    int cnt = 0;
    while (n > 1 && n%x == 0) {
      cnt++;
      n /= x;
    }
    if (cnt == 0) continue;
    for (z = 0, pas = (1<<6); pas > 0; pas /= 2)
      if ((z+pas)*(z+pas+1)/2 <= cnt) z += pas;
    ans += z;
  }
  if (n > 1) ans++; ///daca tai din toate nr prime <= rad iti ramane 1/nr prim
  cout << ans;
  return 0;
}


Measured memory_bytes: 17192
///"    "\\\

# include <bits/stdc++.h>

# define pb push_back

using namespace std;

int k , z = 0 , o , p = 0 ;

	
int main() {

	int n ;
	cin >> n ;
	if( n % 2 == 0 ){
		cout << n / 2 ;
	}
	else{
		cout << ( n / 2 ) + 1 ;	
	}

}

///"    "\\\

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int dp[100005];


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    for(int i=0;i<100005;i++){
    	dp[i]=1000000000000000;
    }
    dp[0]=0;
    int n,w;
    cin>>n>>w;
    int a[n],b[n];
    for(int i=0;i<n;i++){
    	cin>>a[i]>>b[i];
    }
    for(int i=0;i<n;i++){
    	for(int j=100000;j>=b[i];j--){
    		dp[j]=min(dp[j],dp[j-b[i]]+a[i]);
    	}
    }
    int ans=0;
    for(int i=0;i<100005;i++){
    	if(dp[i]<=w){
    		ans=max(ans,i);
    	}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

 
int main()
{
       int a,b;
       scf(a),scf(b);

       if(a>8||b>8)
        printf(":(");

        else
        printf("Yay!");
        
}  

Measured memory_bytes: 256
N, M = map(int, input().split())

dp = [float('inf')] * (2 ** N)
dp[0] = 0

for i in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    key = 0
    for x in c:
      key += 2 **(x-1)
    
    ndp = dp.copy()
    for j in range(2**N):
        if dp[j | key] > ndp[j] + a:
            dp[j | key] = ndp[j] + a
            
if dp[-1] == float('inf'):
  print(-1)
else:
  print(dp[-1])


Measured memory_bytes: 3316
h,w=map(int,input().split())
s=[input() for i in range(h)]
for i in range(1,h-1):
  for j in range(1,w-1):
    if s[i][j]=='#':
      if (s[i+1][j]=='#' or s[i-1][j]=='#' or s[i][j+1]=='#' or s[i][j-1]=='#'):
        continue
      else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 9120
import sys
import os


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

    N, M = list(map(int, sys.stdin.readline().split()))
    lines = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

    ret = -1
    for n in range(0, pow(10, N)):
        if len(str(n)) != N:
            continue
        flg = True
        for s, c in lines:
            if str(n)[s - 1] != str(c):
                flg = False

        if flg:
            ret = n
            break

    print(ret)


if __name__ == '__main__':
    main()


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    string s;
    cin >> n >> s;

    int w_from_l[300001] = {}, e_from_r[300001] = {};
    for (int i = 0; i < n; i++)
    {
        w_from_l[i + 1] = w_from_l[i];
        if (s[i] == 'W')
            w_from_l[i + 1]++;
    }
    for (int i = n - 1; i >= 0; i--)
    {
        e_from_r[i] = e_from_r[i + 1];
        if (s[i] == 'E')
            e_from_r[i]++;
    }
    int mn = INF;
    for (int i = 0; i <= n; i++)
    {
        mn = min(w_from_l[i] + e_from_r[i], mn);
    }
    cout << mn << endl;
}


Measured memory_bytes: 5380
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
	unsigned long int N,K;

    cin >> N >> K;
	cout << N-K+1 << endl;
	return 0;
}


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

int main(){

	int n, x;
	scanf("%d %d", &n, &x);
	int cont = 1, bounce = 0;

	rep(i,n){

		int l;
		scanf("%d", &l);
		
		if (bounce + l <= x){
			bounce += l;
			cont++;
		}else
			break;	
	}

	printf("%d\n", cont);
	return 0;
}


Measured memory_bytes: 3800
S = list(input())
head = int(S[0] + S[1])
tail = int(S[2] + S[3])

if 0 < head < 13 and  0 < tail < 13:
    print('AMBIGUOUS')
elif 0 < head < 13:
    print('MMYY')
elif 0 < tail < 13:
    print('YYMM')
else:
    print('NA')


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

int main() {
	int N, A, B;
	int sum;

	cin >> N >> A >> B;
	for(int i=1;i<=N;i++) {
		int c = 0; 
		int t = i;
		for(int j=0;j<5;j++) {
			if (t%10 < 10) {
				c += t%10;
				t = t / 10;
			}
		}
		if (A<=c && c<=B) {
			sum += i;	
		}
	}

	cout << sum << endl;
}


Measured memory_bytes: 256
a0=input().split()
n=int(a0[0])
k=int(a0[1])

b0=input().split()
nl=[]
for i in range(n):
  nl.append(int(b0[i]))
  
nl.sort()
ans=0
for i in range(k):
  ans+=nl[i]
print(ans)

Measured memory_bytes: 9196
class Unionfind():
    def __init__(self,n):
        self.parents=[-1]*n
        self.ranks=[0]*n
    
    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    
    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return 
        if self.ranks[x]<self.ranks[y]:
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x
        if self.ranks[x]==self.ranks[y]:
            self.ranks[x]+=1
    
    def number_of_class(self):
        return sum(x<0 for x in self.parents)
    
    def clear(self):
        self.parents=[-1]*n

n,m=map(int,input().split())
edge=[tuple(map(lambda x:int(x)-1,input().split())) for _ in range(m)]
g=Unionfind(n)
ans=0
for e in edge:
    g.clear()
    for f in edge:
        if f!=e:
            g.union(f[0],f[1])
    if g.number_of_class()>1:
        ans+=1
print(ans)
    


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#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++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

bool compare_by_sec(pii a, pii b)
{
    if (a.second != b.second)
        return a.second > b.second; // if we change < for >, we can sort desc by second_key
    else
        return a.first < b.first;
}

vector<ll> a(500000);
vector<pll> t(500000);
ll ind[500000] = {}; //c[i]使う個数

int main()
{
    ll n, m;
    cin >> n >> m;

    rep(i, n) cin >> a[i];
    sort(a.begin(), a.begin() + n);

    rep(i, m) cin >> t[i].first >> t[i].second;

    sort(t.begin(), t.begin() + m, compare_by_sec);

        ll cnt = 0;

    rep(i, m)
    {
        ll d = upper_bound(a.begin() + cnt, a.begin() + n, t[i].second) - a.begin() - cnt;
        ind[i] = min(d, t[i].first);
        cnt += ind[i];
    }

    ll sum = 0;
    rep(i, m) sum += t[i].second * ind[i];
    for (int i = cnt; i < n; i++)
        sum += a[i];

    OP(sum);

    return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long llong;

void DFriendSuggestions(std::istream& in, std::ostream& out) {
  int n, m, k;
  in >> n >> m >> k;

  vector<set<int>> graph;
  vector<set<int>> enemy;

  for (int i = 0; i < n; ++i) {
    graph.emplace_back(set<int>());
  }
  for (int i = 0; i < n; ++i) {
    enemy.emplace_back(set<int>());
  }

  for (int i = 0; i < m; ++i) {
    int a, b;
    in >> a >> b;
    graph[a - 1].insert(b - 1);
    graph[b - 1].insert(a - 1);
  }

  for (int i = 0; i < k; ++i) {
    int a, b;
    in >> a >> b;
    enemy[a - 1].insert(b - 1);
    enemy[b - 1].insert(a - 1);
  }

  vector<set<int>> un;
  vector<int> leader;
  for (int i = 0; i < n; ++i) {
    leader.push_back(-1);
  }
  // BFS
  for (int i = 0; i < n; ++i) {
    if (leader[i] >= 0)
      continue;

    leader[i] = un.size();
    un.emplace_back(set<int>());
    // init : suggestions are empty
    set<int> to_visit;
    set<int>& s = un.back();
    to_visit.insert(i);

    while (!to_visit.empty()) {
      auto j = *to_visit.begin();
      to_visit.erase(j);
      s.insert(j);
      for (auto p : graph[j]) {
        if (s.find(p) != s.end())
          continue;
        to_visit.insert(p);
      }
    }

    for (const auto c : s) {
      leader[c] = leader[i];
    }
  }

  for (int i = 0; i < n; ++i) {
    // get the size of union
    int sz = un[leader[i]].size();
    // distract myself and neighbors
    int x = sz - 1 - graph[i].size();
    // if enemy is included, distract
    for (auto j : enemy[i]) {
      if (un[leader[i]].find(j) != un[leader[i]].end())
        --x;
    }
    out << x << " ";
  }
  out << endl;
}

int main() { DFriendSuggestions(cin, cout); }


Measured memory_bytes: 31600
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main()
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    double d,t,s;
    cin>>d>>t>>s;

    double ans = d/s;

    if(ans>t){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }

    return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

int main() {
    double R;
    cin >> R;
    cout << fixed;
    cout << setprecision(10) << R * 2 * PI << endl;
}

Measured memory_bytes: 3808
n = int(input())
ans = 0
S = {}
for _ in range(n):
    s = ''.join(sorted(input()))
    if s in S.keys():
        S[s] += 1
    else:
        S[s] = 1

for i in S.values():
    ans += (i*(i-1)) // 2
print(ans)

Measured memory_bytes: 17852
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

int N, X;
int seq[1000];

int main()
{
	scanf("%d%d", &N, &X);
	int t;
	long long sum = 0;
	for(int i=1; i<=N; i++) scanf("%d", &seq[i]);
	sort(seq+1, seq+N+1);
	for(int i=1; i<=N; i++)
	{
		if(sum + seq[i] > X) {printf("%d\n", i-1); exit(0);}
		else sum += seq[i];
	}
	if(sum == X) printf("%d\n", N);
	else printf("%d\n", N-1);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
      string[] str=Console.ReadLine().Split(' ');
     int[] values=str.Select(int.Parse).ToArray();
      Array.Sort(values);
      double ans=(double)values[0];
      for(int i=1;i<N;i++){
        ans=(double)(ans+values[i])/2;
                  }
       Console.WriteLine(ans);
      
    }
    
  }

}


Measured memory_bytes: 28280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll gcd(ll a,ll b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
int main(){
  ll i,n,t[110];
  cin >> n;
  for(i=0;i<n;i++){
    cin >> t[i];
  }
  if(n==1){
    cout << t[0] << endl;
    return 0;
  }
  ll x=lcm(t[0],t[1]);
  for(i=2;i<n;i++){
    x=lcm(x,t[i]);
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 3552
n,m,l = map(int,input().split())

A = [[int(i) for i in input().split()] for _ in range(n)]
B = [[int(i) for i in input().split()] for _ in range(m)]

for i in range(n):
    for j in range(l):
        print(sum([A[i][k] * B[k][j] for k in range(m)]), end=' ' if j < l - 1 else '\n')


Measured memory_bytes: 6572
def resolve():
    A1 = list(map(int, input().split()))
    A2 = list(map(int, input().split()))
    A3 = list(map(int, input().split()))
    N = int(input())
    b = [int(input()) for i in range(N)]
 
    A = A1 + A2 + A3
    checkA = [0]*9
    for i in range(N):
        if b[i] in A:
            checkA[A.index(b[i])] = 1
    if checkA[0] + checkA[1] + checkA[2] == 3:
        print('Yes')
    elif checkA[3] + checkA[4] + checkA[5] == 3:
        print('Yes')
    elif checkA[6] + checkA[7] + checkA[8] == 3:
        print('Yes')
    elif checkA[0] + checkA[3] + checkA[6] == 3:
        print('Yes')
    elif checkA[1] + checkA[4] + checkA[7] == 3:
        print('Yes')
    elif checkA[2] + checkA[5] + checkA[8] == 3:
        print('Yes')
    elif checkA[0] + checkA[4] + checkA[8] == 3:
        print('Yes')
    elif checkA[2] + checkA[4] + checkA[6] == 3:
        print('Yes')
    else:
        print('No')
resolve()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  string n;
  int num=0;
  cin >> n;
  rep(i, n.size()){
    num+=n[i]-'0';
    num%=9;
  }
  if(num==0){co("Yes");}else{co("No");}
  return 0;
}


Measured memory_bytes: 3700
<?php
$n = (int)trim(fgets(STDIN));
// kからの距離リスト
$dist = [];
$inf = 1000000001;
for ($i=1; $i <= $n; $i++) { 
	$dist[$i] = $inf;
}
// 連結リスト
$list = [];
for ($i=1; $i < $n; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$from = (int)$input[0];
	$to = (int)$input[1];
	$dis = (int)$input[2];
	$list[$from][] = [$to, $dis];
	$list[$to][] = [$from, $dis];
}
// var_dump($list);
$input = explode(' ', trim(fgets(STDIN)));;
$q = (int)$input[0];
$k = (int)$input[1];
$questions = [];
for ($i=0; $i < $q; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$questions[$i] = [(int)$input[0],(int)$input[1]];
}
$dist[$k] = 0;
// exit();
dfs($k);

for ($i=0; $i < $q; $i++) { 
	$tmp = $questions[$i];
	echo $dist[$tmp[0]] + $dist[$tmp[1]] . PHP_EOL;
}


function dfs($k){
	global $dist;
	global $list;
	global $inf;
	$start = $list[$k];
	foreach ($start as $to) {
		if ($dist[$to[0]] === $inf) {
			$dist[$to[0]] = $dist[$k] + $to[1];
			dfs($to[0]);
		}
	}
}


Measured memory_bytes: 207724