akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

namespace {
    /** whole range */
    #define whole(xs) (xs).begin(), (xs).end()

    int N;
    vector<int> A;
    void input() {
        cin >> N;
        A.resize(N);
        for (int i = 0; i < N; i++) cin >> A[i];
    }

    void solve() {
        auto it_m = min_element(whole(A));
        int am = *it_m; int m_ind = it_m - A.begin();
        auto it_M = max_element(whole(A));
        int aM = *it_M; int M_ind = it_M - A.begin();

        vector<pair<int, int>> ans;

        auto pos = [&]() {
            for (int i = 0; i < N - 1; i++) {
                ans.emplace_back(i + 1, i);
            }
        };
        auto neg = [&]() {
            for (int i = N - 1; i >= 1; i--) {
                ans.emplace_back(i - 1, i);
            }
        };

        if (am >= 0) {
            pos();
        } else if (aM <= 0) {
            neg();
        } else if (abs(am) < abs(aM)) {
            for (int i = 0; i < N; i++) {
                if (i == M_ind) continue;
                ans.emplace_back(i, M_ind);
                A[i] += aM;
            }
            pos();
        } else {
            for (int i = 0; i < N; i++) {
                if (i == m_ind) continue;
                ans.emplace_back(i, m_ind);
                A[i] += am;
            }
            neg();
        }

        cout << ans.size() << endl;
        for (auto a : ans) {
            cout << a.second + 1 << " " << a.first + 1 << endl;
        }
    }
}

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



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>

#define div1 1000000007

using namespace std;

int main(void)
{
    long long s, c, ans=0;

    cin >> s >> c;

    if(c <= s*2){
        cout << c/2 << endl;
    }

    else{
        ans += s;
        c -= s*2;

        ans += c/4;

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

void solve() {
    ll N;
    cin >> N;
    string C;
    cin >> C;
    ll ans = 0, w = 0, rt=0,wt=0;
    rep(i,N){
        if(C[i]=='W'){
            w++;
        }
    }
    rep(i,N-w){
        if(C[i]=='W'){
            wt++;
        }
    }
    rng(i,N-w,N){
        if(C[i]=='R'){
            rt++;
        }
    }
    print(min(wt,rt));
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3708
def main():
    K=int(input())
    x=7
    for i in range(1,10**8):
        m=x%K
        #print(m)
        if m==0:
            print(i)
            break
        x=m*10+7
        
    else:
        print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 80160
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	int ans = 1000 - (n % 1000);
	if (ans == 1000) ans = 0;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  int n, k;
  scanf("%d%d", &n, &k);
  printf("%d\n", n - k + 1);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    for (char c : S) {
        if (c == 'R') {
            ans++;
        }
    }
    if (S == "RSR") {
        cout << 1 << endl;
    } 
    else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 3596
n = int(input())
li = list(map(int,input().split()))
cnt = 0
li.sort()
if len(set(li)) == 1:
        cnt = 0
elif li[int(n/2 - 1)] == li[int(n/2)]:
        cnt = 0
else:
        cnt = li[int(n/2)] - li[int(n/2 -1)]
print(cnt)

Measured memory_bytes: 14556
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    string s, t;
    cin >> N >> s >> t;
    rep(i, 0, N + 1)
    {
        if (s.substr(i) == t.substr(0, N - i))
        {
            cout << N + i << endl;
            return;
        }
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int main(){
  string s;
  int K;
  cin >> s;
  cin >> K;

  for(int i = 0; i < s.size(); i++){
    int dist_to_a = (26 - (s[i] - 'a')) % 26;
    if(K >= dist_to_a){
      K -= dist_to_a;
      s[i] = 'a';
    }
  }
  if(K > 0){
    s[s.size() -1] = ((int) (s[s.size() - 1] - 'a') + K) % 26 + 'a';
  }
  cout << s << endl;
}

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

int solve(int n, int h, std::vector<int>a, std::vector<int>b) {
	// 剣を振った時の最大の威力
	const int maxAttack = accumulate(a.begin(), a.end(), 1,
		[](int x, int y) { return std::max(x, y); });

	int cnt = 0;
	// 投げる方が高威力なら投げます。
	for (int i = 0; i < n; i++) {
		if (maxAttack < b[i]) {
			h -= b[i];
			cnt++;
		}

		if (h <= 0) {
			return cnt;
		}
	}

	// ひたすら剣で殴る
	cnt += h / maxAttack;
	cnt += (bool)(h % maxAttack);
	return cnt;
}

int main() {
	int n, h;
	std::cin >> n >> h;

	std::vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		std::cin >> a[i] >> b[i];
	}

	// 降順ソート(剣を投げた時に威力の高い順)
	sort(b.begin(), b.end(), std::greater<int>());

	std::cout << solve(n, h, a, b) << std::endl;
	return 0;
}


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

string str;

int main()
{
  int i,j;//2????????????????¨????
  int x,y,s;
  int max=0;
  int a,b;//2????????????????¨????

 while(1){
  cin>>x>>y>>s;
  if(x==0&& y==0&&s==0)break;
  max=0;
  for(i=1;i<s;i++)
    //    cout<<'B'<<endl;
    for(j=1;j<=i;j++){
      a=i*(100+x)/100;
      b=j*(100+x)/100;
      //      cout<<'C'<<endl;
      if(a+b==s){
	//	cout<<'D'<<endl;
	//	cout<<'A'<<a<<" "<<b<<endl;
	a=i*(100+y)/100;
	b=j*(100+y)/100;

	if(max<a+b)
	  max=a+b;

	//	cout<<max<<'M'<<endl;
	//	cout<<'I'<<i<<" "<<j<<endl;

      }
    }
  cout<<max<<endl;     
 }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;
 
int main() {
	int t, i, j, k;
	int a, b, c ,d,F=0;
	string A,D,E;
	char B,C;
	cin >> A;
 
	a = A.size();
 
	a -= 2;
	cout << A[0]<< a << A[a+1]  << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
using namespace std;
const int N=1e5+3, INF=1e9;
int n, m;
signed main()
{
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2;
}

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


int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  if(n%2!=0) ans +=1;
  else{
      for(int i=0;i<n/2;++i){
          if(s[i]!=s[n/2+i]) ans+=1;
      }
  }
  if(ans>0) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	string S;
	cin >> S;

	char color = S[0];
	int range = 1;
	rep(i, 1, S.size()) {
		if(color != S[i]) {
			range++;
			color = S[i];
		}
	}

	cout << range - 1 << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int S;
    cin >> S;
    int U = S / 100;
    int D = S % 100;

    if(1 <= U && U <= 12) {
        if(1 <= D && D <= 12) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else if (1 <= D && D <= 12) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
}

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

bool solve(const string &s, const string &t){
	int N = s.size(), M = t.size();
	for(int k=0 ; k < M ; k++ ){
		for(int i=1 ; i < M ; i++ ){
			string str;
			for(int j=0 ; j < N ; j++ ){
				if( t.size() <= k + i * j ) continue;
				str.push_back(t[k + i * j]);
			}
			if( str == s ){
				return true;
			}
		}
	}
	return false;
}

int main(){
	int N, ans = 0;
	string s;
	cin >> N >> s;
	for(int i=0 ; i < N ; i++ ){
		string t;
		cin >> t;
		if( solve(s, t) ) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1216
#include <stdio.h>
int main() {
	int S, h, m, s;

	scanf("%d", &S);
	h = S / 3600;
	S -= h * 3600;
	m = S / 60;
	s = S - m * 60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

Measured memory_bytes: 592
N, H = map(int, input().split())
alist = []
blist = []
for i in range(N):
    A, B = map(int, input().split())
    alist.append(A)
    blist.append(B)

maxa = max(alist)
blist = list(filter(lambda el: el > maxa, blist))

def mergesort(l):
    def merge(left, right):
        result = []
        while left and right:
            if left[0] <= right[0]:
                result.append(left.pop(0))
            else:
                result.append(right.pop(0))
        return result + left + right

    length = len(l)
    if length <= 1:
        return l
    middle = length // 2
    return merge(mergesort(l[:middle]), mergesort(l[middle:]))

blist = mergesort(blist)
blist.reverse()

sum_for_h = 0
ans = 0
for i in blist:
    sum_for_h += i
    ans += 1
    if sum_for_h >= H:
        print(ans , flush=True)
        exit()

anum = (H-sum_for_h) / maxa
import math
anum = math.ceil(anum)
print(ans + anum, flush=True)



Measured memory_bytes: 22244
#include <iostream>

using namespace std;

int main(){
	int n,k,d;
	cin >> n;
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			if(4*i + j*7 == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << 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);
		String s = sc.next();
		int n = s.length();
		sc.close();
		int ans = 0;
		for(int i = 0; i < n; ++i) {
			if(s.charAt(i) == '0')++ans;
		}
		if(n - ans < ans)ans = n - ans;
		ans *= 2;
		System.out.println(ans);
	}

}



Measured memory_bytes: 25512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        int max = 0;
        int sum = 0;
        int[] diff = new int[N];
        for (int i = 0; i < N; i++) {
            if (i != N-1) {
                diff[i] = A[i+1]-A[i];
            } else {
                diff[i] = A[0]+K-A[N-1];
            }
            max = Math.max(max, diff[i]);
            sum += diff[i];
        }
        System.out.println(sum-max);
    }
}



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

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

    int way1 = N*(N-1)/2;
    int way2 = M*(M-1)/2;
    if(N == 0) way1 = 0;
    if(M == 0) way2 = 0;
    cout << way1+way2 << endl;
}

Measured memory_bytes: 256
//Volume5-0501
import java.util.*;

class Main {
	
	//declare
	private static HashMap<Character,Character> map = new HashMap<Character,Character>();
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int  n,m;
		char c,r;
		while((n=sc.nextInt())!=0){
			map.clear();
			while(n-- > 0){
				map.put(sc.next().charAt(0),sc.next().charAt(0));
			}
			m=sc.nextInt();
			while(m-- > 0){
				c=sc.next().charAt(0);
				if   (map.containsKey(c)){r=map.get(c);}
				else                     {r=c;         }
				System.out.print(r);
			}
			System.out.println();
		}
	}
}

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

void Main() {
  int N;
  string S;
  cin >> N >> S;

  int R[N], G[N], B[N];
  memset(R, 0, sizeof(R));
  memset(G, 0, sizeof(G));
  memset(B, 0, sizeof(B));
  if (S[0] == 'R') R[0] = 1;
  if (S[0] == 'G') G[0] = 1;
  if (S[0] == 'B') B[0] = 1;
  for (int i = 1; i < N; i++) {
    R[i] = R[i - 1];
    G[i] = G[i - 1];
    B[i] = B[i - 1];
    if (S[i] == 'R') R[i] = R[i - 1] + 1;
    if (S[i] == 'G') G[i] = G[i - 1] + 1;
    if (S[i] == 'B') B[i] = B[i - 1] + 1;
  }

  long long ans = 0;
  for (int i = 0; i < N; i++) {
    long long tmp = 0;
    if (S[i] == 'R') {
      tmp = (G[N - 1] - G[i]) * (B[N - 1] - B[i]);
      for (int j = i + 1; j + (j - i) < N; j++) {
        if ((S[j] == 'G' && S[j + (j - i)] == 'B') || (S[j] == 'B' && S[j + (j - i)] == 'G')) tmp--;
      }
    } else if (S[i] == 'G') {
      tmp = (R[N - 1] - R[i]) * (B[N - 1] - B[i]);
      for (int j = i + 1; j + (j - i) < N; j++) {
        if ((S[j] == 'R' && S[j + (j - i)] == 'B') || (S[j] == 'B' && S[j + (j - i)] == 'R')) tmp--;
      }
    } else if (S[i] == 'B') {
      tmp = (R[N - 1] - R[i]) * (G[N - 1] - G[i]);
      for (int j = i + 1; j + (j - i) < N; j++) {
        if ((S[j] == 'R' && S[j + (j - i)] == 'G') || (S[j] == 'G' && S[j + (j - i)] == 'R')) tmp--;
      }
    }
    ans += tmp;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <queue>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::string X, Y;
	int q;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	std::getline(ifs, X);
#else
	std::getline(std::cin, X);
#endif
	q = std::stoi(X);

	for(int i = 0; i < q; i++){
		std::vector<std::vector<int> > dp;
#if INPUT_FROM_FILE
		std::getline(ifs, X);
		std::getline(ifs, Y);
#else
		std::getline(std::cin, X);
		std::getline(std::cin, Y);
#endif
		dp.resize(X.size() + 1);
		for(int i = 0; i < dp.size(); i++){
			dp[i].resize(Y.size() + 1, 0);
		}

		for(int i = 0; i < X.size(); i++){
			for(int j = 0; j < Y.size(); j++){
				if(X[i] == Y[j]){
					dp[i + 1][j + 1] = dp[i][j] + 1;
				}
				else{
					dp[i + 1][j + 1] = std::max(dp[i + 1][j], dp[i][j + 1]);
				}
			}
		}
		std::cout << dp[X.size()][Y.size()] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 6856
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a-b)%c<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0162
{
    public class Program

    {
        public const int MAX = 1000000;

        public static void Main(string[] args)
        {
            bool[] isHumming = new bool[MAX + 1];
            int[] cumSum = new int[MAX + 1];

            for (int i = 0 ; i < 9 ; i++)
            {
                for (int j = 0 ; j < 13 ; j++)
                {
                    for (int k = 0 ; k < 20 ; k++)
                    {
                        long num = (long)(Math.Pow(5, i) * Math.Pow(3, j) * Math.Pow(2, k));
                        if(num <= 1000000) isHumming[num] = true;
                    }
                }
            }

            cumSum[1] = 1;
            for (int i = 2 ; i <= MAX ; i++)
            {
                cumSum[i] = cumSum[i - 1];
                if (isHumming[i]) cumSum[i]++;
            }

            while (true)
            {
                int[] items = RIntAr();
                if (items[0] == 0) break;             
                int primeCnt = cumSum[items[1]] - cumSum[items[0] - 1];
                Console.WriteLine(primeCnt);

            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

ll n, ret;

void dfs(ll num, int three, int five, int seven) {
	if (num > n) return ;
	if (three * five * seven > 0) ret++;

	dfs(10 * num + 3, 1, five, seven);
	dfs(10 * num + 5, three, 1, seven);
	dfs(10 * num + 7, three, five, 1);
	return ;
}

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

	cin >> n;

	dfs(0, 0, 0, 0);

	cout << ret << '\n';
	return 0;
}


Measured memory_bytes: 3656
import java.io.*;
import java.util.*;

class Main {
	static final String YES = "Yes";
	static final String NO = "No";

	// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		long A;
		A = sc.nextLong();
		long B;
		B = sc.nextLong();
		long C;
		C = sc.nextLong();
		solve(A, B, C);
	}

	static void solve(long A, long B, long C){
		if(A + B >= C){
			System.out.println(YES);
		}else{
			System.out.println(NO);
		}
	}
}


Measured memory_bytes: 25172
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m,ans=0;
    cin >> n >> m >> k;
	vc a,b;
	a.resize(n+1);
	b.resize(m+1);
	for (ll i = 1; i <= n; ++i)
	{
		cin >> a[i];
		a[i] += a[i-1];
	}
	for (ll i = 1; i <= m; ++i)
	{
		cin >> b[i];
		b[i] += b[i-1];
	}
 
	for (ll i = 0; i <= n; ++i)
	{
		ll rem = k - a[i];
		if(rem < 0)
			break;
		auto it = upper_bound(all(b), rem) - b.begin() - 1;
		ans = max(ans, i + it);
	}
 
	cout << ans << endl;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 13500
#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<double,int>;

int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<P,vector<P>,greater<P>>q;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        q.emplace(P(a,b));
    }
    int ans=0,now=0;
    priority_queue<int>q2;
    rep(i,m){
        while(!q.empty()&&i+1>=q.top().first){
            q2.emplace(q.top().second);
            q.pop();
        }
        if(!q2.empty()){
            ans+=q2.top();
            q2.pop();
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5544
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}

int main()
{
	ll n=ri();
	while(n--)
	{
		ll a=ri(),b=ri();
		if(a==1&&b==1)
		{	
			wi(0);putchar('\n');
			continue;
		}
		if(a>b)	swap(a,b);
		ll s=a*b;	
		ll gg=sqrt((long double)(s-1));
		ll sum=gg*2;
		if(gg==(s-1)/gg)	sum--;
		if(a<=gg)	sum--;
		wi(sum);putchar('\n');
	}
	return 0;
}


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

using namespace std;
#define endl "\n"
#define FILEIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define LL long long 
#define mod 1000000007LL
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
//#define p push
#define I insert
#define bg begin()
#define ed end()
#define sz size()
#define all(v) v.begin(),v.end()
typedef vector<LL> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef map<LL ,LL > mii;
//typedef priority_queue<int> pq;
typedef queue<int>que;
typedef stack<int>stk;
#define Inf 100000005LL
#define f first
#define s second





vi vect_2pow;
void pow_of_2(){
    vect_2pow.assign(32,0);
      for(int i=0;i<=32;i++){
           LL y = 1<<i;
           vect_2pow[i]=y;
      }
}
bool Ispalindrome(string str){
        LL len = str.size();
		bool flag;
		for(int i=0;i<len/2;i++){
				if(str[i]==str[len-i-1])
				     {
						 flag=0;
						 continue;
					 }
					 else 
					    {
							flag=1;
							break;
						}
			}
		if (flag==1)
		  return false;
		else return true;  
		
}
vector<LL> prime_check;
mii get_high_prime;
int high_prime_factor(){
	//cout<<"ecd";
	LL max_prime=0;
	for(int i=2;i<100000;i++)
	{
		LL n=i;
		
		while(n%2==0)
		{
			max_prime=2;
			n>>=1;
		}
		for(int j=3;j<=sqrt(n);j++)
		{
			while(n%j==0){
				max_prime=j;
				n/=j;
			}
		}
		if(n>2)
		  max_prime=n;
		  
		//prime_check.pb(max_prime);
		get_high_prime[i]=max_prime;
	}
	
			
}

const LL inf = 10e+9;

int main()
{
   fast;
   LL n,k;
   cin>>n>>k;
   vi vect(n);
   for(LL &x:vect)
        cin>>x;

   vector<LL> dp(n,inf);
   dp[0]=0;
   for(LL i=0;i<n;i++)
   {
	   for(LL j=i+1;j<=i+k;j++){
		   if(j<n)
		   {
			   dp[j]=min(dp[j],dp[i]+abs(vect[i]-vect[j]));
			   //cout<<dp[j]<<" "<<j<<endl;
		   }
	   }
   }
   cout<<dp[n-1];


}

Measured memory_bytes: 1792
k,n=map(int, input().split())
a=list(map(int, input().split()))

max_distance = abs(k - a[-1] + a[0])
str_index = 0
gl_index = -1
for i in range(n):
    if i == 0:
        continue
    elif max_distance < abs(a[i-1] - a[i]):
        max_distance = abs(a[i-1] - a[i])
        str_index = i-1
        gl_index = i
if gl_index == -1:
    print(a[gl_index] - a[str_index])
else:
    print(a[str_index] + (k - a[gl_index]))

Measured memory_bytes: 26444
#include <stdio.h>
#define MAX 2000000

void max(int);

int size,A[MAX+1];

int main ()
{
  scanf("%d",&size);
  int i;
  
  for(i=1;i<=size;i++) scanf("%d",&A[i]);

  for(i=size/2;i>=1;i--) max(i);

  for(i=1;i<=size;i++)
    {
      printf(" %d",A[i]);
    }
  printf("\n");

  return 0;
}

void max(int i)
{
  int l,r,largest,t;
  l=2*i;
  r=2*i+1;
  if(l<=size && A[l]>A[i]) largest=l;
  else largest = i;
  if(r<=size&&A[r]>A[largest]) largest = r;
  if(largest != i)
    {
      t=A[i];A[i]=A[largest];A[largest]=t;
      max(largest);
    }
}




  



Measured memory_bytes: 3692
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn :: IO Int
    print $ solve n

solve :: Int -> Int
solve n = sum [m | m<-map (subtract 1) ds, let (q, r) = divMod n m, q == r]
  where
    (1:ds) = divisors n
-------------------------------------------------------------------------------

primeFactors :: Int -> [Int]
primeFactors n | n < 2 = []
primeFactors n = go n $ 2:[3,5..]
  where
    go !n pps@(p:ps)
        | n < p * p = [n]
        | r > 0     = go n ps
        | otherwise = p : go q pps
      where
        (q, r) = quotRem n p
    go n [] = [n]

isPrime :: Int -> Bool
isPrime n = [n] == primeFactors n

divisors :: Int -> [Int]
divisors n = L.sort . map product . mapM (scanl (*) 1) . L.group $ primeFactors n

type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

Measured memory_bytes: 2300
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


void solve() {
   int n,m;cin>>n>>m;
   char a[n][m];
   for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>a[i][j];
   int dp[n][m];
   memset(dp,0, sizeof(dp));
   dp[0][0]=1;
   bool b=true;
   for(int i=1;i<m;i++){
       if(b && a[0][i]=='.'){
           dp[0][i]=1;
       } else{
           b=false;
           dp[0][i]=0;
       }
   }
   b=true;
    for(int i=1;i<n;i++){
        if(b && a[i][0]=='.'){
            dp[i][0]=1;
        } else{
            b=false;
            dp[i][0]=0;
        }
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(a[i][j]=='.'){
                if(a[i-1][j]=='.'){
                    dp[i][j]+=dp[i-1][j];
                }
                if(a[i][j-1]=='.'){
                    dp[i][j]+=dp[i][j-1];
                }
            }
            dp[i][j]%=MOD;
        }
    }
    cout<<dp[n-1][m-1]<<endl;
}
int32_t main() {
    IOS;
    int test = 1;
//    cin >> test;
    for(int i=1;i<=test;i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 9088
A, B, C = map(int, input().split())

if A == B:
    if A != C:
        print('Yes')
    else:
        print('No')
elif A == C:
    if A != B:
        print('Yes')
    else:
        print('No')
elif B == C:
    if B != A:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 38384
using System;


public class B{
	
	public static void Main(){
	
		string[] args = Console.ReadLine().Split(' ');
		int n = Int32.Parse(args[0]);
		
		int result = 0;
		if( n >= 105 ){
			
			result = 1;  // 105
			for( int i = 117; i <= n; i+=2 ){
				int counter = 1;  // 1
				for( int j = 2; j <= i; j++ ){
					if( i % j == 0 ) counter++;
					if( counter > 8 ) break;
				}
				if( counter == 8 ) result++;
			}			
			
		}
		
		Console.WriteLine(result);
		
	}

}

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

int main() {
    int N;
    cin >> N;
    int x = N;
    int digit_sum = 0;

    while (x > 0) {
        digit_sum += x % 10;
        x /= 10;
        // cout << digit_sum << endl;
    }

    if (N % digit_sum == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin>>N;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin>>A[i];
	}
	int ans = 0;
	for(int i=0;i<N;++i){
		while(A[i]%2 == 0){
			A[i] /= 2;
			++ans;
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
using System;

class A {
    static void Main(string[] args) {
        var val = Console.ReadLine().Split(' ');

        int A = int.Parse(val[0]);//倍数
        int B = int.Parse(val[1]);//割る数
        int C = int.Parse(val[2]);//この値になるか

        int[] count = new int[B];
        for (int i = 0; i < B; i++)
        {
            count[i] = 1000;
        }
        //mod計算
        for (int i = 0; i < B; i++)
        {
            count[i] = A*i % B;
            if ((count[0] == count[i])&&i!=0) { count[i] = 1000;break; }
        }

        Array.Sort(count);

        Console.WriteLine((C % (count[1] - count[0]) == 0) ? "YES" : "NO");
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,m; cin >> n>>m;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vii ch(m);
  rep(i,m) {
    int b, c; cin >> b >> c;
    ch[i] = make_pair(b,c);
  }
  sort(ch.begin(), ch.end(), [](ii a, ii b) {return a.second > b.second;} );
  int cnt = 0;
  [&] {
    rep(i, m)
    {
      rep(j, ch[i].first)
      {
        cnt++;
        a.push_back(ch[i].second);
        if (cnt > n)
          return;
      }
    }
  }();
  sort(a.begin(), a.end(), [](ll a, ll b) {return a>b;});
  ll ans = 0;
  rep(i,n) ans += a[i];
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 5616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

int main(){
  int n, _p;
  while(cin >> n >> _p) {
    if(n == 0 && _p == 0) break;
    vector<int> people(n, 0);
    int step = 0, p = _p;
    while(1){
      if(p){
	people[step]++;
	p--;
      } else {
	p = people[step];
	people[step] = 0;
      }
      
      if(people[step] == _p) {
	cout << step << endl;
	break;
      }
      step = (step + 1) % n;
    }
  }
  return 0;
}



Measured memory_bytes: 3012
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int N;

int main() {
	cin >> N;
	ll ak[111111][3];
	ll dp[111111][3];
	rep(i, 0, N) {
		cin >> ak[i][0] >> ak[i][1] >> ak[i][2];
		dp[i][0] = 0;
		dp[i][1] = 0;
		dp[i][2] = 0;
	}
	rep(i, 0, N) {
		rep(j, 0, 3) {
			rep(k, 0, 3) {
				if (j == k) continue;
				chmax(dp[i + 1][k], dp[i][j] + ak[i][k]);
			}
		}
	}
	cout << max({ dp[N][0], dp[N][1], dp[N][2] }) << endl;

	return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ---------------------------------------------------------------------------

int main(){
  vector<int> vec(4);
  for(int i=0; i<4; i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  int ans = inf;
  do{
    chmin(ans,abs(vec[0]+vec[1]-(vec[2]+vec[3])));
  }while(next_permutation(vec.begin(),vec.end()));
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3172
def inp() a=gets.chomp.split(" ").map(&:to_i)end 
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b = na(a.max+1); a.each{|n|b[n]+=1};return b end
def na(n=0,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
class Uf
def initialize(n)
  @r = na(n+1)
  @a = (0...n).to_a
end
def uf(x)
  return x if (@a[x] == x)
  @a[x] = uf(@a[x])
end
def add(x,p)
  root  = uf(x)
  connect  = uf(p)
  return if root == connect
  if @r[root] > @r[connect]
    @a[connect] = root
  elsif @r[root] == @r[connect]
    @a[connect] = root
    @r[root] += 1
  else
    @a[root] = connect
  end
end
def ufj(x,p)
   return uf(x) == uf(p) 
end
end
h = {}
n,k,l = inp
a = Uf.new(n+1)
b = Uf.new(n+1)
(k).times do |i|
  d = inp
  a.add(d[0],d[1])
end
(l).times do |i|
  d = inp
  b.add(d[0],d[1])
end
(1..n).each do |i|
  aa = a.uf(i)
  bb = b.uf(i)
  h[[aa,bb]] = 0 if(h[[aa,bb]] == nil)
  h[[aa,bb]] += 1
end
(1..n-1).each do |i|
  aa = a.uf(i)
  bb = b.uf(i)
  print "#{h[[aa,bb]]} " 
end
aa = a.uf(n)
bb = b.uf(n)
puts h[[aa,bb]]
=begin
max = c if max < c 
=end

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

int main(){
    int k, s;
    cin >> k >> s;

    int cnt = 0;
    for(int i=0;i<=k;++i){
        for(int j=0;j<=k;++j){
            int l = s - i - j;
            if(l >= 0 && l <= k)cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int c = 0;
        for (int i = 0 ; i < s.length ; i++) {
            if (s[i] != t[i]) {
                c++;
            }
        }
        System.out.println(c);
    }

}


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

int main(){
    int i,j,n,sum=0,ans=0,count=0;;
    cin >> n;
    vector<int> s(n);
    vector<bool> juu(n,false);
    for(i=0;i<n;i++){
        cin >> s.at(i);
        sum += s.at(i);
        if(s.at(i)%10==0)juu.at(i)=true;
    }
    if(sum%10!=0)cout << sum << endl;
    else{
        for(i=0;i<n;i++){
            if(juu.at(i))count++;
            else ans = max(ans,sum-s.at(i));
        }
        if(count==n)cout << 0 << endl;
    else cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s ;
    cin >> s ;
    int cnt = 0 ;
    if(s[0] == '1')
        cnt ++ ;
    if(s[1] == '1')
        cnt ++ ;
    if(s[2] == '1')
        cnt ++ ;

    cout << cnt << endl ;


}


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

void solve(){
    int n;
    cin >> n;
    cout << n * (n + 1)/2 << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t =1;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <tuple>
#include <math.h>
#include <iomanip>
#include <string>
#include <queue>

using namespace std;

class Sover {
};

int main()
{
	while (true) {
		int w, h;
		cin >> w >> h;
		if (w == 0)break;

		vector<vector<int>> grid(h, vector<int>(w, 0));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> grid[i][j];
			}
		}

		vector<int> costs(4);
		for (int i = 0; i < 4; i++)cin >> costs[i];

		vector<vector<vector<int>>> distances(h,
			vector<vector<int>>(w, vector<int>(4, 1e9)));

		queue<tuple<int, int, int, int>> que;
		que.emplace(make_tuple(0, 0, 0, 0));
		while (que.size() > 0) {
			int y, x, dire, cost;
			tie(y, x, dire, cost) = que.front();
			que.pop();
			if (distances[y][x][dire] <= cost)continue;

			distances[y][x][dire] = cost;

			if (y > 0) {
				int next_cost = 0;
				if (dire == 0) {
					if (grid[y][x] != 3)next_cost = costs[3];
				}
				if (dire == 1) {
					if (grid[y][x] != 2)next_cost = costs[2];
				}
				if (dire == 2) {
					if (grid[y][x] != 1)next_cost = costs[1];
				}
				if (dire == 3) {
					if (grid[y][x] != 0)next_cost = costs[0];
				}
				next_cost += cost;
				que.push(make_tuple(y - 1, x, 3, next_cost));
			}
			if (y + 1 < h) {
				int next_cost = 0;
				if (dire == 0) {
					if (grid[y][x] != 1)next_cost = costs[1];
				}
				if (dire == 1) {
					if (grid[y][x] != 0)next_cost = costs[0];
				}
				if (dire == 2) {
					if (grid[y][x] != 3)next_cost = costs[3];
				}
				if (dire == 3) {
					if (grid[y][x] != 2)next_cost = costs[2];
				}
				next_cost += cost;
				que.push(make_tuple(y + 1, x, 1, next_cost));
			}
			if (x > 0) {
				int next_cost = 0;
				if (dire == 0) {
					if (grid[y][x] != 2)next_cost = costs[2];
				}
				if (dire == 1) {
					if (grid[y][x] != 1)next_cost = costs[1];
				}
				if (dire == 2) {
					if (grid[y][x] != 0)next_cost = costs[0];
				}
				if (dire == 3) {
					if (grid[y][x] != 3)next_cost = costs[3];
				}
				next_cost += cost;
				que.push(make_tuple(y, x - 1, 2, next_cost));
			}
			if (x + 1 < w) {
				int next_cost = 0;
				if (dire == 0) {
					if (grid[y][x] != 0)next_cost = costs[0];
				}
				if (dire == 1) {
					if (grid[y][x] != 3)next_cost = costs[3];
				}
				if (dire == 2) {
					if (grid[y][x] != 2)next_cost = costs[2];
				}
				if (dire == 3) {
					if (grid[y][x] != 1)next_cost = costs[1];
				}
				next_cost += cost;
				que.push(make_tuple(y, x + 1, 0, next_cost));
			}
		}

		int res = 1e9;
		for (int i = 0; i < 4; i++)res = min(res, distances[h - 1][w - 1][i]);

		cout << res << endl;
	}
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846

using namespace std;

void test_case()
{
    int s,w;
    cin>>s>>w;
    if(w>=s) puts("unsafe");
    else puts("safe");

}

int main()
{
    test_case();

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>

using namespace std;

typedef long long ll;

const ll prime = 10000000000 + 7;



int main() {
	
	vector<int> s(4);
	int num;
	cin >> num;
	for (int i = 0; i < 4; i++)
	{
		s[3-i] = (num / (int)(pow(10, i))) % 10;
	}

	int currentNum;
	vector<char> operators(3);
	bool yes = false;

	for (int i = 0; i < pow(2, 3); i++)
	{
		currentNum = (int)s[0];
		for (int j = 0; j < 3; j++)
		{
			if (i & (1 << j)) {
				operators[j] = '+';
				currentNum += (int)s[j + 1];
			}
			else {
				operators[j] = '-';
				currentNum -= (int)s[j + 1];
			}
		}

		if (currentNum == 7) {
			yes = true;
			break;
		}
	}


	if (yes) {
		string text = "";
		for (int i = 0; i < 3; i++)
		{
			text += to_string(s[i]);
			text += operators[i];
		}
		text += to_string(s[3]);
		text += "=7";

		cout << text << endl;
	}

	return 0;
}

Measured memory_bytes: 888