akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  

class UnionFind {
  public:
    vi Parent;
    UnionFind(int N) {
      Parent = vi(N,-1);
    }
  
    int root(int A) {
      if(Parent[A] < 0) return A;
      return Parent[A] = root(Parent[A]);
    }
  
    int size(int A) {
      return -Parent[root(A)];
    }
  
    bool connect(int A,int B) {
      A = root(A);
      B = root(B);
      if(A == B) return false;
      if(size(A) < size(B)) swap(A,B);
      Parent[A] += Parent[B];
      Parent[B] = A;
      return true;
    }
};
int main() {
  int N,M;
  cin >> N >> M;
  UnionFind tree = UnionFind(N+M);
  rep(i,N) {
    int k;
    cin >> k;
    rep(j,k) {
      int l;
      cin >> l;
      l--;
      tree.connect(M+i,l);
    }
  }
  bool ok = true;
  srep(i,M,M+N-1) {
    if(tree.root(i) != tree.root(i+1)) {
      ok = false;
      break;
    }
  }
  if(ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder S = new StringBuilder(sc.nextLine());
        String T = sc.nextLine();
        sc.close();
        boolean ans = false;
        int len = S.length();
        for(int i = 0; i <= len; i++){
            S.insert(0, S.charAt(len-1));
            S.deleteCharAt(len);
            if(S.toString().equals(T)){
                ans = true;
                break;
            }
        }
        if(ans) System.out.println("Yes");
        else System.out.println("No");

    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
const int  Inv2 = (MOD+1)/2;

     signed main(){
  string w;
  cin>>w;
  int ans=0;
  for(int i=0;i<w.size();i++)ans^=(1<<(w[i]-'a') );
  if(ans)cout<<"No"<<"\n";
  else cout<<"Yes"<<endl;   
}

        


Measured memory_bytes: 256
type Dice = [Pip]
type Pip = String
type ToBe = [Pip]

main :: IO ()
main = do
    dice1 <- fmap words getLine
    dice2 <- fmap words getLine
    putStrLn $ if sameDice dice1 dice2 then "Yes" else "No"

sameDice :: Dice -> Dice -> Bool
sameDice d1 d2 = d1 `elem` allStates d2

allStates :: Dice -> [Dice]
allStates = concatMap allTurns . allTops

allTops :: Dice -> [Dice]
allTops dice = scanl role dice "EESEE"

allTurns :: Dice -> [Dice]
allTurns dice = scanl turn dice "RRR"

turn :: Dice -> Char -> Dice
turn [a,b,c,d,e,f] com
    | com == 'R' = [a,c,e,b,d,f]
    | com == 'L' = [a,d,b,e,c,f]

role :: Dice -> Char -> Dice
role [a,b,c,d,e,f] com
    | com == 'E' = [d,b,a,f,e,c]
    | com == 'N' = [b,f,c,d,a,e]
    | com == 'S' = [e,a,c,d,f,b]
    | com == 'W' = [c,b,f,a,e,d]


Measured memory_bytes: 3584
# coding=utf-8

class Tree():
    def __init__(self, init_field):
        self.root = init_field

    def search(self, field_id, field):
        global final_queen_pos
        #print("field_id:", field_id)
        #field.print_field()
        q_r = rest_row[field_id - n]
        if final_queen_pos:
            return None
        else:
            for q_c, cell in enumerate(field.state[q_r]):
                if cell == 0:
                    if final_queen_pos:
                        break
                    if field_id == 7:
                        field.queen_pos.append([q_r, q_c])
                        final_queen_pos = field.queen_pos
                        break
                    else:
                        next_field = Field(field_id + 1, field)
                        field.children.append(next_field)
                        next_field.update(q_r, q_c)
                        self.search(field_id + 1, next_field)
                else:
                    continue

class Field():
    def __init__(self, field_id, parent=None):
        self.id = field_id
        self.parent = parent
        self.children = []

        if field_id == 0:
            self.state = [[0 for _ in range(W)] for H in range(H)]
            self.queen_pos = []
        else:
            self.state = []
            self.queen_pos = []
            for row in self.parent.state:
                x = row.copy()
                self.state.append(x)
            for parent_queen_pos in self.parent.queen_pos:
                self.queen_pos.append(parent_queen_pos)

    def update(self, q_r, q_c):
        self.queen_pos.append([q_r, q_c])
        for i in range(8):
            self.state[q_r][i] = 1
            self.state[i][q_c] = 1
        summ = q_c + q_r
        diff = q_c - q_r
        for i in range(8):
            if (0 <= i + diff < 8):
                self.state[i][i + diff] = 1
            if (0 <= summ - i < 8):
                self.state[i][summ - i] = 1

    def print_field(self): #for debug
        print("queen_pos:", self.queen_pos)
        for row in self.state:
            print(*row)


H, W = 8, 8
n = int(input())
init_field = Field(0)
tree = Tree(init_field)
field_list = [init_field]
rest_row = [i for i in range(8)]
queen_pos = []
final_queen_pos = None
final_result = [["." for _ in range(8)] for _ in range(8)]

for _ in range(n):
    r, c = map(int, input().split())
    queen_pos.append([r, c])
    rest_row.remove(r)

if n < 8:
    i = 0
    prev_field = init_field
    for q_r, q_c in queen_pos:
        i += 1
        field = Field(i, prev_field)
        field.update(q_r, q_c)
        field_list.append(field)
        prev_field.children = [field]
        prev_field = field

    tree.search(i, field)

    for q_r, q_c in final_queen_pos:
        final_result[q_r][q_c] = "Q"

    for row in final_result:
        print("".join(row), end = "\n")

else:
    for q_r, q_c in queen_pos:
        final_result[q_r][q_c] = "Q"

    for row in final_result:
        print("".join(row), end = "\n")

Measured memory_bytes: 7904
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#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)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	for (int kame = 0; kame <= x; kame++) {
		int turu = x - kame;

		int asi = kame * 4 + turu * 2;
		if (asi == y) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}

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

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

    vector<bool> ex(x + 1);
    ex[1] = true;
    rep(i, 2, x + 1) {
        int v = i * i;
        while (v <= x) {
            ex[v] = true;
            v *= i;
        }
    }
    for (int i = x; i >= 1; --i) {
        if (ex[i]) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

type Pos struct {
	x int
	y int
}

func main() {
	Count := readLineInt()[0]
	PosArray := make([]Pos, Count)
	Loop(0, Count, func(i int) {
		in := readLineInt()
		PosArray[i] = Pos{in[0], in[1]}
	})

	var Sum float64
	Perm := getAllPermutation(getPermutationFromLength(Count)...)
	for _, v := range Perm {
		Length := len(v)
		for i, from := range v {
			if Length <= i+1 {
				continue
			}
			from--
			to := v[i+1] - 1
			Sum += math.Sqrt(math.Pow(float64(PosArray[from].x-PosArray[to].x), 2) + math.Pow(float64(PosArray[from].y-PosArray[to].y), 2))
		}
	}
	fmt.Println(Sum / float64(len(Perm)))
}

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

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

func Loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func pow(a, b int) int {
	result := a
	Loop(0, b-1, func(i int) {
		result = result * a
	})

	return result
}

func sqrt(a int) int {
	return int(math.Sqrt(float64(a)))
}

func getPermutationFromLength(i int) []int {
	result := make([]int, i)
	Loop(0, i, func(i int) {
		result[i] = i + 1
	})
	return result
}

func getAllPermutation(source ...int) [][]int {
	Result := make([][]int, 0, len(source))
	for _, v := range source {
		excluded := excludeFromArray(source, v)
		if len(excluded) == 1 {
			Result = append(Result, []int{v, excluded[0]})
		} else {
			a := getAllPermutation(excluded...)
			for _, av := range a {
				o := make([]int, len(av)+1)
				o[0] = v
				for avi, avv := range av {
					o[avi+1] = avv
				}
				Result = append(Result, o)
			}
		}
	}

	return Result
}

func excludeFromArray(i []int, t int) []int {
	Result := make([]int, len(i)-1)
	index := 0
	for _, c := range i {
		if c != t {
			Result[index] = c
			index++
		}
	}
	return Result
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n,k;
cin>>n>>k;
map<int, int> sunuke;
ll d;
rep(i,k){
    cin>>d;
    int a;
    rep(i, d){
        cin>>a;
        sunuke[a]++;
    }
}
cout << n - sunuke.size() << endl;
return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 2e5 + 100;
char s[N];
int main() {
	int n;
	cin >> n;
	scanf("%s", s + 1);
	int ans = 0;
	for(int i = 1; i <= n; i ++) {
		ans += (s[i] == '.');
	}
	int res = ans;
	for(int i = 1; i <= n; i ++) {
		if(s[i] == '.') ans --;
		else ans ++;
		res = min(res, ans);
	}
	cout << res << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;



int dp[3010][3010];

int main(){
string S,T; cin >> S >> T; int n = (int) S.size();  int m = (int) T.size();
  
  for(int i = 0; i < 3010; i++){
    for(int j = 0; j < 3010; j++){
      dp[i][j] = 0;}}
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m ; j++){
      if(S[i] == T[j]){
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + 1);}
      
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j]);
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1]);
                       }}
                      
   string res = "";
  
 int a = n - 1; int b = m - 1;
  
  while( a >= 0 && b >= 0){
    if(dp[a+1][b+1] == dp[a+1][b]){b--;}
    else if( dp[a+1][b+1] == dp[a][b+1]){ a--;}
    else{ 
       res = S[a] + res; a--; b--;}}
  
  cout << res << endl; return 0;}
    
    
    


Measured memory_bytes: 35712
s = input()
m = int(input())
for i in range(m):
    com, *lw = map(str, input().split())
    if com == "replace":
        s = s[:int(lw[0])] + lw[2] + s[int(lw[1]) + 1:]
    if com == "reverse":
        t = s[int(lw[0]):int(lw[1]) + 1]
        s = s[:int(lw[0])] + t[::-1] + s[int(lw[1]) + 1:]
    if com == "print":
        print(s[int(lw[0]):int(lw[1]) + 1])



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

int main() {
	int n, m;
	vector<double> A;
	
	cin >> n >> m;
	double total=0;
	for (int i=0; i<n;i++) {
		double temp;
		cin >> temp ;
		A.push_back(temp);
		total += temp;
	}

	int cnt=0;
	for (auto iter=A.begin(); iter != A.end();iter++) {
		if (*iter >= total/(4.0*m)){
			cnt++;
		}
	}

	string ans = "No";
	if (cnt >= m) {
		ans = "Yes";
	}
	cout << ans << endl;

}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  vector<ll>l(n+1),r(n+1),b(n+1);
  rep(i,0,n){
    l[i+1]=l[i]+max(0LL,a[i]);
    r[n-i-1]=r[n-i]+max(0LL,a[n-i-1]);
    b[i+1]=b[i]+a[i];
  }
  rep(i,0,n-k+1){
    chmax(res,l[i]+r[i+k]+max(0LL,b[i+k]-b[i]));
    //cout<<l[i] spa r[i+k] spa b[i+k] spa b[i]<<endl;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cstring>
# define mod 1000000007
using namespace std;
typedef long long ll;
ll dp[100009][13];
int main(){
	string s;
	cin>>s;
	memset(dp,0,sizeof(dp));
	if(s[0]=='?')
		for(int i=0;i<10;i++)
			dp[0][i]=1;
	else
		dp[0][s[0]-'0']=1;
		int len=s.length();
	for(int i=1;i<len;i++)
	{
		if(s[i]=='?')
		{
			for(int j=0;j<13;j++)
				for(int k=0;k<10;k++)
				{
					dp[i][(j*10+k)%13]+=dp[i-1][j];
					dp[i][(j*10+k)%13]%=mod;
				}
		}
		else
		{
			for(int j=0;j<13;j++)
			{
				dp[i][(s[i]-'0'+j*10)%13]+=dp[i-1][j];
				dp[i][(s[i]-'0'+j*10)%13]%=mod;
			}
		}
	}
		 cout<<dp[len-1][5]<<endl;
	return 0;
} 

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

int main() {
  char c;
  cin >> c;
  if(c == 'A')cout << "T" << endl;
  if(c == 'T')cout << "A" << endl;
  if(c == 'G')cout << "C" << endl;
  if(c == 'C')cout << "G" << endl;
}


Measured memory_bytes: 3548
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, lint b) {
	T res(1);
	while(b){
		if(b&1)res*=a;
		a*=a;
		b>>=1;
	}
	return res;
}
lint modpow(lint a, lint b, lint m) {
	lint res(1);
	while(b){
		if(b&1){
			res*=a;res%=m;
		}
		a*=a;a%=m;
		b>>=1;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size()){
		std::cout << vec[i];
		std::cout<<(i==(int)vec.size()-1?"\n":" ");
	}
}
template<typename T>
void printArray(T l, T r) {
	T rprev = std::prev(r);
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
LP extGcd(lint a,lint b) {
	if(b==0)return {1,0};
	LP s=extGcd(b,a%b);
	std::swap(s.first,s.second);
	s.second-=a/b*s.first;
	return s;
}
LP ChineseRem(const lint& b1,const lint& m1,const lint& b2,const lint& m2) {
	lint p=extGcd(m1,m2).first;
	lint tmp=(b2-b1)*p%m2;
	lint r=(b1+m1*tmp+m1*m2)%(m1*m2);
	return std::make_pair(r,m1*m2);
}
template<typename F>
inline constexpr decltype(auto) lambda_fix(F&& f){
	return [f=std::forward<F>(f)](auto&&... args){
		return f(f,std::forward<decltype(args)>(args)...);
	};
}
#line 2 "main.cpp"
int main(){
	std::string S;
	std::cin>>S;
	if(S.back()=='s')std::cout<<S<<"es"<<std::endl;
	else std::cout<<S<<"s"<<std::endl;
	return 0;
}

Measured memory_bytes: 3600
n,k=map(int,input().split())
a=list(map(int,input().split()))
current=[0]
dic={}
dic[0]=1
ans=0
for i in range(n):
  current.append((current[-1]+a[i]-1)%k)
  if i>=k-1:
    dic[current[-k-1]]-=1
  if current[-1] in dic:
    ans+=dic[current[-1]]
    dic[current[-1]]+=1
  else:
    dic[current[-1]]=1
print(ans)

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll n, i, j;
    cin >> n;
    vector< ll >v1(n),v2(n),v(n);
    for(i = 0; i < n; i++)cin>>v1[i];
    for(i = 0; i < n; i++)cin>>v2[i];
    iota(all(v),1);
    
    ll c1 = 0,c2 = 0,cur = 0;
    do{
        cur++;
        rep(i,0,n){
            if(v[i] != v1[i])break;
        }
        if(i == n)c1 = cur;
        rep(i,0,n){
            if(v[i] != v2[i])break;
        }
        if(i == n)c2 = cur;
    }
    while(next_permutation(all(v)));
    cout << abs(c1-c2) << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

#define MOD 1000000007
typedef long long ll;

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1) ;
    divisor  *= i;
  }
  return dividend / divisor;
}

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

ll divmod(ll a, ll b) {
  return (a * 1LL * mod_pow(b, MOD - 2)) % MOD;
}

ll factorial(ll n) {
  if (n > 0) {
    return n * factorial(n-1) % MOD;
  } else {
    return 1LL;
  }
}

ll nCr(ll n, ll r) {
  if (n < r) return 0;
  return divmod(factorial(n), factorial(r) * factorial(n-r) % MOD);
}

int main() {
  int K, N;
  cin >> N >> K;
  for (int i = 1; i <= K; i++) {
    if (N-K+1 < i || K-1 < i-1) cout << "0" << endl;
    else cout << (nCr(K-1, i-1) * nCr(N-K+1, i)) % MOD << endl;
    //else cout << (combination(K-1, i-1) * combination(N-K+1, i)) % MOD << endl;
  }
  return 0;
}


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

int main(){
 string s;
 cin >> s;
 int len = s.size();
 long long ans = 0;

 for(int bit = 0; bit < (1<<(len-1)); bit++)
 {
   long long num = s[0] - '0';
   for(int i = 0; i < len-1; i++)
   {
     if(bit&(1<<i)){
       ans += num;
       num = 0;
     }
     num = num*10 + (s[i+1] - '0');
   }
   ans += num;
   //cout << bit<< " " << ans << endl;
 }

 cout << ans << endl;

 return 0;
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int x3 = x2 + y1 - y2;
  int y3 = y2 + x2 - x1;

  int x4 = x3 - (x2 - x1);
  int y4 = y3 - (y2 - y1);

  cout << x3 << " " << y3 << " " << x4 << " " << y4;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N){
    if (N <= 6 && N != 5) {
        if (N == 3) {
            cout << "2 5 63" << endl;
        } else if (N == 4) {
            cout << "2 5 20 63" << endl;
        } else if (N == 6) {
            cout << "2 5 20 63 180 360" << endl;
        }
        return;
    }
    vector<int> two = {2,4,6}, three = {3,9}, five;
    int remain = N - 5;
    int current = 8;
    while (remain > 2 && current+4 <= 30000) {
        two.push_back(current);
        two.push_back(current+2);
        two.push_back(current+4);
        current += 6;
        remain -= 3;
    }
    while (remain % 2 != 0) {
        two.pop_back();
        two.pop_back();
        two.pop_back();
        remain += 3;
    }
    current = 15;
    while (remain > 0 && current+6 <= 30000) {
        three.push_back(current);
        three.push_back(current+6);
        current += 12;
        remain -= 2;
    }
    if (remain > 0) {
        while (two.size() % 5 != 0) {
            rep(i,0,3) {
                two.pop_back();
                remain++;
            }
        }
        while (three.size() % 5 != 0) {
            rep(i,0,2) {
                three.pop_back();
                remain++;
            }
        }
        rep(i,1,30001) {
            if (remain == 0) break;
            if (i % 5 == 0 && i % 2 != 0 && i % 3 != 0) {
                five.push_back(i);
                remain--;
            }
        }
    }
    vector<int> answer = two;
    copy(all(three), back_inserter(answer));
    copy(all(five), back_inserter(answer));
    rep(i,0,N) {
        cout << answer[i] << (i==N-1 ? "\n" : " ");
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> b;
	for (int i = n; i >= 1; i--) {
		if (!a[i - 1]) continue;
		b.push_back(i);
		for (int j = 1; j < i; j++) {
			if (j * j > i) break;
			if (i % j) continue;
			a[j - 1] ^= 1;
			if (j * j < i) {
				a[i / j - 1] ^= 1;
			}
		}
		// for (int j = 0; j < n; j++) {
		// 	cout << a[j] << " \n"[j == n - 1];
		// }
	}
	cout << b.size() << endl;
	for (int i = 0; i < b.size(); i++) {
		cout << b[i] << " \n"[i == b.size() - 1];
	}
	return 0;
}

Measured memory_bytes: 2424
from collections import deque
H,W=map(int,input().split())
Map=[list(input()) for i in range(H)]
for h in range(H):
  Map[h].insert(0,"#")
  Map[h].append("#")
Map.insert(0,["#"]*(W+2))
Map.append(["#"]*(W+2))
white=sum(Map[i].count(".") for i in range(H+2))

Que=deque([(1,1,1)])
visited=[[10**10]*(W+2) for i in range(H+2)]
while Que:
  x,y,stage=Que.popleft()
  if x==W and y==H:
    print(white-stage)
    exit()
  stage+=1
  for i,j in ((x+1,y),(x-1,y),(x,y+1),(x,y-1)):
    if Map[j][i]=="." and stage<visited[j][i]:
      visited[j][i]=stage
      Que.append((i,j,stage))
print(-1)

Measured memory_bytes: 40048
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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); }

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

  int n, q;
  string s;
  cin >> n >> q >> s;

  vector<int> check(n, 0);
  rep(i, 1, n) {
    if (s[i - 1] == 'A' && s[i] == 'C')
      check[i] = check[i - 1] + 1;
    else
      check[i] = check[i - 1];
  }

  while (q--) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    cout << check[r] - check[l] << endl;
  }
}


Measured memory_bytes: 3848
import numpy as np
def main():
    mod = 1000000007
    n = int(input())
    A = np.array(list(map(int, input().split())), dtype = np.int)
    ans = 0
    for i in range(61):
        n1 = np.sum((A >> i) & 1)
        tmp = (n - n1) * n1
        for _ in range(i):
            tmp = (tmp * 2) % mod
        ans += tmp
    print(ans % mod)

if __name__ == '__main__':
    main()


Measured memory_bytes: 48824
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  string s;
  cin >> s;
  if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
    cout << "Yes" << endl;
  } else  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 764
//楽しいカードゲーム
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
#define MP make_pair
#define PB push_back
#define F_d first
#define S_d second
#define LARGE 100000000
#define MOD 100000
#define LL long long

int A, B, a[5009], b[5009], ans = 0;
int main() {
	cin >> A >> B;
	for (int i = 0; i < A; i++)cin >> a[i];
	for (int i = 0; i < B; i++)cin >> b[i];

	for (int i = 0; i < B; i++) {
		int tmp = 0;
		for (int j = 0; j < A; j++) {
			if (a[j] == b[i + tmp]) tmp++;
		}
		ans = max(tmp, ans);
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 3140
N = int(input())
money = []
for i in range(N):
    money.append(list(input().split()))

total = 0.0
for i in range(N):
    if money[i][1] == 'JPY':
        total += float(money[i][0])
    else:
        total += 380000.0*float(money[i][0])

print(total)



Measured memory_bytes: 2940
import sys

N = int(input())
S = input()

# N = 6
# S = 'abcabc'

if N % 2 == 1:
    print('No')
    sys.exit()

l = list(S)

# front = l[0:int(len(l) /2)]
# print(front)
# rear = l[int(len(l) / 2) : ]
# print(rear)

if l[0:int(len(l) /2)] == l[int(len(l) / 2):]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n-1];
        for (int i = 0; i < n; i++) a[i] = sc.nextInt()-1;
        for (int i = 0; i < n; i++) b[i] = sc.nextInt();
        for (int i = 0; i < n-1; i++) c[i] = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += b[a[i]];
            if(0 < i && a[i] - 1 == a[i-1]) ans += c[a[i-1]];
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 21844
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$a = trim($key->A[0]);
while(1) {
  $a = substr($a,0,-1);
  //偶数でないとだめ
  if (strlen($a)%2!=0) continue;
  $len = strlen($a);
  if (strcmp(substr($a,($len/2),$len/2),substr($a,0,$len/2))==0) {
    printf("%d\n",$len);
    exit;
  }

}


Measured memory_bytes: 3828
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)


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

    int x; cin >> x;
    if(x == 1){
        cout << 1 << endl;
        return 0;
    }
    int ans = -1;
    for(int i = 2; i*i <= x; ++i){
        int tmp = i;
        while(tmp <= x) tmp *= i;
        tmp /= i;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;
#define MAXN 1E5 + 10
using namespace std;

int n;
 
vector<pii> t(2 * MAXN , { -1 , INF });

auto f(const pii& a , const pii& b)
{
	return a.fi > b.fi || (a.fi == b.fi && a.se < b.se) ? a : b;
}
 
void build(){
	for(int i = n - 1 ; i > 0 ; --i){
		t[i] = f(t[2 * i] , t[2 * i + 1]);
	}
}
 
void modify(int p , int val){
	for(t[p += n] = { val , p } ; p > 1 ; p /= 2){
		t[p / 2] = f(t[p] , t[p ^ 1]);
	}
}
 
pii query(int l , int r){//[l , r)
	pii res = { -1 , INF };
	for(l += n , r += n ; l < r ; l /= 2 , r /= 2){
		if(l % 2){
			res = f(res , t[l]);
			++l;
		}
		if(r % 2){
			--r;
			res = f(res , t[r]);
		}
	}
	return res;
}

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

	cin >> n;
	
	rep(i , n)
	{
		cin >> t[n + i].fi;
		t[n + i].se = i;
	}
	
	build();
	
	int ans = 0;
	
	while(query(0 , n).fi != -1)
	{
		int r = n;
		for(;;)
		{
			auto cur = query(0 , r);
			if(cur.fi == -1) break;
			
			modify(cur.se , -1);
			r = cur.se;
		}
		
		++ans;
	}
	
	cout << ans << nl;

	return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  string ans;
  int ab = a - b;
  int bc = b - c;
  int ca = c - a;
  if(ab*bc*ca == 0){
    ans = "Yes";
    if(ab == bc && bc == ca){
      ans = "No";
    }
  }
  else{
    ans = "No";
  }
  
  cout << ans << endl;
}

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


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll n,m,v,p; 
vll a;
bool isOk(ll mid){
  if(mid<=p-1) true;
  ll point=a[mid]+m;
  if(a[p-1]>point) return false;
  ll total=(p-1)*m+(n-mid)*m;
  irep(i,p-1,mid){
    // mid と 同じスコアになる or 最大m票 まで目一杯票を入れる
    total+=min(m,point-a[i]);
  }
  // [p-1,mid) までの a[i] が、a[mid] と同じスコアになるために必要な票数が全投票数以上になる
  // => a[mid] は採用される
  // 逆に [p-1,mid) が a[mid] と同じスコアになるための票数が全投票数未満なら、[p-1,mid) のどれかが a[mid] よりスコアが大きくなる
  return total>=m*v;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>m>>v>>p;
  a.resize(n);
  rep(i,n) cin>>a[i];
  sort(a.rbegin(),a.rend());
  ll ans=p;
  ll ok=-1, ng=n;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(isOk(mid)) ok=mid;
    else ng=mid;
  }
  cout<<ok+1<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){

    int h, a;
    int i;
    i = 0;

    scanf("%d",&h);
    scanf("%d",&a);

    while(h > 0){
        h -= a;
        i += 1;
    }

    printf("%d",i);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{
    vector<int> par;
    vector<int> sizes;

    UnionFind(int size) : par(size), sizes(size,1){
        for(int i=0;i<size;i++) par[i] = i;
    }

    bool unite(int x,int y){
        x = find(x);
        y = find(y);

        if(x == y) return false;
        if(sizes[x] < sizes[y]) swap(x,y);

        par[y] = x;
        sizes[x] += sizes[y];
        sizes[y] = 0;

        return true;
    }

    int find(int x){
        if(par[x] == x) return x; 
        return par[x] = find(par[x]);
    }

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

    int getSize(int x){
        return sizes[find(x)];
    }
};

int main(){
    
    int N, Q;
    cin >> N >> Q;
    UnionFind uf(N);
    for(int i=0;i<Q;i++){
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0) uf.unite(x, y);
        else cout << uf.same(x, y) << endl;
    }
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
 
#define ll long long 
# define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std ;
 
ll z , o , ans ;

ll N = 1e4 + 15820 ;

int main(){ skorost ;

	int n , l ;

	cin >> n >> l ;

	string a[n] ;

	for( int i = 0 ; i < n ; i ++ ){

		cin >> a[i] ;

	}

	sort(a,a+n);

	for( int i = 0 ; i < n ; i ++ ){

		cout << a[i] ;

	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

bool judge(vector<int> v){
  for(int i=1;i < (ll)v.size();i++)
  {
    if(v[i]<v[i-1])return false;
  }
  return true;
}

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

  for(int i=0;i < n;i++)
  {
    for(int j=0;j < n;j++)
    {
      u=v;
      swap(u[i],u[j]);
      if(judge(u)) {
        cout<<"YES"<<endl;
        return 0;
      }
    }
  }

  cout<<"NO"<<endl;


}

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

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

  int n;
  cin >> n;

  if (n & 1) cout << 2*n << '\n';
  else cout << n << '\n';

  return (0);
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5, m = 1e9 + 7;
int h, w, dg[1000][1000];
char g[1000][1000];
int main()
{
    cin >> h >> w;
    for(int i=0; i<h; ++i)
        for(int j=0; j<w; ++j)
            cin >> g[i][j];
    for(int i=0; i<w; ++i){
        if( g[0][i] == '#' )
            break;
        dg[0][i] = 1;
    }
    for(int i=0; i<h; ++i){
        if( g[i][0] == '#' )
            break;
        dg[i][0] = 1;
    }
    for(int i=1; i<h; ++i)
        for(int j=1; j<w; ++j){
            dg[i][j] = (dg[i-1][j] + dg[i][j-1])%m;
            if( g[i][j] == '#' )
                dg[i][j] = 0;
        }
    cout << dg[h-1][w-1];
    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)

using namespace std;

int main(){
	long long N, K;
	cin >> N >> K;
	vector<long long> H;
	rep(i, N) {
		long long tmp;
		cin >> tmp;
		H.push_back(tmp);
	}
	sort(H.begin(), H.end(), greater<long long>());

	if(H.size() <= K) {
		cout << 0 << endl;
	} else {
		long long ans = 0;
		for(long long i = K; i < H.size(); i++) {
			ans += H[i];
		}
		cout << ans << endl;
	}
}

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

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

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

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


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

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

  int N;
  cin >> N;
  VL xs(N);
  cin >> xs;

  LL ans = 0;
  map<LL,LL> dp;
  ++dp[0];
  LL acc = 0;
  for(auto x: xs){
	acc += x;
	if(dp.count(acc))
	  ans += dp[acc];
	++dp[acc];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 14336
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

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

const int INF = 1<<30;

int main(){
  ll n;cin>>n;
  ll ans=ll(1e13);
  for(ll i=1LL;i<=sqrt(double(n));i++){
    if(n%i==0){
      ans = min(ans, i+n/i);
    }
  }
  ans -= 2LL;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-09-13
**/

#include <bits/stdc++.h>
using namespace std;


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<long long> x(n), y(n);
	vector<vector<pair<long long,int>>> sums(4, vector<pair<long long,int>> (n));
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		for (int j = 0; j < 4; j++) {
			long long x1 = j / 2 == 0 ? x[i] : -x[i];
			long long y1 = j % 2 == 0 ? y[i] : -y[i];
			sums[j][i] = {x1 + y1, i};
		}
	}
	for (int j = 0; j < 4; j++) {
		sort(sums[j].begin(), sums[j].end());
	}

	vector<pair<long long,int>> s;
	for (int j = 0; j < 4; j++) {
		s.push_back(sums[j][0]);
		s.push_back(sums[j][n-1]);
	}
	long long ans = 0;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < s.size(); j++) {
			int i1 = s[i].second, i2 = s[j].second;
			ans = max(ans, abs(x[i1] - x[i2]) + abs(y[i1] - y[i2]));
		}
	}
	cout << ans << '\n';

	return 0;	
}


Measured memory_bytes: 21924