akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
	int n,q,tmp=0;
	string s;
	cin>>n>>q>>s;
	vector<int> l(q),r(q);
	for(int i=0;i<q;i++){
		cin>>l[i]>>r[i];
	}
	vector<int> hint(n);
	bool A=false;
	for(int i=0;i<n;i++){
		if(s[i]=='A'){
			A=true;
			hint[i]=tmp;
		}else if(s[i]=='C' && A){
			tmp++;
			hint[i]=tmp;
			A=false;
		}else{
			hint[i]=tmp;
			A=false;
		}
	}
	for(int i=0;i<q;i++){
		cout << hint[r[i]-1] - hint[l[i]-1] <<"\n";
	}
	return 0;
}


Measured memory_bytes: 2256
N,Y = map(int, input().split(" "))
f = False
t = int(Y/10000)
for a in range(t+1):
    for b in range(N+1):
        if a+b>N:
            break
        c=N-a-b
        num = a*10000+b*5000+c*1000
        if num==Y:
            print(str(a)+" "+ str(b)+" "+str(c))
            f=True
            break
    if f:
        break
if f==False:
    print('-1 -1 -1')


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

using namespace std;

const int N = 10000002;

int main(){
  int n,count = 0 ;
  vector<int> v(N,1) ;
  v[0] = 0, v[1] = 0;
  for(size_t i = 2; i < N-1;++i){
    if(v[i] == 1){
      for(size_t j = i*2; j < N-1;j+=i){
          v[j] = 0 ;
      }
    }
  }
  while(cin >> n){
    count = 0 ;
    for(size_t i = 2; i <= n;++i){
      if(v[i] == 1){
        ++count ;
      }
    }
    cout << count << endl;
  }
  return 0 ;
}

Measured memory_bytes: 40176
S = input()
S = S.replace("LR", "L,R")
S_list = S.split(",")
def counter(S):
    S_left_right = S.split("RL")
    S_left = S_left_right[0]
    S_right = S_left_right[1]
    num_R = len(S_left)
    num_L = len(S_right)
    num_center = [1, 1]
    num_center[0] += num_R // 2
    num_center[1] += num_R - num_R // 2
    num_center[0] += num_L - num_L // 2
    num_center[1] += num_L // 2
    return_list = [0] * num_R + num_center + [0] * num_L
    return return_list
ans = []
for string in S_list:
    ans += counter(string)
print(*ans)

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

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

    ll A[N+1];
    rep(i, N) cin >> A[i];
    A[N] = 0;

    sort(A, A+N+1, greater<int>());

    ll long_side = 0, short_side = 0;
    int same_num = 1;
    rep(i, N) {
        if (A[i] == A[i+1]) same_num++;
        else {
            if (same_num >= 4) {
                long_side = max(long_side, A[i]);
                short_side = max(short_side, A[i]);
            } else if (same_num >= 2) {
                if (long_side == 0) long_side = A[i];
                else if (short_side == 0) short_side = A[i];
            }
            same_num = 1;
        }
    }

    cout << long_side * short_side << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vector<double> dp(3000, 0);
  dp[0] = 1.0;
  for(auto&& i:irange(0,n)) {
    double p;
    cin>>p;
    vector<double> tmp(3000, 0);
    for(auto&& j:irange(0,2999)) {
      tmp[j+1] += dp[j] * p;
      tmp[j] += dp[j] * (1.0 - p);
    }
    swap(dp, tmp);
  }
  cout<<fixed<<setprecision(10)<<accumulate(begin(dp) + (n/2+1), end(dp), 0.0)<<endl;
  return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

int n, one, two, three, p;
vec<vec<vd>> dp;
/*FUNCs=================================================*/
double func(int one, int two, int three) {
    if(dp[one][two][three] != -1) return dp[one][two][three];
    if(one==0&&two==0&&three==0) return 0.0;

    double ret = 0.0;
    if(one>0) ret += func(one-1, two, three) * one;
    if(two>0) ret += func(one+1, two-1, three) * two;
    if(three>0) ret += func(one, two+1, three-1) * three;
    ret += n;
    ret *= 1.0/(one+two+three);
    dp[one][two][three] = ret;
    return ret;
}

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    cout << fixed << setprecision(15);

    cin >> n;
    rep(i,n) {
        cin >> p;
        if(p==1) ++one;
        else if(p==2) ++two;
        else ++three;
    }
    dp.resize(305, vec<vd>(305, vd(305, -1)));

    double ans = func(one,two,three);
    cout << ans << '\n';
}

Measured memory_bytes: 225664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int S;
    cin >>S;
    int count=1;
   
    for(;;){
        if(S==4||S==2||S==1){
            cout <<count+3<<endl;
            return 0;
        }
        if(S%2==1){
            S=3*S+1;
            count++;
        }
        else{
            S=S/2;
            count++;
    }
    }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
const int N = 3003;

int n;
long double dp[N];
long double ndp[N];

int main()
{
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(11);
    cin >> n;
    dp[0] = 1;
    for (int ii = 0; ii < n; ++ii)
    {
        memset(ndp, 0, sizeof ndp);
        long double x;
        cin >> x;
        for (int i = 0; i <= ii; ++i)
        {
            ndp[i] += (dp[i] * (1 - x));
            ndp[i + 1] += (dp[i] * x);
        }
        memcpy(dp, ndp, sizeof ndp);
    }
    long double ans = 0;
    for (int i = n / 2 + 1; i <= n; ++i)
        ans += dp[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  ll n;
  cin >> n;
  vector<ll> ya;
  for(ll i = 1; i * i <= n; i++){
    if(n % i != 0) continue;
    ya.push_back(i);
    ll j = n / i;
    if(i == j) continue;
    ya.push_back(j);
  }

  ll ans = 0;
  for(ll add : ya){
    add--;
    if(add == 0) continue;
    if(n/add == n % add) ans += add;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

  ll int N;
  cin >> N;

  ll int A[N+1];
  ll int hito[N+1];
  ll int x[16][16];
  ll int y[16][16];
  rep(i,N){
	  cin >> A[i];
   rep(j,A[i]){
		   cin >> x[i][j] >> y[i][j];
		   }
		   }

   ll int ans = 0;
   ll int kazu =0;
   ll int unko =0;
  for(int i=0;i < 1<<N;i++){
	kazu = 0;
	unko = 0;
    for(int j = 0;j<N;j++){
      if(i>>j & 1){
      hito[j+1]=1;
      kazu+=1;
      }
      else{
      hito[j+1]=0;
      }

      }

      for(int k=1;k<=N;k++){
       if(hito[k]==1){
	rep(j,A[k]){
		if(hito[ x[k][j]] == y[k][j]){
		}
		else{
			unko =2;
		}
	}
	}

       else{}
      }
 
      if(unko == 0){
	      if(ans < kazu){
	      ans = kazu;
	      }
	      else{}
      }
      else{}
  }
   cout << ans;











	return 0;

}



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

int main(){
    using namespace std;
    vector<unsigned long> ans;
    const auto& dfs = [&ans](auto f, unsigned long v, unsigned long p) -> void {
        if(v > 3234566667)return;
        ans.push_back(v);
        for(unsigned long i{max(1UL, p) - 1}, j{min(p, 8UL) + 2}; i < j; ++i)f(f, 10 * v + i, i);
    };
    for(unsigned long i{1}; i <= 9; ++i)dfs(dfs, i, i);
    sort(ans.begin(), ans.end());
    unsigned long K;
    cin >> K;
    cout << ans[K - 1] << endl;
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	map<int, int> a, b;
	REP(i, n) {
		if (i & 1)a[v[i]]++;
		else b[v[i]]++;
	}
	vector<pii> A, B;
	for (auto c : a)A.push_back({ c.second,c.first });
	for (auto c : b)B.push_back({ c.second,c.first });
	sort(ALL(A), greater<>());
	sort(ALL(B), greater<>());
	if (A.size() == 1 && B.size() == 1) {
		if (A[0].second != B[0].second)cout << 0 << endl;
		else cout << n / 2 << endl;
	}
	else {
		if (A.size() == 1) {
			if (A[0].second == B[0].second)cout << (n + 1) / 2 - B[1].first << endl;
			else cout << (n + 1) / 2 - B[0].first << endl;
		}
		else if (B.size() == 1) {

			if (A[0].second == B[0].second)cout << (n + 1) / 2 - A[1].first << endl;
			else cout << (n + 1) / 2 - A[0].first << endl;
		}
		else {

			if (A[0].second == B[0].second)cout << n - max(A[0].first + B[1].first, A[1].first + B[0].first) << endl;
			else cout << n - A[0].first - B[0].first << endl;
		}
	}
}

Measured memory_bytes: 6524
#include <stdio.h>

int bubblesort(int A[],int N)
{
  int i,j,v;
  int count = 0;
  for(i = 0; i < N - 1; i++)
  {
    for(j = N - 1; j > i; j--)
    {
      if(*(A + j) < *(A + j - 1))
      {
        v = 0;
      	v = *(A + j);
        *(A + j) = *(A + j - 1);
        *(A + j - 1) = v;
        count++;
      }
    }
  }
  return count;
}

int main()
{
  int N,count,i;
  int A[100];
  
  scanf("%d",&N);
  for(i = 0; i < N; i++)
  {
    scanf("%d",A + i);
  }
  
  count = bubblesort(A,N);
  
  for(i = 0; i < N; i++)
  {
    if(i > 0)
  	{
  		printf(" ");
  	}
  	printf("%d",*(A + i));
  }
	printf("\n");
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 604
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN (1<<18)

int n, m;
int a[MAXN];
pair<int,int> s[MAXN][2];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	m = (1<<n);
	for (int i=0; i<m; i++) scanf("%d", &a[i]);
	return 1;
}

void init() {
	memset(s, 0, sizeof(s));
}

void merge(int i, int j) {
	pair<int,int> x[4] = {s[i][0], s[i][1], s[j][0], s[j][1]};
	sort(x, x+4);
	int k = unique(x, x+4)-x;
	//p(k, x[0], x[1], x[2], x[3]);
	s[i][0] = x[k-1];
	s[i][1] = x[k-2];
}

long solve() {
	for (int i=0; i<m; i++) s[i][0] = {a[i], i};
	for (int k=0; k<n; k++) {
		int b = (1<<k);
		for (int i=0; i<m; i++)
			if ((i&b)==0)
				merge(i|b, i);
	}
	return 1;
}

void output(long ans) {
	long x = 0;
	for (int i=1; i<m; i++) {
		//p(s[i][0], s[i][1]);
		x = max(x, long(s[i][0].first)+s[i][1].first); 
		printf("%ld\n", x);
	}
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 8064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		// スキャナのクローズ
		sc.close();
		System.out.println(a % b == 0 ? 0 : 1);
	}
}

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

using namespace std;

vector<int> toList[100'000];
vector<u_int64_t> weightList[100'000];

u_int64_t distFromK[100'000];
bool isFinished[100'000];

int x[100'000];
int y[100'000];

void fill(int node)
{
    isFinished[node] = true;
    for (int i = 0; i < toList[node].size(); i++)
    {
        int to = toList[node][i];
        u_int64_t w = weightList[node][i];

        if (isFinished[to])
        {
            continue;
        }

        distFromK[to] = distFromK[node] + w;
        fill(to);
    }
}

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        u_int64_t c;
        cin >> a >> b >> c;
        a--;
        b--;

        toList[a].push_back(b);
        weightList[a].push_back(c);

        toList[b].push_back(a);
        weightList[b].push_back(c);
    }

    int Q, K;
    cin >> Q >> K;
    K--;

    distFromK[K] = 0;
    fill(K);

    for (int i = 0; i < Q; i++)
    {
        int xx, yy;
        cin >> xx >> yy;
        xx--;
        yy--;

        x[i] = xx;
        y[i] = yy;
    }

    for (int i = 0; i < Q; i++)
    {
        u_int64_t ans = distFromK[x[i]] + distFromK[y[i]];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 19072
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String S = scanner.nextLine();
    scanner.close();
    if (S.equals("AAA") || S.equals("BBB")) {
        System.out.println("No");
    } else {
        System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 22612
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>




int main(int argc, char* argv[]) {
	int a,b;//a人、b種類のお菓子

	std::cin >>a>>b;

	std::vector<int> count(a);
	for (int x = 1; x < a; x++) {
		count.at(x) = 0;
	}

	std::vector<int> count2(b);

	//int* p = new int[b][b];
	//std::vector<std::vector<int>> p(b, std::vector<int>(100));
	for (int i = 0; i < b; i++) {
		std::cin >> count2[i];
		int l,l2;
		//printf("%dつ入力してね\n", count2[i]);
		for (int j = 0; j < count2[i];j++) {
			std::cin >> l;
			l2 = l - 1;
			//printf("入力=%d\n", l);
			count.at(l2)=1;
		}
		//printf("ループぬけたよ\n");
		/*for (int j = 0; j < count2[i]; j++) {
			int num;
			std::cin >> num;
			count[num]++;
		}*/
	}
	int countA = a;
	for (int y = 0; y < a; y++) {
		if (count.at(y) != 0) {
			countA--;
		}
	}
	std::cout << countA;
	std::cout << std::endl;


	
	

	//printf("%d\n", d);
	//std::cout <<d<< std::endl;
	return 0;
}



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

int main() {
  int n; cin >> n;
  set<string> word_set;
  string ans = "Yes";

  char last_char = '\0';
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    
    if (last_char != '\0' && last_char != s[0]) {
      ans = "No";
      break;
    }
    last_char = s[s.size() - 1];
    word_set.insert(s);
  }
    
  if (word_set.size() != n) ans = "No";
  
  cout << ans << endl;
  
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int ac = 0, wa = 0, tle = 0, re = 0;
  string s;
  for(int i = 0; i < N; i++){
    cin >> s;
    if(s == "AC"){
      ac++;
    }else if(s == "WA"){
      wa++;
    }else if(s == "TLE"){
      tle++;
    }else if(s == "RE"){
      re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}

Measured memory_bytes: 3628
"use strict";

var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );

readable.on( 'data', function( chunk ) {
		var data = chunk.split( ' ' );
		var a = parseInt( data[0] );
		var b = parseInt( data[1] );
		if( a < b ) {
			console.log( "a < b" );
		} else if( a > b) {
			console.log( "a > b" );
		} else {
			console.log( "a == b" );
		}
	});



Measured memory_bytes: 15244
//abc175_a.cpp
//Sat Aug 15 20:46:18 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (s=="RRR"){
		cout << 3 << endl;
	}else if (s=="RRS" || s=="SRR"){
		cout << 2 << endl;
	}else if (s=="RSS" || s=="SRS" || s=="SSR" || s=="RSR"){
		cout << 1 << endl;
	}else {
		cout << 0 << endl;
	}


//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3624
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_variables)]

use std::io::stdin;
use std::str::FromStr;
use std::collections::VecDeque;

fn read<T: FromStr>() -> T {
    let mut str = String::new();
    stdin().read_line(&mut str).ok();
    str.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut str = String::new();
    stdin().read_line(&mut str).ok();
    str.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_n_vec<T: FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v_outer = Vec::new();
    for _ in 0..n {
        let v_inner = read_vec();
        v_outer.push(v_inner);
    }
    v_outer
}

fn main() {
    let k: u32 = read();
    let mut q: VecDeque<u64> = VecDeque::new();

    for i in 1..10 {
        q.push_back(i);
    }

    let mut ppd = 0;
    for _ in 0..k {
        ppd = q.pop_front().unwrap();
        if ppd % 10 != 0 {
            q.push_back(10 * ppd + ppd % 10 - 1);
        }

        q.push_back(10 * ppd + ppd % 10);

        if ppd % 10 != 9 {
            q.push_back(10 * ppd + ppd % 10 + 1);
        }
    }
    println!("{}", ppd);
}

Measured memory_bytes: 6396
import java.util.Scanner;

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

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += a[i];
            }

            int mean = sum / N;

            int min = (int) 1e9;
            min = Math.min(min, sumDiff(N, a, mean));
            min = Math.min(min, sumDiff(N, a, mean + 1));

            System.out.println(min);
        }
    }

    private static int sumDiff(int N, int[] a, int mean) {
        int sumDiff = 0;
        for (int i = 0; i < N; i++) {
            sumDiff += (a[i] - mean) * (a[i] - mean);
        }
        return sumDiff;
    }
}


Measured memory_bytes: 27216
N = int(input())
d = {}
ans = 0
for n in range(1, N+1):
  l = n%10
  u = n
  while u >= 10:
    u //= 10
  if l > 0:
    if (u,l) in d:
      d[(u,l)] += 1
    else:
      d[(u,l)] = 1
for i in range(1, 10):
  if (i, i) in d:
    a = d[(i, i)]
    ans += a*(a-1)+a
  for j in range(i+1, 10):
    a, b = (0, 0)
    if (i, j) in d:
      a = d[(i, j)]
    if (j, i) in d:
      b = d[(j, i)]
    ans += a*b*2
print(ans)

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

using namespace std;

int main(void){
    int n, ans;

    cin >> n;

    ans = 0;
    vector<int> p(n,0);
    int min_v = 200001;

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

        if(p[i] < min_v)
            ans++;

        min_v = min(min_v,p[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	ll n, d;
	cin >> n >> d;
	ll cnt = 0;
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		if (a * a + b * b <= d * d) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include<string.h>
#include<math.h>
#include<algorithm>

using namespace std;

int main() {
	string S;
	char A, B;
	cin >> S;
	if (S[0] == S[1]) {
		if (S[2] == S[3]) {
			if (S[1] == S[2] || S[0] == S[3])cout << "No" << endl;
			else cout << "Yes" << endl;
		}
		else cout << "No" << endl;
		return 0;
	}
	else{
		A = S[0];
		B = S[1];
		if (A == S[2]) {
			if (B == S[3])cout << "Yes" << endl;
			else cout << "No" << endl;
			return 0;
		}
		if (B == S[2]) {
			if (A == S[3])cout << "Yes" << endl;
			else cout << "No" << endl;
			return 0;
		}
		else cout << "No" << endl;
	}

	return 0;
}


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

int main() {
  int N, A, x;
  
  cin >> N;
  cout << endl;
  cin >> A;
  
  x = N%500 ;
  
  if (x <= A){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;

int main (int argc, char *argv[]) {
    int n, total;
    while (cin>>n, n) {
        total = 0;
        for (int i = 0; i < 9; ++i) {
            int tmp;
            cin>>tmp;
            total += tmp;
        }
        cout<<n - total<<endl;
    }
    return 0;
}


Measured memory_bytes: 3056
n,k=map(int,input().split())
mod=10**9+7
tree=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)
stack=[0]
visited=[True]+[False]*n
ans=k
while stack:
  v=stack.pop()
  c=k-2 if v!=0 else k-1
  for i in tree[v]:
    if not visited[i]:
      ans=(ans*c)%mod
      c-=1
      stack.append(i)
      visited[i]=True
print(ans)

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int a, b;
    char op;
    cin >> a >> op >> b;
    cout << (op == '+' ? a + b : a - b) << endl;
}


Measured memory_bytes: 256
n,q=map(int,input().split())
s=input()
count=[0]*n
for i in range(1,n):
    count[i]+=count[i-1]
    if s[i-1:i+1]=="AC":
        count[i]+=1
for i in range(q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])

Measured memory_bytes: 7700
N = int(input())
P = [i for i in input().split()]
Q = [i for i in input().split()]

Z = ['1','2','3','4','5','6','7','8']

X = Z[:N]

from itertools import permutations

A=[]
for l in list(permutations(X)):
  a = "".join(l)
  A.append(a)

# print(A)

p = "".join(P)
q = "".join(Q)

a = A.index(p)
b = A.index(q)

print( abs(a-b) )


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

int main() {
	int d, g; cin >> d >> g;
	int p[11], c[11]; for (int i = 0; i < d; i++)cin >> p[i] >> c[i];

	int ans = 1e10;
	for (int b = 0; b < (1 << d); b++) {
		int s0 = 0, cnt = 0, rest = -1;
		for (int i = 0; i < d; i++) {
			if (b >> i & 1) {
				s0 += 100 * (i + 1) * p[i] + c[i];
				cnt += p[i];
			}
			else rest = i;
		}
		if (s0 < g) {
			int s1 = 100 * (rest + 1);
			int need = (g - s0 + s1 - 1) / s1;
			if (need >= p[rest])continue;
			cnt += need;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;

	return 0;
}

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

const int N = 1e5 + 9;

using ll = long long;
int A[N], n;
ll f[N][3];
bool o[N];
char s;

int pd (int a, bool o) { return o ? a : -a; }

int main () {
	scanf("%d", &n);
	for (int i = o[1] = 1; i <= n; ++i) {
		if (i > 1) scanf("%s", &s), o[i] = s == '+' ? 1 : 0;
		scanf("%d", &A[i]);
	}
	f[0][1] = f[0][2] = -0x3f3f3f3f3f3f3f3f;
	for (int i = 1; i <= n; ++i) {
		f[i][2] = f[i - 1][2];
		for (int j = 0; j < 2; ++j) f[i][j] = max(f[i - 1][j], f[i - 1][j + 1]);
		for (int j = 0; j < 3; ++j) f[i][j] += ((o[i] ^ (j & 1)) ? A[i] : -A[i]);
		if (!o[i]) for (int j = 2; j; --j) f[i][j] = max(f[i][j - 1], f[i][j]);
	}
	printf("%lld\n", max(f[n][0], max(f[n][1], f[n][2])));
	return 0;
}

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

const double PI=acos(-1.0);

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

    int cnt = 0;
    for(int i = 0; i <= a; i++) {
        for(int j = 0; j <= b; j++) {
            for(int k = 0; k <= c; k++) {
                int val = (500 * i + 100 * j + 50 * k);
                //cout << val << endl;
                if(x == val) cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        aa: [isize; n],
        q: usize,
        bc: [(isize, isize); q],
    }

    let mut map = HashMap::new();

    let mut sum = aa.iter().copied().sum::<isize>();

    for a in aa {
        *map.entry(a).or_insert(0) += 1;
    }
    
    for (b, c) in bc {
        let count = if let Some(count) = map.get_mut(&b) {
            let ret = *count;
            sum += (c - b) * ret;
            *count = 0;
            ret
        } else {
            0
        };
        
        *map.entry(c).or_insert(0) += count;
        println!("{}", sum);
    }
}

Measured memory_bytes: 9552
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013


int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		int n;
		cin>>n;
		int a[n];
		vector<int> m(1000006);
		fi(0,n) 
		{
			cin>>a[i];
			m[a[i]]++;
		}
		bool pw=true;
		for(ll i=2;i<=1000005;i++)
		{
			int count=0;
			for(ll j=i;j<=1000005;j+=i)
			{
				count+=m[j];
			}
			if(count>1)
			{
				pw=false;
				break;
			}
		}
		if(pw)
		{
			cout<<"pairwise coprime\n";
			return 0;
		}
		
		int temp=a[0];
		fi(1,n)
		{
			temp=__gcd(temp,a[i]);
		}
		if(temp==1)
		{
			cout<<"setwise coprime\n";
		}
		else
		{
			cout<<"not coprime\n";
		}
		
		
	}
}


Measured memory_bytes: 11040
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
# import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)
def IF(c, t, f): return t if c else f


class Flow():
    def __init__(self, e, N):
        self.E = e
        self.N = N
        self.nl = list(range(N))

    def max_flow(self, s, t):
        r = 0
        e = self.E
        v = None

        def f(c):
            v[c] = 1
            if c == t:
                return 1
            for i in e[c]:
                if v[i] is None and f(i):
                    e[c].remove(i)
                    e[i].add(c)
                    return 1
            return

        while True:
            v = [None] * self.N
            if f(s) is None:
                break
            r += 1

        return r


def main():
    n,m = LI()
    sa = [S() for _ in range(n)]

    e = collections.defaultdict(set)
    s = n*m
    t = n*m + 1
    for i in range(n):
        for j in range(m):
            if sa[i][j] == '#':
                continue

            ij = i*m+j
            if (i+j) % 2 == 1:
                e[ij].add(t)
                continue

            e[s].add(ij)
            for di,dj in dd:
                ni = i + di
                nj = j + dj
                if ni < 0 or ni >= n or nj < 0 or nj >= m or sa[ni][nj] == '#':
                    continue
                e[ij].add(ni*m+nj)

    fl = Flow(e, n*m+2)
    r = fl.max_flow(s,t)
    ra = [[c for c in s] for s in sa]
    for i in range(n):
        for j in range(m):
            ij = i*m+j
            if sa[i][j] == '#' or (i+j) % 2 == 1 or ij in e[s]:
                continue

            ni = nj = 0
            for di, dj in dd:
                ni = i + di
                nj = j + dj
                if ni < 0 or ni >= n or nj < 0 or nj >= m or sa[ni][nj] == '#':
                    continue

                if ni*m+nj not in e[ij]:
                    break

            if ni < i:
                ra[ni][j] = 'v'
                ra[i][j] = '^'
            elif ni > i:
                ra[i][j] = 'v'
                ra[ni][j] = '^'
            elif nj < j:
                ra[i][nj] = '>'
                ra[i][j] = '<'
            else:
                ra[i][j] = '>'
                ra[i][nj] = '<'

    return f"{r}\n" + JAA(ra, "\n", "")


print(main())




Measured memory_bytes: 23340
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		StringBuilder sb = new StringBuilder();
		sb.append(s.charAt(0)).append(s.length() - 2).append(s.charAt(s.length() - 1));
		System.out.println(sb);
	}
}


Measured memory_bytes: 21844
#include <iostream>

using lint = long long;
constexpr lint INF = 1000000000000000000LL;

void solve() {
    int n;
    std::cin >> n;

    lint ans = 1;
    while (n--) {
        lint a;
        std::cin >> a;

        if (a != 0 && ans > (INF * 2) / a) {
            ans = INF + 1;
        } else {
            ans = std::min(ans * a, INF + 1);
        }
    }

    std::cout << (ans > INF ? -1 : ans) << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3692
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if b==a: print('YES');exit()
if v-w<=0:print('NO');exit()
dist = abs(b-a)
velocity = v-w
if dist/velocity <=t:print('YES')
else: print('NO')



Measured memory_bytes: 61656
#include <iostream>
using namespace std;
int main(void){
    long N,x,ans=0;
    cin>>N>>x;
    long a[N];
    for(long i=0;i<N;i++){
        cin>>a[i];
    }
    long b[N-1];
    for(long i=0;i<N-1;i++){
        b[i]=a[i]+a[i+1];
        if(b[i]>x){
            if(b[i]-x>a[i+1]){
                a[i+1]=0; a[i]=a[i]-(b[i]-x-a[i+1]);
                ans=ans+b[i]-x;
            }else{
                a[i+1]=a[i+1]-(b[i]-x);
                ans=ans+b[i]-x;
            }
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#define p(n) pow(n,2)
using namespace std;
int main(){
  int n,a,b;
  vector<int> v;
  bool f;
  v.push_back(2);
  for(int i=3;i<=50000;i+=2){
    f = true;
    for(int j=0;pow(v[j],2)<=i;j++){
	if(!(i%v[j])){f=false;break;}
    }
    if(f)v.push_back(i);
  }
  v.push_back(50021);
  while(cin>>n){
    if(cin.eof())return 0;
    vector<int>::iterator it = v.begin();
    while(it!=v.end()){
      if(n<*it){
	a=(n==*(it-1))?*(it-2):*(it-1);
	b=*it;
	cout<<a<<" "<<b<<endl;
	break;
      }
      it++;
    }
  }
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a < b) {
        if(b < c) printf("Yes\n");
        else printf("No\n");
    }
    else printf("No\n");
    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ll double
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

int main()
{
    
    Fast;

    ll n,k,ann,i,annn;
    cin>>n>>k;
    ann=0;
    if(n>k)
        ann+=(n-k)/(double)n;
    for(i=0;i<min(n,k);i++)
    {
        if(i!=(k-1))
        {
            long long x=i+1,c=1,j;
            annn=1.000000000000;
            while(x<k)
            {
                c=c*2;
                x=x*2;
            }
            ann+=(double)annn/(n*c);
        }
        else
        {
            ann+=1/(double)n;
        }
    }
    printf("%0.12lf",ann);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll dp[200001][3] = {};
ll dp2[200001][3][3] = {};
int main() {
	bool f = true;
	ll n, a, b; cin >> n >> a >> b;
	if (n >a*b||n<a+b-1) {
		cout << -1 << endl;
	}
	else {
		int rest = n; int now = 0;
		rep1(i, a) {
			if (rest - b >= a - i) {
				now = i * b;
				for (int j = i * b; j > (i - 1)*b; j--) {
					cout << j << " ";
				}
				rest -= b;
			}
			else if (rest == a - i+1) {
				rest--; now++;
				cout << now << " ";
			}
			else {
				int x = rest - (a - i);
				now += x;
				for (int j = now; j > now - x; j--) {
					cout << j << " ";
				}
				rest = a - i;
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
  int n, a;
  priority_queue<long long> nums,t;
  vector<long long> nums_v;
  vector<long long> nums_count(200000,0);
  long long sum=0,ans=0,b=0,now,count=0;;
  scanf("%d",&n);
  rep(i,n){
    scanf("%d",&a);
    nums_v.push_back(a);
    nums.push(a);
  }
  now = nums.top();
  rep(i,n){
    if(nums.top() == now){
      count++;
    }else{
      nums_count.at(now) = count;
      sum += count*(count-1)/2;
      now = nums.top();
      count = 1;
    }
    nums.pop();
  }
  
  nums_count.at(now) = count;
  sum += count*(count-1)/2;
  
  
  rep(i,n){
    b = nums_count.at(nums_v.at(i));
    if(b != 0){
      ans = sum - b + 1;
    }else{
      ans = sum;
    }
    printf("%lld\n",ans);
  }
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 H, W, N; cin >> H >> W >> N;
    i64 M = max(H, W);
    i64 cnt = N / M + (N % M > 0);
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3564
#include<iostream>

using namespace std;

int main()
{
	int a[6];
	int count[4]={};
	for(int i=0;i<6;i++)
	{
		cin >> a[i];
		count[a[i]-1]++;
	}
	int ki=0;
	for(int i=0;i<4;i++)
	{
		if(count[i]%2==1)ki++;
	}

	if(ki>2)cout << "NO" << endl;
	else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define int(x) int x; scanf("%d",&x)
#define input(x) scanf("%d",&x)
#define rep(x,n) for(int x = 0; x < n; x++)
#define _br printf("\n")
#define INF 2000000000

vector<pair<int,int> > PathList[100];
int d[100];
bool complete[100];

void dijkstra(int n,vector<pair<int,int> > PathList[]){
    rep(i,n){
        d[i] = INF;
        complete[i] = false;
    }
    d[0] = 0;
    
    int count = 0;
    
    while (count != n) {
        int mind = INF;
        int mindi = 0;
        rep(i,n){
            if (!complete[i] && d[i] < mind) {
                mind = d[i];
                mindi = i;
            }
        }
        
        complete[mindi] = true;
        count++;
        
        rep(i,PathList[mindi].size()){
            if (PathList[mindi][i].second + d[mindi] < d[PathList[mindi][i].first]) {
                d[PathList[mindi][i].first] = PathList[mindi][i].second + d[mindi];
            }
        }
    }
}


int main(){
    int(n);
    rep(i,n){
        int(k);int(num);
        rep(j,num){
            int(s);int(t);
            PathList[i].push_back(make_pair(s,t));
        }
    }
    
    dijkstra(n,PathList);
    
    rep(i,n){
        printf("%d %d\n",i,d[i]);
    }
    
    return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>

int main(void)
{
	int i=0,count=1;
	char s[4];
	scanf("%s",s);
	for(i;i <= 2;i++)
		{
		if(s[i] == s[i+1])
			{count++;}
		else
			{count=1;}
		if(count == 3)
			{break;}
		}
	if(count == 3)
		{printf("Yes");}
	else
		{printf("No");}
	return 0;
}


Measured memory_bytes: 128
import itertools

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#factorization(24) 

## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1


t=int(input())
if t==1:
  print(0)
  exit()
  
ans=0
x=factorization(t)


z=[i for i in range(51)]
z=list(itertools.accumulate(z))

for i in range(len(x)):
    cnt=x[i][1]
    for j in range(len(z)):
        if z[j]>cnt:
            ans+=j-1
            break

print(ans)


Measured memory_bytes: 63636
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            string s = ReadString();
            Console.WriteLine(Solve(s) ? "Yes" : "No");
        }

        static bool Solve(string s)
        {
            if (s.Length % 2 != 0)
            {
                return false;
            }

            for (int i = 0; i < s.Length / 2; i++)
            {
                if (s.Substring(i * 2, 2) != "hi")
                {
                    return false;
                }
            }

            return true;
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



















int main(){
    ll n, m, q;
    cin >> n >> m >> q;
    vector<ll> a(q), b(q), c(q), d(q);
    REP(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    vector<ll> A(n);
    ll ans = 0;
    [dfs = [&](auto &&dfs, ll now, ll mn) -> void {
        if(now == n){
            ll sum = 0;
            REP(i, q){
                if(A[b[i]] - A[a[i]] == c[i]){
                    sum += d[i];
                }
            }
            ans = max(ans, sum);
            return;
        }
        for(ll i = mn; i <= m; i++){
            A[now] = i;
            dfs(dfs, now + 1, i);
        }
    }](){ dfs(dfs, 0, 1); }();
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define MOD 998244353
#define INF 10000000000000001
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define vc vector
#define vll vector<long long>
#define pll pair<long long,long long> 
#define pb push_back
#define all(v) v.begin(),v.end()
#define T ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define MAX 1000005
#define ll long long
using namespace std;
int main()
{
	ll n,m;
	cin>>n;
	ll ar[n+1]={0};
	rep(i,1,n+1)
	cin>>ar[i];
	vector<ll> v;
	ll c=0;
	rep(i,1,n+1)
	{
		if(ar[i]!=i)
		{
			c++;
			v.pb(ar[i]);
		}
	}
	if(c>2){
	cout<<"NO";
	return 0;
        }
	else if(c==0){
	cout<<"YES";
	return 0;}
	else
	{
		ll temp=ar[v[1]];
		ar[v[1]]=ar[v[0]];
		ar[v[0]]=temp;
		rep(i,1,n+1)
		{
			if(ar[i]!=i)
			{
				cout<<"NO";
				return 0;
			}

		}
		cout<<"YES";
	}
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
	int k;
	cin>>k;
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i!=s.size()-1;++i){
		string a=s.substr(0,i),b=s.substr(i);
		int cur=0;
		set<int> x,y;
		for(auto i:a)
			x.insert(i);
		for(auto i:b)
			y.insert(i);
		for(auto i:x){
			if(y.find(i)!=y.end())
				++cur;
		}
		ans=max(cur,ans);
	}
	cout<<ans;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,z=0;
	cin>>n>>k;
	int f[n+5];
	memset(f,0,sizeof(f));
	int a;
	for(int i=0;i<k;i++)
	{
		int d;
		cin>>d;
		for(int j=0;j<d;j++)
		{
			cin>>a;
			f[a]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(f[i]==0)
		z++;
	}
	cout<<z;
}

Measured memory_bytes: 3620