akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
    int A[3];
    while (cin >> A[0] >> A[1] >> A[2]) {
        sort(A,A+3); reverse(A,A+3);
        int ans = A[0]*10+A[1] + A[2];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[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)*}
    };
}

#[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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        m: usize,
        ab: [[i64; 2]; n],
    );
    let mut ab = ab;
    ab.sort_by(|a,b| a[0].cmp(&b[0]));

    let mut ans = 0i64;
    let mut cnt = m as i64;
    for x in &ab {
        let buy_cnt = min(cnt, x[1]);
        ans += buy_cnt * x[0];
        cnt -= buy_cnt;
        if buy_cnt == 0 {
            break;
        }
    }

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

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 14716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
ll dp[N][2],arr[N];
void solve()
{
	int n;
	cin >> n;

	for (int i = 1; i < n + 1; i++)
		cin >> arr[i];
	memset(dp, 0, sizeof(dp));
	dp[2][1] = arr[2];
	dp[2][0] = arr[1];
	for (int i = 3; i < n + 1; i++)
	{
		if (i & 1)
		{
			ll temp = max({dp[i-3][1],dp[i-3][0],dp[i-2][1],dp[i-2][0]});
			//i为奇数 i要选x个  x=i/2
			//i-1 位置已经维护好 x个  那么只能从 选了x-1的 地方进行转移，很明显i-2   i-3  是维护好了x-1个
			dp[i][1] = arr[i] + temp;

			dp[i][0]=max({dp[i-1][1],arr[i-2]+dp[i-3][0]});
			//该位置不选，从 x-1 的两个位置：i-2,i-3转移
		}
		else
		{
			dp[i][1]=arr[i]+max({dp[i-2][1],dp[i-2][0],dp[i-1][0]});///偶数位置 i  要选 i/2个 i-2的位置（i/2-1）
			//以及前一个不选
			dp[i][0] = arr[i-1]+dp[i-2][0];//i不选，一定选i-1  维护前i个必须选i/2个的特性
		}
	}
	cout << max(dp[n][1], dp[n][0]) << endl;
	return;
}

int main()
{
	solve();
	return 0;
}
/*
没有两个相邻的被选上
8
1 2 3 4 -1 -2 -3 -4
*/


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

using namespace std;

#define int long long

bool codejam = 0;

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}
int n, d;
int arr[50][50];
set<int> sq;
void solve() {	
	for (int i = 0; i <= 20000; ++i) sq.insert(i * i);
	cin >> n >> d;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= d; ++j)
			cin >> arr[i][j];
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j < i; ++j) {
			int di = 0;
			for (int k = 1; k <= d; ++k) {
				di += (arr[i][k] - arr[j][k]) * (arr[i][k] - arr[j][k]);
			}
			if (sq.count(di)) ans += 1;
		}
	}	
	cout << ans;
}

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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(A) A.begin(), A.end()
#define SZ(A) (ll)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 1e6;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h, n;
    cin >> h >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    int dp[h + 1];
    dp[0] = 0;
    for (int i = 1; i <= h; i++) {
        dp[i] = inf;
        for (int j = 0; j < n; j++) {
            if (a[j] >= i) {
                dp[i] = min(dp[i], b[j]);
            }
            else {
                dp[i] = min(dp[i], b[j] + dp[i - a[j]]);
            }
        }
    }
    cout << dp[h] << "\n";
 	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define met(a,x) memset(a,x,sizeof(a))
#define inf 0x3f3f3f3f
#define mp make_pair;

using namespace std;
const int N=1e5+10;
const int mod=1e9+7;
int a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,c,k;
    cin>>n>>c>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    int ans=0;
    int now=0;
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(cnt==0){
            now=a[i];
            ans++;
            cnt++;
        }
        else{
            if(a[i]-now>k){
                cnt=1;
                now=a[i];
                ans++;
                continue;
            }
            else{
                if(cnt>=c){
                    cnt=1;
                    now=a[i];
                    ans++;
                    continue;
                }
            }
            cnt++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] data = new int[M][2];
        for (int i = 0; i < M; i++) {
            data[i][0] = sc.nextInt();
            data[i][1] = sc.nextInt();
        }

        sort(data, 1);
        int result = 0;
        int nowclear = 0;

        int nowfrom = 0;
        int nowto = 0;
        for (int i = 0; i < M; i++) {
            nowfrom = data[i][0];
            nowto = data[i][1];

            if (nowclear < nowfrom) {
                nowclear = nowto - 1;
                result++;
            }
        }
        System.out.println(result);

    }

    private static void sort(int[][] ob, int column) {
        Arrays.sort(ob, new Comparator<Object>() {
            public int compare(Object o1, Object o2) {
                int[] one = (int[]) o1;
                int[] two = (int[]) o2;
                if (one[column] > two[column]) {
                    return 1;
                } else if (one[column] < two[column]) {
                    return -1;
                } else {
                    return 0;
                }
            }
        });
    }
}


Measured memory_bytes: 90792
#include <bits/stdc++.h>
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define itn int
bool dbg = false;
int N;
string S;
void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    cin >> S;
    FOR(i, 0, (int)S.size()) {
        char c;
        c = S[i];
        int s = c - 'A';
        s = (s + N) % 26;
        S[i] = s + 'A';
    }
    cout << S << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    static int[][] dp;

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] balls = new int[3];
        for(int i=0;i<3;i++){
            balls[i] = sc.nextInt();
        }
        int n = sc.nextInt();
        dp = new int[4][n+1];
        for(int i=0;i<4;i++){
            Arrays.fill(dp[i], -1);
        }
        int res = helper(balls,0,n,0);
        System.out.println(dp[0][0]);
    }

    private static int helper(int[] balls, int ind, int n, int sum){
        if(ind >= balls.length){
            if(sum == n){
                return 1;
            }
            return 0;
        }else if(sum > n){
            return 0;
        }else{
            if(dp[ind][sum] != -1){
                return dp[ind][sum];
            }
            int res = 0;
            for(int i=0;i<=(n/balls[ind]);i++){
                res += helper(balls,ind+1, n, sum+(i*balls[ind]));
            }
            dp[ind][sum] = res;
            return res;
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <vector>
#include<stdio.h>

using namespace std;
int main(void){
    // Your code here!
    
    int s1,s2,s3,e1,e2,e3;
    cin>>s1;
    cout<<s1*800-s1/15*200<<endl;
    
    
    
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define xl(n) (n).begin(),(n).end()
#define fi first
#define se second

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

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

	string a,b;
	cin >> a >> b;
	int x=a.length(),y=b.length();

	vector<vector<int> > dp(x+1, vector<int>(y+1, 0));
	for (int i = 1; i < x+1; i++) {
		for (int id = 1; id < y+1; id++) {
			if (a[i-1] == b[id-1]) {
				dp[i][id]=dp[i-1][id-1]+1;
			} else {
				dp[i][id]=max(dp[i-1][id],dp[i][id-1]);
			}
		}
	}

	string ans = "";
	while(x&&y) {
		if (dp[x][y]==dp[x][y-1]) {
			y--;
			continue;
		}
		if (dp[x][y]==dp[x-1][y]) {
			x--;
			continue;
		}
		if (dp[x][y]==dp[x-1][y-1]+1) {
			ans+=a[x-1];
			x--;y--;
			continue;
		}
	}
	for (int i = ans.length()-1; i >=0; i--) cout << ans[i];
	cout << "\n";
}

Measured memory_bytes: 38548
S=input()

c1=0
c2=0
for i in range(0,len(S)):
  if i % 2 == 0:
    if S[i] =='0':
      c1+=1
    else:
      c2+=1
  else:
    if S[i] =='0':
      c2+=1
    else:
      c1+=1
print(min(c1,c2))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;

long long dp[101][5][5][5];
//文字数 最後から 3 2 1文字目の3つ
//dp[10][3][2][2]は10文字で最後が322の文字数
int main(void){
	int N;
	cin >> N;
	//長さ0の文字列は1である
	//0,1,2に関する制約しかないので
	//Sは333Sと考えてもよい
	//iが文字列の文字数
	dp[0][4][4][4]=1;
	for(int i=0;i<N;i++){
		//jが最後から3文字目の文字
		for(int j=0;j<5;j++){
			//kが最後から2文字目の文字
			for(int k=0;k<5;k++){
				//lが最後から1文字目の文字
				for(int l=0;l<5;l++){
					//条件に当てはまるものがないときcontinue;
					if(dp[i][j][k][l]==0)continue;
					//新しく追加する文字
					for(int a=0;a<4;a++){
						if(a==2&&k==0&&l==1)continue;
						if(a==2&&k==1&&l==0)continue;
						if(a==1&&k==0&&l==2)continue;
						if(a==2&&j==0&&l==1)continue;
						if(a==2&&j==0&&k==1)continue;
						dp[i+1][k][l][a]+=dp[i][j][k][l];
						dp[i+1][k][l][a]%=mod;
					}
				}
			}
		}
	}
	long long ans = 0;
	for(int i=0;i<4;i++)for(int j=0;j<4;j++)for(int k=0;k<4;k++){
		ans+=dp[N][i][j][k];
		ans%=mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,maxn=0;
	cin>>a;
	while(a>=500){
		maxn=maxn+1000;
		a=a-500;
	}
	maxn=maxn+a-a%5;
	cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main(){
  int n;
  int a[45];
  cin >> n;
  a[0] = 1;
  a[1] = 1;
  REP(i, 2, n+1){
    a[i] = a[i-1] + a[i-2];
  }

  cout << a[n] << endl;

}


Measured memory_bytes: 3116
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N, K;
vector<long long> pos, neg, posmult, negmult;
vector<double> pospre, negpre;
bool zero = false, found = false;
pair<double, long long> ret;

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        long long x; cin >> x;
        if(x > 0) pos.pb(x);
        else if(x < 0) neg.pb(x);
        else zero = 1;
    }
    pospre.resize(pos.size()+1); negpre.resize(neg.size()+1);
    posmult.resize(pos.size()+1); negmult.resize(neg.size()+1);

    sort(pos.begin(), pos.end()); reverse(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    pospre[0] = negpre[0] = 0; posmult[0] = negmult[0] = 1;
    for(int i = 1; i <= pos.size(); i++) pospre[i] = pospre[i-1]+log(pos[i-1]), posmult[i] = (posmult[i-1]*pos[i-1])%MOD;
    for(int i = 1; i <= neg.size(); i++) negpre[i] = negpre[i-1]+log(-neg[i-1]), negmult[i] = (negmult[i-1]*(neg[i-1]+MOD))%MOD;
    for(int i = 0; i <= neg.size(); i += 2){
        if(!(i <= K && K-i <= pos.size())) continue;
        if(!found) ret = mp(pospre[K-i]+negpre[i], (posmult[K-i]*negmult[i])%MOD);
        else ret = max(ret, mp(pospre[K-i]+negpre[i], (posmult[K-i]*negmult[i])%MOD));
        found = true;
    }

    reverse(neg.begin(), neg.end());
    for(int i = 1; i <= neg.size(); i++) negpre[i] = negpre[i-1]+log(-neg[i-1]), negmult[i] = (negmult[i-1]*(neg[i-1]+MOD))%MOD;
    for(int i = 1; i <= neg.size(); i += 2){
        if(!(i <= K && K-i <= pos.size())) continue;
        if(!found) ret = mp(-(pospre[K-i]+negpre[i]), (posmult[K-i]*negmult[i])%MOD);
        else ret = max(ret, mp(-(pospre[K-i]+negpre[i]), (posmult[K-i]*negmult[i])%MOD));
        found = true;
    }

    if((!found || ret.f < 0 || (ret.f == 0 && ret.s == MOD-1)) && zero) cout << "0\n";
    else cout << ret.s << '\n';

    //cout << negpre[1] << ' ' << negpre[2] << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

Measured memory_bytes: 8048
n = int(input())
v = list(map(int, input().split()))

def cal(v):
  if len(v) == 1:
    return v[0]
  else:
    vv = v
    vv.sort()
    vv.reverse()
    vv_max = vv[0]
    vv.pop(0)
    return (cal(vv)+vv_max)/2

print(cal(v))

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

void print() {
  cout << endl;
}

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
}

template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
}

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

  vi v(3);
  rep(i, 0, 3) {
    cin >> v[i];
  }

  sort(All(v));

  int K; cin >> K;

  rep(i, 0, K) {
    v[2] *= 2;
  }

  int ans = 0;
  rep(i, 0, 3) {
    ans += v[i];
  }

  cout << ans << endl;


  return 0;
};


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*
--------------------------------------------

	Optimizer

--------------------------------------------
*/
//#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
--------------------------------------------
 
	Utility Algorithm

-------------------------------------------- 
*/

template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}
 
template <typename T1>
T1 euclideanAlgorithm(T1 a, T1 b) {
    T1 a_tmp = a;
    T1 b_tmp = b;
 
    if (a_tmp > b_tmp) {
        swapAlgorithm<T1>(a_tmp, b_tmp);
    }
 
    T1 r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

template <typename T2>
T2 getLCM(T2 a, T2 b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main(int argc, char const *argv[])
{

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin >> n >> m;

    if(n==m) cout << "Yes";
    else cout << "No";
    
    return 0;
}


Measured memory_bytes: 256
S = input()
mojisu = len(S)
if mojisu % 2 == 1:
    S1 = S[:mojisu//2]
    S2 = S[mojisu//2+1:]
else:
    S1 = S[:mojisu//2]
    S2 = S[mojisu//2:]
S3 = []
for item in S2[::-1]:
    S3.append(item)
ans = 0
for i in range(mojisu//2):
    if S1[i] != S3[i]:
        ans += 1
print(ans)

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int A, B, X; cin >> A >> B >> X;
  double da = A;
  double db = B;
  double dx = (double)X / da;

  double th = 0.0;
  double pi = 4.0 * atan2(1,1);
  if (2 * dx <= da * db) {
    th = atan2(2*dx / db, db);
  }else {
    th = atan2(da, 2 * (da * db - dx) / da);
  }
  double ans = 90.0 - th / pi * 180.0;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
string S;
set<char> seen;

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

  cin >> S;
  if (S.size() < 26) {
    for (char c: S) seen.insert(c);
    for (char c='a';c<='z';c++) {
      if (!seen.count(c)) {
        S+=c;
        cout << S << endl;
        return 0;
      }
    }
  }

  rep_down(i, 26){
    seen.insert(S[i]);
    auto it = seen.upper_bound(S[i]);
    if (it != seen.end()) {
      string res = S.substr(0, i)+*it;
      cout << res << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect
N=int(input())
A=list(map(int,input().split()))
A.sort()
k=bisect.bisect_left(A,0)
a=-sum(A[:k])+sum(A[k:])
if N==2:
  a-=2*A[0]
elif k==0:
  a-=2*A[0]
elif k==N:
  a+=2*A[N-1]
print(a)
if N==2:
  print(A[1],A[0])
elif k>=N-1:
  x=A[N-1]
  for i in range(N-1):
    print(x,A[i])
    x-=A[i]
else:
  
    x=A[0]
    
    for i in range(max(k,1),N-1):
      print(x,A[i])
      x-=A[i]
    print(A[-1],x)
    x=A[-1]-x
    for i in range(1,k):
      print(x,A[i])
      x-=A[i]
  

Measured memory_bytes: 60940
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
int main()
{
	fio;
	int a,b;
	inp(a);
	inp(b);
	int p=max(a*b,max(a-b,a+b));
	cout<<p<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str  = sc.nextLine();
        String suuji = sc.nextLine();
        String[] astr = suuji.split(" "); //状況に合わせて
        Double tmp = 0.0;
        double ans = 0.0;
        Double hoge = 0.0;
        int[] in_data = Stream.of(astr).mapToInt(x->{
            try{
                return Integer.parseInt(x);
            }
            catch(Exception e){
                e.printStackTrace();
            }
            return 0;
        }).toArray();
        sc.close();

        for(int i=0;i<in_data.length;i++){
            hoge = (double)1 / in_data[i];
            tmp = tmp + hoge;
        }
        ans = 1/tmp;

        if(ans == (int) ans){
            System.out.println((int)ans);
        }else{
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 26580
<?php

$n = trim(fgets(STDIN));
$parr = explode(' ', trim(fgets(STDIN)));

$cnt=0;
$min=$n+1;
for ($i=0; $i<$n; $i++) {
    $min = min($min, $parr[$i]);
    if ($min == $parr[$i]) {
        $cnt++;
    }
}

echo "$cnt\n";



Measured memory_bytes: 18932
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }
template<typename A, typename B>
ostream& operator << (ostream& out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}

const int maxN = 5000 + 5;
const LL P = 1000000007;
LL qpow(LL a, LL b) {
	LL r = 1;
	while(b) {
		if(b & 1) (r *= a) %= P;
		(a *= a) %= P; b >>= 1;
	}
	return r;
}
LL fac[maxN], ifac[maxN];
LL C(int n, int k) {
	if(k < 0 || k > n) return 0;
	return fac[n] * ifac[k] % P * ifac[n - k] % P;
}
int n;
int pa[maxN], sz[maxN], ig[maxN];
int findset(int x) {
	return pa[x] == x ? x : pa[x] = findset(pa[x]);
}

LL f[maxN];

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#endif
	cin >> n;
	for(int i = 1; i <= n; ++i) pa[i] = i, sz[i] = 1, ig[i] = 0;
	for(int i = 1; i <= n; ++i) {
		int p;
		cin >> p;
		if(p >= 1) {
			int x = findset(i), y = findset(p);
			if(x != y) {
				pa[y] = x;
				ig[x] |= ig[y];
				sz[x] += sz[y];
			}
		} else {
			int x = findset(i);
			ig[x] = 1;
		}
	}
	displaya(pa, 1, n);
	displaya(ig, 1, n);
	vector<int> a;
	for(int i = 1; i <= n; ++i) if(pa[i] == i) {
		if(ig[i]) a.push_back(sz[i]);
	}
	displayv(a);
	
	LL ans = 0;
	for(int i = 1; i <= n; ++i) if(pa[i] == i) {
		if(!ig[i]) (ans += qpow(n - 1, a.size())) %= P;
	}
	display(ans);
	
	fac[0] = 1;
	for(int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % P;
	ifac[n] = qpow(fac[n], P - 2);
	for(int i = n - 1; i >= 0; --i) ifac[i] = ifac[i + 1] * (i + 1) % P;
	
	memset(f, 0, sizeof(f));
	f[0] = 1;
	for(int i = 0; i < (int)a.size(); ++i) {
		for(int j = i + 1; j > 0; --j)
			(f[j] = f[j] * (n - 1) + f[j - 1] * a[i]) %= P;
		f[0] = f[0] * (n - 1) % P;
	}
	for(int k = 2; k <= (int)a.size(); ++k) (ans += f[k] * fac[k - 1]) %= P;
	for(int i = 0; i < (int)a.size(); ++i) {
		(ans += (a[i] - 1) * qpow(n - 1, a.size() - 1)) %= P;
	}
	display(ans);
//	display(qpow(n - 1, a.size()) * n);
	display(ans);
	ans = (qpow(n - 1, a.size()) * n - ans + P) % P;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3788
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;



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(int i) {       
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      
    return a / gcd(a, b) * b ;
}
int keta(ll n) {       
    if(n == 0) return 1;
    int 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;
}

#pragma endregion

signed main() {
    int n,c,k;cin >> n >> c >> k;
    vector<P> v(n);
    rep(i, n) {
        cin >> v[i].first;
        v[i].second=v[i].first+k;
    }
    sort(all(v));
    int count = 0;
    rep(i, n) {
        int cnt = 0;
        int j = i;
        while(j<n&&cnt<c&&v[i].second>=v[j].first) {
            cnt++;
            j++;
        }
        if(cnt>0) count++;
        i=j-1;
        // cout << i << endl;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4812
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
ll n, m;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> m >> n;
  cout << modpow(m, n, mod) << endl;
  return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define MAX_N 300000
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, a[MAX_N+5], b[MAX_N+5]; char s[MAX_N+5];
int main() {
	read(n), scanf("%s", s+1); int m = 0x3f3f3f3f;
	for (int i = 1; i <= n; i++) a[i] = a[i-1]+(s[i]=='W');
	for (int i = n; i >= 1; i--) b[i] = b[i+1]+(s[i]=='E');
	for (int i = 1; i <= n; i++) m = min(m, a[i-1]+b[i+1]);
	return printf("%d\n", m), 0;
}


Measured memory_bytes: 2944
use std::io;
use std::vec::Vec;
use std::str::FromStr;
use std::collections::HashMap;
fn main() {
    let mut vote_count = String::new();
    io::stdin().read_line(&mut vote_count).unwrap();
    vote_count.pop();
    let vote_count = u32::from_str(&vote_count).unwrap();

    let mut votes = HashMap::new();
    for _ in 0..vote_count {
        let mut vote = String::new();
        io::stdin().read_line(&mut vote).unwrap();
        vote.pop();
        let value = if let Some(cnt) = votes.get(&vote) {
            cnt + 1
        } else {
            1
        };
        votes.insert(vote, value);
    }

    let mut max_value = 0;
    let mut max_votes: Vec<String> = Vec::new();
    for (key, value) in votes.iter() {
        if *value > max_value {
            max_value = *value;
            max_votes.clear();
        }
        if *value == max_value {
            max_votes.push(key.to_string());
        }
    }

    max_votes.sort();
    for vote in max_votes.iter() {
        println!("{}", vote);
    }
}

Measured memory_bytes: 26844
#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
int main(){
     cin>>n>>k;
     ans=1;
     for(int i=0;i<n;i++){
        if(ans>k){ans+=k;}
        else ans*=2;}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n, k; cin >> n >> k;

  int ans = 0;
  while(n > 0){
    n /= k;
    ans++;
  }
  if(ans == 0) ans = 1;
  cout << ans << endl;

  return 0;
}


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

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N;
    read(N);
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N - 1);
    for(int i = 0; i < N; i++){
        read(A[i]);
    }
    for(int i = 0; i < N; i++){
        read(B[i]);
    }
    for(int i = 0; i < N - 1; i++){
        read(C[i]);
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += B[A[i] - 1];
        if(i < N - 1 && A[i + 1] - A[i] == 1){
            ans += C[A[i] - 1];
        } 
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

class UnionFind{
  public:
  vector<int> par;
  UnionFind(int n): par(n,-1){}
  bool unite(int x,int y){
    x = root(x),y = root(y);
    if(x == y)return false;
    if(par[x] > par[y])swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  bool find(int x,int y){
    return root(x) == root(y);
  }
  int root(int x){
    return par[x] < 0 ? x : par[x] = root(par[x]);
  }
};

int main(){
  
  int n,m;
  cin >> n >> m;
  vector<vector<int>> v(m);
  rep(i,n){
    int k;cin >> k;
    rep(j,k){
      int l;cin >> l;
      l--;
      v[l].push_back(i);
    }
  }
  UnionFind uf(n);
  rep(i,m)rep(j,(int)(v[i].size())-1)uf.unite(v[i][j],v[i][j+1]);
  int res = 0;
  rep(i,n)if(uf.par[i]< 0)res++;
  cout << (res == 1 ? "YES" : "NO") << endl;




  


  return 0;
}

Measured memory_bytes: 4608
// stdin
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

// input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        return x;
    }
    gcd(y, x % y)
}

fn primes(num: i64) -> Vec<i64> {
    let mut ans = vec![1];
    let mut cur = num;
    for i in 2.. {
        if i * i > num { break; }
        if cur % i == 0 {
            ans.push(i);
            while cur % i == 0 {
                cur /= i;
            }
        }
    }
    if cur > 1 {
        ans.push(cur);
    }
    return ans;
}


test! {
r"12 18
" => r"3",

r"420 660
" => r"4",

r"1 2019
" => r"1"
}

fn solve(src: &str) -> String {
    input! {
        source=src,
        a:i64,
        b:i64,
//        a:[i32;n],
    }
    let a: i64 = a;
    let b: i64 = b;

    let gcd = gcd(a, b);
    let mut primes = primes(gcd);
//    dbg!(&primes);
    primes.dedup();

    let ans = primes.len();
    format!("{}", ans)
}


fn main() {
    println!("{}", solve(&stdin!()));
}



Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> bk(n,0);
  
  REP(i,n-1){
    int c;
    cin >> c;
    bk[c-1] += 1;
  }
  
  REP(i,n){
    cout << bk[i] << endl;
  }
  
  
}

Measured memory_bytes: 4028
import java.util.Scanner;

public class Main {
	/*問題文
	非負の整数 a, b (a≤b) と、正の整数 x が与えられます。
	 a 以上 b 以下の整数のうち、x で割り切れるものの個数を求めてください。
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		System.out.println(( b + x ) / x - ( a + x - 1 ) / x );
	}

}

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

int main(){
  int n,i,x,y;
  char s[100000];
  int p[100],a[101];
    
  
  scanf("%d %d\n",&x,&n);
  if(n==0){
    printf("%d",x);
    return 0;
  }
  fgets(s,sizeof(s),stdin);
  y = atoi(strtok(s, " "));
  a[y] = y;
  
  for(i=1;i<n;i++){
    //printf("a\n");
    y = atoi(strtok(NULL, " "));
    a[y] = y;
    //printf("%d",a[y]);
  }
  
  if(a[x] != x){
    printf("%d\n",x);
    return 0;
  }
  
  for(i=1;i<x;i++){
    if(a[x-i] != x-i){
      printf("%d\n",x-i);
      return 0;
    }
    else if(a[x+i] != x+i){
      printf("%d\n",x+i);
      return 0;
    }
  }
  printf("0\n");
  return 0;
}


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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const int mod=1e9+7;
const int sze=1e5+2;
signed main(){
  char ch;
  cin>>ch;
  char ans=ch+1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
ans = ""

def get_input():
    flag = 1
    cnt = 0
    while True:
        if flag == 1:
            N,L = input().split()
            flag = 0
            continue
        else:
            a = input()
            yield ''.join(a)
            cnt += 1
            if cnt >= int(N):
                break

if __name__ == "__main__":
    array = list(get_input())
    array.sort()

    for i in range(0,len(array)):
        ans += array[i]

    print(ans)


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] A = new long[n];
        Arrays.setAll(A, i -> Long.parseLong(sc.next()));
        Arrays.sort(A);
        long maxSide1 = 0;
        long maxSide2 = 0;
        for(int i = n - 1; i > 0; i--) {
            if(A[i] == A[i-1]) {
                if(maxSide1 < A[i]) {
                    maxSide2 = maxSide1;
                    maxSide1 = A[i];
                    A[i-1] = -1;
                } else if(maxSide2 < A[i]) {
                    maxSide2 = A[i];
                }
            }
        }
        System.out.println(maxSide1 * maxSide2);
    }
}


Measured memory_bytes: 49336
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
 
const ll INF = 1ll<<60;
 
int main() {
  ll n, x, d;
  cin >> n >> x >> d;

  if (d == 0) {
    if (x == 0) {
      cout << 1 << endl;
    } else {
      cout << n+1 << endl;
    }
    return 0;
  }
 
  map<int, vector<P>> mp;
  rep(k,n+1) {
    ll s = k*x;
    ll l = (ll) (k-1)*k/2;
    ll r = l + (ll)k*(n-k);
    s += l*d;
    r -= l;
    mp[ (s%d+d) % d ].emplace_back(s,r);
  }
  ll ans = 0;
  for (auto p : mp) {
    vector<P> a = p.second;
    int m = a.size();
    rep(i,m) a[i].first = (a[i].first - p.first)/d;
    vector<P> ev;
    rep(i,m) {
      ev.emplace_back(a[i].first, 1);
      ev.emplace_back(a[i].first + a[i].second + 1, -1);
    }
    sort(ev.begin(), ev.end());
    ll cnt = 0, pre = -INF;
    for (auto e : ev) {
      ll len = e.first - pre;
      if (cnt) ans += len;
      cnt += e.second;
      pre = e.first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 25452