akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.Map.Entry;



public class Main{
	
	public int num;
	public int vol;

	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int N=sc.nextInt();
	 int[] a=new int[N];
	 
	 Map<Integer,Integer> map= new HashMap<Integer,Integer>();
	 
	 long result = 1;
	 for(int i=0;i<N;i++) {
		 int temp=sc.nextInt();
		 if(map.containsKey(temp)) {
			 map.put(temp, map.get(temp)+1);
		 }else {
			 map.put(temp, 1);
		 }
	 }
	 
     List<Entry<Integer, Integer>> list_entries = new ArrayList<Entry<Integer, Integer>>(map.entrySet());
     
     
     Collections.sort(list_entries, new Comparator<Entry<Integer, Integer>>() {
         public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) {
            
             return obj1.getValue().compareTo(obj2.getValue());
         }
     });
     
     int answer = 0;
     
     for(Entry<Integer, Integer> entry : list_entries) {
    	 
    	
    	 
    		long temp = entry.getValue();
    		
    		if(map.containsKey(entry.getKey()+1)) {
    			temp += map.get(entry.getKey()+1);
    		}
    		
    		if(map.containsKey(entry.getKey()-1)) {
    			temp += map.get(entry.getKey()-1);
    		}
    		
    		
    		
    		 if(temp>result) {
    			 result = temp;
    			 answer = entry.getKey();
    		 }
    	 
    	 
    	 
    	 
       
     }
     
     
     
     System.out.println(result);
	 
 }
	


}




Measured memory_bytes: 62548
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define ll long long
#define debug cout << __FILE__ << ":" << __LINE__ << endl;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}

int gcd(int a, int b) {
    if (a < b) a, b = b, a;
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

void solve() {
    int N;
    cin >> N;

    int M[N][3];
    rep(i, N) {
        cin >> M[i][0] >> M[i][1] >> M[i][2];
    }

    rep(i, 101) {
        rep(j, 101) {
            set<int> s;
            rep(k, N) {
                int x = M[k][0];
                int y = M[k][1];
                int h = M[k][2];

                if (h == 0) continue;

                int t = abs(i - x) + abs(j - y) + h;
                s.insert(t);
            }
            if (s.size() != 1) continue;

            bool f = true;
            int v = *s.begin();
            rep(k, N) {
                int x = M[k][0];
                int y = M[k][1];
                int h = M[k][2];

                int t = max(v - abs(i - x) - abs(j - y), 0);
                if (t != h) {
                    f = false;
                    break;
                }
            }
            if (f) {
                printf("%d %d %d", i, j, v);
                exit(0);
            }
        }
    }
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    cout.precision(20);
    cout << fixed;

    solve();
}


Measured memory_bytes: 256
from collections import deque, Counter
from itertools import chain, combinations
import json
import numpy as np
import bisect
import sys

sys.setrecursionlimit(10 ** 8)
# mem = {}

M = 10 ** 9 + 7


def main():
    N = input()
    print('Yes' if '7' in N else 'No')
    # b, c = [int(a) for a in input().split()]
    # print()




if __name__ == "__main__":
    main()


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct BIT {
    int N, id; vector<int> bit; vector<pair<int, int>> his;
    BIT(int N, int id=0) : N(N), id(id), bit(N+1), his() {
        for (int i = 1; i <= N; ++i) add(i, id, false);
    }
    void add(int i, int v, bool flg=true) {
        if (flg) his.emplace_back(i, v);
        for (int j = i; j <= N; j += j & -j) bit[j] += v;
    }
    int sum(int i) {
        int res = 0;
        for (int j = i; j > 0; j -= j & -j) res += bit[j];
        return res;
    }
    int sum(int l, int r) {return sum(r-1) - sum(l-1);}
    void clear() {
        for (auto &p : his) add(p.first, -p.second, false);
        his.clear();
    }
};

vector<int> G[MAX];

int dfs(int v, vector<int> &in, vector<int> &out, int p=-1, int k=1) {
    in[v] = k++;
    for (auto &u : G[v]) {
        if (u == p) continue;
        k = dfs(u, in, out, v, k);
    }
    return out[v] = k;
}

ll calc(ll x) {return x*(x+1)/2;}

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

    vector<int> C(N);
    for (auto &i : C) cin >> i, --i;

    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> in(N), out(N);
    dfs(0, in, out);

    BIT bit = BIT(N, 1);

    vector<vector<int>> V(N);
    rep(i, N) V[C[i]].push_back(i);
    rep(i, N) {
        sort(V[i].begin(), V[i].end(), [&](int a, int b) {
            return in[a] > in[b];
        });
    }

    ll total = calc(N);

    rep(i, N) {
        ll ans = total;
        vector<int> &NV = V[i];
        for (auto &v : NV) {
            int cnt = 1;
            for (auto &u : G[v]) {
                if (in[v] > in[u]) continue;
                int num = bit.sum(in[u], out[u]);
                ans -= calc(num);
                cnt += num;
            }
            bit.add(in[v], -cnt);
        }
        int num = bit.sum(1, N+1);
        ans -= calc(num);
        cout << ans << endl;
        bit.clear();
    }
}

Measured memory_bytes: 41272
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    int n; string s; int k;
    cin >> n >> s >> k;
    char tmp = s[k - 1];
    rep(i, s.size()) {
        if (s[i] != tmp) s[i] = '*';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,mark=0;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=3;i++){
		 int h=i*n*m;
		 if(h%2){
		 	mark=1;
		 	printf("Yes\n");
		    return 0;
		}
	}
	printf("No\n");
	return 0; 
}

Measured memory_bytes: 256
#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[i];
  
  int total=0;
  vector<int>	ans(n+1);
  for(int i=n/2+1;i<=n;i++){
    ans[i]=a[i];
    if(ans[i]==1)	total++;
  }
  
  for(int i=n/2;i>=1;i--){
    int cnt=2;
    int sum=0;
    while(i*cnt<=n){
      sum+=ans[i*cnt];
      cnt++;
    }
    if(sum%2==a[i])	a[i]=0;
    else{
      ans[i]=1;
      total++;
    }
  }
  cout << total << endl;
  for(int i=1;i<=n;i++){
    if(ans[i]==0)	continue;
    cout << i << endl;
  }
}

Measured memory_bytes: 4716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(Math.min(n * a, b));

		sc.close();
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int a,b;
  string s;
  cin >> a >> s >> b;

  if (s == "+") pr(a+b);
  else pr(a-b);


  return 0;
}


Measured memory_bytes: 256
import numpy as np

def main():
	N, M = map(int,input().split())

	As = sorted(list(map(int,input().split())))
	BCs = []

	for i in range(M):
		inputs = list(map(int,input().split()))
		BCs.append(inputs)
	BCs = sorted(BCs, reverse = True, key=lambda x: x[1])

	index = 0
	for bc in BCs:
		b = bc[0]
		c = bc[1]

		for n in range(b):
			try:
				if As[index] < c:
					As[index] = c
					index += 1
				else:
					print(sum(As))
					return
			except:
				print(sum(As))
				return
	print(sum(As))

if __name__ == '__main__':
	main()

Measured memory_bytes: 42676
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int K, T;
  cin >> K >> T;
  vector<int> A(T);
  int mx = 0;
  rep(i, T) {
    cin >> A[i];
    mx = max(A[i], mx);
  }
  cout << (mx<=(K+1)/2 ? 0 : mx-1-(K-mx)) << endl;
  return 0;
}


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

using namespace std;

int main()
{
	char s[10];
	scanf("%s",s);
	for (int i=0;i<strlen(s)-1;i++)
	{
		if (s[i]=='A')
		{
			if (s[i+1]=='C')
			{
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
  speed;
  vector<ll> s;
  ll n,t=0,p=0;
  
  cin>>n;
  ll a[n];
  
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    t^=a[i];
  }
  p=t;
  for(int i=0;i<n;i++)
  {
    t=p;
    s.push_back(t^a[i]);
  }
  
  for(int i:s)
    cout<<i<<" ";
  
  return 0;
}
  

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

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

template <typename T, typename U>
bool chmin(T &a, const U &b){
  return (a > b ? a = b, true : false);
}

template <typename T, typename U>
bool chmax(T &a, const U &b){
  return (a < b ? a = b, true : false);
}

template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v){
  std::fill((U*)a, (U*)(a + N), v);
}

template <typename T, size_t N, size_t I = N>
auto make_vector(const std::array<int, N> &a, T value = T()){
  static_assert(I >= 1);
  static_assert(N >= 1);
  if constexpr (I == 1){
    return std::vector<T>(a[N - I], value);
  }else{
    return std::vector(a[N - I], make_vector<T, N, I - 1>(a, value));
  }
}

template <typename T>
std::ostream& operator<<(std::ostream &s, const std::vector<T> &a){
  for(auto it = a.begin(); it != a.end(); ++it){
    if(it != a.begin()) s << " ";
    s << *it;
  }
  return s;
}

template <typename T>
std::istream& operator>>(std::istream &s, std::vector<T> &a){
  for(auto &x : a) s >> x;
  return s;
}


namespace haar_lib {}

namespace solver {
  using namespace haar_lib;

  constexpr int m1000000007 = 1000000007;
  constexpr int m998244353 = 998244353;

  void init(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(12);
    std::cerr << std::fixed << std::setprecision(12);
    std::cin.exceptions(std::ios_base::failbit);
  }

  void solve(){
    int64_t N, X, M; std::cin >> N >> X >> M;

    std::vector<int> check(M);
    int64_t a = X;

    int tail = 0, cycle = 0;

    {
      int i = 1;
      while(true){
        check[a] = i;

        a = a * a % M;
        ++i;
        if(check[a] > 0){
          tail = check[a] - 1;
          cycle = i - check[a];
          break;
        }
      }
    }

    // for(int64_t i = 0, a = X; i < 30; ++i){
    //   std::cerr << a << " ";
    //   a = a * a % M;
    // }
    // std::cerr << "\n";


    //dump(tail, cycle);

    int64_t ans = 0;

    if(N <= tail){
      int64_t a = X;
      for(int i = 0; i < N; ++i){
        ans += a;
        a = a * a % M;
      }
    }else{
      int64_t a = X;
      for(int i = 0; i < tail; ++i){
        ans += a;
        a = a * a % M;
      }

      N -= tail;

      {
        int64_t b = a, s = 0;
        for(int i = 0; i < cycle; ++i){
          s += b;
          b = b * b % M;
        }

        ans += s * (N / cycle);
      }

      {
        int64_t b = a;
        for(int i = 0; i < N % cycle; ++i){
          ans += b;
          b = b * b % M;
        }
      }
    }

    std::cout << ans << "\n";
  }
}

int main(){
  solver::init();
  while(true){
    try{
      solver::solve();
    }catch(const std::istream::failure &e){
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3992
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string S;
    cin>>S;
    if(S.size()%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    for(ll i=0;i<S.size();){
        if(S[i]!='h' || S[i+1]!='i'){
            cout<<"No"<<endl;
            return 0;
        }
        i+=2;
    }
    cout<<"Yes"<<endl;
    
    return 0;
}


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

#define putchar_unlocked putchar

char T[550005];

// Based on editorial solution
int D[13][550005]; // one digit at a time, with digit 0 representing the ones place
int W[13][550005];
int lastUpdated[13][550005];

inline void putInt(int i){
    if(i==0){putchar_unlocked('0');}
    else{
    int x[11];
    int count1=0;
    while(i>0){
        x[count1++]=i%10;
        i/=10;
    }
    for(int j=count1-1;j>=0;j--){
        putchar_unlocked(48+x[j]);
    }
    }
    putchar_unlocked(' ');
}

int N;

void update(int n, int indx, int cntS){
    if((cntS&1) != (lastUpdated[n][indx]&1)){
        // conduct salsa
        if(D[n][indx] == 1){
            D[n][indx] = 2;
        }else if(D[n][indx] == 2){
            D[n][indx] = 1;
        }
    }
    // updated the lastUpdated index
    lastUpdated[n][indx] = cntS;
}

int pow3[16];

int main(){
    scanf("%d", &N);

    scanf(" %s", T);

    int M = strlen(T);

    pow3[0] = 1;
    for(int i = 1; i <= N; i ++){
        pow3[i] = pow3[i-1]*3;
    }

    int pow3N = pow3[N];

    //printf("ok");
    memset(W, 0, sizeof(W));
    for(int n = 1; n <= N; n ++){
        //printf("ok");
        for(int j = 0; j < pow3[N]; j ++){
            D[n][j] = (j%pow3[n])/pow3[n-1];
            //printf("D[%d][%d]=%d\n", n, j, D[n][j]);
        }
        W[n][0] = pow3[n]-1;
    }


    memset(lastUpdated, 0, sizeof(lastUpdated));
    int cntS2 = 0;
    for(int n = 1; n <= N; n ++){
        int cntS = 0;
        for(int i = 0; i < M; i ++){
            int indx0 = W[n-1][i];
            int indx1 = W[n-1][i]+pow3[n-1];
            if(indx1 >= pow3[n]){
                indx1 -= pow3[n];
            }
            int indx2 = W[n-1][i]+(pow3[n-1]<<1);
            if(indx2 >= pow3[n]){
                indx2 -= pow3[n];
            }

            update(n, indx0, cntS+(T[i]=='S'));
            update(n, indx1, cntS+(T[i]=='S'));
            update(n, indx2, cntS+(T[i]=='S'));
            if(D[n][indx0] == 2){
                W[n][i] = indx0;
            }else if(D[n][indx1] == 2){
                W[n][i] = indx1;
            }else{
                W[n][i] = indx2;
            }

            if(T[i] == 'R'){
                D[n][indx0] = (D[n][indx0]+1);
                D[n][indx1] = (D[n][indx1]+1);
                D[n][indx2] = (D[n][indx2]+1);
                if(D[n][indx0] == 3){D[n][indx0] = 0;}
                if(D[n][indx1] == 3){D[n][indx1] = 0;}
                if(D[n][indx2] == 3){D[n][indx2] = 0;}
                lastUpdated[n][indx0] = cntS;
                lastUpdated[n][indx1] = cntS;
                lastUpdated[n][indx2] = cntS;
            }else if(T[i] == 'S'){
                cntS ++;
            }

            //printf("W[%d][%d]=%d\n", n, i+1, W[n][i+1]);
        }

        cntS2 = cntS;
    }

    for(int n = 1; n <= N; n ++){
        for(int i = 0; i < pow3[n]; i ++){
            update(n, i, cntS2);
        }
    }

    for(int i = 0; i < pow3[N]; i ++){
        int temp = 0;
        for(int n = 1; n <= N; n ++){
            temp += D[n][i%pow3[n]]*pow3[n-1];
        }
        putInt(temp);
    }

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int arr[n];
    int ar2[n];
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
        ar2[i] = arr[i];
    }
    sort(ar2, ar2+n);
    int cnt=0;
    int val[2];
    val[0] = -1;
    val[1] = -1;
    int flag = true;
    for(int i=0; i<n-1; i++)
    {
        if(arr[i]>arr[i+1])
        {
            if(cnt<2)
                val[cnt] = i;
            cnt++;
            if(cnt>2)
                flag = false;
        }
    }
    if(flag == true)
    {
        if(val[0]!=-1 and val[1]!=-1)
            swap(arr[val[0]], arr[val[1]+1]);
        for(int i=0; i<n; i++)
        {
            if(arr[i]!=ar2[i])
                flag = false;
        }
    }
    if(flag == true)
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}


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

long long dp[110][100010];
 
int main(){
  int n,w;cin >> n >> w;
  int weight[n],value[n];
  rep{
    cin >> weight[i] >> value[i];
  }
  for(int i = 0;i<=n;i++){
    for(int j = 0;j<=100001;j++){
      dp[i][j] =  w+1;
    }
  }
  dp[0][0] = 0;
  for(int i = 0;i<n;i++){
    for(int j = 0;j<= 100001;j++){
      if(j-value[i]>=0){
        dp[i+1][j] = min(dp[i][j],dp[i][j-value[i]]+weight[i]);
      }else{
        dp[i+1][j] = dp[i][j];
      }
      //cout << dp[i+1][j] << " ";
    }//cout << endl;
  }
  long long ans = 0;
  for(int i = 0;i<=100001;i++){
    if(dp[n][i]<=w) ans = i;
  }
  cout << ans << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &h.at(i));
    }

    sort(h.begin(), h.end());

    auto itr = lower_bound(h.begin(), h.end(), k);
    int ans = distance(itr, h.end());

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.*;

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

		int N = scanner.nextInt();
		ArrayList<Integer> array = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			array.add(scanner.nextInt());
		}

		int ans = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = i + 1; j < N; j++) {
				ans += array.get(i) * array.get(j);
			}
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 23252
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,x,t = LI()
    print(t*math.ceil(n/x))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 65480
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll x[51],y[51];
	map<pll,int> kumi;
	int kumimax=0;
	scan(N);
	rep(i,N){
		scan(x[i]>>y[i]);
	}
	rep(i,N){
		rep(j,N){
			if(i==j) continue;
			kumi[{x[i]-x[j],y[i]-y[j]}]++;
			kumimax=max(kumimax,kumi[{x[i]-x[j],y[i]-y[j]}]);
		}
	}
	prin(N-kumimax);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  a--;
  b--;
  c--;
  d--;
  string s;
  cin>>s;
  
  int e=0;
  int ch=0;
  
  if(c<d){
    Rep(i,a,d){
      if(s[i]=='.'){
        e=0;
      }
      else{
        e++;
        ch=max(e,ch);
      }
    }
    Ans(ch<=1);
  }
  
  else{
    Rep(i,a,d){
      if(s[i]=='.'){
        e=0;
      }
      else{
        e++;
        ch=max(e,ch);
      }
    }
    int z=0;
    int x=0;
    Rep(i,b-1,d+2){
      if(s[i]=='.'){
        z++;
        x=max(x,z);
      }
      else{
        z=0;
      }
    }
    
    Ans(ch<=1 && x>=3);
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

/*int makecontest(int day, vector<vector<int>>&s, vector<int>&c, vector<int>&last, int sat) {
  
}*/

int score(const int d, const vector<vector<int>>&s, const vector<int>&c, vector<int>&contests) {
  //vector<int> contests(d);
  vector<int> last(26, 0);
  int sat = 0;
  //makecontest(s, c, last, contests);
  for (int i = 0; i < d; i++) {
    //cout << d << " " << i << endl;
    last[contests[i]-1] = i+1;
    sat += s[i][contests[i]-1];
    for (int j = 0; j < 26; j++) {
      sat -= c[j] * (i+1 - last[j]);
    }
    //cout << sat << endl;
  }
  return sat;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15);

  int d;
  cin >> d;
  vector<int> c(26);
  for (int i = 0; i < 26; i++) cin >> c[i];
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }

  vector<int> contests(d);
  //for (int i = 0; i < d; i++) cin >> contests[i];
  for (int i = 0; i < d; i++) {
    int mx = 0, ct;
    for (int j = 0; j < 26; j++) {
      mx = max(mx, s[i][j]);
      if (mx == s[i][j]) ct = j+1;
    }
    contests[i] = ct;
  }
  
  int sc = score(d, s, c, contests);
  //cout << sc << endl;
  for (int p = 0; p < 10000; p++) {
    srand(time(NULL));
    int day = rand() % d;
    int q = rand() % 26;
    //cout << day << " " << q << endl;
    int old = contests[day];
    contests[day] = q + 1;
    if (score(d, s, c, contests) < sc) {
      contests[day] = old;
      continue;
    }
    sc = score(d, s, c, contests);
    //cout << sc << endl;
  }
  //cout << sc << endl;

  for (int i = 0; i < d; i++) cout << contests[i] << endl;
}


Measured memory_bytes: 3676
/**
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 *  Institute : Pandit Deendayal Petroleum University
 **/
#include <bits/stdc++.h>

using namespace std;

void solve()
{
    string s;
    cin >> s;
    int c = 0, x = 0;
    for (auto it : s)
        if (it == 'R')
            ++c;
        else
        {
            x = max(c, x);
            c = 0;
        }
    x = max(c, x);
    cout << x;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3636
import collections
import math

N = int(input())

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(int(n))
    return table


def aaa(num):
    tmp = (math.sqrt(8*num+1)-1)/2
    t = math.floor(tmp)
    return t


c = collections.Counter(prime_decomposition(N))


ans = 0
d = list(c.values())

for i in range(len(d)):
    if d[i] == 1:
        ans += 1
    else:
        ans += aaa(d[i])
        
print(ans)

Measured memory_bytes: 9560
import java.util.*;
public class Main {
	private static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		byte a = sc.nextByte();
		for (int l=0; l<a; l++){
			byte gx=sc.nextByte();
			byte gy=sc.nextByte();
			byte No [][] = new byte [gx+1][gy+1];
			byte b = sc.nextByte();
			for (int k=0; k<b; k++){
				byte x1=sc.nextByte();
				byte y1=sc.nextByte();
				byte x2=sc.nextByte();
				byte y2=sc.nextByte();
				
				if (x1 == x2) {
					No [x1][(Math.max(y1, y2))]+=1;
				}
				else {No[(Math.max(x1,x2))][y1]+=2;}			
			}
			int Total[][] = new int [gx+1][gy+1];
			Total[0][0] = 1;
			for (int i=0; i<=gx; i++){
				for (int j=0; j<=gy; j++){
					if (No[i][j] == 0){
						if (i>0 & j>0){
							Total[i][j]=Total[i-1][j]+Total[i][j-1];
						}
						else if (i>0){
							Total[i][j]=Total[i-1][j];
						}
						else if (j>0){
							Total[i][j]=Total[i][j-1];
						}
						else;
					}
					else if(No[i][j] == 1){
						if (i>0){
							Total[i][j]=Total[i-1][j];
							}
						else Total[i][j]=0;
					}
					else if(No[i][j] == 2){
						if (j>0){
						Total[i][j]=Total[i][j-1];
						}
						else Total[i][j]=0;
					}
					else {
						Total[i][j]=0;
					}
				}
			}
			if (Total[gx][gy]==0){
				System.out.println("Miserable Hokusai!");
			}
			else {System.out.println(Total[gx][gy]);
			}
		}
	}
}

Measured memory_bytes: 33320
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
const int MAX=1e5+10;
char a[MAX];
int main()
{
    long long n;
    cin>>a;
    int len=strlen(a);
    long long sum=0;
    long long sum1=0;
    for(int i=0;i<len;i++)
        sum1+=(int)(a[i]-'0');
    sum+=(int)(a[0]-'0')-1;
    sum+=(len-1)*9;
    if(sum<0)
        sum=0;
    if(len==1)
    {
        cout<<a[0]<<endl;
        return 0;
    }
    int flag=0;
    for(int i=0;i<len;i++)
    {
        if(a[i]!='9')
        {
            flag=1;
            break;
        }
    }
    if(!flag)
        sum++;
    cout<<max(sum,sum1)<<endl;
    return 0;
}


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

int main(){
    int tt,ts,h,t,o,a,b,tmp,count=0;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        tmp=i;
        tt=tmp/10000;
        tmp-=tt*10000;
        ts=tmp/1000;
        tmp-=ts*1000;
        h=tmp/100;
        tmp-=h*100;
        t=tmp/10;
        tmp-=t*10;
        o=tmp;
        if((tt==o)&&(ts==t))count++;
    }
    cout<<count<<endl;
    return 0;
}

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

int n, q;
string s;
char t[200010], d[200010];

int f(int n) {  // 左に落ちる→-1、落ちない→0、右に落ちる→1
  for (int i = 0; i < q; i++) {
    if (s[n] == t[i]) {
      if (d[i] == 'L') n--;
      if (d[i] == 'R') n++;
    }
    if (n < 0)
      return -1;
    if (s.size() <= n)
      return 1;
  }
  return 0;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

// ====================================================================

int main() {
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];

  // にぶたん
  int left = 0, right = s.size();
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (f(mid) == -1)
      left = mid;
    else
      right = mid;
  }
  int l = right;

  left = 0;
  right = s.size();
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (f(mid) != 1)
      left = mid;
    else
      right = mid;
  }
  int r = right;

  cout << r - l << endl;
}


Measured memory_bytes: 900
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const int inf=1000000000;
struct edge{
	int to,cost;
};

int main() {
	string s;
	cin>>s;
	int ls=s.length();
	bool d[4]={};
	for(int i=0;i<ls;++i){
		if(s[i]=='N')d[0]=true;
		if(s[i]=='W')d[1]=true;
		if(s[i]=='S')d[2]=true;
		if(s[i]=='E')d[3]=true;
	}
//	cout<<d[0]<<" "<<d[1]<<endl;
	if(d[0]==d[2]&&d[1]==d[3]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var min, max, target, count int
	fmt.Scan(&min, &max, &target)
	for i := min; i < max+1; i++ {
		if target%i == 0 {
			count++
		}
	}
	fmt.Println(count)
}



Measured memory_bytes: 1176
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(int n, int k) {
        int res = 0;
        while (n > 0) {
            ++res;
            n /= k;
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    Solution sol;

    cout << sol.solve(n, k) << "\n";

    return 0;
}

Measured memory_bytes: 256
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define inf 1e18
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
	ll n; cin>>n;
	char s[20000];
	int i=0;
	while(n > 0){
		int x = n%26;
		if(x == 0){
			s[i++] = 'z';
			n = (n/26) - 1;
		}
		else{
			s[i++] = (x-1) + 'a';
			n /= 26;
		}
	}
	string ans = "";
	f(j,i) ans += s[j];
	reverse(all(ans));
	cout<<ans<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#define MAX 21
using namespace std;

typedef struct {
    int PositionX;
    int PositionY;
    bool field[MAX][MAX];
} Player;

int main() {
    Player xy_player;
    while (true) {
        xy_player.PositionX=10;
        xy_player.PositionY=10;
        for (int i=0; i<MAX; i++) {
            for (int j=0; j<MAX; j++) {
                xy_player.field[i][j]=false;
            }
        }
        int N;
        scanf("%d",&N);
        if (N==0) {
            break;
        }
        int x, y;
        for (int i=0; i<N; i++) {
            scanf("%d %d",&x,&y);
            xy_player.field[y][x]=true;
        }
        int M;
        scanf("%d",&M);
        char direction;
        int move;
        for  (int i=0; i<M; i++) {
            cin >> direction >> move;
            switch (direction) {
                case 'N':
                    for (int j=0; j<=move; j++) {
                        xy_player.field[xy_player.PositionY+j][xy_player.PositionX]=false;
                    }
                    xy_player.PositionY+=move;
                    break;
                case 'E':
                    for (int j=0; j<=move; j++) {
                        xy_player.field[xy_player.PositionY][xy_player.PositionX+j]=false;
                    }
                    xy_player.PositionX+=move;
                    break;
                case 'S':
                    for (int j=0; j<=move; j++) {
                        xy_player.field[xy_player.PositionY-j][xy_player.PositionX]=false;
                    }
                    xy_player.PositionY-=move;
                    break;
                case 'W':
                    for (int j=0; j<=move; j++) {
                        xy_player.field[xy_player.PositionY][xy_player.PositionX-j]=false;
                    }
                    xy_player.PositionX-=move;
                    break;
                default:
                    break;
            }
        }
        bool jewelry=true;
        for (int i=0; i<MAX; i++) {
            for (int j=0; j<MAX; j++) {
                if (xy_player.field[i][j]==true) {
                    jewelry=false;
                }
            }
        }
        if (jewelry) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 3088
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> tree[55];
map<ll,ll> vertex;
vector<ll> edge_use[25];

ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x, n/2);
    if(n % 2 == 1) res = res * x;
    return res;
}

bool dfs(ll cur, ll par, ll target){
    bool flg = false;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        flg |= dfs(e, cur, target);
    }
    if(cur == target){
        flg = true;
    }
    if(flg) vertex[cur]++;
    return flg;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll a[55], b[55];
    map<lpair, ll> mp;
    rep(i,0,N-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        mp[{a[i], b[i]}] = i+1;
        mp[{b[i], a[i]}] = i+1;
        tree[a[i]].push_back(b[i]);
        tree[b[i]].push_back(a[i]);
    }

    ll M;
    cin >> M;
    ll u[25], v[25];
    rep(i,0,M){
        cin >> u[i] >> v[i];
        u[i]--; v[i]--;
    }

    ll ans = 0;
    rep(i,0,M){
        vertex.clear();
        bool res = dfs(u[i], -1, v[i]);
        rep(j,0,N-1){
            if(vertex[a[j]] > 0 && vertex[b[j]] > 0) edge_use[i].push_back(j);
        }
    }


    rep(bit,1,(1LL<<M)){
        ll cnt = __builtin_popcount(bit);
        ll check[55] = {};
        rep(i,0,M){
            if((bit>>i) & 1){
                for(auto &e: edge_use[i]){
                    check[e] = 1;
                }
            }
        }
        ll check_cnt = 0;
        rep(i,0,N-1){
            if(check[i] > 0) check_cnt++;
        }
        check_cnt = N-1 - check_cnt;
        ll res = power(2, check_cnt);
        if(cnt % 2 == 1){
            ans += res;
        }else{
            ans -= res;

        }
    }
    ans = power(2,N-1) - ans;
    print(ans);

    

}

Measured memory_bytes: 384
def calc(n):
    for i in range(1, n+1):
        if i % 3 == 0:
            print("", i, end='')
            continue

        x = i

        while x > 0:
            if x % 10 == 3:
                print("", i, end='')
                break

            x = x // 10

    print()

calc(int(input()))



Measured memory_bytes: 6240
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int A = sc.nextInt();
        int B = sc.nextInt();
        String N = sc.next();

        if (S.equals(N)) {
            A--;
        } else {
            B--;
        }
        System.out.println(A + " " + B);
    }
}

Measured memory_bytes: 21844
n, a, b = map(int, input().split())
X = list(map(int, input().split()))
fatigue = 0
for i in range(n-1):
    dis_X= X[i+1]-X[i]
    if(a*dis_X >= b):
        fatigue += b
    else:
        fatigue += a*dis_X
print(fatigue)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 5;

ll v[N];

int main()
{
    int n;
    scanf("%d", &n);
    ll sum = 0;
    for(int i = 0; i < n; ++i)
    {
        scanf("%lld", &v[i]);
        sum += v[i];
    }
    ll ans = abs(v[0] - (sum - v[0]));
    ll k = v[0];
    for(int i = 1; i < n - 1; ++i)
    {
        k += v[i];
        ans = min(ans, abs(k - (sum - k)));
    }
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c)
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000007
#define PI           acos(-1.0)
#define MAX3(a,b,c)  max(a,max(b,c))

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

//x = 1e18 means 10^18
//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//printf("%I64d\n", a);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> X;
//map <ll,ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//bool ok = true;
//char ch;
string S, T, U;
ll i=0, j=0, k=0, a, b, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);//NULL
    cout.tie(nullptr);//NULL

    cin>>S>>k;

    T=S;
    auto ip = unique(all(T));
    T.resize(distance(T.begin(), ip));

    if(T.sz==1)
    {
        cout<<(S.sz*k)/2<<endl;
        return 0;
    }

    ll A[105]= {0};

    f0(i,S.sz-1)
    {
        if(S[i]==S[i+1])
        {
            A[i]=1;
            i++;
        }
    }

    ans = count(A,A+S.sz-1, 1);

    if(S[0]!=S[S.sz-1])
    {
        cout<<ans*k<<endl;
    }
    else
    {
        f0(i,S.sz)
        {
            if(S[0]!=S[i])
            {
                a = i;
                break;
            }
        }
        for(ll i=S.sz-1; i>=0; i--)
        {
            if(S[0]!=S[i])
            {
                b = abs(S.sz-1-i);
                break;
            }
        }
        cout<<(ans*k)-(((a/2)+(b/2)-(a+b)/2)*(k-1))<<endl;
    }
    return 0;
}


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

#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef pair<int,int> P;
typedef pair<int,P> PP;

int main(){
    int N,C;
    cin>>N>>C;
    vector<PP> v(N),vv;
    REP(i,N){
        int s,t,c;
        cin>>s>>t>>c;
        v[i]=PP(c,P(s,t));
    }
    sort(ALL(v));
    REP(i,N){
        if(vv.size()==0)vv.pb(v[i]);
        else if(vv.back().fi==v[i].fi&&vv.back().se.se==v[i].se.fi)vv.back().se.se=v[i].se.se;
        else vv.pb(v[i]);
    }
    N=vv.size();
    vector<int> s(212345,0);
    REP(i,N){
        vv[i].se.fi *=2;
        vv[i].se.fi +=1;
        vv[i].se.se *=2;
        vv[i].se.se +=2;
        s[vv[i].se.fi]++;
        s[vv[i].se.se]--;
    }
    int ret=0;
    FOR(i,1,212345){
        s[i]+=s[i-1];
        chmax(ret,s[i]);
        
    }
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 3572
program chocolate_bar
  implicit none
  integer :: h, w, i
  integer(8) :: m, s1, s2, s3
  read(*,*) h, w
  if (mod(h,3)*mod(w,3) == 0) then
    write(*,'(i0)') 0
    stop
  end if
  m = min(h,w)
  do i = 1, h-1
    s1 = int(i,8)*int(w,8)
    s2 = int(h-i,8)*int(w/2,8)
    s3 = int(h-i,8)*int(w-w/2,8)
    m = min(m,max(s1,s2,s3)-min(s1,s2,s3))
  end do
  do i = 1, w-1
    s1 = int(i,8)*int(h,8)
    s2 = int(w-i,8)*int(h/2,8)
    s3 = int(w-i,8)*int(h-h/2,8)
    m = min(m,max(s1,s2,s3)-min(s1,s2,s3))
  end do
  write(*,'(i0)') m
end program chocolate_bar

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N=5005;
const int mod=1e9+7;
int n,way[N],f[N][N],g[N],sz[N],ans;
vector<int>E[N];
void dfs(int u,int fa){
	sz[u]=f[u][1]=1;
	for(int v:E[u])
		if(v!=fa){
			dfs(v,u);
			for(int i=1;i<=sz[u];++i)
				for(int j=1;j<=sz[v];++j){
					g[i+j]=(g[i+j]+1ll*f[u][i]*f[v][j])%mod;
					g[i]=(g[i]+1ll*f[u][i]*f[v][j]%mod*(mod-way[j]))%mod;
				}
			sz[u]+=sz[v];
			for(int i=1;i<=sz[u];++i)f[u][i]=g[i],g[i]=0;
		}
}
int main(){
	scanf("%d",&n);
	for(int i=1,x,y;i<n;++i){
		scanf("%d%d",&x,&y);
		E[x].push_back(y);E[y].push_back(x);
	}
	way[0]=1;
	for(int i=2;i<=n;i+=2)way[i]=1ll*(i-1)*way[i-2]%mod;
	dfs(1,0);
	for(int i=1;i<=n;++i)ans=(ans+1ll*f[1][i]*way[i])%mod;
	printf("%d\n",ans);
	return 0;
}


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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N -1], dneg[2 * N -1];

bool X[N][N];

void initialize() {
    for (int i = 0; i < N; i++) {
        row[i] = FREE, col[i] = FREE;
    }
    for (int i = 0; i < N; i++) {
        dpos[i] = FREE;
        dneg[i] = FREE;
    }
}

void printBoard() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (X[i][j]) {
                if(row[i] != j) return;
            }
        }
    }
    for(int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << ((row[i] == j) ? "Q" : "." );
        }
        cout << endl;
    }
}

void recursive(int i) {
    if (i == N) {
        printBoard();
        return;
    }
    
    for (int j = 0; j < N; j++) {
        if (NOT_FREE == col[j] || NOT_FREE == dpos[i + j] || NOT_FREE == dneg[i - j + N - 1]) continue;
        row[i] = j;
        col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
        recursive(i + 1);
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
}

int main() {
    initialize();
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) X[i][j] = false;
    }
    
    int k;
    cin >> k;
    for(int i = 0; i < k; i++) {
        int r, c;
        cin >> r >> c;
        X[r][c] = true;
    }
    
    recursive(0);
    
    return 0;
}


Measured memory_bytes: 3128