akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    vec<lint> D_list(N);
    range(i, 0, N) cin >> D_list.at(i);
    sort(D_list.begin(), D_list.end());
    vec<lint> best = {0};
    range(i, 0, N) {
        lint D = D_list.at(i);
        best.emplace_back((i % 2 ? D : -D));
    }
    lint s = 1LL << 58;
    range(i, 0, N) range(j, i + 1, N + 1) {
        lint diff = abs(best.at(i) - best.at(j));
        s = min(s, min(diff, 24 - diff));
    }
    cout << s << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define N 100000

typedef struct {
    int p,k,dep;
    int *c;
} Node;


int main(){
    int i,j,n,id;
    Node T[N],tmp;
    
    scanf("%d",&n);
    
    for(i=0; i<n; i++){
        T[i].p = -1;
        T[i].dep = 0;
    }
    
    for(i=0; i<n; i++){
        scanf("%d",&id);
        scanf("%d",&T[id].k);
        T[id].c = (int *)malloc(sizeof(int)*T[id].k);
        
        for(j=0; j<T[id].k; j++){
            scanf("%d",&T[id].c[j]);
            T[T[id].c[j]].p = id;
        }
    }
    
    for(i=0; i<n; i++){
        tmp = T[i];
        
        while(1){
            if(tmp.p==-1) break;
            T[i].dep++;
            tmp = T[tmp.p];
        }
    }
    
    for(i=0; i<n; i++){
        if(T[i].dep==0){
            printf("node %d: parent = %d, depth = %d, root, [",i,T[i].p,T[i].dep);
            for(j=0; j<T[i].k-1; j++) printf("%d, ",T[i].c[j]);
            if(T[i].k!=0) printf("%d]\n",T[i].c[j]);
            else printf("]\n");
        }
        
        else if(T[i].k!=0 && T[i].p!=-1){
            printf("node %d: parent = %d, depth = %d, internal node, [", i,T[i].p,T[i].dep);
            for(j=0; j<T[i].k-1; j++) printf("%d, ", T[i].c[j]);
            printf("%d]\n",T[i].c[j]);
        }
        
        else if(T[i].k==0) printf("node %d: parent = %d, depth = %d, leaf, []\n",i,T[i].p,T[i].dep);
    }
    
    return 0;
}

Measured memory_bytes: 6456
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)

/*
template <typename T = long long>
class UnionFind {
  std::vector<T> data;

public:
  UnionFind(T size) {
    data.resize(size);
    std::iota(data.begin(), data.end(), 0);
  }

  bool unite(T x, T y) {
    x = find(x), y = find(y);
    if(x == y) return false;
    if(
*/


struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(M), B(M);
  rep (i, M) cin >> A[i] >> B[i];

  UnionFind clusters(N);

  vector<ll> ans(M+1);
  for (ll i = M; i > 0; --i) {
    if (i == M) {
      ans[i] = N * (N-1) / 2;
      continue;
    }
    else {
      ans[i] = ans[i+1];
    }
    ll convenience = clusters.size(A[i]-1) * clusters.size(B[i]-1);
    if (clusters.unite(A[i]-1, B[i]-1)) ans[i] -= convenience;
  }
  for (ll i = 1; i <= M; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 5496
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int x,y; cin >>x >>y;
  if(y%2) cout <<"No";
  else if(y<2*x||y>4*x) cout <<"No";
  else cout <<"Yes";
return 0;}

Measured memory_bytes: 3640
import java.io.*;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] num;
		int sum;
		
		do {
			sum = 0;
			num = br.readLine().split("");
			
			for (String str : num) sum += Integer.valueOf(str);
			
			if (sum == 0) break;
			
			System.out.println(sum);

		} while (true);
		
	}
}

Measured memory_bytes: 25268
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define MOD (long) 1000000007
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end());
#define MAX(vec) *max_element(vec.begin(), vec.end());
#define IN(n,m)  (!(m.find(n) == m.end()))

using namespace std;
typedef long long LL;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef map<LL,long> mp;
typedef map<LL,mp> mmp;

mmp memo;
long rec(LL S,LL X){
	if (IN(S,memo) && IN(X,memo[S])) return memo[S][X];
	if (X == 0) return (S+1);
	if (S == 1) return 2L;
	long val = rec(S/2,X/2) % MOD;
	if (S >= 1 && X >= 1) val += (rec((S-1)/2,(X-1)/2)%MOD);
	if (S >= 2) val += (rec((S-2)/2,X/2)%MOD);
	return memo[S][X] = val;
}
int main(void){
	LL N;
	cin >> N;
	cout << rec(N,N)%MOD << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

c = [[0]*3] * 3

for i in range(3):
    c[i] = list(map(int, input().split()))

c = np.array(c)

if len(set(c[0] - c[1])) == 1 and len(set(c[1] - c[2])) == 1 and len(set(c[:,0] - c[:,1])) == 1 and len(set(c[:,1] - c[:,2])) == 1:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 12488
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int main(){
	int N, R;
	int ans;
	cin >> N >> R;

	if (N >= 10){
		ans = R;
	}
	else{
		ans = (100 * (10 - N)) + R;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    children=[]
    n,x = map(int,input().split())
    children=list(map(int,input().split()))
    sorted_chiledren=sorted(children)
    counter=0
    last=x

    if sum(children) == x:
        print(n)
        exit()
    elif min(children) > x:
        print(0)
        exit()

    for idx,data in enumerate(sorted_chiledren):
        if data < last:
            last-=data
            counter+=1
            if idx+1==n:
                print(counter-1)
                exit()
        elif data == last:
            counter+=1
            print(counter)
            exit()
        else:
            print(counter)
            break

    
if __name__=="__main__":
    main()

Measured memory_bytes: 9236
from collections import deque

n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = -1000000000
for i in range(n):
    now = i
    j = 0
    score = deque([0])
    while j < k:
        score.append(score[j] +c[p[now]-1])
        now = p[now]-1
        j += 1
        if now == i:
            break
    ans = max(ans, max(list(score)[1:]))
    if j < k and score[-1] > 0:
        loop_num = k//j
        rest = k%j
        ans = max(ans, max(list(score)[:rest+1])+loop_num*score[-1] )
        ans = max(ans, max(list(score))+(loop_num-1)*score[-1] )
print(ans)
        

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

class FiftyFifty{
	string str;
	bool judgment0();
	bool judgment1();
public:
	FiftyFifty(string str0);
	void print();
};

FiftyFifty::FiftyFifty(string str0){
	str = str0;
}
//ユニーク数が2ならTRUE
bool FiftyFifty::judgment0(){
	bool ret = true;
	
	//配列vecにユニークな文字を格納
	vector<char> vec;
	vec.push_back(str[0]);
	for(int i = 1; i < str.length(); i++){
		for(int j = 0; j < vec.size(); j++){
			if(str[i] == vec[j]){
				break;
			}
			else if(j == vec.size() - 1){
				vec.push_back(str[i]);
			}
		}
	}
	
	//配列vecの要素数が2かどうかを格納
	ret = vec.size() == 2 ? true : false;
	
	return ret;
return false;
}
//0番目の文字と同じ文字が計2文字ならTRUE
bool FiftyFifty::judgment1(){
	bool ret;
	int count = 1;
	for(int i = 1; i < str.length(); i++){
		if(str[0] == str[i]){
			count++;
		}
	}
	ret = count == 2 ? true : false;
	return ret;
}
//入力値が正しいかどうかを出力
void FiftyFifty::print(){
	bool jdg0 = judgment0();
	bool jdg1 = judgment1();
	//テスト出力
	//cout << jdg0 << endl << jdg1 << endl;
	if(jdg0 && jdg1){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

int main(void){
	string str;
	cin >> str;
	FiftyFifty fif(str);
	fif.print();
return 0;
}

Measured memory_bytes: 256
s = input()
n=len(s)
s+='R'
k=0

c=[0]*n
z=0
for i in range(n):
    k+=1
    if s[i]=='R' and s[i+1]=='L':
        z=i
        p=k
    if s[i]=='L' and s[i+1]=='R':
        if k%2:
            if p%2:
                c[z]=(k+1)//2
                
                c[z+1]=(k-1)//2
            else:
                c[z]=(k-1)//2
                
                c[z+1]=(k+1)//2
                
        else:
            c[z]=k//2
            c[z+1]=k//2
        k=0
print(*c)
                
    

Measured memory_bytes: 78832
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<ll> cnt(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i]--;
    cnt[a[i]]++;
  }
  ll total = 0;
  for (int i = 0; i < n; ++i) {
    total += cnt[i] * (cnt[i] - 1) / 2;
  }
  for (int i = 0; i < n; ++i) {
    ll ans = total;
    ans -= cnt[a[i]] * (cnt[a[i]] - 1) / 2;
    ans += max(0ll, (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
int main(void) {
    string s; cin >> s;
    map<char,int> mp;
    rep(i,4) {
        mp[s[i]]++;
    }
    bool flag = true;
    auto begin = mp.begin(), end = mp.end();
    for(auto iter = begin; iter != end; iter++) {
        if(iter->second != 2) flag = false;
    }
    if(flag) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main{
	static int V;
	static int []match;
	static boolean []used;
	static Map<Integer, List<Integer>> G = new HashMap<Integer, List<Integer>>();
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int E = sc.nextInt();
		int []x = new int[E];
		int []y = new int[E];
		for(int i = 0; i < E; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		sc.close();
		V = X + Y;
		match = new int[V];
		used = new boolean[V];
		for(int i = 0; i < E; i++) {
			y[i] += X;
			if(G.containsKey(x[i])) {
				G.get(x[i]).add(y[i]);
			}else {
				List<Integer> list = new ArrayList<Integer>();
				list.add(y[i]);
				G.put(x[i], list);
			}
			if(G.containsKey(y[i])) {
				G.get(y[i]).add(x[i]);
			}else {
				List<Integer> list = new ArrayList<Integer>();
				list.add(x[i]);
				G.put(y[i], list);
			}
		}
		int max = bipatricleMatching();
		System.out.println(max);
	}
	static boolean dfs(int v) {
		used[v] = true;
		if(!G.containsKey(v)) return false;
		for(int i = 0; i < G.get(v).size(); i++) {
			int u = G.get(v).get(i);
			int w = match[u];
			if(w < 0 || (!used[w] && dfs(w))) {
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}
	static int bipatricleMatching() {
		int res = 0;
		Arrays.fill(match, -1);
		for(int v = 0; v < V; v++) {
			if(match[v] < 0) {
				Arrays.fill(used, false);
				if(dfs(v)) res++;
			}
		}
		return res;
	}
}


Measured memory_bytes: 51048
#include<bits/stdc++.h>
using namespace std;
long long dp[100][100005];
  long long wt[1000];
  long long v[1000];
 long long n,w;
long long solve(long long j,long long wg){
//base case
  if(j==n||wg<=0){
    return 0;
  }
  
    if(dp[j][wg]!=-1){
    return dp[j][wg]; 
  }
 long long o1=0;
 long long o2=0;
  
  if(wt[j]<=wg){
 o1=v[j]+solve(j+1,wg-wt[j]);

  }
o2=solve(j+1,wg);

  
    return dp[j][wg]=max(o1,o2);
    
 }
  
int main(){
   memset(dp, -1, sizeof(dp)); 
   memset(wt, -1, sizeof(wt)); 
   memset(v, -1, sizeof(v)); 
 
  cin>>n>>w;

  for(int i=0;i<n;i++)
    cin>>wt[i]>>v[i];
 
  cout<<solve(0,w);
 
  return 0;
  
}


Measured memory_bytes: 81784
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define F first
#define S second
#define mod 1000000007
///distance(s.begin(),s.lower_bound(101))
using namespace std;
///dp[i][j]=j lessons skipped in first i days.
///mn[i][j]=min hours needed to spend in ith day to skip skip exactly j lessons.



int main(){
    ll x;cin >>x;
    ll ans=0;
    ll curr=x/500;
    ans+=(curr*1000);
    x=x%500;
    curr=x/5;
    ans+=(curr*5);
    cout <<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n;
    cin>>n;
    int v[n],c[n];
    rep(i,n)cin>>v[i];
    rep(i,n)cin>>c[i];
    int res=0;
    rep(i,n){
        res += max(0,v[i]-c[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_harshad_number(void) {
	int n,m;
	int wa = 0;
	string judge = "No";
	cin >> n;
	m = n;
	while (true) {
		wa += (n % 10);
		n /= 10;
		if (n == 0) break;
	}

	if (m % wa == 0) judge = "Yes";

	cout << judge << endl;
}

int main()
{
	b_harshad_number();
    return 0;
}

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

    if temp!=1:
        arr.append(1)

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

    return arr
N = int(input())
if N == 1:
    print(0)
else:
    b = factorization(N)
    count = 0
    for i in b:
        j = 1
        while(1):
            i -= j
            if i<0:
                break
            else:
                count += 1
                j += 1
    print(count)

Measured memory_bytes: 27148
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
  int n;
  cin>>n;
  map<string,int>mp;
  rep(i,n){
    string s; 
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll ans=0;
  for(auto p:mp){
    ans+=p.second*(ll)(p.second-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main()
{
    string s;
    cin >> s;
    set<char> st;
    for (auto c : s)
        st.insert(c);
    if (st.size() == 2)
    {
        puts("Second");
        return 0;
    }

    if (s.front() == s.back())
    {
        if (s.size() % 2 == 0)
        {
            puts("First");
        }
        else
        {
            puts("Second");
        }
    }
    else
    {
        if (s.size() % 2 == 0)
        {
            puts("Second");
        }
        else
        {
            puts("First");
        }
    }
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = 1e9 + 7;

string s, t;

int main()
{
  ios::sync_with_stdio(0); cin.tie(0);
  cin >> s >> t;
  int lens = s.length();
  int lent = t.length();
  int ans = 1e9;
  for (int i = 0; i + lent - 1 < lens; i++) {
    int cnt = 0;
    for (int j = 0; j < lent; j++) {
      if (t[j] != s[i + j]) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << E;
  //system("pause");
  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    int c = a * b;

    if (c % 2 == 1)
    {
    	// 出力
    	cout << "Odd" << endl;
    }
  	else
    {
    	// 出力
    	cout << "Even" << endl;      
    }
    return 0;
} 


Measured memory_bytes: 256
n = int(input())
a = sorted(list(map(int, input().split())))
an = a[-1]
a = a[:n - 1]
res = 10 ** 9
ans = 0
if an % 2 == 0:
    mid_l = an // 2
    mid_r = an // 2
else:
    mid_l = an // 2
    mid_r = (an + 1) // 2

for i in range(n - 1):
    if a[i] <= mid_l:
        if mid_l - a[i] < res:
            ans = a[i]
            res = mid_l - a[i]
    elif mid_r <= a[i]:
        if a[i] - mid_r < res:
            ans = a[i]
            res = mid_r - a[i]

print(an, ans)


Measured memory_bytes: 19984
#include <iostream> pre processor directive
#include <string>
#include <iomanip>
using namespace std;
int main()
{
  int H,A;
  cin>>H>>A;
  int counter=0;
  for (int i=H;i>=0;i--){
    H-=A;
    counter++;
    if (H<=0){
        break;
    }
  }
  cout<<counter<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main()
{
  long double l;
  cin >> l;
  long double ans;
  l = l*l*l;
  ans = l / 27;
  cout << fixed << setprecision(10);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
vector<long long> dp,h;
long long flog(long long i){
    if(dp[i]!=-1){
        return dp[i];
    }
    if(i==0){
        return dp[0]=0;
    }
    if(i==1){
        return dp[1]=abs(h[1]-h[0]);
    }else{
        return dp[i]=min(flog(i-1)+abs(h[i]-h[i-1]),flog(i-2)+abs(h[i]-h[i-2]));
    }
}
int main(void){
    // Your code here!
    int n;cin>>n;
h.assign(n,0);
dp.assign(n,-1);
for(int i=0;i<n;i++){
    cin>>h[i];
}
    cout<<flog(n-1)<<endl;
    
    
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)

vector<int> sieve_of_eratosthenes(int n) {
	vector<int> primes(n);
	for (int i = 2; i < n; i++)primes[i] = i;
	for (int i = 2; i*i < n; i++) {
		if (primes[i]) {
			for (int j = i * i; j < n; j += i) primes[j] = 0;
		}
	}

	return primes;
}

int main() {
	ll n, i = 0; cin >> n;
	auto p = sieve_of_eratosthenes(100000);

	while (n) {
		if (p[i] && i % 10 == 1) {
			cout << i << endl;
			n--;
		}
		i++;
	}

	return 0;
}

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

#define fi first
#define se second
#define inf 0x3f3f3f3f
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin(),A.rend()
#define MOD 1000000007
#define int long long
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main(){
	
	int a,b;
	cin >> a >> b;
	if(a==1 or b==1){
		cout << "1\n";
		return 0;
	}
	int x = (a+1)/2;
	int y = (b+1)/2;
	cout << x*y + (a-x)*(b-y) << '\n';
	
	
#ifdef LOCAL_DEFINE
	cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1,mod=1e18;
const int inf=(1ull<<31)-1;
int n;

bool check(int a){
	for (int j=2;j*j<=a;j++)
		if (a%j==0)
			return false;
	return true;
}

int main()
{
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(15);
	cin>>n;
	int i;
	for (i=n;!check(i);i++);
	cout<<i;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        cin >> n;
        if (n == 0) break;
        int ans = 0;
        rep2(i, 1, n) {
            int sum = 0;
            rep2(j, i, n + 1) {
                sum += j;
                if (sum == n) {
                    ans++;
                    break;
                }
                else if (sum > n) break;
            }
        }
        cout << ans << endl;
    }

}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int k;
    cin >> k;
    vector<int> A(k);
    REP(i,k) cin >> A[i];

    bool flg=true;
    ll low=2,high=2;
    for(int i=1;i<=k;++i){
        low=A[k-i]*((low+A[k-i]-1)/A[k-i]);
        if(low>high){flg=false;break;}
        high=A[k-i]*(high/A[k-i])+A[k-i]-1;
    }

    if(flg) cout << low << " " << high << endl;
    else cout << "-1\n";
    return 0;
}


Measured memory_bytes: 640
function main(inputData) {
    var output = [];
    for(var i = 0; i < inputData.length; i++) {
        if(0 != inputData[i]) {
            output.push('Case ' + (i + 1) + ': ' + inputData[i]);
        }
    }
    console.log(output.join('\n'));
  }
  
  process.stdin.resume();
  var input = '';  
  process.stdin.setEncoding('utf-8');
  process.stdin.on('data', function(chunk) {
    input += chunk;
  });
  process.stdin.on('end', function() {
    var inputData = input.split('\n');
    main(inputData);
  });

Measured memory_bytes: 19572
#include<iostream>

using namespace std;

int main(){

  int n,p[100],x=0;

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  for(int i=0;i<n-2;i++){
    if(p[i]<p[i+1] && p[i+1]<p[i+2]){
      x=x+1;
    }
    if(p[i+2]<p[i+1] && p[i+1]<p[i]){
      x=x+1;
    }

  }
  cout<< x <<endl;
  return 0;
}


Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int ll

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , h , a[N] , b[N] , mx , ans ;

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> h ;

	for (int i = 0 ; i < n ; i ++) cin >> a[i] >> b[i] , mx = max(mx , a[i]) ;

	sort(b , b + n , greater <int>()) ;

	for (int i = 0 ; i < n ; i ++) {
		if (h > 0 && b[i] > mx) {
			h -= b[i] ;
			ans ++ ;
		}
	}

	if (h > 0) ans += (h + mx - 1) / mx ;

	cout << ans << '\n' ;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
n = int(input())
s = list(input())

ans = 0
for i in range(1, n):
    tmp1 = s[:i]
    tmp2 = s[i:]
    #print(tmp1, tmp2)
    #print(len(set(tmp1) & set(tmp2)))
    if len(set(tmp1) & set(tmp2)) > ans:
        ans = len(set(tmp1) & (set(tmp2)))
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>

int main(void)

{
	double r;
	double menseki;
	double syuu;
	
	scanf("%lf",&r);
	
	menseki=r*r*3.1415926535897932;
	syuu=2*r*3.1415926535897932;
	
	printf("%lf %lf\n", menseki, syuu);
	
	return (0);
}

Measured memory_bytes: 648
a,b,k=map(int,input().split())
a_st=a
b_st=b
num=[]
cnt=0
for i in range(a,b+1):
    if cnt<k:
        num.append(i)
        cnt+=1
    else:
        break
cnt=0
for i in range(b,a,-1):
    if cnt<k:
        num.append(i)
        cnt+=1
    else:
        break
num2=list(set(num))
num2.sort()
[print(x) for x in num2]

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test(n) cout << "test" << n << endl;
#define fixsp(n) fixed << setprecision(n)
#define defsp(n) defaultfloat << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define iikae auto&
#define vector3D(K, N, M, DP) vector<vector<vector<ll>>> DP(K, vector<vector<ll>>(N, vector<ll>(M)));
#define vector4D(K, N, M, O, DP) vector<vector<vector<vector<ll>>>> DP(K, vector<vector<vector<ll>>>(N, vector<vector<ll>>(M, vector<ll>(O))));
#define zenbu(a) a.begin(), a.end()
#define rzenbu(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long;using ld = long double;using P = pair<ll,ll>;/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}
/* ここからコード開始 */

int main(){
  kyopro;
  ll N, M;
  cin >> N >> M;
  vector<ll> c(M);
  rep(i, 0, N){
    ll K;
    cin >> K;
    rep(i, 0, K){
      ll j;
      cin >> j;
      c[j-1]++;
    }
  }
  ll ans{};
  for(auto&& i : c){
    if(i == N) ans++;
  }
  cout << ans << rt;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
s = []
c = []
ans = [0]*n
for _ in range(m):
  st,ct = map(int,input().split())
  s.append(st)
  c.append(ct)

f = 1
af = [0]*n
for i in range(m):
  if s[i] == 1 and c[i] == 0 and n != 1:
    f = 0
    break
  if af[s[i]-1] == 1 and ans[s[i]-1] != c[i]:
    f = 0
    break
  ans[s[i]-1] = c[i]
  af[s[i]-1] = 1
if f == 0:
  print(-1)
else:
  if ans[0] == 0 and n != 1:
    ans[0] = 1
  print(''.join(map(str,ans)))

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

int main()
{
  string S;
  cin >> S;
  int n = S.length(), num_0 = 0, num_1 = 0;
  for (int i = 0; i<n;i++){
    if (S[i]== '1' ) num_1 ++;
    else num_0 ++;
  }
  cout << 2 * min(num_1, num_0) << endl;
}

Measured memory_bytes: 512
#C
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    return gcd(y,x%y)
def lcm(x,y):
    return x*y//gcd(x,y)
def count(a,b,k):
    cnt=b//k-a//k
    if a%k==0:
        cnt+=1
    return cnt

a,b,c,d=map(int,input().split())
l=lcm(c,d)
print(b-a+1-count(a,b,c)-count(a,b,d)+count(a,b,l))

Measured memory_bytes: 38384
#include <cstdio>

const int MN = 100005;

char s[MN];
int a, b, c, d;

int main() {
	scanf("%s", s + 1);
	for (int i = 1; s[i]; ++i) {
		if (s[i] == 'N') ++a;
		if (s[i] == 'S') ++b;
		if (s[i] == 'E') ++c;
		if (s[i] == 'W') ++d;
	}
	puts((a && !b) || (b && !a) || (c && !d) || (d && !c) ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 128
N=int(input()) 

li_AC = list()
li_TLE = list()
li_WA = list()
li_RE = list()


for i in range(N):
    s=input()
    if 'AC' == s:
        li_AC.append(s)
    if 'RE' == s:
        li_RE.append(s)
    if 'TLE' == s:
        li_TLE.append(s)
    if 'WA' == s:
        li_WA.append(s)

print(f'AC x {len(li_AC)}')

print(f'WA x {len(li_WA)}')
print(f'TLE x {len(li_TLE)}')
print(f'RE x {len(li_RE)}')

Measured memory_bytes: 16220
N = int(input())
W = list(map(int, input().split()))
d = sum(W) / 2
count = 0
for i in range(N):
  count += W[i]
  if count >= d:
    if i == 0:
      print(W[0] - sum(W[1:]))
      break
    else:
      print(min(sum(W[i:]) - sum(W[:i]), sum(W[:i + 1]) - sum(W[i+1:])))
      break
    
    


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        long ans = 0;
        for (int i = 1; i <= k; i++) {
            for (int j = 1; j <= k; j++) {
                for (int l = 1; l <= k; l++) {
                    ans += getGcd(i, getGcd(j, l));
                }
            }
        }
        System.out.println(ans);
    }

    private static int getGcd(int x, int y) {
        return y == 0 ? x : getGcd(y, x % y);
    }
}

Measured memory_bytes: 35760
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const ll MAX=200005;
const ll MOD=998244353;
char s[MAX];
ll n;
ll dp[MAX][3][3],q,fin,c=1,all=1;
ll make_dp(int x,int m,int e){
    if(x==1){
        if(m==e) return 1;
        return 0;
    }
    if(dp[x][m][e]==-1){
        dp[x][m][e]=0;
        for(int i=0;i<3;i++) if(i!=e){
            dp[x][m][e]+=make_dp(x-1,(m-e+3)%3,i),dp[x][m][e]%=MOD;
        }
    }
    return dp[x][m][e];
}
ll power(ll x,ll y){
    if(y==0) return 1;
    if(y==1) return x;
    ll t=power(x,y/2);
    if(y%2) return ((t*t)%MOD*x)%MOD;
    return (t*t)%MOD;
}
int main(){
    ll t;
    scanf(" %s",s);
    n=strlen(s);
    if(n==2){
        if(s[0]!=s[1]) fin=2;
        else fin=1;
    }
    if(n==3){
        if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]) fin=3;
        else if(s[0]==s[1]&&s[1]==s[2]) fin=1;
        else if(s[0]==s[1]||s[1]==s[2]) fin=6;
        else fin=7;
    }
    else{
    for(int i=0;i<=n+1;i++) for(int j=0;j<3;j++) for(int k=0;k<3;k++) dp[i][j][k]=-1;
    for(int i=0;i<n;i++) q+=s[i]-'a';
    for(int i=0;i<n-1;i++) if(s[i]==s[i+1]) c=0,all++;
    if(all==n){
        fin=1;
    }
    else{
    q%=3;
    fin=power(3,n-1);
    fin-=(make_dp(n,q,0)+make_dp(n,q,1)+make_dp(n,q,2))%MOD,fin+=MOD,fin%=MOD;
    fin+=c,fin%=MOD;
    }
    }
    printf("%lld\n",fin);
}



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

static constexpr int inf = INT_MAX / 2;
static_assert(inf > 1'000'000'000, "range of `int` is smaller than expected.");
static int dist[300][300];

template <class T> static void fill(T &dest, const T &value) { dest = value; }
template <class T, size_t N, class V> static void fill(T (&dest)[N], const V &value) {
    for (auto &elem : dest)
        fill(elem, value);
}

int main() {
    int cities, m, tank;
    cin >> cities >> m >> tank;
    fill(dist, inf);
    for (int i = 0; i < cities; i++)
        dist[i][i] = 0;

    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        if (c <= tank) {
            dist[a][b] = c;
            dist[b][a] = c;
        }
    }

    for (int k = 0; k < cities; k++) {
        for (int s = 0; s < cities; s++) {
            for (int g = 0; g < cities; g++) {
                if (dist[s][g] > dist[s][k] + dist[k][g])
                    dist[s][g] = dist[s][k] + dist[k][g];
            }
        }
    }

    for (int s = 0; s < cities; s++) {
        for (int g = 0; g < cities; g++) {
            if (dist[s][g] <= tank) {
                dist[s][g] = 1;
            } else {
                dist[s][g] = inf;
            }
        }
    }

    for (int k = 0; k < cities; k++) {
        for (int s = 0; s < cities; s++) {
            for (int g = 0; g < cities; g++) {
                if (dist[s][g] > dist[s][k] + dist[k][g])
                    dist[s][g] = dist[s][k] + dist[k][g];
            }
        }
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int s, t;
        cin >> s >> t;
        s--, t--;
        int d = dist[s][t];
        if (d < inf) {
            cout << (d - 1) << "\n";
        } else {
            cout << -1 << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main() {

    ll K,X;
    cin >> K >> X;

    ll a,b;

    a = X - K + 1;
    b = X + K - 1;

    for(ll i = a; i <= b; ++i)
    {
        cout << i << " ";    
    }
    cout << endl;

    return 0;
}

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

const int MOD = 1e9 + 7;

const int MAX_N = 2000000;
ll inv[MAX_N + 10];
ll fac[MAX_N + 10], facInv[MAX_N + 10];
class MATH{
public:
	MATH(){
		inverse();
		factroial();
	}
	ll nCk(ll n, ll k){// n! / k!*(n-k)!
		// cout << "nCk " << n << " " << k << endl;
		if(k < 0 || k > n) return 0;
		ll ret = fac[n];
		(ret *= facInv[k]) %= MOD;
		(ret *= facInv[n - k]) %= MOD;
		return ret;
	}
	ll nHk(ll n, ll k){// nHk = n+k-1 C k = (n+k-1)! / k! * (n-1)!
		if(n == 0 && k == 0) return 1;
		ll ret = fac[n + k - 1];
		(ret *= facInv[k]) %= MOD;
		(ret *= facInv[n - 1]) %= MOD;
		return ret;
	}
	ll nPk(ll n, ll k){//nPk = n! / (n-k)!
		if(k < 0 || k > n) return 0;
		ll ret = fac[n];
		(ret *= facInv[n - k]) %= MOD;
		return ret;
	}
private:
	void inverse(void){
		inv[1] = 1;
		for (int i = 2; i <= MAX_N; ++i){
			// inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
			inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		}
	}
	void factroial(void){
		fac[0] = facInv[0] = 1;
		for (int i = 1; i <= MAX_N; ++i){
			fac[i] = (fac[i - 1] * i) % MOD;
			facInv[i] = (facInv[i - 1] * inv[i]) % MOD;
		}
	}
};

int main(int argc, char const *argv[])
{
	int n, k; cin >> n >> k;
	MATH ma;
	int b = k, r = n - k;

	for (int i = 1; i <= k; ++i) { // b を i 個にわける
		ll numb = ma.nCk(b - 1, i - 1); // bをi個に分ける (空なし)
		ll numr = ma.nCk(r - (i - 1) + i, i); // r - (i - 1) を i+1 個に分ける (空あり)
		cout <<  (numb * numr) % MOD << endl;
	}
	return 0;
}


Measured memory_bytes: 47104
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
#include <cstdarg>
#include <sstream>
#include <functional>
using namespace std;

int const MAX_N = 512 * 1024;
long long const LL_INF = 5000000000000000000LL;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int a, p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2;
	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000;
#define PI 3.14159265
ll n,c,k;
bool check(ll kk,ll nn)
{
    if(nn==1)
        return true;
    else if(nn<kk)
        return false;
    if((nn%kk)==0)
        return check(kk,nn/kk);
    else
    {
        return check(kk,nn%kk);
    }
}
int main()
{
    fastio;
    cin>>n;
    ll temp = n-1;
    map<ll,int>mp;
    for(ll i=1;i<=sqrt(temp);i++)
    {
        if((temp%i)==0)
        {
            mp[i]++;
            if(i!=(temp/i))
                mp[temp/i]++;
        }
    }
    int ans = mp.size() - 1;
    vector<ll>dn;
    for(ll i=1;i<=sqrt(n);i++)
    {
        if((n%i)==0)
        {
            dn.pb(i);
            if(i!=(n/i))
                dn.pb(n/i);
        }
    }
    sort(all(dn));

    for(ll i : dn)
    {
        if(mp.count(i)==0 && check(i,n))
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif
using namespace std;

ll solve() {
    ll N;
    cin >> N;
    if(N & 1) return 0;
    N /= 2;
    ll ans = 0;
    for(ll i = 5;; i *= 5) {
        ll n = N / i;
        ans += n;
        if(n < 5) break;
    }

    return ans;
}

int main() {
    cout << solve() << endl;
    return 0;
}


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

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

    int ans = 100;
    for(char i = 'a'; i <= 'z'; i = (char)(i+1)){
        int localMax = 0, cnt = 0;
        for(int j = 0; j < s.length(); j++){
            if(s[j] == i){
                localMax = max(localMax, cnt);
                cnt = 0;
            }else{
                cnt++;
            }
        }
        localMax = max(localMax, cnt);

        ans = min(ans, localMax);
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<map>
#include<cctype>
#include<sstream>
using namespace std;
#define N 1000000000
string s;
string ret;
long long int k;
int main()
{
	while (cin>>s>>k)
	{
		ret = "";
		char ans;
		for (auto c : s)
		{
			if (c == '1')
				ret += "1";
			else
			{
				ans = c;
				break;
			}
		}
		int len = ret.length();
		if (k <= len)
			cout << "1" << endl;
		else
			cout << ans << endl;
	}
}


Measured memory_bytes: 256
# solution
# online help seeked

n, k = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]
sushi.sort(key=lambda x: x[1])
t = {}
x = []
z = 0
for i in range(n - 1, n - k - 1, -1):
    ti, di = sushi[i]
    if ti in t.keys():
        x.append(di)
        t[ti] += 1
    else:
        t[ti] = 1
    z += di

p = len(t.keys())
ans = z + p ** 2
idx = 1
for i in range(n - k - 1, -1, -1):
    if idx == len(x) + 1:
        break
    ti, di = sushi[i]
    if ti not in t.keys():
        t[ti] = 1
        z += di - x[-idx]
        p += 1
        idx += 1
        ans = max(ans, z + p ** 2)

print(ans)


Measured memory_bytes: 32164
#include<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++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 SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b, bool equal = false){
    if(a < b || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b, bool equal = false){
    if(b < a || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

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

    string s,t;
    cin >> s >> t;

    int cnt = 0;
    rep(i, s.size()){
        cnt += s[i] == t[i];
    }
    cout << cnt << endl;

    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for (int i = 0; i < 1000; i++) {
			char[] cs = in.readLine().toCharArray();
			boolean isPass = true;
			for (int n = 1; n < cs.length && isPass; n++) {
				char now = cs[n - 1];
				char next = cs[n];
				isPass &= (now != 'C' && now != 'F' && now + 1 == next)
						|| (now != 'D' && now != 'G' && now - 1 == next)
						|| ('G' > now && now + 3 == next)
						|| ('C' < now && now - 3 == next);
			}
			if (isPass) {
				System.out.println(cs);
			}

		}
	}
}

Measured memory_bytes: 21152