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

using namespace std;

int ps[100005];
char s[100005];

int main() {
    int n, q;
    scanf("%d%d", &n, &q);

    scanf("%s", s);

    int l = strlen(s);

    for (int i = 1; i < l; i++) {
        if (s[i - 1] == 'A' && s[i] == 'C') ps[i]++;
        ps[i] += ps[i - 1];
    }

    while (q--) {
        int x, y;
        scanf("%d%d", &x, &y);
        x--; y--;

        printf("%d\n", ps[y] - ps[x]);
    }
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

void buildSA(const string& s, VI& sa, VI& rank){
  int N = SZ(s);
  vector<int> tmp(N+1);
  sa.assign(N+1, 0);
  rank.assign(N+1, 0);
  for(int i=0;i<N+1;++i) sa[i] = i, rank[i] = (i < N? s[i]: -1);

  int h;
  auto comp = [&](int x, int y){
	return rank[x]!=rank[y]? rank[x] < rank[y]
	: (x+h<=N?rank[x+h]:-1) < (y+h<=N?rank[y+h]:-1);
  };
  for(h=1;h<=N;h*=2){
	sort(sa.begin(), sa.end(), comp);
	tmp[sa[0]] = 0;
	for(int i=1;i<=N;++i)
	  tmp[sa[i]] = tmp[sa[i-1]] + (comp(sa[i-1], sa[i])?1:0);
	for(int i=0;i<=N;++i)
	  rank[i] = tmp[i];
  }
}

int findSA(const string& t, const string& p, const vector<int>& sa){
  int a = 0, b = SZ(t), m = SZ(p);
  while(a < b) {
    int c = (a + b) / 2;
    if(strncmp(t.c_str()+sa[c], p.c_str(), m) < 0)
	  a = c+1;
	else
	  b = c;
  }
  return strncmp(t.c_str()+sa[a], p.c_str(), m) == 0 ? sa[a] : -1;
}

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

  string text;
  cin >> text;
  VI sa, rank;
  buildSA(text, sa, rank);
  
  int Q; cin >> Q;
  while(Q--){
	string p;
	cin >> p;
	cout << (findSA(text, p, sa) != -1) << endl;
  }

  return 0;
}

Measured memory_bytes: 15796
#include<stdio.h>

int main(){
    int A,B,i=1,temp,flg=1;

    scanf("%d",&A);
    scanf("%d",&B);
    temp=A-1;
    if(B==1){
        i=0;
        flg=0;
    }
    while(A<B && flg==1){
        A+=temp;
        i++;
    }
    printf("%d\n",i);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;


int main()
{
    double l;
   cin>>l;

   
   double a= l/3;

  double b= (a*a)*(a);

  cout << fixed << setprecision(12) << b;
 
return 0;
}

    
  

   


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

int main(){
	string s;
	cin >> s;
	int ans=0;
	if(s == "SUN"){ ans = 7;
	}else if(s == "MON"){ans = 6;
	}else if(s == "TUE"){ans = 5;
	}else if(s == "WED"){ans = 4;
	}else if(s == "THU"){ans = 3;
	}else if(s == "FRI"){ans = 2;
	}else if(s == "SAT"){ans = 1;}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

ll x1[60], x2[60];
ll ya1[60], y2[60];
ll z1[60], z2[60];
vector<ll>xs, ys, zs;
ll zaatu(int n,int k) {
	ll ans = 0;
	for (int x = 0; x < xs.size() - 1; x++) {
		for (int y = 0; y < ys.size() - 1; y++) {
			for (int z = 0; z < zs.size() - 1; z++) {
				ll c = 0;

				for (int i = 0; i < n; i++) {
					if (x1[i] <= xs[x] && xs[x + 1] <= x2[i] &&
						ya1[i] <= ys[y] && ys[y + 1] <= y2[i] &&
						z1[i] <= zs[z] && zs[z + 1] <= z2[i]) {
						c++;
					}
				}

				if (c >= k) {
					ans += (xs[x + 1] - xs[x])*(ys[y + 1] - ys[y])*(zs[z + 1] - zs[z]);
				}
			}
		}
	}
	return ans;
}

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x1[i] >> ya1[i] >> z1[i] >> x2[i] >> y2[i] >> z2[i];
	}
	for (int i = 0; i < n; i++) {
		xs.push_back(x1[i]);
		xs.push_back(x2[i]);
		ys.push_back(ya1[i]);
		ys.push_back(y2[i]);
		zs.push_back(z1[i]);
		zs.push_back(z2[i]);
	}
	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());
	sort(zs.begin(), zs.end());
	cout << zaatu(n, k) << endl;
	return 0;
}

Measured memory_bytes: 3160
d,g = map(int,input().split())
P,C = [0]*d,[0]*d
for i in range(d): P[i],C[i] = map(int,input().split())
ans = 10**9
for bin in range(0, 1<<d):
    cnt = tot = 0
    rest_max_bit = -1
    for i in range(d):
        if bin & 1<<i:
            t = (i+1)*100
            tot += P[i]*t + C[i]
            cnt += P[i]
        else: rest_max_bit = i
    if tot < g:
        t = (rest_max_bit + 1)*100
        p = (g - tot + t - 1)//t
        if p >= P[rest_max_bit]: continue
        cnt += p
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h> 
#define ll long long int
#define ld long double
#define maxim (ll)1000000000000
#define PB push_back
#define MP make_pair
using namespace std;
bool sortbysecond(const pair<ll,ll> &a,const pair<ll,ll> &b)
{ 
if(a.second<b.second)
return true;
else
 return false;
}
int main()
{

ios::sync_with_stdio(0);
cin.tie(0);
ll t=1;
//cin>>t;
while(t--)
{
 ll n,a;
 cin>>n;
 vector<pair<ll,ll> > vp;
 for(ll i=1;i<=n;i++){
  cin>>a;
  vp.PB(MP(i,a));
 }
 sort(vp.begin(),vp.end(),sortbysecond);
 for(ll i=0;i<n;i++)
  cout<<vp[i].first<<" ";
 cout<<endl;
}
return 0;
}

Measured memory_bytes: 3444
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
$i=1;
$s=(int)$a[0];
while($i<$n){
  $s^=$a[$i];
  ++$i;
}
$i=0;
while($i<$n){
  if($i>0){
    echo " ";
  }
  echo $s ^ $a[$i];
  ++$i;
}

Measured memory_bytes: 31856
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()
n, m = [int(i) for i in input().split()]
e = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)
dp1 = [0] * n


def dfs1(i=0, r=-1):
    s = 1
    for j in e[i]:
        if j != r:
            s *= dfs1(j, i)
            s %= m
    dp1[i] = s
    return s + 1


dfs1()
dp2 = [0] * n
dp2[0] = dp1[0]


def dfs2(i=0, r=-1, s=1):
    a = [1]
    for j in e[i]:
        if j != r:
            a.append(a[-1] * (dp1[j]+1) % m)
    b = [1]
    for j in reversed(e[i]):
        if j != r:
            b.append(b[-1] * (dp1[j]+1) % m)
    b.reverse()

    k = 0
    for j in e[i]:
        if j != r:
            l = (a[k] * b[k + 1] * s + 1)%m
            dp2[j] = l * dp1[j] % m
            dfs2(j, i, l)
            k += 1


dfs2()
print("\n".join(map(str,dp2)))


Measured memory_bytes: 133752
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF= 1e18L+5;

int main() {
	string s1,s2;
	cin >> s1>>s2;
	int n = s1.length(),m = s2.length();
	vector<vector<int>>	dp(n+1,vector<int>(m+1,0));
	for(int i=0; i<=n; i++){
		for(int j=0; j<=m; j++){
			if((i<n&&j<m)&&s1[i]==s2[j]){
				dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j+1]);
			}
			if(i<n)
				dp[i+1][j] = max(dp[i][j],dp[i+1][j]);
			if(j<m)
				dp[i][j+1] = max(dp[i][j],dp[i][j+1]);
		}
	}
	string ans;
	int i=n,j=m;
	
	while(i>0&&j>0){
		if(s1[i-1]==s2[j-1]){
			ans = s1[i-1]+ans;
			i = i-1;
			j = j-1;
		}
		else if(dp[i-1][j]>dp[i][j-1]){
			i = i-1;	
		}
		else	j = j-1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 35584
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
from itertools import permutations
from math import factorial
def main():
    n = int(input())
    xy = [tuple(map(int, input().split())) for _ in range(n)]

    # 町同士の距離をxydisにいれる
    xydis = [[0] * n for _ in range(n)]
    for i1 in range(n):
        for i2 in range(n):
            xydis[i1][i2] = ((xy[i1][0] - xy[i2][0])**2 + (xy[i1][1] - xy[i2][1])**2)**0.5
    # 組み合わせごとの距離をdis_sumに足す。
    per = tuple(permutations(range(n), n))
    dis_sum = 0
    for pere in per:
        for j1 in range(n - 1):
            dis_sum += xydis[pere[j1]][pere[j1 + 1]]
    ans = dis_sum / factorial(n)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14140
#include <iostream>
using namespace std;
 
int main() {
  
    char c;
    cin >> c;
    
    if( c == 'a'){
        cout << "vowel" <<endl;
    }
    else if( c == 'i'){
        cout << "vowel" <<endl;
    }
    else if( c == 'u'){
        cout << "vowel" <<endl;
    }
    else if( c == 'e'){
        cout << "vowel" <<endl;
    }
    else if( c == 'o'){
        cout << "vowel" <<endl;
    }
    else {
        cout << "consonant" <<endl;
    }
    
}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
$v = gets.split.map(&:to_i)
ans = 0

def calc(l, r, k, n)
    k -= (l + r)
    return -1 if k < 0 || (l + r) > n
    tmp = ($v[0, l] + $v[-r, r]).sort
    k = [k, tmp.size].min
    res = 0
    tmp.each { |x| res += x }
    k.times do |i|
        res -= tmp[i] if tmp[i] < 0
    end
    res
end

(0..k).each do |l|
    (0..k).each do |r|
        ans = [ans, calc(l, r, k, n)].max
    end
end

puts ans

Measured memory_bytes: 1916
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long array[] = new long[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextLong();
        }

        long money = 1000;
        long stock = 0;

        long min = array[0];

        for (int i = 1; i < n; i++) {
            if (array[i] > array[i - 1]) {
                stock = money / min;
                money = money % min;

                money += stock * array[i];
                stock = 0;

                min = array[i];
            }

            if (min > array[i]) {
                min = array[i];
            }
        }

        System.out.println(money);

        sc.close();

        }

    }



Measured memory_bytes: 35728
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
ans = 0
MOD = 10**9+7

for i in range(65):
    one = 0
    zero = 0
    
    for j in range(N):
        if (A[j]>>i)&1:
            one += 1
        else:
            zero += 1
    
    ans += one*zero*pow(2, i, MOD)
    ans %= MOD

print(ans)

Measured memory_bytes: 123132
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
    string s;
    cin >> s;
    if(s.size()<4)cout << "No" << endl;
    else{
        bool a=true;
        if(s.at(0)!='Y')a=false;
        if(s.at(1)!='A')a=false;
        if(s.at(2)!='K')a=false;
        if(s.at(3)!='I')a=false;
        if(a)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
}


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

// 3101
public class Main {

    List<Integer> a = new ArrayList<>();


	// メイン return falseでおしまい
	boolean main() throws IOException {

	    int N = readIntArray()[0];
        String S = reader.readLine();

//		if (N == 0)
//			return false; /* おしまい */

        int north = 0;
        int east = 0;
		for(int i = 0; i < N; i++) {
		    int c = S.charAt(i);
		    if ('A' <= c && c <= 'M') {
		        north++;
		    }
		    else if ('N' <= c && c <= 'Z') {
                north--;
            }
		    else if ('a' <= c && c <= 'm') {
                east++;
            }
            else if ('n' <= c && c <= 'z') {
                east--;
            }
		}
		String r = "";
		for(int i = 0; i< Math.abs(north); i++) {
		    if (north > 0) {
		        r += "A";
		    }
		    else {
                r += "N";
		    }
		}
        for(int i = 0; i< Math.abs(east); i++) {
            if (east > 0) {
                r += "a";
            }
            else {
                r += "n";
            }
        }



		System.out.printf("%d\n%s\n", r.length(), r);

		//return true; /* 正常終了 次へ */
		return false;
	}


//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;

			String inputStr = "5\r\n" + 
			        "xUkad\n";
//			String inputStr = "4\n0 0 10 0 10 10 0 10\n10\n12\n0 0\n9 1\n0\n"; // 96.63324958071081
//			String inputStr = "4\n0 0 10 0 10 10 0 10\n10\n12\n0 1\n9 1\n0\n"; // 103.2664991614216
//			String inputStr = "8\n2 0 4 0 6 2 6 4 4 6 2 6 0 4 0 2\n10\n12\n3 0\n3 5\n0\n"; // 60.0

			reader = new BufferedReader(new StringReader(inputStr));

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // 書き捨て
			reader = new BufferedReader(new InputStreamReader(System.in)); // コンソールから
		}

		for(int loop = 0;; loop++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}

		reader.close();
	}


	static PrintStream log;
	static BufferedReader reader;


	// 標準入力より　1行分のスペース区切りの整数値を読む
	private int[] readIntArray() throws IOException {

		String s = reader.readLine();
		String[] sp = s.split(" ");
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}

}





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

#define M 100000
int main(){
  int n,a[M],i;
  int c=0;
  cin>>n;
  cin>>a[0];
  for(i=1;i<n;i++){
    cin>>a[i];
    if(a[i]<a[i-1])c++;
    if(a[i]==a[i-1])c++;
  }
  cout<<++c<<endl<<n<<endl;
  return 0;
}



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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-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 X;

int pow5(int x){
    return x*x*x*x*x;
}

signed main(){
    cin>>X;
    for(int A=-1000;A<=1000;++A){
        for(int B=-1000;B<=1000;++B){
            if(pow5(A)-pow5(B)==X){
                cout<<A<<" "<<B<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3584
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
#define ll long long int
using namespace std;

int i, n, x, mx = -1, mn = 1001;

int main()
{
    sf("%d", &n);
    for (i = 0; i < n; i++) {
        sf("%d", &x);
        if (x > mx) mx = x;
        if (x < mn) mn = x;
    }
    pf("%d\n", mx-mn);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int count=0;
        for(int m=1;m<=a; m++) {
        	if(m==a) {
        		for(int y=1;y<=b; y++) {
        			if(m==y) {
        				count++;
        			}
        		}
        	}else {
        		for(int y2=1;y2<=31;y2++) {
        			if(a==y2) {
        				count++;
        			}
        		}
        	}
        }
        System.out.println(count);
	}

}

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

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

    int kyu = 8;
    for (size_t i = 400;; i += 200) {
        if (i <= x && x < i + 200) {
            cout << kyu << endl;
            return 0;
        }
        kyu--;
    }
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int N, T;
	int ans_idx = -1;
	int ans_c = 100000;
	cin >> N >> T;

	vector<int> c(N), t(N);
	for (int i = 0; i < N; i++)
	{
		int c, t;
		cin >> c >> t;

		if (t <= T && c < ans_c)
		{
			ans_c = c;
			ans_idx = i;
		}
	}

	if (ans_idx == -1)
	{
		cout << "TLE" << endl;
	}
	else
	{
		cout << ans_c << endl;
	}

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);

  for(int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  
  double ans = v.at(0);
  for(int i = 1; i <  n; i++) ans = (ans+v.at(i))/2;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
 
#define mem0(x) memset(x, 0, sizeof(x))
#define asort(x) sort(x.begin(), x.end());
#define dsort(x, t) sort(x.begin(), a.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
 
int main() {
    ll N, K, cnt;
    cnt = 0;
    cin >> N >> K;
    while(N > 0) {
        N /= K;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int m;
const int mmax=1e5+8;
long long d,c;
long long ans,sum;
int main(){
	cin>>m;
	for(int i=1;i<=m;i++){
		cin>>d>>c;
		sum+=d*c;
		ans+=c;
	}
	ans--;
	sum--;
	sum/=9;
	cout<<ans+sum;
	return 0;
} 

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

std::vector<bool> get_prime_table(int n) {
    std::vector<bool> ret(n + 1, true);
    if (n >= 0) { ret[0] = false; }
    if (n >= 1) { ret[1] = false; }
    for (int i = 2; i * i <= n; i++) {
        if (!ret[i]) { continue; }
        for (int j = i + i; j <= n; j += i) {
            ret[j] = false;
        }
    }
    return ret;
}
int X;
signed main() {
    cin >> X;
    vector<bool> a = get_prime_table(200000);
    while (true) {
        if (a[X]) { fin(X); }
        X++;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 101
#define MAX_M 101
#define rep(i, n) for(int i=0; i<n; i++)
int max_x, min_y, x, y, N, M;
int main(void){
	cin >> N >> M >> max_x >> min_y;
	rep(i, N){
		cin >> x;
		max_x = max(max_x, x);
	}
	rep(i, M){
		cin >> y;
		min_y = min(min_y, y);
	}
	if(max_x < min_y) cout << "No War" << endl;
	else cout << "War" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
int main()
{
	int t;
	vector<int>a;
	cin >> t;
	while (t--)
	{
		int p, q;
		cin >> p;
		if (p != 2)
		{
			cin >> q;
			if (p == 0)
			{
				a.push_back(q);
			}
			if (p == 1)
			{
				cout << a[q] << endl;
			}
		}
		else if (p == 2)
		{
			a.pop_back();//删除末尾的数
		}
	}
}


Measured memory_bytes: 3880
n, q = [ int( val ) for val in raw_input( ).split( " " ) ]
ps = [0]*n
t = [0]*n
for i in range( n ):
    ps[i], t[i] = raw_input( ).split( " " )
 
 
output = []
qsum = 0
while t:
    psi = ps.pop( 0 )
    ti = int( t.pop( 0 ) )
    if ti <= q:
        qsum += ti
        output.append( "".join( ( psi, " ", str( qsum ) ) ) )
    else:
        t.append( ti - q )
        ps.append( psi )
        qsum += q
 
print( "\n".join( output ) )

Measured memory_bytes: 11516
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    string S;
    cin >> S;
    if (S == "ABC") {
        cout << "ARC\n";
    } else {
        cout << "ABC\n";
    }
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;

public static class Program
{
    public static void Main(string[] args)
    {
        var s = Console.ReadLine().Select(x => x.ToString()).ToArray();
        string[] vals = { "A", "C", "G", "T" };
        var result = 0;
        var cnt = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (vals.Contains(s[i]))
                cnt++;
            else
            {
                result = cnt > result ? cnt : result;
                cnt = 0;
            }
        }
        result = cnt > result ? cnt : result;
        Console.WriteLine(result);
    }
}

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

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

using namespace std;
using ll = long long;

int main(void) {
  int v[3][3];
  rep(i, 3) {
    rep(j, 3) {
      cin >> v[i][j];
    }
  }
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) {
    cin >> vec[i];
  }
  rep(i, n) {
    int num = vec[i];
    rep(j, 3) {
      rep(k, 3) {
        if (v[j][k] == num) {
          v[j][k] = -1;
        }
      }
    }
  }
  bool f;
  rep(i, 3) {
    f = true;
    rep(j, 3) {
      if (v[i][j] != -1) {
        f = false;
      }
    }
    if (f) {
      fin("Yes");
      return 0;
    }
  }
  rep(i, 3) {
    f = true;
    rep(j, 3) {
      if (v[j][i] != -1) {
        f = false;
      }
    }
    if (f) {
      fin("Yes");
      return 0;
    }
  }
  f = true;
  rep(i, 3) {
    if (v[i][i] != -1) {
      f= false;
    }
  }
  if (f) {
    fin("Yes")
    return 0;
  }  
  if (v[0][2] == v[1][1] && v[1][1] == v[2][0] && v[0][2] == -1) {
    fin("Yes");
    return 0;
  }
  fin("No");
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
dp = [[0] * 21 for i in range(n - 1)]
dp[0][a[0]] = 1
for i in range(1, n - 1):
    for j in range(21):
        if 0 <= j + a[i] <= 20:
            dp[i][j] += dp[i - 1][j + a[i]]
        if 0 <= j - a[i] <= 20:
            dp[i][j] += dp[i - 1][j - a[i]]
print(dp[n - 2][a[n - 1]])

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


int main() {
  int N,K;
  string S;
  cin >> N >> K;
  cin >> S;
  S[K-1] -= 'A' - 'a';
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
struct circle{
	ld x, y, r;
};
ld dist(circle a, circle b){
	return max((ld) 0.0, sqrt(((b.x - a.x) * (b.x - a.x)) + ((b.y - a.y) * (b.y - a.y))) - b.r - a.r);
}
circle c[1005];
ld INF = 1e18;
ld d[1005][1005];
ll n;
bool sptset[2005];
ld rd[1005];
ll mindis(){
	ld mn = INF + 1, mdex;
	for (ll v = 0; v <= n + 1; v++){
		if ((sptset[v] == 0) && (rd[v] <= mn)){
			mn = rd[v]; mdex = v;
		}
	}
	return mdex;
} 
void dijkstra(ll src){
	for (ll i = 0; i <= n + 1; i++) rd[i] = INF;
	rd[src] = 0;
	for (ll cnt = 0; cnt <= n; cnt++){
		ll u = mindis(); sptset[u] = 1;
		for (ll v = 0; v <= n + 1; v++){
			if (!sptset[v] && rd[u] != INF && rd[u] + d[u][v] < rd[v]) rd[v] = rd[u] + d[u][v];
		}
	}
}
int main(){
	fastio;
	cout << fixed << setprecision(12);
	ld xs, ys; cin >> xs >> ys;
	circle s; s.r = 0; s.x = xs; s.y = ys; 
	ld xe, ye; cin >> xe >> ye;
	circle e; e.r = 0; e.x = xe; e.y = ye; 
	cin >> n;
	c[0] = s; c[n + 1] = e;
	for (ll i = 1; i <= n; i++) cin >> c[i].x >> c[i].y >> c[i].r;
	for (ll i = 0; i <= n + 1; i++){
		for (ll j = i + 1; j <= n + 1; j++) d[i][j] = dist(c[i], c[j]);
		d[i][i] = 0;
		for (ll j = 0; j < i; j++) d[i][j] = d[j][i];
 	}
 	dijkstra(0);
	cout << rd[n + 1] << endl;
}

Measured memory_bytes: 19640
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int H, W, K;
  int S[10][SIZE];

  scanf("%d%d%d", &H, &W, &K);

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      scanf("%1d", S[i] + j);
    }
  }

  int ans = INF;

  for (int i = 0; i < (1 << H); i++) {
    int bits[10], sum[10] = {};
    int counter = 0;

    for (int j = 0; j < H; j++) bits[j] = (i >> j) & 1;
    for (int j = 1; j < H; j++) counter += bits[j - 1] != bits[j];

    for (int j = 0; j < W; j++) {
      int index = 0, tmp[10] = {};
      bool ng1 = false, ng2 = false;
      for (int k = 0; k < H; k++) {
        if (k && bits[k - 1] != bits[k]) index++;
        tmp[index] += S[k][j];
        ng1 |= tmp[index] > K;
        ng2 |= sum[index] + tmp[index] > K;
      }

      if (ng1) {
        counter = INF;
        break;
      }

      if (ng2) {
        counter++;
        for (int k = 0; k < H; k++) sum[k] = 0;
      }
      for (int k = 0; k < H; k++) sum[k] += tmp[k];
    }

    debug(counter);
    ans = min(ans, counter);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,q;
	cin>>n>>k>>q;
	int i,j,b[n];
	
	fill_n(b,n,k-q);
	for(i=0;i<q;i++)
	{ 
	int a;
		cin>>a;
		b[a-1]++;
	}
	
	for(i=0;i<n;i++)
	{
		if(b[i]<=0)
		{
			cout<<"No"<<endl;
		}
		else
		{
			cout<<"Yes"<<endl;
		}
	}

}

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

#define ll long long 
#define pll pair<ll,ll> 

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string s, t;
	cin>>s>>t;
	ll ans=INT_MAX;
	for(ll i=0;i+t.size()-1<s.size();i++){
		ll c=0;
		for(ll j=0;j<t.size();j++){
			c+=s[i+j]!=t[j];
		}
		ans=min(ans, c);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define INF 100000000

const int MOD = 1e9+7;
typedef long long ll;
using namespace std;
const ll M = 998244353;


int main(void) {
	int n;
	cin >> n;
	ll sum =0;
	for(int i=1;i<n+1;i++) {
	    if(i%3 == 0 || i%5==0) continue;
	    sum += i;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int s1[301][301];
int s2[301][301];
int vis[301][301];

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string str;
		cin>>str;
		for(int j=0;j<n;j++){
			s1[i][j]=str[j]-'a';
		}
	}
	int ans=0;
	for(int a=0;a<n;a++){
		for(int b=0;b<n;b++){
			if(vis[a][b]==1)
				continue;
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					s2[(i+a)%n][(j+b)%n]=s1[i][j];
				}
			}
			int flag=0;
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(s2[i][j]!=s2[j][i])
						flag=1;
				}
			}
			if(flag==0)
				ans+=n;
			for(int i=0;i<n;i++){
				vis[(a+i)%n][(b+i)%n]=1;
			}
		}
	}
	cout<<ans;

}

Measured memory_bytes: 1280
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/

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

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

int main() {
ll A,B,C,D;
cin>>A>>B>>C>>D;
ll ans=0;
ans+=B-A+1;
ans-=B/C-(A-1)/C+B/D-(A-1)/D;
ans+=B/LCM(C,D)-(A-1)/LCM(C,D);
cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 3636
<?php

$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$b = explode(" ", trim(fgets(STDIN)));

$sumA = 0;
foreach($a as $val) {
    $sumA += $val;
}
$sumB = 0;
foreach($b as $val) {
    $sumB += $val;
}

if ($sumA < $sumB) {
    echo "-1";
    exit;
}

$lessThanNum = 0;
$differenceMinusSum = 0;
$differencePlusArr = [];
for($i = 0; $i < $n; $i++){
    if ($a[$i] < $b[$i]) {
        $lessThanNum++;
        $differenceMinusSum += ($b[$i] - $a[$i]);
    } else {
        $differencePlusArr[$i] = $a[$i] - $b[$i];
    }
}

$echoNum = $lessThanNum;

if ($echoNum == 0){
    echo $echoNum;
    exit;
}

rsort($differencePlusArr);

foreach ($differencePlusArr as $val){
    $echoNum++;
    if($val >= $differenceMinusSum) {
        break;
    }else{
        $differenceMinusSum -= $val;
    }
}

echo $echoNum;
exit;

Measured memory_bytes: 27120
#include <iostream>
#include <string>

using namespace std;

int N;
string S;
int Q;
int k[100];

long long int dpd;
long long int dpm;
long long int dp;

int main(void) {

	cin >> N >> S >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> k[i];
	}

	long long int ans = 0;

	for (int q = 0; q < Q; q++) {
		int K = k[q];
		dpd = 0; dpm = 0; dp = 0;  ans = 0;

		for (int i = 0; i <= N - 1; i++) {
		//	cout << S[i] << endl;
			if (S[i] == 'D') { dpd++; }
			else if (S[i] == 'M') { dpm++;
			dp += dpd;
			}
			else if(S[i]=='C') {
				ans += dp;
			}

			//cout << "dpd= " << dpd << "  dpm= " << dpm << "  dp= " << dp << endl;
			if (i-K+1>=0 && S[i - K + 1] == 'D') {
				dpd--;
				dp -= dpm;
			}
			else if (i - K + 1 >= 0 && S[i - K + 1] == 'M') {
				dpm--;
			}

		}
		cout << ans << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll N;
  cin >>N;
  string str[N];
  long num[N];
  for(long i=0;i<N;i++){
  cin>>str[i]>>num[i];
  }
  string X;
  cin>>X;
  
  long ans=0;
  long a=0;
  
  for(long i=0;i<N;i++){
      if(ans==1){a=a+num[i];}
  if(str[i]==X){ans=1;}

  }
  
  
   cout << a<< endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine(
            n / 10 == 9 || n % 10 == 9 ?
            "Yes" : "No");
    }
}


Measured memory_bytes: 11092
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    auto A = aryread();
    long[9] B;
    foreach (a; A)
    {
        B[min(8, a / 400)]++;
    }
    // writeln(B);
    if (B[8])
    {
        long l = B[0 .. $ - 1].map!(x => !!x).sum();
        long g = l + min(N - l, B[8]);
        writefln("%d %d", max(l, 1), g);
    }
    else
    {
        long ans = B.dup.map!(x => !!x).sum();
        writefln("%d %d", ans, ans);
    }
}


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

int main()
{
  int b, f, r, v, n;
  int count[4][3][10];
  string line = "####################";
  cin >> n;
  for (int i = 0; i < 4; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 10; k++)
      {
        count[i][j][k] = 0;
      }
    }
  }
  for (int i = 0; i < n; i++)
  {
    cin >> b >> f >> r >> v;
    count[b - 1][f - 1][r - 1] += v;
  }
  for (int i = 0; i < 4; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 10; k++)
      {
        cout << " " << count[i][j][k];
      }
      cout << endl;
    }
    if (i != 3)
    {
      cout << line << endl;
    }
  }
}


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


vector<vector<int>> edge, b_edge;

vector<vector<int>> scc, scc_e;
vector<int> belong;
vector<int> postorder;
vector<bool> visited;

void dfs_1(int now) {
    visited[now] = true;
    for (int nxt : edge[now]) {
        if (!visited[nxt]) {
            dfs_1(nxt);
        }
    }
    postorder.push_back(now);
    return;
}

void dfs_2(int now, int num) {
    visited[now] = true;
    scc[num].push_back(now);
    belong[now] = num;
    
    for (int nxt : b_edge[now]) {
        if (!visited[nxt]) {
            dfs_2(nxt, num);
        }
    }
    return;
}

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    edge.resize(N+1);
    b_edge.resize(N+1);
    visited.resize(N+1, false);
    belong.resize(N+1);
    
    for (int i = 0; i < N; i++) {
        edge[N].push_back(i);
        b_edge[i].push_back(N);
    }
    for (int i = 0; i < M; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        edge[a].push_back(b);
        b_edge[b].push_back(a);
    }
    
    dfs_1(N);
    visited = vector<bool>(N+1, false);
    int num = 0;
    for (int i = N; i >= 0; i--) {
        if (visited[postorder[i]]) continue;
        scc.push_back({});
        dfs_2(postorder[i], num);
        num++;
    }
    
    scc_e.resize((int)scc.size());
    for (int i = 0; i <= N; i++) {
        for (int j : edge[i]) {
            if (belong[i] == belong[j]) continue;
            scc_e[belong[i]].push_back(belong[j]);
        }
    }
    for (int i = 0; i < (int)scc_e.size(); i++) {
        sort(scc_e[i].begin(), scc_e[i].end());
        scc_e[i].erase(unique(scc_e[i].begin(), scc_e[i].end()), scc_e[i].end());
    }
    
    
    int V = scc.size();
    printf("%d\n", V-1);
    for (int i = 1; i < V; i++) {
        printf("%d", (int)scc[i].size());
        for (int v : scc[i]) printf(" %d", v);
        printf("\n");
    }
    
    return 0;
}


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

template <typename T>
using lim = numeric_limits<T>;

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

	string s;
	cin >> s;
	cout << (s.find("7") != string::npos ? "Yes" : "No") << "\n";
}

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

using Graph = vector<vector<int>>;
int N, Q;
Graph G;

void dfs(int v, int p, vector<long long> &res) {
  if (p != -1) res[v] += res[p];
  for (auto e : G[v]) {
    if (e == p) continue;
    dfs(e, v, res);
  }
}

int main() {
  cin >> N >> Q;
  G.assign(N, vector<int>());
  for (int i = 0; i < N-1; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<long long> val(N, 0);
  for (int i = 0; i < Q; ++i) {
    int p, x;
    cin >> p >> x;
    --p;
    val[p] += x;
  }
  dfs(0, -1, val);
  for (auto v : val) cout << v << " ";
  cout << endl;
}

Measured memory_bytes: 25172
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n, h;
    readf("%s %s", &n, &h);
    readln;
    
    auto ans = readln.chomp.split.map!(to!int).count!(x => x >= h);
    
    ans.writeln;
}

Measured memory_bytes: 4232
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

using std::string;
using std::cin;
using std::cout;
typedef long long ll;
using std::vector;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////



//////////////////////////////////////

int main() {
    
    int N, M;
    cin >> N >> M;
    std::priority_queue<ll, vector<ll>, std::greater<ll>> A;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        A.push(a);
    }
    using P = std::pair<ll, ll>;
    vector<P> BC;
    for (int i = 0; i < M; i++) {
        ll b, c;
        cin >> b >> c;
        BC.push_back(std::make_pair(b, c));
    }
    std::sort(BC.begin(), BC.end(),
              [](const P &x, const P &y) { return x.second > y.second;});
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < BC[i].first; j++) {
            if (A.top() < BC[i].second) {
                A.pop();
                A.push(BC[i].second);
            } else {
                break;
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += A.top();
        A.pop();
    }
    cout << ans << std::endl;
    
    return 0;
}



Measured memory_bytes: 3188
#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 <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#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 <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
  long long  n,s=0;
  cin >> n;
  for(long long i=0; i<sqrt(n*2); i++){
    s++;
    if(s*(s+1)/2>=n){break;}
  }
  cout << s << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>
#include<bitset>
typedef long long ll;

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define MOD 1000000007;
using namespace std;
ll n=0,k=0;
int main(){
    cin>>n>>k;
    ll ans1=n%k;
    ll ans2=abs(n%k-k);
    puts(min(ans1,ans2));
}  


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}


int main() {
	int n, m;
	cin >> n >> m;
	int c = 0;
	vector<int> list;
	rep(i, n) {
		int a;
		cin >> a;
		list.push_back(a);
	}
	int sum = accumulate(list.begin(), list.end(), 0);
	rep(i, n) {
		int a = list[i];
		if (a * 4 * m >= sum){
			c++;
		}
	}
	if (c >= m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}



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

signed main(void)
{
	int n;
	int ans, sum;
	cin >> n;
	ans = 1e9;
	rep(i, n)
	{
		int x, y;
		x = i;
		y = n - i;	
		sum = 0;
		while(x)
		{
			sum += x % 10;
			x /= 10;
		}
		while(y)
		{
			sum += y % 10;
			y /= 10;
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n = 100;
    int m = 0;
    cin >> n;
    cin >> m;
    int matA[n][m];
    int matB[m];
    int matC[n];
    for (int i = 0; i < n; i++) {
        matC[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> matA[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> matB[i];
    }
    

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            matC[i] += matA[i][j] * matB[j];
        }
    }

    for (int i = 0; i < n; i++) {
        cout << matC[i] << endl;
    }


}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    for(long long i = 1; i <= 9; ++i){
        for(long long j = 1; j <= 9; ++j){
            if(i * j == N){
                cout << YES << endl;
                return;
            }
        }
    }
    cout << NO << endl;
    return;
}

// 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)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-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 N,K;
int A[200005];
int MAX_A;

bool check(int m){
    int cnt=0;
    for(int i=0;i<N;++i){
        if(A[i]>m)cnt+=A[i]/m;
    }
    if(cnt<=K)return true;
    else return false;
}

signed main(){
    cin>>N>>K;
    for(int i=0;i<N;++i){
        cin>>A[i];
        chmax(MAX_A,A[i]);
    }
    int l=1,r=MAX_A;
    for(int i=0;i<100;++i){
        int mid=(l+r)/2;
        if(check(mid))r=mid;
        else l=mid;
    }
    if(check(l))cout<<l<<endl;
    else cout<<r<<endl;
    //cout<<(int)(ceil((double)(l+r)/2.0))<<endl;
}

Measured memory_bytes: 5084