akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String[] args) throws IOException {
		MScanner sc = new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int ans=0;HashSet<Character>acgt=new HashSet<Character>();
		acgt.add('A');acgt.add('C');acgt.add('G');acgt.add('T');
		char[]in=sc.nextLine().toCharArray();
		for(int i=0;i<in.length;i++) {
			int c=0;
			for(int j=i;j<in.length;j++) {
				if(!acgt.contains(in[j])) {
					break;
				}
				c++;
			}
			ans=Math.max(c, ans);
		}
		pw.println(ans);
		pw.flush();
 
	}
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
  int N,oldx=0,oldy=0,oldt=0,newx,newy,newt;
	cin>>N;
	REP(i,N){
		cin>>newt>>newx>>newy;
		int tem=abs(newx+newy-oldx-oldy);
		int tem2=abs(newt-oldt);
		if((tem2<tem)||((tem2-tem)%2==1)){
			print("No");
			return 0;
		}
		oldx=newx;
		oldy=newy;
		oldt=newt;
	}
	print("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

long long k;
queue<long long> q;

int s2i(string c){
  if(c=="1"){
    return 1;
  }else if(c=="2"){
    return 2;
  }else if(c=="3"){
    return 3;
  }else if(c=="4"){
    return 4;
  }else if(c=="5"){
    return 5;
  }else if(c=="6"){
    return 6;
  }else if(c=="7"){
    return 7;
  }else if(c=="8"){
    return 8;
  }else if(c=="9"){
    return 9;
  }else{
    return 0;
  }
}

long long lunlun(){
  long long x;
  int y;
  string s;
  x=q.front();
  q.pop();
  s=to_string(x);
  s=*(s.end()-1);
  y=s2i(s);
  if(y!=0)q.push(x*10+y-1);
  q.push(x*10+y);
  if(y!=9)q.push(x*10+y+1);
  return x;
}

int main() {
  long long val;
  for(long long i=1;i<10;i++)q.push(i);
  cin>>k;
  for(int i=1;i<k+1;i++){
    val=lunlun();
    if(i==k)cout<<val<<endl;
  }
}


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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multi_set;

#define mod         1000000007
#define pi          acos(-1.0)
#define eps         1e-9


#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define unique(c) (c).resize(unique(all(c)) - (c).begin())
#define itn int

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;
typedef vector<vector<LL> > matrix;
typedef vector<vector<int> > graph;
LL INF=1e9;

string grid[1000];
LL dp[1005][1005];

LL func(int i,int j)
{
    if(i==0 and j==0)
        return 1;
    LL &r=dp[i][j];
    if(r!=-1)
        return r;
    LL ans1=0;
    LL ans2=0;
    if(i-1>=0 and grid[i-1][j]!='#')
        ans1=func(i-1,j);
    if(j-1>=0 and grid[i][j-1]!='#')
        ans2=func(i,j-1);
    return r=(ans1+ans2)%mod;
}
void solve()
{
    int h,w;
    cin>>h>>w;
    setneg(dp);
    REP(i,0,h-1)
        cin>>grid[i];
    cout<<func(h-1,w-1)<<nl;
}
int main()
{
    fast;
        solve();
}


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

main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);cin.tie(NULL);

    int n,m;cin>>n>>m;
    string a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    
    const int MOD=1e9+7;
    
    int dp[n][m];
    memset(dp,0,sizeof(dp));

    dp[n-1][m-1]=1;
    for(int i=n-1;i>=0;i--){
        for(int j=m-1;j>=0;j--){
            if(a[i][j]=='#')    continue;
            if(i+1<n){
                dp[i][j]+=dp[i+1][j];
                dp[i][j]%=MOD;
            }
            if(j+1<m){
                dp[i][j]+=dp[i][j+1];
                dp[i][j]%=MOD;   
            }
        }
    }
    cout<<dp[0][0]<<"\n";
}

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

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

	vector <string> v = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string s;

	cin >> s;

	int res = 0;
	for(int i=0;i<v.size();i++)
	{
		if(s==v[i])
		{
			res = 7 - i;
			break;
		}
	}	

	cout << res << '\n';
	
	return 0;
}


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

using namespace std;

#define endl "\n"
typedef long long int ll;
#define f first
#define s second

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;

ll INF = 1e10;
int MOD = 1e9+7;

ll ABS(ll x){
    if(x < 0)
        return (-1LL)*x;
    else
        return x;
}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("debug.txt", "w", stderr);
    #endif
    fastio();
    
    ll x, k, d;
    cin >> x >> k >> d;
    ll step = ABS(x) / d;
    dbg(step);
    if(k <= step){
        cout << ABS(x) - k*d;
        return 0;
    }
    ll remain = k - step;
    if(remain % 2 == 0){
        cout << ABS(ABS(x) - step*d);
    }
    else{
        cout << ABS(d - ABS(ABS(x) - step*d));
    }
    return 0;
}


Measured memory_bytes: 3640
X, N = map(int,input().split())
A = list(map(int, input().split()))
dist = []
for i in range(N): 
    if i < N-1: 
        dist.append(X-(A[i+1]-A[i])) 
    else: 
        dist.append(X-(X-A[N-1]+A[0]))

print(min(dist))



Measured memory_bytes: 86220
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	double a,b,h,m;
	scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
	double deg=(h+m/60)*360/12,deg2=m*360/60,deg3=min(abs(deg-deg2),abs(360-deg)+abs(360-deg2));
	//printf("%lf %lf %lf\n",deg,deg2,deg3);
	printf("%.10lf\n",sqrt(a*a+b*b-2*a*b*cos(deg3*acos(-1)/180)));
}

Measured memory_bytes: 2592
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = null;
        try {
            sc = new Scanner(System.in);
            while (sc.hasNextInt()) {
                int targetThing = sc.nextInt();
                int weight = 512;

                Deque<Integer> result = new LinkedList<Integer>();

                while (targetThing > 0) {
                    if (weight > targetThing) {
                        weight /= 2;
                    } else {
                        targetThing -= weight;
                        result.push(weight);
                    }
                }
                print(result);
            }
        } finally {
            sc.close();
        }
    }

    public static void print(Deque<Integer> deque) {
        StringBuilder sb = new StringBuilder();
        for (int num : deque) {
            sb.append(num).append(" ");
        }
        System.out.println(sb.toString().trim());
    }
}

Measured memory_bytes: 26184
#include <iostream>
using namespace std;
int main() 
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N,K; cin >> N >> K;
    vector<ll> v(N);
    rep(i,N) cin >> v[i];

    ll ans = 0;
    for(int l=0;l<=N;l++){
        for(int r=0;l+r<=N;r++){
            int cost = l + r;
            if(cost > K) break;
            /* cout << l << " " << r << endl; */
            ll val = 0;
            for(int i=0;i<l;i++) val += v[i];
            for(int i=0;i<r;i++) val += v[N-1-i];
            /* debug(val); */

            vector<ll> m;
            for(int i=0;i<l;i++) if(v[i] < 0) m.emplace_back(v[i]);
            for(int i=0;i<r;i++) if(v[N-1-i] < 0) m.emplace_back(v[N-1-i]);

            sort(all(m));
            //reverse(all(m));
            /* cout << m << endl; */
            for(int i=0;i<K-cost;i++){
                if(i >= m.size()) break;
                val -= m[i];
            }
            /* cout << val << endl; */
            /* cout << endl; */
            ans = max(ans,val);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = input()

if n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9":
    print("hon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9052
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n,m;
        n = cin.nextInt();
        m = cin.nextInt();
        int sum = 0;
        for(int i= 0;i < m;i++){
            sum += cin.nextInt();
        }
        if(sum > n){
            System.out.println(-1);
        }
        else{
            System.out.println(n-sum);
        }
    }
}


Measured memory_bytes: 46420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

//逆元(素数MOD)
long long inverse(long long b){
  long long r=1,e=MOD-2;
  while(e){
      if(e&1){
          r=(r*b)%MOD;
      }
      b=(b*b)%MOD;
      e >>=1;
  }
  return r;
}


int main(void){
    ll S;
    cin >> S;
    
    ll Ans=0;
    OREP(i,S/3){
        ll M=S-3*i;
        
        ll num=1;
        REP(j,i-1){
            num=(num*(M+j+1))%MOD;
            num=(num*inverse(j+1))%MOD;
        }
        
        Ans=(Ans+num)%MOD;
        //cout << M MM num << endl;
    }
    cout << Ans << endl;
    return 0;
}



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

int main() {
    
    double d, t, s, ans;

    cin >> d >> t >> s;

    ans = d / s;
    if(t < ans) cout << "No";
    else cout << "Yes";
    
    return 0;
}


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

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

    ll n,k;
    cin>>n>>k;

    vector<ll>h(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin>>h[i];
    }

    vector<ll>cost(n+5);
    cost[1]=0;

    for(ll i=2;i<=n;i++)
    {
        ll c=LONG_MAX;
        for(ll j=i-1;j>i-k-1&&j>0;j--)
        {
            c=min(c,cost[j]+abs(h[i]-h[j]));
        }
        cost[i]=c;
    }

    cout<<cost[n]<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  std::array<i64, 5> dishes;
  tools::read(dishes);

  std::sort(dishes.begin(), dishes.end(), [](const i64& x, const i64& y) {
    return (x - 1) % 10 + 1 > (y - 1) % 10 + 1;
  });
  std::transform(dishes.begin(), dishes.end() - 1, dishes.begin(), [](const i64& dish) {
    return tools::ceil<i64>(dish, 10) * 10;
  });
  std::cout << std::accumulate(dishes.begin(), dishes.end(), static_cast<i64>(0)) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define FASTI0 ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
    int n,x;
    cin>>n;
    vector<int>v;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    int sum=0;
    for(int i=1;i<n;i++)
    {
        if(v[i]<v[i-1])
        {
            sum+=abs(v[i]-v[i-1]);
            v[i]=v[i-1];
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 5296
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main( void ) 
{
    int n;
    while ( cin >> n ) {
        vector <int> T(n);
        for ( int i = 0; i < n; i++ ) cin >> T[i];

        sort( T.begin(), T.end() );
        int s = 0, t = 0;
        for ( int i = 0; i < n; i++ ) {
            s += T[i] + t;
            t += T[i];
        }

        cout << s << endl;
    }
    return 0;
}

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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
// const int MAXV = (100);
const int MAXV = (100 * 1000 + 1);

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("d.3", "r", stdin);

  int N, W;
  cin >> N >> W;
  vector<ll> dp(MAXV + 1, INF);
  vector<ll> weight(N + 1);
  vector<ll> value(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> weight[i] >> value[i];
  }
  dp[0] = 0;
  for (int i = 1; i <= N; i++) {
    for (int v = MAXV; 0 <= v; v--) {
      if (value[i] <= v)
        dp[v] = min(dp[v - value[i]] + weight[i], dp[v]);
    }
    // dumpv(dp);
  }
  ll ans = 0;
  for (int v = 0; v <= MAXV; v++) {
    if (dp[v] <= W)
      ans = v;
  }
  cout << ans << endl;
  return 0;
}


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

long long n,a,b,ans,x[100001];

int main()
{
	std::cin>>n>>a>>b;
	
	for(re i=1;i<=n;i++)
		std::cin>>x[i];
		
	for(re i=1;i<n;i++)
		ans+=std::min(a*(x[i+1]-x[i]),b);

	std::cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
 
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
#define db double
db a[233], b[233];
db cal(db x) {
  db ans = 0.0;
  rep (i, 6)
    ans += max(a[i] * x, b[i] * (1.0 - x));
  return ans;       
}

int main(void) {
  rep (i, 6) cin >> a[i], a[i] /= 100.0;
  rep (i, 6) cin >> b[i], b[i] /= 100.0;
  db l = 0.0, r = 1.0;
  rep (_, 100) {
    db lc = l + (r - l) / 3.0;
    db rc = l + (r - l) / 3.0 * 2.0;
    if (cal(lc) < cal(rc)) r = rc;
    else l = lc;
  }
  printf("%.10f\n", cal(r));
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll (i)=0;(i)<(n);(i)++)

bool is(string s, int i, int j) {
    for (int l = 0; l <= j - i; l++) {
        if (s[l + i] != s[j - l]) {
            return false;
        }
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    int n;
    n = s.size();
    if (is(s, 0, (n - 1) / 2 - 1) && is(s, 0, n - 1) && is(s, (n + 3) / 2 - 1, n - 1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    string s;
    cin >> s;

    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
        cout <<"Bad"<<endl;
    }else{
        cout<<"Good"<<endl;
    }


    return 0;

}


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

using namespace std;
string s;
int k;

int main() {
    cin >> s >> k;
    for (int i = 0; i < s.length(); i++) {
        int n = 'z' - s[i] + 1;
        if (n <= k && n != 26) {
            s[i] = 'a';
            k -= n;
        }
        if (i == (s.length() - 1)) {
            s[i] += k % 26;
        }
    }
    for (int i = 0; i < s.length(); i++) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys


def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"):
    ans = [0]*(N)
    for k in range(N-1):
        cst = S[k]+C[k]
        for i in range(k+1,N-1):
            if(cst < S[i]):
                cst = max(cst, S[i])
            elif(cst%F[i] == 0):
                cst = cst
            else:
                cst = cst + F[i] - (cst%F[i])
            cst += C[i]
        ans[k] = cst

    for i in ans:
        print(i)

    return

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    global N, C, S, F
    N = int(next(tokens))  # type: int
    C = [int()] * (N-1)  # type: "List[int]" 
    S = [int()] * (N-1)  # type: "List[int]" 
    F = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        C[i] = int(next(tokens))
        S[i] = int(next(tokens))
        F[i] = int(next(tokens))
    solve(N, C, S, F)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
using System;
class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
        string t = Console.ReadLine();
        for(int i=0; i<s.Length; i++){
            if(s[i] != t[i]) {
                Console.WriteLine("No");
                return;
            } 
        }
        Console.WriteLine("Yes");
	}
}

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


void solve(std::string S, std::string T){
    long long ans = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] != T[i]) ans++;
    }
    cout << ans << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 4124
#pragma GCC optimize "-O3"

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* Starry Sky Tree */
//0-index

struct StarrySkyTree{
  typedef ll Type;
  int segn2;
  vector<Type> data, s_data;

  StarrySkyTree(int n) {
    for(segn2=1; segn2<n; segn2*=2);
    data.assign(segn2*2, 0);
    s_data.assign(segn2*2, 0);
  }

  //get value of [a,b)
  Type query(int a, int b, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(r <= a || b <= l) return LLINF; //大きさに注意
    if(a <= l && r <= b) return data[k] + s_data[k];
    return min(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2 , r, k*2+2)) + s_data[k];
  }

  //add x to [a,b)
  Type add(int a, int b, Type x, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(a <= l && r <= b)
      s_data[k] += x;
    else if(a < r && l < b)
      data[k] = min(add(a, b, x, l, (l+r)/2, k*2+1), add(a, b, x, (l+r)/2, r, k*2+2));

    return data[k] + s_data[k];
  }

  Type val(int x){
    Type res = 0;
    x += segn2 - 1;

    while(x){
      res += s_data[x];
      x = (x-1)/2;
    }

    return res;
  }

  void add(int a, Type x){
    a += segn2 - 1;
    s_data[a] += x;

    while(a){
      a = (a-1)/2;
      data[a] = min(data[a*2+1] + s_data[a*2+1], data[a*2+2] + s_data[a*2+2]);
    }
  }
};

int main(){
  int N, A, B, p;

  scanf("%d%d%d", &N, &A, &B);

  StarrySkyTree seg(N+1);

  for(int i=0;i<N;i++){
    scanf("%d", &p);

    seg.add(p, seg.query(0, p) - seg.val(p));
    seg.add(0, p, A);
    seg.add(p+1, N+1, B);
  }

  ll ans = seg.query(0, N+1);

  cout << ans << endl;

  return 0;
}


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

using namespace std;
long long N,K,ans=1;
int main()
{
     cin>>N>>K;
     
     
     for(int i=0;i<N;i++)
     {
     	
     	ans+=min(ans,K);
     	
     	
     }
     
     
     
     
     
     
     
     cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	vi xs(5);
	REP(i, 5) cin >> xs[i];
	REP(i, 5) {
		if (i + 1 != xs[i]) {
			cout << i + 1 << endl;
		}
	}
}

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


Measured memory_bytes: 3616
#!/usr/bin/python3

import sys

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())
S = input()
#D = list(map(int, input().split()))

alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

# ord and chr
asciiA = ord('A')

def ord_rel_a(c):
    return ord(c) - asciiA

def chr_rel_a(i):
    j = i + asciiA
    return chr(j)

iZ = ord_rel_a('Z')

Shift = ""

for c in S:
    i = ord_rel_a(c)
    j = (i + N) % (iZ+1)
    Shift += chr_rel_a(j)

print(Shift)


Measured memory_bytes: 3064
def main():
    n = [int(i) for i in input().split()]
    bridge = set()
    counter = 0
    reqs = [[int(j) for j in input().split()] for i in range(n[1])]
    reqs.sort(key=lambda x:(x[0],x[1]))
    prefix = 0
    
    for i in range(1, n[0]+1):
        if i in bridge:
            bridge.clear()
            counter += 1
        for j in range(prefix, len(reqs)):
            if reqs[j][0] == i:
                bridge.add(reqs[j][1])
            else:
                prefix = j
                break
    
    print(counter)
 
main()

Measured memory_bytes: 30192
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace std;
char _;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#ifdef _getchar_nolock
#define getchar _getchar_nolock
#endif
#ifdef _putchar_nolock
#define putchar _putchar_nolock
#endif
#ifdef getchar_unlocked
#define getchar getchar_unlocked
#endif
#ifdef putchar_unlocked
#define putchar putchar_unlocked
#endif
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
template <typename t> void scan (t& x) {do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0);}
void scan(pii &x) {scan(x.first); scan(x.second);}
template <typename t, typename ...r> void scan (t& x, r&... xs) {scan(x); scan(xs...);}
const int MN = 1e5+2, MM = 1e6+2, MOD = 1e8, BASE = 131;
int fpow (int base, int ex) {int res = 1;while (ex) {if (ex&1) res = res*1LL*base%MOD;base = base*1LL*base%MOD;ex>>=1;}return res;}
ll lcm (ll a, ll b) {return a*b/__gcd(a,b);}
int moddiv (int a, int b) {return a*1LL*fpow(b,MOD-2)%MOD;}
multiset<int,greater<int>> have;
multiset<int> need;
vector<int> nu;
int main () {
    int n,a;
    scan(n);
    for (int i = 0; i < (1 << n); i++) {
        scan(a);
        need.insert(a);
    }
    auto it = --need.end();
    have.insert(*it);
    need.erase(it);
    for (int i = 1; i <= n; i++) {
        nu.clear();
        for (int j : have) {
            it = need.lower_bound(j);
            if (it == need.begin()) return !printf ("No\n");
            --it;
            nu.push_back(*it);
            need.erase(it);
        }
        for (int j : nu) have.insert(j);
    }
    printf ("Yes\n");
}

Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
int n,k,now=0,g=0;
int gcd(int a,int b)
{
    if(a==0)
        return b;
    return gcd(b%a,a);
}
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        now=max(now,a);
        g=gcd(g,a);
    }
    if(k<=now&&k%g==0)
        cout<<"POSSIBLE";
    else
        cout<<"IMPOSSIBLE";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
		int Slen = S.length();
		
		for (int i=Slen-2; i>0; i-=2) {
			String Ssub = S.substring(0, i);
			String Ssub_1 = Ssub.substring(0, i/2);
			String Ssub_2 = Ssub.substring(i/2, i);
			if (Ssub_1.equals(Ssub_2)) {
				System.out.println(i);
				break;
			}
		}
	}

}


Measured memory_bytes: 21844
N, Q = [int(nq) for nq in input().split()]
AB = []
for i in range(N):
  AB.append([])
for i in range(N - 1):
  a, b = [int(ab) for ab in input().split()]
  AB[a - 1].append(b)
  AB[b - 1].append(a)

P, X = [], []
for j in range(Q):
  p, x = [int(px) for px in input().split()]
  P.append(p)
  X.append(x)

Score = [0] * N
for j in range(Q):
  Score[P[j] - 1] += X[j]

Exists = [0] * N

Now = []
Next = [1]
Exists[1 - 1] = 1

while Next != []:
  Now = Next
  Next = []
  for nw in Now:
    for nxt in AB[nw - 1]:
      if Exists[nxt - 1] == 0:
        Exists[nxt - 1] = 1
        Score[nxt - 1] += Score[nw - 1]
        Next.append(nxt)

print(*Score)

Measured memory_bytes: 71244
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,m,k;
int a[3010][3010];
int dp[3010][3010][4];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>m>>k;
    rep(i,k){
        int r,c,v;
        cin>>r>>c>>v;
        a[r][c]=v;
    }
    rep(i,n+1)rep(j,m+1)rep(l,4)dp[i][j][l]=-1;
    dp[1][1][0]=0;
    if(a[1][1]>0)dp[1][1][1]=a[1][1];
    rep(i,n+1){
        rep(j,m+1){
            rep(l,4){
                if(dp[i][j][l]==-1)continue;
                {
                    if(i+1<=n&&a[i+1][j]>0){
                        chmax(dp[i+1][j][1],dp[i][j][l]+a[i+1][j]);
                    }
                    chmax(dp[i+1][j][0],dp[i][j][l]);
                }
                {
                    if(j+1<=m&&a[i][j+1]>0&&l<=2){
                        chmax(dp[i][j+1][l+1],dp[i][j][l]+a[i][j+1]);
                    }
                    chmax(dp[i][j+1][l],dp[i][j][l]);
                }
            }
        }
    }
    int ans=0;
    rep(l,4)chmax(ans,dp[n][m][l]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 356420
#include <iostream>                                             
#include <string>                                               
using namespace std;                                            
                                                                
int main() {                                                    
  string str;                                                   
  int m;                                                        
  while (true) {                                                
    cin >> str;                                                 
    if (str=="-") {                                             
      break;                                                    
    }                                                           
    cin >> m;                                                   
    string x, y;                                                
    for (int i=0; i<m; i++) {                                   
      int h;                                                    
      cin >> h;                                                 
      x = str.substr(0,h);                                      
      y = str.substr(h);                                        
      str = y+x;                                                
    }                                                           
    cout << str << endl;                                        
  }                                                             
  return 0;                                                     
}                                                               
                                                                
                                                                
                                                                
                    

Measured memory_bytes: 3152
#include<stdio.h>

#define WHITE 1
#define BLACK 2
#define GRAY 3
#define INF -1

#define N 101

void bfs(int);

//queue

int dequeue(void);
void enqueue(int);

int G[N][N];
int Q[N];
int color[N],d[N];

int tail=0,head=0;
int num;
int num_element=0;
int length=N;


int main(){
  int i,j;
  int k,v,u;
  int start = 1;
  

  scanf("%d",&num);
  //printf("%d\n",num);

  for(i=1;i<=num;i++){
    for(j=1;j<=num;j++){
      G[i][j] = -1;
    }
  }
  
  for(i=1;i<=num;i++){
    scanf("%d%d",&u,&k);
    //printf("%d    %d\n",u,k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      G[u][v] = 1;
    }
  }

  /*
  for(i=1;i<=num;i++){
    for(j=1;j<=num;j++){
      printf("%d ",G[i][j]);
    }
    printf("\n");
  }
  */

  bfs(start);

  

  for(i=1;i<=num;i++){
    printf("%d %d\n",i,d[i]);
  }

  return 0;

}



void bfs(int s){
  int u;
  int i,j;
  int v;
  
  //each vertex u in V - {s}
  for(i=1;i<=num;i++){
    color[i] = WHITE;
    d[i] = INF;
  }
  color[s] = GRAY;
  d[s] = 0;

  //Q = empty;
  for(i=0;i<num;i++) Q[i] = 0;
  
  enqueue(s);
  
  while(tail != head){
    
    u = dequeue();

    //each v in adj[u]
    for(v=1;v<=num;v++){
      if(G[u][v] == -1) continue;
      if(color[v] == WHITE){
	color[v] = GRAY;
	d[v] = d[u]+1;
	enqueue(v);
      }
    }

    color[u] = BLACK;

  }
}


int dequeue(void){
  int x;

  x = Q[head];
  
  if(head + 1 == length){
    head = 0;
  }

  else head = head + 1;

  num_element--;
  
  return x;
}

void enqueue(int x){
  Q[tail] = x;
  
  if(tail + 1 == length) tail = 0;

  else tail = tail + 1;

  num_element++;
}

  



Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int gcd(int a,int b);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int k,tmp;
	long long int sum=0;
    cin>>k;
    for(int a=1;a<=k;a++){
    	for(int b=1;b<=k;b++){
    		tmp=gcd(a,b);
    		for(int c=1;c<=k;c++){
    			sum+=gcd(tmp,c);
			}
		}
	}
	cout<<sum;
    
//system("pause");
return 0;

}

int gcd(int a,int b){
	int t;
	while(b!=0)
        {
            t=b;
            b=a%b;
            a=t;
        }
    return a;
}


Measured memory_bytes: 3608
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long k = sc.nextInt();
        int mod = 1000000007;
        long ans = 0;

        for(long i=k; i<=n+1;i++) {
            long min = sum(i-1);
            long max = sum(n) - sum(n-i);
            long sa = max - min;
            sa++;
            ans = (ans + sa);
        }
        ans = ans % mod;
        System.out.println(ans);
    }
    public static long sum(long n) {
        long ans = n*(n+1)/2;
        //累積和
        return ans;
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> card_num(N);
  for (int i=0; i < N; i++){
    cin >> card_num.at(i);
  }
  sort(card_num.begin(),card_num.end());
  reverse(card_num.begin(),card_num.end());
  int score = 0;
  for (int i=0; i < N; i++){
    score += (i%2==0)*card_num.at(i)-(i%2==1)*card_num.at(i);
  }
  cout << score << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int A, B;
  cin >> A >> B;
  
  if( A+B > A-B && A+B > A*B){//最大なんだからA+Bが大きくなる全てのケースを挙げないと
    cout << A+B;
  } else if( A*B > A-B && A*B > A+B){
    cout << A*B;
  } else
    cout << A-B;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
A=[input() for i in range(N)]
B=[input() for i in range(M)]
flag=0
for i in range(N-M+1):
    for j in range(N-M+1):
        flag2=1
        for x in range(M):
            for y in range(M):
                if A[i+x][j+y]!=B[x][y]:
                    flag2=0
                    break
            if flag2==0:
                break
        if flag2==1:
            flag=1
            break
    if flag==1:
        break
if flag==1:
    print("Yes")
else:
    print("No")


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

int main() {
    ll A, B;
    cin >> A >> B;
    cout << A / __gcd(A, B) * B << endl;
    return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll x,y,a,b,c;
  cin >> x >> y  >> a >> b >> c;
  vector<ll> p(a),q(b),r(c);
  vector<ll> ringo;
  for(int i=0;i<a;i++){
    cin >> p[i];
  }
  sort(p.begin(),p.end(),greater<ll>());
  for(int i=0;i<x;i++){
    ringo.push_back(p[i]);
  }
  for(int i=0;i<b;i++){
    cin >> q[i];
  }
  sort(q.begin(),q.end(),greater<ll>());
  for(int i=0;i<y;i++){
    ringo.push_back(q[i]);
  }
  for(int i=0;i<c;i++){
    cin >> r[i];
    ringo.push_back(r[i]);
  }
  sort(ringo.begin(),ringo.end(),greater<ll>());
  ll ans = 0;
  for(int i=0;i<x+y;i++){
    ans += ringo[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 8816
fun main(args: Array<String>) {
    val mod = 1000000007L
    val n = getInt()
    val m = Array<LongArray>(3) {
        LongArray(n + 1) { 0L }
    }

    m[0][1] = 8L
    m[1][1] = 2L
    m[2][1] = 0L
    (2 .. n).forEach { i ->
        m[0][i] = m[0][i - 1] * 8 % mod
        m[1][i] = (m[0][i - 1] * 2 + m[1][i - 1] * 9) % mod
        m[2][i] = (m[1][i - 1] + m[2][i - 1] * 10) % mod
    }
    println(m[2][n])
}

fun getInt() = readLine()!!.toInt()

Measured memory_bytes: 65208
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
int main()
{
	cin >>n>>m;
	if (n>=10) cout <<m;
	else cout <<m+100*(10-n);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int N, M;
vector<vector<int>> A(0, vector<int>(0));
vector<int> touroku(0);
vector<P> ans(0);  // f:行き先 :0への距離
struct qi{
  int a;
  int b;
  int c;
};
queue<tuple<int,int,int>> lol{};
void dfs(int heyanum, int kyori, int previd) {
  if (ans[heyanum].second<=kyori&&previd!=touroku[heyanum]) {
    return;
  }
  REP(i, A[heyanum].size()) {
    int id = A[heyanum][i];
    if (previd == id) continue;
    if(kyori+1<ans[id].second){
      ans[id] = P(heyanum, kyori + 1);
      touroku[id] = heyanum;
      //tuple<int, int, int> t = make_tuple(id, kyori + 1, heyanum);
      lol.push(make_tuple(id, kyori + 1, heyanum));
      //dfs(id, kyori + 1, heyanum);
    }
    
  }
  if(!lol.empty()){
    tuple<int, int, int> qi = lol.front();
    lol.pop();
    dfs(get<0>(qi), get<1>(qi), get<2>(qi));
  }
}
int main() {
  cin >> N >> M;
  A.resize(N);
  ans.resize(N);
  touroku.resize(N);
  REP(i, N) {ans[i] = P(-1, INF);
    touroku[i] = -1;
  }

  REP(i, M) {
    int a, b;
    cin >> a >> b, a--, b--;
    A[a].push_back(b);
    A[b].push_back(a);
  }
  dfs(0, 0, -1);
  ans[0] = P(0, 0);
  cout << "Yes" << endl;
  REP(i, N-1) { cout << ans[i + 1].first+1 << endl; }
}

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

using namespace std;

#define ll long long
#define debug(n) cerr << #n << ':' << n << endl;
#define MP make_pair
#define pll pair<long long , long long >
#define pii pair<int, int>

template<class T>
void chmax(T&a, const T&b){if(a < b)a = b;}
template<class T>
void chmin(T&a, const T&b){if(a > b)a = b;}

int main(){
  double w,h,x,y;cin >> w >> h >> x >> y;
  cout << fixed << setprecision(10) << (w*h)*0.5 << ' ' << (2*x==w&&2*y==h) << endl;
  return 0;
}


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

int dp[1010][1010];

void LCS(string X, string Y) {
    rep(i, X.size()+1) rep(j, Y.size()+1) dp[i][j] = 0;

    rep(i, X.size()) rep(j, Y.size()) {
        if (X[i] == Y[j]) dp[i+1][j+1] = max({dp[i][j]+1, dp[i][j+1], dp[i+1][j]});
        else dp[i+1][j+1] = max({dp[i][j], dp[i][j+1], dp[i+1][j]});
    }

    cout << dp[X.size()][Y.size()] << endl;
}


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

    rep(i, q) {
        string x, y;
        cin >> x >> y;

        LCS(x, y);
    }

    return 0;
}


Measured memory_bytes: 7120
s = gets.chomp.to_i
num = s.to_s.split("").map(&:to_i)
sum = 0

n = num.length
(1..n).each do |digit| #桁数
    (0..n-1).each do |i| #インデックス
        next if digit > (n-i)
        dig = num[i] * 10**(digit-1)
        left = i
        right = (n-1 - (i+digit) > 0 ? n-1 - (i+digit): 0)
        sum += dig * (2 ** (left + right))
    end
end
puts sum

Measured memory_bytes: 1788
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val S = nextList()
    println("A${S[1][0]}C")
}

Measured memory_bytes: 37908