akhauriyash/Code-Regression huggingface dataset:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,K = LI()
    A = LI()

    f = [1]
    r = [1]
    c = 1
    for i in range(1,N+1):
        c = (c * i) % MOD
        f.append(c)
        r.append(pow(c,MOD-2,MOD))

    def comb(n,k):
        return f[n] * r[k] * r[n-k]

    A.sort()
    max_a = 0
    min_a = 0
    for i in range(N-1,K-2,-1):
        max_a = (max_a + A[i] * comb(i,K-1)) % MOD
    for i in range(N-K+1):
        min_a = (min_a + A[i] * comb(N-1-i,K-1)) % MOD
    print((max_a - min_a) % MOD)

if __name__ == '__main__':
    main()

Measured memory_bytes: 72040
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  char X, Y;
  rd(X);
  rd(Y);
  if(X==Y){
    wt_L('H');
    wt_L('\n');
  }
  else{
    wt_L('D');
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// {
//   char X, Y;
//   rd(X, Y);
//   wt( if[X==Y, 'H', 'D'] );
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = 5e15;
int main(){
    string s;
    cin >> s;
    ll ans = INF;
    for(ll i = 0; i < s.size() - 2; i++){
        ll tmp = (s[i] - '0') * 100 +
            (s[i + 1] - '0') * 10  +
            (s[i + 2] - '0');
        ans = min(ans, abs(753 - tmp));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n;
cin>>n;
ll a[200005];
for(int i = 0; i<n; i++){
    cin>>a[i];
}
sort(a,a+n);
for(int i = 0; i<n-1; i++){
    if(a[i]==a[i+1]){
        cout<<"NO"<<endl;
        return 0;
    }
}
cout<<"YES"<<endl;
}

Measured memory_bytes: 1792
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int res = 0;
		Integer[] a = new Integer[n];
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			map.put(a[i], map.getOrDefault(a[i], 0) + 1);
		}
		Arrays.sort(a, (x, y) -> y - x);
		for (int key : a) {
			int countKey = map.getOrDefault(key, 0);
			if (countKey > 0) {
				map.put(key, countKey - 1);
				int diff = Integer.highestOneBit(key) * 2 - key;
				int countDiff = map.getOrDefault(diff, 0);
				if (countDiff > 0) {
					map.put(diff, countDiff - 1);
					res++;
				}
				else map.put(key, countKey);
			}
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 103300
#include<stdio.h>
#include<string.h>

int main(){
  int n;
  scanf("%d\n", &n);
  int i;
  char str[1024], *ptr, wrong[] = "Hoshino";
  while(n--){
    fgets(str, sizeof(str), stdin);
    while((ptr = strstr(str, wrong)) != NULL){
      ptr[6] = 'a';
    }
    printf("%s",str);
  }
  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> vec(N + 1);
    FOR(x, 1, 101) {
        FOR(y, 1, 101) {
            FOR(z, 1, 101) {
                ll tmp = x * x + y * y + z * z + x * y + y * z + z * x;
                if (tmp <= N) {
                    vec[tmp]++;
                }
            }
        }
    }
    REP(i, N) {
        cout << vec[i + 1] << endl;
    }
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	vector<int>in(n);
	rep(i,n)cin>>in[i];
	vector<vector<ll> >dp(n-1,vector<ll>(21));
	dp[0][in[0]]=1;
	loop(i,1,n-1)rep(j,21){
		if(j-in[i]>=0)dp[i][j]+=dp[i-1][j-in[i]];
		if(in[i]+j<=20)dp[i][j]+=dp[i-1][in[i]+j];
	}
	/*rep(i,n-1){
		rep(j,21)cout<<" "<<dp[i][j];
		cout<<endl;
	}*/
	cout<<dp[n-2][in[n-1]]<<endl;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n];
  int b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b,b+n);
  for (int i = 0; i < n; i++) {
    if (a[i] <= b[n/2 - 1]) {
      cout << b[n/2] << '\n';
    }
    else if (b[n/2 - 1] < a[i] && a[i] < b[n/2]) {
      cout << a[i] << '\n';
    }
    else {
      cout << b[n/2 - 1] << '\n';
    }
  }
}

Measured memory_bytes: 3840
/**
>>> In The Name Of GOD
**/
#include <bits/stdc++.h>

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

#define pb push_back
#define pp pop_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define bs binary_search
#define smin(x,y) (x) = min((x) ,(y))
#define smax(x,y) (x) = max((x) ,(y))
#define sz(x) (int)(x).size()
#define ssz(x) (int)(x).length()
#define all(x) (x).begin(),(x).end()

//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

///ifstream fin("input.txt");
///ofstream fout("output.txt");


bool cmp_pair_F_2(pair <int,int> x, pair <int,int> y)
{
    return x.F>y.F;
}
bool cmp_pair_S_2(pair <int,int> x, pair <int,int> y)
{
    return x.S>y.S;
}
bool cmp_pair_S_1(pair <int,int> x, pair <int,int> y)
{
    return x.S<y.S;
}

bool cmp(int x, int y)
{
	return x>y;
}



int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //int i,j;
	int a,b;
	cin >> a >> b;
	if (a>=13)
        cout << b;
    else if (a>=6)
            cout << b/2;
        else
            cout << 0;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    if(n%3!=0){
        cout<<(a[n-1]==0 ? "Yes" : "No")<<endl;
        return 0;
    }
    int x=a[0];
    int y=a[n/3];
    int z=a[(n/3)*2];
    if(x!=a[(n/3)-1]||y!=a[(n/3)*2-1]||z!=a[n-1]){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<((x^y)==z ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 768
#pragma region Include
#include <bits/stdc++.h>
// #include <algorithm>
// #include <bitset>
// #include <climits>
// #include <cmath>
// #include <iostream>
// #include <iterator>
// #include <map>
// #include <queue>
// #include <sstream>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << endl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

template <typename T1, typename T2>
inline void chmin(T1& a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1& a, T2 b) {
  if (a < b) a = b;
}
#pragma endregion

int main() {
  int N, M, L;
  cin >> N >> M >> L;
  vvi G(N, vi(N, INF));
  vvi sup(N, vi(N, INF));
  rep(i, M) {
    int v1, v2, w;
    cin >> v1 >> v2 >> w;
    --v1;
    --v2;
    G[v1][v2] = w;
    G[v2][v1] = w;
  }
  rep(i, N) { G[i][i] = 0; }

  rep(k, N) {
    rep(i, N) {
      rep(j, N) { G[i][j] = min(G[i][j], G[i][k] + G[k][j]); }
    }
  }

  // dump(G);

  rep(i, N) {
    rep(j, N) {
      if (G[i][j] <= L) {
        sup[i][j] = 1;
      }
    }
    sup[i][i] = 0;
  }

  rep(k, N) {
    rep(i, N) {
      rep(j, N) { sup[i][j] = min(sup[i][j], sup[i][k] + sup[k][j]); }
    }
  }

  // dump(sup);

  int Q;
  cin >> Q;
  rep(_, Q) {
    int s, t;
    cin >> s >> t;
    --s;
    --t;
    if (sup[s][t] == INF) {
      cout << -1 << endl;
    } else {
      cout << sup[s][t] - 1 << endl;
    }
  }

  return 0;
}

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


using namespace std;
#define int long long

int32_t main()
{
    
    string s;
    cin >> s;
    int ans = 0;
    for (char i : s)
    {
        ans += (i - '0');
        ans = ans % 9;
    }

    
    if (ans % 9 == 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        sc.close();

        int ans = 0;
        int cnt = (int) Math.pow(2, m);
        for (int i = 0; i < cnt; i++) {
            ans += (n - m) * 100 + m * 1900;
        }

        System.out.println(ans);

    }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const Int MOD = 1000000007;
Int dp[1000010][3];
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        dp[i+1][0] = dp[i][0] * 8 % MOD;
        dp[i+1][1] = (dp[i][0] * 2 + dp[i][1] * 9) % MOD;
        dp[i+1][2] = (dp[i][1] + dp[i][2] * 10) % MOD;
    }
    cout << dp[N][2] << endl;
    return 0;
}


Measured memory_bytes: 30540
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
   if(a==b && b!=c)
    cout<<"Yes"<<endl;
   else if(b==c && c!=a)
    cout<<"Yes"<<endl;
    else if(c==a && a!=b)
    cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
*,S = $<.read.split
t,A = 0,S.size.times.group_by{|i| S[i]}.values
A[2] && A.permutation {|x,y,z|
  b,ys,zs,s = 0,y.size,z.size,S[z[0]||0]
  x.each {|i|
    k = z[c=0]
    b += 1  until i < y[b]  rescue break
    b.upto(ys-1) {|b|
      l = (j=y[b])*2 - i
      k = z[c+=1]  until j < k  rescue break
      t += S[l]==s ? zs-c-1 : zs-c
    }
  }
}
p t

Measured memory_bytes: 14524
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N, aa;cin>>N;
    ll ans=INF;
    vector<ll> a;
    vector<ll> s(N+1, 0);
    for(int i=0; i<N;i++){
      cin>>aa; a.push_back(aa);
    }
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

    for(int i=1; i<N;i++){
      ll tmp = abs(s[N] - 2*s[i]);
      ans = min(tmp, ans);
    }

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3956
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =
				new BufferedReader( new InputStreamReader(System.in) );

		Deque<Integer> stack = new ArrayDeque<>();

		char[] data = br.readLine().toCharArray();

		/**
		 * ?????£????????????data?????????????????´??°?????????????????????
		 * \ ??¨ / ?????????????????¨???????°´?????????????????§???
		 * \ ??¨???????????????????????? / ????????¨????????´??????
		 * \ ?????¨?????¨??????????????´??°????????????????´?????????????????????? / ??????????????????????????????????????¨?????°????????\?????????
		 * ???????????? / ????????? \ ??¨???\??\???????????????????????????/??¨_????????¨????????? 0 ?????\?????????
		 *
		 */
		int[] water = new int[data.length];
		for (int i=0; i < water.length; i++) {
			water[i] = 0;
		}

		/**
		 * ??\???????????????????????????????????????????????????i??????????????????????????????
		 * ???????????????????????????
		 *
		 * backslash \ ?????£?????´??????????????????????????¨?????°???????????????????????????????????????????????\?????????
		 * underscore _ ?????£?????´???????????????????????§?¬?????????????????????????
		 * slash / ?????£?????´???????????????????????????????????????backslash \ ????????????????????????????????????
		 * ?????????????????¨????????????????????´??°???????????????????????????????????????????´?????????´??° i ?????\?????????
		 *
		 * stack???????????\??£???????????????backslash\????????????????????§?????????????????????????????¨????????????????????????
		 *
		 */
		for (int i=0; i < data.length; i++) {
			if (data[i] == '\\') { stack.push(i); }
			else if (data[i] == '/') {
				if ( !stack.isEmpty() ) {
					int x = stack.pop();
					water[x] = i;
				}
			}
		}

		StringBuilder sb = new StringBuilder();

		int k = 0; // ?°´??????????????°
		int A = 0; // ?°´?????????

		/**
		 * ??°??¢?????????????????´??°?????????water??????????????????????????????
		 * ?°´?????????????????????????????£????????????????°´??????????????\??£???????°´??????????????????????????¨???
		 * ?°´???????????????????????§????°?????£???¶???
		 * ?????????????????????????????????????????????????????????water?????????????????????
		 *
		 */
		for (int i=0; i < water.length; i++) {
			if (water[i] != 0) {
				int Li = 0;
				for (int j=i; j < water[i]; j++) {
					if (water[j] != 0) {
						Li += water[j] - j;
					}
				}
				sb.append(" " + Li);
				k++;
				A += Li;
				i = water[i];
			}
		}
		System.out.println(A);
		System.out.println(k + sb.toString());

//		System.out.println(data);
//		System.out.println('\\');
	}

}

/*           10        20        31
 * 0123456789012345678901234567890123456
 * \\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\
 * 32   7  9  164   09         50  3
 * 3,2,7,9,21,16,14,20,19,35,30,33,
 *
 * 3-0 + 2-1 = 4
 * 7-5 = 2
 * 9-8 = 1
 * 21-11 + 16-12 + 14-13 + 20-17 + 19-18 = 19
 * 35-28 + 30-29 + 33-32 = 9
 *
 */

Measured memory_bytes: 25600
s = gets.chomp.split(//).map(&:to_i)
ans0 = 0
ans1 = 0
s.each_with_index do |n, i|
  if i % 2 == 0
    ans0 += 1 if n == 1
    ans1 += 1 if n != 1
  else
    ans0 += 1 if n != 1
    ans1 += 1 if n == 1
  end
end

puts [ans0, ans1].min


Measured memory_bytes: 9724
import sys
from fractions import gcd

def input():
	return sys.stdin.readline()

N = int(input())
A = [int(_) for _ in input().split()]
p1 = [0] * N
p2 = [0] * N

p1[0] = A[0]
p2[-1] = A[-1]

for i in range(1, N):
	p1[i] = gcd(p1[i-1], A[i])
	p2[-(i+1)] = gcd(p2[-i], A[-(i+1)])

m = max(p1[-2], p2[1])

if N > 2:
	for i in range(1, N-1):
		m = max(m, gcd(p1[i-1], p2[i+1]))

print(m)

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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

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

	if (x >= 30)cout << "Yes\n";
	else {
		cout << "No\n";
	}

}

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

struct ystruct {
    double val;
    int64_t init_length;
    int64_t split_num;
};
bool operator<=(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val <= rhs.val;
}
bool operator<(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val < rhs.val;
}
bool operator>=(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val >= rhs.val;
}
bool operator>(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val > rhs.val;
}
bool operator==(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val == rhs.val;
}
bool operator!=(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val != rhs.val;
}
ostream& operator<<(ostream& os, ystruct const& yst) {
    return os << yst.val;
}

int main() {
    int64_t N, K;
    cin >> N;
    cin >> K;

    int64_t total_length = 0;
    priority_queue<ystruct> yp;
    vector<int64_t> avec;
    for (uint64_t i = 0; i < N; i++) {
        int64_t A;
        cin >> A;
        yp.push(ystruct{val : 1.0 * A, init_length : A, split_num : 0});
        avec.push_back(A);
        total_length += A;
    }

    // 適当な初期値を与えて上界とする
    double upper_bound = -1;
    for (auto a : avec) {
        int64_t split_num_heuristic = (K * a) / total_length;
        upper_bound = max(upper_bound, 1.0 * a / (split_num_heuristic + 1));
    }
    int64_t j = 0;
    while (j < K) {
        ystruct y = yp.top();
        yp.pop();

        int64_t split_num_min;
        split_num_min = (y.init_length / upper_bound) - 1L;

        if (y.split_num < split_num_min) {
            y.split_num = split_num_min;
            y.val = 1.0 * y.init_length / (y.split_num + 1);
            j += split_num_min;
            yp.push(y);
        } else {
            y.split_num = y.split_num + 1;
            y.val = 1.0 * y.init_length / (y.split_num + 1);
            j++;
            yp.push(y);
        }
    }
    ystruct yy = yp.top();
    if (yy.init_length % (yy.split_num + 1) == 0) {
        cout << (yy.init_length / (yy.split_num + 1)) << endl;
    } else {
        cout << (1 + yy.init_length / (yy.split_num + 1)) << endl;
    }
}


Measured memory_bytes: 11580
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin >> n;
    int a[n], cnt=0;
    REP(i, n) cin >> a[i];

    FOR(i, 1, n){
        if(a[i] == a[i-1]){
            a[i] = -1;
            cnt++;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

struct order{
  bool type;
  ll time;
  ll pos;
  order(bool t, ll s, ll p){type=t, time=s, pos = p;}
};

bool comp(order o1, order o2){
  if(o1.time==o2.time){
    return o1.type<o2.type;
  }else{
    return o1.time<o2.time;
  }
}

int main(){
  int n,q;
  cin >> n >> q;
  vector<order> orders;
  REP(i,n){
    ll s,t,x;
    cin >> s >> t >> x;
    orders.push_back(order(true,s-x,x));
    orders.push_back(order(false,t-x,x));
  }
  sort(orders.begin(),orders.end(),comp);
  set<ll> st;
  auto itr = orders.begin();
  REP(i,q){
    ll d; cin >> d;
    while(itr!=orders.end()&&(*itr).time<=d){
      if((*itr).type){
        st.insert((*itr).pos);
      }else{
        st.erase((*itr).pos);
      }
      itr++;
    }
    if(st.empty()){
      cout << -1 << endl;
    }else{
      cout << *st.begin() << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 21608
/* Author:bhagatsunny96
         JGEC
	   template__
	lets_code_it_ */
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define test long long int t; cin>>t; while(t-->0)
#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(long long int i=0;i<n;i++)
#define loopr(n) for(long long int i=n-1;i>=0;i--)
#define lrp(a,b) for(long long int i=a;i<=b;i++)
#define lrn(a,b) for(long long int i=b;i>=a;i--)
#define endl '\n'
#define vec vector<ll>v;
#define imap map<ll,ll>mip;
#define umap unordered_map<ll,ll>ump;
#define sett set<ll>st;
using namespace std;
ll gcd(ll a, ll b)
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);
}
ll lcm(ll a, ll b)  
 {  
    return (a*b)/__gcd(a, b);  
 }
 ll power(ll x, unsigned ll y) 
 { 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
 }
 bool isPrime(ll num)
 {
    bool flag=true;
    for(ll i =2;i<=num/2;i++) 
    {
       if(num%i==0) 
       {
          flag=false;
          break;
       }
    }
    return flag;
}
bool isPalin(ll num)
{
    bool flag=false;
    ll digit,rev=0,n=num;
    do
     {
         digit = num % 10;
         rev = (rev * 10) + digit;
         num = num / 10;
     } while (num != 0);
     if(rev==n)
     flag=true;
     return flag;
}
ll sumofdigits(ll n)
{
    ll c=0;
    while(n>0)
    {
        c++;
        n/=10;
    }
    return c;
}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b) 
{ 
    return (a.first > b.first); 
}
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
string sortString(string &str) 
{ 
   sort(str.begin(), str.end()); 
   return str;
} 
void countSort(ll arr[], ll n, ll exp) 
{ 
	ll output[n];
	ll i, count[10] = {0}; 
	for (i = 0; i < n; i++) 
		count[ (arr[i]/exp)%10 ]++; 
	for (i = 1; i < 10; i++) 
		count[i] += count[i - 1]; 
	for (i = n - 1; i >= 0; i--) 
	{ 
		output[count[ (arr[i]/exp)%10 ] - 1] = arr[i]; 
		count[ (arr[i]/exp)%10 ]--; 
	} 
	for (i = 0; i < n; i++) 
		arr[i] = output[i]; 
} 
void radixsort(ll arr[], ll n) 
{
    ll mx = arr[0]; 
	for (ll i = 1; i < n; i++) 
		if (arr[i] > mx) 
			mx = arr[i];
	ll m =mx;
	for (ll exp = 1; m/exp > 0; exp *= 10) 
		countSort(arr, n, exp); 
} 
void print(ll arr[], ll n) 
{ 
    for (ll i = 0; i < n; i++) 
        cout << arr[i] << " "; 
} 
int main() 
{
    fIO
    string s;
    cin>>s;
    ll n=s.length();
    ll a=0,b=0;
    loop(n)
    {
        if(s[i]=='A')
        a++;
        else
        b++;
    }
    if(a==0 || b==0)
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n;cin >> n;
    vi a(n);
    int g;
    set<int> st;
    bool ok = true;
    rep(i, n) {
        cin >> a[i];
        if(i==0)g=a[i];
        else g=gcd(g,a[i]);
        if(ok) if(a[i]!=1) ok=false;
    }
    if(ok) {
        cout << "pairwise coprime\n";
        return 0;
    }
    if(g!=1) {
        cout << "not coprime\n";
        return 0;
    }
    resort(a);
    rep(i, n) {
        for(int j = 1;j<=(int)(sqrt(a[i]));j++) {
            if(a[i]%j==0) {
                if(st.count(j)||st.count(a[i]/j)) {
                    cout << "setwise coprime\n";
                    return 0;
                }
                if(j!=1)st.insert(j);
                if(a[i]/j!=1)st.insert(a[i]/j);
            }
        }
    }
    cout << "pairwise coprime\n";
    return 0;
}
// 3 
// 1 1 1

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

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }

    ll ans = 0;
    ll left = 0;
    ll tmp = 0;
    for(ll right = 1; right <= n; ++right){
        while(left < right && (tmp + a.at(right - 1) != (tmp ^ a.at(right - 1)))){
            tmp -= a.at(left);
            left++;
        }
        // cerr << left << ' ' << right << endl;
        ans += right - left;
        tmp += a.at(right - 1);
    }
    cout << ans << endl;
    return 0;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  ll n, k;
  cin >> n >> k;

  set<ll> s;
  for (long i = 0; i < k; i++) {
    ll d;
    cin >> d;
    for (long j = 0; j < d; j++) {
      ll a;
      cin >> a;
      s.insert(a);
    }
  }

  cout << n - s.size() << endl;
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// dp[l][r] := l以上r未満の範囲をもらったときのX-Yの最大値

// dp[i][i] = 0
// 太郎の場合
// dp[l][r] = max(dp[l+1][r] + a[l], dp[l][r-1] + a[r-1])
// dp[l][r] = min(dp[l+1][r] - a[l], dp[l][r-1] - a[r-1])

// 区間DP
ll dp[3300][3300];

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

    for (int width = 1; width <= n; ++width) {
        for (int l = 0; l+width <= n; ++l) {
            int r = l+width;

            // 先手
            if (width % 2 == n%2) {
                dp[l][r] = max(dp[l+1][r] + a[l], dp[l][r-1] + a[r-1]);
            }
            else {
                dp[l][r] = min(dp[l+1][r] - a[l], dp[l][r-1] - a[r-1]);
            }
        }
    }

    cout << dp[0][n] << endl;
}


Measured memory_bytes: 78080
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  if (n % 2 == 0)
    cout << n / 2 - 1 << endl;
  else
    cout << n / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
abc=list(map(int,input().split()))
a,b,c=abc[0],abc[1],abc[2]
k=int(input())
for i in range(k+1):
    if a < b < c:
        print("Yes")
        break
    elif b <= a < c:
        b *= 2
    else:
        c *= 2
else:
    print("No")

Measured memory_bytes: 9148
from itertools import product


def makelist(BIT):
    LIST, tmp = [], s[0]
    for si, bi in zip(s[1:], BIT):
        if bi == 1:
            LIST.append(tmp)
            tmp = si
        elif bi == 0:
            tmp = [t + sij for t, sij in zip(tmp, si)]
    else:
        LIST.append(tmp)
    return LIST


def solve(LIST):
    COST, cnt = 0, [li[0] for li in LIST]
    if any(num > k for num in cnt):
        return h * w
    for j in range(1, w):
        tmp = [t + li[j] for t, li in zip(cnt, LIST)]
        if any(num > k for num in tmp):
            COST += 1
            cnt = [li[j] for li in LIST]
        else:
            cnt = tmp[:]
    return COST


h, w, k = map(int, input().split())
s = [[int(sij) for sij in input()] for _ in range(h)]

ans = h * w
for bit in product([0, 1], repeat=(h - 1)):
    numlist = makelist(bit)
    ans = min(ans, solve(numlist) + sum(bit))
print(ans)


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int N, M;
    cin >> N >> M;
    cout << (N == M ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define N 605
#define mod 1000000007
int dp[N][N],n,m,a,b,t[N],s[N],su[N],as;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&a,&b),t[a]=b,t[b]=a;
	s[0]=1;for(int i=2;i<=n*2;i++)s[i]=1ll*s[i-2]*(i-1)%mod;
	for(int i=1;i<=n*2;i++)su[i]=su[i-1]+!t[i];
	for(int l=1;l<=n*2;l++)
	for(int i=1;i+l<=n*2;i++)
	{
		int j=i+l;
		int fg=1;
		for(int k=i;k<=j;k++)if((t[k]<i||t[k]>j)&&t[k])fg=0;
		if((su[j]^su[i-1])&1)fg=0;
		if(!fg)continue;
		int tp=s[su[j]-su[i-1]];
		for(int k=i;k<j;k++)tp=(tp-1ll*dp[i][k]*s[su[j]-su[k]]%mod+mod)%mod;
		dp[i][j]=tp;as=(as+1ll*tp*s[su[n*2]-su[j]+su[i-1]])%mod;
	}
	printf("%d\n",as);
}//

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

typedef long long ll;
 
int main(){
  int n, k;
  cin >> n >> k;
  ll x[n], y[n], sx[n], sy[n];
  for(int i=0; i<n; i++){
    cin >> x[i] >> y[i];
    sx[i] = x[i];
    sy[i] = y[i];
  }
  sort(sx, sx+n);
  sort(sy, sy+n);
  ll ans = (sx[n-1] - sx[0]) * (sy[n-1] - sy[0]);
  for(int xi=0; xi<n; xi++){
    for(int xis=xi+1; xis<n; xis++){
      for(int yi=0; yi<n; yi++){
        for(int yis=yi+1; yis<n; yis++){
          ll minx = sx[xi], maxx = sx[xis];
          ll miny = sy[yi], maxy = sy[yis];
          int cnt = 0;
          for(int j=0; j<n; j++){
            if(minx<=x[j]&&x[j]<=maxx&&miny<=y[j]&&y[j]<=maxy) cnt++;
          }
          if(cnt >= k) ans = min(ans, (maxx-minx)*(maxy-miny));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a = 1000000000;
  
  for (int i = 0; i < N; i++) {
    int A_i;
    cin >> A_i;
    int b = 0;
    
    while (1) {
      if (A_i % 2 == 0){
        b += 1;
        A_i /= 2;
      }
      else {
        break;
      }
    }
    
    if (a > b) {
      a = b;
    }

  }
  
  cout << a << endl;
  
}

Measured memory_bytes: 256
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int n=sc.nextInt();
        long ans=1;
        long mod=1000000007;
        String s=sc.next();
        HashMap<Character,Long> map=new HashMap<>();
        for (int i = 0; i < n; i++) {
            char c=s.charAt(i);
            map.put(c,map.getOrDefault(c,0l)+1);
        }
        for (Long k:map.values())ans=(ans*(k+1))%mod;
        out.println((ans-1+mod)%mod);
        out.close();
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

        static int nextInt() {
            return Integer.parseInt(s.next());
        }

        static long nextLong() {
            return Long.parseLong(s.next());
        }

        static double nextDouble() {
            return Double.parseDouble(s.next());
        }
    }
}

Measured memory_bytes: 28268
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int main()
{
    int a,b,ans;
    char s[300000],t[300000];
    scanf("%s %s",s,t);
    a=strlen(s);
    ans=a;

    for(int i=0;i<a;i++)
    {
        if(s[i]==t[i])
        {
            ans=ans-1;
        }
    }


    printf("%d\n",ans);


    return 0;
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int h, w; cin >> h >> w;
    vector<string> s(h); rep(i,h) cin >> s[i];
    int left[h][w] = {};
    int right[h][w] = {};
    int up[h][w] = {};
    int down[h][w] = {};

    rep(i,h){
        rep(j,w){
            if(s[i][j] == '#'){
                left[i][j] = 0;
                up[i][j] = 0;
            }
            else{
                if(j==0){
                    left[i][j] = 1;
                }
                else{
                    left[i][j] = left[i][j-1] + 1;
                }
                if(i==0){
                    up[i][j] = 1;
                }
                else{
                    up[i][j] = up[i-1][j] + 1;
                }                
            }

            if(s[h-1 -i][w-1 -j] == '#'){
                down[h-1 -i][w-1 -j] = 0;
                right[h-1 -i][w-1 -j] = 0;
            }
            else{
                if(j==0){
                    right[h-1 -i][w-1 -j] = 1;
                }
                else{
                    right[h-1 -i][w-1 -j] = right[h-1 -i][w -j] + 1;
                }
                if(i==0){
                    down[h-1 -i][w-1 -j] = 1;
                }
                else{
                    down[h-1 -i][w-1 -j] = down[h -i][w-1 -j] + 1;
                }                
            }
        }
    }

    int ans = 0;
    rep(i,h){
        rep(j,w){
            ans = max(ans,left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3);
        }
    }

    //cout << left[1][1]  << " " << right[1][1] << " " << up[1][1] << " " << down[1][1] << endl;

    cout << ans << endl;
}

Measured memory_bytes: 66816
while 1:
 n=int(input())
 if n==0:break
 d={}
 for _ in[0]*n:
  k,v=input().strip().split()
  d[k]=v
 for _ in[0]*int(input()):
  e=input().strip()
  print(d[e]if e in d else e,end='')
 print()


Measured memory_bytes: 6464
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int MOD = 1e9 + 7, N = 4e5 + 9;
int pow2[N];

int add(ll a, int b) {
	a += b;
	if(a >= MOD) a -= MOD;
	if(a < 0) a += MOD;
	return a;
}

int sub(int a, int b) {
	return (a - b + MOD) % MOD;
}

int mul(int a, int b) {
	return (1ll*a*b) % MOD;
}

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	pow2[0] = 1;
	for (int i = 1; i < N; ++i)
		pow2[i] = mul(pow2[i - 1], 2);
	int n, zeros = 0, a1 = 0, a2 = 0;
	map<pair<ll, ll>, int> mp;
	ll x, y;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> x >> y;
		if(x == 0 && y == 0) {
			++zeros;
			continue;
		} else if(x == 0) {
			++a2;
			continue;
		} else if(y == 0) {
			++a1;
			continue;
		}
		ll g = __gcd(x, y);
		x /= g, y /= g;
		if(y < 0)
			x = -x, y = abs(y);
		mp[{x, y}]++;
	}
	int ans = add(pow2[a1], pow2[a2]);
	ans = sub(ans, 1);
	for(auto &it: mp) {
		if(!it.second) continue;
		ll y = it.first.first;
		ll x = it.first.second;
		y = -y;
		if(x < 0)
			x = abs(x), y = -y;
		ll cur = 0;
		if(mp.find({x, y}) != mp.end()) {
			cur = mp[{x, y}];
			mp[{x, y}] = 0;
		}
		ans = mul(ans, sub(add(pow2[cur], pow2[it.second]), 1));
		it.second = 0;
	}
	ans = sub(ans, 1);
	ans = add(ans, zeros);
	cout << ans;
	return 0;
}


Measured memory_bytes: 17612
n,x = map(int,input().split())
lst = list(map(int, input().split()))
score = 1
dp = 0
for i in range(n):
	if dp < x:
		dp += lst[i]
		score += 1
	elif dp == x:
		dp += lst[i]
		break
	else:
		score -= 1
		break
print(score)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		Set<String> dictionary = new HashSet<String>();
		for (int i = 0; i < num; i++) {
			String com = br.readLine();
			String[] commands = com.split(" ");
			String command = commands[0];
			String word = commands[1];
			if (command.equals("insert")) {
				dictionary.add(word);
			} else {
				if (dictionary.contains(word)) {
					System.out.println("yes");
				} else {
					System.out.println("no");
				}
			}
		}

	}
}


Measured memory_bytes: 189540
#include <stdio.h>
#include <string.h>

typedef struct{
    //***軸は半時計周り***
    int X[4];//top front btm back
    int Y[4];//front right back left
    int Z[4];//top left btm right
}Dice;

void init_dice(Dice *d, int arr[]){
    //top
    d->X[0] = arr[0];
    d->Z[0] = arr[0];
    //front
    d->X[1] = arr[1];
    d->Y[0] = arr[1];
    //right
    d->Y[1] = arr[2];
    d->Z[3] = arr[2];
    //left
    d->Y[3] = arr[3];
    d->Z[1] = arr[3];
    //back
    d->X[3] = arr[4];
    d->Y[2] = arr[4];
    //bottom
    d->X[2] = arr[5];
    d->Z[2] = arr[5];
}

int rotate_X(int X[], int Y[], int Z[], int n){ //n : how many loops?
    //North : n=1
    //South : n=3
    int tmp, i, j;
    for(i = 0; i < n; i++){
        for(j = 0; j < 3; j++){
            tmp = X[j + 1];
            X[j + 1] = X[j];
            X[j] = tmp;
        }
    }
    Z[0] = X[0];
    Y[1] = X[1];
    Z[2] = X[2];
    Y[2] = X[3];
}

int rotate_Y(int X[], int Y[], int Z[], int n){ //n : how many loops?
    //Left : n=1
    //Right : n=3
    int tmp, i, j;
    for(i = 0; i < n; i++){
        for(j = 0; j < 3; j++){
            tmp = Y[j + 1];
            Y[j + 1] = Y[j];
            Y[j] = tmp;
        }
    }
    X[1] = Y[0];
    Z[3] = Y[1];
    X[3] = Y[2];
    Z[1] = Y[3];
}

int rotate_Z(int X[], int Y[], int Z[], int n){ //n : how many loops?
    //East : n=1
    //West : n=3
    int tmp, i, j;
    for(i = 0; i < n; i++){
        for(j = 0; j < 3; j++){
            tmp = Z[j + 1];
            Z[j + 1] = Z[j];
            Z[j] = tmp;
        }
    }

    //sync
    X[0] = Z[0]; //top
    Y[3] = Z[1]; //left
    X[2] = Z[2]; //btm
    Y[1] = Z[3]; //right
}


int main(){
    Dice d, *p = &d;
    int i, tmp[6];

    for(i = 0; i < 6; i++){
        scanf("%d", &tmp[i]);
        getchar();
    }

    init_dice(p, tmp);

    char odr[101];
    scanf("%s", odr);
    int len = strlen(odr);

    for(i = 0; i < len; i++){
        switch(odr[i]){
            case 'N':
                rotate_X(d.X, d.Y, d.Z, 1);
                break;

            case 'S':
                rotate_X(d.X, d.Y, d.Z, 3);
                break;

            case 'E':
                rotate_Z(d.X, d.Y, d.Z, 1);
                break;

            case 'W':
                rotate_Z(d.X, d.Y, d.Z, 3);
                break;
        }
    }

    printf("%d\n", d.X[0]);
}



Measured memory_bytes: 2120
from bisect import bisect_left

n = int(input())
hurui = [True for _ in range(100010)]
prime_lst = []
for i in range(2, 100010):
  if not hurui[i]:
    continue
  prime_lst.append(i)
  for j in range(i * i, 100010, i):
    hurui[j] = False

pos = bisect_left(prime_lst, n)
print(prime_lst[pos])

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end() å
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int p, q, r;

signed main()
{
    cin >> p >> q >> r;

    int s1 = p + q;
    int s2 = q + r;
    int s3 = p + r;

    int ans = min({s1, s2, s3});

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n;
void partition(int *,int,int);
int main(){
  int i;
  int A[100001];
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  partition(A,0,n);
  return 0;
}

void partition(int A[],int p,int r){
  int x = A[r-1];
  int i,j,tmp;
  j=p;
  for(i=p;i<r;i++){
    if(A[i]<=x){
      tmp = A[i];
      A[i] = A[j];
      A[j]=tmp;
      j++;
    }
  }
  for(i=p;i<r;i++){
    if(i==j-1) printf("[%d]",A[i]);
    else printf("%d",A[i]);
    if(i!=r-1) printf(" ");
  }
  printf("\n");
}
    



Measured memory_bytes: 2112
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;

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

int main()
{
	FAST;
	char in[51][51];
	
	int r,c;
	cin >> r >> c;
	for(int i=0 ; i<r ; i++)
		cin >> in[i];

	for(int i=0 ; i<r ; i++)
	{
		for(int j=0 ; j<c ; j++)
		{
			if(in[i][j] == '#')
				cout << "#";
			else
			{
				int count = 0;
				for(int k=0 ; k<8 ; k++)
				{
					int ni = i+dx[k];
					int nj = j+dy[k];

					if(ni >= 0 && ni < r && nj >= 0 && nj < c)
					{
						if(in[ni][nj] == '#')	count++;
					} 
				}
				cout << count;
			}
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cctype>
#include<cstring>
#define maxn 2007
#define SDOI2020 RP++ 
using namespace std;
int n; 
inline int read()
{
	int x=0;
	int flag=0;
	char ch;
	ch=getchar();
	while(!isdigit(ch)) 
	{
		if(ch=='-') flag=1;
	ch=getchar();	
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-48;
		ch=getchar();
		}
		if(flag==1) x=-x;	
		return x;
}

int main()
{
	n = read();
	for(register int i = 1;i <= n;i++)
	{
		int x = read();
		if(x % 2 == 0)
		{
			if(x % 3 && x % 5)
			{
				printf("DENIED\n");
				return 0;
			}
		}
	}
	printf("APPROVED\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<62)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa

using namespace std;

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int x; cin >> x;
  cout << (x^1);
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;


int main() {

	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int cnt = 0;

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

	cout << cnt << endl;

	return 0;
}


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

int main(){
  int n,i,r=0;
  cin>>n;
  int v[n],c[n];
  for(i=0;i<n;i++) cin>>v[i];
  for(i=0;i<n;i++) cin>>c[i];
  for(i=0;i<n;i++){
    if(v[i]>c[i]) r+=v[i]-c[i];
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin
from collections import defaultdict

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

mod = 10 ** 9 + 7
g = defaultdict(int)
ans = 0

for i in range(N):
    tmp = 1
    a = A[i]
    g_tmp = defaultdict(int)
    while tmp <= A[i] ** 0.5:
        while tmp > 1 and a % tmp == 0:
            a //= tmp
            if tmp not in g_tmp:
                g_tmp[tmp] = 1
            else:
                g_tmp[tmp] += 1
        tmp += 1
    if a > 1:
        if a not in g_tmp:
            g_tmp[a] = 1
        else:
            g_tmp[a] += 1

    for j in g_tmp:
        if j not in g:
            g[j] = g_tmp[j]
        else:
            g[j] = max(g[j], g_tmp[j])

l = 1
ans = 0
for i in g:
    l *= pow(i, g[i], mod)
    l %= mod
for a in A:
    ans += l * pow(a, mod - 2, mod)
    ans %= mod

print(ans)

Measured memory_bytes: 46300