akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    vi candies(3);
    cin >> candies[0] >> candies[1] >> candies[2];
    sort(candies.begin(), candies.end());

    if (candies[0] + candies[1] == candies[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	a_list = np.array(LI())
	cost = INF
	for a in range(-100,101):
		a_diff = (a - a_list) ** 2
		cost = min(cost, np.sum(a_diff))
	print(cost)


if __name__ == '__main__':
    main()

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    string s;
    cin >> s;

    int div = 0, ans = 0, deci = 1;
    for(int in=0;in<s.size();in++) {
        div += s.at(in)-'0';
        ans += (s.at(s.size()-1-in)-'0') * deci;
        // cout << s.at(s.size()-1-in) << endl;
        deci *= 10;
    }

    if(ans%div==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    // cout << ans << endl;
    // cout << div << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        for(int a=0;a<N;a++) list.add(sc.nextInt());
        Collections.sort(list);
        int min= 999999999;
        for(int a=0;a<N-K+1;a++){
            if(min>list.get(a+K-1)-list.get(a)) min = list.get(a+K-1)-list.get(a);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 60968
N=int(input())
dp=[float('inf')]*100010
dp[0]=0

for i in range(N+1):
    power=1
    while power<=N:
        dp[i]=min(dp[i],dp[i-power]+1)
        power*=6
    power=1
    while power<=N:
        dp[i]=min(dp[i],dp[i-power]+1)
        power*=9

print(dp[N])

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>

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

using namespace std;

char dan[22][4][4];
char drop[5][2][4][4];

bool check(int d, int n, int sx, int sy){
	rep(i,2) for(int x=1; x<=2; x++) for(int y=1; y<=2; y++){
		if( dan[d+i][x+sx][y+sy] == '#' && drop[n][i][x][y] == '#' ){
			return false;
		}
	}
	return true;
}

int merge(int d, int n, int sx, int sy){
	int ret = 0;
	rep(i,2) for(int x=1; x<=2; x++) for(int y=1; y<=2; y++){
		if( dan[d+i][x+sx][y+sy] == '.' ){
			dan[d+i][x+sx][y+sy] = drop[n][i][x][y];
		}
	}
	rep(i,2){
		if( d+i < 2 ) continue;
		auto f = [&]{ rep(x,4) rep(y,4) if( dan[d+i][x][y] != '#' ) return true; return false; };
		if( !f() ){
			for(int j=d+i; j<20; j++) rep(x,4) rep(y,4){
				dan[j][x][y] = dan[j+1][x][y];
			}
			d--;
			ret++;
		}
	}
	return ret;
}

int solve(int n){
	if( n >= 3 ) return 0;
	int ret = 0, ans=0;
	char _dan[22][4][4];
	rep(sx,3) rep(sy,3){
		rep(i,22) rep(y,4) rep(x,4) _dan[i][y][x] = dan[i][y][x];
		for(int d=20; d>=0; d--){
			if( !check(d,n,sx-1,sy-1) ){
				if( d < 20 )
					ret = max( ret, merge(d+1,n,sx-1,sy-1) + solve(n+1) );
				break;
			}
		}
		rep(i,22) rep(y,4) rep(x,4) dan[i][y][x] = _dan[i][y][x];
	}
	return ret;
}

int main(){
	int H, N;
	while( cin >>H >>N, N|H ){
		fill( (char*)dan[0], (char*)dan[22], '#' );
		fill( (char*)drop[0], (char*)drop[5], '.' );
		rep(i,20) rep(y,2) rep(x,2) dan[i+2][y+1][x+1] = '.';
		rep(i,H) rep(j,2) rep(k,2){
			cin >> dan[i+2][j+1][k+1];
		}
		rep(n,N) rep(i,2) rep(j,2) rep(k,2){
			cin >> drop[n][i][j+1][k+1];
		}
		cout << solve(0) << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
    map<string,int> memo;

    int N,max=0; cin>>N;
    string s;
    for(int i=0;i<N;i++){
        cin >> s;
        memo[s]+=1;
        if(memo[s]>max){
            max = memo[s];
        }
    }

    for(auto it = memo.begin(); it != memo.end();it++){
        if(it->second == max){
            cout << it->first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int arr[13][13];
int main() {
    ll N, M, X;
    cin >> N >> M >> X;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j <= M; ++j) {
            cin >> arr[i][j];
        }
    }
    bool an = false;
    ll cost = LLONG_MAX;
    ll ct = 0;
    for(int i = 1; i <= ((1 << N) - 1); ++i) {
        an = true;
        ll ans[M + 1] = {0}, ct = 0;
        for(int j = 0; j < N; ++j) {
            if((1 << j)&i) {
                for(int k = 1; k <= M; ++k) {
                    ans[k] += arr[j][k];
                }
                ct += arr[j][0];
            }
        }
        //cout << ct  << " " << i << endl;
        for(int f = 1; f <= M; ++f) {
            if(ans[f] < X) {
                an = false;
                break;
            }
        }
        if(an) {
            cost = min(cost, ct);
        }
    }
    if(cost != LLONG_MAX) {
        cout << cost;
    }
    else
        cout << -1;
}


Measured memory_bytes: 3636
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans = 1
if n == 1:
    print(int(t == a))
    exit()
for i in range(1, n - 1):
    ht, ha = 0, 0
    if t[i - 1] < t[i] and a[i] > a[i + 1]:
        if t[i] != a[i]:
            print(0)
            break
    elif t[i - 1] < t[i]:
        if t[i] > a[i]:
            print(0)
            break
    elif a[i] > a[i + 1]:
        if t[i] < a[i]:
            print(0)
            break
    else:
        ans = ans * min(t[i], a[i]) % mod
else:
    print(ans)


Measured memory_bytes: 97460
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 998244353;
const int N = 10000005;
const int K = 25;
int f[N], invf[N];
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int c(int n, int k){
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    n /= 2;
    f[0] = 1;
    invf[0] = 1;
    for (int i = 1; i < N; i++) f[i] = f[i - 1] * i % mod;
    invf[N - 1] = binpow(f[N - 1], mod - 2);
    for (int i = N - 2; i >= 0; i--){
        invf[i] = invf[i + 1] * (i + 1) % mod;
    }
    int ans = binpow(9, n);
    for (int i = 0; i < n; i++){
        ans = (ans - c(n + n, i) * binpow(2, i + 1) % mod + mod) % mod;
    }
    cout << ans;
}


Measured memory_bytes: 156544
#include<stdio.h>

#define nmax 100000
#define qmax 50000

int binarySearch(int);

int n;
int A[nmax];

int main(){
  int q, i, cnt=0;
  int B[qmax];
  
  scanf("%d",&n);
  for(i=0; i<n ; i++) scanf("%d",&A[i]);
  
  scanf("%d",&q);
  for(i=0; i<q ; i++) scanf("%d",&B[i]);

  for(i=0 ; i<q ; i++) cnt += binalySearch(B[i]);

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

int binalySearch(int key){
  int left, right, mid;

  left = 0;
  right = n;
  
  while(left<right){

    mid = (left + right) / 2;

    if(key == A[mid]) return 1;

    if(key > A[mid]) left = mid + 1;

    else if(key < A[mid]) right = mid;
  }

  return 0;
}

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

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

    map<char, int> sm;
    for (int i = 0; i < 4; i++) {
        sm[s[i]]++;
    }

    if (sm.size() == 2 && sm[s[0]] == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/*
 * 2492.cc: goto busters
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int INF = 1 << 30;

/* typedef */

typedef queue<int> qi;
typedef pair<int,int> pii;
typedef map<string,int> msi;

/* global variables */

string lbls[MAX_N];
int gts[MAX_N], dists[MAX_N + 1];
msi lmap;

/* subroutines */

inline int next(int k) { return (gts[k] < 0) ? k + 1 : gts[k]; }

/* main */

int main() {
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> lbls[i];

    if (lbls[i] == "goto") {
      gts[i] = 0;
      cin >> lbls[i];
      lbls[i].erase(lbls[i].size() - 1);
    }
    else {
      gts[i] = -1;
      lbls[i].erase(lbls[i].size() - 1);
      lmap[lbls[i]] = i;
    }
  }

  for (int i = 0; i < n; i++) {
    if (gts[i] >= 0) gts[i] = lmap[lbls[i]];
    //printf("%d: %d\n", i, gts[i]);
  }

  for (int i = 0; i <= n; i++) dists[i] = INF;
  dists[0] = 0;

  priority_queue<pii> q;
  q.push(pii(0, 0));

  while (! q.empty()) {
    pii u = q.top(); q.pop();
    int ud = -u.first, &ui = u.second;
    if (ui == n) break;
    if (dists[ui] != ud) continue;

    int vd = ud + 1;

    if (gts[ui] >= 0) {
      int vi = next(ui);
      if (dists[vi] > ud) {
	dists[vi] = ud;
	q.push(pii(-ud, vi));
      }

      vi = ui + 1;
      if (dists[vi] > vd) {
	dists[vi] = vd;
	q.push(pii(-vd, vi));
      }
    }
    else {
      int vi = ui + 1;
      if (dists[vi] > ud) {
	dists[vi] = ud;
	q.push(pii(-ud, vi));
      }
    }
  }

  printf("%d\n", dists[n]);
  return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin>>S;
  int N=S.size();
  int B=pow(2,4);
  for(int b=0;b<B;b++){
    int res=S[0]-'0';
    for(int i=0;i<N-1;i++){
      if((b>>i)&1)res+=(S[i+1]-'0');
      else res-=(S[i+1]-'0');
    }
    if(res==7){
      cout<<S[0];
      for(int i=0;i<N-1;i++){
        if((b>>i)&1)cout<<"+";
        else cout<<"-";
        cout<<S[i+1];
      }
      cout<<"=7"<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ff first
#define ss second
#define fr(a,b,c) for(int a=b; a<=c; a++)
 
const int N=1e5+5;
const int mod=1e13;
 
void solve(int tt)
{
    int n;
    cin>>n;
    int a[n+5],l[n+5],r[n+5],good[n+5],pw[n+5],temp=1;
    for(int i=0;i<=n;i++)
    {
        cin>>a[i];
        good[i]=0;
        pw[i]=temp;
        if(i<=50)
            temp*=2;
    }    
    if(n==0)
    {
        if(a[0]==1)
            cout<<"1";
        else
            cout<<"-1";
        return;
    }
    if(n==1)
    {
        if(a[0]==0)
        {
            if(a[1]==1)
                cout<<"2";
            else if(a[1]==2)
                cout<<"3";
            else
                cout<<"-1";
            return;
        }
        cout<<"-1";
        return;
    }
    l[n]=a[n];
    r[n]=a[n];
    for(int i=n-1;i>=0;i--)
    {
        r[i]=r[i+1];
        l[i]=(l[i+1]+1)/2;
        l[i]+=a[i];
        r[i]+=a[i];
        l[i]=max(1LL,l[i]);
        r[i]=min(r[i],pw[i]);
    }
    if(a[0]==0)
        good[0]=1;
    int ans=0;
    for(int i=1;i<n;i++)
    {
        int mini=good[i-1];
        int maxi=min(mod,2*good[i-1]);
        if(maxi<l[i] || mini>r[i])
        {
            cout<<"-1";
            return;
        }
        ans+=min(maxi,r[i]);
        good[i]=min(maxi,r[i])-a[i];
    }
    ans+=1;
    ans+=a[n];
    cout<<ans;
}
 
int32_t main()
{
    IOS;

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

    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
    {
        solve(i);
        cout<<endl;
    }
}


Measured memory_bytes: 7492
let mutable mass_num = stdin.ReadLine() |>int
let mutable G : ResizeArray<int> array = Array.zeroCreate mass_num
let mutable Fennec :int array = Array.zeroCreate mass_num
let mutable Kisuke :int array = Array.zeroCreate mass_num
let mutable mass = 0 |>int 
let mutable before = 0 |>int
let mutable dist = 0 |>int

for i in [0..mass_num-1]do
    G.[i] <-ResizeArray<int>()
done;;

let rec dfs_Fe(mass,before,dist) =
    Fennec.[mass]<-dist
    for i in [0..G.[mass].Count-1]do
    if(G.[mass].[i] <> before ) then dfs_Fe(G.[mass].[i],mass,dist+1);;

let rec dfs_Ki(mass,before,dist) =
    Kisuke.[mass]<-dist
    for i in [0..G.[mass].Count-1]do
    if(G.[mass].[i] <> before ) then dfs_Ki(G.[mass].[i],mass,dist+1);;

let mutable Fe_mass = 0
for i in [0..mass_num-2]do
let mutable IN = stdin.ReadLine().Split(' ') |> Array.map int
IN.[0]<-IN.[0]-1
IN.[1]<-IN.[1]-1
G.[IN.[0]].Add(IN.[1])
G.[IN.[1]].Add(IN.[0])
done;;
dfs_Fe(0,-1,0)  
dfs_Ki(mass_num-1,-1,0)  
for i in [0..mass_num-1]do
if Fennec.[i]<=Kisuke.[i] then Fe_mass<-Fe_mass+1
else Fe_mass<-Fe_mass-1
done;;
if Fe_mass > 0 then "Fennec" else "Snuke"
|>printfn "%s"


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

using namespace std;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    for (int i = 0; i < H; ++i)
        cin >> S[i];

    int ret = 1e9;
    for (int bs = 0; bs < (1 << (H - 1)); ++bs) {
        int nb = 1 + __builtin_popcount(bs);
        vector<int> cnt(nb);
        int tmp = __builtin_popcount(bs);
        bool suc = false;
        for (int j = 0; j < W; ++j) {
            int now = 0;
            for (int i = 0; i < H; ++i) {
                if (S[i][j] == '1') cnt[now]++;
                if ((bs >> i) & 1) now++;
            }

            if (*max_element(cnt.begin(), cnt.end()) > K) {
                if (suc) {
                    tmp = 1e9;
                    break;
                }
                tmp++;
                for (auto &x : cnt) x = 0;
                --j;
                suc = true;
                continue;
            }
            suc = false;
        }
        ret = min(ret, tmp);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int N) : par(N), rank(N) {
        rep(i, N) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]) {
            par[rx] = ry;
        }
        else {
            par[ry] = rx;
            if (rank[rx] == rank[ry]) rank[rx]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int N, M;
    cin >> N >> M;

    UnionFind tree(N);
    rep(i, M) {
        int x, y, z;
        cin >> x >> y >> z;
        tree.unite(x - 1, y - 1);
    }

    set<int> st;
    rep(i, N) {
        st.insert(tree.root(i));
    }

    cout << (int)st.size() << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main(){
    int count, lowest = 1000, kind, powder, need;
    scanf("%d %d", &kind, &powder);
    for(int i = 0; i<kind; i++){
        scanf("%d\n", &need);
        powder -= need;
        if(need < lowest) lowest = need;
    }
    count = kind + powder/lowest;
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 128
from itertools import combinations

N = int(input())
Sn = [input() for _ in range(N)]

march = ["M", "A", "R", "C", "H"]
d = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
cnt = 0
for i in range(N):
    if Sn[i][0] not in march:
        continue
    d[Sn[i][0]] += 1
    cnt += 1

ans = 0
for a, b, c in combinations(march, 3):
    ans += d[a] * d[b] * d[c]

print(ans)


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


int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    
    int n;
    long long int k;
    cin>>n>>k;
    int a[n+1];
    for (int i=1; i<=n; i++){
        cin>>a[i];
    }
    bool visited[n+1] = {false};
    vector<int> loop;
    int curr = 1;
    visited[curr] = 1;
    loop.push_back(curr);
    int res = 0;
    while(true){
        curr = a[curr];
        if (visited[curr]){
            res = curr;
            break;    
        } 
        visited[curr] = 1;
        loop.push_back(curr);
    }
    // for (auto val:loop) cout<<val<<" ";
    // cout<<endl;
    // cout<<res;
    int ind = 0;
    for (int i=0; i<n; i++){
        if (loop[i]==res){
            ind = i;
            break;
        }
    }
    vector<int> rem;
    for (int i=ind; i< (int)loop.size(); i++){
        rem.push_back(loop[i]);
    }
    int m = rem.size();
    
    if (k<ind){
        cout<<loop[k];
    }
    else{
        cout<<rem[(k-ind)%m];
    }
    return 0;
}


Measured memory_bytes: 6568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
int main(){
    int k;cin >> k;
    vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] number = new int[3];
		for (int i=0;i<3;i++) {
			number[i]=Integer.parseInt(sc.next());
		}
		Arrays.sort(number);
		System.out.println(number[0]*number[1]/2);
	}
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  string s;cin>>s;
  cout<<s.substr(0,s.size()-8)<<endl;
  return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  string A;
  cin >> A;
  int n = A.size();

  map<char, int> mp;

  long long ans = n * (n - 1) / 2;
  dump(ans);
  for (auto &c : A) {
    mp[c]++;
  }
  dump(mp);

  for (auto &p : mp) {
    int x = p.second;
    ans -= x * (x - 1) / 2;
    dump(ans);
  }
  ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 2019
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L, R;
    cin >> L >> R;
    int ans = 2020;
    REP(i, L, min(L + 2020, R)) {
        REP(j, i + 1, min(L + 2020, R)) {
            //cout << i << " " << j << endl;
            ans = min(ans, (i * j) % mod);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,k,sum=0,max=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&k);
		if(k>max)max=k;
		sum+=k;
	}
	sum-=max/2;
	printf("%d",sum);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
typedef struct {
  double x,y;
}Point;
void koch(int n,Point p1,Point p2){
  Point s,t,u;
  double theta;
  theta=M_PI*60.0/180.0;
  if(n==0) return;
  s.x=(2.0*p1.x+1.0*p2.x)/3.0;
  s.y=(2.0*p1.y+1.0*p2.y)/3.0;
  t.x=(1.0*p1.x+2.0*p2.x)/3.0;
  t.y=(1.0*p1.y+2.0*p2.y)/3.0;
  u.x=(t.x-s.x)*cos(theta)-(t.y-s.y)*sin(theta)+s.x;
  u.y=(t.x-s.x)*sin(theta)+(t.y-s.y)*cos(theta)+s.y;
  koch(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,p2);
}
int main(){
  Point p1,p2;
  int n;
  scanf("%d",&n);
  p1.x=0.0;
  p1.y=0.0;
  p2.x=100.0;
  p2.y=0.0;
  printf("%.8f %.8f\n",p1.x,p1.y);
  koch(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);
  return 0;
}

Measured memory_bytes: 644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] a = new int[N];
		for(int i=0 ; i<N ;i++) {
			a[i] = stdIn.nextInt();
		}
		int count = 1;
		int min = a[0];
		for(int i=1 ; i<N ; i++) {
			if(a[i] > min) {
				
			}else {
				count++;
				min = a[i];
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 84912
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll n, m, p[210000], x, y, d[210000], res;
const ll INF = 1000000000000000000;
vector<ll> vec[210000];

void dfs(ll x, ll y){
    d[x] = y;
    for(ll i = 0; i < vec[x].size(); i++) {
        if (d[vec[x][i]] != INF) continue;
        dfs(vec[x][i], y);
    }
}

int main(void){
    // Your code here!
    cin >> n >> m;
    for (ll i = 1; i <= n; i++) cin >> p[i];
    for (ll i = 0; i < m; i++) {
        cin >> x >> y;
        vec[x].push_back(y);
        vec[y].push_back(x);
    }
    for (ll i = 1; i <= n; i++) d[i] = INF;
    for (ll i = 1; i <= n; i++) {
        if (d[i] != INF) continue;
        dfs(i, i);
    }
    for (ll i = 1; i <= n; i++) {
        if (d[p[i]] == d[i]) res++;
    }
    cout << res << endl;
}


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

#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  cin >> n;

  vector <int> heights;

  rep (i, n)
  {
    int h;
    cin >> h;
    heights.emplace_back (h);
  }

  auto ans = true;
  heights [0] -= 1;
  for (size_t i = 1; i < n; ++ i)
  {
    if (heights [i - 1] < heights [i])
    {
      heights [i] -= 1;
    }
    else if (heights [i - 1] == heights [i])
    {
      ;
    }
    else
    {
      ans = false;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 892
use std::io;
use std::io::BufRead;

fn main() {
    let board_line = "#.".repeat(151);
    let stdin = io::stdin();
    for line in stdin.lock().lines() {
        let v: Vec<usize> = line.unwrap()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect();
        if v == [0, 0] {
            return;
        }
        for (a, b) in (0..2).cycle().map(|a| (a, a + v[1])).take(v[0]) {
            println!("{}", &board_line[a..b]);
        }
        println!("");
    }
}



Measured memory_bytes: 5032
#include <iostream>
#include <complex>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

const int MAX = 100000001;
const double EPS = 1e-7;
bool compare(complex<double> c1, complex<double> c2){
  if(fabs(c1.real()-c2.real()) < EPS){
    return c1.imag() < c2.imag();
  } else {
    return c1.real() < c2.real();
  }
}

vector<complex<double> >p;
int main(){
  srand(time(NULL));
  int n;

  cin >> n;
  p.resize(n);
  int a = rand() % 180 + 1;
  double angle = a * M_PI / 180.0;
  for(int i=0; i<n; i++){
    cin >> p[i].real() >> p[i].imag();
    double tmpx = p[i].real();
    double tmpy = p[i].imag();
    p[i].real() = cos(angle)*tmpx + sin(angle)*tmpy;
    p[i].imag() = -sin(angle)*tmpx + cos(angle)*tmpy;
  }

  sort(p.begin(),p.end(),compare);

  double Min = 1e+200;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      if(fabs(p[i].real() - p[j].real()) > Min)break;
      double dis = sqrt(pow(p[i].real()-p[j].real(),2) +
			pow(p[i].imag()-p[j].imag(),2));
      Min = min(Min,dis);
    }
  }

  cout << Min*Min << endl;

  return 0;
}

Measured memory_bytes: 8988
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    PrintWriter out = new PrintWriter(System.out);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int k = Integer.parseInt(sl[2]);

    int z = a + 1;

    while(k > 0)
    {
      z--;
      if(a % z == 0 && b % z == 0)
      {
        k--;
      }
    }

    out.println(z);
    out.flush();
  }

}

Measured memory_bytes: 22996
#include<iostream>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (n) ; ++i)
#define Rrep(i,n) for(int i = (n) ; i >= 0 ; --i)
int dx[]={-1,-1,-1,0,0,1,1,1},dy[]={-1,0,1,-1,1,-1,0,1},nx,ny,flg,java[8][8];
char mas[8][8];
int rec(int x,int y,int way,bool pl,int cnt,bool ura){
  if( x<0 || y<0 || x>=8 || y>=8 ) return 0;
  if(mas[x][y] == (pl ? 'o' : 'x')) return cnt - 1;
  if(mas[x][y] == (pl ? 'x' : 'o')){
    int res = 0;
    if(res = rec(x+dx[way],y+dy[way],way,pl,cnt+1,ura)){
      if(ura) mas[x][y] = pl ? 'o' : 'x';
      return res;
    }
  }
  return 0;
}
int judge(int x,int y,bool pl,bool ura){
  int res = 0;
  rep(i,8){
    nx = x + dx[i] , ny = y + dy[i];
    if(mas[nx][ny]==(pl?'x':'o')) res += rec(nx,ny,i,pl,1,ura);
  }
  if(ura) mas[x][y] = pl ? 'o' : 'x';
  return res;
}
bool info(bool p){
  int big = 0;
  memset(java,0,sizeof(java));
  rep(i,8) rep(j,8){
    int xx = p?i:7-i , yy = p?j:7-j;
    if(mas[xx][yy] == '.'){
      java[xx][yy] = judge(xx,yy,p,false);
      big = max(big,java[xx][yy]);
    }
  }
  if(!big) return false;
  rep(i,8) rep(j,8){
    int xx = p?i:7-i , yy = p?j:7-j;
    if(java[xx][yy] == big ) return judge(xx,yy,p,true);
  }
}
int main(){
  rep(i,8) rep(j,8){
    cin >> mas[i][j];
  }
  while(flg < 2){
    flg = info(true) ? 0 : flg + 1;
    flg = info(false) ? 0 : flg + 1;
  }
  rep(i,8){
    rep(j,8) cout << mas[i][j];
    cout << endl;
  }
}

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

typedef long long ll;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    if (A > B) {
        swap(A, B);
    }
    if (A == B) {
        cout << 0 << endl;
        return 0;
    }
    ll X = 1e18;
    if ((B - A) % 2ll == 0ll) {
        X = (B - A) / 2;
    } else {
        ll pre = min(A - 1, N - B);
        X = pre + 1 + (B - A - 1) / 2;
    }
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll s;

int main() {
    fast_io; cout_precision;
    for (ll i = 0, x; i < 3; i++) {
        cin >> x;
        s += x;
        if (x != 5 && x != 7) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << ((s == 17)? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

struct Combination{
    vector<ll> fac,finv,inv;
    Combination(int mx){init(mx);}
    void init(int mx){
        fac.resize(mx+1);
        finv.resize(mx+1);
        inv.resize(mx+1);
        fac[0]=fac[1]=1;
        finv[0]=finv[1]=1;
        inv[1]=1;
        for(int i=2;i<=mx;i++){
            fac[i]=fac[i-1]*i%MOD;
            inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
            finv[i]=finv[i-1]*inv[i]%MOD;
        }
    }
    ll calc(int n,int k){
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
    }
};

ll dp[3002][2];

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    pair<int,int> p[n+2];
    for(int i=0;i<n;i++){
        int r,c;
        cin>>r>>c;
        p[i]={r,c};
    }
    p[n]={1,1};
    p[n+1]={h,w};
    sort(p,p+n+2);
    Combination comb(200000);
    dp[0][0]=1;
    for(int i=1;i<=n+1;i++){
        for(int j=0;j<i;j++){
            int ri=p[i].first;
            int ci=p[i].second;
            int rj=p[j].first;
            int cj=p[j].second;
            if(rj<=ri&&cj<=ci){
                ll t=comb.calc(ri-rj+ci-cj,ri-rj);
                dp[i][0]+=(t*dp[j][1])%MOD;
                dp[i][1]+=(t*dp[j][0]%MOD);
            }
        }
        dp[i][0]%=MOD;
        dp[i][1]%=MOD;
    }
    ll ans=dp[n+1][1]-dp[n+1][0];
    ans=(ans+MOD)%MOD;
    cout<<ans<<endl;
}

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

int main() {
  int a;
  cin >> a;
  int x;
  int y;
  int s = 0;
  for (int i = 0; i < a; i++){
    cin >> x >> y;
    s += (y - x + 1);
  }
   cout << s << endl; 
}


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

#define int long long
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define vint vector<int>
#define vchar vector<char>
#define vstr vector<string>
#define pb(n) push_back(n)

signed main(){
  int A,B,N,M,count=0,count2=0,count3=0,stack=0;
  str S,T;
  int C='A'-'a';
  cin>>A;
  vstr W(N);
  vint P(N);
  if(A%4==0||A%7==0)cout<<"Yes"<<endl;
  else if((A-7)%4==0&&A>7||(A-14)%4==0&&A>14)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*2
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = b;
	cout << min(c, b + a + 1) + b << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {


    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int a = in.nextInt();

        int b = in.nextInt();
        
        int c = in.nextInt();
        
        int N = in.nextInt();
        
        int max;

        int sum = a + b + c;
        
        max = a<b? b:a;
        max = max<c?c:max;
        
        sum -= max;

        for(int i=0;i<N;i++)
        	max*=2;
        
        System.out.println(sum + max);

        in.close();
    }

}


Measured memory_bytes: 22996
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() { 
    int n; cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    ll res = 0, sum = 0; int right = 0;
    for(int left = 0; left < n; left++){
        while(right < n){
            ll tmp = sum^A[right];
            if(sum+A[right] != tmp) break;
            sum += A[right];
            right++;
        }
        res += (ll)(right - left);

        sum -= A[left];
    }
    cout << res << ln;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(a, b);
    int2(c, d);

    while (a > 0 && c > 0) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int T;
	scanf("%d", &T);
	while (T--)
	{
		int n, k, x[114514], dis[114514];
		scanf("%d%d", &n, &k);
		rep (i, n)
			scanf("%d", x + i);
		n;
		for (int i = 0; i < n - 1; ++i)
			dis[i] = x[i + 1] - x[i];
		sort(dis, dis + (n - 1));
		int res = 0;
		for (int i = 0; i < n - k; ++i)
			res += dis[i];
		printf("%d\n", res);
	}
}

Measured memory_bytes: 0
from fractions import gcd

global a, b, c, d
a, b, c, d = map(int, input().split())

def lcm(a, b):
    return (a * b) // gcd(a, b)

def solve(n):
    x = n // c
    y = n // d
    z = n // lcm(c, d)
    return n - x - y + z

print(solve(b) - solve(a - 1))

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

int main() {
	string s; cin >> s;
    s = " " + s;
    bool b = false;
    for (int i = 1; i < s.length(); i += 2) if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') b = true;
    for (int i = 2; i < s.length(); i += 2) if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') b = true;
    if (b) cout << "No" << endl; else cout << "Yes" << endl;
    }

Measured memory_bytes: 256
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn main() {
    let n = read_line();
    let n_int = n.parse::<i32>().unwrap();
    let mut dig_sum = 0;
    for c in n.chars() {
        let diff = (c as i32) - ('0' as i32);
        dig_sum += diff;
    }
    if n_int % dig_sum == 0 {
        println!("Yes");
    }
    else{
        println!("No");
    }

}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>

using namespace std;

void solve()
{
	double a;
	while(cin >> a)
	{
		double sum = 0;
		for(int i = 0; i < 10; ++i)
		{
			sum += a;
			if(i % 2 == 0)
			{
				a *= 2;
			}
			else
			{
				a /= 3;
			}
		}
		printf("%.8f\n", sum);
	}
}

int main()
{
	solve();
	return(0);
}

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

int main() {
  long long n,m,total=0,ans;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int l;
    cin>>l;
    total+=l;
  }
  ans=n-total;
  if(ans<0)cout<<-1<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 3620