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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    int x, y;
    REP(i, n) {
        cin >> x >> y;
        v[i] = make_pair(x, y);
    }

    int t = n;
    REP(i, n) {
        REP(j, n) {
            if (i == j) {
                continue;
            }
            int dx = v[i].first - v[j].first;
            int dy = v[i].second - v[j].second; 
            int c = 0;
            REP(k, n) {
                REP(l, n) {
                    if (k == l) {
                        continue;
                    }
                    if (dx == v[k].first - v[l].first && dy == v[k].second - v[l].second) {
                        c++;
                    }
                }
            }
            chmin(t, n - c);
        }
    }

    cout << t << endl;    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
ll mod=1000000007;

int main(){
    std::ios::sync_with_stdio(false);
    string s;
    cin>>s;
    vector<string> vec;
    string pu="";
    pu+=s[0];
    vec.pb(pu);
    int fl=0;
    for(int i=1;i<s.size();){
        int n=vec.size();
        string s1="";
        for(int j=i;j<s.size();j++){
            s1+=s[j];
            if(s1!=vec[n-1]){
                vec.pb(s1);
                i=j+1;
                //cout<<"MS"<<endl;
                break;
            }
            else if(j==s.size()-1){
                i=j+1;break;
            }
        }
    }
    cout<<vec.size();


    return 0;
}


Measured memory_bytes: 11016
#!/usr/bin/python3

import numpy
import collections
#標準出力からの読み込み
n = int(input())

#判定ロジック
#nを素因数分解
output = 0

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

prime = prime_factorize(n)
c = collections.Counter(prime)

try:
    for key, values in c.items():
        i = 1
        while values - i >= 0:
            output = output + 1
            values = values - i
            i = i + 1
except:
    pass

print(output)


Measured memory_bytes: 27164
// depends on: -

/*
usage:

tools::square(5) => 25
*/

namespace tools {
  template <typename T> constexpr T square(const T x) {
    return x * x;
  }
}
// depends on: square.cpp

/*
usage:

tools::pow(2. 5) => 32
*/

namespace tools {
  template <typename T> constexpr T pow(const T base, const T exponent) {
    return exponent == 0
      ? 1
      : exponent % 2 == 0
        ? square(pow(base, exponent / 2))
        : pow(base, exponent - 1) * base;
  }
}
#include <iostream>
#include <cstdint>

int main() {
  std::int_fast64_t d, n;
  std::cin >> d >> n;
  if (n == 100) n = 101;
  std::cout << tools::pow<std::int_fast64_t>(10, d * 2) * n << std::endl;
  return 0;
}

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

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

  vector<int> H(N);
  for (int i = 0; i < N; i++)
    cin >> H.at(i);

  int maxv = -1;
  for (int i = 0; i < N - 1; i++)
  {
    if (H.at(i) < H.at(i + 1)) H.at(i + 1)--;
    if (H.at(i) - H.at(i + 1) >= 1 ){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 640
n=int(input())
ans=0
count=[[0 for _ in range(10)] for _ in range(10)]
for i in range(1,n+1):
    stri=str(i)
    count[int(stri[0])][int(stri[-1])]+=1

for i in range(10):
    for j in range(i,10):
        if(i==j):
            ans+=count[i][j]*count[j][i]
        else:
            ans+=2*(count[i][j]*count[j][i])

print(ans)

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    set<char> c;
    for(auto ch:s){
        c.insert(ch);
    }
    if(c.count('N')==c.count('S') && c.count('W')==c.count('E'))
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

dp = [[0]*N for i in range(N)]

for i, a in enumerate(A):
  dp[i][i] = a

for i in range(1, N):
  for j in range(i-1, -1, -1):
    dp[i][j] = max(A[i]-dp[i-1][j], A[j]-dp[i][j+1])

print(dp[N-1][0])

Measured memory_bytes: 111964
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	if(n<=111)
	{
		printf("111");
	}else if(n<=222)
	{
		printf("222");
	}else if(n<=333)
	{
		printf("333");
	}else if(n<=444)
	{
		printf("444");
	}else if(n<=555)
	{
		printf("555");
	}else if(n<=666)
	{
		printf("666");
	}else if(n<=777)
	{
		printf("777");
	}else if(n<=888)
	{
		printf("888");
	}else if(n<=999)
	{
		printf("999");
	}
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main(){
    int N;  ll K, cnt;   cin >> N >> K;
    vector<pair<int, int> > p(N);
    for(int i=0; i<N; i++)  cin >> p[i].first >> p[i].second;
    sort(all(p));
    cnt = 0;
    for(int i=0; i<N; i++){
        cnt += p[i].second;
        if(cnt >= K){
            cout << p[i].first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3944
#include<stdio.h>
#define MAX 10000

int main(){
    int n, a[MAX], i, j, max, min, tmp;
    long long int total = 0;
    scanf("%d", &n);

    for(i = 0; i < n; i++) scanf("%d", &a[i]);

    for(i = 0; i < n; i++){
        total += a[i];
    }

    for(i = 0; i < n; i++){
        for(j = i + 1; j < n; j++){
            if(a[i] > a[j]){
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }

    min = a[0];
    max = a[n - 1];

    printf("%d %d %Ld\n", min, max, total);

    return 0;
}


Measured memory_bytes: 2132
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

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

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n) {
        cin >> v[i];
    }

    ll sum = 0;
    REP(i, n) {
        sum += i%2 ? -v[i] : v[i];
    }

    std::cout << sum << '\n';
    ll left = sum / 2;
    REP2(i, 1, n) {
        left = v[i-1] - left;
        std::cout << left * 2 << '\n';
    }

    return 0;
}


Measured memory_bytes: 1664
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	string str;
	cin>>str;
	if(str == "ABC") cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
	return 0;
}

Measured memory_bytes: 3624
n,m,k=[int(x) for x in input().rstrip().split()]
a=[int(x) for x in input().rstrip().split()]
b=[int(x) for x in input().rstrip().split()]

A=[0]
B=[0]

for i in range(n):
  A.append(A[i]+a[i])

for i in range(m):
  B.append(B[i]+b[i])

ans=0
j=0

for i in range(n+1):
  # j=0
  if A[i]>k:
    break
  nokori=k-A[i]

  while(B[j]<=nokori and j<m):
    j+=1

  if nokori<B[j]:
    j-=1
    
  ans=max(ans,i+j)
print(ans)


Measured memory_bytes: 47344
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;

vector<string> split(string delim,string str){
	vector<string> res;
	str += delim;
	for(int i=0;i<str.size();i++){
		for(int j=1;i+j<=str.size();j++){
			if(str.substr(i,j).find(delim) != string::npos){
				if(str.substr(i,j-1).size() >0 ) res.push_back(str.substr(i,j-1));
				i+=j-1;
				break;
			}
		}
	}

	return res;
}

int main(){

	string str;
	while(getline(cin,str)){
		vector<string> res1;
		res1 = split(" ",str);

		vector<string> res2;
		for(int i=0;i<res1.size();i++){
			vector<string> tmp;
			tmp = split(",",res1[i]);
			for(int j=0;j<tmp.size();j++){
				res2.push_back(tmp[j]);
			}
		}

		vector<string> res3;
		for(int i=0;i<res2.size();i++){
			vector<string> tmp;
			tmp = split(".",res2[i]);
			for(int j=0;j<tmp.size();j++){
				res3.push_back(tmp[j]);
			}
		}

		vector<string> refined;
		for(int i=0;i<res3.size();i++){
			if(res3[i].size() <= 2 || res3[i].size() >=7) continue;
			refined.push_back(res3[i]);
		}
		

		for(int i=0;i<refined.size();i++){
			printf("%s%s",refined[i].c_str(),i==refined.size()-1 ? "\n" : " ");
		}
	}
}

Measured memory_bytes: 0
n,k = [int(i) for i in input().split()]
a = sorted([int(i) for i in input().split()])

sum = 0
count = 0
for i in a[:-1]:
  sum+=i
  if sum>k:
    break
  count+=1
if a[-1]==k-sum:
  count+=1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,a,b;
     cin>>a>>b;
     char arr[a+5][b+5];
     for(int i=0;i<=a+1;i++)
     {
         for(int j=0;j<=b+1;j++)
         {
             arr[i][j]='#';
         }
     }
     for(int i=1;i<=a;i++)
     {
         for(int j=1;j<=b;j++)
         {
             cin>>arr[i][j];
         }
     }
     for(int i=0;i<=a+1;i++)
     {
         for(int j=0;j<=b+1;j++)
         {
             cout<<arr[i][j];
         }
         cout<<endl;
     }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n;
    cin >> n;
    bool flag = true;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(a % 2 != 0) {
            continue;
        } else {
            if(a % 3 != 0 && a % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

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

int main()
{


int a,b,x;


    cin>>x>>a>>b;
    if(a-b>=0)
        cout<<"delicious";

    else  if(abs(a-b)<=x)
        cout<<"safe";
    else
        cout<<"dangerous";









    }






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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

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

const int MAX = 1000010;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    ll X, Y;
    cin >> X >> Y;
    ll tmp = X - 2 * Y;
    if (tmp % 3 != 0 || tmp > 0) {
        print(0);
        return 0;
    }

    ll a = -1 * tmp / 3;
    ll b = Y - 2 * a;
    if (b < 0) {
        print(0);
        return 0;
    }
    COMinit();
    print(COM(a+b, a));
    return 0;
}

Measured memory_bytes: 23680
#include <stdio.h>
int main(void){
  long N,K;
  scanf("%ld%ld", &N,&K);
  long sum = K;
  for(int i = 1;i < N;i++){
    sum = sum * (K-1);
  }
  printf("%ld\n",sum);
  return 0;
}


Measured memory_bytes: 128
import math
A,B,H,M= map(int,input().split())
kd_a=0.5*(M+60*H)
kd_b=6*M

rad=math.radians(kd_a-kd_b)

X=A**2+B**2-2*A*B*math.cos(rad)
print(X**0.5)

Measured memory_bytes: 9504
#include <iostream>
using namespace std;
int main() {
    int k;
    cin >> k;
    int n , m;
    cin >> n >> m;
    if (m - n >= k) {
        cout << "OK\n";
        return 0;
    }
    for (int i = 0; i <= m - n && i < k; ++i) {
        if ((n+i) % k == 0) {
            cout << "OK\n";
            return 0;
        }
    }

    cout << "NG\n";
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <stack>
#include <string>
#include <bits/stdc++.h>
using namespace std;


int main() {
	ios::sync_with_stdio(false);

	string stT = "";
	string tmp="";
	getline(cin, stT) ;
	stack<int> st;

	for (int i = 0; i < stT.length(); i++) {
		if (stT[i] != ' ') {
			if (isdigit(stT[i])) {
				tmp += stT[i];
			} else if (stT[i] == '+') {
				int tmp = st.top();
				st.pop();
				tmp += st.top();
				st.pop();
				st.push(tmp);
				i++;
			} else if (stT[i] == '-') {
				int tmp = st.top();
				st.pop();
				tmp = (tmp - st.top()) * -1;
				st.pop();
				st.push(tmp);
				i++;
			} else {
				int tmp = st.top();
				st.pop();
				tmp *= st.top();
				st.pop();
				st.push(tmp);
				i++;
			}
		}else{
			int stackTmp;
			sscanf(tmp.c_str(), "%d", &stackTmp);
			st.push(stackTmp);
			tmp = "";
		}
	}
	cout << st.top() << endl;
	return 0;
}

Measured memory_bytes: 3324
def main():
    N = int(input())

    ans = f(N)
    print(ans)


def sum_digits(x):
    ans = 0
    while x > 0:
        x, a = divmod(x, 10)
        ans += a
    return ans


def sum_digits_slow(x):
    return sum(map(int, list(str(x))))


def f(N):
    ans = float("inf")
    # 正の整数
    for A in range(1, N//2 + 1):
        B = N - A
        tmp = sum_digits(A) + sum_digits(B)
        ans = min(ans, tmp)

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#define Max 100

int main(){
  int A[Max];
  int n,i,temp,flag=0;
  int time=0;
  
  scanf("%d",&n);
  for(i=0 ; i<n ; i++) scanf("%d",&A[i]);

  while(flag < n-1){
    for(i=n-1 ; i>=1+flag ; i--){
      if(A[i] < A[i-1]){
        temp = A[i];
        A[i] = A[i-1];
        A[i-1] = temp;
	time++;
      }
    }
    flag++;
  }

  for(i=0 ; i<n-1 ; i++) printf("%d ",A[i]);
  printf("%d\n",A[n-1]);
  printf("%d\n",time);

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
   
using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;
   
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}


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

    int n;
    double res = 0;
    cin >> n;
    vector<int> x(n),y(n),num(n);

    rep(i,n){
        cin >> x[i] >> y[i];
        num[i] = i;
    }

    do{
        int nx = x[num[0]],ny = y[num[0]];
        double sum = 0;
        for(int i = 1;i < n;++i){
            sum += hypot(nx - x[num[i]],ny - y[num[i]]);
            nx = x[num[i]],ny = y[num[i]];
        }
        res += sum;
    }while(next_permutation(all(num)));

    int p = 1;
    reps(i,n) p *= i;

    cout << Fixed << res / p << '\n';

    return 0;
}

Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    A, B = map(int, input().split())

    A, B = max(A, B), min(A, B)
    if A == B:
        return 2 * A
    else:
        return 2 * A - 1


if __name__ == '__main__':
    print(main())


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

int main(){
  int N;
  int i;
  int n=0;
  cin >> N;
  vector<int> H(N);
  int max=0;
    for(i=0;i<N;i++){
      cin >> H.at(i);
    }
  for(i=0;i<N;i++){
    if(H.at(i)>=max){
      n++;
      max=H.at(i);
    }
  }
  cout << n << endl;
}
      
      
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,a[100005],b[100005],gg[500],ans;bitset<500>s[500];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d%d",&a[i],&b[i]);
	for(int i=1,j;i<=n;i++) for(s[i][i]=1,j=m;j;j--)
	{
		if(s[i][a[j]]&&s[i][b[j]]){gg[i]=1;break;}
		else if(s[i][a[j]]&&!s[i][b[j]]) s[i][b[j]]=1;
		else if(!s[i][a[j]]&&s[i][b[j]]) s[i][a[j]]=1;
	}
	for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) if(!gg[i]&&!gg[j]&&(s[i]&s[j]).none()) ans++;
	printf("%d\n",ans);
}

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

int dt(int p, int q){
    int min1 = min(abs(p-q), abs(p-x)+1+abs(q-y));
    int min2 = min(min1, abs(p-y)+1+abs(q-x));
    return min2;
}
const int NM = 2010;
int dist[NM][NM];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>x>>y;
//    Fill(dist, 100000);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            dist[i][j] = dt(i, j);
//            cerr<<i<<" "<<j<<" "<<dist[i][j]<<endl;
        }
    }
    map<int,int> dmap;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            //if(dist[i][j] == i) cnt++;
            dmap[dist[i][j]]++;
        }
    }
    for(int i=1;i<=n-1;i++){
        cout<<dmap[i]<<endl;
    }
}

Measured memory_bytes: 16128
#include<cstdio>
#include<iostream>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#include<algorithm>
#include<stack>
#include<sstream>
#include<string>
using namespace std;
#define ll long long
#define N 300010

int main()
{
    ll n,tt,t=1000000000000005,ans=0;
    scanf("%lld",&n);
    for(int i=0;i<5;i++)
    {
        scanf("%lld",&tt);
        t=min(tt,t);
    }

    printf("%lld\n",4 + (n+t-1)/t);
       return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int t,a,d,c;
  while(cin>>a>>d,(a|d)) {
    t=a+d;c=0;
    for(int i=1;i<5;i++) {
      cin>>a>>d;
      if(t<a+d)t=a+d,c=i;
    }
    cout<<(char)(c+'A')<<' '<<t<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}


int main()
{
    optimize();

    ll a, b;
    cin >> a >> b;

    cout << ( a * b ) / __gcd ( a, b );


    return 0;
}


















Measured memory_bytes: 256
#include <iostream>
using namespace std; 
long long p[100001],x[100001],ans=0;
int n,s,l,r;
int main(){
	cin>>n>>s;
	for (int i=1;i<=n;i++)
		cin>>x[i]>>p[i];
	l=1;r=n;
	while (l<=r){
	if (s<=x[l]){
		cout<<x[r]-s+ans;
		return 0;
	} 
	else if (s>=x[r]){
		cout<<ans+s-x[l];
		return 0;
	}  //所有住处都在s的一侧，可以直接开过去 		
	if (p[l]>=p[r]){
		ans+=x[r]-x[l];
		while (l<r&&p[l]>=p[r]) p[l]+=p[r--];
	}
	else{
		ans+=x[r]-x[l];
		while (l<r&&p[l]<p[r]) p[r]+=p[l++];
	}
	}
	return 0;
} 

Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		double A = sc.nextInt();
		int B = sc.nextInt();
		double T = sc.nextInt();

		int c = (int) ((T + 0.5) / A);
		System.out.println(c * B);

		System.out.println();

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int n;
    cin >> n;
    if (65 <= n && n <= 90) {
        cout << 1 << endl;
    }
    else if (97 <= n && n <= 122) {
        cout << 2 << endl;
    }
    else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3088
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Side = Tuple!(long, "from", long, "to");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    long[long] a;
    foreach (i; iota(n))
    {
        auto tmp = lread();
        if (!(tmp in a))
            a[tmp] = 1;
        else
            a[tmp] = !a[tmp];
    }
    long ans;
    foreach (e; a)
        ans += e;
    ans.writeln();
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

bool isPrime(ll n){
    if(n==2) return true;
    if(n==1 || (n&1)==0) return false;

    ll d = (n-1)>>1;
    while((d&1)==0) d=d>>1;
    for(int k=0;k<100;k++){
        //ll a = (ll)abs(rand()) << (sizeof(int)*8);
        ll a = (ll)abs(rand()) << (sizeof(int)*7);
        a = 1 + (abs(a|(ll)rand()) % (n-1));
        ll t = d;
        ll y = 1;
        //modpow
        while (t > 0) {
            if (t & 1) y = y * a % n;
            a = a * a % n;
            t >>= 1;
        }
        t = d;

        while(t != n - 1 && y != 1 && y != n - 1){
            y = (y * y) % n;
            t <<= 1;
        }

        if(y != n - 1 && (t & 1) == 0)
            return false;
    }
    return true;
}

int main() {
    //ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    int ans=0;
    REP(i,n){
        int p;
        cin>>p;
        if(isPrime(p)) ans++;
    }

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


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[65];
int main()
{
    for(ll i=1;i<=60;i++)
        a[i] = (i*(i+1))/2;
    ll n;
    cin >> n;
    if(n==1)
    {
        cout << 0 << endl;
        return 0;
    }

    map<ll,ll>mp;
    for(ll i=2;i*i<=n;i++)
    {
        ll cnt=0;
        while(n%i==0)
        {
            cnt++;
            n/=i;
        }
        if(cnt)
            mp[i]=cnt;
    }

    if(n>1)
        mp[n]=1;
    ll ans =0;
    for(auto it: mp)
    {
        ll id = lower_bound(a,a+60,it.second)-a;
        if(a[id]==it.second)
            ans+=id;
        else
            ans+=id-1;
    }

    cout << ans <<endl;

}


Measured memory_bytes: 3640
n = int(input())
a = list(map(int,input().split()))

yen = 1000

kabu = 0

for i in range(n-1):
    if a[i] < a[i+1]:
        kabu_today = yen // a[i]
        kabu += kabu_today
        yen = yen % a[i]
        
    else:
        yen += kabu * a[i]
        kabu = 0
    
#    print(yen, kabu,a[i], a[i] < a[i+1])

yen += kabu * a[n-1]
kabu = 0

print(yen)


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

int main(){
	string s, p, ss;
	bool flag = 0;
	//s = "sakanagapyonpyon";
	//p = "sakand";
	cin >> s >> p;
	ss = s + s;
	for (long i = 0; i < ss.size(); i++){
		if (ss[i] == p[0]){
			for (long j = 0; j < p.size(); j++){
				if (ss[i + j] != p[j]) break;
				if (j == p.size() - 1) flag = 1;
			}
			if (flag == 1) break;
		}
	}
	if (flag == 1) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1188
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		long sum = getLong(sc);
		boolean overflow = false;
		for (int i = 1; i < n; i++) {
			try {
				long next = Math.multiplyExact(sum, getLong(sc));
				sum = next;
			} catch (Exception e) {
				overflow = true;
			}

		}
		if (sum == 0) {
			System.out.println(0);
		} else if (isOver(sum) || overflow) {
			System.out.println(-1);
		} else {
			System.out.println(sum);
		}

	}

	private static boolean isOver(long sum) {
		if (sum > 1000000000000000000L) {
			return true;
		}
		return false;
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}

class Status {
	int row = 0;
	int col = 0;
	int candies = 0;

	public Status(int row, int col, int candies) {
		this.row = row;
		this.col = col;
		this.candies = candies;
	}
}


Measured memory_bytes: 58772
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<functional>
#include<iostream>
#include<queue>
using namespace std;
int main(void)
{
	int x;
	cin >> x;
	if(x < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl; 
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    
    vector<int> enemy(n + 1);
    vector<int> hero(n);
    
    for (int i = 0; i < n + 1; i++) {
        cin >> enemy.at(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> hero.at(i);
    }
    
    long count = 0;
    for (int i = 0; i < n; i++) {
        if (hero.at(i) > enemy.at(i)) {
            count += enemy.at(i);
            hero.at(i) -= enemy.at(i);
            enemy.at(i) = 0;
            if (hero.at(i) > enemy.at(i + 1)) {
                count += enemy.at(i + 1);
                hero.at(i) -= enemy.at(i + 1);
                enemy.at(i + 1) = 0;
            } else {
                count += hero.at(i);
                enemy.at(i + 1) -= hero.at(i);
                hero.at(i) = 0;
            }
        } else {
            count += hero.at(i);
            enemy.at(i) -= hero.at(i);
            hero.at(i) = 0;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
const ll MOD = 1000000007;
//const ll MOD = 998244353;

ll seg[524288];

void raq(int s, int t, ll v, int k = 1, int l = 0, int r = 262143) {
	if (t < l || r < s)return;
	if (s <= l && r <= t) {
		seg[k] += v;
		return;
	}
	raq(s, t, v, k * 2, l, (l + r) / 2);
	raq(s, t, v, k * 2 + 1, (l + r) / 2 + 1, r);
}

ll gets(int x) {
	x += 262144;

	ll ans = 0;
	while (x) {
		ans += seg[x];
		x /= 2;
	}
	return ans;
}

int main() {
	for (int i = 0;i < 524288;i++)seg[i] = 0;
	ll N, D, A, H, X;
	cin >> N >> D >> A;
	vector<pair<ll, ll>> V(N);
	for (int i = 0;i < N;i++) {
		cin >> X >> H;
		V[i] = { X,H };
	}
	sort(all(V));
	for (int i = 0;i < N;i++) {
		raq(i, i, V[i].second);
	}

	pair<ll, ll> P;
	ll ans = 0, id, att;
	for (int i = 0;i < N;i++) {
		X = V[i].first;
		H = gets(i);
		if (H <= 0)continue;
		P = { X + 2 * D + 1,LLONG_MIN };
		auto it = lower_bound(all(V), P);
		if (it == V.begin()) {
			att = (H - 1) / A + 1;
			ans += att;
		}
		else {
			att = (H - 1) / A + 1;
			ans += att;
			it--;
			id = it - V.begin();
			raq(0, id, -att * A);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 7424
n = int(input())
a = list(map(int, input().split()))
a.sort()

if n%2==0 and a[::2] == a[1::2]:
  print(2**(n//2) % (10**9+7))
elif n%2==1 and a[1::2] == a[2::2]:
  print(2**(n//2) % (10**9+7))
else:
  print(0)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main(){
    int n , sum = 0;
	cin >> n;
	int b[n];
	for(int i = 1; i < n; i++){
        cin >> b[i];
    }
	    sum += b[1] + b[n - 1];
	for(int i = 1; i < n - 1; i++){
        sum += min(b[i] , b[i + 1]);
    }
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int d = sc.nextInt();

		String space[] = new String[n];
		int countSpace;
		int countD = 0;

		for(int i = 0; i < n; i++) {
			countSpace = 0;
			space[i] = sc.next();
			for(int j = 0; j < m; j++) {
				if(space[i].charAt(j) == '#') {
					countD += Math.max(countSpace - d + 1, 0);
					countSpace = 0;
				}
				else {
					countSpace++;
					if(j == m - 1) countD += Math.max(countSpace - d + 1, 0);
				}
			}
		}

		for(int i = 0; i < m; i++) {
			countSpace = 0;
			for(int j = 0; j < n; j++) {
				if(space[j].charAt(i) == '#') {
					countD += Math.max(countSpace - d + 1, 0);
					countSpace = 0;
				}
				else {
					countSpace++;
					if(j == n - 1) countD += Math.max(countSpace - d + 1, 0);
				}
			}
		}

		System.out.println(countD);
	}

}



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

#define int long long int
#define vi vector<int>
#define pii pair<int,int>
#define pq priority_queue<int>
#define pb push_back
#define INF 1000000000000000000
#define modu 1000000007
#define out(a) cout<<a
#define out2(a,b) cout<<a<<" "<<b
#define out3(a,b,c) cout<<a<<" "<<b<<" "<<c
#define in(a) cin>>a
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define spc <<" "
#define nl <<"\n"
#define khubTesh(ti) cout<<"Case "<<ti<<": "

void testCase(int ti,int ans){
    khubTesh(ti);
    out(ans) nl;
}

void debug(string pr,vector<int> var)
{
    cout<<pr;
    for(int i=0;i<var.size();i++) cout<<" "<<var[i];
    cout<<endl;
}

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
}

int n,k;
int ans[110][100010];
int w[110],v[110];

int dp(int at,int weight){
    if(weight==0 || at>n) return 0;
    if(ans[at][weight]!=-1) return ans[at][weight];
    int ans1=0,ans2=0;
    if(weight-w[at]>=0) ans1=dp(at+1,weight-w[at])+v[at];
    ans2=dp(at+1,weight);
    return ans[at][weight]=max(ans1,ans2);
}

int32_t main(){
    faster();
    #ifdef OFFLINE
      freopen("in.txt", "r", stdin);
      freopen("out.txt", "w", stdout);
    #endif
    //Now I will start writing codes and start preparation to get errors
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++) ans[i][j]=-1;
    }
    cout<<dp(1,k);
   // cout<<"ashena kn!!";
    return 0;
}


Measured memory_bytes: 79360
r, g, b = map(int, input().split())
K = int(input())
for i in range(K+1):
    for j in range(K+1-i):
        for k in range(K+1-i-j):
            rr, gg, bb = r * (1<<i), g * (1<<j), b * (1<<k)
            if rr < gg < bb:
                print('Yes')
                exit()
print('No')


Measured memory_bytes: 9172
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;
const int MAX = 1000001;
long long fac[MAX];
long long finv[MAX];
long long inv[MAX];
 
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
 
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
int main(){ 
    long long X;
    long long Y;
    cin >> X >> Y;
    comb_init();
    long long ans = 0;
    for(int i = 0; i <= X; i++){
        if((X - i) % 2 == 0){
            int two_jump_num = (X - i) / 2;
            if(Y == 2 * i + two_jump_num){
                ans = (ans + comb(i + two_jump_num, two_jump_num)) % MOD;
            }
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 23808
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    ll jou=1;
    if(n%2)jou=2;
    ll dp[n+1][2][jou+1];
    rep(i,0,n+1){
        rep(j,0,2)rep(k,0,jou+1)dp[i][j][k]=-inf;
    }
    dp[0][0][0]=0;
    rep(i,0,n){
        rep(j,0,2){
            rep(k,0,jou+1){
                if(j==0){
                    Max(dp[i+1][1][k],dp[i][j][k]+a[i]);
                    if(k<jou){
                        Max(dp[i+1][0][k+1],dp[i][j][k]);
                    }
                }
                else{
                    Max(dp[i+1][0][k],dp[i][j][k]);
                }
            }
        }
    }
    
    ll ans=-inf;
    rep(i,0,2){
        rep(j,jou-1,jou+1)Max(ans,dp[n][i][j]);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 14532
#include<cstdio>
int m=99,n,w[12]={1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
void dfs(int p,int s,int c)
{
	if(!(s^n))m=m<c?m:c;
	else if(p--)for(int i=0;i<6&&s+w[p]*i<=n;++i)dfs(p,s+w[p]*i,c+i);
}
int main()
{
	scanf("%d",&n);
	dfs(12,0,0);
	printf("%d",m);
}

Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    int n,c,k;cin>>n>>c>>k;
    int t[n];
    int count=1;
    int riders=1;
    int q=0;
    rep(i,n)cin>>t[i];
    sort(t,t+n);
    for(int i=1;i<n;i++){
        if(t[i]-t[q]>k||riders==c){
            count++;
            riders=1;
            q=i;
        }
        else {
            riders++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 640
n = int(input())
A = []
for i in range(n):
    x,l = map(int,input().split())
    a = x -l
    b = x + l
    A.append((b,a))
A.sort()

ans = 0
prev = -10**9 - 7

for i in range(n):
    if A[i][1] >= prev:
        prev = A[i][0]
        ans += 1
print(ans)

Measured memory_bytes: 16988
A, B, C, X, Y = map(int, input().split())
ans = X*A + Y*B
if X>Y:
  ans = min(X*A + Y*B, 2*X*C, 2*Y*C+(X-Y)*A)
else:
  ans = min(X*A + Y*B, 2*Y*C, 2*X*C+(Y-X)*B)
print(ans)

Measured memory_bytes: 3060
iN = int(input())
aA = [int(x) for x in input().split()]

#i2M = (min(aA) + max(aA)) // 2
iMM = sum(aA) // len(aA)

#if i2M < iMM :
#   iLM = i2M
#   iUM = iMM + 1
#else:
#   iLM = iMM
#   iUM = i2M + 1

iLM = iMM
iUM = iMM + 1

aR = []
for iM in range(iLM,iUM+1):
    aR.append(0)
    for iA in aA:
        aR[-1] += (iA - iM) ** 2
print(min(aR))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (int i = 0; i < n; i++)
#define repc(i, n) for (int i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long
#define printarray(arr, n) for(int i= 0;i<n;i++) cout<<a[i]<<' '; cout<<endl;
#define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl;
#define initdp(a) memset(a, -1, sizeof(a));

using namespace std;
const int MOD = 1e9 + 7;
const int INF = 2e15;
const int MAXN = 1e6 + 5;

int fastexpo(int b, int exp){
    if(exp == 0) return 1;
    if(exp == 1) return b;
    int ans = (fastexpo(b,exp/2) % MOD);
    ans *= ans;
    ans %= MOD;
    if(exp % 2 == 1){
        ans *= b;
    }
    ans %= MOD;
    return ans;
}



signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    if(n < 2) {
        cout<<0<<endl;
        return 0;
    }
    cout<<((((fastexpo(10, n)-((fastexpo(9, n)*2)%MOD))+MOD)%MOD)+ (fastexpo(8, n)%MOD))%MOD<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 202000,inf=0x3f3f3f3f;
int n,x,y,a[N],b[N],dis[N],fa[N][18],dep[N];Vi e[N],red[N];bool win[N];
void dfs1(int u, int Fa, int Dep){
	fa[u][0]=Fa;dep[u]=Dep;
	rep(i,0,SZ(e[u])-1)if(e[u][i]!=Fa)
		dfs1(e[u][i],u,Dep+1);
}
int LCA(int u, int v){
	if(dep[u]<dep[v])swap(u,v);int del=dep[u]-dep[v];
	rep(i,0,17)if(del>>i&1)u=fa[u][i];
	if(u==v)return u;
	per(i,17,0)if(fa[u][i]!=fa[v][i])u=fa[u][i],v=fa[v][i];
	return fa[u][0];
}
int getdis(int u, int v){
	return dep[u]+dep[v]-2*dep[LCA(u,v)];
}
int res;
void bfs(){
	memset(dis,inf,sizeof(dis));dis[x]=0;
	static int q[N];int f=0,r=1;q[f]=x;
	while(f!=r){
		int u=q[f++];if(!(dis[u]<dep[u]))continue;
		if(win[u]){puts("-1");exit(0);}umax(res,2*dep[u]);
		rep(i,0,SZ(red[u])-1)if(dis[red[u][i]]>dis[u]+1){
			dis[red[u][i]]=dis[u]+1;q[r++]=red[u][i];
		}
	}
}
int main() {
	read(n);read(x);read(y);
	rep(i,1,n-1)read(a[i]),read(b[i]);
	rep(i,1,n-1){
		int u,v;read(u),read(v);
		e[u].pb(v);e[v].pb(u);
	}
	dfs1(y,0,0);
	rep(j,1,17)rep(i,1,n)fa[i][j]=fa[fa[i][j-1]][j-1];
	rep(i,1,n-1)if(getdis(a[i],b[i])>=3)win[a[i]]=win[b[i]]=1;
	else red[a[i]].pb(b[i]),red[b[i]].pb(a[i]);
	bfs();printf("%d",res);
	return 0;
}


Measured memory_bytes: 53504
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <cctype>
#include <cstdio>
#include<string>
using namespace std;

int main(){
   string s,p;
   cin >> s >> p;
   s=s+s;

   if(s.find(p)!=-1) printf("Yes\n");
   else printf("No\n");

   return 0;
}



Measured memory_bytes: 3212