akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >>  N >> S;
  rep(i,0,N-2)if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')sum++;
  Out(sum);
}

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

int n;

int main() {
    cin >> n;
    int c = n%10;
    if (c == 2 || c == 4 || c == 5 || c == 7 || c == 9)
        cout << "hon";
    else if (c == 0 || c == 1 || c == 6 || c == 8)
        cout << "pon";
    else
        cout << "bon";
    return 0;
}

Measured memory_bytes: 3552
k,x=[int(i) for i in input().split()]

first=x-k+1
last=x+k-1
numlist=[]

if first>=-1000000 and last<=1000000:
    for i in range(first,last+1):
        numlist.append(str(i))
elif last<=1000000:
    for i in range(-1000000,last+1):
        numlist.append(str(i))
elif first>=-1000000:
    for i in range(first,1000001):
        numlist.append(str(i))
else:
    for i in range(-1000000,1000001):
        numlist.append(str(i))
print(" ".join(numlist))


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

bool is_kaibun(string s, int i, int j) {
    for (int k = i; k <= (i + j) / 2; k++) {
        if (s[k] != s[j - k]) return 0;
    }
    return 1;
}

int main(void) {
    string s;
    cin >> s;
    int n = s.size();
    if (is_kaibun(s, 0, n - 1) && is_kaibun(s, 0, (n - 1) / 2 - 1) && is_kaibun(s, (n + 3) / 2 + 1, n - 1)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
set<int> parse(string &S, int &p){
  if (isdigit(S[p])){
    set<int> st;
    int tmp = 0;
    while (isdigit(S[p])){
      tmp = tmp * 10 + S[p] - '0';
      p++;
      if (p == S.size()){
        break;
      }
    }
    st.insert(tmp);
    return st;
  } else {
    vector<set<int>> st;
    vector<char> op;
    p++;
    while (1){
      st.push_back(parse(S, p));
      if (p == S.size()){
        break;
      }
      if (S[p] == ')'){
        p++;
        break;
      }
      op.push_back(S[p]);
      p++;
    }
    int N = st.size();
    vector<vector<set<int>>> dp(N + 1, vector<set<int>>(N + 1));
    for (int i = 0; i < N; i++){
      dp[i][i + 1] = st[i];
    }
    for (int d = 2; d <= N; d++){
      for (int i = 0; i <= N - d; i++){
        int j = i + d;
        for (int k = i + 1; k < j; k++){
          for (int x : dp[i][k]){
            for (int y : dp[k][j]){
              if (op[k - 1] == '+'){
                dp[i][j].insert(x + y);
              }
              if (op[k - 1] == '-'){
                dp[i][j].insert(x - y);
              }
              if (op[k - 1] == '*'){
                dp[i][j].insert(x * y);
              }
              if (op[k - 1] == '/' && y != 0){
                if ((x < 0) ^ (y < 0)){
                  dp[i][j].insert(abs(x) / abs(y) * -1);
                } else {
                  dp[i][j].insert(abs(x) / abs(y));
                }
              }
            }
          }
        }
      }
    }
    return dp[0][N];
  }
}
int main(){
  while (1){
    string S;
    cin >> S;
    if (S == "#"){
      break;
    }
    S = '(' + S + ')';
    int p = 0;
    set<int> st = parse(S, p);
    cout << st.size() << endl;
  }
}


Measured memory_bytes: 3212
import sys
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
b_list=[]
for i in range(N):
  b_list.append(int(input()))
 
for i in b_list:
  A1 = [x if x != i else -1 for x in A1]
  A2 = [y if y != i else -1 for y in A2]
  A3 = [z if z != i else -1 for z in A3]
 
if sum(A1)==-3 or sum(A2)==-3 or sum(A3)==-3:
  print('Yes')
  sys.exit()
for t in range(3):
  if A1[t]+A2[t]+A3[t] == -3:
    print('Yes')
    sys.exit()
if A1[0]+A2[1]+A3[2] == -3 or A1[2]+A2[1]+A3[0] == -3:
  print('Yes')
  sys.exit()
print('No')

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

int n;
int A[20];

int solve(int i, int m){
    if(m==0){
        return true;
    } if(i >= n){
        return false;
    }
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main(){
    cin >> n;
    for(int a=0; a<n; a++){
        cin >> A[a];
    }
    int q;
    cin >> q;
    int m[q];
    for(int b=0; b<q; b++){
        cin >> m[b];
    }

    for(int i=0; i<q; i++){
        int result = solve(0, m[i]);
        if(result){
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <algorithm>    
#include <cmath>
#include <map>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <set>
#include <functional>
#define int long long
#define mod(int)(1000000007)
using namespace std;
const int INF = 1000000000000000;
int cnt[345678], test[345678];
signed main() {
	int n, m; cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second
 
 
main(){
 int n;
 cin>>n;
        while(n--){
                string man,in,fr,ba;
                cin>>man>>in;
                reverse(ALL(man));
                
                rep(i,man.size()){
                        switch(man[i]){
                        case 'J':
                                in=in[in.size()-1]+in.substr(0,in.size()-1);
                                break;
                        case 'C':
                                in=in.substr(1)+in[0];
                                break;
                        case 'E':
                                fr=in.substr(0,in.size()/2);
                                ba=in.substr((in.size()+1)/2);
                                if(in.size()%2){
                                        in =ba+in[in.size()/2]+fr;
                                }else in =ba+fr;
                                break;
                        case 'A':
                                reverse(ALL(in));
                                break;
                        case 'P':
                                rep(j,in.size()){
                                        if(isdigit(in[j])){
                                                --in[j];
                                                if(in[j]=='0'-1)in[j]='9';
                                        }
                                }
                                break;
                        case 'M':
                                rep(j,in.size()){
                                        if(isdigit(in[j])){
                                                ++in[j];
                                                if(in[j]=='9'+1)in[j]='0';
                                        }
                                }
                                break;
                        }
                }
                cout<<in<<endl;
        }
}

Measured memory_bytes: 0
def ip():
    return [ int(_) for _ in input().split()]

def main():
    ip1=ip()
    two=ip1[1]-ip1[0]*2
    if (two&1 or two<0):
        print("No")
        return
    four=ip1[0]*4-ip1[1]
    if (four&1 or four<0):
        print("No")
        return
    print("Yes")
    





if __name__=='__main__':
    main()



Measured memory_bytes: 9048
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int W = sc.nextInt();
    int H = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r = sc.nextInt();
    if(x < r || y < r) {
      System.out.println("No");
    }else if(x + r > W || y + r > H) {
      System.out.println("No");
    }else {
      System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 26392
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const int inf=1e9,mod=998244353;
int n,sl,fh;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
int main()
{
	n=rd();
	for(int i=1;i<=n;++i)
		if(floor(i*1.08)==n)
			return printf("%d\n",i),0;
	puts(":(");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 aa, bb;
	cin >> aa >> bb;
	if((aa + bb) % 2 == 0)
	{
		cout << ((aa + bb) / 2) << endl;
	}
	else
	{
		puts("IMPOSSIBLE");
	}
	return 0;
}

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

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    
    ll ans = N/(A+B)*A;
    ll R = N%(A+B);
    ans += min(R, A);

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

Measured memory_bytes: 256
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

a, b, x = MAP()
print(b//x-a//x+1 if a%x==0 else b//x-a//x)

Measured memory_bytes: 10112
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char s[200005][16];
int asc(const void* a, const void* b)
{
	return strcmp(s[*(int*)a], s[*(int*)b]);
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++)
		scanf("%s", s[i]);
	int c[200005];
	for (i = 0; i < n; i++)
		c[i] = i;
	qsort(c, n, sizeof(int), asc);
	int a[200005];
	a[c[0]] = 1;
	for (i = 1; i < n; i++)
	{
		if (strcmp(s[c[i]], s[c[i - 1]]) == 0)
			a[c[i]] = a[c[i - 1]] + 1;
		else
			a[c[i]] = 1;
	}
	int max = 0;
	for (i = 0; i < n; i++)
		if (a[i] > max)
			max = a[i];
	for (i = 0; i < n; i++)
		if (a[c[i]] == max)
			printf("%s\n", s[c[i]]);
	return 0;
}

Measured memory_bytes: 6516
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

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

  sort(p.rbegin(), p.rend());

  int ans = 0;
  for(int i = 1; i <= 100; i++){ // 得点
    int num = 0;
    for(int j = 0; j < n; j++){
      if(p[j] >= i) num++;
    }
    if(i <= num) ans = i;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3108
def main():
    N, M = (int(i) for i in input().split())
    sc = [[int(i) for i in input().split()] for j in range(M)]
    for i in range(1000):
        if len(str(i)) != N:
            continue
        for s, c in sc:
            ss = str(i)
            if ss[s-1] != str(c):
                break
        else:
            return print(i)
    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())

strs = [ input() for _ in range(n) ]

ab = sum(map(lambda s:s.count("AB"), strs))
# print(ab)

last_a = sum(map(lambda s:1 if s.endswith("A") else 0, strs))

first_b = sum(map(lambda s:1 if s.startswith("B") else 0, strs))

both = sum(map(lambda s:1 if s.endswith("A") and s.startswith("B") else 0, strs))

if both > 0 and last_a == first_b and first_b == both:
    print(ab + min(last_a, first_b) - 1)
else:
    print(ab + min(last_a, first_b))

Measured memory_bytes: 46040
import sys

def main(inp):
    N=int(next(inp))
    H=list(map(int,next(inp).split()))
    
    ans=0
    high=0
    for i in range(N):
        if(high<=H[i]): ans+=1
        high=max(high,H[i])
    
    return ans
    
print(main(sys.stdin))

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
    int n,a,b;
    s3(n,a,b);
    int ans = (n/(a+b))*a + min(n%(a+b), a);
    out<<ans<<endl;
}

class BCountBalls {
public:
	void solve(std::istream& in, std::ostream& out) {
        int t;
        int READ = 0;
        if(READ) s(t);
        else t = 1;
        while(t--){
            ssolve(in, out);
        }
	}
};


integer main() {
	BCountBalls solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


Measured memory_bytes: 256
str_N = input()
t = len(str_N)
N = int(str_N)

sum = 0

if t % 2 ==0:
    for i in range(t//2):
        sum += 9*(100**(i))
    print(sum)
else:
    for i in range((t-1)//2):
            sum += 9*(100**(i))
    sum += N - 10**(t-1) + 1
    print(sum)


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

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

    int ans = 0;

    ans += b[a[0]-1];
    REP(i,1,n) {
        ans += b[a[i]-1];
        if(a[i]==a[i-1]+1) {
            ans += c[a[i-1]-1];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n, k;
  cin >> n >> k;
  vecint v(n, 0);
  for (auto& e : v) cin >> e;
  int m = min(k, n);
  vec2int left(m + 1, vecint(m + 1, 0));
  vec2int right(m + 1, vecint(m + 1, 0));
  priority_queue<int, vector<int>, greater<int>> q;
  vecint sum(n + 1, 0);
  REP(i, n) sum[i + 1] = sum[i] + v[i];
  REP(i, m) {
    q.push(v[i]);
    priority_queue<int, vector<int>, greater<int>> q2 = q;
    left[i + 1][0] = sum[i + 1];
    REP(j, i + 1) {
      int tmp = q2.top();
      q2.pop();
      left[i + 1][j + 1] = left[i + 1][j] - tmp;
    }
  }
  while (!q.empty()) {
    q.pop();
  }
  reverse(all(v));
  reverse(all(sum));
  REP(i, m) {
    q.push(v[i]);
    priority_queue<int, vector<int>, greater<int>> q2 = q;
    right[i + 1][0] = sum[0] - sum[i + 1];
    REP(j, i + 1) {
      int tmp = q2.top();
      q2.pop();
      right[i + 1][j + 1] = right[i + 1][j] - tmp;
    }
  }
  // for (int i = n - 1; i >=)
  // REP(i, m + 1) {
  //   cout << "i = " << i << endl;
  //   REP(j, i + 1) { cout << setw(4) << std::right << left[i][j]; }
  //   cout << endl;
  // }
  // REP(i, m + 1) {
  //   cout << "i = " << i << endl;
  //   REP(j, i + 1) { cout << setw(4) << std::right << right[i][j]; }
  //   cout << endl;
  // }
  int ans = 0;
  REP(i, m + 1) {
    REP(i2, m + 1) {
      if (i + i2 > n) break;
      REP(j, i + 1) {
        REP(j2, i2 + 1) {
          if (i + i2 + j + j2 > k) continue;
          ans = max(ans, left[i][j] + right[i2][j2]);
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

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

    int a, b, c;
    vector<vector<int>> happ(N + 1, vector<int>(3));
    for (int i = 1; i <= N; i++) {
        cin >> a >> b >> c;
        happ[i][0] = max(happ[i - 1][1] + a, happ[i - 1][2] + a);
        happ[i][1] = max(happ[i - 1][0] + b, happ[i - 1][2] + b);
        happ[i][2] = max(happ[i - 1][0] + c, happ[i - 1][1] + c);
    }
    cout << max(happ[N][0], max(happ[N][1], happ[N][2])) << endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    VI P(N); REP(i, N) cin >> P[i];
    VI Q(N); REP(i, N) cin >> Q[i];

    int a = -1, b = -1;
    VI tmp(N);
    iota(ALL(tmp), 1);
    int cnt = 1;
    do {
        if (tmp == P) a = cnt;
        if (tmp == Q) b = cnt;
        cnt++;
    } while (next_permutation(ALL(tmp)));

    cout << abs(a - b) << endl;
}


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


public class A
{
    public static void Main()
    {
        var c = GetString();
        var vowel = new string[] {"a", "i", "u", "e", "o"};
        for (int i = 0; i < vowel.Length; i++)
        {
            if (vowel[i] == c)
            {
                Console.WriteLine("vowel");
                return;
            }
        }
        Console.WriteLine("consonant");
    }
}

public static class MyIO
{
    private static string[] args = null;
    private static int num = -1;
    private static int used = -1;

    private static string getArg()
    {
        if (used == num)
        {
            args = Console.ReadLine().Split(' ');
            num = args.Length;
            used = 0;
        }
        return args[used++];
    }

    public static int GetInt() { return int.Parse(getArg()); }
    public static long GetLong() { return long.Parse(getArg()); }
    public static double GetDouble() { return double.Parse(getArg()); }
    public static string GetString() { return getArg(); }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    string S;
    cin >> S;
    char A = '0';
    int tmpa = 0;
    char B = '1';
    int tmpb = 0;
    REP(i, S.size())
    {
        if (S[i] == A)
        {
            tmpa++;
        }
        else
        {
            tmpb++;
        }
        if (A == '0')
            A = '1';
        else
            A = '0';
    }
    cout << min(tmpa, tmpb) << endl;
    // system("pause");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

int main() {
    string n; cin >> n;
    int sum_dig = 0;
    rep(i, n.size()) {
        sum_dig += n[i] - '0'; //ASCIIコードを利用
    }
    if (sum_dig % 9 == 0) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			try{
				String[] strA = insBR.readLine().split(" ");
				int[] intA = new int[strA.length];
				for(int i = 0;i < strA.length ;i++){
					intA[i] = Integer.parseInt(strA[i]);
				}
				if(intA[0] == 0 && intA[1] == 0){
					break;
				}else{
					for(int j = 0; j <intA[1]; j++){
						System.out.print("#");
					}
					System.out.println();
					for(int i = 0;i < intA[0] - 2;i++){
						System.out.print("#");
						for(int j = 0; j < intA[1]-2;j++){
							System.out.print(".");
						}
						System.out.println("#");
					}
					for(int j = 0; j <intA[1]; j++){
						System.out.print("#");
					}
					System.out.println();
					System.out.println();
				}
			}catch(IOException e){
				e.printStackTrace();
			}catch(NumberFormatException e){
				e.printStackTrace();
			}
		}
	}

}



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

int main() {
	string angou;
	while(getline(cin, angou)) {
		while(1) {
			if(angou.find("the") != -1 || angou.find("this") != -1 || angou.find("that") != -1) break;
			else {
				for(int i = 0; i < angou.size(); i++) {
					if(angou[i] == ' ' || angou[i] == '.') continue;
					else angou[i]++;
					if(angou[i] == 'z'+1) angou[i] = 'a';
//					cout << angou[i] << endl;
				}
			}
		}
		cout << angou << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200000005
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,x,y,ans=0;
    cin>>n;
    vector<ll> vi;
    for(i=0;i<n;i++){
        cin>>x;
        vi.pb(x);
    }
    sort(vi.begin(),vi.end());
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            x=vi[i]+vi[j];
            y=lower_bound(vi.begin(),vi.end(),x)-vi.begin();
            ans+=y-j-1;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int K = sc.nextInt();
    
    Set<String> set = new HashSet<>();
    for (int i = 0; i < s.length(); i++) {
      for (int j = i; j < s.length() && j - i + 1 <= K; j++) {
        set.add(s.substring(i, j+1));
      }
    }
    List<String> list = new ArrayList<>(set);
    Collections.sort(list);
    System.out.println(list.get(K-1));
  }
}

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

long long int make(long long int a,long long int b){
    long long int result=b/3;
    long long int rem=b%3;
    long long int r1=result,r2=result,r3=result;
    if(rem>=1){
        r2++;
    }
    if(rem>=2){
        r3++;
    }
    long long int a1=r1*a;
    long long int a2=r2*a;
    long long int a3=r3*a;
    long long int max1=max(a1,max(a2,a3));
    long long int min1=min(a1,min(a2,a3));
    return max1-min1;
}
long long int second(long long int a,long long int b){

    long long int height=ceil(b/3.0);
    long long int rem=b-height;
    long long int first=a/2;
    long long int second=a-first;
    long long int a1=first*rem;
    long long int a2=second*rem;
    long long int a3=height*a;
    long long int max1=max(a1,max(a2,a3));
    long long int min1=min(a1,min(a2,a3));
    long long int result1=max1-min1;
    height=(b/3.0);
    rem=b-height;
    first=a/2;
    second=a-first;
    a1=first*rem;
     a2=second*rem;
    a3=height*a;
    long long int max2=max(a1,max(a2,a3));
    long long int min2=min(a1,min(a2,a3));
    long long int result2=max2-min2;
    return min(result1,result2);
}

int main(){
    long long int a,b;
    cin>>a>>b;
    vector<long long int>v;
    long long int area1=make(a,b);
    long long int area2=make(b,a);
    long long int area3=second(a,b);
    long long int area4=second(b,a);
    long long int finalresult=min(area1,min(area2,min(area3,area4)));
    cout<<finalresult;
}

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


 int main(){

 	string str;
 	cin>>str;

 	lli ans1=0,ans2=0;

 	//0スタートにする場合。
 	REP(i,str.size()){
 		lli next = i%2;
 		if(str.at(i)-'0' != next)ans1++;
 	}

 	//1スタート
 	REP(i,str.size()){
 		lli next = (i+1)%2;
 		if(str.at(i)-'0' != next)ans2++;
 	}

 	cout<<min(ans1,ans2)<<endl;
 
	return 0;
 
}

Measured memory_bytes: 512
#include <stdio.h>
int main()
{
	int N,K,P;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d %d",&K,&P);
		if(K<=P)
			printf("%d\n",K);
		else{
			if(K%P==0)
				printf("%d\n",P);
			else
				printf("%d\n",K%P);
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#coding:utf-8



def main():
    from sys import stdin

    input = stdin.readline
    N = int(input())
    D = list(map(int,input().split()))
    D.sort()
    lower = D[N//2-1]
    upper = D[N//2]
    print(upper-lower)
if __name__ == '__main__':
    main()


Measured memory_bytes: 52840
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n=int(input())

edge=[[]for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    edge[a].append((b,c))
    edge[b].append((a,c))
q,k=map(int,input().split())

dis=[None]*(n+1)
def set_dist(x,d):
    dis[x]=d
    for y,f in edge[x]:
        if dis[y] is not None:
            continue
        set_dist(y,d+f)
set_dist(k,0)

for i in range(q):
    x,y=map(int,input().split())
    print(dis[x]+dis[y])

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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    char c;
    cin >> c;
    if(c >= 'A' && c <= 'Z'){
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
}

Measured memory_bytes: 3628
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int k = sc.nextInt();
                int[] a = new int[n];
                for(int i = 0 ; i < n ; i++){
                        a[i] = sc.nextInt();
                }
                sc.close();
                Arrays.sort(a);
                int yono = 0;
                for(int i = n - k ; i < n ; i++){
                        yono += a[i];
                }
                System.out.println(yono);
        }
}
//今日は部活があります

Measured memory_bytes: 35800
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>

using namespace std;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint N[2000001];

int main()
{
	int X, Y;
	cin >> X >> Y;
	
	if((-X + 2 * Y) % 3 != 0 || (2 * X - Y) % 3 != 0){
		cout << "0" << endl;
		return 0;
	}
	
	int x = (-X + 2 * Y)/3;
	int y = (2*X - Y)/3;
	
	if(x < 0 || y < 0){
		cout << "0" << endl;
		return 0;
	}
	
	N[0] = 1;
	for(int i = 1; i < 2000001; i++){
		N[i] = N[i-1] * i;
	}
	
	mint ans = N[x+y] / (N[x] * N[y]);
	
	cout << ans.x << endl;
	
	return 0;
}


Measured memory_bytes: 15872
def equalize(arr):
    idx = 0
    parity = []

    for i in arr:
        parity.append(i%2)

    s = sum(parity)

    if s == 1:
        arr[parity.index(1)] -=1
        idx+=1
    elif s == 2:
        arr[parity.index(0)] -=1
        idx+=1

    arr.sort()

    while arr[0] != arr[2]:
        arr[0] += 2
        arr.sort()
        idx+=1

    return idx

print(equalize(list(map(int, input().split()))))


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

using namespace std;
using ll = long long;

int D;
int c[26];
int s[400][26];

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

    for (int i = 0; i < 26; i++) cin >> c[i];
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    // vector<int> t(D, 1);
    // random_device rnd;
    // mt19937 mt(rnd());
    // uniform_int_distribution<> rand(1, 26);
    // for (int i = 0; i < D; i++) {
    //     cout << rand(mt) << '\n';
    // }
    int mx = 0;
    int mxi = 1;
    for (int i = 0; i < 26; i++) {
        if (c[i] > mx) {
            mx = c[i];
            mxi = i + 1;
        }
    }

    for (int i = 0; i < D; i++) {
        cout << mxi << '\n';
    }
    return 0;
}



Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define rint register int
#define ll long long 
using namespace std;
int n,pos,A[1010100],L;
int main(){
	cin>>n>>L;
	for(rint i=1;i<=n;++i) cin>>A[i];
	for(rint i=1;i<=n-1;++i) {
		if(A[i]+A[i+1]>=L) pos=i;
	} 
	if(!pos) cout<<"Impossible"; 
	else {
		cout<<"Possible\n";
		for(rint i=1;i<=pos-1;++i) cout<<i<<endl;
		for(rint i=n-1;i>=pos;--i) cout<<i<<endl;
//		cout<<pos<<endl;
	} 
	return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> b(n);
    rep(i,n){
        int a;
        cin>>a;
        b[a-1]++;
    }
    sort(b.begin(),b.end());
    int ans = 0;
    rep(i,n-k) ans += b[i];
    cout << ans << endl;
    
    return 0;
}


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

int main(){

  int N,K;
  cin>>N>>K;

  double ans=0;
  int i;
  for(i=0;i<N;i++){
    double n=N;
    double kaku=1.0/n;
    // cout<<"kaku "<<kaku<<" k "<<k<<endl;
    int k=i+1;
    // bool jud=0;
      while(k<K){
        // jud=1;
        kaku*=0.5;
        k*=2;
        // cout<<kaku<<endl;
      }
      // if(jud)
      // ans+=kaku*(1.0*0.5);
      // else
      ans+=kaku;
      // cout<<"ans "<<ans<<endl;
    }

    cout<<setprecision(12)<<ans<<endl;
}


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

#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n;

	cin >> n;

	string str;

	ll AC = 0;
	ll WA = 0;
	ll TLE = 0;
	ll RE = 0;

	while (n--) {

		cin >> str;

		if (str == "AC") {
			AC++;
		}
		else if (str == "WA") {
			WA++;
		}
		else if (str == "TLE") {
			TLE++;
		}
		else if (str == "RE") {
			RE++;
		}
	}

	cout << "AC x " << AC << endl;
	cout << "WA x " << WA << endl;
	cout << "TLE x " << TLE << endl;
	cout << "RE x " << RE << endl;
	
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll k,x;
  cin>>k>>x;

  for(ll i=x-k+1;i<=x+k-1;i++) cout << i << " ";
  cout << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int a[3],tmp,sum;
        int i,j;

        scanf("%d%d%d",&a[0],&a[1],&a[2]);

        for(i=1;i<3;i++){
                for(j=2;j>=i;j--){
                        if(a[j]>a[j-1]){
                                tmp = a[j];
                                a[j] = a[j-1];
                                a[j-1] = tmp;
                        }
                }
        }

        sum = 0;
        sum = a[0] - a[1];
        sum +=a[1]-a[2];

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


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

int main() {
  int n;
  cin >> n;
  if ((n % 10) == 7 || (n / 10 % 10) == 7 || (n / 100) == 7) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll a[111];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;ll x;cin>>n>>x;
  REP(i,n){
    cin>>a[i];
  }
  sort(a,a+n);
  ll sm=0;
  REP(i,n){
    sm+=a[i];
    if(sm>x){
      cout<<i<<endl;
      return 0;
    }
  }
  if(sm==x){
    P(n);
  }else{
    P(n-1);
  }
  return 0;
}


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


namespace NTL1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var sb = new StringBuilder();
            int n = int.Parse(Console.ReadLine());
            var P = new List<int>();
            eratos(P, (int)Math.Sqrt(n));

            sb.Append(n + ":");
            int i = 0;
            while (true)
            {
                if (n % P[i] != 0)
                {
                    i++;
                }
                else
                {
                    n /= P[i];
                    sb.Append(" " + P[i]);
                }
                if (i == P.Count)
                {
                    sb.Append(" " + n);
                    break;
                }
                if (n == 1)
                {
                    break;
                }

            }

            Console.WriteLine(sb);
        }
        //2???n?????§????´???°????????????(n>=2)
        static void eratos(List<int> P, int n)
        {
            var a = new bool[n + 1];
            a[0] = a[1] = true;
            int i;
            for (i = 2; i * i <= n; i++)
            {
                if (!a[i])
                {
                    P.Add(i);
                    int j = i << 1;
                    while (j <= n)
                    {
                        a[j] = true;
                        j = j + i;
                    }
                }
            }
            for (; i <= n; i++) if (!a[i]) P.Add(i);
        }
        
	}
     
    
}

Measured memory_bytes: 9288
n,k,q = map(int,input().split())
if(k>q):
  for i in range(n):
    print("Yes")
else:
  d = []
  for i in range(n):
    d.append(k+q*(-1))
  for i in range(q):
    a = int(input())
    d[a-1]+=1
  for i in range(n):
    if(d[i]>0):
      print("Yes")
    else:
      print("No")

    
  
  

Measured memory_bytes: 7848
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int v[n];
    float total=0;
    for(int a=n;a--;)cin>>v[a];
    for(int a=1;a<n;a++){
        for(int b=0;b<a;b++){
            if(v[a]<v[b]){
                v[a]+=v[b];
                v[b]=v[a]-v[b];
                v[a]-=v[b];
            }
        }
    }
    total=(v[0]+v[1])/2.0;
    for(int a=2;a<n;a++){
        total=(total+v[a])/2.0;
    }
    cout<<total;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  if(n%2==1){
    for(int i=1;i<=m;i++)
      cout<<i<<' '<<m*2+1-i<<endl;
  }else{
    for(int i=1;i<=(m+1)/2;i++)
      cout<<i<<' '<<(m+1)/2*2+1-i<<endl;
    for(int i=1;i<=m/2;i++)
      cout<<i+(m+1)/2*2<<' '<<m/2*2+2-i+(m+1)/2*2<<endl;
  }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int par[100010];//親
int rnk[100010];//ランク

void init(int n){//初期化
  for(int i=0;i<n;i++){
     par[i]=i;
     rnk[i]=0;
  }
}

int find(int x){//親を求める
  if(par[x]==x) return x;
  return par[x]=find(par[x]);
}

void unite(int x,int y){//union
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rnk[x]<rnk[y]){//rankが小さい方にくっつける
    par[x]=y;
  }
  else{
   par[y]=x;
    if(rnk[x]==rnk[y])rnk[x]++;//rankが同じ時は1増やす
  }
}

bool same(int x,int y){
 return find(x)==find(y); 
}

int main(){cout<<fixed<<setprecision(10);
		   int n,m;
           cin>>n>>m;
           vin a(m),b(m);
           rep(i,0,m){
             cin>>a[i]>>b[i];
             a[i]--;b[i]--;
           }
           int ans=0;
           rep(i,0,m){//i本目の橋を
             init(n);
             rep(j,0,m){
              if(i==j)continue;
               unite(a[j],b[j]);
             }
             bool ok=true;
             rep(j,0,n){
               if(!same(0,j))ok=false;
             }
             if(!ok)ans++;
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int h = in.nextInt();
        int n = in.nextInt();
        int sum = 0;
        for(int i=0; i<n; i++) {
            sum += in.nextInt();
        }
        System.out.println(sum>=h ? "Yes" : "No");
    }
}


Measured memory_bytes: 48156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)

map<ll, ll> prime_factor(ll n){
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++){
        while (n % i == 0) ++res[i], n /= i;
    }
    if (n != 1) res[n] = 1;
    return res;
}

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

int main(){
    ll a, b; scll(a), scll(b);
    ll tmp = gcd(a,b), ans = 0;
    map<ll,ll> mp = prime_factor(tmp);
    for (const auto &x : mp) ans += 1;
    cout << ans + 1 << endl;
    return 0;
}

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

using namespace std;
int main(){

    string s;
    cin >> s;
long A=s.size();
long Z=-1;
    for(long int i=0;i<s.size();i++){
if(s[i]=='A'){
    A=min(A,i);
}
if(s[i]=='Z'){
    Z=max(Z,i);
}
    }

    cout <<Z-A+1<<endl;
 return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    if (a == b && b == c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

}


Measured memory_bytes: 23764