akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n,k;
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
    scanf("%d%d",&n,&k);
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
    LL res=(LL)(n/k)*(LL)(n/k)*(LL)(n/k);
	if(!(k&1)){
		k/=2;
		int num=n/k;
		res+=(LL)((num+1)/2)*(LL)((num+1)/2)*(LL)((num+1)/2);
	}
	printf("%lld\n",res);
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int x,y;
  cin>>x>>y;
  int a[12]={1,3,5,7,8,10,12,4,6,9,11,2};
  char gx,gy;
  for(int i=0;i<12;i++){
  if(x==a[i]){
    if(i<=6){
      gx='a';
  }else if(i>6&&i<11) {
      gx='b';
  }else{
    gx='c';
  }
  }
  if(y==a[i]){
    if(i<=6){
      gy='a';
  }else if(i>6&&i<11) {
      gy='b';
  }else{
      gy='c';
  }
  }
}
  if(gx==gy){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

using namespace std;

#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  

#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 998244353  
#define M 998244353  
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)  

long long qpow(long long a, long long n) {
    long long ret = 1;
    a = (a % M + M) % M;
    for (; n; n >>= 1) {
        if (n & 1) ret = (ret * a) % M;
        a = (a * a) % M;
    }
    return ret;
}

int n;
vector<string> vs, l, r;
int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        vs.push_back(s);
    }
    priority_queue<pii> va, vb;
    ll nsum = 0;
    for (auto &s : vs) {
        pii a(0,0);
        for (int i = 0; i < s.size(); ++i) {
            a.fi += s[i] == '(' ? 1:-1;
            a.se = min(a.se, a.fi);
        }
        if (a.se >= 0) nsum += a.fi; 
        else if (a.fi >= 0)
            va.push(a);
        else vb.push((pii){a.fi-a.se, -a.se});
    }
    while (!va.empty()) {
        pii p = va.top(); va.pop();
        if (nsum + p.se <= 0) {
            cout << "No" << endl; return 0;
        }
        nsum += p.fi;
    }

    while (!vb.empty()) {
        pii p = vb.top(); vb.pop();
        if (nsum - p.se < 0) {cout << "No" << endl; return 0;}
        nsum += p.fi - p.se;
    }
    if (nsum == 0)
        cout << "Yes"  << endl;
    else 
        cout << "No"  << endl;
    return 0;
}

Measured memory_bytes: 42488
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct Node{
  int key;
 struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);

int main(){
  int n,i,x;
  char s[20];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",s);
    if(strcmp(s,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(s,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

void insert(int k){
  struct Node *y = NIL,*x = root,*z;

  z = malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if(y == NIL)root = z;
  else {
    if(z->key < y->key)y->left = z;
    else y->right = z;
  }
}

void inorder(struct Node *u){

  if(u == NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){

  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

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

void fill(string&s,vector<int>&east,vector<int>&west){
	if(s.front()=='E')++east.front();
	else ++west.front();
	for(int i=1;i<s.size();++i){
		east.at(i)=east.at(i-1);
		west.at(i)=west.at(i-1);
		if(s.at(i)=='E')++east.at(i);
		else ++west.at(i);
	}
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	string s;
	cin>>n>>s;
	vector<int>le(n,0),lw(n,0),re(n,0),rw(n,0);
	fill(s,le,lw);
	reverse(s.begin(),s.end());
	fill(s,re,rw);
	reverse(re.begin(),re.end());
	int ans=1e9;
	for(int i=0;i<n;++i)ans=min(ans,lw.at(i)+re.at(i)-1);
	cout<<ans<<"\n"s;
}

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

int main(){
	int N;
  	cin >> N;
  	int64_t mas =1;
  	int res = pow(10,9)+7;
  	for(int i =0;i<N;i++){
    	mas = mas*(i+1)%res;
    }
  	cout << mas << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
int main()
{
	int w;
	std::cin >> w;
	int*nums = new int[w];
	for(int i = 0; i < w; i++)
	{
		nums[i] = i + 1;
	}
	int n;
	std::cin >> n;
	for(int i = 0; i < n; i++)
	{
		int a, b;
		char foo;
		std::cin >> a >> foo >> b;
		int temp = nums[a - 1];
		nums[a - 1] = nums[b - 1];
		nums[b - 1] = temp;
	}
	for(int i = 0; i < w; i++)
	{
		std::cout << nums[i] << std::endl;
	}
	delete[]nums;
	return 0;
}


Measured memory_bytes: 3024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if (a.compareTo(b) < 0)
			System.out.println("<");
		else if (a.compareTo(b) == 0)
			System.out.println("=");
		else
			System.out.println(">");
		sc.close();
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    ll ans=0;
    ll id=n-1;
    for(ll i=n-1;i>=0;i--){
        if(s[i]=='B'){
            ans+=id-i;
            id--;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    
    for(int i = 0; i < S.size(); i++){
        if (S[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

using P = pair<ll, ll>;

int n;
vector<P> a;

ll dp[5009];

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

    cin >> n;
    rep(i, n) {
        ll h, p;
        cin >> h >> p;
        a.emplace_back(h, p);
    }
    sort(ALL(a),
         [](P a, P b) { return a.first + a.second < b.first + b.second; });

    fill(ALL(dp), inf);
    dp[0] = 0;

    rep(i, n) FORR(j, i + 1) if(dp[j] <= a[i].first)
        chmin(dp[j + 1], dp[j] + a[i].second);

    cout << lower_bound(ALL(dp), inf) - dp - 1 << endl;

    return 0;
}

Measured memory_bytes: 512
// Shift-JIS（シフトジス）

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if ((C - A) * (C - B) < 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int a[1000], N;

void print() {
  for (int i = 0; i < N-1; i++) {
    cout << a[i] << " ";
  }
  cout << a[N-1] << endl;
}

signed main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 0; i < N; i++) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    print();
  }
}



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

int main() {
    int N, M; cin >> N >> M;
    vector<int> food(M, 0);
    int ans=0;

    for (int i = 0; i < N; ++i) {
        int K; cin >> K;
        for (int j = 0; j < K; ++j) {
            int A; cin >> A;
            food[A-1]++;
        }
    }

    for (int k = 0; k < M; ++k) {
        if(food[k]==N) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    
    int ans = 0;
    forn(i, 1, n+1) {
        int x = i, sum = 0;
        while (x) {
            sum += x%10;
            x /= 10;
        }
        if (sum >= a && sum <= b) ans += i;
    }
    cout << ans << endl;
}

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

int main(){
  int W, H, x, y;
  cin >>W >>H >>x >>y;
  double ans = double(W)*double(H)/2;
  printf("%.9lf\n", ans);

  if(W==2*x && H==2*y){
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef double DD;
typedef long long LL;
const int N = 401010;

int p[N], num[N];
char s[N];

int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	LL ans = 1ll * n * (n + 1) >> 1;
	ans++;
	for(int i = 1; i <= n; i++)
	{
		num[s[i] - 'a' + 1]++;
	}
	for(int i = 1; i <= 26; i++)
		ans -= 1ll * num[i] * (num[i] + 1) >> 1;
	printf("%lld\n", ans);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
char a[11];
int main()
{
	int i,ans=0,tmp;
	scanf("%s",a);
	for(i=0;i<strlen(a)-2;i++)
	{
		tmp=(a[i]-'0')*100+(a[i+1]-'0')*10+(a[i+2]-'0');
		if(abs(tmp-753)<abs(ans-753))
			ans=tmp;
	}
	printf("%d",abs(ans-753));
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld; 


#define F first
#define S second
#define pob pop_back
#define pb push_back
#define Time()	cerr << clock() * 1000 / CLOCKS_PER_SEC << "ms\n"
#define show(x)	cerr << #x << " = " << (x) << '\n'
#define inf 1e14
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define Test int T;cin>>T;while(T--)
#define vec vector<ll> 
#define REP(i,j,k) for(int i=(j);(i)<(k);(i)++)




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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long a[26];

int main()
{
    long long n;
    string s;
    cin >> s;
    n = s.length();
    n = n * (n + 1) >> 1;
    for (int j = 0; j < s.length(); j++) {
        a[s[j] - 'a']++;
    }
    for (int j = 0; j < 26; j++) {
        n -= (a[j] * (a[j] - 1) >> 1);
    }
    n -= s.length() - 1;
    cout << n;
}


Measured memory_bytes: 640
n,m = map(int,input().split())
INF = 10**18
d = [[INF]*n for _ in range(n)]
nd = [[INF]*n for _ in range(n)]
for i in range(n):
    d[i][i] = 0
    nd[i][i] = 0
for _ in range(m):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c
    nd[a][b] = c
    nd[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            nd[i][j] = min(nd[i][j], nd[i][k]+nd[k][j])

cnt = 0
for i in range(n):
    for j in range(n):
        if d[i][j] == INF: continue
        if nd[i][j] < d[i][j]: cnt += 1
print(cnt//2)

Measured memory_bytes: 9220
k = int(input())
a,b = map(int,input().split())
if(k==a or k==b or (k>=a and k<=b) or (0>=a and 0<=b)):
    print('OK')
elif(k>b):
    print('NG')
elif(k<a):
    x = int(a/k)
    if(x*k==a):
        print('OK')
    elif(((x+1)*k>=a) and (x+1)*k<=b):
        print("OK")
    else:
        print('NG')
        
    
            

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, x, c = 0;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> x;
        if(i % 2 == 1 && x % 2 == 1)c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 3564
import java.util.*;

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

        int N = scanner.nextInt();
        Map<String, Integer> map = new HashMap<>();

        int max = 0;
        for (int i = 0 ; i < N ; i++) {
            String S = scanner.next();
            if (map.containsKey(S)) {
                map.put(S, map.get(S) + 1);

            } else {
                map.put(S, 1);
            }
            max = Math.max(max, map.get(S));
        }

        List<String> stringList = new ArrayList<>();
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            if (entry.getValue() == max) {
                stringList.add(entry.getKey());
            }
        }
        Collections.sort(stringList);
        for (String s : stringList) {
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 81932
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
  int N, K; cin >> N >> K;
  vector<ll> a(N), p(N);
  REP(i, N) {
    cin >> a[i];
    p[i] = max(0LL, a[i]);
  }
  REP(i, N - 1) {
    a[i + 1] += a[i];
    p[i + 1] += p[i];
  }

  auto psum = [&](vector<ll>& a, ll l, ll r)->ll {
    if (r < 0 || l >= N) return 0;
    else if (l <= 0) return a[r];
    else return a[r] - a[l - 1];
  };

  ll ans = -LLINF;
  REP(i, N - K + 1) {
    ll inside = psum(a, i, i + K - 1);
    ll outside = psum(p, 0, i - 1) + psum(p, i + K, N - 1);
    ans = max({ans, outside + inside, outside});
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true){
      int m = sc.nextInt();
      int f = sc.nextInt();
      int r = sc.nextInt();
      if(m==-1&&f==-1&&r==-1) break;
      else if(m==-1||f==-1) System.out.println("F");
      else if(m+f>=80) System.out.println("A");
      else if(m+f>=65) System.out.println("B");
      else if(m+f>=50) System.out.println("C");
      else if(m+f>=30) {
        if(r>=50)
        System.out.println("C");
        else
        System.out.println("D");
      }else System.out.println("F");
    }
    sc.close();
  }
}


Measured memory_bytes: 26144
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    vector<int> seq;

    int a = s;
    seq.emplace_back(a);
    for (int i = 2; i <= 1000000; ++i) {
        if (a % 2 == 0) {
            a /= 2;
        } else {
            a = 3*a + 1;
        }

        auto it = find(begin(seq), end(seq), a);
        if (it != end(seq)) {
            cout << i << endl;
            break;
        }

        seq.emplace_back(a);
    }

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx2")
# include <bits/stdc++.h>
using namespace std;
# define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
# define FDR(i, a, b) for (int i = (a); i >= (b); --i)
# define mem(a, x) memset(a, x, sizeof(a));
# define mp make_pair
# define pb push_back
typedef vector<int> Vi;
typedef tuple<int, int, int> Ti;
typedef pair<int, int> Pi;
typedef long long i64;
const int N = 100005;
const int MOD = 1000000007;
const int INF = 1000000000;

int a[N], v[N];
int n, tree[N*3];

int lowbit(int x) {return x & (-x);}
int sum(int x) {
    int res = 0;
    while (x) res += tree[x], x -= lowbit(x);
    return res;
}
void add(int x) {
    while (x < N*3) ++tree[x], x += lowbit(x);
}
int To(int x) {return x + N;}
bool check(int x) {
    mem(tree, 0);
    add(To(0));
    int y = 0;
    i64 res = 0;
    FOR(i, 1, n) {
        y += (a[i] <= x ? 1 : -1);
        res += sum(To(y-1));
        add(To(y));
    }
    //cout << x << ' ' << res << endl;
    return res >= ((i64)n*n+n) / 2 / 2 + 1;
}
int main ()
{
    scanf("%d", &n);
    FOR(i, 1, n) scanf("%d", a + i), v[i] = a[i];
    sort(v + 1, v + n + 1);
    int l = 1, r = n + 1, mid;
    while (l < r) {
        int mid = (l + r) / 2;
        if (check(v[mid])) r = mid;
        else l = mid + 1;
    }
    printf("%d\n", v[l]);
    return 0;
}



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

void InputSet(std::vector<int> & a) {
	int n;
	cin >> n;
	a.resize(n,0);
	for(int i=0;i<n;++i) {
		cin >> a.at(i);
	}
}

int solve(unsigned int idx,std::vector<int> & a,int M) {
	int sub = M - a[idx];
	if (sub==0) {
		return	1;
	} else if (sub > 0) {
		if (idx + 1 < a.size()){
			if (solve(idx+1,a,sub)==1){
				return	1;
			}
		}
	}

	if (idx + 1 < a.size()){
		if (solve(idx+1,a,M)==1){
			return	1;
		}
	}

	return	0;
}

int main(){
	std::vector<int> A,Q;
	::InputSet(A);
	::InputSet(Q);
	const char* ans[] = { "no", "yes" };
	for(unsigned int k=0;k<Q.size();++k){
		cout << ans[solve(0,A,Q[k])] << std::endl;
	}
}

Measured memory_bytes: 1196
n = int(input())
if n<=1000:
    print(1000-n)
elif n<=2000:
    print(2000-n)
elif n<=3000:
    print(3000-n)
elif n<=4000:
    print(4000-n)
elif n<=5000:
    print(5000-n)
elif n<=6000:
    print(6000-n)
elif n<=7000:
    print(7000-n)
elif n<=8000:
    print(8000-n)
elif n<=9000:
    print(9000-n)
elif n<=10000:
    print(10000-n)

Measured memory_bytes: 9200
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1:
                print("#",end = "")
            else:
                print(".",end = "")
        print()
    
    print()


Measured memory_bytes: 7000
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


// range sum query using fenwick tree
// note index starts at 1

class fenwick_tree {
	vector<long> t;
	long size;
public:
	fenwick_tree(long n) {
		t.assign(n + 1, 0);
		size = n + 1;
	}

	long LSOne(long k) {	// least significant 1-bit
		return k & (-k);
	}

	void update(long index, long val) {	// can go up or go down
		for (; index < size; index += LSOne(index)) t[index] += val;
	}

	long query_full(long a, long b) {		// range query
		return query(b) - ((a <= 1) ? 0 : query(a - 1));
	}

	long query(long b) {	// range query 1..b
		if (b < 1) return 0;

		long sum = 0;
		for (; b; b -= LSOne(b)) sum += t[b];
		return sum;
	}
};



int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, i, j, k, id, x, aa, bb, cc;
	cin >> n;
	vector<int> a(n), b(n), ans(n);
	set<int> s;
	map<int, int> sid, v;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		s.insert(a[i]);
	}
	id = 1;
	for (auto p : s) {
		sid[p] = id;
		v[id] = p;
		id++;
	}

	fenwick_tree ft(n + 1);
	for (i = 0; i < n; i++) {
		b[i] = sid[a[i]];
		ft.update(b[i], 1);
	}

	for (i = 0; i < n; i++) {
		ft.update(b[i], -1);
		aa = 1; bb = n;
		while (aa < bb) {
			cc = (aa + bb) / 2;
			x = ft.query_full(1, cc);
			if (x < n / 2) aa = cc + 1;
			else bb = cc;
		}
		ans[i] = v[aa];
		ft.update(b[i], 1);
	}

	for (i = 0; i < n; i++) cout << ans[i] << "\n";

	return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	int n, m;
	priority_queue<int> que;
	cin >> n >> m;
	FOR(i, 1, n) {
		int a;
		cin >> a;
		que.push(a);
	}
	FOR(i, 1, m) {
		int tmp = que.top();
		que.pop();
		tmp >>= 1;
		que.push(tmp);
	}
	ll res = 0;
	FOR(i, 1, n) {
		res += que.top();
		que.pop();
	}
	pv(res)
	return(0);
}

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

int main() {
    int x, a, b;  cin >> x >> a >> b;
    if (abs(a-x) < abs(b-x))  cout << 'A' << endl;
    else  cout << 'B' << endl;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto X = s[1].to!long;
    auto A = readln.split.map!(to!long).array;
    
    auto mins = new long[][](N, N);
    foreach (i; 0..N) fill(mins[i], 1L << 59);

    foreach (i; 0..N) {
        mins[i][0] = A[i];
        foreach (jj; 1..N) {
            int j = (i - jj + N) % N;
            mins[i][jj] = min(mins[i][jj-1], A[j]);
        }
    }

    long ans = 1L << 59;
    foreach (i; 0..N) {
        long tmp = 0;
        foreach (j; 0..N) tmp += mins[j][i];
        ans = min(ans, tmp + i * X);
    }

    ans.writeln;
}


Measured memory_bytes: 34428
#include <stdio.h>

int main() {
	int a, b;
	char ans[20];
	scanf("%d %d", &a, &b);
	if (a == b) {
		printf("a == b\n");
	}
	else if(a < b){
		printf("a < b\n");
	}
	else {
		printf("a > b\n");
	}
	return 0;
}


Measured memory_bytes: 2104
#1_D
n = int(input())
r = []
for i in range(n):
    r.append(int(input()))

rmin = r[0]
rmax = r[1]
delr = rmax - rmin

for i in range(n-1):
    delr = max(delr, r[i+1]-rmin)
    rmin = min(rmin, r[i+1])
print(delr)


Measured memory_bytes: 13584
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	ll n;
	cin >> n;
	ll a[5];
	ll min = 1e18;
	int index;
	REP(i, 5){
		cin >> a[i];
		if (min > a[i]){
			min = a[i];
			index = i;
		}
	}
	if (n <= min){
		cout << 5 << endl;
		return 0;
	}

	ll ans;
	if (n % min != 0){
		ans = n / min + 1;
	} else ans = n / min;

	cout << ans + 4 << endl;
}


Measured memory_bytes: 256
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



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

	int K;
	cin >> K;
	int ans = 0;
	rep(i,K){
		rep(j,K){
			rep(k,K){
				ans += gcd(gcd(i+1,j+1),k+1);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ1_5_A
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int H = int.Parse(str[0]);
                int W = int.Parse(str[1]);

                if (W == 0 && H == 0)
                {
                    break;
                }
                else
                {
                    for (int i = 0; i < H; i++)
                    {
                        for (int j = 0; j < W; j++)
                        {
                            Console.Write("#");
                        }
                            Console.Write("\n");
                    }
                    Console.Write("\n");
                }
            }
        }
    }
}




Measured memory_bytes: 17912
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;

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

    ll l,r; cin >> l >> r;

    ll ans = 2018;

    if(r-l>=2019){cout << 0 << endl; return 0;}
    else{
        for(ll i=l; i<=r; i++){
            for(ll j=i+1;j<=r; j++){
                ans = min(ans, i%2019*j%2019);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import bisect

N, K = map(int, input().split())
V = [int(i) for i in input().split()]

ans = -10**20
for l in range(min(K+1, N+1)):
    for r in range(min(K-l+1, N-l+1)):
        P = V[:l]+V[N-r:]
        P.sort()
        z = bisect.bisect_left(P, 0)

        if z <= K-l-r:
            ans = max(ans, sum(P[z:]))
        else:
            ans = max(ans, sum(P[K-l-r:]))

print(ans)


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  char c;
  std::cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    std::cout << "vowel" << std::endl;
  } else {
    std::cout << "consonant" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int x,y;
    while(cin>>x>>y)
    {
        int ans=0;
        if(x==1)ans+=300000;
        else if(x==2)ans+=200000;
        else if(x==3)ans+=100000;
        if(y==1)ans+=300000;
        else if(y==2)ans+=200000;
        else if(y==3)ans+=100000;
        if(x==1&&y==1)ans+=400000;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    sc.close();
    
    int tmp = a;
    a = b;
    b = tmp;
    
    tmp = a;
    a = c;
    c = tmp;
    
    System.out.println(a + " " + b + " " + c);
    
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"
#define int ll

using namespace std;
typedef string::const_iterator State;
#define eps 1e-8L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
int now_val = 0;
int expr(State& now) {
	if (*now == '0') {
		now++;
		return 0;
	}
	if (*now == '1') {
		now++;
		return 1;
	}
	if (*now == '-') {
		now++;
		return (1 - expr(now));
	}
	if (*now == '(') {
		now++;
		int a = expr(now);
		int flag = 0;
		if (*now == '^') {
			flag = 1;
		}
		now++;
		int b = expr(now);
		now++;
		if (flag == 1) {
			return (a ^ b);
		}
		else {
			return (a & b);
		}
	}
	if ((1 << (*now - 'a')) & now_val) {
		now++;
		return 1;
	}
	else {
		now++;
		return 0;
	}
}
int evaluator(string s) {
	s.push_back(' ');
	int ans = 0;
	REP(i, 16) {
		State hoge = s.begin();
		now_val = i;
		ans += (1 << i) * expr(hoge);
	}
	return ans;
}
vector<string> expr_list[17];
int expr_shortest[(1 << 16)];
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	REP(i, (1 << 16)) {
		expr_shortest[i] = 1e18;
	}
	expr_list[1].push_back("0");
	expr_list[1].push_back("1");
	expr_list[1].push_back("a");
	expr_list[1].push_back("b");
	expr_list[1].push_back("c");
	expr_list[1].push_back("d");
	REP(i, expr_list[1].size()) {
		expr_shortest[evaluator(expr_list[1][i])] = 1;
	}
	for (int i = 2; i <= 16; ++i) {
		for (int q = 0; q < expr_list[i - 1].size(); ++q){
			string geko = "-" + expr_list[i - 1][q];
			if (expr_shortest[evaluator(geko)] > i) {
				expr_shortest[evaluator(geko)] = i;
				expr_list[i].push_back(geko);
			}
		}
		for (int q = 1; q <= i - 4; ++q) {
			int j = i - 3 - q;
			REP(t, expr_list[q].size()) {
				REP(p, expr_list[j].size()) {
					{
						string geko = "(" + expr_list[q][t] + "*" + expr_list[j][p] + ")";
						if (expr_shortest[evaluator(geko)] > i) {
							expr_shortest[evaluator(geko)] = i;
							expr_list[i].push_back(geko);
						}
					}
					{
						string geko = "(" + expr_list[q][t] + "^" + expr_list[j][p] + ")";
						if (expr_shortest[evaluator(geko)] > i) {
							expr_shortest[evaluator(geko)] = i;
							expr_list[i].push_back(geko);
						}
					}
				}
			}
		}
	}
}
void solve() {
	while (true) {
		string s;
		cin >> s;
		if (s == ".") return;
		cout << expr_shortest[evaluator(s)] << endl;
	}
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3808
#a,b,c=map(int,input().split())
#d=list(map(int,input().split()))
#n=int(input())
#d,x=map(int,input().split())
#a=[int(input()) for i in range(n)]
T=list(input())
S=""
if T[0]=="?":
  S+="D"
else:
  S+=T[0]
for i in range(1,len(T)):
  if T[i]!="?":
    S+=T[i]
  else:
    S+="D"
print(S)
      

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

int main() {
  int N; cin >> N;
  vector<int> a(N+1);
  for (int i = 1; i <= N; i++) cin >> a.at(i);
  int M = 0;
  vector<int> b(N+1);
  for (int i = N; i > 0; i--) {
    int cnt = 0;
    for (int j = 2*i; j <= N; j += i) {
      if (b.at(j) == 1) cnt++;
    }
    if (cnt % 2 != a.at(i)) {
      b.at(i) = 1;
      M++;
    }
  }
  cout << M << endl;
  for (int i = 1; i <= N; i++) {
    if (b.at(i) == 1) cout << i << " ";
  }
  if (M != 0) cout << endl;
}

Measured memory_bytes: 2432
def resolve():

    N=int(input())
    s = str(input())


    l=['%03d'%(p) for p in range(0,10**3)]
    ans=[]
    for i in l:
        if i[0] in s:
            s0=s.index(i[0])
            if i[1] in s[s0+1:]:
                s1=s[s0+1:].index(i[1])
                if i[2] in s[s0+1:][s1+1:]:
                    ans.append(i)



    print(len(set(ans)))


resolve()

Measured memory_bytes: 39920
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
   
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
          
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
      
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=map(int,input().split())
uf=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
print(uf.group_count()-1)

Measured memory_bytes: 12952
#include<bits/stdc++.h>
#define ll long long
#define Test int t;cin>>t;while(t--)
#define PI acos(-1)
#define endl "\n"
#define fx(x) fixed<<setprecision(x)
#define sz(s) s.size()
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
const double eps=1e-9;
const int mod=1e9+7;
int dx[]={-1,-1,-1,0,0,1,1,1};
int dy[]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll x,ll y) {return(!y)?x:gcd(y,x%y);}
ll lcm(ll x,ll y) {return((x/gcd(x,y))*y);}
using namespace std;
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int a[100102];
int dp[100102];
int n,k;
int solve(int idx){
    if(idx==n-1)return 0;
    if(idx+k>=n)return abs(a[idx]-a[n-1]);
    int &ret=dp[idx];
    if(ret!=-1)return ret;
    int mn=INT_MAX;
    for(int i=1;i<=k;i++){
        if(idx+i<n)mn=min(mn,solve(idx+i)+abs(a[idx]-a[idx+i]));
    }
    ret=mn;
    return ret;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    memset(a,1000000000,sizeof a);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<solve(0);
    return 0;
}


Measured memory_bytes: 12168
N = gets.to_i
a_array=gets.chomp.split(" ").map(&:to_i)

even_count = a_array.select{|e| e.even? }.length
odd_count = N - even_count

if even_count == 0 || odd_count == 0
    puts 0
elsif odd_count.odd?
    puts N-1
else
    puts N-2
end



Measured memory_bytes: 22148
import math

n = int(input())

def Prime(n):
    List = [1 for _ in range(n+1)]
    List[0],List[1] = 0,0
    P_List_tmp = [2]
    for i in range(3,n+1):
        flag = 0
        for j in range(len(P_List_tmp)):
            if i % P_List_tmp[j] == 0:
                flag = 1
                List[i] = 0
        if List[i] == 1:
            P_List_tmp.append(i)
    P_List = []
    for i in range(n+1):
        if List[i] == 1:
            P_List.append(i)
    return P_List

def fact(n):
    P_List = Prime(int(math.sqrt(n)))
    Ans = []
    for i in range(len(P_List)):
        if n % P_List[i] == 0:
            while n % P_List[i] == 0:
                n //= P_List[i]
                Ans.append(P_List[i])
    if n != 1:
        Ans.append(n)
    return Ans

print(str(n)+":",end="")
Ans = fact(n)
for i in range(len(Ans)):
    print(" "+str(Ans[i]),end="")
print()



Measured memory_bytes: 6016
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

typedef long long ll;
const int MAX_N = 3000 + 2;
ll dp[MAX_N][MAX_N];
ll a[MAX_N];

int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];

  memset(dp, 0, sizeof(dp));

  for (int j = 0; j < N; j++) dp[1][j] = a[j];

  for (int i = 2; i <= N; i++) {
    for (int j = 0; j <= N - i; j++) {
      ll front = a[j] + (-1)*dp[i-1][j+1];
      ll back  = a[j+i-1] + (-1)*dp[i-1][j];
      dp[i][j] = max(front, back);
    }
  }

  cout << dp[N][0] << endl;
  return 0;
}


Measured memory_bytes: 73624
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
/******************************define**********************************/

/*****************************functions********************************/

/****************************main function*****************************/
int main(void){

    ll r,d,x1;cin >> r >> d >> x1;
    ll x[11]; x[0]=x1;
    for(ll i = 1;i < 11;i++){
        x[i]=x[i-1]*r - d;
        cout << x[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,a,b = map(int, input().split())
x = list(map(int, input().split()))
diff = [x[i+1] - x[i] for i in range(n-1)]
ans = 0
for i in range(1,n):
    if diff[i-1] * a > b:
        ans += b
    else:
        ans += diff[i-1] * a
# print(diff)
print(ans)



Measured memory_bytes: 15020
n = int(input())
a =[]
for i in range(n):
    a.append(int(input()))

count = 0
now = 0

for i in range(n+2):
    now = a[now] -1
    count += 1
    if now == 1:
        break

if count == n+2:
    print(-1)
else:
    print(count)

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,k,c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vl dp_L(k,-1),dp_R(k,-1);
  ll i=0,j=0;
  while(i<n&&j<k){
    if(s[i]=='o'){
      dp_L[j]=i;
      j++;
      i +=c+1;
    }
    else
      i++;
  }
  i=n-1,j=k-1;
  while(i>=0&&j>=0){
    if(s[i]=='o'){
      dp_R[j]=i;
      j--;
      i -=c+1;
    }
    else
      i--;
  }
  bool a=false;
  rep(i,k){
    if(dp_L[i]==dp_R[i]){
      a=true;
      dp_L[i]++;
      cout << dp_L[i] << endl;
    }
  }
}

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

using namespace std;

int main() {
  int n, z, w;
  scanf("%d %d %d", &n, &z, &w);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  if (n == 1) {
    printf("%d\n", abs(a[0] - w));
    return 0;
  }
  printf("%d\n", max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])));
  return 0;
}



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

using namespace std;

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

void solve(){
	int H,W;
	cin >> H >> W;
	vector<string> A(H);
	for(auto &s : A) cin >> s;
	if(A[0][0] != '#' || A[H-1][W-1] != '#'){
		cout << "Impossible" << endl;
		return;
	}
	A[0][0] = '.';
	int i = 0, j = 0;
	while(i != H-1 || j != W-1){
		bool flag = true;
		for(int k = 0; k < 2; k++){
			int ii = i + dy[k];
			int jj = j + dx[k];
			if(ii == H || jj == W) continue;
			if(A[ii][jj] == '#'){
				flag = false;
				A[ii][jj] = '.';
				i = ii;
				j = jj;
				break;
			}
		}
		if(flag) break;
	}
	A[H-1][W-1] = '.';
	for(int y = 0; y < H; y++){
		for(int x = 0; x < W; x++){
			//cout << A[y][x];
			if(A[y][x] == '#') {
				cout << "Impossible" << endl;
				return;
			}
		}
	}
	cout << "Possible" << endl;
}


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

    solve();

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int d=sc.nextInt();
		int e=sc.nextInt();
		int f=sc.nextInt();
		int sw=0;
		int s=0;
		double con=0;
		for(int i=0; 100*i*a<=f; i++){
			for(int j=0; 100*j*b+100*i*a<=f; j++){
				for(int t=0; t*c<=e*(a*i+b*j);t++){
					for(int k=0; t*c+d*k<=e*(a*i+b*j); k++){
						if(i+j+t+k==0) continue;
						if((100*(a*i+b*j)+c*t+d*k)<=f && con<=(double)100*(c*t+d*k)/(100*(a*i+b*j)+c*t+d*k)){
							con=(double)100*(c*t+d*k)/(100*(a*i+b*j)+c*t+d*k);
							sw=100*(a*i+b*j)+c*t+d*k;
							s=c*t+d*k;
						}
					}
				}
			}
		}
		System.out.println(sw+" "+s);
	}
}


Measured memory_bytes: 24020
/*
[abc138] D - Ki
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 2e5;
const int MAX_Q = 2e5;

int N, Q;
vector<int> g[MAX_N];
int p[MAX_Q], x[MAX_Q];
int ans[MAX_N];

void dfs(int v, int par = -1) {
    if (par >= 0) {
        ans[v] += ans[par];
    }
    for (int to : g[v]) {
        if (to == par) {
            continue;
        }
        dfs(to, v);
    }
}

void solve() {
    for (int i = 0; i < Q; i++) {
        ans[p[i]] += x[i];
    }
    dfs(0);

    for (int i = 0; i < N; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
}

int main() {
    cin >> N >> Q;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }
    for (int i = 0; i < Q; i++) {
        cin >> p[i] >> x[i];
        p[i]--;
    }

    solve();

    return 0;
}


Measured memory_bytes: 25088
S = gets.chomp
T = gets.chomp
m = T.size
(0 .. S.size - T.size).each do |i|
  c = 0
  (0...T.size).each do |j|
    if T[j]!=S[i+j]
      c += 1 
      break if c > m
    end
  end
  m = c if c < m
end
puts m

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

int main(){
    int k;
    cin >> k;
    string ans;
    rep(i,k){
        ans += "ACL";
    }
    cout << ans <<endl;
}

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

int main() {
  int N, A, min = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A;
    int j = 0;
    for (; A % 2 == 0; A /= 2) {
      j++;
    }
    if (i == 0 || min > j) {
      min = j;
    }
  } 
  cout << min << endl;
}


Measured memory_bytes: 256
import numpy as np


N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
X = np.array(X)

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        tmp = ((abs(X[i] - X[j]))**2).sum()
        tmp = np.sqrt(tmp)
        if tmp.is_integer():
            cnt += 1
print(cnt)

Measured memory_bytes: 12484
#include<stdio.h>

int main(void){
   int a,b,c,d,e,k;

   scanf("%d",&a);
   scanf("%d",&b);
   scanf("%d",&c);
   scanf("%d",&d);
   scanf("%d",&e);
   scanf("%d",&k);

   if (e-a > k)

    puts(":(");
   else
    puts("Yay!");

  return 0;
}


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 1, inf = 1000111222;
const ll mod = 1000000007;

string s;
int cnt[27];

int main()
{
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    cin >> s;
    ll ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        ll res = 1;
        int cur = s[i] - 'a';
        for (int i = 0; i < 27; ++i) {
            if (i == cur) continue;
            res *= (cnt[i] + 1);
            res %= mod;
        }
        ans += res;
        ans %= mod;
        cnt[cur]++;
    }
    cout << ans << endl;

    return 0;
}




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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

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



int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a,b,h;
	cin >> a >> b >> h;
	cout << (a+b) * h / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
ca,cb=0,0
s=input()
for i in range(n):
    if s[i]=="a":
        if ca<a+b:
            print("Yes")
            ca+=1
        else: print("No")
    elif s[i]=="b":
        if ca<a+b and cb<b:
            print("Yes")
            ca+=1;cb+=1
        else: print("No")
    else: print("No")

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	int cnt = 1, num = 0;
	while(cnt < b) num++, cnt += a - 1;
	cout << num << "\n";
	return 0;
}

Measured memory_bytes: 256