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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, p[200000], r[200000];

int main() {
	cin >> n;
	inc(i, n) { cin >> p[i]; p[i]--; }
	
	inc(i, n) { r[p[i]] = i; }
	
	int c = 1, ma = 1;
	incID(i, 1, n) {
		if(r[i - 1] < r[i]) { c++; setmax(ma, c); } else { c = 1; }
		// cout << "c: " << c << endl;
	}
	
	cout << n - ma << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;
// 10:12
int main()
{
    int A, B, C, D, E, F;
    std::cin >> A >> B >> C >> D >> E >> F;

    std::set<int> waterCandidates;

    for (int a = 0; 100*A * a <= F; ++a) {
        for (int b = 0; 100*B * b <= F; ++b) {
            const auto w = 100 * a*A + 100 * b*B;
            if (0 < w && w <= F) {
                waterCandidates.insert(w);
            }
        }
    }

    std::set<int> sugerCandidates;
    for (int c = 0; C * c < F; ++c) {
        for (int d = 0; D * d < F; ++d) {
            if (c*C + d*D <= F) {
                sugerCandidates.insert(c*C + d*D);
            }
        }
    }

    double md = -1;
    int mw = 0;
    int ms = 0;

    for (auto w : waterCandidates) {
        for (auto s : sugerCandidates) {
            if (w + s <= F && s <= E * (w /100)) {
                auto d = 100.0*s/(w + s);
                if (md < d) {
                    mw = w;
                    ms = s;
                    md = d;
                }
            }
        }
    }

    std::cout << mw + ms << " " << ms << std::endl;

    return 0;
}


Measured memory_bytes: 384
import sys
from operator import itemgetter as ig
from collections import defaultdict as dd

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def input():
    return next(args)
def parse(*params):
    if len(params) == 1:
        return params[0](next(args))
    return tuple(p(v) for p, v in zip(params, next(args).split()))
def debug(*v):
    if __debug__:
        print(*v, file=sys.stderr)

# エントリーポイント
def main():
    N, K = parse(int, int)
    H = [parse(int) for _ in range(N)]

    h = sorted(H)

    diff_h = tuple(h[l + K - 1] - h[l] for l in range(N - K + 1))

    print(min(diff_h))

if __name__ == '__main__':
    args = iter(sys.stdin.read().split("\n"))
    main()


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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    cout << (n - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
/*..............................................*\
Author:Kishor Kumar Paroi
Dept:CSE-1703053
RUET,BANGLADESH
\*---------------------------*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include<bits/stdc++.h>
#include<iostream>
#include<iterator>

#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

//const int N=100*1000;
//const int mod=1e9+7;

//# define int min3(int a,int b,int c){return min(a,min(b,c));}
//#define int max3(int a,int b,int c){return max(a,max(b,c));}
//#define int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
//#define int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a+b == c || b+c == a || c+a == b)
    {
        printf("%s", "Yes\n");
    }
    else
    {
        printf("%s", "No\n");
    }

    return 0;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,m,ans=0;
void Main(){
    cin>>n>>m;
    if(max(n,m)>9)cout<<-1<<endl;
    else cout<<n*m<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    elif L % 673 == 0 and L + 2 <= R:
        print(0)
        return
    elif R % 673 < L % 673 and L + 2 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

bool check(string s,string t){
    REP(i,s.size()){
        if(s[i]!='?' and s[i]!=t[i]) return false;
    }
    return true;
}

signed main()
{   
    string s,t; cin>>s>>t;
    set<string> st;
    for(int i=0;i+t.size()<=s.size();i++){
        if(check(s.substr(i,t.size()),t)){
            string u;
            for(int j=0;j<i;j++)
                u+=(s[j]=='?'? 'a':s[j]);
            REP(j,t.size()) u+=t[j];
            for(int j=i+t.size();j<s.size();j++)
                u+=(s[j]=='?'? 'a':s[j]);
            st.insert(u);
        }
    }
    if(st.empty()) cout<<"UNRESTORABLE"<<endl;
    else cout<<*st.begin()<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
 
using namespace std;

vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define MOD 1000000007
#define A first
#define B second
#define all(x) (x).begin(), (x).end

typedef long long ll;
 
inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}
 
inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}
 
inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}
 
inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}
 
inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}
 
inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}
 
const int N = 1e5 + 5;

int arr[N];

void solve(){
  char c;
  cin >> c;
  if(c >= 'a' && c <= 'z'){
    cout << 'a';
  }
  else {
    cout << 'A';
  }

}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

vector<pair<ll,ll>> fact(ll n){
    vector<pair<ll,ll>> p;
    for(ll i = 2; i*i <= n; i++){
        ll cnt = 0;
        while(n%i == 0){
            n /= i;
            cnt++;
        }
        p.push_back(make_pair(i, cnt));
    }
    if(n != 1) p.push_back(make_pair(n ,1));
    return p;
} 
int main(){

    ll n;
    cin >> n;
    const auto &res = fact(n);
    int ans = 0;
    for(auto iter: res){
        int cnt = iter.second;
        int i = 1;
        while(cnt >= i){
            cnt -= i;
            i++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19760
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,m;
  cin>>n>>m;
  ll cnt=m/n;
  ll ans=0;
  Rep(i,sqrt(m)+1){
    if(m%i==0){
      ll a=i;
      ll b=m/i;
      if(a<=cnt) chmax(ans,a);
      if(b<=cnt) chmax(ans,b);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
word = input()
q = int(input())

for _ in range(q):
    s = input().split(" ")
    command = s[0]
    a = int(s[1])
    b = int(s[2])
    if command == "print":
        print(word[a:b+1])
    elif command == "reverse":
        word = word[:a] + word[a:b+1][::-1] + word[b+1:]
    elif command == "replace":
        word = word[:a] + s[3] + word[b+1:]

Measured memory_bytes: 7648
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;

ll N,M;


int main(void)
{
	cin >> N>>M;
	ct(N + M / 2);

	return 0;
}

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

int main() {
  string str;
  cin >> str;
  int count = 0;
  int strLen = str.length();
  for (int i = 0; i < strLen / 2; i++) {
    if (str.at(i) != str.at(strLen - i - 1)) count++;
  }
  cout << count << endl;
  return 0;
}

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

void dfs(vector<int>& colors, vector<vector<pair<int, int> > >& out, int node,
         bool c) {
  if (colors[node] != -1) return;
  colors[node] = c ? 1 : 0;
  for (int i = 0; i < out[node].size(); i++) {
    bool ev = (out[node][i].second % 2 == 0);
    dfs(colors, out, out[node][i].first, (ev ? c : !c));
  }
}
int main() {
  int N, u, v;
  long long int w;
  cin >> N;
  vector<int> colors(N + 1);
  for (int i = 1; i < N + 1; i++) colors[i] = -1;
  vector<vector<pair<int, int> > > out(N + 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> u >> v >> w;
    out[u].push_back(make_pair(v, w));
    out[v].push_back(make_pair(u, w));
  }
  dfs(colors, out, 1, false);
  for (int i = 1; i < N + 1; i++) cout << colors[i] << endl;
  return 0;
}


Measured memory_bytes: 8960
#include<stdio.h>
 
int main(){
   int a,b,aa,ans;
   scanf("%d %d", &a,&b);
  ans = 1;
  aa = a;
   while(aa<b){
   		aa = a-1 + aa;
     	ans++;
   
   }
	if(b==1){ ans = 0;}

  	printf("%d", ans);
	return 0;
 
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  rep(i,n-2){
    if (s.substr(i,3) == "ABC") ans++;
  }
  cout << ans << endl;
  return 0;
}


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

print(' '.join(list(map(str, a))))
for i in range(1, n):
    key = a[i]
    j = i - 1
    while j >= 0 and a[j] > key:
        a[j + 1] = a[j]
        j -= 1
    a[j + 1] = key
    print(' '.join(list(map(str, a))))



Measured memory_bytes: 5604
n=int(input())
ans=0
for num in range(1,n+1,2):
    cnt=0
    for i in range(1,num):
        if i*i>num:
            break
        if num%i==0:
            if num==i*i:
                cnt+=1
            else:
                cnt+=2
    if cnt==8:
        ans+=1
print(ans)

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

int main(){
  int n, k, ans=1e9;
  cin >> n >> k;

  vector<int> h(n);
  for (int i=0; i<n; i++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  
  for( int i=0; i< n-k+1; i++) {
    ans = min(ans, h[i+k-1] - h[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<string>
#define N 6009
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;

int main()
{
    int sx, sy, tx, ty;
    scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
    for(int i = sy + 1; i <= ty; i++) printf("U");
    for(int i = sx + 1; i <= tx; i++) printf("R");
    for(int i = ty - 1; i >= sy; i--) printf("D");
    for(int i = tx - 1; i >= sx; i--) printf("L");
    printf("L");
    for(int i = sy; i <= ty; i++) printf("U");
    for(int i = sx; i <= tx; i++) printf("R");
    printf("DR");
    for(int i = ty; i >= sy; i--) printf("D");
    for(int i = tx; i >= sx; i--) printf("L");
    printf("U\n");
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a;
    string b;
    cin >> a >> b;
    int tmp = 0;
    for(char c : b){
        if(c == '.') continue;
        tmp = tmp * 10 + (c - '0');
    }
    cout << a * tmp / 100 << endl;
    return 0;
}


Measured memory_bytes: 3632
from heapq import heappush, heappop

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

exists = set()
q = [(-(A[0] + B[0] + C[0]), (0, 0, 0))]
for _ in range(K):
    v, i = heappop(q)
    print(-v)
    if i[0] < X - 1:
        ni = (i[0] + 1, i[1], i[2])
        if ni not in exists:
            exists.add(ni)
            nv = A[i[0] + 1] + B[i[1]] + C[i[2]]
            heappush(q, (-nv, ni))
    if i[1] < Y - 1:
        ni = (i[0], i[1] + 1, i[2])
        if ni not in exists:
            exists.add(ni)
            nv = A[i[0]] + B[i[1] + 1] + C[i[2]]
            heappush(q, (-nv, ni))
    if i[2] < Z - 1:
        ni = (i[0], i[1], i[2] + 1)
        if ni not in exists:
            exists.add(ni)
            nv = A[i[0]] + B[i[1]] + C[i[2] + 1]
            heappush(q, (-nv, ni))


Measured memory_bytes: 4840
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll n, ll m){
    return n * (m / gcd(n, m));
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vi A(N);
    REP(i,N){
        cin >> A[i];
    }
    ll ans=0;
    REP(i,N){
        ans += A[i]-1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
  char egara;
  int value;
}C;

void BubbleSort(C[36], int);
void SelectionSort(C[36], int);
int isStable(C[36],C[36],int);

int main(){
  int n,i;
  C c1[36],c2[36];

  scanf("%d",&n);

  for(i = 0; i < n; i++) scanf(" %c%d",&c1[i].egara,&c1[i].value);

  for(i = 0; i <n; i++) c2[i] = c1[i];

  BubbleSort(c1,n);
  SelectionSort(c2,n);

   for(i = 0; i < n; i++){
    if(i == n-1) printf("%c%d\n",c1[i].egara,c1[i].value);
    else printf("%c%d ",c1[i].egara, c1[i].value);
  }
   printf("Stable\n");

    for(i = 0; i < n; i++){
    if(i == n-1) printf("%c%d\n",c2[i].egara,c2[i].value);
    else printf("%c%d ",c2[i].egara, c2[i].value);
  }

    if(isStable(c1, c2, n)) printf("Stable\n");
    else printf("Not stable\n");
   
  return 0;
}

void BubbleSort(C c[36], int n){
  int i,j;
  C temp;

  for(i = 0; i <= n-1; i++){
    for(j = n-1; j >= i+1; j--){
      if(c[j].value < c[j-1].value){
	temp = c[j];
	c[j] = c[j-1];
	c[j-1] = temp;
      } 
    }
  }
}

void SelectionSort(C c[36], int n){
  int i,j,minj;
  C temp;
  
  for(i = 0; i <= n-1; i++){
    minj = i;
    for(j = i; j <= n-1; j++){
      if(c[j].value < c[minj].value) minj = j;
    }
    temp = c[i];
    c[i] = c[minj];
    c[minj] = temp;
  }
}

int isStable(C c1[36], C c2[36], int n){
  int i;

  for(i = 0; i < n; i++){
    if(c1[i].egara != c2[i].egara) return 0;
  }

  return 1;
}



Measured memory_bytes: 2108
#include <iostream>
using namespace std;
int n, m, k;
int main() {
	int i, j;
	cin>>n>>m>>k;
	for(i=0; i<=n; i++) for(j=0; j<=m; j++) {
		if((n-i)*j + (m-j)*i == k) {cout<<"Yes"; return 0;}
	}
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
#N,A,B = map(int,input().split())
#X_list = list(map(int,input().split()))
#X1_list = [int(input()) for i in range(N)]
#X2_list = [list(map(int,input().split())) for i in range(N)]

if N < 10:
    print(N)
elif 10 <= N < 100:
    print(9)
elif 100 <= N < 1000:
    print(9 + N - 99)
elif 1000 <= N < 10000:
    print(909)
elif 10000 <= N < 100000:
    print(909 + N - 9999)
elif 100000 <= N < 1000000:
    print(90909)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int main(void){
	int n;
	cin >> n;
	vector<string> vs = vector<string>(n);
	for(int i = 0;i < n; ++i){
		cin >> vs[i];
	}
	for(int i = n-1; 0 <= i; --i){
		cout << vs[i];
		if(i != 0){
			cout << " ";
		} else {
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> odd(100001);
    vector<int> even(100001);
    for(int i = 0; i < n; i+=2)
    { int a, b;
        cin >> a >> b;
        odd[a]++;
        even[b]++;
    }
    int oddmax = 0;
    int evenmax = 0;
    int oddsecond = 0;
    int evensecond = 0;
    int oddcount = 0;
    int evencount = 0;
    int oddsecondcount = 0;
    int evensecondcount = 0;
    for(int i = 1; i <= 100000; i++)
    {
        if(odd[i] > oddcount)
        {
            oddsecond = oddmax;
            oddsecondcount = oddcount;
            oddmax = i;
            oddcount = odd[i];
        }
        else if(odd[i] > oddsecondcount)
        {
            oddsecond = i;
            oddsecondcount = odd[i];
        }
        if(even[i] > evencount)
        {
            evensecond = evenmax;
            evensecondcount = evencount;
            evenmax = i;
            evencount = even[i];
        }
        else if(even[i] > evensecondcount)
        {
            evensecond = i;
            evensecondcount = even[i];
        }
    }
    if(oddmax != evenmax)
    {
        cout << n - oddcount - evencount << endl;
    }
    else if(oddmax == evenmax)
    {
      cout << min(n - oddcount - evensecondcount, n - evencount - oddsecondcount) << endl;
    }
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(void){
  char a[101],b[101];

  scanf("%s%s",a,b);

  if(strlen(a) > strlen(b)){
    printf("GREATER\n");
  }else if(strlen(a) < strlen(b)){
    printf("LESS\n");
  }else{
    for(int i = 0;i < strlen(a);i++){
      if(a[i] > b[i]){
        printf("GREATER\n");
        return 0;
      }else if(a[i] < b[i]){
        printf("LESS\n");
        return 0;
      }
    }
    printf("EQUAL\n");
  }

  return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    cout << x*32<<"\n";
    }


Measured memory_bytes: 3120
#include<stdio.h>
int main()
{
    char s[100];
    int n,r,i,flag;
    scanf("%d",&n);
    scanf("%s",&s);

    if((n%2)==0)
    {
       r = n/2;
    }
    else
    {
        printf("No\n");
        return 0;
    }

    for(i=0;i<r;i++)
    {
        if(s[i] == s[i+r])
        {
           flag = 1;
        }
        else
        {
            flag = 0;
            printf("No\n");
            return 0;
        }
    }

    if(flag == 1)
        printf("Yes\n");

    return 0;
}


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

const int adx[4] = { -1,0,1,0 };
const int ady[4] = { 0,1,0,-1 };

int main() {
	int N, M; cin >> N >> M;
	vector<vector<int>>field(N, vector<int>(N));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> field[i][j];
		}
	}
	while (M--) {
		int type; cin >> type;
		if (type == 0) {
			int r, c, s, a; cin >> r >> c >> s >> a;
			r--; c--;
			a /= 90;
			for (int i = 0; i < a; ++i) {
				vector<vector<int>>nfield(field);
				
				for (int dx = 0; dx <  s; ++dx) {
					for (int dy = 0; dy < s; ++dy) {
						nfield[r + dy][c + dx] = field[r+s-dx - 1 ][c+dy ];
					}
				}
				field = nfield;
			}
		}
		else if (type == 1) {
			int r, c, s; cin >> r >> c >> s;
			r--; c--;
			{
				vector<vector<int>>nfield(field);

				for (int dx = 0; dx < s; ++dx) {
					for (int dy = 0; dy < s; ++dy) {
						nfield[r + dy][c + dx] = !field[r+dy ][c+dx];
					}
				}
				field = nfield;
			}
		}
		else if (type == 2) {
			int r;
			cin >> r;
			r--; 
			{
				vector<vector<int>>nfield(field);

				rotate(nfield[r].begin(), nfield[r].begin() + 1, nfield[r].end());
				field = nfield;
			}
		}
		else if (type == 3) {
			int r;
			cin >> r;
			r--;
			{
				vector<vector<int>>nfield(field);

				rotate(nfield[r].begin(), nfield[r].begin() + N-1, nfield[r].end());
				field = nfield;
			}
		}
		else {
			int r, c;
			cin >> r >> c;
			r--; c--;
			const int target = field[r][c];
			vector<vector<int>>flag(N,vector<int>(N));
			vector<pair<int, int>>que;
			que.push_back(make_pair(c,r));
			flag[r][c] = true;
			while (!que.empty()) {
				auto p = que.back();
				que.pop_back();
				const int ax = p.first;
				const int ay = p.second;
				for (int way = 0; way < 4; ++way) {
					const int nx = ax + adx[way];
					const int ny = ay + ady[way];
					if (nx >= 0 && nx < N&&ny >= 0 && ny < N) {
						if (!flag[ny][nx] && field[ny][nx] == target) {
							flag[ny][nx] = true;
							que.push_back(make_pair(nx, ny));
						}
					}
					
				}
			}
			{
				vector<vector<int>>nfield(field);

				for (int dx = 0; dx < N; ++dx) {
					for (int dy = 0; dy < N; ++dy) {
						if (flag[dy][dx]) {

							nfield[dy][dx] = !field[ dy][ dx];
						}
					}
				}
				field = nfield;
			}
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {

			cout << field[i][j];
			if (j == N - 1)cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

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

using namespace std;

int N, h[100005];

long long int dp[100005];

int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> h[i];
	}

	for (int i = 1; i <= N; i++) {
		dp[i] = 999999999999;
	}

	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);

	for (int i = 3; i <= N; i++) {
		dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}

	cout << dp[N] << endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 1408
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    k = sum(A)//(N*(N+1)//2)
    if sum(A) % (N*(N+1)//2) != 0:
        return "NO"

    D = [0]*N
    for i in range(N-1):
        D[i] = A[i+1]-A[i]-k
    D[-1] = A[0]-A[-1]-k

    cnt = sum([v//N for v in D])
    if all(x <= 0 and -x % N == 0 for x in D)and -cnt == k:
        return "YES"
    else:
        return "NO"


print(solve())


Measured memory_bytes: 15044
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")

for i in a:
    #右から連続する0の個数分になるように、
    #全体長からrfindのインデックスを引き、０開始なのでさらに１引く。
    #rfind("1")右から数えて1を見つけたインデックスを返す
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)

print(round(ans))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<iomanip>
#include<algorithm>
#include<stdio.h>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<cstdlib>

using namespace std;

int main(void){

	string s,t;
	cin >> s;
	cin >> t;
	for(int i = 0; i < t.size(); i++){
		char c = t[0];
		t.erase(0,1);
		t.push_back(c);
		//cout << t << endl;
		if(t.compare(s) == 0){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
	return 0;
}

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

using namespace std;

int solve(string s, char c) {
    vector <int> v(s.size(), 0);
    for (int i = 0; i < s.size(); ++i) v[i] = (s[i] == c);
    v.push_back(1);
    int cur = 0, ret = 0;
    for (int i = 0; i < v.size(); ++i) if (v[i]) ret = max(ret, cur), cur = 0; else ++cur;
    return ret;
}

int main(void) {
    string s;
    cin >> s;
    int ans = s.size();
    for (char c = 'a'; c <= 'z'; ++c) ans = min(ans, solve(s, c));
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, M, X = MI()
    C = []
    A = []
    for i in range(N):
        tmp = LI()
        C.append(tmp[0])
        A.append(np.array(tmp[1:]))

    ans = INF
    for i in range(1 << N):
        bag = []
        for j in range(N):
            if (i >> j) & 1:
                bag.append(j)
        sm = np.zeros(M)
        c = 0
        for b in bag:
            c = c + C[b]
            a = A[b]
            sm = sm + a
        if np.all(sm >= X):
            ans = min(ans, c)

    if ans != INF:
        print(ans)
    else:
        print(-1)





if __name__ == '__main__':
    solve()


Measured memory_bytes: 27280
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int s, w;
    cin >> s >> w;
    if (w >= s)
        cout << "unsafe";
    else
        cout << "safe";
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <climits>
#include <cmath>
#define endl '\n'
#define ll long long

using namespace std;
ll max(ll a, ll b) { return a > b ? a : b;}
int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    ll A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    ll ret = LLONG_MAX;
    
    for(int i = 0; i < 2000001; i += 2)
    {
        ll A_pizza = max(0, X - i / 2);
        ll B_pizza = max(0, Y - i / 2);
        ll total = A_pizza * A + B_pizza * B + i * C;
        ret = min(ret, total);
    }
    cout << ret << endl;
    return 0;
}


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

int N, M;
vector<vector<int>> G;

int dp[100100];
int rec(int v) {
    if (dp[v] != -1) {
        return dp[v];
    } 

    int res = 0;
    for (auto nv : G[v]) {
        res = max(res, rec(nv) + 1);
    }
    return dp[v] = res;
}

int main() {
    cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; i++) {
        int x, y; cin >> x >> y;
        --x, --y;
        G[x].push_back(y);
    }

    for (int v = 0; v < N; v++) {
        dp[v] = -1;
    }

    int res = 0;
    for (int v = 0; v < N; v++) {
        res = max(res, rec(v));
    }
    cout << res << endl;
}



Measured memory_bytes: 8192
N,K = map(int,input().split())
cnt = 0
for b in range(1,N+1):
    p = int(N/b)
    r = N%b
    cnt += max(0,b-K)*p + max(0, r-K+1)
    #print(b,cnt)
    if K==0:
        cnt -= 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N;
    cin >> N;
    ll avg = 0;
    vll x(N);
    rep(i, N) {
        cin >> x[i];
        avg += x[i];
    }
    avg /= N;

    ll ans = INF;
    for(int i = -1; i <= 1; i++) {
        ll m = avg + i;
        ll tmp = 0;
        rep(i, N) tmp += pow(x[i] - m, 2);
        chmin(ans, tmp);
    }
    cout << ans << endl;
}


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

void Main()
{
  int N;
  cin >> N;
  vector<int> t(N), x(N), y(N);
  int curX = 0, curY = 0, curT = 0;
  rep(i,N) {
    cin >> t[i] >> x[i] >> y[i];
  }
  rep(i,N) {
    int dx = abs(x[i]-curX);
    int dy = abs(y[i]-curY);
    if (dx + dy <= t[i]-curT && (t[i]-curT-dx-dy)%2==0) ;
    else {cout << "No" << endl; return;}
    curX = x[i];
    curY = y[i];
    curT = t[i];
  }
  cout << "Yes" << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){

	int a, b, C;
	cin >> a >> b >> C;

	double pi, S, L, h;

	pi = atan(1.0) * 4.0;

	h = b * sin(pi * C / 180);

	S = a * h / 2;

	L = a + b + sqrt(pow(a - b * cos(pi * C / 180), 2) + pow(h, 2));

	cout << fixed << S << endl;
	cout << fixed << L << endl;
	cout << fixed << h << endl;

	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for(ll i=(ll)(srt); i<(ll)(end); i++)

int main(){
    string s;
    cin>>s;
    int n = s.size()-1;
    ll ans=0;

    for(int i=0;i<(1<<n);i++){

        ll ver = s[0] - '0';
        for(int j=0; j<n; j++){
            if(i & (1<<j)){
                ans+=ver;
                ver=0;
            }
            ver=ver*10+s[j+1]-'0';
        }

        ans+=ver;
    }

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

Measured memory_bytes: 256
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;

int main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	int cntX = 0, cntY = 0, priceX = 0, priceY = 0;
	while (cntX < n) {
		cntX += a;
		priceX += b;
	}
	while (cntY < n) {
		cntY += c;
		priceY += d;
	}
	cout << min(priceX, priceY) << endl;
}


Measured memory_bytes: 3108
N, M = map(int,input().split())
s = []
c = []
for i in range(M):
  S, C = map(int,input().split())
  s.append(S)
  c.append(C)


for i in range(10 ** (N + 1)):
  Str = str(i)

  if len(Str) == N and all([Str[s[j] - 1] == str(c[j]) for j in range(M)]):
      print(Str)
      exit()

print(-1)

Measured memory_bytes: 67068
#include <iostream>
#include <string.h>
using namespace std;

int main(void)
{
  char s[3][101];
  char last;
  int c[3] = {0};
  int turn = 0;
  int win = 0;
  
  cin >> s[0];
  cin >> s[1];
  cin >> s[2];
  
  while ( 1 ) {
    if ( c[win] > strlen(s[win]) ) {
      break;
    }
    win = turn;
    turn = s[turn][c[turn]] - 'a';
    c[win]++;
  }
  switch ( win ) {
  case 0:
    cout << "A" << endl;
    break;
  case 1:
    cout << "B" << endl;
    break;
  case 2:
    cout << "C" << endl;
    break;
  default:
    cout << "?" << endl;
    break;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

def isOk(index, key, a):
    if a[index] >= key:
        return True
    else:
        return False

def binary_search(key, a):
    ng = -1
    ok = len(a)

    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if isOk(mid, key, a):
            ok = mid
        else:
            ng = mid

    return ok

ans = 0
a.sort()
c.sort()
for i in range(n):
    upper = binary_search(b[i], a)
    lower = n - binary_search(b[i] + 1, c)
    ans += upper * lower
print(ans)


Measured memory_bytes: 23220
#include<iostream>

using namespace std;

int H[1000000], W[1000000];

int main(){

	for (int a = 0; a < 1000000; a++){


		cin >> H[a] ;
		cin >> W[a];

		if (H[a] == 0 && W[a] == 0)break;
		for (int n = 0; n < W[a]; n++){
			cout << "#";
		}cout << endl;

		for (int n = 2; n < H[a]; n++){



			cout << "#";

		for (int n=2; n < W[a]; n++){
			cout << ".";
		}             
		
		cout << "#";
		
		cout << endl;
		
		
		}
		for (int n = 0; n < W[a]; n++){
			cout << "#";
		}cout << endl;

		cout << endl;


	}









	return 0;
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
long long nature(long long a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
int main(){
  #define int long long
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x1=a,x2=1,x3=b;
  if(a<=0 && b>=0){x2==0;}
  int y1=c,y2=1,y3=d;
  if(c<=0 && d>=0){y2==0;}
  int ans=-1000000000000000000;
  if(x2==0 && y2==0){
    ans=max(ans,x1*y1);
    ans=max(ans,x2*y1);
    ans=max(ans,x3*y1);
    ans=max(ans,x1*y2);
    ans=max(ans,x2*y2);
    ans=max(ans,x3*y2);
    ans=max(ans,x1*y3);
    ans=max(ans,x2*y3);
    ans=max(ans,x3*y3);
  }
  if(x2==1 && y2==0){
    ans=max(ans,x1*y1);
    //ans=max(ans,x2*y1);
    ans=max(ans,x3*y1);
    ans=max(ans,x1*y2);
    //ans=max(ans,x2*y2);
    ans=max(ans,x3*y2);
    ans=max(ans,x1*y3);
    //ans=max(ans,x2*y3);
    ans=max(ans,x3*y3);
  }
  if(x2==0 && y2==1){
    ans=max(ans,x1*y1);
    ans=max(ans,x2*y1);
    ans=max(ans,x3*y1);
    //ans=max(ans,x1*y2);
    //ans=max(ans,x2*y2);
    //ans=max(ans,x3*y2);
    ans=max(ans,x1*y3);
    ans=max(ans,x2*y3);
    ans=max(ans,x3*y3);
  }
  if(x2==1 && y2==1){
    ans=max(ans,x1*y1);
    //ans=max(ans,x2*y1);
    ans=max(ans,x3*y1);
    //ans=max(ans,x1*y2);
    //ans=max(ans,x2*y2);
    //ans=max(ans,x3*y2);
    ans=max(ans,x1*y3);
    //ans=max(ans,x2*y3);
    ans=max(ans,x3*y3);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a,b,v,w,t;
  cin >> a >> v >> b >> w >> t;
  if(t*abs(v-w) >= abs(a-b) && v >= w){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
const int max0=200100;
struct branch{
    int x,y,a;
}data[max0],mapx[2*max0];
int min0[max0],truemin[max0];
int top0,top1,delta;
bool R=1;
bool v[max0];
int dpt[max0];
int cl[max0],cc;
int bg[max0];
int bfs[max0],top2,btt;
int r,c,n,i;
bool cmp(branch a,branch b){
    if(a.x<b.x)return 1;
    if(a.x>b.x)return 0;
    if(a.y<b.y)return 1;
    if(a.y>b.y)return 0;

    //if(a.a!=b.a)R=0;
    if(a.a<b.a)return 1;
    if(a.a>b.a)return 0;
    return 0;
}
int main(){
    scanf("%d%d%d",&r,&c,&n);
    for(i=0;i<n;i++){
        scanf("%d%d%d",&data[top0].x,&data[top0].y,&data[top0].a);
        top0++;
    }
    for(i=1;i<=c;i++)min0[i]=-1;
    sort(data,data+top0,cmp);
    top1=1;
    if(R){
        for(i=0;i<n;i++)
            if(min0[data[i].y]==-1||data[i].a<min0[data[i].y])
                min0[data[i].y]=data[i].a;
        for(i=1;i<n;i++)
            if(R&&data[i].x==data[i-1].x){
                mapx[top1].x=data[i-1].y;
                mapx[top1].y=data[i].y;
                delta=data[i].a-data[i-1].a;
                mapx[top1].a=delta;
                top1++;
                mapx[top1].x=data[i].y;
                mapx[top1].y=data[i-1].y;
                mapx[top1].a=-delta;
                top1++;
            }
    }
    if(R){
        sort(mapx+1,mapx+top1,cmp);
        for(i=1;i<top1;i++)
            if(bg[mapx[i].x]==0)bg[mapx[i].x]=i;
        for(i=1;R&&i<=c;i++)
            if(!v[i]){
                cc=i;cl[i]=cc;
                v[i]=1;bfs[top2++]=i;
                while(R&&btt<top2){
                    for(int j=bg[bfs[btt]];j<top1&&mapx[j].x==bfs[btt];j++){
                        if(v[mapx[j].y]){
                            if(dpt[mapx[j].y]-dpt[mapx[j].x]!=mapx[j].a)R=0;
                        }
                        else{
                            v[mapx[j].y]=1;
                            cl[mapx[j].y]=cc;
                            bfs[top2++]=mapx[j].y;
                            dpt[mapx[j].y]=dpt[mapx[j].x]+mapx[j].a;

                            if(dpt[mapx[j].y]<truemin[cc])
                                truemin[cc]=dpt[mapx[j].y];
                        }
                    }
                    btt++;
                }
            }
    }
    if(R)
    for(i=1;i<=c;i++)
        if(min0[i]!=-1&&min0[i]-dpt[i]+truemin[cl[i]]<0)R=0;
    if(R)printf("Yes\n");
    else printf("No\n");
	return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

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

	cout << max(max(A + B, A + A - 1), B + B - 1) << endl;

	return 0;
}

Measured memory_bytes: 256