akhauriyash/Code-Regression huggingface dataset:
/**
* @author khokharnikunj8
**/
#include <bits/stdc++.h>

using namespace std;

//macros
#define ll long long
#define endl "\n"
#define pb push_back

//debug

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template<typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }


template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

bool isPrime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int x;
    cin >> x;
    while (!isPrime(x)) x++;
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N;
    cin >> N;
    int ans[] = {2, 5, 63, 20, 90};
    if (N < 6) {
        for (int i = 0; i < N; i++) cout << ans[i] << " ";
        cout << endl;
    } else {
        int S = 0, k = 0, x0 = 0, x4 = 4;
        vector<int> ans;
        for (; N > 0; k++) {
            if (N) ans.push_back(6 * k + 2), N--, S += ans.back();
            if (N) ans.push_back(6 * k + 3), N--, S += ans.back();
            if (N) ans.push_back(6 * k + 4), N--, S += ans.back(), x4 = ans.back();
            if (N) ans.push_back(6 * k + 6), N--, S += ans.back(), x0 = ans.back();
        }
        if (S % 6 == 2) ans.erase(ans.begin()), ans.push_back(x0 + 6);
        if (S % 6 == 3) ans.erase(ans.begin() + 1), ans.push_back(x0 + 6);
        if (S % 6 == 5) ans.erase(ans.begin() + 1), ans.push_back(x4 + 6);
        for (const auto& x : ans) cout << x << " ";
        cout << endl;
    }
    return 0;
}

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

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

#define MOD 1000000007

int main(void) {
    ll N;
    string s, t;
    ll count = 0;
    cin >> N >> s >> t;
    for(ll i = 0;i < N;i++) {
        string a(s.begin() + s.size() - 1 - i, s.end());
        string b(t.begin(), t.begin() + i + 1);
        if(a == b) count = max(count, (ll)a.size());
    }
    cout << s.size() + t.size() - count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,d,x;
  cin >> n >> d >> x;
  //vector<ll> a(n);
  ll res = 0;
  res += x;
  for(int i = 0;i < n;i++){
    ll in;
    cin >> in;
    for(int j = 0;j < d;j++){
      if(j % in == 0)res++;
    }
    //cout << in << endl;
  }
  cout << res << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int x;
    cin >> x;
    for(int i = 2;i*i<=x;i++) {
        if(x%i==0){
            x++;
            i = 1;
        }
    }
    cout << x << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=110;
int n,m,x;
int a[maxn];

int main()
{
    scanf("%d %d %d",&n,&m,&x);
    for(int i=0;i<m;i++)
        scanf("%d",&a[i]);
    sort(a,a+m);
    for(int i=0;i<m;i++)
    {
        if(a[i]>x)
        {
            printf("%d\n",min(m-i,i));
            return 0;
        }
    }
    puts("0");
    return 0;
}


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

typedef long long ll;
const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<int> count(n + 5, 0);
  count[0] = 3;
  vector<ll> dp(n + 1, 0);
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1] * count[a[i]];
    dp[i] %= MOD;
    count[a[i] + 1]++;
    count[a[i]]--;
  }
  cout << dp[n] << endl;
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int res = 0;
    int N;
    cin >> N;
    REP(i, N) {
        int a;
        cin >> a;
        res += a - 1;
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    a = input()
    print('A' if a.lower()!=a else 'a')


main()



Measured memory_bytes: 9908
n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
pre = -2
for i in range(n):
    ans += b[a[i]-1]
    if a[i]-1 == pre + 1:
        ans += c[a[i]-2]
    pre = a[i]-1

print(ans)

Measured memory_bytes: 3064
// author - Saksham :)
#include<bits/stdc++.h>
/*#include <boost/multiprecision/cpp_int.hpp> 
using namespace boost::multiprecision;*/ 
#define ll long long int
#define ld long double
#define bigint int64_t
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;read(t);while(t--)
#define all(v) v.begin(),v.end()

#define forn(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))
#define for1(i,n) for(ll (i) = 1 ; (i) <= (n) ; ++(i))
#define forr(i,n) for(ll (i) = (n)-1 ; (i)>=0 ; --(i))
#define forab(i,a,b,c) for(ll (i) = a ; (i) <= (b) ; (i)+=(c))

using namespace std;

template <typename T>
void read(T &x){
	cin >> x;
}
template <typename T , typename T0>
void read(T &x,T0 &y){
	cin >> x >> y;
}

template <typename T , typename T0 , typename T1>
void read(T &x,T0 &y,T1 &z){
	cin >> x >> y >> z;
}

template <typename T , typename T0 , typename T1 , typename T2>
void read(T &x,T0 &y,T1 &z,T2 &w){
	cin >> x >> y >> z >> w;
}

template <typename T , typename T0>
void read(pair< T , T0 > &p){
	cin >> p.fst >>p.scd;
}

template <typename T>
void read(vector< T > &oneD){
	for(ll i=0;i<oneD.size();i++){
		read(oneD[i]);
	}
}

template <typename T>
void read(T oneD[] , ll n){
	for(ll i=0;i<n;i++){
		read(oneD[i]);
	}
}

template <typename T>
void write(T &x){
	
	cout << x << " ";
}

template <typename T , typename T0>
void write(T &x,T0 &y){
	cout << x << " " << y << "\n";
}

template <typename T , typename T0 , typename T1>
void write(T &x,T0 &y,T1 &z){
	cout << x << " " << y << " " << z << "\n";
}

template <typename T , typename T0 , typename T1 , typename T2>
void write(T &x,T0 &y,T1 &z,T2 &w){
	cout << x << " " << y << " " << z << " " << w << "\n";
}

template <typename T , typename T0>
void write(pair< T , T0 > &p){
	write(p.fst);
	write(p.scd);
	cout << endl;
}

template <typename T>
void write(vector< T > &oneD){
	for(ll i=0;i<oneD.size();i++){
		write(oneD[i]);
	}
	cout << endl;
}

template <typename T>
void write(T oneD[] ,int n){
	for(ll i=0;i<n;i++){
		write(oneD[i]);
	}
	cout << endl;
}

template <typename T , typename T0>
void write(map< T , T0 > &mpp){
	for(auto it : mpp){
		write(it.fst);
		cout << ": ";
		write(it.scd);
		cout << "\n";
	}
	cout<<endl;
}
vll seive;
void Seive(){
	const ll maxn = 1000005;
	seive.resize(maxn);
	forn(i,maxn) seive[i] = i;
	seive[1] = -1;
	seive[0] = -1;
	forab(i,2,maxn,1) if(i == seive[i]) for(ll j = 2*i ; j < maxn ; j+=i) if(seive[j] == j) seive[j] = i;
}

ll extended_GCD(ll a , ll b , ll &x , ll &y){
	if(a == 0){
		x = 0;
		y = 1;
		return b;
	}
	ll x1 , y1;
	ll gcd = extended_GCD(b%a , a , x1 , y1);
	x = y1 - (b/a)*x1; 
	y = x1;
	return gcd;
}

ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll modinv(ll a , ll mod = MOD){
	ll x , y;
	extended_GCD(a , mod , x , y);
	if(x < 0) x += mod;
	return x;
}

int main()
{
    flash;
	ll H,W,h,w;
	read(H,W,h,w);
	cout<<(H*W-h*W-w*H+h*w);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,m;
    cin>>n>>m;
    pair<int,int> j[n];
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        j[i]={-b,a};
    }
    sort(j,j+n);
    int ans=0;
    set<int> s;
    for(int i=m-n+1;i<=m;i++){
        s.insert(i);
    }
    for(int i=0;i<n;i++){
        auto it=s.lower_bound(j[i].second);
        if(it!=s.end()){
            s.erase(it);
            ans+=-j[i].first;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()


int main() {
    char data[100010]; scanf("%s",data);
    string Data = string(data);
    ll red = 0, blue = 0;
    rep(i,Data.size()){
        if (Data[i] == '0') red ++;
        else blue ++;
    }
    cout << min(red,blue)*2 << endl;
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

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

Measured memory_bytes: 3624
a,b,c= map(int, input().split())
tempc = c
result=0
PF=[]

for i in range(1,c+1):
  if tempc % i == 0:
    PF.append(i)

for j in range(len(PF)):
  if a <= PF[j] and PF[j] <= b:
    result+=1
    
print(result)


Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
using namespace std;
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

ll gcd(ll a, ll b){
  if(a<b){
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll x = a*b;
  ll r = a % b;
  
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  } 
  return x/b;
}

int main(){
  ll N;
  cin >> N;
  ll a[3010];
  FOR(i, 0, N) cin >> a[i];
  
  ll sum_a = 0;
  FOR(i, 0, N) sum_a += a[i];
  
  cout << sum_a - N << endl;
  /*ll GC = a[0];
  FOR(i, 1, N) GC = gcd(GC, a[i]);
  
  ll sum_a = 0;
  FOR(i, 0, N) sum_a += a[i];
  
  cout << GC << endl;
  ll max = 0;
  ll sum = 0;
  FOR(j, 0, GC){
    sum = 0;
    FOR(i, 0, N) sum += j % a[i];
    if(max < sum) max = sum;
  }

  cout << max << endl;*/
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static int N = 200;

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

		int cnt = 0;

		while (sc.hasNextInt()) {
			cnt++;
			if (cnt > 200)
				break;

			int a = sc.nextInt();
			int b = sc.nextInt();

			int sum = a + b;
			int count = 1;

			while ((sum /= 10) != 0) {
				count++;
			}

			System.out.println(count);
		}
	}

}

Measured memory_bytes: 20400
N = input()
A = map(int,raw_input().split())

for i in range(N-1):
    print A[i],
print A[-1]

for i in range(1,N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    for i in range(N-1):
        print A[i],
    print A[-1]

Measured memory_bytes: 6416
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int c = Integer.parseInt(a+b);
		if(Math.sqrt(c) % 1 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 23892
#include<iostream>
using namespace std;
int main(){
  int n,m,p;
  int i,j,k,l;
  int x,y,z;
  int bx[]={1,0,0,1,1,0, 1, 1, 0,1,-1, 1, 1};
  int by[]={0,1,0,1,0,1,-1, 0, 1,1, 1,-1, 1};
  int bz[]={0,0,1,0,1,1, 0,-1,-1,1, 1, 1,-1};
  int ln;
  cin >> n >> m >> p;
  while(n+m+p!=0){
    int d[8][8][8]={{{}}};
    int step=0;
    int winner=0;
    int ax,ay,az;
    for(i=0;i<p;i++){
      cin >> x >> y;
      x--;y--;
      //cout << i << endl;
      if(winner == 0){
	z=0;
	while(d[x][y][z]!=0) z++;
	
	if(i%2==0){
	  d[x][y][z]=1;
	  for(j=0;j<13;j++){
	    ln=0;
	    ax=x;ay=y;az=z;
	    while(d[ax][ay][az]==1){
	      ln++;
	      ax+=bx[j];
	      ay+=by[j];
	      az+=bz[j];
	      if(ax<0||ax>=n||ay<0||ay>=n||az<0||az>=n) break;
	    }
	    ax=x;ay=y;az=z;
	    while(d[ax][ay][az]==1){
	      ln++;
	      ax-=bx[j];
	      ay-=by[j];
	      az-=bz[j];
	      if(ax<0||ax>=n||ay<0||ay>=n||az<0||az>=n) break;
	    }
	    //cout << ln << endl;
	    
	    if(ln>m) {
	      winner = 1;
	      step = i+1;
	    }
	  }
	}else{
	  d[x][y][z]=2;
	  for(j=0;j<13;j++){
	    ln=0;
	    ax=x;ay=y;az=z;
	    while(d[ax][ay][az]==2){
	      ln++;
	      ax+=bx[j];
	      ay+=by[j];
	      az+=bz[j];
	      if(ax<0||ax>=n||ay<0||ay>=n||az<0||az>=n) break;
	    }
	    ax=x;ay=y;az=z;
	    while(d[ax][ay][az]==2){
	      ln++;
	      ax-=bx[j];
	      ay-=by[j];
	      az-=bz[j];
	      if(ax<0||ax>=n||ay<0||ay>=n||az<0||az>=n) break;
	    }
	    if(ln>m) {
	      winner = 2;
	      step = i+1;
	    }
	  }
	}
      }
    }
    /*
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	for(k=0;k<n;k++){
	  cout << d[j][k][i];
	}
	cout << endl;
      }
      cout << endl;
    }
    */
    if(winner==0) cout << "Draw" << endl;
    else if(winner==1) cout << "Black" <<  " " << step << endl;
    else cout << "White" <<  " " << step << endl;
    cin >> n >> m >> p;
  }
  return 0;
}

Measured memory_bytes: 1164
m=10**9+7
f=max
r=range
for _ in r(int(input())):
	x,y=sorted(map(int,input().split()))
	s=-1
	i=j=1
	while j<=x and i+j<=y:
		i,j,s=j,i+j,s+1
	if x==1 or y<3:print(1,x*y%m)
	else:
		a=f(0,(y-j)//i+1)+f(0,(x-j)//i+1)
		i=j=1
		for c in r(s):
			k,l=j,i+j*2
			for _ in r(s-c):k,l=l,k+l
			if x>=k:a+=f(0,(y-l)//k+1)
			if y>=k:a+=f(0,(x-l)//k+1)
			i,j=j,i+j
		print(s+1,a%m)

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

int main(){
int N, w = 0;  
string S;
 cin >> N >> S;
int E[N] = {};  
  
int e = 0;  
  
  for(int i = 0;i < N;i++){
  if(S.at(i) == 'E'){
   e++;
  }
  else {
  w++;
  }
    
  E[i] = e;  
  }
  
int mi;

  if(S.at(0) == 'E') mi = e - 1;
  else mi = e;
  
  for(int i = 1;i < N;i++){
    mi = min(mi, i - E[i - 1] + e - E[i]);   
  }

 cout << mi << endl;
  return 0;
  
}

Measured memory_bytes: 1924
a,b,c=map(int,input().split())
ans=7
w=7*a+b
if c<=6*a:
    if c%a==0:
        ans=c//a
    else:
        ans=c//a+1
else:
    if c>w:
        ans+=(c//w-1)*7
        c-=c//w*w
        if c%a==0 and c<=6*a:
            ans+=c//a
        else:
            if 6*a<c<=7*a+b:
                ans+=7
            else:
                ans+=c//a+1
print(ans)


Measured memory_bytes: 5596
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

#input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
    x = int(input())
    for a in range(-200,201):
        for b in range(-200,201):
            if(a**5-b**5 == x):
                print(a,b)
                return

main()


Measured memory_bytes: 73060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i =(b)-1;i>=(a);--i)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	cout << c*60+d-a*60-b-e; 
	return 0;
}


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

int H, W;

int main() {
  cin >> H >> W;

  vector<vector<char>> grid(H + 2, vector<char>(W + 2, '#'));
  rep(i, H) rep(j, W) cin >> grid[i + 1][j + 1];

  vector<vector<vector<int>>> C(H + 2,
                                vector<vector<int>>(W + 2, vector<int>(4, 0)));

  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j) {
      if (grid[i][j] == '#') {
        C[i][j][0] = 0;
      } else {
        C[i][j][0] = C[i][j - 1][0] + 1;
      }
      if (grid[i][W - j + 1] == '#') {
        C[i][W - j + 1][1] = 0;
      } else {
        C[i][W - j + 1][1] = C[i][W - j + 2][1] + 1;
      }
    }

  for (int j = 1; j <= W; ++j)
    for (int i = 1; i <= H; ++i) {
      if (grid[i][j] == '#') {
        C[i][j][2] = 0;
      } else {
        C[i][j][2] = C[i - 1][j][2] + 1;
      }
      if (grid[H - i + 1][j] == '#') {
        C[H - i + 1][j][3] = 0;
      } else {
        C[H - i + 1][j][3] = C[H - i + 2][j][3] + 1;
      }
    }

  int ans = 0;
  rep(i, H) rep(j, W) {
    if (grid[i + 1][j + 1] == '#') continue;
    ans = max(ans, accumulate(all(C[i + 1][j + 1]), 0) - 3);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 225664
#include <iostream>

#define ll long long
using namespace std;

int main() {
    ll n, x;
    cin >> n >> x;
    ll ret = n;
    n -= x;
    while (x > 0) {
        ret += n / x * 2 * x;
        ll tmp = x;
        x = n % x;
        n = tmp;
    }
    cout << ret - n << endl;
    return 0;
}

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

using namespace std;

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N);
    for (int i = 0; i < N; ++i) {
        vector<int> P(D);
        for (int j = 0; j < D; ++j) cin >> P[j];
        X[i] = P;
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            double dis_total = 0;
            for (int k = 0; k < D; ++k) dis_total += pow(X[i][k] - X[j][k], 2);
            dis_total = sqrt(dis_total);
            if (ceil(dis_total) == floor(dis_total)) ++ans;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  map<char,int>m;
  for(auto it:s)m[it]++;
  if((m['a']==m['b']&&m['b']==m['c']&&s.size()%3==0)||
      (m['a']-1==m['b']&&m['b']==m['c'])||
      (m['b']-1==m['c']&&m['c']==m['a'])||
      (m['c']-1==m['a']&&m['a']==m['b'])||
      (m['a']+1==m['b']&&m['b']==m['c'])||
      (m['b']+1==m['c']&&m['c']==m['a'])||
      (m['c']+1==m['a']&&m['a']==m['b'])
      )cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  long n;
  cin >> n;

  string s;
  cin >> s;

  int count = 0;
  for (long i = 0; i < n - 2; i++) {
    if (s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C') {
      count++;
    }
  }

  cout << count << endl;
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 
#define REP(i, n) for (int i = 0; i < (n); i++)

int main(int argc, char const *argv[])
{
    bool ac = true;
    int count = 0; 
    int idx = 0;
    string S; cin >> S;
    if (S[0] != 'A') ac = false;
    REP(i, S.size()) {
        if (S[i] == 'C') {
            count++;
            idx = i;
        }
    }
    if (count != 1) ac = false;
    if (idx < 2 || S.size() - 2 < idx) ac = false;
    FOR(i, 1, S.size()) {
        if (i == idx) continue;
        else if(S[i] < 94) ac = false;
    }
    if (ac) cout << "AC\n";
    else cout << "WA\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define debug(x) cerr<<#x<<' '<<x<<'\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int k,x;
    cin>>k>>x;
    k*=500;
    if(k>=x) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define nl cout<<endl;
#define inp 1000005
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

// Pick yourself up, 'cause...

int main()
{
    jaldi

    int n;
    cin>>n;

    vector<double> head(n+1),tail(n+1);

    for(int i=1;i<=n;i++)
    {
        cin>>head[i];
        tail[i]=1.0-head[i];
    } 

    double dp[n+1][n+1];
    memset(dp,0,sizeof dp);
    dp[0][0]=1.0;

    for(int i=0;i<=n;i++) //i head required
    {
        for(int j=1;j<=n;j++) // introducing jth coin
        {
            dp[i][j]=(dp[i][j-1]*tail[j] + dp[i-1][j-1]*head[j]);
        }
    } 

    // cout<<"dp  : \n";
    // for(int i=0;i<=n;i++)
    // {
    //     for(int j=1;j<=n;j++) cout<<dp[i][j]<<" ";
    //     nl;
    // }

    double ans;
    for(int i=n/2+1;i<=n;i++)
    {
        ans += dp[i][n];
    }

    cout << fixed << setprecision(10) << ans;

    return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<ll>a(n);
  rep(i, 0, n){
      cin >> a[i];
      a[i]-=(i+1);
  }
  sort(a.begin(),a.end());
  if(n%2==0){
      ll ans1=0, ans2=0;
      rep(i, 0, n){
          ans1 += abs(a[i]-a[n/2-1]);
          ans2 += abs(a[i]-a[n/2]);
      }
      cout << min(ans1, ans2) << endl;
      return 0;
  }else{
      ll ans = 0;
      rep(i, 0, n){
          ans += abs(a[i]-a[n/2]);
      }
      cout << ans << endl;
      return 0;
  }
}

Measured memory_bytes: 4764
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    S = list(map(int, input().split()))
    T = list(map(int, input().split()))

    dp = [[0] * (m + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(n + 1):
        for j in range(m + 1):
            if i - 1 >= 0:
                dp[i][j] += dp[i - 1][j]
            if j - 1 >= 0:
                dp[i][j] += dp[i][j - 1]
            if i - 1 >= 0 and j - 1 >= 0:
                dp[i][j] -= dp[i - 1][j - 1]
                if S[i - 1] == T[j - 1]:
                    dp[i][j] += dp[i - 1][j - 1]
            dp[i][j] %= mod
    print(dp[-1][-1])


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 105312
N= int(input())
A= list(map(lambda i:int(i),input().split()))
#print(N)
#print(A)
approved=True
for i in A:
    if i%2 ==0:
        if (i%3!=0) and (i%5!=0):
            approved= False
            break

if approved:
    print("APPROVED")
else:
    print("DENIED")


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

int main()
{

        string s;
        cin >> s;
        for (int i = 0; i < 3; ++i) {
                if (s[i] == '7') {
                        cout << "Yes" << endl;
                        exit(0);
                }
        }
        cout << "No" << endl;


}


Measured memory_bytes: 3624
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
#define N 200005
int n, a[N], b[N], f[N], g[N];
int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read(), f[a[i]]++;
	for (int i=1;i<=n;i++) b[i]=read(), g[b[i]]++;
	for (int i=1;i<=n;i++)
		if (f[i]+g[i]>n){
			puts("No");
			return 0;
		}
	puts("Yes");
	for (int i=1;i<=n/2;i++) swap(b[i],b[n-i+1]);
	int x=0, le=n+1, ri=0;
	for (int i=1;i<=n;i++) if (a[i]==b[i]) x=a[i];
	for (int i=1;i<=n;i++) if (a[i]==x || b[i]==x) le=min(le,i), ri=max(ri, i);	
	for (int i=1, j=1;i<=n;i++)
		if (a[i]==b[i]){
			if (le<=j && j<=ri) j=ri+1;
			swap(b[j++], b[i]);
		}
	for (int i=1;i<=n;i++) printf("%d%s", b[i], i==n?"\n":" ");	
    return 0;
}
/*
5
2 2 3 3 3
1 1 2 2 3
*/ 

Measured memory_bytes: 6764
//#define DEB1 //input from input.txt
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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;
}




/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    string S;
    cin >> S;
    cerr << S[0];
    if(S[0]!='7' && S[1]!='7' && S[2]!='7'){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return;
}



// ----------------------------------------------
int main(){

#ifdef DEB1
    cout << "DEBUG MODE"  << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf()); //for debug
#endif

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N, M;
  cin >> N >> M;
  map< int, int64 > uku;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    uku[-x]++;
  }
  while(M--) {
    int B, C;
    cin >> B >> C;
    uku[-C] += B;
  }
  int64 sum = 0, add = 0;
  for(pair< int, int64 > p : uku) {
    p.first *= -1;
    while(p.second--) {
      sum += p.first;
      ++add;
      if(add == N) break;
    }
    if(add == N) break;
  }
  cout << sum << endl;
}


Measured memory_bytes: 12800
s = input()
for _ in range(int(input())):
    code=input().split()
    if code[0]=='print'  :
        print(s[int(code[1]):int(code[2])+1])
    elif code[0]=='reverse':
        s = s[:int(code[1])] + s[int(code[1]):int(code[2])+1][::-1] + s[int(code[2])+1:]
    elif code[0]=='replace':
        s = s[:int(code[1])] + code[3] + s[int(code[2])+1:]

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define FOR2(i,a,b) for (int i=(a);i<(b);i++)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define ROF2(i,x,y) for(int i = (y) ; i >= (x) ; --i)
#define MP make_pair
#define ODD(x) (((x)&1)==0?(0):(1))
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

template<class T,class U>
ostream &operator<<(ostream &os,const pair<T,U> &x) {
    return os<<"("<<x.first<<","<<x.second<<")";
}

template<class T>
ostream &operator<<(ostream &os,const vector<T> &x) {
    os << '[';
    if ( !x.empty() ) {
        std::copy (x.begin(), x.end(), std::ostream_iterator<T>(os, ","));
        os << "\b";
    }
    os << "]";
    return os;
}
template<class T>
ostream &operator<<(ostream &os,const vector<vector<T> > &x) {
    os << '[';
    if ( !x.empty() ) {
        os << x[0];
        for (int i=1;i<x.size();i++) os << endl << " " << x[i];
    } else os << "[]";
    os << "]";
    return os;
}

int main() {
 //   freopen("in.txt", "r", stdin);
    int n;cin>>n;
    vi x(n);
    FOR(i,n) cin>>x[i];
    sort(x.begin(),x.end());
    int m=x[n-1];
    auto it = lower_bound(x.begin(),x.end(),m/2);
    if (*it==m) it--;
    if (m%2==0){
        if (it!=x.begin()) {
            auto prev = it;
            prev--;
            if (*it - m / 2 <= m / 2 - *prev)
                cout << m << " " << *it;
            else
                cout << m << " " << *prev;
        }else cout << m << " " << *it;

    }else{
        if (*it==m/2 || *it == m/2+1)
            cout << m << " " << *it;

        else if (it!=x.begin()) {
            auto prev = it;
            prev--;
            if (*it - (m + 1) / 2 <= m / 2 - *prev)
                cout << m << " " << *it;
            else
                cout << m << " " << *prev;
        }else cout << m << " " << *it;
    }
    return 0;
}




Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main(void){
    char s[100001];
    scanf("%s",s);
    int len=strlen(s);
    while(len!=0){
        if((s[len-5]=='d' && s[len-4]=='r' && s[len-3]=='e' && s[len-2]=='a' && s[len-1]=='m') || (s[len-5]=='e' && s[len-4]=='r' && s[len-3]=='a' && s[len-2]=='s' && s[len-1]=='e')) s[len-5]='\0';
        else if(s[len-6]=='e' && s[len-5]=='r' && s[len-4]=='a' && s[len-3]=='s' && s[len-2]=='e' && s[len-1]=='r') s[len-6]='\0';
        else if(s[len-7]=='d' && s[len-6]=='r' && s[len-5]=='e' && s[len-4]=='a' && s[len-3]=='m' && s[len-2]=='e' && s[len-1]=='r') s[len-7]='\0';
        else{
            printf("NO");
            return 0;
        }
        len=strlen(s);
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int  linear(int , int [], int );
#define N 10000
int main() {
  int n,q,A[N+1],key,sum = 0,i;

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

for(i=0;i<q;i++) {
    scanf("%d", &key);
    if(linear(key,A,n)) sum++;
}
  printf("%d\n",sum);

  return 0;
}

int  linear(int key, int A[],int n) {
  int i = 0;
   A[n] = key;
   while(A[i] != key) i++;
  return i != n;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define DEBUG true
#define coutd if(DEBUG) cout
#define debugf if(DEBUG) printf
#define ff first
#define ss second
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(){
	ios_base::sync_with_stdio(0);
	ll ent;
	cin >> ent;
	ll f = ent/100;
	ll s = ent%100;
	if(f<=12 && f>0 && s<=12 && s>0){
		cout << "AMBIGUOUS\n";
	}
	else if(f<=12 && f>0 && (s>12 || s<1)){
		cout << "MMYY\n";
	}
	else if((f>12 || f<1) && s>0 && s<=12){
		cout << "YYMM\n";
	}
	else{
		cout << "NA\n";
	}
}



Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){

  int i,j,k,l,n,p[N+1],m[N+1][N+1];

  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d %d",&p[i-1],&p[i]);

  for(i=1;i<=n;i++) m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=(1<<21);
      for(k=i;k<=j-1;k++){
	if(m[i][j]<m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
	  m[i][j]=m[i][j];
	else m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      }
    }
  }
  printf("%d\n",m[1][n]);

  return 0;
}



Measured memory_bytes: 2052
// abc109_b
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define FOR(i, a) for (auto i : a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define show1d(v)                                                              \
  rep(i, v.size()) cout << " " << v[i];                                        \
  cout << endl << endl;
#define show2d(v)                                                              \
  rep(i, v.size()) {                                                           \
    rep(j, v[i].size()) cout << " " << v[i][j];                                \
    cout << endl;                                                              \
  }                                                                            \
  cout << endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def, Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def, pii> pip;
typedef vector<pip> vip;
template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  int n, sOldSize;
  string s, sOld = "";
  map<string, int> w = {};
  cin >> n;
  rep(i, n) {
    cin >> s;
    w[s]++;
    sOldSize = (int)sOld.size();
    if (sOldSize > 0) {
      if (sOld[sOldSize - 1] != s[0]) {
        cout << "No" << endl;
        return 0;
      }

      if (w[s] > 1) {
        cout << "No" << endl;
        return 0;
      }
    }

    sOld = s;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
#define fi first
#define se second
const int N=2e5+5,md=1e9+7;
int id[N],n,fa[N],head[N],cnt,dep[N],ans,_2[N],tot[N];
struct edge{
	int to,nxt;
}e[N];
struct info{
	int _0,_1,_2;
}q;
struct data{
	int ed;
	vector<info>dp;
}F[N];
int mx;
void merge(int&x,int&y){
	if(F[x].ed<F[y].ed)x^=y^=x^=y;
	vector<info>&dpx=F[x].dp,&dpy=F[y].dp;
	for(int _y=(int)dpy.size()-1,_x=(int)dpx.size()-1;~_y;--_y,--_x)
		q=(info){(LL)dpx[_x]._0*dpy[_y]._0%md,((LL)dpx[_x]._0*dpy[_y]._1+(LL)dpx[_x]._1*dpy[_y]._0)%md,((LL)(dpx[_x]._1+dpx[_x]._2)*(dpy[_y]._1+dpy[_y]._2)+(LL)dpx[_x]._0*dpy[_y]._2+(LL)dpx[_x]._2*dpy[_y]._0)%md},dpx[_x]=q;
	mx=max(mx,(int)dpy.size());
	dpy.clear();
}
void dfs(int now){
	F[now].ed=dep[now];
	++tot[dep[now]];
	for(int i=head[now];i;i=e[i].nxt)
		dep[e[i].to]=dep[now]+1,dfs(e[i].to);
	mx=0;
	for(int i=head[now];i;i=e[i].nxt)
		merge(id[now],id[e[i].to]);
	vector<info>&dpp=F[id[now]].dp;
	for(int it=(int)dpp.size()-1;mx--;--it)
		(dpp[it]._0+=dpp[it]._2)%=md,dpp[it]._2=0;
	dpp.push_back((info){1,1,0});
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>fa[i];
		e[++cnt]=(edge){i,head[fa[i]]},head[fa[i]]=cnt;
		id[i]=i;
	}
	dfs(0);
	for(int i=*_2=1;i<=n+1;++i)_2[i]=_2[i-1]*2%md;
	vector<info>&dp=F[*id].dp;
	reverse(dp.begin(),dp.end());
	for(int i=0;i<dp.size();++i)
		ans=(ans+(LL)dp[i]._1*_2[n+1-tot[i]])%md;
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 25844
#include<iostream>
using namespace std;
int main()
{
    int data[3] = {0};
    int i;
    int da;
    cin >> data[0] >> data[1] >> data[2];
    if(data[0] > data[1]){
        da = data[1];
        data[1] = data[0];
        data[0] = da;
    }
    if(data[1] > data[2]){
        da = data[2];
        data[2] = data[1];
        data[1] = da; 
    }
        if(data[0] > data[1]){
        da = data[1];
        data[1] = data[0];
        data[0] = da;
    }
    cout <<data[0]<<" "<<data[1]<<" "<<data[2]<< endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  vector<int> a(5);
  rep(snip_i, 5) cin >> a.at(snip_i);
  rep(i, 5){
    if(a.at(i) == 0) cout << i+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>

int main()
{
    int k;
    int pos[5];
    for (int i = 0; i < 5; i++)
    {
        std::cin >> pos[i];
    }
    std::cin >> k;

    bool exist = false;
    for (int i = 0; i < 5; i++)
    {
        for (int j = i + 1; j < 5; j++)
        {
            if (pos[j] - pos[i] > k)
            {
                exist = true;
                break;
            }
        }
    }

    std::cout << (exist ? ":(" : "Yay!");
}

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

int main() {
  int N;
  cin >> N;
  vector<int> ls(N);
  rep(i,N) cin>>ls[i];
  sort(ls.begin(),ls.end());
  int cnt=0;
  
  rep(i,N)rep(j,i){
    auto iter = upper_bound(ALL(ls),ls[i]-ls[j]);
    unsigned int idx = distance(ls.begin(), iter);
    cnt+=max(0,j-(int)idx);
  }
  cout << cnt << endl;
  
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

bool apperance[1000000001];

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

    int A, B;
    cin >> A >> B;

    int ans = -1;
    REPinit(i, 1, 100001) {
        if ((int)(i * 0.08) == A && (int)(i * 0.1) == B) {
            ans = i;
            break;
        }        
    }

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


Measured memory_bytes: 3652