akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}


const int MAX_N = 212345;
int f[MAX_N];

int main2() {
  int N = nextLong();

  string s; cin >> s;
  vector<int> X(N);
  REP(i, N) X[i] = s[i] - '0';
  int B = accumulate(ALL(X), 0);

  vector<int> ans(N);
  vector<int> isZero(N);

  {
    const int MOD = B+1;
    vector<int> K(N);
    K[0] = 1;
    for (int i = 1; i < N; i++) K[i] = (K[i-1] * 2) % MOD;
    reverse(ALL(K));
    int tot = 0;
    for (int i = 0; i < N; i++) {
      tot += X[i] * K[i];
      tot %= MOD;
    }
    for (int i = 0; i < N; i++) if (X[i] == 0) {
      int v = (tot + K[i]) % MOD;
      ans[i] = v;
    }
  }

  if (B-1 > 0) {
    const int MOD = B-1;
    vector<int> K(N);
    K[0] = 1;
    for (int i = 1; i < N; i++) K[i] = (K[i-1] * 2) % MOD;
    reverse(ALL(K));
    int tot = 0;
    for (int i = 0; i < N; i++) {
      tot += X[i] * K[i];
      tot %= MOD;
    }
    for (int i = 0; i < N; i++) if (X[i] == 1) {
      int v = (tot - K[i] + MOD) % MOD;
      ans[i] = v;
    }
  }
  else
  {
    for (int i = 0; i < N; i++) if (X[i] == 1) {
      isZero[i] = 1;
    }
  }


  REP(i, N) {
    if (isZero[i])
      cout << 0 << '\n';
    else
      cout << 1 + f[ ans[i] ] << '\n';
  }
  return 0;
}

int main() {

  f[0] = 0;
  f[1] = 1;
  for (int i = 2; i <= 212345; i++) {
    f[i] = 1 + f[i % __builtin_popcount(i)];
  }
#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

int main() {
  int N, W; // N = 品物の総数 W = 容量
  cin >> N >> W;
  int value[N], weight[N];
  for (int i = 0; i < N; i++) {
    cin >> value[i] >> weight[i];
  }
  //二次元配列に最大値を保管する
  int V[N+1][W+1];
  for (int i = 0; i <= N; i++) {
    for (int c = 0; c <= W; c++) {
      if (i <= 0 || c <= 0) {
	V[i][c] = 0;
      } else if (weight[i-1] > c) {
	V[i][c] = V[i-1][c];
      } else {
	V[i][c] = max(V[i-1][c], V[i-1][c - weight[i-1]] + value[i-1]);
	  }
    }
  }

  cout << V[N][W] << endl;
}



Measured memory_bytes: 7028
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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K, Q = MAP()
A = np.array([INT() for _ in range(Q)])

point = [0]*N
for i in range(Q):
	point[A[i] - 1] += 1

for i in range(N):
	if K - Q + point[i] >=1:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 23552
#include <bits/stdc++.h>
#define INF 1000000007
#define MOD 1000000007
using namespace std;

bool cmp( int a, int b){
    if(abs(a) != abs(b))
        return abs(a) < abs(b);
    return a < b;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for( int i = 0; i < n; i++ ){
        cin >> v[i];
    }
    sort(v.begin(), v.end(), cmp);
    /*for( int u : v)
        cout << u << ' ';
    cout << endl;
    */
    long long mul = 1;
    int sign = 1;
    for( int i = n - 1; i >= n - k; i-- ){
        mul *= v[i];
        mul %= MOD;
        sign *= (v[i] < 0) ? -1 : 1;
    }
    //cout << sign << ' ' << mul << endl;
    if(sign > 0 || n == k || mul == 0)
        cout << ((mul + MOD) % MOD) << endl;
    else{
        int hneg = -1, hpos = -1, lneg = -1, lpos = -1;
        long long highestNeg = INF, highestPos = INF;
        long long lowestNeg = INF, lowestPos = INF;
        for( int i = n - k; i < n; i++ )
            if(v[i] > 0){
                if(lowestPos == INF)
                    lowestPos = v[i], lpos = i;
            }
            else if(v[i] < 0){
                if(lowestNeg == INF)
                    lowestNeg = -v[i], lneg = i;
            }
        for( int i = n - k - 1; i >= 0; i-- )
            if(v[i] > 0){
                if(highestPos == INF)
                    highestPos = v[i], hpos = i;
            }
            else if(v[i] < 0){
                if(highestNeg == INF)
                    highestNeg = -v[i], hneg = i;
            }
        //cout << highestPos << ' ' << highestNeg << ' ' << lowestPos << ' ' << lowestNeg << endl;
        //cout << hpos << ' ' << hneg << ' ' << lpos << ' ' << lneg << endl;
        if( (highestPos == INF || lowestNeg == INF) && (highestNeg == INF || lowestPos == INF) ){
            mul = 1;
            for( int i = 0; i < k; i++ ){
                mul *= v[i];
                mul %= MOD;
            }
            cout << (( mul + MOD ) % MOD) << endl;
        }
        else{

            if((highestPos == INF || lowestNeg == INF) ){
                swap( v[hneg], v[lpos] );
            }
            else if((highestNeg == INF || lowestPos == INF) ){
                
                swap(v[hpos], v[lneg]);
            }
            else{
                // highestpos / lowestneg  vs  highestneg / lowestpos
                if( highestPos * lowestPos > lowestNeg * highestNeg )
                    swap( v[hpos], v[lneg] );
                else
                    swap( v[hneg], v[lpos] );
            }
            mul = 1;
            for( int i = n - 1; i >= n - k; i-- ){
                mul *= v[i];
                mul %= MOD;
            }
            cout << ((mul + MOD) % MOD) << endl;
        }
    }
    return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  string S;
  cin >> S;
  if (S<="2019/04/30") cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}

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


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int N;
  int P;
  int i;
  long long int min=10000000000;
  int counter=0;
  
  scanf("%d",&N);
  for(i=0;i<N;i++)
  {
    scanf("%d",&P);
    if(P<=min)
    {
      counter++;
      min=P;
    }
  }
  printf("%d",counter);
  return 0;
}


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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	vector<P> m(n);
	REP(i, n) {
		int x, l; cin >> x >> l;
		m[i] = make_pair(x + l, x - l);
	}
	sort(m.begin(), m.end());

	int cnt = 0;
	int p = -1e9;
	REP(i, n) {
		if (p <= m[i].second) {
			cnt++;
			p = m[i].first;
		}
	}

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

Measured memory_bytes: 3924
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>
#include <iomanip>
#include <limits>
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) :
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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;

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

constexpr int INIT = -1e5;
std::vector<std::vector<int>> dp;
std::string s, t;

int lcs( int i, int j ) {
  if ( i <= 0 || j <= 0 ) return 0;
  if ( dp[i][j] != INIT ) return dp[i][j];

  if ( s[i-1] == t[j-1] ) return dp[i][j] = lcs(i-1, j-1) + 1;
  else return dp[i][j] = std::max( lcs(i-1, j), lcs(i, j-1) );
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::cin >> s >> t;
  dp.resize( sz(s)+1 ); rep(i, sz(s)+1) dp[i].assign(sz(t)+1, INIT);

  std::string res = "";
  int i = (int)s.size(), j = (int)t.size();
  while (i > 0 && j > 0) {
    // (i-1, j) -> (i, j) と更新されていた場合
    if (lcs(i,j) == lcs(i-1,j)) {
      --i; // DP の遷移を遡る
    }

    // (i, j-1) -> (i, j) と更新されていた場合
    else if (lcs(i,j) == lcs(i,j-1)) {
      --j; // DP の遷移を遡る
    }

    // (i-1, j-1) -> (i, j) と更新されていた場合
    else {
      res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
      --i, --j; // DP の遷移を遡る
    }
  }
  std::cout << res << std::endl;
  return 0;
}

Measured memory_bytes: 35968
n, k = list(map(int, input().split()))

if k % 2 != 0:
    num_mod_0 = n // k
    print(num_mod_0 ** 3)

else:
    num_mod_0 = n // k
    a = num_mod_0 ** 3

    num_mod_1 = n // (k/2) - n // k
    b = num_mod_1 ** 3

    print(int(a+b))


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
    int n, y, a=0, b, c=0;
    scanf("%d %d", &n, &y);
    y /= 1000;
    b = n;
    while(b > 0){
        if(y == 5*b){
            y = 0;
            break;
        }else if(y < 5*b){
            b--; c++;
            y--;
        }else{
            a++; b--;
            y -= 10;
        }
    }
    if(y != 0)printf("-1 -1 -1");
    else printf("%d %d %d", a, b, c);
    return 0;
}

Measured memory_bytes: 128
from collections import defaultdict

N, M, X = map(int, input().split())
C = []
A = []
for _ in range(N):
    l = list(map(int, input().split()))
    C.append(l[0])
    A.append(l[1:])

ans_min = -1
for i in range(2**N):
    ans = 0
    m = defaultdict(int)
    for j in range(N):
        if (i >> j) & 1:
            ans += C[j]
            for index, k in enumerate(A[j]):
                m[index] += k

    if len(m.values()) != 0 and all(v >= X for v in m.values()):
        if ans_min == -1:
            ans_min = ans
        else:
            ans_min = min(ans, ans_min)
print(ans_min)


Measured memory_bytes: 68884
#include <stdio.h>
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;

for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}

Measured memory_bytes: 2468
#include <iostream>
#include <cstdlib>
using i64 = long long;

int main() {
    i64 x, k, d;
    std::cin >> x >> k >> d;
    if (x < 0) x = -x;

    if (x / d > k) {
        x -= d * k;
        std::cout << x << std::endl;
        return 0;
    }

    const int c = x / d;
    k -= c;
    x -= c * d;

    std::cout << (k % 2 ? d - x : x) << std::endl;

    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long

signed main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  cout<<(a-c)*(b-d)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

 int linearSearch(int *,int,int);

int main(){
int n,q,s[10000],t,i,sum=0;

scanf("%d",&n);
for(i = 0 ; i < n ; i++){
  scanf("%d",&s[i]);
}
scanf("%d",&q);
for(i = 0 ; i < q ; i++){
  scanf("%d",&t);
if(linearSearch(s,t,n) == 1) sum++;
}
printf("%d\n",sum);
return 0;
}

int linearSearch(int *a,int key,int n){
int i = 0;
a[n] = key;
while(a[i] != key){
  i++;
}
if(i == n)return 0;
return 1;
}



Measured memory_bytes: 2140
def check(List,mid):
    tmp=0
    for l in List:
        tmp+=(-(-l//mid)-1)
    return tmp

n,k=map(int,input().split())
a=list(map(int,input().split()))
lo=0
hi=max(a)+1

while hi - lo > 1:
    mid=(lo+hi)//2
    if check(a,mid)<=k:
        hi=mid
    else:
        lo=mid

print(hi)

Measured memory_bytes: 30980
#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, a, j;
  a=0;
  cin >> n;
  vector<int> mochi(100);
  for(i=0;i<n;i++) {
    cin >> mochi.at(i);
  }
  for(i=0;i<n;i++) {
    for(j=i+1;j<n;j++) {
      if(mochi.at(i) == mochi.at(j)) {
        mochi.at(j) = 0;
      }
    }
  }
  for(i=0;i<n;i++) {
    if(mochi.at(i) != 0) {
      a++;
    }
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
#import<iostream>
#define M 1000000007
#define F for(i=0;i<=N;
long N,a[1<<17],m[1<<17],k[1<<17],b,d,i,A,r;long I(long n){long r=1;n%=M;for(A=M-2;A;A/=2){if(A&1)r=r*n%M;n=n*n%M;}return r;}main(){std::cin>>N;*m=*k=1;F ++i)m[i+1]=m[i]*(N+1-i)%M*I(i+1)%M;F a[b]=++i){std::cin>>b;if(a[b])d=i-a[b];}F ++i)k[i+1]=k[i]*(N-d-1-i)%M*I(i+1)%M;F std::cout<<(M-k[i]+m[++i])%M<<" ");}

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

int rec(long long x, int& n, bool has7, bool has5, bool has3) {
  if (x > n) return 0;
  return rec(x * 10 + 7, n, true, has5, has3)
       + rec(x * 10 + 5, n, has7, true, has3)
       + rec(x * 10 + 3, n, has7, has5, true)
       + (has7 and has5 and has3);
}

int main() {
  int n; cin >> n;
  cout << rec(0, n, false, false, false) << endl;
}


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

using namespace std;

int INF = 10000000;
vector<int> po;
vector<int> poo;
vector<int> dp(1000005, INF);
vector<int> dp2(1000005, INF);

void init() {
    for (int i = 1;; i++) {
        int tmp = i*(i+1)*(i+2) / 6;
        if (tmp > 1000000) break;
        po.push_back(tmp);
        if (tmp%2 == 1) poo.push_back(tmp);
    }
    
    dp[0] = 0;
    for (int i = 0; i < 1000001; i++) {
        for (int j = 0; j < po.size(); j++) {
            int sum = i + po[j];
            if (sum <= 1000000) {
                dp[sum] = min(dp[sum], dp[i] + 1);
            }
        }
    }
    
    dp2[0] = 0;
    for (int i = 0; i < 1000001; i++) {
        for (int j = 0; j < poo.size(); j++) {
            int sum = i + poo[j];
            if (sum <= 1000000) {
                dp2[sum] = min(dp2[sum], dp2[i] + 1);
            }
        }
    }
}

int main(void){
    // Your code here!
    vector<pair<int, int>> ans;
    init();
    int N;
    while (cin >> N, N) {
        ans.push_back({dp[N], dp2[N]});
    }
    for (auto &p : ans) {
        cout << p.first << " " << p.second << endl;
    }
    return 0;
}



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

int main(){
	int N, T;
	cin >> N >> T;
	int c[N], t[N], i, ans=1000, count=0;
	for(i=0; i<N; i++){
		cin >> c[i] >> t[i];
		if(t[i]<=T){
			if(ans>=c[i]){
				ans = c[i];
				count++;
			}
		}
	}
	if(count!=0)	cout << ans << endl;
	else		cout << "TLE" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;  // NOLINT
using LL = int64_t;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a * 100 + b * 10 + c) % 4) cout << "NO\n";
    else cout << "YES\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX/2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}





//-----CODE------//
//-----CODE------//

void solve(void)
{
  
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<max(A*B,C*D);
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n, m, num[607], val[607], dp[607][307][307], a, b, res;
bool is[607], vis[607];
int read()
{
	int num = 0, f = 1;
	char c = getchar();
	while ((c < '0' || c>'9') && c != '-')c = getchar();
	if (c == '-')f = -1, c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num * f;
}
void add(int& a, int b)
{
	a += b;
	if (a >= mod)a -= mod;
}
int main()
{
	n = read();
	for (int i = 1; i <= 2 * n; i++)
		num[i] = read();
	for (int i = 1; i <= 2 * n; i += 2)
		if (num[i] == -1 && num[i + 1] == -1)a++;
		else if (num[i] != -1 && num[i + 1] != -1)vis[num[i]] = vis[num[i + 1]] = 1;
		else b++, is[num[i] == -1 ? num[i + 1] : num[i]] = 1;
	for (int i = 2 * n; i >= 1; i--)
		if (!vis[i])val[++m] = i;
	dp[0][0][0] = 1;
	for (int i = 1; i <= m; i++)
		for (int j = 0; j <= a + b; j++)
			for (int k = 0; k <= b; k++)
			{
				if (!dp[i - 1][j][k])continue;
				if (is[val[i]])
				{
					add(dp[i][j][k + 1], dp[i - 1][j][k]);
					if (j)add(dp[i][j - 1][k], dp[i - 1][j][k]);
				}
				else
				{
					add(dp[i][j + 1][k], dp[i - 1][j][k]);
					if (j)add(dp[i][j - 1][k], dp[i - 1][j][k]);
					if (k)add(dp[i][j][k - 1], 1LL * dp[i - 1][j][k] * k % mod);
				}
			}
	res = dp[m][0][0];
	for (int i = 1; i <= a; i++)
		res = 1LL * res * i % mod;
	cout << res << endl;
	return 0;
}

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

using namespace std;

int main () {

    string str;
    cin >> str;

    int q;
    cin >> q;

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

        string order;
        cin >> order;

        // cout << "Scan order" << endl;

        int a, b;
        cin >> a >> b;

        // cout << "Scan a & b" << endl;

        if (order == "print") {

            // cout << "Mode print" << endl;

            string out;
            out = str.substr(a, b + 1 - a);

            cout << out << endl;

        } else if (order == "reverse") {

            // cout << "Mode reverse" << endl;

            int j = 0;
            while (j <= (b - a) / 2) {

                char tmp;
                tmp = str[a + j];
                str[a + j] = str[b - j];
                str[b - j] = tmp; 
                j++;

            }

            // cout << "Result reverse: " << str << endl;

        } else if (order == "replace") {

            // cout << "Mode replace" << endl;
            
            string p;
            cin >> p;

            for (int j = a; j <= b; j++) {

                str[j] = p[j - a];

            }
        
        }

    }

    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	string S, T;
	cin >> S >> T;
	string ans = T + S;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <climits>
using namespace std;
#define mod (1000000007)
#define ll long long int

int ans = INT_MAX;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int W,H;

void dfs(int x0, int y0, vector<vector<int>> MAP, int cnt){
  int x,y,tmp;
  //cout << x0 << ',' << y0 << endl;
  if(cnt > 10){
    return;
  }
  for(int i=0; i<4; i++){
    x = x0; y = y0;
    tmp = 0;

    while(true){
      x += dx[i]; y += dy[i];
      if((x<0 or W<=x) or (y<0 or H<=y)){
        break;
      }else{
        if(MAP[y][x]==0 or MAP[y][x]==2){
          tmp++;
          continue;
        }else if(MAP[y][x]==3){
          ans = min(ans,cnt);
          break;
        }else if(MAP[y][x]==1){
          if(tmp==0){
            break;
          }
          vector<vector<int>>nMAP;
          copy(MAP.begin(), MAP.end(), back_inserter(nMAP));
          nMAP[y][x] = 0;
          x -= dx[i]; y -= dy[i];
          dfs(x,y,nMAP,cnt+1);
          break;
        }
      }
    }
  }
  return;
}


int main(void){
  while(true){
    cin >> W >> H;
    if(W==0 and H==0){
      break;
    }
    vector<vector<int>> MAP;
    MAP.assign(H,vector<int>(W,0));

    int tmp,sx,sy;
    for(int y=0; y<H; y++){
      for (int x=0; x<W; x++){
        cin >> tmp;
        MAP[y][x] = tmp;
        if(tmp==2){
          sx = x;
          sy = y;
          MAP[sy][sx] = 0;
        }
      }
    }

    ans = INT_MAX;
    dfs(sx,sy,MAP,1);
    if(ans == INT_MAX){
      cout << -1 << endl;
    }else{
      cout << ans << endl;
    }

  }
}



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

using namespace std;

int main(void)
{
    int num = 0;

    string str;

    cin >> num; 
    cin >> str;

    if(num >= 3200) {
        cout << str << endl;
    } else {
        cout << "red" << endl;
    }

    return 0;
}


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

const int DIM = 4e2 + 5;

int dp[DIM][DIM];

int main( void ) {
    
    int n, a, b;
    cin >> n >> a >> b;
    
    memset( dp, 0x3f, sizeof(dp) );
    
    dp[0][0] = 0;
    for( int i = 1; i <= n; i ++ ) {
        int x, y, z;
        cin >> x >> y >> z;
        
        for( int j = DIM - 1; j >= x; j -- )
            for( int k = DIM - 1; k >= y; k -- )
                dp[j][k] = min( dp[j][k], dp[j - x][k - y] + z );
    }
    
    int ans = 1e9;
    for( int i = 1; max( a, b ) * i < DIM; i ++ )
        ans = min( ans, dp[i * a][i * b] );
    
    cout << ( ( ans == 1e9 ) ? -1 : ans ) << endl;
    return 0;
}

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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


// import here

int main(){
    LL n;
    cin >> n;
    vector<LL> b(n);
    for(LL i = 0; i < n-1; ++i){
        cin >> b[i];
    }
    LL ans = b[0] + b[n-2];
    for(LL i = 0; i < n-2; ++i){
        ans += min(b[i], b[i+1]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	M, _ := strconv.Atoi(read())
	X := make([]int, M)

	for i := 0; i < M; i++ {
		X[i], _ = strconv.Atoi(read())
	}
	sort.Ints(X)

	dis := make([]int, M)
	for i := 1; i < M; i++ {
		dis[i] = X[i] - X[i-1]
	}
	sort.Ints(dis)

	for i := 0; i < M-(N-1); i++ {
		ans += dis[i]
	}
	fmt.Println(ans)
}

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

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i][0] < a[j][0] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 2944
def main():
    k, s = map(int,input().split())

    ans=0
    for i in range(k+1):
        for j in range(k+1):
            if s-(i+j) >= 0 and s-(i+j) <= k:
                ans+=1

    print(ans)

if __name__ == "__main__":
        main()


Measured memory_bytes: 2940
Input1 = int(input())
N = Input1
Input2 =str(input())
ar = list(Input2)


roop = N - 2
chk_ar=[]
crt = ['A','B','C']

cnt =0
for i in range(roop):
  chk_ar.append(ar[i])
  chk_ar.append(ar[i+1])
  chk_ar.append(ar[i+2])

  if chk_ar == crt:
    cnt+=1
  
  chk_ar=[]

print(cnt)

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

typedef long long ll;
const long long mod=1e9+7;

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	vector<int>h(n);
	vector<ll>dp(n,1e9);
	for(int i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=1;j<=k;j++){
			if(i-j>=0){
				ll tmp=dp[i-j]+abs(h[i]-h[i-j]);
				dp[i]=min(dp[i],tmp);
			}
		}
	}
	printf("%lld\n",dp[n-1]);
	return 0;
}


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

int main() {
	int N;
	cin >> N;
	int64_t sum = 0;
	for (int i = 1; i <= N; i++)
		if (i % 3 != 0 and i % 5 != 0)
			sum += i;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] ab = sc.intarr;

            int num = int.Parse(ab[0].ToString() + ab[1].ToString());

            double sq = Math.Sqrt(num);

            if(sq % 1 == 0)
            {
                wr.wri("Yes");
            }
            else
            {
                wr.wri("No");
            }
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13396
n = int(input())
arr = {}
for i in range(n):
  a,b= map(int, input().split( ))
  if b in arr:
    arr[b] += a
  else:
    arr[b] = a
time = 0
arrs = sorted(arr.items(), key=lambda x:x[0])
for lin in arrs:
  time += lin[1]
  if lin[0] < time:
    print('No')
    exit()
print('Yes')  

Measured memory_bytes: 122524
#include <iostream>
#include <map>
#include <vector>
using namespace std;
using ll = long long;

vector<int> v[100010];
map<pair<int, int>, ll> m;
ll ret[100010];

void update(int par, int cur){
    auto iter = m.find(pair<int, int>(min(par, cur), max(par, cur)));
    if(iter == m.end()) exit(-1);
    ret[cur] = iter->second;

    for(auto i : v[cur]){
        if(par == i) continue;
        auto next = m.find(pair<int, int>(min(cur, i), max(cur, i)));
        if(next == m.end()) exit(-1);
        next->second += ret[cur];
        ret[i] = next->second;
        update(cur, i);
    }
}

int main(){
    int N, Q, K;
    int x[100010], y[100010];
    cin >> N;
    for(int i = 0; i < N - 1; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        v[a].push_back(b);
        v[b].push_back(a);
        if(a > b) swap(a, b);
        m.insert(pair<pair<int, int>, ll>(pair<int, int>(a, b), c));
    }

    cin >> Q >> K;
    for(int i = 0; i < Q; ++i){
        cin >> x[i] >> y[i];
    }

    m.insert(pair<pair<int, int>, ll>(pair<int, int>(0, K), 0));
    update(0, K);

    for(int i = 0; i < Q; ++i){
        auto ak = ret[x[i]];
        auto bk = ret[y[i]];
        cout << ak + bk << endl;
    }
}


Measured memory_bytes: 25984
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n, hen[3];

	cin >> n;

	while (n--)
	{
		cin >> hen[0] >> hen[1] >> hen[2];
		sort(hen, hen + 3);
		if (hen[2] * hen[2] == hen[1] * hen[1] + hen[0] * hen[0]) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int i,j,n,k;
    map<string,int> me;
    string s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s;
        me[s]+=1;
    }
    int max=0;
    for(const auto& x : me) 
    {
        int v=x.second;
        if(v>max)
        max=v;
    }
    for(auto it=me.begin();it!=me.end();it++)
    {
        if(it->second==max)
        cout<<it->first<<endl;
    }
    return 0;
}

Measured memory_bytes: 19264
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
int n, k, a, b; vector<int>x[100007];
int s[100007], t[100007], dist[100007];
queue<int>Q;
void bfs() {
	for (int i = 0; i < 100007; i++) { dist[i] = 100000007; }
	Q.push(1); dist[1] = 0;
	while (!Q.empty()) {
		int a1 = Q.front(); Q.pop();
		for (int i = 0; i < x[a1].size(); i++) {
			if (dist[x[a1][i]] >= 1000000) { dist[x[a1][i]] = dist[a1] + 1; Q.push(x[a1][i]); }
		}
	}
}
int main() {
	for (int i = 0; i < 100007; i++) { s[i] = -100000005; t[i] = 100000005; }
	cin >> n; for (int i = 1; i < n; i++) { cin >> a >> b; x[a].push_back(b); x[b].push_back(a); }
	bfs(); cin >> k; int GK = 0; for (int i = 0; i < k; i++) { cin >> a >> b; s[a] = b; t[a] = b; Q.push(a); GK = (dist[a] + 1000000 - b) % 2; }
	for (int i = 1; i <= n; i++) { if (s[i] >= 0 && (s[i] + 1000000 - dist[i]) % 2 != GK) { cout << "No" << endl; return 0; } }
	while (!Q.empty()) {
		int a1 = Q.front(); Q.pop();
		for (int i = 0; i < x[a1].size(); i++) {
			int to = x[a1][i];
			int L1 = s[a1] - 1, L2 = t[a1] + 1;
			bool flag = false;
			if (s[to] < L1) { s[to] = L1; flag = true; }
			if (t[to] > L2) { t[to] = L2; flag = true; }
			if (flag == true) { Q.push(to); }
		}
	}
	for (int i = 1; i <= n; i++) { if (s[i] > t[i]) { cout << "No" << endl; return 0; } }
	cout << "Yes" << endl;
	for (int i = 1; i <= n; i++)cout << s[i] << endl;
	return 0;
}

Measured memory_bytes: 8312
#include<stdio.h>
int main(void)
{
	int a,s,d,f=-1,g,h,j,i;
	scanf("%d %d",&a,&s);
	while(1){
		if(a==0&&s==0){
			break;
		}
		d=a+s;
		//printf("%d\n",d);
		g=1;
		for(i=2;i<=5;i++){
			scanf("%d %d",&a,&s);
			if(d<a+s){
				d=a+s;
				g=i;
			}
		}
		if(g==1)
			printf("A ");
		if(g==2)
			printf("B ");
		if(g==3)
			printf("C ");
		if(g==4)
			printf("D ");
		if(g==5)
			printf("E ");
		printf("%d\n",d);
		scanf("%d %d",&a,&s);
	}

	return 0;
}
	

Measured memory_bytes: 1028
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
string s;
int p[46], q[15], ans; bool b;
signed main() {
	cin >> s >> s;
	for (int i = 0; i < s.size(); i += 2)p[s[i] - 'a']++;
	for (int i = 0; i < 26; i++)q[p[i]]++;
	if (q[1]) { ans = q[1] * 2 - 1; b = 1; }
	for (int i = 2; i <= 9; i++) {
		if (q[i]) {
			if (b)ans++; b = 1;
			if (q[i] == 1)ans += 3;
			else ans += 4 + (q[i] * 2 - 1);
		}
	}
	cout << ans << endl;
}


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

int main()
{
  int n;
  cin>>n;
  int h[n];
  long int x[n];
  for(int i=0;i<n;i++)
  {
    cin>>h[i];
  }
  
  x[0]=0;
  x[1]=abs(h[1]-h[0]);
  
  for(int i=2;i<n;i++)
  {
    x[i]=min(x[i-1]+abs(h[i]-h[i-1]),x[i-2]+abs(h[i]-h[i-2]));
    
  }
  cout<<x[n-1];
  
  return 0; 
}

Measured memory_bytes: 1408
import numpy as np
from itertools import combinations
N, M, X = map(int, input().split())

row_list = []
C_list = []
for _ in range(N):
  row = list(map(int, input().split()))
  row = np.array(row)
  C_list.append(row[0])
  row_list.append(row[1:])

  
def check(subset, C_list, row_list, X):
  if len(subset) == 0:
    return 0, False
  
  cost_list = [C_list[ind] for ind in subset]
  cost = sum(cost_list)
  
  skill_arr = np.zeros(M)
  for ind in subset:
    skill_arr += row_list[ind]
    
  judge = np.min(skill_arr) >= X
    
  return cost, judge

output = np.inf
for j in range(N+1):
  for subset in combinations(range(N), j):
    cost, judge = check(subset, C_list, row_list, X)
    
    if judge and cost < output:
      output = cost

if output == np.inf:
  output = -1
  
print(output)

Measured memory_bytes: 27128
#include <iostream>
#include <queue>

using namespace std;

int main(){
	int n, q;
	cin >> n >> q;
	queue<int> time;
	queue<string> name;
	for (int i=0; i<n; i++){
		string tmpname;
		int tmptime;
		cin >> tmpname;
		cin >> tmptime;
		time.push(tmptime);
		name.push(tmpname);
	}

	int timeline = 0;
	int endtime[n];
	string endname[n];
	int cnt = 0;

	while (!time.empty()){
		int tt;
		string tn;
		tt = time.front();	
		tn = name.front();
		time.pop();
		name.pop();
		if (tt <= q){
			timeline += tt;
			endtime[cnt] = timeline;
			endname[cnt] = tn;
			cnt++;
		}
		else{
			tt -= q;
			timeline += q;
			time.push(tt);
			name.push(tn);
		}
	}

	for (int i=0; i<n; i++){
		cout << endname[i] << " " << endtime[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 6240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;	
	ll x[n];
	zep(i, 0, n){
		cin >> x[i];
	}
	
	ll ans = 1;
	ll goal = 0;
	zep(i, 0, n){
		if(x[i] < 2*(i-goal)+1){
			//print(x[i])
			ans *= i+1-goal;
			ans %= MOD;
			goal++;
		}
	}
	//print(4311014400%MOD)
	//print(goal)
	while(goal != n){
		ans *= n-goal;
		ans %= MOD;
		goal++;
	}
	
	print(ans)
	return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

bool dp[1111111];

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

    dp[0] = true;
    REP(i, 1000001){
        REP(j, 6){
            dp[i + 100 + j] |= dp[i];
        }
    }

    ll n;cin >> n;
    cout << (dp[n] ? 1 : 0) << endl;

	return 0;
}


Measured memory_bytes: 1280
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>

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

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        if(i==size-1){
            cout << da[i] << endl;
        }
        else{
            cout << da[i] << ' ';
        }
    }
}
template<typename T>
void vvdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        vdeb(da[i]);
    }
}

int main(){
	ll a,b, n;
	cin >> n >> a >> b;
	if((a+b)%2 == 0){
		cout << (b-a)/2 << endl;
	}
	else{
		cout << min(a - 1, n - b) + (b-a)/2  + 1<< endl;
	}
}

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

vector<int> primeFactorization(int n) {
    vector<int> result;
    int i = 2;
    while (i <= sqrt(n)) {
        if (n%i == 0) {
            result.push_back(i);
            n /= i;
        }
        else i += 1;
    }
    if (n != 1) result.push_back(n);
    return result;
}
lint comb(lint n, lint k) {
    if (n == 0) return 0;
    if (n == k || k == 0) return 1;
    else return comb(n-1, k-1) + comb(n-1, k);
}

int main() {
    int n; cin >> n;
    vector<int> v;
    for (int i=1; i<=n; i++) {
        vector<int> rv = primeFactorization(i);
        v.insert(v.end(), rv.begin(), rv.end());
    }
    map<int,int> cnt;
    rep(i,v.size()) cnt[v[i]] ++;
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    int ans = 0;
    int four = 0;
    int two = 0;
    rep(i,v.size()) {
        if (cnt[v[i]] >= 4) four ++;
        else if (cnt[v[i]] >= 2) two ++;
    }
    ans += comb(four,3) * 3;
    ans += comb(four,2) * two;
    // ここで解説見ました...悔しい
    four = 0;
    two = 0;
    int fourteen = 0;
    int twentyfour = 0;
    int seventyfour = 0;
    rep(i,v.size()) {
        if (cnt[v[i]] >= 4) four ++;
        if (cnt[v[i]] >= 2) two ++;
        if (cnt[v[i]] >= 74) seventyfour++;
        if (cnt[v[i]] >= 24) twentyfour++;
        if (cnt[v[i]] >= 14) fourteen++;
    }
    //ans += fourteen * (four-1);
    //ans += twentyfour * (two-1);
    //ans += seventyfour;
    ans += seventyfour + twentyfour*(two-1) + fourteen*(four-1);
    cout << ans << endl;
}

Measured memory_bytes: 3696
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,a[200005],b[200005];
ll ans;
priority_queue<pair<int,int> >q;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    for(int i=1;i<=n;++i){
        scanf("%d",b+i);
        if(b[i]>a[i])q.push(mp(b[i],i));
    }
    while(!q.empty()){
        int x=q.top().second;
        q.pop();
        int o=0;
        if(x>1)o+=b[x-1];
        else o+=b[n];
        if(x<n)o+=b[x+1];
        else o+=b[1];
        int k=(b[x]-a[x])/o;
        k=max(k,1);
        ans+=k;
        b[x]-=k*o;
        if(b[x]<a[x]){
            puts("-1");
            return 0;
        }
        if(b[x]>a[x])q.push(mp(b[x],x));
    }
    printf("%lld\n",ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <stack>
#include <queue>

using namespace std;

const int MAX_W = 100, MAX_H = 100;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

typedef pair<int, int> P;

int main()
{
    int H,W;
    while(cin >> H >> W && H) {
        char field[H][W];
        for(int i = 0; i < H; i++) 
            for(int j = 0; j < W; j++) 
                cin >> field[i][j];
        
        int ans = 0;
        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                if(field[i][j] != ' ') {
                    ans++;
                    char c = field[i][j];
                    queue<P> que;
                    que.push(P(j, i));
                    while(!que.empty()) {
                        P p = que.front(); que.pop();
                        int x = p.first, y = p.second;
                        if(x >= 0 && x < W && y >= 0 && y < H && field[y][x] == c) {
                            field[y][x] = ' ';
                            for(int k = 0; k < 4; k++) que.push(P(x + dx[k], y + dy[k]));
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
deque<char> myq;
char s[MAXN];
int n,t,f,opt;
char g[3];
bool flg;
int main()
{
    scanf("%s",s);
    int len=strlen(s);
    for(int i=0;i<len;i++)
    {
        myq.push_back(s[i]);
    }
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&opt);
        if(opt==1)
        {
            flg^=1;
        }
        else
        {
            scanf("%d%s",&f,g);
            f--;
            if(f^flg)myq.push_back(g[0]);
            else
            {
                myq.push_front(g[0]);
            }
            
        }
    }
    if(flg==1)
    {
        while(!myq.empty())
        {printf("%c",myq.back());
        myq.pop_back();
        }
    }
    else
    {
        while(!myq.empty())
        {
            printf("%c",myq.front());
            myq.pop_front();
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int X,A;
    cin >> X >> A;
    if (X < A)
        cout << 0;
    else
        cout << 10;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

/*
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()
*/

template <class T> void chmin(T& a, T& b) { a = min(a, b);}
template <class T> void chmax(T& a, T& b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-9;

void solve() {
    ll n, m;
    cin >> n >> m;
    vll h(n);
    for(auto& i : h) cin >> i;
    vb ok(n, true);
    for(ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        if(h[a] <= h[b]) ok[a] = false;
        if(h[b] <= h[a]) ok[b] = false;
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++) if(ok[i]) ans++;
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 3996
T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    S = input()

    ans = 0
    B = []
    for i in range(N)[::-1]:
        a = A[i]
        for b in B:
            a = min(a, a ^ b)
        if a:
            if S[i] == '1':
                ans = 1
                break
            B.append(a)
    print(ans)


Measured memory_bytes: 9192
def main():
    s = input()
    if s[0] == s[1]:
        print(1, 2)
        return
    for i in range(2, len(s)):
        if s[i] == s[i-1]:
            print(i-1+1, i+1)
            return
        elif s[i] == s[i-2]:
            print(i-2+1, i+1)
            return
    print(-1, -1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39280