akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;

int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,s.size()) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3852
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
p = sorted([-999] + list(map(int, input().split())) + [999])

from bisect import bisect_left, bisect_right

if x not in p:
    print(x)
    exit()

# 小さい方
m = p.index(x) - 1
target_L = x - 1
while True:
    if target_L not in p:
        break
    target_L -= 1

target_R = x + 1
while True:
    if target_R not in p:
        break
    target_R += 1

if abs(target_L - x) <= abs(target_R - x):
    print(target_L)
else:
    print(target_R)


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

//#define mod      1e9+7
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
long long mod=1e9+7;
ll binpow(int a,int b){
	ll ans=1;
	while(b--){
		ans*=a;
		ans%=mod;
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int n,num;
	cin>>n;
	map<int,int> mp;
	for(int i=0;i<n;i++){
		cin>>num;
		mp[num]++;
	}
	if(n&1 && mp[0]!=1){
		cout<<"0\n";
		return 0;
	}
	if(n%2==0 && mp[0]!=0){
		cout<<"0\n";
		return 0;
	}
	if(n&1){
		for(int i=2;i<n;i+=2){
			if(mp[i]!=2){
				cout<<"0\n";
				return 0;
			}
		}
	}
	if(n%2==0){
		for(int i=1;i<n;i+=2){
			if(mp[i]!=2){
				cout<<"0\n";
				return 0;
			}
		}
	}
	ll ans=binpow(2,n/2);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6552
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,tune=native")
 
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int x[N], y[N], h[N], XX = -1, YY = -1, HH = -1;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i]) {
      XX = x[i];
      YY = y[i];
      HH = h[i];
    }
  }
  int height, expected;
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      height = HH + abs(XX - i) + abs(YY - j);
      int k;
      for (k = 0; k < N; k++) {
        expected = max(height - abs(x[k] - i) - abs(y[k] - j), 0);
        if (h[k] != expected)
          break;
      }
      if (k == N) {
        cout << i << ' ' << j << ' ' << height;
        exit(EXIT_SUCCESS);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[10000];
int main(){
	a[0]=a[1]=1;
	for(int i=2;i<10000;i++){
		if(a[i]==0){
		for(int j=i*2;j<10000;j+=i)
				a[j]=1;
		}
	}
	int n;
	while(cin>>n){
		int s=0;
		for(int i=1;i<=n;i++){
			if(a[i]==0 && a[n+1-i]==0)
			s++;
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 3112
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
using namespace std;
using ll = long long;
typedef pair <int, int> pii;

int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	string s[101];
	//long long n, A[1000000000];
	int n, m, q;
	//int   y[100001], z[100001], x[10001] = {};
	//pii y[100001];
	//pair<int, float> pii[100001];
	ll A[100001] = {};

	cin >> a;
	cin >> k;
	for (c = 0; c < a; c++)
	{
		cin >> A[c];
	}
	if (A[0] <= 0 && A[a - 1] <= 0)
	{
		cout << -A[a-k] << endl;

	}
	else if (A[0] >= 0 && A[a - 1] >= 0)
	{
		cout << A[k - 1] << endl;

	}
	else
	{
		d = 10000000000;
		for (c = 0; c < a - k + 1; c++)
		{
			if (A[c] <= 0 && A[c + k - 1] <= 0)
			{
				d = min(-A[c], d);
			}
			else if (A[c] >= 0 && A[c + k - 1] >= 0)
			{
				d = min(A[c+k-1], d);
			}
			else
			{
				d = min(abs(A[c] * 2) + abs(A[c + k - 1]), d);
				d = min(abs(A[c]) + abs(A[c + k - 1])*2,d);

			}
			//cout << d << endl;
		}

		cout << d << endl;
	}





	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}

Measured memory_bytes: 1024
/*problem from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
#define lowbit(x) ((x)&-(x))
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-');
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=1e5;
int v[N+10];
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int check(int n){
	int odd=0,even=0; bool flag=0;
	for (int i=1;i<=n;i++){
		v[i]&1?odd++:even++;
		if (v[i]==1)	flag=1,odd--;
	}
	if (even&1)	return 1;
	if (flag)	return 0;
	if (odd>1)	return 0;
	return -1;
}
int main(){
	int n=read(),Time=0;
	for (int i=1;i<=n;i++)	v[i]=read();
	while (true){
		int tmp=check(n),d=0; ++Time;
		if (~tmp){
			printf((tmp^Time)&1?"Second\n":"First\n");
			break;
		}
		for (int i=1;i<=n;i++)	if (v[i]&1)	v[i]--;
		for (int i=1;i<=n;i++)	d=gcd(d,v[i]);
		for (int i=1;i<=n;i++)	v[i]/=d;
	}
	return 0;
}

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

int main(){
	// sengen
	int a,b,c,d;
	// nyuryoku
	cin >> a >> b >> c >> d;
	// keisan
	int temp;
	if(b>d){
		swap(a,c);
		swap(b,d);
	}
	if(b>c){
		if(c>a){
			cout << b-c;
		}else{
			cout << b-a;
		}
	}else{
		cout << '0';
	}
  
}

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

void solve() {
    string s, t;
    cin >> s >> t;
    int ans = t.size();
    REP(i, 1 + s.size() - t.size()) {
        int cnt = 0;
        REP(j, t.size()) {
            if (s[i+j] != t[j]) {
                ++cnt;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 3608
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
  		
      	String ss[] = new String[3];
      	String sstack = sc.next();
      	char cstack = sstack.charAt(sstack.length()-1);
      	boolean sir = true;
      	
      	for(int i=0; i < 2 && sir;i++) {
          sstack = sc.next();
          if(sstack.charAt(0) != cstack) sir = false;
          cstack = sstack.charAt(sstack.length()-1);
        }
      	
      
      	if(sir) System.out.println("YES");
      	else System.out.println("NO");
	}
}


Measured memory_bytes: 35724
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, k;
    cin >> n >> k;
    ll ret = 0;
    ll ks  = n / k;
    ret    = ks * ks * ks;
    if (k % 2 == 0) {
        ll khalfs = (n - k / 2) / k;
        if (khalfs * k + k / 2 <= n)
            khalfs++;
        ret += khalfs * khalfs * khalfs;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
/*
?????????: Maximum Sum Sequence
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0022&lang=jp
?????°: 
19:13:12 ?°?????????§??????
19:26:09 ?°??????????????????§???????´????????????????
19:26:28 ????´???????????°??????????????´????????????§????????????????????¨??¢?´¢??§5000^2 ... ????????????
19:32:27 ???????????????
*/
#include <iostream>
#include <vector>
using namespace std;


int main()
{
	while(true){
		int n; cin >> n; if(n == 0) {return 0;}
		vector<int> arr;
		for(int i=0; i<n; i++) {
			arr.push_back(0);
			cin >> arr[i];
		}

		vector<int> sums;
		// sums[0] = 0;
		// sums[1] = sums[0] + arr[0]
		sums.push_back(0);
		for(int i=0; i<n; i++) {
			sums.push_back(sums[i] + arr[i]);
		}

		int ans = -100000;
		for(int i=0; i<n; i++) { 
			for(int j = i+1; j <= n; j++){
				ans = max(ans, sums[j] - sums[i]);
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3048
N = gets.to_i
As = gets.split.map(&:to_i)
MOD = 1E9.to_i + 7

def mpow(x, n, acc = 1)
  return acc if n.zero?
  n.even? ? mpow(x * x % MOD, n >> 1, acc) : mpow(x, n - 1, acc * x % MOD)
end

@f = (1 .. N + 1).inject([x = 1]){|a, n| a << x = x * n % MOD}
@i = []; @i[N + 1] = mpow(@f[N + 1], MOD - 2)
(N + 1).downto(1){|n| @i[n - 1] = @i[n] * n % MOD}

def mc(n, k)
  k > n ? 0 : @f[n] * @i[n - k] * @i[k]
end

d = As.group_by(&:itself).flat_map{|k, v| v.one? ? [] : k}[0]
a, b = As.index(d) + 1, As.rindex(d) + 1
(1 .. N + 1).each{|k| puts (mc(N + 1, k) - mc(N + a - b, k - 1)) % MOD}

Measured memory_bytes: 24700
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        int t = a[i];
        while(t % 2 == 0){
            t /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio,
       std.string,
       std.conv;

void main() {
    int N;
    while(N = readln.chomp.to!int, N) {
        auto a = new int[](N+1);
        auto input = readln.chomp;
        int n = 0;
        foreach(c; input) {
            if(c == 'M')
                a[n+1]++;
            if(c == 'S') {
                a[0] += a[n+1] + 1;
                a[n+1] = 0;
            }
            if(c == 'L') {
                a[n+1] += a[0] + 1;
                a[0] = 0;
            }
            n++;
            n%=N;
        }

        auto b = a[1..$].sort;
        foreach(v; b)
            write(v, ' ');
        a[0].writeln;

    }
}

Measured memory_bytes: 1044
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

template <typename T>
struct BIT {
    const ll UNITY_SUM = 0; // 0
    vector<ll> data; // 値
    // 初期化
    BIT(ll n)
        : data(n + 1)
    {
    }
    void init(ll n) { data.assign(n + 1, UNITY_SUM); }
    // data[x]にaを加える
    inline void add(ll a, ll x)
    {
        for (ll i = a; i < (ll)data.size(); i += i & -i) {
            data[i] = data[i] + x;
        }
    }
    //  data[a]までのの和を求める
    inline ll sum(ll a)
    {
        ll res = UNITY_SUM;
        // 最初に立っているbitから求める
        for (ll i = a; i > 0; i -= i & -i) {
            res += data[i];
        }
        return res;
    }
    // 累積和の差から区間の和を求める
    inline ll sum(ll a, ll b)
    {
        return sum(b - 1) - sum(a - 1);
    }
};

main()
{
    // input
    ll N;
    cin >> N;
    vector<ll> a(N);
    for (ll i = 0; i < N; ++i)
        cin >> a[i];
    // 答えがhighになるように2分探索する
    ll low = 0, high = 1 << 30;
    const ll len = N + 1; // 要素数+1
    while (high - low > 1) {
        ll mid = (low + high) / 2;
        long long num = 0; //
        BIT<long long> bit(N * 2 + 10);
        ll sum = 0;
        bit.add(sum + len, 1); // sum+geta以降に1を足す
        for (ll i = 0; i < N; ++i) {
            ll val;
            if (a[i] <= mid) {
                val = 1; // 中央値より大きいなら1
            } else {
                val = -1; // 中央値より小さいなら-1
            }
            sum += val; // 中央値より大きい値が何個あるか
            num += bit.sum(1, sum + len); // numに区間の和を足す
            bit.add(sum + len, 1); // sum+geta以降に1を足す
        }
        // 半数が中央値より上なら上半分に答えがある
        if (2 * num > (N + 1) * N / 2) {
            high = mid;
        } else {
            low = mid;
        }
    }
    cout << high << endl;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main(){
    int n, t, ci, ti;
    cin >> n >> t;
    int menor = 1001;

    for(int i=0;i<n;i++){
        cin >> ci >> ti;
        if(t<ti){
            continue;
        }
        if(ci < menor){
            menor = ci;
        }

    }


    if(menor==1001){
        cout << "TLE" << endl;
    } else{
        cout << menor << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b,i;
    char op;
    
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+'){
            
        
        printf("%d\n",a+b);
        }
        else if(op=='-'){
        printf("%d\n",a-b);
        }
        else if(op=='*'){
        printf("%d\n",a*b);
        }
        else if(op=='/'){
        printf("%d\n",a/b);
        }
        else if(op=='?'){
         break;}
    }
    return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
    int a,b,c;
    cin>>a>>b>>c;

    if(a==b)cout<<c<<endl;
    else if(a==c)cout<<b<<endl;
    else cout<<a<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;

int main()
{
  stack<int> S;
  int a, b, x;
  char s[100];

  while (cin >> s) {
    if (s[0] == '+') {
      a = S.top();  S.pop();
      b = S.top();  S.pop();
      S.push(a + b);
    } else if (s[0] == '-') {
      a = S.top();  S.pop();
      b = S.top();  S.pop();
      S.push(b - a);
    } else if (s[0] == '*') {
      a = S.top();  S.pop();
      b = S.top();  S.pop();
      S.push(a * b);
    } else {
      S.push(atoi(&s[0]));
    }
  }
  cout << S.top() << endl;
}



Measured memory_bytes: 3124
/* ex9_1
   moka223711 */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 15

typedef struct stack{ // 文字列を格納するスタック
    int size;
    int count; // スタックに格納されたデータ数を表す変数
    char data[SIZE]; // スタックにデータを格納するための配列
    char *top; // スタックの先頭アドレスを表すポインタ
}stack;

void initialize_stack(stack *stk); // スタックを初期化するための関数
void print_stack(stack *stk); // スタックに格納されているデータを出力するための関数
void push(stack *stk, char input); // スタックの先頭にデータを格納するための関数
char pop(stack *stk); // スタックの先頭からデータを取り出すための関数

int main(void){
    stack stk;
    char input; // 入力を受け取るための変数
    initialize_stack(&stk); // スタックを初期化
    while((input = getchar()) != EOF){ // 入力ファイルの終端に達するまで文字を受け取る
        if(input != 'B')push(&stk, input); // 入力された文字が'0'か'1'だったときはスタックの先頭に文字を格納する
        else if(stk.count > 0)pop(&stk); // 入力された文字が'B'でありスタックの要素が空でなければ先頭から文字を削除する
    }
    print_stack(&stk); // スタックに格納されているデータを出力
    return 0;
}

// スタックを初期化するための関数
void initialize_stack(stack *stk){
    stk->count = 0; // スタックに格納されているデータの総数は0
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]); // スタックの先頭アドレスをstk->topに格納する
}

void print_stack(stack *stk){
    int i;
    for(i = 0; i < stk->count; i++) // 格納されているデータをすべて出力していく
        printf("%c", stk->data[stk->size-i-1]); // 古い要素から順番に出力していく
    printf("\n");// 最後に改行を出力して終了
}

// スタックの先頭にデータを格納するための関数
void push(stack *stk, char input){
    if(stk->count >= stk->size)
        exit(1);
    else{
        stk->top--; // スタックの先頭のアドレスを一つずらす
        *(stk->top) = input; // スタックの先頭に文字を格納する
        stk->count++; // スタックのデータの総数のカウントを一つ増やす
    }
}

char pop(stack *stk){
    char ch;
    if(stk->count <= 0)
        exit(1);
    else{
        ch = *(stk->top);
        stk->top++; // スタックの先頭アドレスを一つずらす
        stk->count--; // スタックのデータの総数のカウントを一つ減らす
        return ch;
    }
}


Measured memory_bytes: 1528
s = input()

if len(s) % 2:
  white_black = '10' * (len(s) // 2) + '1'
  black_white = '01' * (len(s) // 2) + '0'
else:
  white_black = '10' * (len(s) // 2)
  black_white = '01' * (len(s) // 2)

if s == white_black or s == black_white:
  count = 0
else:
  diff_wb = sum([len(x) for x, y in zip(s, white_black) if x != y])
  diff_bw = sum([len(x) for x, y in zip(s, black_white) if x != y])
  count = min(diff_wb, diff_bw)

print(count)

Measured memory_bytes: 4084
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():

    n, *a = (int(x) for x in sys.stdin.read().split())
    c = collections.Counter(a)
    count = 0
    for i, j in c.items():
        if j < i: count += j
        else: count += j - i
    
    print(count)
    
if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 18728
class UnionFindVerSize():
    def __init__(self, N,init):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self._parent = [n for n in range(0, N)]
        self._size = [1] *N
        # グループのサイズ（個数）
        self._weight=init
        self._set=[[0,0] for i in range(N)]

    def find_root(self, x):
        """ xの木の根(xがどのグループか)を求める """
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x]) # 縮約
        return self._parent[x]

    def unite(self, x, y):
        """ xとyの属するグループを併合する """
        gx = self.find_root(x)
        gy = self.find_root(y)

        if gx == gy:return

        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._weight[gy]+=self._weight[gx]
            self._size[gy]+=self._size[gx]
            self._set[gy][0]+=self._set[gx][0]
            self._set[gy][1]+=self._set[gx][1]

        else:
            self._parent[gy] = gx
            self._weight[gx]+=self._weight[gy]
            self._size[gx]+=self._size[gy]
            self._set[gx][0]+=self._set[gy][0]
            self._set[gx][1]+=self._set[gy][1]

    def add(self,i,u,key):
        x=self.find_root(u)
        if key:
            self._set[x][0]+=self._set[x][1]+1
            self._set[x][1]=0
        else:
            self._set[x][1]+=1

    def get_size(self, x):
        """ xが属するグループのサイズ（個数）を返す """
        return self._size[self.find_root(x)]

    def get_weight(self,x):
        return self._weight[self.find_root(x)]

    def get_set(self,x):
        return self._set[self.find_root(x)]

    def is_same_group(self, x, y):
        """ xとyが同じ集合に属するか否か """
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        """ グループ数を計算して返す """
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans

import sys

input=sys.stdin.readline

N,M=map(int,input().split())
weight=list(map(int,input().split()))
edge=[]
for i in range(M):
    u,v,c=map(int,input().split())
    edge.append((c,u-1,v-1))
edge.sort()

uf=UnionFindVerSize(N,weight)
for i in range(M):
    c,u,v=edge[i]
    uf.unite(u,v)
    uf.add(i,u,uf.get_weight(u)>=c)

no=uf.get_set(0)[1]
print(no)

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

typedef unsigned long long uLL;
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;
typedef pair <long long,long long> pll;
typedef pair <long long,pll> plll;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int MOD = 1000000007;

int n , m;
bool vis[ N ];
int dp[ N ];
vector <int> graph[ N ];


int solve( int s , int p ) {
        vis[s] = true;
        if( dp[s] != -1 ) return dp[s];
        int ret = 0;
        for( auto x : graph[s] ) {
                if( x != p ) ret = max( ret , 1 + solve( x , s ) );
        }
        return dp[s] = ret;
}

stack <int> S;
void Topological_Sort( int s ) {
    vis[ s ] = true;
    for( int i = 0; i < graph[ s ].size(); i++ ) {
        int next = graph[ s ][ i ];
        if( !vis[ next ] ) {
            Topological_Sort( next );
        }
    }
    S.push( s );
}
int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( NULL );
        cin >> n >>m;
        for( int i = 1; i <= m; i++ ) {
                int u , v;
                cin >> u >> v;
                graph[u].push_back( v );
        }
        /*
        for( int i = 1; i <= n; i++ ) {
            if( !vis[ i ] ) {
                Topological_Sort( i );
            }
        }*/

        memset( dp , -1 , sizeof( dp ) );
        int mx = 0;
        for( int i = 1; i <= n; i++ ) {
                if( !vis[i] ) mx = max( mx , solve( i , 0 ) );
        }
        cout << mx <<endl;
        /*
        //memset( vis , false , sizeof( vis ) );
        //int mx = 0;
        while( !S.empty() ) {
            int top = S.top();
            S.pop();
            if( !vis[ top ] ) {
                mx = max( mx , solve( top , 0 ) );
            }
        }
        cout << mx << endl;*/
        return 0;
}













Measured memory_bytes: 8960
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }

    let mut count = 0;

    for i in 0..n-2 {
        if cmp::max(p[i], cmp::max(p[i+1], p[i+2])) == p[i]
            && cmp::min(p[i], cmp::min(p[i+1], p[i+2])) == p[i+2] {
                count = count + 1;
        } else if cmp::max(p[i], cmp::max(p[i+1], p[i+2])) == p[i+2]
            && cmp::min(p[i], cmp::min(p[i+1], p[i+2])) == p[i] {
                count = count + 1;
        }
    }

    println!("{}", count);
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);	
		int N = io.nextInt();
		String s = io.next();
		s = s + s.charAt(0);
		int[] exp = new int[N+2];
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				exp[0] = (i==0)?1:-1;
				exp[1] = (j==0)?1:-1;
				for(int k=2;k<=N+1;k++){
					if(exp[k-1]==1){
						exp[k] = (s.charAt(k-1)=='o')?exp[k-2]:-exp[k-2];
					}else{
						exp[k] = (s.charAt(k-1)=='o')?-exp[k-2]:exp[k-2];
					}
				}
				if(exp[0]==exp[N] && exp[1]==exp[N+1]){
					StringBuffer ans = new StringBuffer();
					for (int l = 0; l < N; l++) {
						ans.append((exp[l]==1)?'S':'W');
					}
					System.out.println(ans);
					return;
				}
			}
		}
		System.out.println(-1);
	}
}

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

int main() {
  int n, m, cnt = 0;
  cin >> n;

  for (size_t i = 0; i < n; i++) {
    cin >> m;
    if (m == 2) {
      cnt++;
      continue;
    } else if (m % 2 == 0) {
      continue;
    }

    bool is_prime = true;
    for (size_t j = 3; j <= sqrt(m); j += 2) {
      if (m % j == 0) {
        is_prime = false;
        break;
      }
    }
    if (is_prime) cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>

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

using namespace std;

int main() {

	string s;
	cin >> s;
	sort(s.begin(), s.end());

	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
		cout << "Yes";
	else
		cout << "No";

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from math import gcd


def read():
    K = int(input().strip())
    return K,


def solve(K):
    seven = 0
    for i in range(1, K+1):
        seven = seven * 10 + 7
        seven %= K
        if seven == 0:
            return i
    return -1


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

long long inf = 1e9 + 7;

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

    if (abs(n-m) > 1) {
        cout << 0 << endl;
        return 0;
    }

    if (n == m) {
        long long ans1 = 1, ans2 = 1;
        for (int i = 1; i <= n; i++) {
            ans1 *= i % inf;
            ans1 %= inf;
        }
        cout << (2 * ans1 * ans1) % inf << endl;
            return 0;
    }

    if (n < m) {
        long long tmp = n;
        n = m;
        m = tmp;
    }

    long long ansn = 1, ansm = 1;
    for (int i = 1; i <= n; i++) {
        ansn *= i % inf;
        ansn %= inf;
    }
    for (int i = 1; i <= m; i++) {
        ansm *= i % inf;
        ansm %= inf;
    }

    cout << ansn * ansm % inf << endl;
    return 0;
}

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

using ll = unsigned long long;

char grid[402][402];
bool seen[402][402];
int H, W;
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};

ll search(int i, int j) {
  ll black = 0;
  ll white = 0;
  queue<pair<int, int>> q;
  q.push({i, j});
  seen[i][j] = true;

  while (!q.empty()) {
    tie(i, j) = q.front();
    q.pop();
    black += (grid[i][j] == '#');
    white += (grid[i][j] == '.');
    for (int di = 0; di < 4; ++di) {
      int nx = i + dx[di];
      int ny = j + dy[di];
      if (nx >= 0 && nx < H && ny >= 0 && ny < W && !seen[nx][ny] && grid[nx][ny] == ((grid[i][j] == '.') ? '#' : '.')) {
        seen[nx][ny] = true;
        q.push({nx, ny});
      }
    }
  }

  return black * white;
}

int main() {
  scanf("%d%d", &H, &W);
  fill(&seen[0][0], &seen[H + 1][W + 1], false);
  for (int i = 0; i < H; ++i) {
    scanf("%s", grid[i]);
  }

  ll res = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (!seen[i][j]) {
        res += search(i, j);
      }
    }
  }

  printf("%llu\n", res);
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)
#define MOD 1000000007

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; string s; cin >> n >> s;

    int f[26]; memset(f, 0, sizeof f);
    FOR(i, 0, n-1) {
        ++f[s[i]-'a'];
    }

    ll ans = 1;
    FOR(i, 0, 25) ans = ans*(f[i]+1) % MOD;
    cout << (ans-1+MOD)%MOD << '\n';
}



Measured memory_bytes: 1100
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def inp():
    return int(input())
def inps():
    return input().rstrip()
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10

# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque 

# ---------------------------------------

N = inp()
S = inps()

r = []
g = []
b = []

for i in range(N):
    if S[i] == "R":
        r.append(i)
    if S[i] == "G":
        g.append(i)
    if S[i] == "B":
        b.append(i)

ans = 0
for i in r:
    for j in g:
        m = i
        n = j
        if m > n:
            m, n = n, m
        sa = abs(m - n)
        ans += len(b)
        if m - sa >= 0 and S[m - sa] == "B":
            ans -= 1
        if n + sa < N and S[n + sa] == "B":
            ans -= 1
        if sa % 2 == 0 and S[m + sa//2] == "B":
            ans -= 1
print(ans)


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

using namespace std;

#define MAX_V 100010
#define INF (1<<29)

struct Edge{
  int to,cost;
  Edge(int to,int cost) : to(to),cost(cost) {}
};

struct State{
  int v,cost;
  State(int v,int cost) : v(v),cost(cost) {}
  bool operator < (const State &s)const{
    return cost > s.cost;
  }
};

int V,maxi,start;
int dist[MAX_V];
bool visited[MAX_V];
vector<Edge> G[MAX_V];

void getStart(int v,int d){
  if(dist[v] < INF){ return; }
  dist[v] = d;
  if(maxi < d){ maxi = d; start = v; }
  for(int i = 0 ; i < (int)G[v].size() ; i++){
    Edge e = G[v][i];
    getStart(e.to,d+e.cost);
  }
}

int getTreeDiameter(int v){
  int res = 0;
  for(int i = 0 ; i < (int)G[v].size() ; i++){
    Edge e = G[v][i];
    if(!visited[e.to]){
      visited[e.to] = true;
      res = max(res,e.cost+getTreeDiameter(e.to));
    }
  }
  return res;
}

int main(){
  int a,b,w;
  cin >> V;
  for(int i = 0 ; i < V-1 ; i++){
    cin >> a >> b >> w;
    G[a].push_back(Edge(b,w));
    G[b].push_back(Edge(a,w));
  }
  maxi = 0; fill(dist,dist+V,INF);
  getStart(0,0);
  memset(visited,false,sizeof(visited));
  visited[start] = true;
  cout << getTreeDiameter(start) << endl;
  return 0;
}

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

int dp[200010][3];

int main(void){
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n){
        rep1(d,2){
            if (i >= d) {
                if (s.substr(i-d, d) != s.substr(i, d)) {
                    dp[i+d][d] = max(dp[i+d][d], dp[i][d]+1);
                }
            }    
        }
        dp[i+1][1] = max(dp[i+1][1], dp[i][2]+1);
        dp[i+2][2] = max(dp[i+2][2], dp[i][1]+1);
    }
    cout << max(dp[n][1], dp[n][2]) << endl;
    return 0;
}


Measured memory_bytes: 2948
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e9;
ll power(ll x, ll n, ll mod)
{
  ll res = 1;
  x %= mod;
  while (n)
  {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res%mod;
}
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  ll n;
  cin>>n;
  if(n>=30)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}


Measured memory_bytes: 3644
s=input()
n=len(s)
if n<=1:
  print("No")
  exit()
for i in range(n):
  if i!=n-1 and s[i]=="h":
    if s[i+1]!="i":
      print("No")
      exit()
  elif i!=0 and s[i]=="i":
    if s[i-1]!="h":
      print("No")
      exit()
  elif s[i]!="h" or s[i]!="i":
      print("No")
      exit()
print("Yes")


Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
A = [0]+A+[0]
ans = 0
for i in range(1,N+2):
    ans += abs(A[i]-A[i-1])

for i in range(1,N+1):
    print(ans - abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))


Measured memory_bytes: 20572
N, A, B = map(int, input().split())

ans = 0
for i in range(1, N+1):
  digit_sum = 0
  for j in range(len(str(i))):
    digit_sum += int(str(i)[j])
  if (digit_sum >= A) and (digit_sum <= B):
    ans += i
print(int(ans))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

static std::array<std::pair<int, int>, 4> directions = {
    std::make_pair(0, 1),
    std::make_pair(1, 0),
    std::make_pair(0, -1),
    std::make_pair(-1, 0),
};

int solve(int h, int w, std::vector<std::vector<int>> as,
          std::vector<std::pair<int, int>> blacks) {
  int ret = 0;
  while (true) {
    std::vector<std::pair<int, int>> nextBlacks;
    nextBlacks.reserve(blacks.size() * 4);
    for (const auto& black : blacks) {
      int const y = black.first;
      int const x = black.second;
      for (const auto& direction : directions) {
        int const yy = y + direction.first;
        if (yy < 0 || h <= yy) {
          continue;
        }
        int const xx = x + direction.second;
        if (xx < 0 || w <= xx) {
          continue;
        }
        if (as[yy][xx] <= ret + 1) {
          continue;
        }
        as[yy][xx] = ret + 1;
        nextBlacks.emplace_back(std::make_pair(yy, xx));
      }
    }
    if (nextBlacks.empty()) {
      return ret;
    }
    blacks = std::move(nextBlacks);
    ret += 1;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int h;
  std::cin >> h;
  int w;
  std::cin >> w;
  std::vector<std::pair<int, int>> blacks;
  std::vector<std::vector<int>> as(h, std::vector<int>(w, INT_MAX));
  for (int y = 0; y < h; y++) {
    std::string s;
    std::cin >> s;
    for (int x = 0; x < w; x++) {
      auto const ch = s[x];
      if (ch == '#') {
        as[y][x] = 0;
        blacks.emplace_back(std::make_pair(y, x));
      }
    }
  }
  auto const res = solve(h, w, std::move(as), std::move(blacks));
  std::cout << res << std::endl;
  return 0;
}


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

int main(){
        int A, B;
        scanf("%d %d", &A, &B);
    if (B % A == 0) {
        printf("%d\n", A + B);
    } else {
        printf("%d\n", B - A);
    }
    return 0;
}


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

int main(){
  int num;
  string s,t;
  string kekka = "";
  
  cin >> num >> s >> t;
  
  for(int i = 0; i < num; i++){
    kekka += s.substr(i,1) + t.substr(i,1);
  }
  
  cout << kekka;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;
 
 
ll gcd(ll a, ll b){
  if (a%b == 0){return(b);}
  else{return(gcd(b, a%b));}
}
 
int main(){
  ll a, b;
  cin >> a >> b;
  ll c =gcd(a,  b);
  ll cnt = 1;
  for (ll i = 2; i * i < c+1; i++){
    if (c % i == 0){
      cnt ++;
      while (c % i == 0){c = c/i;}
    }
  }
  if (c != 1){cnt ++;}
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;
  
  vector<vector<char>> map (h,vector<char>(w));
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> map.at(i).at(j);
    }
  }
  
  vector<bool> line(h,false);
  vector<bool> column(w,false);
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++){
      if (map.at(i).at(j) == '#') {
        line.at(i) = true;
        column.at(j) = true;
      }
    }
  }
  
  for(int i = 0; i < h; i++) {
    if (line.at(i)) {
      for (int j = 0; j < w; j++) {
        if(column.at(j)) {
          cout << map.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 3588
#include"bits/stdc++.h"
#define rep(i,a) for(int i=0;i<(a);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define ll long long
using namespace std;

int main(){
  const unsigned ll MAX=10e18;
  unsigned int n=0,x,y;

  cin>>x>>y;
  if(y==1||!(x%y)){
    cout<<"-1"<<endl;
  }else{
    for(int i=(x>y?2:y+1);(unsigned ll)(x*i)<=MAX;i++){
      if(!i%y) continue;
      if((x*i)%y){
        cout<<x*i<<endl;
        n++;
        break;
      }
    }
    if(!n) cout<<"-1"<<endl;
  }
}


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

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

  int64_t N;
  cin >> N;

  string c(N, 'a');
  cin >> c;

  int64_t cnt = 0;

  int64_t j = N - 1;
  int64_t i = 0;

  while (i < j and j >= 0 and i <= N - 1) {
    if (c[i] == 'W' and c[j] == 'W') {
      j--;
    }
    if (c[i] == 'W' and c[j] == 'R') {
      i++;
      j--;
      cnt++;
    }
    if (c[i] == 'R' and c[j] == 'W') {
      i++;
      j--;
    }
    if (c[i] == 'R' and c[j] == 'R') {
      i++;
    }
  }
  cout << cnt;

  return 0;
}


Measured memory_bytes: 3612
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif
 
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}
 
template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

int a, b;

void solve() {
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
}

signed main() {
	cout << fixed << setprecision(20);
	solve();
	while(true) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

long long diff(long long a,long long b){if(a>b){return a-b;}return b-a;}

int main(void){
	long long a,b;
	scanf("%lld%lld",&a,&b);
	if(diff(a,b) <= 1){printf("Brown\n");}else{printf("Alice\n");}
	return 0;
}

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

int sento(int n){
	string s = to_string(n);
	return s[0] - '0';
}

int matsubi(int n){
	string s = to_string(n);
	return s[s.size()-1] - '0';
}

int main(){
	int n;
	cin >> n;
	
	ll ans = 0;
	int c[10][10] = {};
	
	
	REP(i,n){
		c[sento(i)][matsubi(i)]++;
	}
	
	
	rep(i,10){
		rep(j,10){
			ans += c[i][j]*c[j][i];
		}
	}
	
	cout << ans << endl;
	
}


Measured memory_bytes: 256
use std::io::{Read, stdin};
use std::str::FromStr;

fn main() {
    let n: i64 = read();
    let mut ans: i64 = 1;
    let k:i64 = 1000000000 + 7;
    for i in 0..n {
        ans = (ans * (i + 1)) % k;
    }
    println!("{}", ans);
}


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

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

using namespace std;
typedef long long ll;

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

int main(){
// ここに処理を記述
    int M, D;
    cin >> M >> D;

    int ans = 0;
    FOR(i,1,M+1){
        FOR(j,1,D+1){
            int d1 = j%10;
            int d2 = j/10;
            if(d1 < 2 || d2 < 2) continue;
            if(i == d1 * d2) ans++;
        }
    }

    cout << ans << "\n";

return 0;
}

Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
ans = 1
zero = 0
for ele in li:
	if ele == 0:
		zero = 1
		break
if zero == 1:
	print(0)
else:
	ans = 1
	for ele in li:
		ans = ans * ele
		if ans > 1000000000000000000:
			ans = -1
			break
	print(ans)

Measured memory_bytes: 21584
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define all(V) V.begin(),V.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
//関数とか

//宣言とか
ll dp[100100];
ll n;
/*signed*/int main(void) {
    cin >> n;
    vector<ll> h(n);
    fill(dp, dp+n, INF);
    dp[0] = 0;
    rep(i, n)cin >> h[i];
    rep(i, n) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 4804
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int [] A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int K = sc.nextInt();
        
        System.out.println(A[K-1]);
    }
}


Measured memory_bytes: 35632
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    ll t = c - a - b;
    if (t <= 0) {
        cout << "No" << endl;
        return 0;
    }

    if (t * t > (4 * a * b)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256