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

void fast_io() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
}

int main() {
  fast_io();

  string s;
  cin >> s;
  cout << s;
  if (s[s.size() - 1] == 's') cout << 'e';
  cout << "s\n";
}


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

int main()
{
    long long int q , h , s , d , n , a , b;
    cin>>q>>h>>s>>d>>n;
    
    a = min(min(8 * q, 4 * h),min(2*s, d));
    b = min(min(4*q, 2*h), s);
    cout<<(n/2)*a + (n%2)*b<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

struct cube {

    vector<string> c;

    cube(): c(6) {}

    static bool is_same(cube a, cube b) {

        {
            bool r = true;
            for (int l = 0; l < 6; l++) {
                if (a.c[l] != b.c[l]) {
                    r = false;
                    break;
                }
            }
            if (r) return true;
        }
        
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < 4; k++) {
                    string temp = b.c[3];
                    b.c[3] = b.c[5];
                    b.c[5] = b.c[2];
                    b.c[2] = b.c[0];
                    b.c[0] = temp;
                    bool r = true;
                    for (int l = 0; l < 6; l++) {
                        if (a.c[l] != b.c[l]) {
                            r = false;
                            break;
                        }
                    }
                    if (r) return true;
                }
                string temp = b.c[4];
                b.c[4] = b.c[5];
                b.c[5] = b.c[1];
                b.c[1] = b.c[0];
                b.c[0] = temp;
            }
            string temp = b.c[3];
            b.c[3] = b.c[4];
            b.c[4] = b.c[2];
            b.c[2] = b.c[1];
            b.c[1] = temp;
        }

        return false;

    }


};

int main() {

    ll n;
    while (cin >> n, n) {

        vector<cube> cb(n);
        for (ll i = 0; i < n; i++) {
            for (ll j = 0; j < 6; j++) {
                cin >> cb[i].c[j];
            }
        }

        ll ans = 0;
        for (ll i = 0; i < n; i++) {
            bool is_kaburi = false;
            for (ll j = 0; j < i; j++) {
                if (cube::is_same(cb[i], cb[j])) {
                    is_kaburi = true;
                    break;
                }
            }
            if (is_kaburi) {
                ans++;
            }
        }

        cout << ans << endl;

    }

}


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

int main(){
  int n,k;
  cin >> n >> k;
  int h[n];
  rep(i,n)cin >> h[i];

  sort(h,h+n);
  int ans=1000000000;
  rep(i,n-k+1){
    int tmp=h[k-1+i]-h[i];
    if(ans>tmp)ans=tmp;
  }
  cout << ans << endl;;
}


Measured memory_bytes: 4016
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
     
    public class Program
    {
        public void Proc() {
            Reader.IsDebug = false;
            string inpt = Reader.ReadLine();
            Stack<char> st = new Stack<char>();
            for(int i=0; i<inpt.Length; i++) {
                if(st.Count>0 && st.Peek() == 'S' && inpt[i]=='T') {
                    st.Pop();
                } else {
                    st.Push(inpt[i]);
                }
            }
            Console.WriteLine(st.Count);

        }



        public class Reader {
            public static bool IsDebug = true;
            private static System.IO.StringReader SReader;
            private static string InitText = @"




TSTTSS







";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;

    i64 k = 1;
    while (k * (k + 1) < n * 2) k++;

    if (k * (k + 1) != n * 2) {
        cout << "No" << endl;
        return;
    }

    cout << "Yes" << endl;
    vector<vector<i64>> ans(k + 1, vector<i64>(k));
    for (i64 i = 0, m = 1; i < k; i++) {
        for (i64 j = i; j < k; j++, m++) {
            ans[i][j] = ans[j + 1][i] = m;
        }
    }

    cout << k + 1 << endl;
    for (auto& e : ans) {
        cout << k;
        for (auto& f : e) cout << " " << f;
        cout << endl;
    }
}

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


Measured memory_bytes: 2944
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

map<ll, ll> mp;

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  REP(i, n){
    ll a;
    cin >> a;
    mp[a]++;
  }

  ll maxl=0, l=0;
  for(auto i=mp.begin(); i!=mp.end(); i++){
    if(i->second > 3 && maxl*l < i->first*i->first){
      maxl = i->first;
      l = i->first;
    }
    else if(i->second > 1){
      if(maxl < i->first){
	l = maxl;
	maxl = i->first;
      }
      else if(l < i->first){
	l = i->first;
      }
    }
  }

  cout << l*maxl << endl;
  
  return 0;
}


Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int bubbleSort(int a[],int n)
{
    int flag=1,i,temp,c=0;
    while(flag)
    {
        flag=0;
        for(i=n-1;i>=1;i--)
        {
            if(a[i]<a[i-1])
            {
                temp=a[i];
                a[i]=a[i-1];
                a[i-1]=temp;
                c++;
                flag=1;
            }
        }
    }
    return c;
}
int main()
{
    int N,A[101];
    cin>>N;
    for(int i=0;i<N;i++)
    {
        cin>>A[i];
    }
    int num=bubbleSort(A,N);
    for(int i=0;i<N;i++)
    {
        if(i>0)
            cout<<" ";
        cout<<A[i];
    }
    cout<<endl<<num<<endl;

    return 0;
}



Measured memory_bytes: 3072
import sys

def shuffle( cards ):
	h = int( sys.stdin.readline() )
	cards = cards[ h : ] + cards[ 0 : h ]
	return cards

while True:
	cards = sys.stdin.readline().rstrip()
	if '-' == cards:
		break
	m = int( sys.stdin.readline() )
	for i in range( m ):
		cards = shuffle( cards )
	print( cards )

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;


li a[100100];

int main(void)
{
	li n;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		a[i]--;
	}
	li res = 0;
	rep(i, n) {
		if (a[i] < i)continue;
		if (a[a[i]] == i)++res;
	}
	cout << res << endl;
	return 0;
}

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

int main () {
    int N, answer = 1000000000;
    cin >> N ;

    for (int i = 0; i < N; i++){
        int A, s = 0;
        cin >> A;

        for (int B = A; B % 2 == 0; B /= 2){
                s += 1;
            }

        if(answer > s){
            answer = s;
            }    
        }
    
    cout << answer << endl;
    }

Measured memory_bytes: 256
#include<stdio.h>
#define N 40
  
int n,pos;
int a[N],b[N];

void solve(int, int);

int main(){
  
  int i;

  scanf("%d",&n);

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

  for(i=0;i<n;i++){
    scanf("%d",&b[i]);
  }
  
  pos=0;

  solve(0,n-1);

  printf("\n");

  return 0;
}
  
void solve(int l,int r){
  
  int x,i;

  x=a[pos];
  
  if(l>r)return;
  if(l==r){
    if(b[l]==a[0]) printf("%d",b[l]);
    else printf("%d ",b[l]);
    pos++;
    return;
  }
  
  pos++;
  for(i=l;i<=r;i++){
    if(b[i]==x)break;
  }
  solve(l,i-1);
  solve(i+1,r);
    
  if(x==a[0])printf("%d",x);
  else printf("%d ",x);
}
  

Measured memory_bytes: 600
N, M = map(int, input().split())
E = [[0] * N for i in range(N)] 
for i in range(M):
  a_i, b_i = map(int, input().split())
  a_i = a_i - 1
  b_i = b_i - 1
  E[a_i][b_i] = 1
  E[b_i][a_i] = 1

visited = [0]*N

def dfs(n, depth):
  if visited[n]: # already visited
    return 0
  
  if depth == N:
    return 1
  
  visited[n] = 1
  
  ans = 0
  for next_n in range(N):
    if E[n][next_n]:
      ans += dfs(next_n, depth+1)
  
  visited[n] = 0
  return ans

print(dfs(0,1))

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

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

    return true;
}

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

    int memo[100001];
    for (int i = 0; i <= 100000; ++i) {
        memo[i] = 0;
    }

    for (int i = 3; i <= 100000; i += 2) {
        int l = (i + 1) / 2, r = i;
        int f = (is_prime(l) && is_prime(r)) ? 1 : 0;
        memo[i] = memo[i - 1] + f;
        memo[i + 1] = memo[i];
    }

    for (int i = 0; i < Q; ++i) {
        int l, r;
        cin >> l >> r;
        cout << memo[r] - memo[l - 1] << endl;
    }
}

Measured memory_bytes: 1024
//
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

#define LL long long
#define Lowbit(X) (X&(-X))
#define Lson (X<<1)
#define Rson (X<<1|1)
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(LL i=A;i<=B;i++)
#define BOR(i,A,B) for(LL i=A;i>=B;i--)
#define FOR_SIDE(i,A) for(LL i=Head[A];i;i=Next[i])
#define INF 0x7fffffff
using namespace std;

inline void File() {
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}

int N,X,T;

int main() {
    //File();
    scanf("%d %d %d",&N,&X,&T);
    printf("%d\n",((N-1)/X+1)*T);
    //fclose(stdin); fclose(stdout);
    //system("pause");
    return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sim template < class c
#define ris return *this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", ", d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; it++)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int N = 110;
const int M = 1000 * N + 10;
const ll INF = 1e18;
ll v[N], w[N], dp[N][M];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, W;
	cin >> n >> W;
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	int maxv = 1000 * n + 5;
	for (int i = 0; i <= maxv; i++) {
		dp[1][i] = INF;
	}
	dp[1][0] = 0;
	dp[1][v[1]] = w[1];
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= maxv; j++) {
			if (v[i] > j) {
				dp[i][j] = dp[i - 1][j];
			} else {
				dp[i][j] = min(dp[i - 1][j], w[i] + dp[i - 1][j - v[i]]);
			}
		}
	}
	ll answer = 0;
	for (int i = 0; i <= maxv; i++) {
		if (dp[n][i] <= W) {
			answer = i;
		}
	}
	cout << answer;
	
	return 0;
}


Measured memory_bytes: 87424
s=list(input())
N=len(s)
s2=s[:(N-1)//2]
s3=s[((N+3)-1)//2:N+1]
if s==list(reversed(s)) and s2==list(reversed(s2)) and s3==list(reversed(s3)):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import java.util.*;

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

		String prev = sc.next();

		if(prev.equals("ABC")){
			System.out.println("ARC");
		}else{
			System.out.println("ABC");
		}

		return;
	}
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    ll suma = 0, sumb = 0;
    REP(i, n) {
        cin >> a[i];
        suma += a[i];
    }
    REP(i, n) {
        cin >> b[i];
        sumb += b[i];
    }

    if(suma < sumb) {
        cout << "-1" << endl;
        return 0;
    }

    vector<ll> sa(n);
    REP(i, n) sa[i] = a[i] - b[i];
    sort(ALL(sa));
    int ans = 0;
    ll herasu = 0;
    REP(i, n) {
        if(sa[i] < 0) {
            ans++;
            herasu += sa[i];
        }
    }

    REP_REV(i, n) {
        if(herasu >= 0) break;
        ans++;
        herasu += sa[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int l = (int) Math.ceil(n/2.0);
        int r = n /2;
        int min = Integer.MAX_VALUE;
        for (int i = l; i > 0 ; i--) {
            min = Math.min(min, getSumDigits(i) + getSumDigits(r));
            r++;
        }
        System.out.println(min);
    }

    public static int getSumDigits(int num){
        int sum = 0;
        while (num > 0) {
            sum = sum + num % 10;
            num = num / 10;
        }

        return  sum;
    }
}


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

int main(){
	string T,W;
	int count=0;
	cin>>W;
	for(int i=0;i<W.size();i++)W[i]=tolower(W[i]);
	while(cin>>T){
		if(T=="END_OF_TEXT")break;
		for(int i=0;i<T.size();i++)T[i]=tolower(T[i]);
		if(T==W)count++;
	}
	cout<<count<<endl;
}


Measured memory_bytes: 3204
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<deque>
#include<iomanip>
#include<ctime>
#include<bitset>
using namespace std;

int Euclidean(int a, int b)
{
	int large = max(a, b);
	int small = min(a, b);

	while (large % small > 0)
	{
		int amari = large % small;
		large = move(small);
		small = amari;
	}

	return small;
}

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

	unsigned long long total = 0;

	for (int i = 1; i <= K; i++)
	{
		for (int j = 1; j <= K; j++)
		{
			for (int l = 1; l <= K; l++)
			{
				int a = Euclidean(i, j);
				total += Euclidean(a, l);
			}
		}
	}

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
  int N, M, flag;
  char A[51][51], B[51][51];

  cin >> N >> M;

  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      cin >> A[i][j];
    }
  }

  for(int i = 0;i < M;i++){
    for(int j = 0;j < M;j++){
      cin >> B[i][j];
    }
  }

  for(int i = 0;i <= N - M;i++){
    for(int j = 0;j <= N - M;j++){
      flag = 0;
      if(A[i][j] == B[0][0]){
        for(int k = 0;k < M;k++){
          for(int s = 0;s < M;s++){
            if(A[i + k][j + s] != B[k][s]){
              flag = 1;
            }
          }
        }
      } else {
        flag = 1;
      }
      if(flag == 0){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  if(flag == 1) cout << "No" << endl;

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define md 1000000007
#define mx 1e18
#define pb push_back
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pii pair<ll int,ll int>
#define ff first
#define ss second


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

	ll int ar[n+1];
	for(ll int i=1;i<=n;i++)
		cin>>ar[i];

	ll int dp[n+1][n+1];
	memset(dp,0,sizeof(dp));

	ll int pre[n+1];
	memset(pre,0,sizeof(pre));

	for(int i=1;i<=n;i++)
		pre[i]=pre[i-1]+ar[i];

	for(ll int i=n;i>=1;i--)
	{
		for(ll int j=i;j<=n;j++)
		{
			dp[i][j]=mx;

			if(i==j)
				dp[i][j]=0;

			for(ll int k=i;k<j;k++)
			{
				dp[i][j]=min(dp[i][j] , dp[i][k] + dp[k+1][j]+pre[j]-pre[i-1]);
			}
		}
	}

	cout<<dp[1][n]<<endl;

	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

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

int main(){

  ll n;cin>>n;
  ll t;
  ll ans=1;

  rep(i,0,n){
    cin>>t;
    ans=lcm(t,ans);
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int S;
    int h, m, s;
    cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
    
}


Measured memory_bytes: 3100
import java.util.*;

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

      int n=sc.nextInt();

      int ans;

      int[] a = new int[n];

      for(int i=0;i<n;i++){
        a[i]=sc.nextInt();
      }

      int max1=0;
      int max2=0;
      int memo1=0;
      int memo2=0;
/////////////////////////////////////////
      for(int j=0;j<n;j++){
        if(a[j]>max1){
          max1=a[j];
        }
      }
      for(int j=0;j<n;j++){
        if(a[j]==max1){
          memo1 = j;
          a[j] = 0;
          break;
        }
      }
/////////////////////////////////////////
/////////////////////////////////////////
      for(int j=0;j<n;j++){
        if(a[j]>max2){
          max2=a[j];
        }
      }
      for(int j=0;j<n;j++){
        if(a[j]==max2){
          memo2 = j;
        }
      }
/////////////////////////////////////////

      for(int i=0;i<n;i++){
        if(i!=memo1){
          System.out.println(max1);
        }
        else{
          System.out.println(max2);
        }
      }


    }
}


Measured memory_bytes: 87580
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;

const int N = 1e5 + 10;
int n, m;
int x[N], y[N], z[N];
vector<int> g[N];
int used[N];

void dfs(int x) {
  used[x] = 1;
  for (int y : g[x]) {
    if (!used[y]) {
      dfs(y);
    }
  }
}

int main() {
  
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", x + i, y + i, z + i);
    g[x[i]].pb(y[i]);
    g[y[i]].pb(x[i]);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      dfs(i);
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 10368
# -*- coding: utf-8 -*-
# 整数の入力
cnt = 1
cur = 1
n = int(input())
k = int(input())
while cnt <= n:
  cnt += 1
  opeA = cur * 2
  opeB = cur + k

  if opeA < opeB :
    cur = opeA
  else:
    cur = opeB
print (cur)


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

int main(){
  int r;
  cin >> r;
  if(r<1200){
    cout << "ABC" << endl;
  }else if(r<2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 256
//...START BY DOING WHAT IS NECESSARY, THEN WHAT IS POSSIBLE AND SUDDENLY YOU ARE DOING THE IMPOSSIBLE... 
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
typedef long long ll;
#define endl '\n'
#define M 1000000007
#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
bool comp(int x,int y)
{
    return x > y;   
}

/*....................code starts here..............................*/

int main() {
    //FAST_IO;
    int t=1;
   cin >> t;
    string s;
    int arr[4]{0};
    while(t--)
    {
        cin >> s;
        if(s == "AC")
        arr[0] += 1;
        else if(s == "WA")
        arr[1] += 1;
        else if(s == "TLE")
        arr[2] += 1;
        else
        arr[3] += 1;
    }
    cout << "AC x " << arr[0] << endl;
    cout <<    "WA x " <<arr[1] << endl;
    cout <<     "TLE x " << arr[2] << endl;
    cout <<    "RE x " <<arr[3] << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    char a,b;
    int ans=0;
    scanf("%c",&a);
    printf("%c",a);
    while(a=getchar()){
        if(a==' '||a=='\n')break;
        ans++;
        b=a;
    }
    printf("%d%c",ans-1,b);
    return 0;
}

Measured memory_bytes: 256
import bisect
a, b = map(int, input().split())
x = 0
li = []
for i in range(1, 1000):
    x += i
    li.append(x)
ids = bisect.bisect_left(li, a)-1
for i in range(ids, len(li)):
    x = abs(li[i]-a)
    y = abs(li[i+1]-b)
    if x == y:
        print(x)
        break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
string s;
int p;
int bns();
int g_A(){
  int a=0;
  if(s[p]=='S'){
    p+=2;
    a=bns();
    a=a*a%1000000007;
    p++;
  }
  else if(isdigit(s[p])){
    while(isdigit(s[p])){
      a=a*10+(s[p]-'0');
      p++;
    }
  }
  return a;
}
int bns(){
  int a=g_A();
  while(s[p]=='>'&&s[p+1]=='>'&&(isdigit(s[p+2])||s[p+2]=='S')){
    p+=2;
    int b=g_A();
    a>>=min(b,63LL);
  }
  return a;
}
main(){
  while(getline(cin,s),s[0]!='#'){
    p=0;
    s.erase(remove(s.begin(),s.end(),' '),s.end());
    cout<<bns()<<endl;
  }
}

Measured memory_bytes: 5880
#!/usr/bin/env python3
N = input()
A = [int(s) for s in input().split()]

if 0 in A:
    print(0)
    exit()

result = 1
LIMIT = 10 ** 18
for a in A:
    result *= a
    if result > LIMIT:
        print(-1)
        exit()

print(result)

Measured memory_bytes: 21632
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll MOD=1e+9+7;
	ll H,W,K;
	ll dp[101][8];
	scan(H);scan(W);scan(K);
	fill(dp[0],dp[101],0);
	K--;
	if(W==1) prin(1);
	else{
		vector<vint > pattern;
		vint kara; pattern.push_back(kara);
		rep1(i,W-1){
			vint one; one.push_back(i); pattern.push_back(one);
		}
		if(W>=4){
			rep1(i,W-3){
				for(int j=i+2;j<=W-1;j++){
					vint two; two.push_back(i); two.push_back(j); pattern.push_back(two);
				}
			}
		}
		if(W>=6){
			rep1(i,W-5){
				for(int j=i+2;j<=W-3;j++){
					for(int k=j+2;k<=W-1;k++){
						vint three; three.push_back(i); three.push_back(j); three.push_back(k); pattern.push_back(three);
					}
				}
			}
		}
		if(W==8){
			vint four; four.push_back(1); four.push_back(3); four.push_back(5); four.push_back(7); pattern.push_back(four);
		}
		int pnum=pattern.size();
		int irekae[1000][8];
		rep(i,pnum){
			rep(j,W){
				irekae[i][j]=j;
			}
			rep(j,pattern[i].size()){
				int w1=pattern[i][j]-1,w2=pattern[i][j];
				swap(irekae[i][w1],irekae[i][w2]);
			}
		}
		dp[0][0]=1;
		rep(h,H){
			rep(i,pnum){
				rep(w,W){
					dp[h+1][irekae[i][w]]+=dp[h][w]%MOD;
					dp[h+1][irekae[i][w]]%=MOD;
				}
			}
		}
		prin(dp[H][K]);
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define CAKE 4 //ケーキは4ドル
#define DONUT 7 //ドーナツは7ドル

int main(void)
{
	//変数を定義
	int n, flag = 0;
	//入力
	scanf("%d", &n);

	//変数flagがカウントされたらYes。されなかったらNo。
	for (int i = 0; i <= 25 ;i++) {
		for (int j = 0; j <= 15 ; j++) {
			//購入の全通りを試す
			if (n == CAKE * i + DONUT * j) {
				printf("Yes\n");
				return 0;
			}
			//入力した値段を超えたらbreak
			else if(n < CAKE * i + DONUT * j){
				break;
			}
		}
	}
	
		printf("No\n");

	return 0;
}



Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(){
    char c[1200] = {0};
    int i = 0;
    int j = 0;
    for(i=0;i<1200;i++){
        scanf("%c",&c[i]);
        if(c[i]=='\n'){
            break;
        }
    }
    for(j=0;j<=i;j++){
        if(c[j]>=65&&c[j]<=90){
            c[j] = c[j]+32;
        }
        else if(c[j]>=97&&c[j]<=122){
            c[j] = c[j]-32;
        }
    }
    for(j=0;j<=i;j++){
        printf("%c",c[j]);
    }
   // printf("\n");
    return 0;
}


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

using namespace std;

const int N = 100;
const int INF = 100000000;


int n, data[N][N], yoko[N][N], tate[N];


main(){
  cin >> n;
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin >> data[i][j];
  for(int i=0;i<n;i++){
    yoko[i][0] = data[i][0];
    for(int j=1;j<n;j++) yoko[i][j] = yoko[i][j-1] + data[i][j];
  }
  /*for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout << yoko[i][j] << ' ';
    }
    cout << endl;
    }*/
  int ans = -INF;
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) ans = max(ans, data[i][j]);
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(i == 0) for(int k=0;k<n;k++) tate[k] = yoko[k][j];
      else for(int k=0;k<n;k++) tate[k] = yoko[k][j] - yoko[k][i-1];
      int tmp[N];
      tmp[0] = tate[0];
      for(int k=1;k<n;k++) tmp[k] = tmp[k-1] + tate[k];
      int valm = 0, valM = -INF;
      for(int k=0;k<n;k++){
        valM = max(valM, tmp[k]);
        if(valm > tmp[k]){
          valm = tmp[k];
          valM = tmp[k];
        }
        //cout << valm << ' ' << valM << endl;
        if(valm != valM) 
          ans = max(ans, valM - valm);
      }
      /*cout << "(" << i << ", " << j << ")" << endl;
      for(int k=0;k<n;k++) cout << tate[k] << ' '; cout << endl;
      cout << "ans = " << ans << endl;*/
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1236
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd()
{
	static uint seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());
	bool f(false);
	while(ch<48||ch>57) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();
	while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp,typename... Args>Finline _Tp min(const _Tp &a,const _Tp &b,const Args &...args){return a<b?min(a,args...):min(b,args...);}
template <typename _Tp,typename... Args>Finline _Tp max(const _Tp &a,const _Tp &b,const Args &...args){return a<b?max(b,args...):max(a,args...);}
Finline int read_str(char *s)
{
	char ch(getchar());
	while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;
	*tar=ch,ch=getchar();
	while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=1000005;
char s[N];
int ch[N][26];
ll sum[N][26];
bool cnt[N];
int node_cnt;
int last[26];
void ins(char *s,int len)
{
	memset(last,0,sizeof(last));
	int cur=0,tmp;
	for(int i=0;i<len;++i)
	{
		tmp=s[i]-'a';
		if(!ch[cur][tmp]) ch[cur][tmp]=++node_cnt;
		cur=ch[cur][tmp];
		last[tmp]=cur;
	}
	for(int i=0;i<26;++i) if(last[i]) ++sum[last[i]][i];
	cnt[cur]=true;
}
int main()
{
	int n;read(n);
	for(int i=1;i<=n;++i)
	{
		int len=read_str(s);
		std::reverse(s,s+len);
		ins(s,len);
	}
	for(int i=node_cnt;i>=1;--i)
	{
		for(int j=0;j<26;++j)
		{
			if(ch[i][j]) for(int k=0;k<26;++k) sum[i][k]+=sum[ch[i][j]][k];
		}
	}
	ll ans=0;
	for(int i=0;i<=node_cnt;++i)
	{
		std::vector<int> v;
		for(int j=0;j<26;++j) if(ch[i][j]) v.pb(ch[i][j]);
		for(int j=0;j<26;++j)
		{
			if(!ch[i][j]||!cnt[ch[i][j]]) continue;
			for(auto it:v) ans+=sum[it][j];
		}
	}
	printf("%lld\n",ans-n);
	return 0;
}


Measured memory_bytes: 308840
#include <bits/stdc++.h>
          
#define pb push_back
#define ll long long
#define F first
#define S second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;                                                      
} 
int dx[5] = {-1, 0, 0, 1};
int dy[5] = {0, -1, 1, 0};
  
const int N = 1e6 + 100;
const ll mod = 1e9 + 7; //998244353;
const ll big = 1e9;

ll binpow (ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)
			res *= a;
		a *= a;
		n >>= 1; 
		a %= mod;
		res %= mod;
	}
	return res;
}
ll dp[N][10][2][2];
int main() 
{
	data();
	//freopen("mountains.in", "r", stdin);
   	//freopen("mountains.out", "w", stdout);          
   	int n;
   	cin >> n;
   	for (int i = 0; i <= 9; i++)
   	{
   		if (i == 0)
   		{
   			dp[1][i][1][0] = 1;
   			continue;
   		}
   		if (i == 9)
   		{
   			dp[1][i][0][1] = 1;
   			continue;
   		} 
   		dp[1][i][0][0] = 1;
   	}
   	for (int i = 2; i <= n; i++)
   	{
   		for (int j = 0; j <= 9; j++)
   		{
   			for (int f = 0; f < 2; f++)
   			{
   				for (int s = 0; s < 2; s++)
   				{
   					if (dp[i - 1][j][f][s] > 0)
   					{
   						for (int k = 0; k <= 9; k++)
   						{
   							int f2 = f;
   							int s2 = s;
   							if (k == 0)
   							{
   								f2 |= 1;
   							}
   							if (k == 9)
   							{
   								s2 |= 1;
   							}
   							dp[i][k][f2][s2] += dp[i - 1][j][f][s];
   							dp[i][k][f2][s2] %= mod;
   						}
   					}
   				}
   			}
   		}
   	}
   	ll ans = 0;
   	for (int i = 0; i <= 9; i++)
   	{
   		ans += dp[n][i][1][1];
   		ans %= mod;
   	}
   	cout << ans;
}

Measured memory_bytes: 315912
#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v, x) binary_search(v.begin(), v.end(), x)
#define popf pop_front
#define p() cout << '\n'
#define p0(x) cout << x << " "
#define p1(x) cout << x << '\n'
#define p2(x, y) cout << x << " " << y << '\n'
#define p3(x, y, z) cout << x << " " << y << " " << z << '\n'
#define printv(v)                   \
  for (ll i = 0; i < v.size(); ++i) \
    cout << v[i] << " ";            \
  cout << '\n'
#define pr1(x) cout << fixed << setprecision(15) << x << '\n'
#define mod 1000000007
#define mod1 998244353
#define fio                         \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define get(n) \
  ll n;        \
  cin >> n
#define getvec(v, n)         \
  vector<ll> v(n);           \
  for (ll i = 0; i < n; i++) \
    cin >> v[i];
#define getstr(s) \
  string s;       \
  cin >> s
#define all(x) x.begin(), x.end()
#define countBits(x) __builtin_popcount(x)
using namespace std;

ll solve(ll n)
{
  ll ans = 0;
  while (n != 0)
  {
    n = n % countBits(n);
    ++ans;
  }
  return ans;
}

void mainSolve()
{

  get(n);
  getstr(s);
  ll one(0);
  for (int i = 0; i < n; i++)
    if (s[i] == '1')
      ++one;
  vl power1(n, 1);
  vl power0(n, 1);
  for (int i = 1; i < n; i++)
  {
    ll temp = one;
    if (one == 1)
      one = 2;
    power1[i] = (power1[i - 1] * 2ll) % (one - 1ll);
    one = temp;
    power0[i] = (power0[i - 1] * 2ll) % (one + 1ll);
  }
  ll x1(0), x0(0);
  ll cnt = 0;
  for (int i = n - 1; i >= 0; i--)
  {
    if (s[i] == '1')
    {
      ll temp = one;
      if (one == 1)
        one = 2;
      x1 = (x1 + power1[cnt]) % (one - 1ll);
      one = temp;
      x0 = (x0 + power0[cnt]) % (one + 1ll);
    }
    ++cnt;
  }
  for (int i = 0; i < n; i++)
  {
    ll currBits = one;
    if (s[i] == '1')
    {
      if (one == 1)
      {
        p1(0);
        continue;
      }
      ll curr = x1;
      --one;
      curr = (curr - power1[n - 1 - i]) % one;
      curr = (curr + one) % one;
      curr = 1ll + solve(curr);
      p1(curr);
    }
    else
    {
      ++one;
      ll curr = x0;
      curr = (curr + power0[n - 1 - i]) % one;
      curr = 1ll + solve(curr);
      p1(curr);
    }
    one = currBits;
  }
}

int main()
{
  fio;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  // get(t);
  ll t = 1;
  while (t--)
  {
    mainSolve();
  }
  return 0;
}


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

using namespace std;

int main() {
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    if(m1>m2) --h2,m2+=60;
    cout << (h2-h1)*60+(m2-m1-k);
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(void){
    // Your code here
    int n;
    int a[100001];
    long min,MAX,sum;
    
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    sum=0;
    min=MAX=a[0];
    for(int i=0; i<n; i++){
        if(a[i]>=MAX) MAX=a[i];
        if(a[i]<=min) min=a[i];
        sum=sum+a[i];
    }
    cout<<min<<' '<<MAX<<' '<<sum<<endl;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Tup = tuple<char, int, int, int>;
vector<Tup> program;
void pls(int a, int b, int c) {
    program.emplace_back('+', a, b, c);
}
void les(int a, int b, int c) {
    program.emplace_back('<', a, b, c);
}
void clr(int a) {
    les(a, a, a);
}
void pri(int a) {
    program.emplace_back('p', a, a, a);
}
int main() {
    enum { A = 0, B, out, zero, one, p2, acc1 = p2 + 30, acc2, a, b, c, d, e, f };
    pls(one, A, B);
    les(one, zero, one);
    pls(p2 + 0, zero, one);
    pls(A, A, one);
    pls(B, B, one);
    for (int i = 1; i < 30; i++) {
        pls(p2 + i, p2 + i - 1, p2 + i - 1);
    }
    for (int i = 29; i >= 0; i--) {
        pls(a, acc1, p2 + i);
        les(b, a, B);
        clr(acc2);
        for (int j = 29; j >= 0; j--) {
            pls(c, acc2, p2 + j);
            les(d, c, A);
            pls(e, b, d);
            les(f, one, e);
            for (int k = 0; k < j; k++) {
                pls(f, f, f);
            }
            pls(acc2, acc2, f);
        }
        for (int j = 0; j < i; j++) {
            pls(b, b, b);
            pls(acc2, acc2, acc2);
        }
        pls(acc1, acc1, b);
        pls(out, out, acc2);
    }
    if (1) {
        cout << program.size() << '\n';
        for (auto& [op, k, i, j] : program) {
            cout << op << ' ' << i << ' ' << j << ' ' << k << '\n';
        }
    }
    auto run = [&](Int in_a, Int in_b) {
        vector<unsigned long long> K(100);
        K[A] = in_a;
        K[B] = in_b;
        for (auto& [op, a, b, c] : program) {
            if (op == '+') {
                K[a] = K[b] + K[c];
            } else if (op == '<') {
                K[a] = K[b] < K[c];
            } else if (op == 'p') {
                cout << K[a] << endl;
            }
            assert(K[a] <= 10000000000000000000ULL);
        }
        if (K[out] != in_a * in_b) {
            cout << "FAILED " << in_a << ' ' << in_b << ' ' << K[out] << endl;
        }
    };
    return 0;
}


Measured memory_bytes: 3872
# -*- coding: utf-8 -*-

import os
import sys

class Main(object):

    def __init__(self):
        pass

    def some_method(self):
        o = input()
        e = input()
        ans = ''
        length = max(len(o), len(e))
        for i in range(length):
            if i < len(o):
                ans += o[i]
            if i < len(e):
                ans += e[i]
        print(ans)
                         
                

        return None

if __name__ == '__main__':
    m = Main()
    m.some_method()


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


class maki {
    static void Main(string[] args) {
        var cin=Console.ReadLine().Split().Select(int.Parse).ToArray();
        //int n = int.Parse(Console.ReadLine());
        //string s=Console.ReadLine();
        int h=cin[0],w=cin[1];
        for(int i=1;i<=h;i++){
        	var s=Console.ReadLine().Split(' ');
        	for(int j=0;j<w;j++){
        		if(s[j]=="snuke"){
        			Console.WriteLine(((char)('A'+j)).ToString()+i.ToString());
        			return;
        		}
        	}
        }
    }
}


Measured memory_bytes: 13396
// m-solutions2020_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    set<P> st;
    st.emplace(1000ll, 0ll);

    REP(i, N){

        set<P> new_st;
        for (auto e: st){
            ll m = e.first;
            ll s = e.second;
            new_st.emplace(m + s * A[i], 0);
            new_st.emplace(m % A[i], s + m / A[i]);
            new_st.emplace(m, s);
        }
        st.clear();

        for (auto e: new_st){
            bool need = true;
            for (auto f: new_st){
                if (e.first < f.first and e.second < f.second){
                    need = false;
                    break;
                }
            }
            if (need){
                st.emplace(e);
            }
        }

    }

    ll ans = 1000;
    for (auto e: st){
        ans = max(ans, e.first);
    }
    print(ans);


    return 0;
}


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

using namespace std;

int main() {
 long long int n;
 cin>>n;
 string s;
 while (n){
     s+='a'+(n-1)%26;
     n=(n-1)/26;
 }
reverse(s.begin(),s.end());
 cout<<s;
}


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 

int dx[8] = {-1,-1,-1,0,1,1,1,0};
int dy[8] = {0,1,-1,1,-1,0,1,-1};

bool inrange(int x,int y){
  if(x<0||y<0||x>7||y>7) return false;
  else return true;
}

char hit[3] = "ox";
int changeban(char wmap[8][8],int turn,int x,int y){
  int cnt = 0;
  REP(i,8){
    bool changable = false;
    int nx = x+dx[i]; int ny = y+dy[i];
    if(!inrange(nx,ny)) continue;
    while(1){
      if(!inrange(nx,ny)) break;
      if(wmap[nx][ny]=='.') break;
      if(wmap[nx][ny]==hit[turn]) changable = true;
      nx += dx[i]; ny+= dy[i];
    }
    if(changable){
      nx = x+dx[i]; ny = y+dy[i];
      while(wmap[nx][ny]!=hit[turn]){
        cnt++;
        wmap[nx][ny] = hit[turn];
        nx += dx[i]; ny+= dy[i];
      }
    }
  }
  return cnt;
}

//MAXとなるところにさす
int max_search(char ban[8][8],int turn){
  char bkup[8][8];
  char ansban[8][8];
  REP(i,8) REP(j,8) ansban[i][j] = ban[i][j];
  int maxchan = -1;
  if(turn==0){
    for(int i=7;i>-1;i--){
      for(int j=7;j>-1;j--){
        if(ban[i][j]=='.'){
          REP(k,8) REP(l,8) bkup[k][l] = ban[k][l];
          bkup[i][j]=hit[turn];
          int rst = changeban(bkup,turn,i,j);
          if((maxchan<=rst)&&(rst!=0)){
            maxchan = rst;
            REP(k,8) REP(l,8) ansban[k][l] = bkup[k][l];
          }
        }
      }
    }
  }else{
    REP(i,8){
      REP(j,8){
        if(ban[i][j]=='.'){
          REP(k,8) REP(l,8) bkup[k][l] = ban[k][l];
          bkup[i][j]=hit[turn];
          int rst = changeban(bkup,turn,i,j);
          if((maxchan<=rst)&&(rst!=0)){
            //cout << "(" << i <<"," <<j <<")" <<"num: " << rst << endl;
            maxchan = rst;
            REP(k,8) REP(l,8) ansban[k][l] = bkup[k][l];
          }
        }
      }
    }
  }
  REP(i,8) REP(j,8) ban[i][j] = ansban[i][j];
  return maxchan;//-1,0ならさせない
}

void ShowBan(char data[8][8]){
  REP(i,8){
    REP(j,8){
      cout << data[i][j];
    }
    cout << endl;
  }
}

int main(){
  char data[8][8];
  REP(i,8){
    scanf("%s",data[i]);
  }
  while(1){
    //2人もおけないならend
    int rst1 = max_search(data,0);
    //ShowBan(data);
    int rst2 = max_search(data,1);
    //ShowBan(data);
    if((rst1<=0)&&(rst2<=0)) break;
  }
  ShowBan(data);
  return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  bool flag = false;
  for (int i = 0; i < int(s.size()); i++) {
    if(i % 2 == 0){
      if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D') continue;
      flag = true;
    }else{
      if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D') continue;
      flag = true;
    }
  }
  if(!flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

const int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    ve<ve<int>> a(n,ve<int>(n));
    rep(i,n)rep(j,n) cin >> a[i][j];
    ve<ve<ll>> dp(n+1,ve<ll>(1<<n));
    dp[0][0] = 1;
    for(int i=0;i<n;i++){
        rep(j,n){
            if(a[i][j]==0) continue;
            else{
                int mask = 1<<j;
                rep(k,1<<n){
                    if(mask&k) continue;
                    (dp[i+1][k|mask] += dp[i][k])%=mod;
                }
            }
        }
    }
    cout << dp[n][(1<<n)-1] << endl;
    return 0;
}


Measured memory_bytes: 377216
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]

li = [["" for i in range(n)]for j in range(n)]
for i in range(n):
    s = stdin.readline().rstrip()
    for j in range(n):
        li[i][j] = s[j]

lin = [["" for i in range(m)]for j in range(m)]
for i in range(m):
    s = stdin.readline().rstrip()
    for j in range(m):
        lin[i][j] = s[j]

for i in range(n-m+1):
    for j in range(n-m+1):
        point = 0
        for k in range(m):
            for l in range(m):
                if lin[k][l] == li[k+i][l+j]:
                    point += 1
                    if point == m**2:
                        print("Yes")
                        exit()
                        
print("No")

Measured memory_bytes: 3064