akhauriyash/Code-Regression huggingface dataset:
def main():
    A, B = (int(i) for i in input().split())
    ans = -1
    from math import floor
    for y in range(100000 + 1):
        a = floor(y*0.08)
        b = floor(y*0.1)
        if a == A and b == B:

            ans = y
            break
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int n, k; cin >> n >> k;
  double ans = 0;
  for (int i=1; i<=n; i++) {
    ans += (1.0/n) * pow((1.0/2.0), max(ceil(log2((double)k / (double)(i))), 0.0));
  }
  cout << fixed << setprecision(12);
  cout << ans << endl;
}

Measured memory_bytes: 384
#pragma GCC optimze("Ofast")

#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define vp(x,y) vector< pair<x,y> >
#define mp make_pair
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x));
#define DSort(x) sort(all(x), greater<>());
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define l_b lower_bound
#define u_b upper_bound
#define u_set unordered_set
#define u_map unordered_map
#define ff first
#define sc second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)

const ll M=1e9+7;
const ld PI=3.14159265;

using namespace std;

int main(){
    fast_io;
    ll t,n,i,j,k,c=0;
    t=1;
    while(t--){
        cin>>n;
        ll ar[n];
        for(i=0;i<n;i++) cin>>ar[i];
        sort(ar,ar+n);
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                for(k=j+1;k<n;k++){
                    if(ar[i]==ar[j] or ar[i]==ar[k] or ar[j]==ar[k]) continue;
                    if(ar[i]+ar[j]>ar[k] and ar[i]+ar[k]>ar[j] and ar[j]+ar[k]>ar[i]) c++;
                }
            }
        }
        cout<<c;
    }
}




Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    int count = 0;
    for(int i = 0;i < n;i++)
    {
        if(v[i] == i + 1)
        {
            swap(v[i],v[i + 1]);
            count++;
        }
    }
    cout << count;

    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);

int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2;
	int x = x2 - x1, y = y2 - y1;
	cout << x2 - y<<" ";
	cout << y2 + x<<" ";
	cout << x1 - y<<" ";
	cout << y1 + x<<" ";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, c;
int sum[40][200100];

int main() {
	cin >> n >> c;
	rep(i, n) {
		int s, t, cc;
		cin >> s >> t >> cc;
		cc--;
		sum[cc][2 * s - 1] = 1;
		sum[cc][2 * t] = -1;
	}
	rep(i, c) {
		rep(j, 200100 - 1) {
			sum[i][j + 1] += sum[i][j];
		}
	}
	int ans = 0;
	rep(i, 200100) {
		int cnt = 0;
		rep(j, c) {
			cnt += (sum[j][i] > 0);
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 24832
/*
 * atcoder/dp_2nd/k.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
#include <set>

using namespace std;

#define ll long long
#define MOD 1000000007

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 100100;
int N, K;
vector<int> A;

int dp[MAX];

void input() {
  cin >> N >> K;
  int a;
  loop(n,0,N) {
    cin >> a;
    A.push_back(a);
  }
}

int grundy(int n) {
  int &cache = dp[n];
  if (~cache) return cache;
  if (n < A[0]) return cache = 0;
  set<int> S;
  for (auto &&a: A) {
    if (n-a < 0) continue;
    S.insert(grundy(n-a));
  }

  int g = 0;
  while (S.count(g)) g++; // mex: 集合に含まれない最小の非負整数
  return cache = g;
}

void solve() {
  memset(dp, -1, sizeof(dp));
  sort(A.begin(), A.end());
  int g = grundy(K);
  if (g == 0) cout << "Second" << endl;
  else cout << "First" << endl;
  // loop(n,0,K+1) cout << dp[n] << " ";
  // cout << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


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

int main()
{
    ll a, b, i, j, ans=0,x;
    cin>>a>>b;

    for(i=0; i<b; i++)
    {
        cin>>x;
        ans+=x;
    }
    if(ans>=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}

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

ll N;

string encode(ll a){
    string ret;
    while(a>0){
        if(a%2==0)ret='0'+ret;
        else ret='1'+ret;
        a/=2;
    }
    while(ret.size()<N){
        ret='0'+ret;
    }
    return ret;
}

ll decode(string s){
    ll ret=0;
    ll pow2=pow(2,s.size()-1);
    for(ll i=0;i<s.size();i++){
        if(s[i]=='1')ret+=pow2;
        pow2/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll M,X;
    cin>>N>>M>>X;
    vll C(N);
    vvll A(N,vll(M));
    for(ll i=0;i<N;i++){
        cin>>C[i];
        for(ll j=0;j<M;j++){
            cin>>A[i][j];
        }
    }
    
    ll ans=LLMAX;
    for(ll i=0;i<pow(2,N);i++){
        string S=encode(i);
        ll cost=0;
        vll P(M,0);
        for(ll j=0;j<N;j++){
            if(S[j]=='1'){
                cost+=C[j];
                for(ll k=0;k<M;k++){
                    P[k]+=A[j][k];
                }
            }
        }
        
        bool ok=true;
        for(ll j=0;j<M;j++){
            if(P[j]<X)ok=false;
        }
        if(ok)chmin(ans,cost);
    }
    if(ans==LLMAX)cout<<-1<<endl;
    else cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 4096
import java.util.*;

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

        if(a < b) System.out.println("a < b");
        else if(a > b)System.out.println("a > b");
        else System.out.println("a == b");
    }
}


Measured memory_bytes: 26152
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
//#define min(a, b, c) min(a, min(b, c))
//#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	ll h,w;
	cin>>h>>w;
	ll ans=(n-h)*(m-w);
	cout<<ans;
	
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
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 vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vi a(n);
    int c1=0,c2=0,c3=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]%4==0)c3++;
        else if(a[i]%2==0)c2++;
        else if(a[i]%2!=0)c1++;
    }
    if(c2==0){
        if(c3>=c1-1){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    else{
        if(c3>=c1){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 640
import math
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

get_ints = lambda: [int(st) for st in input().split()]
N=int(input())
inarr=get_ints()

sorted_in = sorted(inarr)
# print(sorted_in)
comb = N*(N+1) // 2

def binsearch(lft, rgt):
    half = (lft + rgt) // 2
    # print("investigate: lft {} rgt {} half {} value {}".format(lft, rgt, half, sorted_in[half]))
    if lft >= half:
        return half
    summed = 0
    res = 0

    bit = Bit(2*N+1)
    bit.add(N, 1)
    for i, x in enumerate(inarr):
        value = 1 if x >= sorted_in[half] else -1
        summed += value
        # print("summed: {}, bit: {}".format(summed, bit.sum(N + summed)))
        count = bit.sum(N + summed)
        bit.add(N + summed, 1)
        res += count

    # print("num {} cnt {} judge {}".format(sorted_in[half], res, math.ceil(comb/2)))
    if res >= math.ceil(comb/2):
        return binsearch(half, rgt)
    else:
        return binsearch(lft, half)

# print(sorted_in)
res = binsearch(0, N)
# print(res, sorted_in[res])
print(sorted_in[res])


Measured memory_bytes: 86372
#include<stdio.h>
int main(){
  	int a[6],i;
  	for(i=1;i<=5;i++){
      scanf("%d",&a[i]);
    }
  for(i=1;i<=5;i++)
    if(a[i]==0){
      printf("%d",i);
  		break;
    }
  return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    auto dist = [&](int i, int j) {
        double dx = x[i] - x[j];
        double dy = y[i] - y[j];
        return sqrt(dx * dx + dy * dy);
    };
    vector<int> p(n);
    rep(i, n) p[i] = i;
    double len = 0;
    int cnt = 0;
    do{
        rep(i, n - 1) {
            len += dist(p[i], p[i + 1]);
        }
        cnt++;
    } while(next_permutation(p.begin(), p.end()));
    double ans = len / cnt;
    cout << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
char c[200];
int main(){
	int n;
	scanf("%d%s",&n,c);
	int len=strlen(c);
	if(len<=n)printf("%s",c);else{
		c[n]='\0';
		printf("%s...\n",c);
	}
}

Measured memory_bytes: 1724
a,b,c,d,e,f=map(lambda x: int(x), input().split())

dic_w={}
i=0
while True:
    if (a*i*100)>f:
        break
    j=0
    while True:
        w=(a*i+b*j)*100
        if w==0:
            j+=1
            continue
        if w>f:
            break
        else:
            dic_w[w]=dic_w.get(w,0)+1
        j+=1
    i+=1
list_w=list(dic_w.keys())
list_w.sort()

dic_s={}
max_s=int(e*f/(100+e)+1)
i=0
while True:
    if c*i>max_s:
        break
    j=0
    while True:
        s=c*i+d*j
        if s>max_s:
            break
        else:
            dic_s[s]=dic_s.get(s,0)+1
        j+=1
    i+=1
list_s=list(dic_s.keys())
list_s.sort()

max_per=0
flag=False
ans_w=0
ans_s=0
for w in list_w:
    if flag==True:
        break
    for s in list_s:
        if s/(w/100)==e and s+w<=f:
            ans_w=w
            ans_s=s
            flag=True
            break
        if s/(w/100)>e:
            break
        if 100*s/(s+w)>=max_per and s+w<=f:
            ans_w=w
            ans_s=s
            max_per=100*s/(s+w)
print('{} {}'.format(ans_w+ans_s,ans_s))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const int MOD = 1e9+7;
 
int main() {
	int A,B,C,D;
  	cin >> A >> B >> C>> D;
  	vi time(101);
  	for(int i = A; i<=B ;i++) time[i]++;
  	for(int i = C; i<=D ;i++) time[i]++;
  	int ans = 0;
  	rep(i,101){
    	if(time[i] == 2) ans++;
    }
  	if(ans != 0){
  		cout << ans-1 << endl;
    }
  	else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
   
  
   
int main(){
   
    int n; 
    int r[1000],w[1000];
    int sum_r=0,sum_w=0,idx=0;
	
    while(scanf("%d",&n),n){
         
        sum_r=sum_w=idx=0;
        for(int i=0;i<n;i++){
            scanf("%d %d",&r[i],&w[i]);
            sum_r+=r[i];
            sum_w+=w[i];
            if(r[idx]<r[i]) idx=i;
        }
  
        int r0=r[idx],r=sum_r-r0;
        w[idx]=0;
 
        if(r0 <= r){
            cout<<sum_r+sum_w<<endl;
        }else{
  
            int res=2*r0;
            //vector<vector<bool> > dp(1001,vector<bool>(1000,false));
  
			bool cur[1001]={};
            cur[0]=true;
            for(int i=0;i<n;i++){
				bool next[1001]={};
                for(int j=0;j<=r0-r;j++){
                    if(cur[j]){
                        next[j]=true; 
                        if(j+w[i]<=r0-r)
                            next[j+w[i]]=true; 
                    }
                }
				swap(cur,next);
            }
  
            int opt=r0-r;
            while(!cur[opt]) opt--;
  
            res+=sum_w-opt;
            printf("%d\n",res);
  
  
  
        }
          
          
    }
}

Measured memory_bytes: 1248
N = input()

def r(s):
    me = all(('3' in s, '5' in s, '7' in s))
    if len(s) < len(N):
        return r(s+'3') + r(s+'5') + r(s+'7') + me
    elif s<=N:
        return me
    else:
        return 0

print(r(''))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int a,b,c,g=1,h=1,o,x=1;
int tab[1006][1006];
int tabi[1000006];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>a>>b;

    for(int i=1; i<=a; i++)
    {
        for(int j=1; j<=b; j++)
        {
            cin>>tab[i][j];
        }
    }

    for(int i=1; i<=a; i++)
    {
        for(int j=1; j<=b; j++)
        {
            if(tab[i][j]%2!=0)
            {
                if(j==b && i+1<=a)
                {
                    tab[i+1][j]++;
                    tabi[x]=i;
                    tabi[x+1]=j;
                    tabi[x+2]=i+1;
                    tabi[x+3]=j;
                    x+=4;
                }
                else if(j<b)
                {
                    tab[i][j+1]++;
                    tabi[x]=i;
                    tabi[x+1]=j;
                    tabi[x+2]=i;
                    tabi[x+3]=j+1;
                    x+=4;
                }
            }
        }
    }
    x/=4;
    cout<<x<<endl;
    for(int i=1; i<=x*4; i++)
    {
        cout<<tabi[i];
        if(i%4!=0) cout<<" ";
        else cout<<endl;
    }
}




Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define befv(V) ((V)[(sz(V)-2)])
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MAXN = 100005;

ll dp[MAXN][2];

int A[MAXN], B[MAXN], C[MAXN];

int N;

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

	cin >> N;
	for(int i = 1; i <= N; i++) {
		cin >> A[i];
		int j = 0; for(; (1<<j) < A[i]; j++);
		B[i] = j;
		C[i] = (1<<j) == A[i] ? j : j-1;
	}

	dp[1][0] = dp[1][1] = B[1];
	for(int i = 2; i <= N; i++) {
		dp[i][0] = min(dp[i-1][0] - min(C[i-1], B[i]), dp[i-1][1] - min(B[i-1], B[i])) + B[i];
		dp[i][1] = min(dp[i-1][0] - min(C[i-1], C[i]), dp[i-1][1] - min(B[i-1], C[i])) + B[i];
	}

	cout << min(dp[N][0], dp[N][1]) << endl;
	return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.setf(ios::fixed);
	cout.precision(20);

	ll a, b, c, n, m, ans = 0, x = 0;
	string s;
	cin >> n;
	if (n % 2 == 0) cout << n;
	else cout << n * 2 << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0426_VsCode1
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            if (a == "A")
            {
                Console.WriteLine("T");
            }
            else if (a == "T")
            {
                Console.WriteLine("A");
            }
            else if (a == "C")
            {
                Console.WriteLine("G");
            }
            else if (a == "G")
            {
                Console.WriteLine("C");
            }
            else
            {
                Console.WriteLine(a);
            }
            Console.Read();
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  ll H,W; cin >> H >> W;
  ll ans = 1e18;
  ll Sa,Sb,Sc;
  for ( ll h = 1; h < H; h++ ) {
     Sa = h*W;
     Sb = ((H-h)/2)*W;
     Sc = (H-((H-h)/2)-h)*W;
     ll Smax = max(max(Sa,Sb),Sc);
     ll Smin = min(min(Sa,Sb),Sc);       
    if ( Smax - Smin >= 0 && ans > Smax-Smin ) {
      ans = Smax-Smin;
    }
  }

  for ( ll h = 1; h < H; h++ ) {
     Sa = h*W;
     Sb = (H-h)*(W/2);
     Sc = (H-h)*(W-W/2);
     ll Smax = max(max(Sa,Sb),Sc);
     ll Smin = min(min(Sa,Sb),Sc);  
     if ( Smax - Smin >= 0 && ans > Smax-Smin ) {
       ans = Smax-Smin;
     }
  }
  swap(H,W);

 for ( ll h = 1; h < H; h++ ) {
     Sa = h*W;
     Sb = ((H-h)/2)*W;
     Sc = (H-((H-h)/2)-h)*W;
     ll Smax = max(max(Sa,Sb),Sc);
     ll Smin = min(min(Sa,Sb),Sc);       
    if ( Smax - Smin >= 0 && ans > Smax-Smin ) {
      ans = Smax-Smin;
    }
  }

  for ( ll h = 1; h < H; h++ ) {
     Sa = h*W;
     Sb = (H-h)*(W/2);
     Sc = (H-h)*(W-W/2);
     ll Smax = max(max(Sa,Sb),Sc);
     ll Smin = min(min(Sa,Sb),Sc);  
     if ( Smax - Smin >= 0 && ans > Smax-Smin ) {
       ans = Smax-Smin;
     }
  }


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


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

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	for (int i = 0; i < 2 * N; i += 2) {
		if (S[i] == 'B') S[i] = 'W';
		else S[i] = 'B';
	}
	ll ans = 1;
	int L = 0;
	for (int i = 0; i < 2 * N; i++) {
		if (S[i] == 'W') {
			L++;
		}
		else {
			if (L == 0) {
				cout << 0 << endl;
				return 0;
			}
			(ans *= L) %= MOD;
			L--;
		}
	}
	if (L > 0) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i <= N; i++) (ans *= i) %= MOD;
	cout << ans << endl;
}

Measured memory_bytes: 640
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int x;
	std::vector<int> lens;
	for (int i = 0; i < 3; ++i) {
		std::cin >> x;
		lens.push_back(x);
	}
	std::sort(lens.begin(), lens.end());
	if (lens == std::vector<int>{5, 5, 7})
		std::cout << "YES\n";
	else
		std::cout << "NO\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int N, K;
int P[5500];
int C[5500];
vector<vector<ll>> cycle;

ll f(vector<ll>& v) {
	ll s = 0;
	vector<ll> tmp = v;
	for (int i : v) tmp.push_back(i);
	vector<ll> psum(tmp.size() + 1);
	for (int i = 0; i < tmp.size(); i++)
		psum[i + 1] = psum[i] + C[tmp[i]];

	ll ret = -2e18;
	for (int i = 0; i < v.size(); i++)
		for (int j = i; j < i + v.size(); j++) {
			int len = j - i + 1;
			if (len > K) continue;
			ret = max(ret, psum[j + 1] - psum[i] + (K - len) / (ll)v.size() * max(0LL, psum[v.size()]));
		}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> P[i];
	for (int i = 0; i < N; i++) cin >> C[i];

	bool visited[5500] = { 0 };
	for (int i = 0; i < N; i++) {
		vector<ll> tmp;
		int pos = i + 1;
		if (!visited[pos]) {
			tmp.push_back(pos - 1);
			visited[pos] = 1;
			while (true) {
				pos = P[pos - 1];
				if (visited[pos]) break;
				visited[pos] = 1;
				tmp.push_back(pos - 1);
			}
			cycle.push_back(tmp);
			tmp.clear();
		}
	}

	ll ans = -2e18;
	for (auto tmp : cycle) {
		ans = max(ans, f(tmp));
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3816
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n, t; cin >> n >> t;
    set<pii> rec;
    rec.insert(pii(-1, -1));
    rec.insert(pii((int)1e15, (int)1e15));
    rep(i,0,n) {
        int a; cin >> a;
        auto it1 = rec.upper_bound(pii(a, -1));
        it1--;
        auto it2 = rec.upper_bound(pii(a, -1));
        pii id1 = *it1, id2 = *it2;
        
        pii temp = pii((int)1e15, -1);
        if(id1.second > a) {
            rec.erase(id1);
            temp = pii(min(id1.first, temp.first), max(a+t, temp.second));
        }
        if(id2.first < a+t) {
            rec.erase(id2);
            temp = pii(min(a, temp.first), max(id2.second, temp.second));
        }
        temp = pii(min(temp.first, a), max(temp.second, a+t));
        rec.insert(temp);
    }
    int ans = 0;
    for(auto elem : rec) {
        ans += (elem.second - elem.first);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
#!/usr/bin/env python3

from collections import Counter

n = int(input())
v = list(map(int, input().split()))


v_odd = []
v_even = []
for i in range(n):
    if i % 2 == 0:
        v_even.append(v[i])
    else:
        v_odd.append(v[i])

c_even = Counter(v_even).most_common()
c_odd = Counter(v_odd).most_common()

# print(c_even)
# print(c_odd)

if c_even[0][0] == c_odd[0][0]:
    if len(c_even) == 1:
        c_odd = c_odd[1:]
    elif len(c_odd) == 1:
        c_even = c_even[1:]
    else:
        if c_even[1][1] >= c_odd[1][1]:
            c_even = c_even[1:]
        else:
            c_odd = c_odd[1:]

if len(c_even) == 0:
    c_even.append((-1, 0))
if len(c_odd) == 0:
    c_odd.append((-1, 0))

diff_even = n//2-c_even[0][1]
diff_odd = n//2-c_odd[0][1]

print(diff_even+diff_odd)


Measured memory_bytes: 25908
#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(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);
  sort(a.begin(), a.end());
  int an = a.back();
  int ar = a.front();
  int mnd = abs(ar-an/2);
  rep(i, n-1){
    int ad = abs(a.at(i)-an/2);
    if(ad <= mnd){
      mnd = ad;
      ar = a.at(i);
    }
  }
  cout << an << " " << ar << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;
const int maxn = 100;
char in[maxn];
int main(){
    scanf("%s",in);
    int i,len = strlen(in);
    for(i=0;i<len-8;i++){
        printf("%c",in[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string A,B,C;
    cin>>A>>B>>C;
    if(A[A.size()-1]==B[0] && B[B.size()-1]==C[0]){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
    return 0;
}


Measured memory_bytes: 256
//By Don4ick
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qwer1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = (int)105;

using namespace std;

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	int n;
	scanf("%d", &n);
	vector < int > a(n + 1), b(n + 1);
	int sumA = 0, sumB = 0;
	forn(i, n)
	{
		scanf("%d", &a[i]);
	}
	forn(i, n)
	{
		scanf("%d", &b[i]);
		sumB += b[i];
	}
	int ans = 0;
	forn(i, n)
	{
		sumA += a[i];
		ans = max(ans, sumA + sumB);
		sumB -= b[i];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#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()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;

long long gcd(long long a, long long b) {
    return b ? gcd(b, a % b) : a;
}

long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b;
}

int main() {
    cin >> n;

    ll x = 0;
    REP(i, n) {
        int a; cin >> a;
        x += a-1;
    }
    cout << x << '\n';

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
res_max = 10 ** 18
res = 1
for i in A:
  if i == 0:
    print("0")
    exit()
for i in A:
  res *= i
  if res > res_max:
    print("-1")
    exit()
print(res)


Measured memory_bytes: 88144
mod=10**9+7

N,M=map(int,input().split())
L=-1;R=-1
S=input()
ope=[]
for i in range(M):
    l,r=map(int,input().split())
    l-=1;r-=1
    if L<=l and r<=R:
        continue
    else:
        L,R=l,r
        ope.append((l,r))

M=len(ope)
data=[-1]*N
for i in range(M):
    l,r=ope[i]
    for j in range(l,r+1):
        data[j]=i

dp=[[0 for i in range(N+1)] for j in range(N+1)]

for j in range(N+1):
    dp[-1][j]=1

for i in range(N-1,-1,-1):
    id=data[i]
    if id!=-1:
        l,r=ope[id]
        temp1=sum(int(S[k]) for k in range(r+1))
        temp0=r+1-temp1
        for j in range(temp1+1):
            np1=temp1-j
            np0=temp0-(i-j)
            if np1==0:
                if np0>0:
                    dp[i][j]=dp[i+1][j]
            else:
                if np0>0:
                    dp[i][j]=(dp[i+1][j+1]+dp[i+1][j])%mod
                elif np0==0:
                    dp[i][j]=dp[i+1][j+1]
    else:
        if S[i]=="1":
            for j in range(N):
                dp[i][j]=dp[i+1][j+1]
        else:
            for j in range(N+1):
                dp[i][j]=dp[i+1][j]

print(dp[0][0])

Measured memory_bytes: 154652
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors


def solve():
    N = int(rl())
    
    divs = make_divisors(N)
    ans = 0
    for div in divs[1:]:
        m = div - 1
        if N // m == N % m:
            ans += m
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3268
//A_reward_for_a_Carpenter.cc

#include <iostream>
#include <cstdio>
#define Inf 1001001001
using namespace std;

int main()
{
    int n,m,s,g,V,P,i,j,k,last;
    int K[32][32];
    scanf("%d",&n);
    scanf("%d",&m);
    //cin >> n >> m;
    int a[110],b[110],c[110],d[110];
    for(i=1;i<32;i++)
        for(j=1;j<=32;j++)
            K[i][j]=Inf;
    for(i=0;i<m;i++)
    {
        scanf("%d,%d,%d,%d",&a[i],&b[i],&c[i],&d[i]);
        //cin >> a[i] >> b[i] >> c[i] >> d[i];
        K[a[i]][b[i]]=c[i];
        K[b[i]][a[i]]=d[i];
    }
    //cin >> s >> g >> V >> P;
    scanf("%d,%d,%d,%d",&s,&g,&V,&P);
    for(k=1;k<=n;k++)
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++)
            {
                if(K[i][j] > K[i][k] + K[k][j])
                    K[i][j] = K[i][k] + K[k][j];
            }
    last = V - P - K[s][g] - K[g][s];
    cout << last << endl;
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	string s;
	while (s.length() != n)  s += '#';
	//cout << "s is: " << s << "\n";
	while (m--) {
		int x;
		char y;
		cin >> x >> y;
		if (s[x - 1] == '#')
			s[x - 1] = y;
		else {
			if (s[x - 1] == y) continue;
			else {
				cout << "-1";
				return 0;
			}
		}
	}
	if (n == 1) {
		if (s[0] == '#')
			cout << "0";
		else
			cout << s;
	}
	else {
		if (s[0] == '0')
			cout << "-1";
		else {
			for (int i = 0; i < n; ++i) {
				if (s[i] == '#') {
					if (i == 0) cout << "1";
					else cout << "0";
				}
				else {
					cout << s[i];
				}
			}
		}

	}
}
		


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++)

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans;
    //1往復目
    rep(i, (ty-sy)) ans.push_back('U');
    rep(i, (tx-sx)) ans.push_back('R');
    rep(i, (ty-sy)) ans.push_back('D');
    rep(i, (tx-sx)) ans.push_back('L');

    //2往復目
    ans.push_back('L');
    rep(i, (ty-sy+1)) ans.push_back('U');
    rep(i, (tx-sx+1)) ans.push_back('R');
    ans.push_back('D');
    ans.push_back('R');
    rep(i, (ty-sy+1)) ans.push_back('D');
    rep(i, (tx-sx+1)) ans.push_back('L');
    ans.push_back('U');
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    int n; cin >> n;
    int k; cin >> k;
    REP(i, (1 << n)){
        stringstream ss;
        ss << i << ":";
        int ii = i, bit = 0, cnt = 0;
        while(ii){
            if(ii % 2){
                ss << " " << bit;
                ++cnt;
            }
            ++bit; ii /= 2;
        }
        ss << "\n";
        if(cnt == k) cout << ss.str();
    }
    return 0;
}



Measured memory_bytes: 3216
var n,i:integer;
begin 
  read(n);
  if (n mod 7=0) or (n mod 4=0) then begin write('Yes');exit;end;
  for i:=1 to n div 7 do 
    if (n-i*7) mod 4=0 then 
    begin 
      write('Yes');
      exit;
    end;
  write('No');
end.

Measured memory_bytes: 128
N=input()
OP=[['+','+','+'],['-','+','+'],['+','-','+'],['+','+','-'],
    ['+','-','-'],['-','+','-'],['-','-','+'],['-','-','-']]
for op in OP:
  str=N[0]+op[0]+N[1]+op[1]+N[2]+op[2]+N[3]
  ans = eval(str)
  if ans==7:
    print(str + "=7")
    break

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    s = input()
    a = []
    z = []
    for i, c in enumerate(s):
        if c == 'A':
            a.append(i)
        if c == 'Z':
            z.append(i)
    
    print(z[-1]-a[0]+1)


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()




"""

4
1 2
2 4
1 3
3
2 2 4
4 5 6

6
1 2
2 3
3 4
4 5
4 6
3
3 5 6
2 17 31 5 11

"""





Measured memory_bytes: 17332
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 100010

int main(){
	IOS;
	tihs;

	
	ll n,r;cin>>n>>r;
	if(n>=10)cout<<r;
	else cout<<r+100*(10-n);

	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>  //min, max, sort, unique, fill
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

int main() {
  ll n, tmp;
  cin >> n;
  VI a(n, 0);

  REP(i, n) cin >> a[i];

  sort(a.begin(), a.end());
  ll med = a[n - 1] / 2;
  auto result = find_if(a.begin(), a.end(), [med](int x) { return x > med; });
  cout << a[n - 1] << " ";

  if (abs(*result - med) <= abs(*(result - 1) - med) && result != a.end() - 1)
    cout << *result << endl;
  else
    cout << *(result - 1) << endl;

  return 0;
}


Measured memory_bytes: 1024
#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()
{
  int x; cin >> x;
  int ans = 1;
  for(int b = 2; b <= sqrt(x); ++b) {
    for(int p = 2; (int)pow(b, p) <= x; ++p) chmax(ans, (int)pow(b, p));
  }
  cout << ans << endl;
}


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

const int mod = 998244353;
int n, f[2][3][3][2], nw = 1, pst = 0;
char s[2000010];

int main() {
	scanf("%s", s + 1); n = strlen(s + 1);
	for (int i = 0; i < 3; i++)f[nw][i][i][0] = 1;
	for (int t = 2; t <= n; t++) {
		swap(nw, pst);
		memset(f[nw], 0, sizeof(f[nw]));
		for (int i = 0; i < 3; i++)for (int j = 0; j < 3; j++)for (int k = 0; k < 2; k++) {
			for (int cur = 0; cur < 3; cur++) {
				(f[nw][(i + cur) % 3][cur][(j == cur) | k] += f[pst][i][j][k]) %= 998244353;
			}
		}
	}
	int tot = 0, ans = 1, flag = 0;
	for (int i = 1; i <= n; i++) {
		tot += s[i] - 'a'; tot %= 3;
		if (i > 1 && s[i] != s[i - 1])flag = 1;
		if (i > 1 && s[i] == s[i - 1])ans = 0;
	}
	if (flag == 0) { puts("1"); return 0; }
	if (n == 2) { puts("2"); return 0; }
	if (n == 3) {
		if (s[1] == s[2])puts("6");
		else {
			if (s[2] == s[3])puts("6");
			else if (s[3] == s[1])puts("7");
			else puts("3");
		}
		return 0;
	}
	for (int i = 0; i < 3; i++)(ans += f[nw][tot][i][1]) %= 998244353;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384