akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
const int M=1e9+7;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
typedef long long ll;
typedef pair<int,int> PII;
char s[N];
int a[N+10]; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	cin>>s;
	ll ans=0;
	int len=strlen(s);
	for(int i=0;i<len;i++)
		a[i]=s[len-i-1]-'0';
	for(int i=0;i<len+15;i++){
		if(a[i]>=10){
			a[i]-=10;
			a[i+1]++;
		}
		if(a[i]>=6){
			ans+=(10-a[i]);
			a[i+1]++;
		}
		else if(a[i]==5){
			ans+=5;
			if(a[i+1]>=5)
				a[i+1]++;
		}
		else
			ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=1e9;
int main(void)
{
    bool easy=true;
    string s;
    cin >> s;
    for(int i=0;i<int(s.size());i++)
    {
        if(i%2==0)
        {
            if(s[i]=='L') easy=false;
        }
        else
        {
            if(s[i]=='R') easy=false;
        }
        
    }
    if(easy)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }
template<typename T = i64>
void OUT(T& x) { cout << x << endl; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

#ifdef _DEBUG
signed Main()
#else
signed main()
#endif
{
	auto N = IN();
	vector<double> v(N);
	for (auto& vec : v)
	{
		cin >> vec;
	}
	sort(v.begin(), v.end());

	REP(i, N - 1)
	{
		v[i + 1] = (v[i] + v[i + 1]) / 2;
	}

	cout << v[N-1] << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque
k = int(input())
d = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for i in range(k - 1):
    x = d.popleft()
    if x%10 > 0:
        d.append(x*10 + x%10 - 1)
    d.append(x*10 + x%10)
    if x%10 < 9:
        d.append(x*10 + x%10 + 1)

print(d.popleft())

Measured memory_bytes: 18992
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int f[21][1<<21];
int to[1<<21][2];
char S[1<<21];
int val[21][1<<20];
int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	to[1][0]=to[1][1]=0;
	for(int i=2;i<(1<<(n+1));i++)
	{
		to[i][i&1]=i>>1;
		to[i][(i&1)^1]=to[i>>1][(i&1)^1];
	}
	for(int i=0;i<=n;i++)
	{
		scanf("%s",S);
		for(int x=0;x<(1<<i);x++)
		{
			if(S[x]=='0')continue;
			int y=0;
			for(int j=0;j<i;j++)
				if(x&(1<<j))
					y|=1<<(i-j-1);
			y|=(1<<i);
			f[0][y]++;
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int s=0;s<(1<<i);s++)
			for(int t=1;t<(1<<(n-i+1));t++)
			{
				f[i+1][s|(to[t][0]<<(i+1))]+=f[i][s|(t<<i)];
				f[i+1][(s|(1<<i))|(to[t][1]<<(i+1))]+=f[i][s|(t<<i)];
			}
	}
	for(int i=0;i<=n;i++)
		for(int s=0;s<(1<<i);s++)
			for(int t=1;t<(1<<(n-i+1));t++)
				val[i][s]+=f[i][s|(t<<i)];
	for(int i=n;i>=0;i--)
	{
		int res=1e9;
		for(int s=0;s<(1<<i);s++)
		{
			if(val[i][s]<k)continue;
			int x=0;
			for(int j=0;j<i;j++)
				if(s&(1<<j))
					x|=1<<(i-j-1);
			res=min(res,x);
		}
		if(res>(1<<i))continue;
		for(int j=i-1;j>=0;j--)
			printf("%d",(res>>j)&1);
		printf("\n");
		return 0;
	}
}

Measured memory_bytes: 235904
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

public static partial class Program
{
    public static void Main()
    {
        var nt = CRL().ArrayInts();
        var n = nt[0];
        var t = nt[1];
        var txis = CRL().ArrayInts();

        long ans = t;
        for (int i = 0; i < n - 1; i++)
        {
            ans += Math.Min(t, txis[i + 1] - txis[i]);
        }

        CWL(ans);
    }
}

public static partial class Program
{
    //テンプレここから
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static string RL() => ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static void WL(object obj) => WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);

    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    //テンプレここまで
}

Measured memory_bytes: 28384
def _calc_today_max(today, Ci, Sdi, last_day):
    today_total_bad_value = \
        sum([Ci[contest] * today + 1 - last_day[contest] for contest in range(26)])

    max_value = -999999999
    max_context = 0
    for contest in range(26):
        today_contest_value = Sdi[today][contest]
        today_bad_value = today_total_bad_value - Ci[contest]
        today_value = today_contest_value - today_bad_value
        if max_value < today_value:
            max_value = today_value
            max_context = contest
    return max_context


def _main(D, Ci, Sdi):
    last_day = [0] * 26
    for today in range(D):
        max_contest = _calc_today_max(today, Ci, Sdi, last_day)
        print(max_contest + 1)
        last_day[max_contest] = today + 1


def _execute():
    D = int(input())
    Ci = list(map(int, input().split()))
    Sdi = []
    for i in range(D):
        Sdi.append(list(map(int, input().split())))
    _main(D, Ci, Sdi)


if __name__ == "__main__":
    _execute()


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

int main(){
    int K,N;
    cin >> K >> N;
    vector<int> A(N+5);
    rep(i,N){
        cin >> A.at(i);
    }
    int max_distance = -1;
    rep(i,N){
        if(A.at(i) == A.at(N)){
                max_distance = max(max_distance, A.at(1) + K - A.at(N));
            }else{
                max_distance = max(max_distance, A.at(i+1)-A.at(i));
            }
    }
    int sum = 0;
    rep(i,N){
        if(A.at(i) == A.at(N)){
            sum = sum + A.at(1) + K - A.at(N);
        }else{
           sum = sum + (A.at(i+1)-A.at(i));
        }
    }
    cout << sum - max_distance << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int[] a = new int[n];
    int[][] x = new int[n][n];
    int[][] y = new int[n][n];
    
    for(int i=0;i<n;i++){//証人ごと
      a[i]=sc.nextInt();
      for(int j=0;j<a[i];j++){//証言ごと
        x[i][j]=sc.nextInt();
        y[i][j]=sc.nextInt();
      }
    }
    
    int map =0;
    int ans=0;
    /*
          for(int i2=0;i2<n;i2++){
            System.out.println(i2);
            for(int j2=0;j2<a[i2];j2++){
              System.out.println(x[i2][j2]+" "+y[i2][j2]);
            }
          }
    */
    
    for(;map<Math.pow(2,n);map++){//正直者,嘘つきのパターン
    //for(map=2;map<3;map++){
      
      Boolean[] honest = new Boolean[n];
      Boolean ok = true;//矛盾がないか
      int tempAns=0;//現パターンの正直者の人数
       
      for(int i=0;i<n;i++){
        if((map>>i)%2==1){
          honest[i] = true;
          tempAns++;
        }else honest[i] = false;
      }
      
      for(int i=0;i<n;i++){//証人ごと
        
        for(int j=0;j<a[i];j++){//証言ごと
          //Boolean temp =  honest[x[i][j]]==(y[i][j]==1);//test
          //System.out.println(honest[i] +" "+ i+" "+j+" " + temp);//test
          

          
          if(!honest[i])break;
          if(honest[x[i][j]-1]==(y[i][j]==1)){
          }else{
            ok = false;
            break;
          }
        }
        
        if(!ok)break;
      }
      
      //System.out.println(map + " " + ok);
      if(ok)ans = Math.max(ans,tempAns);
    }
    
    System.out.println(ans);
    
  }
}

Measured memory_bytes: 25016
#include<bits/stdc++.h>
using namespace std;
main()
{
    int a,b;
    while(scanf("%d %d",&a,&b)==2){
        if(a*b>=a+b&&a*b>=a-b){
            printf("%d\n",a*b);
        }
        else if(a+b>=a*b&&a+b>=a-b){
            printf("%d\n",a+b);
        }
        else
            printf("%d\n",a-b);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int h, w, target;
    cin >> h >> w >> target ;
    
    vector<vector<int>> tile(h, vector<int>(w));
    string s;
    vector<int> line(h), row(w);
    int sum = 0, treat;
    
    for(int i = 0; i < h; i++){
        cin >> s ;
        for(int j = 0; j < w; j++){
            if(s.at(j) == '#'){
                tile.at(i).at(j) = 1;
                line.at(i)++;
                row.at(j)++;
                sum++;
            } else {
                tile.at(i).at(j) = 0;
            }
            //cout << tile.at(i).at(j) ;
        }
        //cout << endl;
    }
    
    /*
    for(int i = 0; i < h; i++){
        cout << line.at(i) << endl;
    }
    cout << endl;
    
    for(int j = 0; j < w; j++){
        cout << row.at(j) << endl;
    }
    cout << endl;
    */
    
    int tri, trk, hsum, ans = 0;
    set<int> lpaint;
    for(int i = 0; i < pow(2, h); i++){
        lpaint.clear();
        tri = i;
        treat = sum;
        for(int j = 0; tri != 0; j++){
            if(tri % 2 != 0){
                treat -= line.at(j);
                lpaint.insert(j);
            }
            tri /= 2;
        }
        //cout << treat << endl;
        for(int k = 0; k < pow(2, w); k++){
            trk = k;
            hsum = treat;
            for(int l = 0; trk != 0; l++){
                if(trk % 2 != 0){
                    hsum -= row.at(l);
                    for(int m = 0; m < h; m++){
                        if(lpaint.count(m) == 1){
                            if(tile.at(m).at(l) == 1){
                                hsum++;
                            }
                        }
                    }
                }
                trk /= 2;
            }
            //cout << hsum << endl;
            if(hsum == target){
                ans++;
            }
        }
    }
    
    cout << ans << endl;

}


Measured memory_bytes: 4036
x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}


int main() {
    int N; cin >> N;
    vector<ll> A(N); REP(i, N) cin >> A[i];
    map<ll, ll> tmp;

    REP(i, N) {
        if(tmp[A[i]] == 0) {
            tmp[A[i]]++;
        } else {
            tmp[A[i]]--;
        }
    }

    ll cnt = 0;
    sort(all(A));
    for(int i = 0; i < N; ++i) {
        if(i == 0) {
            if(tmp[A[i]] == 1) {
                cnt++;
            }
            continue;
        }

        if(A[i - 1] != A[i]) {
            if(tmp[A[i]] == 1) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
}

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

dub=[-1]*(n+1)
duble=[]

for i,aa in enumerate(a):
    if dub[aa]==-1:
        dub[aa]=i
    else:
        duble=[dub[aa],i]


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10**9+7 #割る数
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

#cmb(n, c, p)

duble.sort()
left=duble[0]
right=duble[1]
#print(left,middle,right)
for i in range(1,n+2):
    ans=cmb(n+1,i,p)-cmb(n+1-2-(right-1-left),i-1,p)
    print(ans%p)





Measured memory_bytes: 142148
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 998244353
 
using namespace std;


void solve(){
	int n; cin>>n;
	
	while(n){
		int x = n%10;
		if(x == 7){
			cout<<"Yes";
			return;
		}
		n = n/10;
	}
	cout<<"No";



}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//cout<<fixed<<setprecision(12);
	//memset(dp,-1,sizeof(dp));
	
	int t =1; 
	//cin>>t;

	//int x = t;


	while(t--){
		solve();
		//cout<<"\n";
	}




	return 0;

	}




Measured memory_bytes: 3660
N=int(input())
R=[0]*(N-1)
for i in range(1,N+1):
  for r in range (2,N+1):
    count=0
    while i%r==0:
      i=i/r
      count+=1
    R[r-2]+=count

count=1
for r in range(N-1):
  count=count*(R[r]+1)
print(count%(10**9+7))

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

int lengths[105];
bool allDifferent(int len1, int len2, int len3)
{
	return (len1 != len2) && (len2 != len3) && (len3 != len1);
}

bool canFormTriangle(int len1, int len2, int len3)
{
	int maxLen = max(max(len1, len2), len3);
	return len1 + len2 + len3 - maxLen > maxLen;
}

int main()
{
	int N;
	scanf("%d", &N);
	
	for(int i = 1; i <= N; i++)
		scanf("%d", &lengths[i]);
	
	int ans = 0;
	for(int i = 1; i <= N; i++)
	{
		for(int j = i + 1; j <= N; j++)
		{
			for(int k = j + 1; k <= N; k++)
			{
				if(allDifferent(lengths[i], lengths[j], lengths[k]) && canFormTriangle(lengths[i], lengths[j], lengths[k]))
					ans++;
			}
		}
	}
	
	printf("%d", ans);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define int long long
const int MOD=1e9+7;
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 55, maxsreq = 20005;

int n, m, s, u, v, a, b, c[maxn], d[maxn], mintime[maxn][maxsreq];
vector<pair<int, pii>> adj[maxn];

void dijkstra(int silverreq) 
{
    for(int i = 0; i < n; i++)
        for(int j = 0; j <= silverreq; j++)
            mintime[i][j] = (int) 4e18;

    mintime[0][s] = 0;
    priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> pq;
    pq.push({0, {0, s}});
    while (!pq.empty()) 
    {
        int t = pq.top().first;
        pii state = pq.top().second;
        pq.pop();
        if(t != mintime[state.first][state.second])
            continue;
        for(auto v : adj[state.first])
            if(state.second >= v.second.first && mintime[v.first][state.second - v.second.first] > t + v.second.second)
            {
                mintime[v.first][state.second - v.second.first] = t + v.second.second;
                pq.push({mintime[v.first][state.second - v.second.first], {v.first, state.second - v.second.first}});
            }
        for(int j = 1; state.second + c[state.first] * (j - 1) < silverreq; j++)
        {
            int newsum = state.second + c[state.first] * j;
            if(newsum > silverreq)
                newsum = silverreq;
            if(mintime[state.first][newsum] > t + j * d[state.first])
            {
                mintime[state.first][newsum] = t + j * d[state.first];
                pq.push({mintime[state.first][newsum], {state.first, newsum}});
            }
        }
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> s;
    int sumtripcosts = 0;
    for(int i = 0; i < m; i++)
    {
        cin >> u >> v >> a >> b;
        sumtripcosts += a;
        u--; v--;
        adj[u].push_back({v, {a, b}});
        adj[v].push_back({u, {a, b}});
    }
    for(int i = 0; i < n; i++)
        cin >> c[i] >> d[i];
    s = min(s, sumtripcosts);
    dijkstra(sumtripcosts);
    for(int i = 1; i < n; i++)
    {
        int curans = (int) 4e18;
        for(int j = 0; j <= sumtripcosts; j++)
            curans = min(curans, mintime[i][j]);
        cout << curans << "\n";
    }
    return 0;
}

Measured memory_bytes: 53556
n = int(input())
cards = list(map(int,input().split()))
cnt = 0
for i in range(n):
    minj = i
    for j in range(i,n):
        if cards[minj] > cards[j]:
            minj = j
    if i != minj:
        cnt += 1
    cards[i], cards[minj] = cards[minj], cards[i]


print(*cards)
print(cnt)



Measured memory_bytes: 5604
#include <iostream>
#include <set>
using namespace std;
int a,b;
set<string> ans;

bool check(int x,int y,string s){
  if(x==a&&y==b)return true;
  return false;
}

void dfs(int x,int y,string s){
  if(check(x,y,s)){
    ans.insert(s);
    return;
  }
  if(x==5&&y==5)return;
  if((x==5&&y<=3)||(x<=3&&y==5))return;
  if(x==6||y==6)return;
  dfs(x+1,y,s+'A');
  dfs(x,y+1,s+'B');
}

int main(){
  cin>>a>>b;
  dfs(0,0,"");
  set<string>::iterator ite=ans.begin();
  while(ite!=ans.end()){
    cout<<(*ite)<<endl;
    ite++;
  }
  return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"


int32_t main()
{
	IOS;
	int a,b;
	cin>>a>>b;
	int ans=max(a+b,a-b);
	cout<<max(ans,a*b);

 	return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include <math.h>
#include<iostream>
using namespace std;
typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         ld;

#define sf                  scanf
#define pf                  printf
#define srev                reverse(s.begin(),s.end())
#define sortstr             sort(s.begin(), s.end());
#define gtl(x)              getline(cin, (x))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define PI                  acos(-1)
#define Precision(a) cout << fixed << setprecision(a)
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
int main()
{
    FasterIO
    ll n, x;
    cin >> n;
    x=n/500;
    x=x*1000;
    n=n%500;
    x+=(n/5*5);
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()

if S[0] == S[1] and S[1] == S[2] and S[2] == S[3]:
    print('No')
elif S[0] == S[1] and S[2] == S[3]:
    print('Yes')
elif S[0] == S[2] and S[1] == S[3]:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2]:
    print('Yes')
else: 
    print('No')

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

using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define v vector
#define vi vector<int>
#define vi2 vector<vi>
#define vl vector<long long>
#define vl2 vector<vl>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

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

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll b[n-1];

    for(ll i=0; i<n-1; i++) {
        cin>>b[i];
    }
    ll ans=0;
    ll tmp=0;
//    ll a[n];

//    a[0]=b[0];
    ans = b[0];
    for(ll i=0; i<n-1; i++) {
        tmp = min(b[i],b[i+1]);
        ans = ans + tmp;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int P, Q, R;
	cin >> P >> Q >> R;
	cout << min(P + Q, min(P + R, Q + R)) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		int R = sc.nextInt();
		int d = sc.nextInt();
		int ans = 0;
		for(int i = L; i <= R; i++){
			if(i % d == 0){
				ans ++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 35644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  
  int a, b, c;
  a = N / 100;
  b = (N % 100) / 10;
  c = (N % 100) % 10;
  
  bool ans = false;
  if(a == 7){
    ans = true;
  }
  
  if(b == 7){
    ans = true;
  }
  
  if(c == 7){
    ans = true;
  }
  
  if(ans){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
      
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main(){
int i,n,a[110];
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
 	if(a[i]%2==0){
 		if(a[i]%3!=0 && a[i]%5!=0){
  			 cout << "DENIED" << endl;
 			break;
 		}
	 }
  	if(i==n-1){
  		cout << "APPROVED" << endl;
 	 }  
 }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
using namespace std;
int pi[200010];
int main()
{
    string s;
    cin>>s;
    int i;
    long long ans=0;
    for (i=0;i<s.length();i++) pi[s[i]-'a']++;
    for (i=0;i<26;i++) ans-=pi[i]*1ll*(pi[i]+1)/2;
    ans+=s.length()*1ll*(s.length()+1)/2;
    printf("%lld\n",ans+1);
    return 0;
}


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

char y;
char x='a';
string A,B,C;

char dfs(char z){
  if(z=='a'){
    if(A.size()==0){return 'A';}
    else{
      y=A[0];
      A=A.substr(1,A.size()-1);
      return dfs(y);}
  }
  else if(z=='b'){
    if(B.size()==0){return 'B';}
    else{
      y=B[0];
      B=B.substr(1,B.size()-1);
      return dfs(y);}
  }
  else if(z=='c'){
    if(C.size()==0){return 'C';}
    else{
      y=C[0];
      C=C.substr(1,C.size()-1);
      return dfs(y);}
  }
}

int main() {
  cin >> A >> B >> C;
  cout << dfs(x) << endl;
}

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

#define M 1000000007

int main(){
  int n, m;
  
  cin >> n >> m;
  
  if(abs(n - m) > 1){
    cout << 0 << endl;
    return 0;
  }
  
  if(n == m){
    long long f = 1;
    
    for(int i = 1;i <= n;i++){
      f *= i;
      f %= M;
    }
    
    cout << (2 * f * f) % M << endl;
  }else{
    long long f1= 1, f2 = 1;
    
    for(int i = 1;i <= min(n, m);i++){
      f1 *= i; f2 *= i;
      f1 %= M; f2 %= M;
    }
    f2 *= max(n, m);
    f2 %= M;
    
    cout << (f1 * f2) % M << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
//絶対値を取る -> そのままと-1倍したものから大きいものを取る
//それぞれ(x,y,z)のどれを負にするかについて全探索してやればいい
int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<ll> > cake(N,vector<ll>(3));
  rep(i,N) rep(j,3) cin >> cake[i][j];
  ll res = 0;
  rep(bit,(1 << 3)) {
    vector<ll> vec;
    rep(i,N) {
      ll S = 0;
      rep(j,3) {
        if (bit & (1 << j)) S += cake[i][j];
        else S -= cake[i][j];
      }
      vec.push_back(S);
    }
    sort(vec.begin(),vec.end(),greater<ll>());
    ll sum = 0;
    rep(i,M) sum += vec[i];

    res = max(res,sum);
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second

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


  int R;
  cin >> R;
  R *= 2;

  cout << ((long double)M_PI * R);
}


Measured memory_bytes: 3800
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;


int main(){
	int n, t, e;
	cin>>n>>t>>e;
	int a;
	rep(i, n){
		cin>>a;
		for(int j = a; j <= t + e; j += a){
			if(j >= t - e && j <= t + e) {
				cout<<i + 1<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int dp[3001][3001];
int fun(string s1,string s2,int n,int m)
{
	if(n==0 || m==0)
		return dp[n][m]=0;
	else if(dp[n][m]!=-1)
		return dp[n][m];
	else if(s1[n-1]==s2[m-1])
		return dp[n][m]=1+fun(s1,s2,n-1,m-1);
	else
		return dp[n][m]=max(fun(s1,s2,n-1,m),fun(s1,s2,n,m-1));
}
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int i,j,n=s1.length(),m=s2.length();
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
			dp[i][j]=-1;
	}
//	fun(s1,s2,n,m);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(s1[i-1]==s2[j-1])
				dp[i][j]=1+dp[i-1][j-1];
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	i=n,j=m;
	string ans;
	while(i>0 && j>0)
	{
		if(s1[i-1]==s2[j-1])
		{
			ans.push_back(s1[i-1]);
			i--;
			j--;
		}
		else
		{
			if(dp[i-1][j]>dp[i][j-1])
				i--;
			else
				j--;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}


Measured memory_bytes: 35456
N,M,K=list(map(int,input().split()))
A_list = list(map(int,input().split()))
B_list = list(map(int,input().split()))

a = [0]
b = [0]
for i in range(N):
    a.append(a[i]+A_list[i])
for i in range(M):
    b.append(b[i]+B_list[i])

j = M
while b[j] > K:
    j -= 1
max = j
i = 0
while a[i]<=K :
    while b[j]> K-a[i]:
        j -= 1
    if max <= i+j:
        max = i+j
    if i < N:
        i += 1
    else:
        break

print(max)

Measured memory_bytes: 47340
N = gets.to_i
as = gets.split.map(&:to_i)
table = Hash.new { 0 }
as.each do |a|
  table[a] += 1
end
ans = 0
table.each do |a, c|
  ans += if a > c
    c
  else
    c - a
  end
end
puts ans

Measured memory_bytes: 14468
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n,k;
    while(scanf("%d%d",&n,&k)==2)
    {
        int c;
        int sum=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&c);
            sum+=min(c,k-c);
        }
        printf("%d\n",sum*2);
    }
    return 0;
}


Measured memory_bytes: 256
program  ec12;
var 
	n,m,i,j:longint;
	ans:int64;
	a:array[1..100001] of longint;
	vis:array[0..100001] of longint;
begin 
	fillchar(vis,sizeof(vis),0);
	readln(n);
	for i:=1 to n do 
	begin 
		read(a[i]);
		if a[i]>=n then 
		begin 
			writeln(0);
			halt;
		end;
		inc(vis[a[i]]);
		if (a[i]=0) and (vis[0]>=2) then 
		begin 
			writeln(0);
			halt;
		end;
	end; 
	ans:=1;
	for i:=0 to n-1 do 
	begin 
		if vis[i]=2 then 
		ans:=(ans*2) mod 1000000007
		else
		begin 
			if (vis[i]=1) and (i>0) then 
			begin 
				writeln(0);
				halt;
			end;
		end;
	end;
	writeln(ans);
end. 

Measured memory_bytes: 896
from itertools import accumulate
import sys
n,m,k=map(int,input().split())
a=[0]+list(accumulate(list(map(int,input().split()))))
b=[0]+list(accumulate(list(map(int,input().split()))))

tmp=m
ans=0
for i in range(n+1):
    while a[i]+b[tmp]>k:
        if tmp>0:tmp-=1
        else:
            print(ans)
            sys.exit()
    ans=max(ans,i+tmp)

print(ans)

Measured memory_bytes: 125904
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    string f, l;
    for (int i = 0; i < N / 2; ++i)
    {
        f += S[i];
    }
    for (int i = N / 2; i < N; ++i)
    {
        l += S[i];
    }
    cout << (f == l ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
  //INPUT
  llint N;
  cin >> N;
  vector<llint> A(N);

  vector<llint> B(N);
  vector<llint> C(N-1);
  rep(i,0,N) {
    cin >> A[i];
  }
  rep(i,0,N) {
    cin >> B[i];
  }
  rep(i,0,N-1) {
    cin >> C[i];
  }

  //SOLVE
  llint ans;
  llint buf_mae=-INF;
  ans = 0;
  rep(i,0,N) {
    ans+=B[i];
  }
  rep(i,0,N-1) {
    if (A[i]+1 == A[i+1]) {
      ans+=C[A[i]-1];
      // cout << C[A[i]-1];
    }
    // buf_mae = A[i];
  }

  //OUTPUT
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
    int n;
    while (scanf("%d",&n)) {
        if (!n) break;
        ll sum=1;
        if (n==1) {
            puts("deficient number");
            continue;
        }
        for (int i=2; i*i<=n; i++) {
            if (n%i==0) {
                if (i!=n/i) sum+=n/i+i;
                else sum+=i;
            }
        }
        if (sum>n) puts("abundant number");
        else if (sum<n) puts("deficient number");
        else puts("perfect number");
    }
}

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

using namespace std;

typedef long long ll;
const int N = (int)2e3+9;
ll d[N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, x, y;
    cin >> n >> x >> y;
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            ll D;
            if(x==i&&y==j)
                D = 1;
            else if(i<x&&j>y)
                D = (j-i)-(y-x-1);
            else if(j>=x&&j<=y&&i<=x)
                D = min(j-i, (y-j)+(x-i+1));
            else if(i>=x&&i<=y&&j>=y)
                D = min(j-i, (i-x)+(j-y+1));
            else if(x<=i&&x<=j&&y>=i&&y>=j)
                D = min(j-i, (i-x)+(y-j)+1);
            else
                D = (j-i);
            d[D]++;
        }
    }
    for(int i=1; i<n; i++)
        cout << d[i] << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import re
import queue
import collections
import math
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
	N = i_input()
	D = []
	for i in range(0,N):
		tmp1,tmp2 = i_map()
		if(tmp1 == tmp2):
			D.append(1)
		else:
			D.append(0)

	flag = False
	for i in range(0,N-2):
		if(D[i]==D[i+1]==D[i+2]==1):
			flag = True

	if(flag):
		print('Yes')
	else:
		print('No')

	return

if __name__ == '__main__':
	main()

Measured memory_bytes: 10708
#include <bits/stdc++.h>
using namespace std;
#define maxn 23000000
#define int long long
#define mod 1000000007
int digit[maxn], ans, S;

int read()
{
    int x = 0, k = 1;
    char c; c = getchar();
    while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * k;
}

int Qpow(int times)
{
    int x = 10, base = 1;
    for(; times; times >>= 1, x = x * x % mod)
        if(times & 1) base = base * x % mod;
    return base;
}

void Up(int &x, int y) { x = (x + y) % mod; }
signed main()
{
    S = read(); int lim = S / 8, now = 0;
    for(int i = 1; i < maxn; i ++) digit[i] = digit[i / 10] + 1;
    for(int i = 1, now = 0, tem = 0; i < 1e7; i ++)
    {
        while(tem < S) { tem += digit[now]; now ++; }
        if(tem == S) { ans += 1; if(ans >= mod) ans -= mod; } 
        tem -= digit[i];
    }
    for(int i = 1; i <= lim; i ++)
    {
        if(!(S % i)) 
        {
            int l = S / i, sum = Qpow(l - 1) * 9 % mod;
            Up(ans, (sum - i + 1 + mod) % mod);
        }
        else 
        { 
            int l = (S - S % i) / i;
            ans += 1; if(ans >= mod) ans -= mod; 
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 179968
package main

import "fmt"

func main() {
	a := make([]int, 3)
	c := make([][]int, 3)
	for i := range c {
		c[i] = make([]int, 3)
		fmt.Scan(&c[i][0], &c[i][1], &c[i][2])
	}

	for a[0] = 0; a[0] <= 100; a[0]++ {
		for a[1] = 0; a[1] <= 100; a[1]++ {
			for a[2] = 0; a[2] <= 100; a[2]++ {
				if c[0][0]-a[0] == c[0][1]-a[1] && c[0][0]-a[0] == c[0][2]-a[2] &&
					c[1][0]-a[0] == c[1][1]-a[1] && c[1][0]-a[0] == c[1][2]-a[2] &&
					c[2][0]-a[0] == c[2][1]-a[1] && c[2][0]-a[0] == c[2][2]-a[2] {
					fmt.Println("Yes")
					return
				}
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <stdio.h>
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    
    
    if(a>=b) {
        for(int i=0; i<a; i++){
            printf("%c", b+'0');
        }
    }
    else {
        for(int i=0; i<b; i++){
            printf("%c", a+'0');
        }
    }
    return 0;
}


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

int main(){
  int a[8];
  for(int i=0;i<8;i++) cin >> a[i];
  cout << max(a[0] + a[1] + a[2] + a[3],a[4] + a[5] + a[6] + a[7]) << endl;
}

Measured memory_bytes: 1160
#include<cctype>
#include<cstdio>

inline void read(int & x) {
	x = 0;
	bool w = 0;
	char c = ' ';
	while (!isdigit(c) && c != '-') c = getchar();
	if (c == '-') w = 1, c = getchar();
	while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
	if (w) x *= -1;
}

int n, sum;

int main() {
    for (int i = 0; i < 3; i++){
        read(n), sum += n;
        if (sum >= 22) {
            puts("bust");
            return 0;
        }
    }
    puts("win");
    return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;

int N, K, A[100005];
lint B[100005];

int main() {
	cin >> N >> K;
	for_(i,0,N) cin >> A[i] >> B[i];
	
	lint ans = 0;
	for_(i,0,N) if ((A[i] & (~K)) == 0) ans += B[i];
	
	for_(i,0,31) {
		if (K >> i & 1) {
			int L = (K ^ (1 << i)) | ((1 << i) - 1);
			lint sum = 0;
			for_(i,0,N) if ((A[i] & (~L)) == 0) sum += B[i];
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>

void call(int n){
  for(int i=1;i<=n;i++){
    int x=i;
    if(x%3==0){
      printf(" %d", i);
      continue;
    }
    do{
      if(x%10==3){
        printf(" %d",i);
        break;
      }
      x/=10;
    }while(x);
  }
  printf("\n");
}

int main(){
  int n;
  scanf("%d",&n);
  call(n);
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d[105][5],cur=0,ans=-1;
  cin>>n;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=2;j++) cin>>d[i][j];
  }
  for(int i=1;i<=n;i++){
    if(d[i][1]==d[i][2]) ans=max(ans,++cur);
    else cur=0;
  }
  if(ans>=3) cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int C[3][3];

bool check(int a1, int a2, int a3, int b1, int b2, int b3){

    const int a[]={a1, a2, a3};
    const int b[]={b1, b2, b3};
    for(int i = 0; i < 3; i++){
        if(!(a[i] >=0&&a[i]<=100)) return false;
        if(!(b[i] >=0&&b[i]<=100)) return false;
    }

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(!(C[i][j] == a[i] + b[j]))
                return false;
        }
    }
    return true;
}

int main(){

    for(int i = 0; i < 3; i++)
        for(int j = 0; j < 3; j++)
            cin >> C[i][j];

    for(int a1 = 0; a1 <= 100; a1++){
        for(int a2 = 0; a2 <= 100; a2++){
            for(int a3 = 0; a3 <= 100; a3++){
                int b1 = C[0][0] - a1;
                int b2 = C[1][1] - a2;
                int b3 = C[2][2] - a3;
                // check
                if(check(a1, a2, a3, b1, b2, b3)){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
k, x = map(int, input().split())

a = 2000001
n = 1000000

A = [str(i - n) for i in range(a)]

b_min = max(-n, x - k + 1) + n
b_max = min(n, x + k) + n

C = A[b_min : b_max]
C =" ".join(C)
print(C)


Measured memory_bytes: 129816
import numba
import numpy as np
N = int(input())
P = np.array([int(c)-1 for c in input().split()])

#from random import shuffle
#N = 500
#P = list(range(N*N))
#shuffle(P)
#P = np.array(P)

@numba.njit("void(i8,i8[:])")
def proc(N, P):
    ans = 0
    Removed = np.zeros((500, 500), dtype=np.int8)
    Mat = np.zeros((500, 500), dtype=np.int16)
    Dy, Dx = [1,0,-1,0], [0,1,0,-1]

    for y in range(N):
        for x in range(N):
            Mat[y, x] = min(y, N-1-y, x, N-1-x)
    #print(Mat)
    for i in range(N*N):
        p = P[i]
        y, x = divmod(p, N)
        ans += Mat[y,x]
        Removed[y,x] = 1
        st = [(y, x)]
        while st:
            vy, vx = st.pop()
            vr = Removed[vy,vx]
            val = Mat[vy,vx]
            #for dy, dx in zip(Dy, Dx):
            for j in range(4):
                uy, ux = vy + Dy[j], vx + Dx[j]
                if not (0<=uy<N and 0<=ux<N):
                    continue
                ur = Removed[uy,ux]
                if vr:
                    if Mat[uy,ux] >= val+1:
                        Mat[uy,ux] = val
                        st.append((uy, ux))
                else:
                    if Mat[uy,ux] >= val+2:
                        Mat[uy,ux] = val+1
                        st.append((uy, ux))
    # for m in Mat:
    #     print(m)
    print(ans)
proc(N, P)



Measured memory_bytes: 120520
/*input
1000000000
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	map<ll, ll> mp;
	auto pow5 = [&](ll x) {
		ll ret = x * x * x * x * x;
		mp[ret] = x;
		return ret;
	};
	ll X;
	cin >> X;
	vector<ll> arr;
	arr.emplace_back(0);
	for(ll i=1; ; i++) {
		ll cur = pow5(i);
		if(cur - arr.back() > 1e9) break;
		arr.emplace_back(cur);
	}
	for(auto a : arr) {
		for(auto b : arr) {
			if(abs(a - b) == X) {
				if(a > b)
					cout << mp[a] << " " << mp[b] << endl;
				else
					cout << mp[b] << " " << mp[a] << endl;
				return;
			}
			if(a + b == X) {
				if(a > b) 
					cout << mp[a] << " " << -mp[b] << endl;
				else
					cout << mp[b] << " " << -mp[a] << endl;
				return;
			}
		}
	}
}

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


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

ll N, A, B;
const int MOD = 1.0e9 + 7;

ll pow_mod(ll n, ll k, ll mod) {
    if (k == 0) return 1;
    else if (k % 2 == 1) {
        return pow_mod(n, k-1, mod) * n % mod;
    }
    else {
        ll tmp = pow_mod(n, k/2, mod);
        return tmp * tmp % mod;
    }
}

ll modinv(ll n, ll mod) {
    return pow_mod(n, mod - 2, mod);
}

ll COM(ll n, ll k) {
    ll tmp = 1;
    for (ll i = 1; i <= k; i++) {
        tmp = (tmp * (n - i+1)) % MOD;
        tmp = (tmp * modinv(i, MOD)) % MOD;
    } 
    return tmp;
}

ll neg_mod(ll n, ll mod)  {
    ll res = n % mod;
    if (res < 0) res += mod;
    return res;
}

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

    ll ans = pow_mod(2, N, MOD);

    ans = neg_mod(ans - 1, MOD);

//cout << COM(N, A) << endl;
   ans = neg_mod(ans - COM(N, A), MOD);

//cout << COM(N, B) << endl;
    ans = neg_mod(ans - COM(N, B), MOD);

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
typedef long long int lli;
 
using namespace std;
 
int arr[22][22];
const int N=22;
int dp[1ll << N][22];
 
int func(int mask,int col,int n)
{
    if(col==n)
    {
        if(mask==(1<<n)-1)
        {
            return 1;
        }
        return 0;
    }
    
    if(dp[mask][col]!=-1)
    {
        return dp[mask][col];
    }
    
    long long int ans=0;
    //i have to assign col woman to a man who has not been assigned any queen
    for(int i=0;i<n;i++)//got man i
    {
        if(arr[i][col]==1 && (mask&(1<<i))==0)
        {
            ans=(ans%MOD+func(mask|(1<<i),col+1,n)%MOD)%MOD;
        }
    }
    
    dp[mask][col]=ans;
    return dp[mask][col];
}
 
 
 
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>arr[i][j];
        }
    }
 
    int mask=0;
    int col=0;
    memset(dp,-1,sizeof(dp));
    cout<<func(mask,col,n);    
    
    return 0;
}




Measured memory_bytes: 360704