akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : JOI.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;

int main() {

	string str;
	int d=0;
	cin>>str;


	for(int i=0; i<str.size();++i){
		if(str[i]=='A'&&str[i+1]=='C'){
			d+=1;
		}
	}
		if(d>0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}








}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define TO_STRING(a) #a
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }
template<class T> void MSG(T a){ cout << TO_STRING(a) << " = " << a << endl; }


int dp[101][3][2];
int field[101];

const int MOD = 10000;

int rec(pint b, int no, int lim)
{
	if(no == lim)
		return 1;
	
	int res = 0;
	
	if(field[no] == 4)
	{
		rep(i, 3)
		{
			if(!(b.first == b.second && b.second == i))
			{
				pint buf = b;
				swap(b.first, b.second);
				b.second = i;
				res = (res + rec(buf, no+1, lim)) % MOD;
			}
		}
	}
	else
	{
		if((b.first == b.second && b.second == field[no]))
			return 0;
		
		swap(b.first, b.second);
		b.second = field[no];
		
		return rec(b, no+1, lim);
	}
	
	return res % MOD;
}




int main()
{
	const int INF = 1 << 30;
	
	memset(dp, 0, sizeof(dp));
	rep(i, 101) field[i] = 15;
	
	int n, k;
	cin >> n >> k;
	
	rep(i, k)
	{
		int p, s;
		cin >> p >> s;
		
		field[p-1] = s-1;
	}
	
	// initialize
	if(field[0] != 15)
	{
		dp[0][field[0]][0] = 1;
	}
	else
	{
		rep(i, 3)
		dp[0][i][0] = 1;
	}
	
	REP(i, 1, n)
	{
		if(field[i] != 15)
		{
			dp[i][field[i]][0] = (dp[i-1][(field[i] + 1)%3][0] + dp[i-1][(field[i] + 1)%3][1] + dp[i-1][(field[i] + 2)%3][0] + dp[i-1][(field[i] + 2)%3][1]) % MOD;
			dp[i][field[i]][1] = dp[i-1][field[i]][0];
		}
		else
		{
			rep(j, 3)
			{
				dp[i][j][0] += (dp[i-1][(j+1)%3][0] + dp[i-1][(j+1)%3][1] + dp[i-1][(j+2)%3][0] + dp[i-1][(j+2)%3][1]) % MOD;
				dp[i][j][1] += dp[i-1][j][0];
			}
		}
	}
	
	int res = 0;
	rep(i, 3) rep(j, 2) res += dp[n-1][i][j];
	
	cout << res % MOD << endl;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var n int
	_, _ = fmt.Scan(&n)

	fmt.Println(answer162B(n))
}

func answer162B(n int) int {
	var sum int

	for i := 1; i <= n; i++ {
		if !(i%3 == 0 || i%5 == 0) {
			sum += i
		}
	}

	return sum
}


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

int main() {
    unsigned long N, M;
    cin >> N >> M;
    vector<vector<unsigned long>> edges(N);
    for (unsigned long i = 0, a, b; i < M; ++i) {
        cin >> a >> b;
        --a;
        --b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<unsigned long> used(N);
    deque<unsigned long> ans({0});
    unsigned long beg = 0;
    used[0] = 1;

    while([&edges, &beg, &used, &ans]{
        for(const auto i : edges[beg])
            if(!used[i]){
                used[beg = i] = 1;
                ans.push_back(beg);
                return true;
            }
        return false;
    }());

    beg = 0;

    while([&edges, &beg, &used, &ans]{
        for(const auto i : edges[beg])
            if(!used[i]){
                used[beg = i] = 1;
                ans.push_front(beg);
                return true;
            }
        return false;
    }());

    cout << ans.size() << endl;
    for(const auto i : ans)cout << i + 1 << " ";

    return 0;
}

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

int main() {
    int N, a, ans = 100, count;
    cin >> N;
    rep(i, N){
        count = 0;
        cin >> a;
        while (a % 2 == 0){
            a /= 2;
            count ++;
        }
        if (count < ans){
            ans = count;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
 ll X;
 cin>>X;
 ll ans=0;
 for(int i=1; i<35; i++){
     int cnt=i;
     for(int j=0; j<11; j++){
         cnt*=i;
         if(cnt<=X){
             if(ans<cnt){
                 ans=cnt;
             }
         }
         if(X<cnt){
             j+=40;
         }    
     }
     } 
     cout<<ans<<endl;
 }



Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }


#define debug(x) cout << #x << "==" << x << endl;

const int mod = 1e+9 + 7;

typedef long long ll;



int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  map<int,int> mp;
  int tmp;
  for(int i = 0; i<N;i++){
    cin >> tmp;
    mp[tmp]++;
  }

  
  int M;
  cin >> M;
  for(int i = 0; i<M; i++){
    cin >> tmp;
    if(mp[tmp] > 0){
      mp[tmp]--;
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  
  cout << "YES" << endl;

  return 0;
}


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

using namespace std;

int main() {

	int l, r, d;

	cin >> l >> r >> d;

	int ans = 0;

	for (int i = l; i <= r; i++) {
		if (i % d == 0)
			ans++;
	}

	cout << ans << "\n";

	return 0;
}

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

typedef long long ll;

int main() {
    int N; cin >> N;
    vector<long long> a(N*3);
    for (int i = 0; i < N*3; ++i) cin >> a[i];

    // 左から前処理
    vector<long long> S(N*2+1, 0);
    priority_queue<long long, vector<long long>, greater<long long> > que1;
    for (int i = 0; i < N; ++i) {
        S[i+1] = S[i] + a[i];
        que1.push(a[i]);
    }
    for (int i = N; i < 2 * N; i++) {
        que1.push(a.at(i));
        ll mi = que1.top();
        que1.pop();
        S.at(i + 1) = S.at(i) + a.at(i) - mi;
    }

    // 右から前処理
    vector<long long> T(N*2+ 1, 0);
    priority_queue<long long> que2;
    for (int i = 0; i < N; ++i) {
        T[i+1] = T[i] + a[N*3-1 - i];
        que2.push(a[N*3-1 - i]);
    }
    for (int i = N; i < 2 * N; i++) {
        que2.push(a.at(3 * N - 1 - i));
        ll ma = que2.top();
        que2.pop();
        T.at(i + 1) = T.at(i) + a.at(3 * N - 1 - i) - ma;
    }

    // 集計
    long long res = -(1LL<<60);
    for (int i = N; i <= N*2; ++i) {
        res = max(res, S[i] - T[N*3-i]);
    }
    cout << res << endl;
}


Measured memory_bytes: 8052
using System.Linq;
using System.Numerics;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        getAns(n, a);
    }
    static void getAns(int n, long[] a)
    {
        if (a.Contains(0)) { Console.WriteLine(0); return; }
        BigInteger ans = 1;
        for (int i = 0; i < n; i++)
        {
            ans *= a[i];
            if (ans > 1000000000000000000) { Console.WriteLine(-1); return; }
        }
        Console.WriteLine(ans);
    }
}

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

using namespace std;

int main()
{
	string S;
	cin >> S;
	int x = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '1') {
			x++;
		 }
	}


	cout << x << endl;
}


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

using namespace std;
typedef long long ll;

const int N = int(1e5) + 7;

void init(){

}

void solve(){
    char c[N];
    scanf("%s", c);
    int l = strlen(c);
    stack<int> st;
    int ans = 0;
    for(int i = 0; i < l; i++){
        int k = c[i] - '0';
        if(!st.empty() && st.top() != k){
            st.pop();
            ans += 2;
        }
        else
            st.push(k);
    }
    printf("%d\n", ans);
}

int main(){
    int test_cases_number = 1;
//    scanf("%d", &test_cases_number);
//    ios_base::sync_with_stdio(0);
//    cin.tie(0); cout.tie(0);
//    cin >> test_cases_number;
    for(int i = 0; i < test_cases_number; i++)
        solve();
}



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

int main(){
    int  N;
    cin >> N;
    int count = 0;

    for (int i = 1;i <= N;i++){
        if (to_string(i).size() % 2 != 0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define loop while(1)

int main(void){
	int m , f , r;
	loop{
		cin>>m>>f>>r;
		if(m==-1 && f==-1 && r==-1) break;
		if(m==-1 || f==-1) {
			cout << 'F' << "\n";
		} else if ((m+f)>=80) {
			cout << 'A' << "\n";
		} else if ((m+f)>=65 && (m+f)<80) {
			cout << 'B' << "\n";
		} else if ((m+f)>=50 && (m+f)<65 ) {
			cout << 'C' << "\n";
		} else if ((m+f)>=30 && (m+f)<50){
			if(r>=50){
				cout << 'C' <<"\n";
			} else {
				cout << 'D' << "\n";
			}
		} else {
			cout << 'F' << "\n";
		}
	}
	return 0;
}

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

int main() {
  string s;
  int sum = 0;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '1') {
      sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3460
N=int(raw_input())

#ary=[]

sum=0

for i in range(N):
    X,U = raw_input().split()
    if U == 'JPY':
        sum = sum + int(X)
    else:
#        print float(X) * 380000
        sum = sum + (float(X) * 380000)

print sum


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

lli dp[400][400];

void func(long long N, long long M, long long L, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C, long long Q, std::vector<long long> s, std::vector<long long> t){

    REP(i,0,N)dp[i][i]=0;

    REP(k,0,N)REP(i,0,N)REP(j,0,N)chmin(dp[i][j],dp[i][k]+dp[k][j]);

    REP(i,0,N)REP(j,0,N){
        LOG3(i,j,dp[i][j]);
        if(i==j)dp[i][j]=0;
        else if(dp[i][j]<=L)dp[i][j]=1;
        else dp[i][j] = INF;
    }

    REP(k,0,N)REP(i,0,N)REP(j,0,N)chmin(dp[i][j],dp[i][k]+dp[k][j]);

    REP(i,0,Q){
        if(dp[s[i]][t[i]]==INF)cout<<-1<<endl;
        else cout<<dp[s[i]][t[i]]-1<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);


    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long L;
    scanf("%lld",&L);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    
    REP(i,0,N)REP(j,0,N)dp[i][j]=INF;

    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
        
        A[i]--,B[i]--;
        dp[A[i]][B[i]]=C[i];
        dp[B[i]][A[i]]=C[i];
    }
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> s(Q);
    std::vector<long long> t(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&t[i]);
        s[i]--,t[i]--;
    }
    func(N, M, L, std::move(A), std::move(B), std::move(C), Q, std::move(s), std::move(t));
    return 0;
}


Measured memory_bytes: 3840
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sum = 0
for i in range(n):
    if(b[i] > a[i]):
        b[i] -= a[i]
        sum += a[i]
        a[i] = 0;
      
        if(b[i] > a[i+1]):
          sum += a[i+1]
          a[i+1] = 0;
        else:
          a[i+1] -= b[i]
          sum += b[i]
    else:
        sum += b[i]
print(sum)

Measured memory_bytes: 24136
#include <iostream>
#define N 300005
using namespace std;
typedef long long ll;
ll n, a, b, k, ans, M=998244353;
ll fac[N]={1,1}, inv[N]={1,1}, fiv[N]={1,1};

ll c(ll p) {
	if(p>n) return 0;
	return fac[n] * fiv[n-p] % M * fiv[p] % M;
}

int main() {
	cin>>n>>a>>b>>k;
	ll i;
	for(i=2; i<=n; i++) {
		fac[i] = fac[i-1] * i % M;
		inv[i] = inv[M%i] * (M-M/i) % M;
		fiv[i] = fiv[i-1] * inv[i] % M;
	}
	for(i=0; i<=n && a*i<=k; i++) {
		if((k-a*i)%b == 0) ans += c(i) * c((k-a*i)/b) % M;
	}
	cout<<ans%M;
	return 0;
}

Measured memory_bytes: 7296
a11,a12,a13 = (x for x in input().split())
a21,a22,a23 = (x for x in input().split())
a31,a32,a33 = (x for x in input().split())
N = int(input())
b = list()
for _ in range(N):
    b.append(input())
if a11 in b and a12 in b and a13 in b:
    print("Yes")
elif a21 in b and a22 in b and a23 in b:
    print("Yes")
elif a31 in b and a32 in b and a33 in b:
    print("Yes")
elif a11 in b and a21 in b and a31 in b:
    print("Yes")
elif a12 in b and a22 in b and a32 in b:
    print("Yes")
elif a13 in b and a23 in b and a33 in b:
    print("Yes")
elif a11 in b and a22 in b and a33 in b:
    print("Yes")
elif a13 in b and a22 in b and a31 in b:
    print("Yes")
else:
    print("No")


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}


int t[110][110];
int a[10000];

int main2() {
  int H = nextInt();
  int W = nextInt();
  int N = nextInt();
  REP(i, N) {
    a[i] = nextInt();
  }

  int color = 0;
  for (int i = 0; i < H; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < W; j++) {
        t[i][j] = color + 1;
        if (--a[color] == 0) color++;
      }
    } else {
      for (int j = W -1 ; j >= 0; j--) {
        t[i][j] = color + 1;
        if (--a[color] == 0) color++;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    printf("%d", t[i][0]);
    for (int j = 1; j < W; j++) 
      printf(" %d", t[i][j]);
    printf("\n");
  }

  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

class UnionFindTrees{
	public:
		UnionFindTrees(int _n){
			n = _n;
			root = vector<int>(_n);
			tree_size = vector<int>(_n,1);
			rep(i,_n) root[i] = i;
		}
		int find(int x){
			if(root[x]==x) return x;
			else return root[x]=find(root[x]);			
		}
		bool same(int x, int y){
			return find(x)==find(y);
		}
		void merge(int x, int y){
			if(same(x,y)) return;
			x = root[x];
			y = root[y];
			if(tree_size[x]<tree_size[y]) swap(x,y);			
			root[y] = x;
			tree_size[x] += tree_size[y];
			n--;			
		}
		int get_tree_size(int x){
			return tree_size[find(x)];
		}
		int get_forest_size(){return n;}
	private:
		vector<int> root;
		vector<int> tree_size;
		int n;

};
int main(void) {
	int n,m,k; cin >> n >> m >> k;
	UnionFindTrees uft(n);
	vi friends(n,0);
	rep(i,m){
		int a,b; cin >> a >> b;
		a--; b--;
		uft.merge(a,b);
		friends[a]++;
		friends[b]++;
	}
	vi blocks(n,0);
	rep(i,k){
		int c,d; cin >> c >> d;
		c--; d--;
		if(uft.same(c,d)){
			blocks[c]++;
			blocks[d]++;
		}
	}
	vi ans(n);
	rep(i,n){
		ans[i] = uft.get_tree_size(i)-1;
		ans[i] -= friends[i];
		ans[i] -= blocks[i];
	}
	rep(i,n) cout << ans[i] << " ";
	cout << endl;
}




Measured memory_bytes: 2816
/*
  ∧,,∧
( 'ω' )つ ＜またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;

int main()
{
    int N;
    cin >> N;
    vector<pair<LD, string>> lot(N);

    for (int i = 0; i < N; i++) {
        cin >> lot[i].first >> lot[i].second;
    }

    LD ans = 0.0;
    for (int i = 0; i < N; i++) {
        if (lot[i].second == "JPY") {
            ans += lot[i].first;
        } else {
            ans += lot[i].first*380000.0;
        }
    }

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


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
#define IOS ios::sync_with_stdio(false)
void solve(){
	int n, x, t;
	cin >> n >> x >> t;
	int cnt = (n % x == 0) ? (n / x) : (n / x + 1);
	cout << cnt * t<< endl;
}
int main(){
	IOS;
	solve();
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  vector<int> abc(3);
  int i;
  for (i = 0; i < 3; i++) {
    cin >> abc[i];
  }
  int k;
  cin >> k;
  sort(abc.begin(), abc.end());
  for (i = 0; i < k; i++) {
    abc[2] *= 2;
  }
  cout << abc[0] + abc[1] + abc[2] << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;

string my_readln() { return chomp(readln()); }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	//auto tokens = my_readln().split();
	//auto N = tokens[0].to!uint;
	//auto K = tokens[1].to!uint;
	auto s = my_readln;
	auto t = my_readln;

	auto dp = new uint[][](3005, 3005);

	foreach (i, cs; s)
	{
		foreach (j, ct; t)
		{
			dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
			if (cs == ct)
			{
				dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
			}
			//stderr.writeln(i, ":", j, " ", dp[i+1][j+1]);
		}
	}

	string ans;
	long i = s.length - 1, j = t.length - 1;
	while (i >= 0 && j >= 0)
	{
		if (s[i] == t[j])
		{
			ans = s[i] ~ ans;
			--i; --j;
		}
		else if (dp[i+1][j] > dp[i][j+1]) --j;
		else							  --i;
	}
	
	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 42620
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,v[20],c,s=0; cin>>n;
	for(int i=0;i<n;i++) cin>>v[i];
	for(int i=0;i<n;i++){
		cin>>c;
		if(v[i]-c>0) s+=v[i]-c;
	}
	cout<<s;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <memory>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#include <map>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable, numberOFbegin, numberOFend) for(long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable, numberOFbegin, numberOFend) for(long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable, numberOFend) for(long long int LoopVariable = 0; (LoopVariable) < (numberOFend); LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max() - 5;
constexpr long long int inf = numeric_limits<int>::max() - 5;
constexpr long long int mod = 1000000007;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    llint n;
    cin >> n;
    vector<llint>v(n);
    REP(i,n){
        cin >> v[i];
    }
    if(v[0]!=0){
        cout << 0 << endl;
    }else{
        llint result = 1;
        map<llint, llint> mp;
        FOR(i,0,n){
            mp[v[i]]++;
        }
        if(mp[0]!=1){
            cout << 0 << endl;
        }else{
            llint num =mp[0];
            FOR(i,1,n){
                if(mp[i]==0){
                    break;
                }
                result *= (llint)modpow(mp[i - 1] , mp[i],998244353);
                num += mp[i];
                result %=998244353 ;
            }
            if(n==num){
                cout << result << endl;
            }else{
                cout << 0 << endl;
            }
        }
    }
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> k(n+2,0);
  rep(i,m){
    int l,r;
    cin >> l >> r;
    k[l]++;
    k[r+1]--;
  }
  int cnt=0;
  rep(i,n){
    k[i+1]+=k[i];
    //cout << k[i+1] << endl;
    if(k[i+1]==m)cnt++;
  }
  cout << cnt << endl;
  
}  


Measured memory_bytes: 640
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M = map(int, input().split())
l = [0] * N

for _ in range(M):
    a, b = map(int, input().split())
    l[a-1] += 1
    l[b-1] += 1

print(*l, sep="\n")

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

char str[2010][2010];

int a[2010][2010], b[2010][2010], c[2010][2010];

int n, m, q;

int main()
{
	giii(n, m, q);
	for (int i = 1; i <= n; ++i) scanf("%s", str[i] + 1);
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
			if (str[i][j] == '1') ++a[i][j];
		for (int j = 1; j < m; ++j)
			if (str[i][j] == '1' && str[i][j + 1] == '1') ++b[i][j];
		if (i < n)
			for (int j = 1; j <= m; ++j)
				if (str[i][j] == '1' && str[i + 1][j] == '1') ++c[i][j];
	}
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
		{
			a[i][j] += a[i][j - 1] + a[i - 1][j] - a[i - 1][j - 1];
			b[i][j] += b[i][j - 1] + b[i - 1][j] - b[i - 1][j - 1];
			c[i][j] += c[i][j - 1] + c[i - 1][j] - c[i - 1][j - 1];
		}
	while (q--)
	{
		int x1, y1, x2, y2;
		gii(x1, y1);
		gii(x2, y2);
		int A = a[x2][y2] + a[x1 - 1][y1 - 1] - a[x2][y1 - 1] - a[x1 - 1][y2];
		//cerr << "A = " << a[x2][y2] << endl;
		int B = b[x2][y2 - 1] + b[x1 - 1][y1 - 1] - b[x2][y1 - 1] - b[x1 - 1][y2 - 1];
		int C = c[x2 - 1][y2] + c[x1 - 1][y1 - 1] - c[x2 - 1][y1 - 1] - c[x1 - 1][y2];
		printf("%d\n", A - B - C);
	}
	return 0;
}

Measured memory_bytes: 53120
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e18
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll a[maxn],dp[maxn][5],n,pre[maxn];

int main()
{
	n=read(); rep(i,1,n) a[i]=read();
	rep(i,1,n) rep(j,0,3) dp[i][j]=-inf;
	dp[1][0]=a[1]; dp[2][1]=a[2]; dp[3][2]=a[3];
	for(int i=3;i<=n;i++)
	{
		dp[i][0]=dp[i-2][0]+a[i];
		dp[i][1]=max(dp[i-2][1],dp[i-3][0])+a[i];
		if(i>=4) dp[i][2]=max(max(dp[i-2][2],dp[i-3][1]),dp[i-4][0])+a[i];
	}
	if(n%2==1) cout<<max(max(dp[n][2],dp[n-1][1]),dp[n-2][0])<<endl;
	else cout<<max(dp[n][1],dp[n-1][0])<<endl;
	return 0;
}

Measured memory_bytes: 12992
import collections
n, k = map(int, input().split())
a = list(map(int, input().split()))
c = collections.Counter(a)

to_del = max(0, len(c) - k)
cm = c.most_common()[::-1][:to_del]
ans = sum(cm[i][1] for i in range(to_del))
print(ans)

Measured memory_bytes: 44280
from collections import defaultdict

S = input()
N = len(S)
MOD = 2019

rems = [0] * N
rems[-1] = int(S[-1]) % MOD
last = int(S[-1])
tens = 1
for i in range(N - 1):
    tens = tens * 10 % MOD
    last = int(S[N - 2 - i]) * tens + last
    rems[N - 2 - i] = last % MOD
pos = defaultdict(int)
for i in range(N):
    r = rems[i]
    pos[r] += 1
ans = pos[0]
for i in range(MOD):
    ans += pos[i] * (pos[i] - 1) // 2
print(ans)

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

int main() {
    int A,B;
    cin>>A>>B;
    for (int i = 1;;i++) {
        int a = i * 0.08;
        int b = i * 0.1;
        if (a > A || b > B) break;
        if (a == A && b == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
import copy
N,A,B,C,D = map(int,input().split())
S = input()

for i in range(A,max(C,D)-1):
    if S[i:i+2] == "##":
        print("No")
        exit(0)

if C > D:
    flag = False
    for i in range(B-1,D):
        if S[i-1:i + 2] == "...":
            flag = True
            break

    if flag == False:
        print("No")
        exit(0)

print("Yes")


Measured memory_bytes: 4084
#include <iostream>
#include <math.h>
#include <cstdio>
using namespace std;

int main(){
	int i,n;
	double total,sd,s[1001];
	while(1){
		total=0;
		sd=0;
		cin >> n;
		if(n==0){
			break;
		}
	for(i=0;i<n;i++){
	cin >> s[i];
	total += s[i];
	}
		total=total/n;
	for(i=0;i<n;i++){
		sd += pow((s[i]-total),2);
	}
	printf("%.8f\n",sqrt(sd/n));
	}
	return 0;
}

Measured memory_bytes: 3288
using System;
class ITP1_1
{
    static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //System.Console.SetIn(exStdIn);

        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));

        Console.WriteLine(a[0]*a[1] +" "+ (a[0] + a[1]) * 2);
    }
}

Measured memory_bytes: 9156
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<string>
#include<set>
//#include<unordered_map>
using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll>PLL;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int eps=1e-9;
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int lcm(int a,int b){return a*b/gcd(a,b);}
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
    return x*f;
}
const int maxn=1e5+50;
int n,m,fa[maxn];
int find(int x)
{
    return fa[x]==x?x:fa[x]=find(fa[x]);
}
void Union(int x,int y)
{
    int fx=find(x),fy=find(y);
    if(fx!=fy) fa[fx]=fy;
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;++i) fa[i]=i;
    while(m--)
    {
        int x,y;
        cin>>x>>y;
        Union(x,y);
    }
    int sum=0;
    for(int i=1;i<=n;++i)
    {
        if(find(i)==i)
        {
            //cout<<find(i)<<endl;
            //cout<<i<<endl;
            sum++;
        }
    }
    cout<<sum-1<<endl;
    return 0;
}

Measured memory_bytes: 4024
#include <stdio.h>
int main(void){
	int x,y,tmp;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0){
			if(y==0){
			break;
			}
		}
		if(x>y){
			tmp=x;
			x=y;
			y=tmp;
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>

int main() {
  int n;
  
  while(std::cin >> n) {
    int result = 0;

    for(int a = 0; a < 10; ++a) {
      for(int b = 0; b < 10; ++b) {
        for(int c = 0; c < 10; ++c) {
          for(int d = 0; d < 10; ++d) {

            if((a + b + c + d) == n) {
              ++result;
            }

          }
        }
      }
    }

    std::cout << result << std::endl;
  }
}

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

using namespace std;

#define MAX 1000
#define INF 1e9
typedef pair<double,int> P;

int H,W;

double make(int x,int y){
  if(x == 0) return INF;
  return (double)y / x;
}

int pat(char a,char b,char c,char d){
  if(a == '.' && b == '#' && 
     c == '#' && d == '#'){
    return 1;
  }
  if(a == '#' && b == '.' && 
     c == '.' && d == '.'){
    return 1;
  }
  if(a == '.' && b == '.' && 
     c == '.' && d == '#'){
    return -1;
  }
  if(a == '#' && b == '#' && 
     c == '#' && d == '.'){
    return -1;
  }
 
  return 0;
}

int main(){
  string in;
  char a[MAX][MAX];

  for(int i = 0 ; i < MAX ; i++){
    for(int j = 0 ; j < MAX ; j++){
      a[i][j] = '.';
    }
  }

  cin >> H >> W;
  for(int i = H ; i > 0 ; i--){
    cin >> in;
    for(int j = 1 ; j <= W ; j++){
      a[i][j] = in[j-1];
    }
  }

  vector<P> v;
  for(int i = 0 ; i <= H ; i++){
    for(int j = 0 ; j <= W ; j++){
      char u1 = a[i+1][j],u2 = a[i+1][j+1];
      char u3 = a[i][j],u4 = a[i][j+1];
      int n = pat(u1,u2,u3,u4);

      if(n != 0){
	double r = make(j,i);
	v.push_back(P(r,n));
      }
    }
  }

  sort(v.begin(),v.end());
  int len = (int)v.size(),ans = 1,sum = 1;
  for(int i = 0 ; i < len ; i++){
    sum += v[i].second;
    ans = max(ans,sum);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4096
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
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")
}

fn calc(
    last: usize,
    depth: usize,
    t: usize,
    foods: &Vec<(usize, usize)>,
    memo: &mut Vec<Vec<Vec<Option<usize>>>>,
) -> usize {
    let n = memo[0].len();
    let max_t = memo[0][0].len();
    if depth >= n {
        return 0;
    }
    if let Some(ret) = memo[last][depth][t] {
        return ret;
    }
    let mut ret = calc(last, depth + 1, t, foods, memo);
    if last == 0 {
        let nret = foods[depth].1 + calc(1, depth + 1, t, foods, memo);
        ret = std::cmp::max(ret, nret);
    }
    let nt = t + foods[depth].0;
    if nt < max_t {
        let nret = foods[depth].1 + calc(last, depth + 1, nt, foods, memo);
        ret = std::cmp::max(ret, nret);
    }
    memo[last][depth][t] = Some(ret);
    return ret;
}

fn main() {
    let n = read::<usize>();
    let t = read::<usize>();
    let mut foods = vec![(0, 0); n];
    for i in 0..n {
        foods[i].0 = read::<usize>();
        foods[i].1 = read::<usize>();
    }
    let mut memo = vec![vec![vec![None; t]; n]; 2];
    let ans = calc(0, 0, 0, &foods, &mut memo);
    println!("{}", ans);
}


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

int main(){
  int n;
  cin >>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >>a.at(i);
  }
  sort(a.begin(),a.end());
  long long int ans =0;
  if(n%2 == 0){
    for(int i=0;i<n/2;i++){
      ans += a.at(i+n/2);
    }
    for(int i=0;i<n/2;i++){
      ans -= a.at(i);
    }
    ans *= 2;
    ans += a.at(n/2-1)-a.at(n/2);
    cout << ans <<endl;
    return 0;
  }
  if(n%2 == 1){
    long long int u,v;
    for(int i=0;i<n/2;i++){
      u += a.at(n-1-i);
    }
    for(int i=0;i<n/2;i++){
      u -= a.at(i);
    }
    u *= 2;
    u += a.at(n/2-1)-a.at(n/2);
    for(int i=0;i<n/2;i++){
      v += a.at(i);
    }
    for(int i=0;i<n/2;i++){
      v -= a.at(n-1-i);
    }
    v *= 2;
    v += a.at(n/2+1)-a.at(n/2);
    v = abs(v);
    ans = max(u,v);
    cout << ans <<endl;
    return 0;
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define  ll long long int

double   dp[302][302][302] ;



int main() {
  int n;
  cin>>n;
  int a[4]={0};
  for(int i=0;i<n;i++)
  {
     int k;
     cin>>k;
     a[k]++;
  }
  double ans=0;
  double total;
  double exp;
  dp[a[1]][a[2]][a[3]]=1.0;
  for( int i=a[3] ;i>=0 ;i--)
  {
     for(int j=n ;j>=0 ;j--)
    {
      for(int k=n;k>=0 ;k--)
      {   total =double(i+j+k) ;
      if(total>0)
      {  
          exp=(double(n)/total) ;
          ans+=exp*dp[k][j][i];
          if(k)  dp[k-1][j][i]+=(double(k)/total)*dp[k][j][i];
             if(j)  dp[k+1][j-1][i]+=(double(j)/total)*dp[k][j][i];
                if(i)  dp[k][j+1][i-1]+=(double(i)/total)*dp[k][j][i];


      }

      }
    }

  }
cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 215424
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    int n;
    cin >> n;
    n %= 10;
    if (n == 0 or n == 1 or n == 6 or n == 8)
    {
        cout << "pon";
    }
    else if(n == 3)
    cout << "bon";
    else
    {
        cout << "hon";
    }
    

    return 0;
}

Measured memory_bytes: 3656
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i,a,b) for(register int i=(a);i<=(b);i++)
#define down(i,a,b) for(register int i=(a);i>=(b);i--)
#define mem(x,y) memset(x,(y),sizeof x)
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d",&a)
#define scl(a) scanf("%I64d",&a)
#define scs(a) scanf("%s",a)
#define pr(a,b) printf("%d%c",a,b)
#define prl(a,b) printf("%I64d%c",a,b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(),v.end()

typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> V;

int main() {
	int a,b,c;sc(a),sc(b),sc(c);
	pr(min(b,c),' '),pr(max(0,b+c-a),'\n');
}

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

int main() {

    int M;
    cin >> M;
    while(M--) {
        int ans = 0;
        map< string, bool > used;
        string s; cin >> s;

        used[s] = true;
        ans++;
        for(int i = 1; i < s.size(); i++) {
            string front = s.substr(0, i), back = s.substr(i, s.size() - i);
            string rfront = front;
            reverse(rfront.begin(), rfront.end());
            string rback = back;
            reverse(rback.begin(), rback.end());
            if(!used[back + front]) {
                used[back + front] = true;
                ans++;
            }
            if(!used[front + rback]) {
                used[front + rback] = true;
                ans++;
            }
            if(!used[rfront + back]) {
                used[rfront + back] = true;
                ans++;
            }
            if(!used[rfront + rback]) {
                used[rfront + rback] = true;
                ans++;
            }
            if(!used[rback + front]) {
                used[rback + front] = true;
                ans++;
            }
            if(!used[back + rfront]) {
                used[back + rfront] = true;
                ans++;
            }
            if(!used[rback + rfront]) {
                used[rback + rfront] = true;
                ans++;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

/*
bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
void dfs(int x,int y){
		if(x == n+1){
			int tmp = 0;
			FOR(i,0,k){
				if(tmp1[mortyy[i]]-tmp1[morty[i]] == mortyyy[i])tmp+=mortyyyy[i];
			}
			rick = max(rick,tmp);
			return ;
		}
		int i;
		for(i = y;i<=n1;i++){
			tmp1[x] = i;
			dfs(x+1,i);
		}
	}
*/


//3111111111111111111111111111111




	void solve(){

		ins(x);
		string x1= "ARC";
		if(x == x1)out("ABC");
			else out("ARC");






	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

Measured memory_bytes: 3644
// I need some holiday
// But I don't wish that everyday is holiday
// Because I didn't bear the pain
// Because it wasn't a true freedom
//         ——『イヤホンと蝉時雨』·Orangestar

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return cur == ed && (ed = (cur = buffer) + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur == ed) ? EOF : *cur++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

inline char *read_str(char *s)
{
	register char ch(getc());
	while(!isgraph(ch)) ch = getc();
	for(; isgraph(ch); ch = getc()) *s++ = ch;
	*s = '\0';
	return s;
}

// END tpl.

const int MOD = 998244353;

inline int fpm(int x, int y)
{
	int res = 1;
	for(; y; y >>= 1, x = (LL) x * x % MOD) if(y & 1) res = (LL) res * x % MOD;
	return res;
}

inline int inv(int x) { assert(x); return fpm(x, MOD - 2); }

namespace MATH
{
	const int n = (int) 1e6;

	int fac[n + 5], ifac[n + 5];

	inline void init()
	{
		fac[0] = 1;
		for(int i = 1; i <= n; ++i) fac[i] = (LL) fac[i - 1] * i % MOD;
		ifac[n] = inv(fac[n]);
		for(int i = n - 1; i >= 0; --i) ifac[i] = (LL) ifac[i + 1] * (i + 1) % MOD;
	}

	inline int C(int N, int M) { return N < 0 || M < 0 || N < M ? 0 : (LL) fac[N] * ifac[N - M] % MOD * ifac[M] % MOD; }
}
using MATH::C;

int n, m;

inline void input()
{
	n = read<int>(), m = read<int>();
}

inline void solve()
{
	if(n < m) swap(n, m);

	int iv = inv(C(n + m, n)), iv2 = (MOD + 1) / 2, ans = n;
	for(int i = 1; i <= m; ++i) (ans += (LL) iv2 * iv % MOD * C(2 * i, i) % MOD * C(n + m - 2 * i, n - i) % MOD) %= MOD;
	printf("%d\n", (ans + MOD) % MOD);
}

int main()
{
#ifdef K_ON
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	MATH::init();
	input();
	solve();

	return 0;
}




Measured memory_bytes: 8192
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define MOD 1000000007
typedef long long int ll;
typedef unsigned long long int llu;

void yes(){printf("Yes\n");}
void no(){printf("No\n");}


int main(void)
{
    int a[3][3];
    int n;
    int b[10];

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            scanf("%d",&a[i][j]);
        }
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(a[j][k]==b[i]){
                    a[j][k]=-1;
                }
            }
        }
    }
    int flg=0;
    if(a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1)flg=1;
    if(a[0][2]==-1&&a[1][1]==-1&&a[2][0]==-1)flg=1;
    for(int i=0;i<3;i++){
        int aiu=0;
        for(int j=0;j<3;j++){
            if(a[i][j]!=-1){
                aiu=1;
                break;
            }
        }
        if(aiu==0){
            flg=1;
        }
    }
    for(int i=0;i<3;i++){
        int aiu=0;
        for(int j=0;j<3;j++){
            if(a[j][i]!=-1){
                aiu=1;
                break;
            }
        }
        if(aiu==0){
            flg=1;
        }
    }
    if(flg==0)no();
    if(flg==1)yes();
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int a, b;
    cin >> a >> b;
    cout << a*b << ' ' << (a+b) * 2 << endl;

    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>
int main(int argc, const char * argv[]) {
    long int n;
    std::cin >> n;
    std::unordered_map<std::string, int> counter;
    for(long int i=0; i<n; i++)
    {
        std::string s;
        std::cin >> s;
        std::sort(s.begin(), s.end());
        
        counter[s]++;
    }
    long int count=0;
    for(auto iter=counter.begin(); iter!=counter.end(); iter++)
    {
        long int n=(*iter).second;
        if(n >= 2){
            count += n*(n-1)/2;
        }
    }
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 10660
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  vector<int> n;
  int t;
  for(int i=0;i<5;i++){
    int tmp;
    cin>>tmp;
    n.emplace_back(tmp);
  }
  cin>>t;
  
  int mx=*max_element(n.begin(),n.end());
  int mn=*min_element(n.begin(),n.end());
  if(mx-mn>t) cout<<":("<<endl;
  else cout<<"Yay!"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
import statistics as stc

n=int(input())
 
a = list(map(int, input().split()))

#a[i]-(b+1) = a[i]-i-b
a_ = [a[i]-(i+1) for i in range(len(a))]

b=stc.median(a_)

def sad(a,b):
    b=int(b)
    score=0
    for i in range(len(a)):
        score+= abs(a[i]-b)
    return score

res = sad(a_,b)
print(res)

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

using namespace std;

using ll = long long;


void dfs (const vector<vector<int>> &gr, vector<int> &dep, int v, int d = 0)
{
	if (dep[v] != -1)
		return;

	dep[v] = d;

	for (auto it : gr[v])
		dfs (gr, dep, it, d + 1);
}


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;

	cin >> n;

	vector<vector<int>> gr(n);

	for (int i = 1; i < n; i++)
	{
		int a, b;

		cin >> a >> b;
		a--;
		b--;

		gr[a].push_back(b);
		gr[b].push_back(a);
	}

	vector<int> dep (n, -1);

	dfs (gr, dep, 0);

	int a = max_element(dep.begin (), dep.end ()) - dep.begin ();

	fill (dep.begin (), dep.end (), -1);

	dfs (gr, dep, a);

	int d = *max_element(dep.begin (), dep.end ());

	cerr << d << endl;

	if (d == 0)
		cout << "First" << endl;
	else if (d == 1)
		cout << "Second" << endl;
	else
		cout << ((d + 2) % 3 == 0 ? "Second" : "First") << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	ifstream fin("../input.txt");

	solve(fin);

	cout << setprecision(4) << "clock: " << clock() / (double) CLOCKS_PER_SEC << endl;
#else
	cout << setprecision(20);

	solve();
#endif

	return 0;
}


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

int main()
{
    ll N;
    cin >> N;
    set<string> se;
    
    for(ll i = 0; i < N; i++)
    {
        string tmp;
        cin >> tmp;
        se.insert(tmp);
    }

    cout << se.size() << endl;
    return 0;
}

Measured memory_bytes: 19124