akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll h, w, k; cin >> h >> w >> k;
  vector<string> c(h); cin >> c;

  int H = 1<<h;
  int W = 1<<w;

  ll sum = 0;
  rep(i, h) rep(j, w) if (c[i][j] == '#') ++sum;

  ll ans = 0;
  rep(S0, H) rep(S1, W) {
    int cnt = 0;
    rep(i, h) rep(j, w) {
      if (c[i][j] == '#') {
        if ((S0>>i&1) || (S1>>j&1)) ++cnt;
      }
    }
    if (sum - cnt == k) ++ans;
  }

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


Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main (){
    int a,b;
    while (cin >> a >>b){
        if(a==0 && b==0)
            break;
        switch (a){
            case 1 : break;
            case 2 : b+=31; break;
            case 3 : b+=60; break;
            case 4 : b+=91; break;
            case 5 : b+=121; break;
            case 6 : b+=152; break;
            case 7 : b+=182; break;
            case 8 : b+=213; break;
            case 9 : b+=244; break;
            case 10 : b+=274; break;
            case 11 : b+=305; break;
            case 12 : b+=335; break;
        }
        switch (b%7){
            case 0: cout << "Wednesday" << endl; break;
            case 1: cout << "Thursday" << endl; break;
            case 2: cout << "Friday" << endl; break;
            case 3: cout << "Saturday" << endl; break;
            case 4: cout << "Sunday" << endl; break;
            case 5: cout << "Monday" << endl; break;
            case 6: cout << "Tuesday" << endl; break;
        }
    }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using ll = int64_t;

int main() {
  int n;
  cin>>n;
  vector<pair<ll, ll>> vp;
  REP(i,n) {
    ll x,y;
    cin>>x>>y;
    vp.emplace_back(x, y);
  }
  vector<string> vs(n);
  vector<ll> vl;
  string dir = "RULD";
  REP(i,40) {
    ll mx = 0;
    REP(j,n) {
      ll x, y;
      tie(x, y) = vp[j];
      mx = max(mx, abs(x) + abs(y));
    }
    if (mx == 0) {
      cout << i << endl;
      REP(j, vl.size()) {
        if (j) cout << ' ';
        cout << vl[j];
      }
      cout << endl;
      for (const auto& s : vs) {
        cout << s << endl;
      }
      return 0;
    }
    ll l = (mx + 1) / 2;
    vl.push_back(l);
    ll dx[] = {l, 0, -l, 0};
    ll dy[] = {0, l, 0, -l};
    REP(j,n) {
      ll x, y;
      tie(x, y) = vp[j];
      int idx = 0;
      ll mn = mx;
      REP(k,4) {
        ll ax = dx[k];
        ll ay = dy[k];
        ll d = abs(x-ax)+abs(y-ay);
        if (d < mn) {
          mn = d;
          idx = k;
        }
      }
      vs[j].push_back(dir[idx]);
      vp[j] = make_pair(x - dx[idx], y - dy[idx]);
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(8);
    string s;
    while(getline(cin, s))
    {
        s += ' ';
        stack<double> st;
        int pos = 0;
        string tmp = "";
        while(pos < s.size())
        {
            if(s[pos] == ' ')
            {
                if(tmp == "+" || tmp == "-" || tmp == "*" || tmp == "/")
                {
                    double a = st.top(); st.pop();
                    double b = st.top(); st.pop();
                    if(tmp == "+") st.push(b + a);
                    else if(tmp == "-") st.push(b - a);
                    else if(tmp == "*") st.push(b * a);
                    else st.push(b / a);
                }
                else
                {
                    double v = stod(tmp);
                    st.push(v);
                }
                tmp = "";
            }
            else tmp += s[pos];
            pos++;
        }
        cout << st.top() << endl;
    }
    return 0;
}




Measured memory_bytes: 3100
using System;
public class Hello{
    public static void Main(){
        var input = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        int A = input[0];
        int B = input[1];
        int C = input[2];
        
        var nums = new long[1000];
        nums[0] = 0;
        for(var i = 1;i < nums.Length;i++){
            nums[i] = i * A;
            if(nums[i] % B == C){
                Console.WriteLine("YES");
                return;
            }
        }
        Console.WriteLine("NO");
    }
}


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

int main() {
    int N;
    cin >> N;
    int a[N];
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }
    reverse(a, a+N);
    for(int i=0; i<N; i++) {
        if(i<N-1) {
            cout << a[i] << ' ';
        }
        else {
            cout << a[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3080
n,m,l = [int(x) for x in input().split()]

b = []
c = []

for i in range(n):
    a = [int(x) for x in input().split()]
    b.append(a)

for i in range(m):
    a = [int(x) for x in input().split()]
    c.append(a)
    
for i in range(n):
    for j in range(l):
        v = 0
        for k in range(m):
            v += b[i][k]*c[k][j]
        print(v,end="")
        if j < l-1:
            print(" ",end="")
    print()
            
        


Measured memory_bytes: 6508
#include<stdio.h>
#include<string.h>
int main()
{
    
     char str[100];
     int i,l,ind;
     scanf("%s",str);
     l=strlen(str);
     int t=0;
     if(str[0]=='A')
     {
          
          int c=0;
          for(i=2;i<l-1;i++)
          {
                if(str[i]=='C'&&c==0)
                {
                  c=1;
                  ind =i;
                }
                else if(str[i]=='C'&&c==1)
                {

                    c=2;

                }
             

          }
          if(c==1)
          {
            int shotti =1;
            for(i=1;i<l;i++)
            {
               if(i!=ind&&(str[i]>='A'&&str[i]<='Z'))
               {
                shotti = 0 ;
               }

            }
            if(shotti ==1)
            {
              t=1;
            }

          }

     }

   if(t==1)
   {

     printf("AC\n");
   }

   else
   {
       printf("WA\n");


   }

return 0;
}



Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main{
    
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	int n=Integer.parseInt(br.readLine());

	Node node[]=new Node[n];
        for(int i=0;i<n;i++){
	    node[i]=new Node(-1);
	}

	for(int i=0;i<n;i++){
	    String str[]=br.readLine().split(" ");
	    int id=Integer.parseInt(str[0]);
	    int left=Integer.parseInt(str[1]);
	    int right=Integer.parseInt(str[2]);
	    node[id].left=left;
	    node[id].right=right;

	    if(left!=-1)
		node[left].parent=id;
	    if(right!=-1)
		node[right].parent=id;
	}

	int root=0;	    
	for(int i=0;i<n;i++){
	    if(node[i].parent==-1){
		root=i;
		break;
	    }
	}

	System.out.println("Preorder");
	preParse(node,root);
	System.out.print("\n");
	System.out.println("Inorder");
	inParse(node,root);
	System.out.print("\n");
	System.out.println("Postorder");
	postParse(node,root);
	System.out.print("\n");
    }
    static void preParse(Node node[],int s){
	if(s==-1)
	    return;
	System.out.print(" "+s);
	preParse(node,node[s].left);
	preParse(node,node[s].right);
    }
    static void inParse(Node node[],int s){
	if(s==-1)
	    return;
	inParse(node,node[s].left);
	System.out.print(" "+s);
	inParse(node,node[s].right);
    }
    static void postParse(Node node[],int s){
	if(s==-1)
	    return;
	postParse(node,node[s].left);
	postParse(node,node[s].right);
	System.out.print(" "+s);
    }
}
class Node{

    int parent;
    int left=-1;
    int right=-1;
    
    public Node(int parent){
	this.parent=parent;
    }
    public String isType(){
	if(parent==-1){
	    return "root";
	}else if(left==-1&&right==-1){
	    return "leaf";
	}else{
	    return "internal node";
	}
    }

    public int getSibling(Node node[],int id){
	if(parent==-1)
	    return -1;
	if(node[parent].left==id){
	    return node[parent].right;
	}else{
	    return node[parent].left;
	}
    }

    public int getDegree(){
	if(left==-1&&right==-1){
	    return 0;
	}else if((left!=-1&&right==-1)||(left==-1&&right!=-1)){
	    return 1;
	}else{
	    return 2;
	}
    }
    
    public int getDepth(Node node[]){
	int pID=parent;
	int count=0;
	while(pID!=-1){
	    pID=node[pID].parent;
	    count++;
	}
	return count;
    }

    public int getHeight(Node node[],int id){
	int Lheight=0;
	int Rheight=0;
	
	if(node[id].left==-1&&node[id].right==-1){
	    return 0;
	}else{
	    int l=node[id].left;
	    if(l!=-1){
		Lheight=getHeight(node,l)+1;
	    }
	    int r=node[id].right;
	    if(r!=-1){
		Rheight=getHeight(node,r)+1;
	    }
	}
	return Math.max(Lheight,Rheight);
    
    }
}



Measured memory_bytes: 24524
N,M = list(map(int,input().split()))
a= [0 for i in range(N+1)]
for i in range(M):
    a[int(input())]=1
 
S = [0 for i in range(N+1)] 
S[0]=1
if a[1]==1:
    S[1] = 0 
else:
    S[1] = 1
for i in range(2,N+1):
    if a[i]==1:
        S[i] = 0
    else:
        S[i]=(S[i-1]+S[i-2])%(10**9+7)
 
print(S[N])

Measured memory_bytes: 51180
#include<cstdio>
using namespace std;
int main(){
	unsigned int n;
	unsigned long long int a,ev=0,o=0;
	scanf("%u",&n);
	while(n--){
		scanf("%llu",&a);
		if(a&1)
		++ev;
		else
		++o;
	}
	if(ev%2==0)
	printf("YES");
	else
	printf("NO");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<llint,vector<llint>,greater<llint>> que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint a,b,x;

void solve(){
	cin >> a >> b >> x;
	if(x-a<=b && a<=x)cout << "YES" << endl;
	else cout << "NO" << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
int main()
{
	string s,t;
	cin >> s >> t;
	int count = 0;
	for(int i=0;i<(int)s.length();i++){
		if(s[i] != t[i])
			count++;
	}
	cout << count << "\n";
	return 0;
}


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

using namespace std;

int main()
{
  int N;
  int A[200];
  cin>> N;
  for(int i=0;i<N;i++)cin>> A[i];

  int ret=1000000000;
  for(int i=0;i<N;i++)
  {
    int cou=0;
    while(!(A[i]%2))
    {
      A[i]/=2;
      cou++;
    }
    ret=min(ret,cou);
  }
  cout<< ret<< endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;cin>>a>>b>>c;
    ll x,y;cin>>x>>y;
    ll ans = 1e15;
    for(ll abp=0;abp<=max(x,y)*100;abp+=2){
        ll rema = x - abp/2;
        rema=max(0ll,rema);
        ll remb = y - abp/2;
        remb=max(0ll,remb);
        ll cost = rema*a + remb*b + abp*c;
        ans=min(ans,cost);
    }
    cout<<ans;
}


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

using namespace std;

void printReasult(int A, int B){
    if (A>B) cout << "GREATER" << endl;
    else cout << "LESS" << endl;
}

int main(){
    string A,B;
    cin >> A >> B;
    while(A.size()>0){
        if(A.size()==B.size()){
            if(A[0]!=B[0]){
                printReasult(A[0]-'0',B[0]-'0');
                break;
            }else{
                A.erase(A.begin());
                B.erase(B.begin());
            }
        }else{
            printReasult(A.size(),B.size());
            break;
        }
    }
    if (A.size()==0) cout << "EQUAL" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>

using namespace std;
int main(){
  int x;
  scanf("%d",&x);
  if(x==7||x==5||x==3) printf("YES\n");
  else printf("NO\n");

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<assert.h>
#include<string.h>
#include<math.h>
 
#define MAX 1001
#define MAX_C 100001
#define max(a,b) ((a>b)?a:b)
 
int C, N, c[MAX], v[MAX], i, j, dp[MAX_C];
 
int main() {
  scanf("%d %d",&N,&C);
  assert( N < MAX );
  assert( C < MAX_C );
  for(i=0;i<N;i++) scanf("%d %d",v+i,c+i);
   
  memset(dp,-1,sizeof dp);
  dp[0] = 0;
  /*
    // 01 Knapsack
  for(i=0;i<N;++i) {
    for(j=C;j>=0;--j) if( dp[j] != -1 ) {
      if( j + c[i] <= C ) {
    dp[j+c[i]] = max(dp[j+c[i]],dp[j]+v[i]);
      }
    }
  }
  */
  // Knapsack
  for(i=0;i<N;++i) {
    for(j=0;j<C;++j) if( dp[j] != -1 ) {
    if( j+c[i] <= C ) {
      dp[j+c[i]] = max(dp[j+c[i]],dp[j]+v[i]);
    }
      }
  }
 
  int maxi = 0;
  for(i=0;i<=C;i++) maxi = max(maxi,dp[i]);
  printf("%d\n",maxi);
   
  return 0;
}

Measured memory_bytes: 3144
/*  -*- coding: utf-8 -*-
 *
 * 2825.cc: Quiz
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 10000;
const int MAX_M = 1000;
const int INF = 1 << 30;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

pii minscs[MAX_N];
int maxscs[MAX_N];

/* subroutines */

/* main */

int main() {
  for (;;) {
    int n, m;
    scanf("%d%d", &n, &m);
    if (n == 0) break;

    for (int i = 0; i < n; i++) minscs[i] = pii(0, i);
    fill(maxscs, maxscs + n, 0);

    for (int i = 0; i < m; i++) {
      int si, ki;
      scanf("%d%d", &si, &ki);

      for (int j = 0; j < ki; j++) {
	int cj;
	scanf("%d", &cj);
	cj--;
	maxscs[cj] += si;
	if (ki == 1) minscs[cj].first += si;
      }
    }

    sort(minscs, minscs + n);
    int &minsc0 = minscs[0].first, &mini0 = minscs[0].second;
    int &minsc1 = minscs[1].first, &mini1 = minscs[1].second;

    int maxd = 0;
    for (int i = 0; i < n; i++) {
      int d = maxscs[i] - (mini0 != i ? minsc0 : minsc1);
      if (maxd < d) maxd = d;
    }
    printf("%d\n", maxd + 1);
  }
  return 0;
}



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

int main() {
	int N; cin >> N;
	int maxx, sum=0;
	for(maxx=1; sum<N; ++maxx) sum += maxx;
	int excu=sum-N;
	for(int i=maxx-1; i>0; --i){
	    if(i!=excu) cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 256
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = INT()
if N % 500 <= A:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 27268
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string S;
    cin >> S;
    S.resize(4);
    if(S=="YAKI")cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                int N = scan.nextInt();
                int[] costs = new int[N];
                int[] cache = new int[N];
                for(int i = 0 ; i < N ; i++) {
                        costs[i] = scan.nextInt();
                        cache[i] = 2147483647;
                }
                cache[0] = 0;
                cache[1] = Math.abs(costs[1]-costs[0]);
                System.out.println(jump(costs, 2, cache));
                return;
        }

        private static int jump(int[] costs, int k, int[] cache) {
                for(int i = 2 ; i < costs.length ; i++) {
                    for(int j = k ; j > 0 ; j--){
                        cache[i] = Math.min(cache[i], cache[i-j]+(Math.abs(costs[i] - costs[i-j])));
                    }
                    //cache[i] = Math.min(cache[i-1]+Math.abs(costs[i-1]-costs[i]), cache[i-2]+Math.abs(costs[i-2]-costs[i]));
                }
                return cache[costs.length-1];
        }
}

Measured memory_bytes: 52548
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
int main(){
	string s;
	while(cin>>s) puts(s[2]==s[3]&&s[4]==s[5]?"Yes":"No");
}


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

int main(){
	string str; cin >> str; long long sum = 0 , cnt = 0;
	for(int i = 0 ; i < str.size() ; ++i) cnt += str[i] == '1';
	sum += (cnt / 2) * (cnt / 2 + 1) / 2 + ((cnt + 1) / 2) * ((cnt + 1) / 2 + 1) / 2;
	string str1; int cnt1 = 0;
	for(int i = 0 ; i < str.size() ; ++i)
		if(i + 1 < str.size() && str[i + 1] == '1' && str[i] == '1'){++cnt1; ++i;} else str1.push_back(str[i]);
	
	sum += cnt1 * (str.size() - cnt); int pre = 0;
	for(int i = 0 ; i < str1.size() ; ++i)
		if(str1[i] == '1'){++pre; int num0 = i - pre + 1; sum += str.size() - cnt - (pre & 1 ? (num0 + 1) >> 1 : (num0 >> 1));}

	cout << sum; return 0;
}


Measured memory_bytes: 3904
N,M=map(int,input().split())
Islands=[[10**9]*N for i in range(N)]
Edge=[]
S=0
for i in range(M):
  a,b,c=map(int,input().split())
  Islands[a-1][b-1]=c
  Islands[b-1][a-1]=c
  Edge.append([a-1,b-1,c])
for k in range(N):
  for i in range(N):
    for j in range(N):
      Islands[i][j]=min(Islands[i][j],Islands[i][k]+Islands[k][j])

ans=0
for a,b,c in Edge:
  if Islands[a][b]!=c:
    ans+=1
print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, W;
    cin >> N >> W;
    vector<ll> w(N + 1), v(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= w[i]) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
N = int(input())
L = []
for i in range(N):
  x = input().split()
  S = x[0]
  P = int(x[1])
  T = "n"
  for y in L:
    if S == y[0]:
        T = "y"
        y[1].append([P,i+1])
  if T == "n":
    L.append( [ S, [[P,i+1]] ] )

K = sorted(L)
for x in K:
  y = sorted(x[1],reverse=True)
  for a in y:
    print(a[1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll pre[500005] = {0};
ll nex[500005] = {0};

int main(){
	string s; cin >> s;
	pre[0] = 0;
	ll x = 1;
	for(int i = 0;i < s.size();i++){
		if(s[i] == '<') pre[i+1] = x++;
		else{
			pre[i+1] = 0;
			x = 1;
		}
	}
//	for(int i = 0;i <= s.size();i++) cout << pre[i] << " ";
//	cout << endl;
	x = 1;
	nex[s.size()] = 0;
	for(int i = s.size()-1;i >= 0;i--){
		if(s[i] == '>') nex[i] = x++;
		else{
			nex[i] = 0;
			x = 1;
		}
	}
//	for(int i = 0;i <= s.size();i++) cout << nex[i] << " ";
//	cout << endl;
	ll sum = 0;
	for(int i = 0;i <= s.size();i++){
		sum += max(pre[i],nex[i]);
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 8708
# C MP消費を抑えるにはABCとの差が小さけれは良い
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]
INF = 10**9


def dfs(now, a, b, c):
    if now == n:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    # 方法１　１つ飛ばす
    way1 = dfs(now + 1, a, b, c)
    # 方法２　合成魔法(MP10)
    way2 = dfs(now + 1, a + l[now], b, c)+10
    way3 = dfs(now + 1, a, b + l[now], c)+10
    way4 = dfs(now + 1, a, b, c + l[now])+10
    return min(way1, way2, way3, way4)


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		City[] cities = new City[n];
		for (int i = 0; i < n; i++) {
		    cities[i] = new City(i, sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(cities, new Comparator<City>() {
		    public int compare(City c1, City c2) {
		        return c1.x - c2.x;
		    }
		});
		PriorityQueue<Road> queue = new PriorityQueue<>();
		for (int i = 1; i < n; i++) {
		    queue.add(new Road(cities[i].x - cities[i - 1].x, cities[i], cities[i - 1]));
		}
		Arrays.sort(cities, new Comparator<City>() {
		    public int compare(City c1, City c2) {
		        return c1.y - c2.y;
		    }
		});
		for (int i = 1; i < n; i++) {
		    queue.add(new Road(cities[i].y - cities[i - 1].y, cities[i], cities[i - 1]));
		}
		UnionFindTree uft = new UnionFindTree(n);
		long total = 0;
		while (queue.size() > 0) {
		    Road r = queue.poll();
		    if (!uft.same(r.from.id, r.to.id)) {
		        uft.unite(r.from.id, r.to.id);
		        total += r.cost;
		    }
		}
	    System.out.println(total);
   }
   
   static class UnionFindTree {
       int[] parents;
       
       public UnionFindTree(int size) {
           parents = new int[size];
           for (int i = 0; i < size; i++) {
               parents[i] = i;
           }
       }
       
       public int find(int x) {
           if (parents[x] == x) {
               return x;
           } else {
               return parents[x] = find(parents[x]);
           }
       }
       
       public boolean same(int x, int y) {
           return find(x) == find(y);
       }
       
       public void unite(int x, int y) {
           int xx = find(x);
           int yy = find(y);
           if (xx == yy) {
               return;
           }
           parents[xx] = yy;
       }
   }
   
   static class Road implements Comparable<Road> {
       int cost;
       City from;
       City to;
       
       public Road (int cost, City from, City to) {
           this.cost = cost;
           this.from = from;
           this.to = to;
       }
       
       public int compareTo(Road another) {
           return cost - another.cost;
       }
   }
   
   static class City {
       int id;
       int x;
       int y;
       
       public City(int id, int x, int y) {
           this.id = id;
           this.x = x;
           this.y = y;
       }
   }
}




Measured memory_bytes: 95948
N, K = map(int, input().split())
A = list(map(int, ("0 "+input()).split()))


c = [0]*(N+1)
i = 1
cnt = 0
f = True

while cnt < K:
    if f and (c[A[i]] or A[i]==1):
        loop = cnt-c[A[i]]+1
        cnt += (K-cnt-1)//loop*loop
        f = False

    cnt += 1
    i = A[i]
    c[i] = cnt

print(i)

Measured memory_bytes: 32384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int n;
vector<int> data;
int nex[100100];
int dp[100100];

void makeNext(){
    rep(i,100100)nex[i]=-1;
    rep(i,n){
        if(data[i]==0)continue;
        int pos=i;
        bool used[100100]={};
        vector<int> moved;
        while(1){
            moved.pb(pos);
            if(nex[pos]!=-1){
                rep(j,moved.size()){
                    nex[moved[j]]=nex[pos];
                }
                break;
            }
            if(used[pos]){
                rep(j,moved.size()){
                    nex[moved[j]]=INF;
                }
                break;
            }
            used[pos]=true;
            pos+=data[pos];
            if(data[pos]==0){
                rep(j,moved.size()){
                    nex[moved[j]]=pos;
                }
                break;
            }
        }
    }
}

set<int> st;


int main(){
    cin>>n;
    rep(i,n){
        int a;
        cin>>a;
        data.pb(a);
    }
    
    
    rep(i,100100)dp[i]=INF;
    dp[0]=0;
    
    makeNext();
    for(int i=n-1;i>=0;i--)st.insert(i);
    
    while(st.size()){
        int i=*st.begin();
        st.erase(st.begin());
        if(data[i]!=0)continue;
        for(int j=1;j<=6;j++){
            int pos = i+j;
            if(data[pos]==0){
                if(dp[i]+1<dp[pos]){
                    dp[pos] = dp[i]+1;
                    if(pos<=n)st.insert(pos);
                }
            }
            else if(nex[pos]==INF);
            else{
                pos = nex[pos];
                if(dp[i]+1<dp[pos]){
                    dp[pos]=dp[i]+1;
                    if(pos<=n)st.insert(pos);
                }
            }
        }
    }
    cout<<dp[n-1]<<endl;
}

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

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

	int ans = 0;
	if (n <= k) {
		ans = x * n;
	}
	else if (k < n) {
		ans += x * k;
		ans += y * (n - k);
	}

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

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

int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  long long  x=0, y=0, count=0;
  long long C = N/(A+B);
  x += A*C;
  y += B*C;
  if(x+y <= N-A) x = x + A;
    else x =  N - y;
  if(x+y <= N-B) y = y + B;
    else y = N - x;
  cout << x << endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    scanf("%d\n",&n);
    int p[n];
    int count = 0;
    for(int i = 0; i < n; i++){
        scanf("%d",&p[i]);
    } 
    for(int r = 1; r < n; r++){
        if(r-1 >= 0 && r + 1 <n){
            if(p[r-1] < p[r]){
                if(p[r]<p[r+1]){
                    count++;
                }
            }else if(p[r-1]>p[r]){
                if(p[r]>p[r+1]){
                    count++;
                }
            }
        }
    }
    printf("%d\n",count);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;

int main(){
	long long int n;
	cin >> n;
	long long int sqr = (int)pow(n, 0.5);
	cout << (long long int)sqr * sqr << endl;
	return 0;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
constexpr int MAXN = 50;

string arr[2][MAXN];
int cost[MAXN];
map<string, ll> dp[2];
set<string> used[2];

bool IsPalindrom(const string& s) {
    loop(sz(s) >> 1) {
        if (s[i] != s[sz(s) - 1 - i]) {
            return false;
        }
    }
    return true;
}

ll Do(const string& s, int rev, int n) {
    if (IsPalindrom(s)) {
        return 0;
    }
    auto it = dp[rev].find(s);
    if (it != dp[rev].end()) {
        return it->second;
    }
    if (!used[rev].insert(s).second) {
        return 1e18;
    }
    ll res = 1e18;
    for (int i = 0; i < n; ++i) {
        bool ok = true;
        for (int j = 0; j < min(sz(s), sz(arr[rev][i])); ++j) {
            if (s[j] != arr[rev][i][j]) {
                ok = false;
                break;
            }
        }
        if (!ok) {
            continue;
        }
        if (sz(s) < sz(arr[rev][i])) {
            res = min(res, cost[i] + Do(arr[rev][i].substr(sz(s)), rev ^ 1, n));
        } else {
            res = min(res, cost[i] + Do(s.substr(sz(arr[rev][i])), rev, n));
        }
    }
    used[rev].erase(s);
    dp[rev][s] = res;
    return res;
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    loop(n) {
        cin >> arr[0][i] >> cost[i];
        arr[1][i] = arr[0][i];
        reverse(all(arr[1][i]));
    }
    ll ans = 1e18;
    loop(n) {
        used[0].clear();
        used[1].clear();
        ans = min(ans, cost[i] + Do(arr[0][i], 1, n));
    }
    if (ans == (ll)1e18) {
        RET(-1);
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3724
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def extgcd(a,b): # ax+by=1 をみたす(x,y)の組を求める
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return ( m + x%m ) % m
    
def nCk(n,k):
    res = 1
    a=n-k
    b=k
    for i in range(1,a+b+1):
        res = res*i%mod
    for i in range(1,a+1):
        res = res*mod_inv(i,mod)%mod
    for i in range(1,b+1):                                 
        res = res*mod_inv(i,mod)%mod
    return res
    
def main():
    n = inp()
    c = inpl()
    ans = 0
    c.sort()
    x = [pow(2,2*n-1,mod)]
    y = pow(2,2*n-2,mod)
    for _ in range(n-1):
        x.append((x[-1]+y)%mod)
    x.reverse()
    for i in range(n):
        ans += (x[i]*c[i])%mod
    ans %= mod
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 102216
package main

import (
  "sort"
  "fmt"
)

func CardGameForTwo(N int, a []int) int{
	var odd, even int
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	for i := 0; i < N; i++ {
		if i % 2 == 0 {
			odd += a[i]
		}else{
			even += a[i]
		}
	}
	return odd - even
}

func main() {
  	var N, n int
	var a []int
	fmt.Scanln(&N)
	for i := 0; i < N; i++ {
		fmt.Scan(&n)
		a = append(a, n)
	}
	diff := CardGameForTwo(N, a)
	fmt.Println(diff)
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n,m,x,y,x_max,y_min;
	cin >> n >> m >> x_max >> y_min;
	for (int i = 0; i < n; i++){
		cin >> x;
		if (x > x_max) x_max = x;
	}
	for (int i = 0; i < m; i++){
		cin >> y;
		if (y < y_min) y_min = y;
	}
	if (y_min > x_max) cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 256
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int shihab;
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
   // FI(); /// skip this line for compile
    string s;
    ll sum=0;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]!=0) sum+= s[i] - '0';
    }
    if(sum%9==0) cout << "Yes\n";
    else cout << "No\n";
    return 0;
    //code end
}
//okbye


Measured memory_bytes: 3748
n, m, x = map(int, input().split())
c = [list(map(int, input().split())) for i in range(n)]
ans = float("INF")

for i in range(1 << n):
    costs = 0
    understand = [0] * m
    for j in range(n):
        if i >> j & 1:
            costs += c[j][0]
            for k in range(m):
                understand[k] += c[j][k + 1]
    if min(understand) >= x:
        ans = min(ans, costs)
    
print(ans) if ans != float("INF") else print(-1)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll X, N;
    cin >> X >> N;
    set<ll> P;
    rep(i, N) {
        ll p;
        cin >> p;
        P.insert(p);
    }
    ll d = INF;
    ll ans = -1;
    rep2(i, -5, 200) {
        if (P.count(i)) {
            continue;
        }else {
            ll d2 = abs(X-i);
            if (d2 < d) {
                d = d2;
                ans = i;
            }
        }
    }
    cout << ans << '\n';

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
bool check(int x)
{
	if(x%2==0)
		return false;
	int s=0,i;
	for(i=1;i*i<x;i++)
		if(x%i==0)
			s++;
	s*=2;
	if(i*i==x)
		s++;
	if(s==8)
		return true;
	return false;
}
int main()
{
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		if(check(i))
			sum++;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
	
	
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			
			String S = sc.next();
			int L = S.length();
			StringBuilder buf = new StringBuilder();
			
			for (int i = 0;i<L;i++) {
				buf.append("x");
			}
			
			String res = buf.toString();
			
			System.out.println(res);
		}
		
		
	}

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

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin >> a.at(i);
  sort(a.begin(),a.end());
  cout << a.back() << ' ';
  int m=a[0];
  for(int i=0;i<n;i++)if(abs(a.back()-a.at(i)*2)<abs(a.back()-m*2))m=a.at(i);
  cout << m << endl;
  return 0;
}

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

using namespace std;

typedef long long int ll;

int main()
{
  ll n;
  cin>>n;
  ll ans=0;
  ll q=n/500;
  ll r=n-q*500;
  ans=q*1000 + (r/5)*5;
  cout<<ans;
  

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

ll sum(ll n) {
  ll res=0;
  while(n) {
    res+=n%10;
    n/=10;
  }
  return res;
}

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans=0;
  for(ll i=1;i<=n;i++) {
    ll tmp=sum(i);
    if(a<=tmp&&tmp<=b) ans+=i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
#define M 200005
int n,k,q,Cnt;
const int Mod=998244353;
int B[M],e[M];
struct Node {
	int x,y;
} A[M];
bool cmp(Node a,Node b) {
	return a.x<b.x;
}
struct BIT {
	int t[M];
	void clear() {
		memset(t,0,sizeof(t));
	}
	void Add(int x) {
		while(x<=n)++t[x],x+=x&-x;
	}
	int Query(int x) {
		int res=0;
		while(x)res+=t[x],x-=x&-x;
		return res;
	}
} T;
void mod(int &x,int a) {
	x+=a;
	if(x<0)x+=Mod;
	else if(x>=Mod)x-=Mod;
}
int main() {
	scanf("%d",&n);
	e[0]=1;
	for(int i=1; i<=n; ++i) {
		e[i]=e[i-1]+e[i-1];
		if(e[i]>=Mod)e[i]-=Mod;
	}
	for(int i=1; i<=n; ++i) {
		scanf("%d%d",&A[i].x,&A[i].y);
		B[i]=A[i].y;
	}
	sort(B+1,B+1+n);
	sort(A+1,A+1+n,cmp);
	for(int i=1; i<=n; ++i)A[i].y=lower_bound(B+1,B+1+n,A[i].y)-B;
	int Ans=1LL*(e[n]-1)*n%Mod;
	for(int i=1; i<=n; ++i)mod(Ans,2-e[i]),mod(Ans,2-e[n-i+1]);
	for(int i=1; i<=n; ++i) {
		T.Add(A[i].y);
		int tmp=T.Query(A[i].y);
		mod(Ans,e[tmp-1]-1);
		mod(Ans,e[i-tmp]-1);
	}
	T.clear();
	for(int i=n; i; --i) {
		int tmp=T.Query(A[i].y);
		mod(Ans,e[tmp]-1);
		mod(Ans,e[n-i-tmp]-1);
		T.Add(A[i].y);
	}
	printf("%d",Ans);
}

Measured memory_bytes: 4096
s = input()
n = len(s)
if s.count("A") <= 4 and s.replace("A", "") == "KIHBR":
    for i in range(1, n):
        if s[i] == "A" and s[i - 1] not in ["H", "B", "R"]: 
            print("NO")
            break
    else:
        print("YES")
else:
    print("NO")

Measured memory_bytes: 61908
min, max, K = map(int, input().split())

if ((max - min + 1) < 2*K):
    for i in range(min, max+1):
        print(i)

else:
    for i in range(min, min+K):
        print(i)
    for i in range(max-K+1, max+1):
        print(i)

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;

typedef pair<int, int> P;
int myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
bool E[101][101];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

int main() {
    double L;
    cin >> L;
    cout << fixed << setprecision(6) << (L * L * L) / 27 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MAX_N = 100001;

bool is_prime(int n){
    for(int i=2; i*i<=n; i++){
        if (n%i == 0)return false;
    }
    return n != 1;
}


int main() {
    int Q;
    cin >> Q;
    int curr = 0;
    vector<int>cumsm(MAX_N+1);
    cumsm[0] = 0;
    for(int i=0; i<MAX_N-1; i++){
       if (is_prime(i) && is_prime((i+1)/2) && i%2==1){
           cumsm[i+1] = cumsm[i] + 1;
           //if (i<100)cout << i << endl;
       } 
       else{
           cumsm[i+1] = cumsm[i];
       }
    }

    for (int i=0; i<Q; i++){
        int li, ri;
        cin >> li >> ri;
        cout << cumsm[ri+1] - cumsm[li] << endl;

    }


}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n;
	cin >> n;
	string s;
	vector<ll> a(5,0);
	for(ll i = 0; i < n; i++) {
		cin >> s;
		if(s[0] == 'M'){
			a[0]++;
		}
		else if(s[0] == 'A'){
			a[1]++;
		}
		else if(s[0] == 'R'){
			a[2]++;
		}
		else if(s[0] == 'C'){
			a[3]++;
		}
		else if(s[0] == 'H'){
			a[4]++;
		}
	}

	ll ans = 0;
	for(int i = 0; i < 3; i++) {
		for(int j = i+1; j < 4; j++) {
			for(int k = j+ 1; k < 5; k++) {
				ans += a[i] * a[j] * a[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pp push_back
#define fr first
#define sc second
#define mp make_pair
using namespace std;

int a[222];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);



    int x , n; cin >> x >> n;
    int ans = 0;
    for(int i = 0;i < n;i++){
        int t; cin >> t;
        a[t] = 1;
    }
    for(int i = 0;i < 200;i++){
        if(abs(ans - x) > abs(i - x) && !a[i]){
            ans = i;
        }
    }
    cout << ans << '\n';

    return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 




int main(){
string S;
cin >> S;
int N = S.size();
int ans = 0;
for(int i = 2; i < N; i += 2){
  if(S.substr(0, i / 2) == S.substr(i / 2, i / 2)) ans = i;
}

cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int n;
		boolean ans=true;
		String[] w = new String[101];

		n=sc.nextInt();

		for(int i=1;i<=n;i++) {
			w[i]=sc.next();
		}

		char ch=w[1].charAt(w[1].length()-1);

		for(int i=2;i<=n;i++) {
			if(ch==w[i].charAt(0)) {
				ch=w[i].charAt(w[i].length()-1);
			} else {
				ans=false;
				break;
			}
		}

		twho:for(int i=1;i<=n;i++) {
			for(int k=i+1;k<=n;k++) {
				if(w[i].equals(w[k])) {
					ans=false;
					break twho;
				}
			}
		}

		if(ans) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 23124