akhauriyash/Code-Regression huggingface dataset:
h, w = map(int, input().split())
s = [[0]*(w+2)] + [[0] + list(input()) + [0] for _ in range(h)] + [[0]*(w+2)]

for i in range(h + 2):
    for j in range(w + 2):
        if s[i][j] == '#' and s[i+1][j] != '#' and s[i-1][j] != '#' and s[i][j+1] != '#' and s[i][j-1] != '#':
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,T;cin>>N>>T;
    vector<pair<int,int>>pair(N);
    for(int i = 0; i <N; i++)
    {
        cin>>pair[i].first>>pair[i].second;
    }
    sort(pair.begin(),pair.end());
    bool key=true;
    for(int i = 0; i < N; i++)
    {
        if (pair[i].second<=T) {
            key=false;
            cout<<pair[i].first<<endl;
            break;
        }
        
    }
    if (key) {
        cout<<"TLE"<<endl;
    }
    
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val x = sc.nextLong()
  val year = Iterator.iterate((0, 100L)) { case (year, yen) => (year + 1, (yen * 1.01).toLong) }
      .find(x <= _._2).get._1
  println(year)
}


Measured memory_bytes: 55328
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int main() {
    int a, b, c;
    scanf("%d %d %d", &c, &a, &b);
    int m = max(a, max(b, c));
    printf("%d\n", a * b * c / (2 * m));
    return 0;
}

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

int main(){
	int w[10],k[10];
	int wsum,ksum;
	wsum=ksum=0;
	
	for(int i=0;i<10;i++)cin>>w[i];
	for(int i=0;i<10;i++)cin>>k[i];
	
	sort(w,w+10,greater<int>());
	sort(k,k+10,greater<int>());
	
	for(int i=0;i<3;i++){
		wsum+=w[i];
		ksum+=k[i];
	}
	
	cout<<wsum<<" "<<ksum<<endl;
	
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

int main() {
    int ans = INF;
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < S.size() - T.size() + 1; i++) {
        int cnt = 0;
        for (int j = 0; j < T.size(); j++) {
            if (S[i + j] != T[j]) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <queue>
#include <map>

using namespace std;

int solve(string taregt, string origin, int count);
bool checkSameColor(string str);
bool checkLastColor(vector<string> last_str, string str);

int main(int argc, char const *argv[]){
    string color;
    int count;

    while(cin>>color, color != "0"){
        count = 0;
        int result = solve(color, color, count);
        if (result == -1) cout<<"NA"<<endl;
        else cout<<result<<endl;
    }
    return 0;
}

bool checkSameColor(string str){
    char first = str[0];

    for (int i = 0; i < str.size(); i++){
        if (str[i] != first) return false;
    }

    return true;
}

int solve(string target, string origin, int count){   
    queue<pair<string, int> > que;
    que.push(make_pair(origin, 0));
    pair<string, int> worm;
    map<string, int> d;

    while (!que.empty()){
        worm = que.front();
        que.pop();
        string str = worm.first;
        
        if (d[str]) continue;

        if (checkSameColor(str)){
            return worm.second;
        }

        d[str] = worm.second;

        for (int i = 0; i < str.size()-1; ++i){
            string tmp_str = str;
            if((str[i] == 'r' && str[i+1] == 'b') 
                || (str[i] == 'b' && str[i+1] == 'r')){
                pair<string, int> tmp = make_pair(tmp_str.replace(i, 2, "gg"), worm.second+1);
                que.push(tmp);
            }
            else if((str[i] == 'b' && str[i+1] == 'g') 
                || (str[i] == 'g' && str[i+1] == 'b')){
                pair<string, int> tmp = make_pair(tmp_str.replace(i, 2, "rr"), worm.second+1);
                que.push(tmp);
            }
            else if((str[i] == 'g' && str[i+1] == 'r') 
                || (str[i] == 'r' && str[i+1] == 'g')){
                pair<string, int> tmp = make_pair(tmp_str.replace(i, 2, "bb"), worm.second+1);
                que.push(tmp);
            }
        }
    }
    return -1;
}

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

int main(){
  ll X,Y;
  cin>>X>>Y;
  int ans=0;
  while(X<=Y){
    ans++;
    X*=2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(X);
    if (N*500>=X)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    

//-----------------------------------------------------------------------------------------------------------//


    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
int N;
int MOD[1000003];

map<int, int> prime_factor(int n) {
  map<int, int> ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
  INCANT;
  cin >> N;
  if (N%2==0 || N%5==0) {
    cout << -1 << endl;
    return 0;
  }
  if (N==7 || N==1) {
    cout << 1 << endl;
    return 0;
  }
  MOD[0] = 7%N;
  rep(i, N) {
    if (i==0) continue;
    int tmp = (MOD[i-1]*10+7)%N;
    if (tmp==0) {
      cout << i+1 << endl;
      return 0;
    }
    MOD[i] = tmp;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 7488
#create date: 2020-06-30 15:26

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    a, b = na()
    if b - a < 5:
        ans = 0
        for x in range(a, b+1):
            ans ^= x
        print(ans)
        quit()
    left, right = 0, 0
    if a % 4 == 0:
        left = 0
    else:
        for i in range(a % 4, 4):
            x = (a // 4) * 4 + i
            left ^= x
    if b % 4 == 0:
        right = b
    else:
        for i in range(0, b % 4+1):
            y = (b // 4) * 4 + i
            right ^= y
    print(left^right)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9236
n=int(input())
numlist=[int(i) for i in input().split()]
sortedlist=numlist[:]
sortedlist.sort()

for i in range(n):
    if numlist==sortedlist:
        print("YES")
        break
    minnum=i
    for j in range(i,n):
        if numlist[minnum]>numlist[j]:
            minnum=j
    if minnum!=i:
        a=numlist[minnum]
        numlist[minnum]=numlist[i]
        numlist[i]=a
        if numlist==sortedlist:
            print("YES")
        else:
            print("NO")
        break
    

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <unordered_set>
#include <iterator>
#include <functional>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const unordered_set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;
vi d;
int v[15];
int dfs(int i){
	if(i == n) return count_if(v, v+15, [](int i){return i;});
	int res = 15;
	std::function<void(vi&, int, int)> rec = [&](vi &t, int l, int sum){
		if(l >= 15) return;
		if(t.size() == d[i]){
			for(int j : t) v[j] |= 1<<i;
			res = min(res, dfs(i+1));
			for(int j : t) v[j] ^= 1<<i;
		}else{
			if(v[l]) rec(t, l+1, sum);
			if(!(sum & v[l])){
				t.pb(l);
				rec(t, l+1, sum | v[l]);
				t.pop_back();
			}
		}
	};
	vi t;
	rec(t, 0, 0);
	return res;
}

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> n;
	d.resize(n);
	REP(i, n) cin >> d[i];
	sort(RALL(d));
	ll ans = 0;
	REP(i, n){
		if(d[i] >= 5){
			ans += d[i] - 5;
			d[i] = 5;
		}
	}
	cout << ans + dfs(0) << endl;
	return 0;
}

Measured memory_bytes: 1212
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
typedef long long  ll;
int main()
{
    ll n,d;
    cin >> n >> d;
    d *= d;
    int ans = 0;
    for (int i = 1; i <= n;i++)
    {
        ll x, y;
        cin >> x >> y;
        if (x*x + y*y <= d)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    int A = Integer.parseInt(a);
    int B = Integer.parseInt(b);
    String ax = "";
    String bx = "";
    for (int i=0; i<B; i++) {
      ax += a;
    }
    for (int i=0; i<A; i++) {
      bx += b;
    }
    if (ax.compareTo(bx) < 0) {
      System.out.println(ax);
    } else {
      System.out.println(bx);
    }
  }
}
    

Measured memory_bytes: 22868
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
typedef long long ll;
typedef long double ld;

using namespace std;

int main(){
    cs;
    ll t,ans=0;
    cin>>t;
    repp(i,1,t)
    if(i%3&&i%5) ans+=i;
    cout<<ans;
}

Measured memory_bytes: 3652
/*
**   Contest : Panasonic Programming Contest 2020
**   Problem : C - Sqrt Inequality
**
**    Author : Dhiraj Govindvira
**      Date : 05-Jun-2020 ~ Friday
**      Time : 12:19:58 PM
*/

#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll a, b, c;
    cin>>a>>b>>c;

    ll p = a + b;
    if(4*a*b < (c-p)*(c-p) and c>p) {
        cout<<"Yes\n";
    }
    else cout<<"No\n";
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    loop(Case,1,t+1)
    {
        cerr<<"Case #"<<Case<<'\n';
        solve(Case);
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int n=0,d=0,x=0;
    int i=0,j=0;
    int ans = 0;
    int s[150] = {0};
    scanf("%d",&n);
    scanf("%d %d",&d,&x);
    for(i=0;i<n;i++){
        scanf("%d",&s[i]);
    }
    for(i=0;i<n;i++){
        j=0;
        while(1){
            if(s[i]*j+1 > d){
                break;
            }
            if(s[i]*j+1 <= d){
                ans++;
            }
            j++; 
        }
    }
    printf("%d\n",ans+x);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<P,int>P2;
#define fi first
#define se second
int a,b;
signed main(){
    cin>>a>>b;
    cout<<100<<' '<<100<<endl;
    string s[100];
    r(i,50)r(j,100)s[i]+='.';
    r(i,50)r(j,100)s[i+50]+='#';
    a--;
    b--;
    int y=99,x=99;
    while(a){
        a--;
        s[y][x]='.';
        if(x<=1){
            y-=2;
            x=99;
        }
        else{
            x-=2;
        }
    }
    y=0,x=0;
    while(b){
        b--;
        s[y][x]='#';
        if(x>=98){
            y+=2;
            x=0;
        }
        else{
            x+=2;
        }
    }
    r(i,100)cout<<s[i]<<endl;
}

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

int main() {
	int i=0,x,m,n=0;
	cin>>x>>m;
	x=x-1;
	int j=m;
	int s=(2*x)-1;
	int h[s];
	for(i=0;i<x;i++){
		j--;
		h[n]=j;
		n++;
		}
	j=m;
	h[n]=j;
	n++;
	for(i=0;i<x;i++){
		j++;
        h[n]=j;
        n++;
	}
	int k=n;
    sort(h,h+k);
	for(i=0;i<n;i++)
        cout<<h[i]<<" " ;
	return 0;
}


Measured memory_bytes: 256
package main

import (
        "bufio"
        "fmt"
        "os"
        "strconv"
        "strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
        sc.Scan()
        return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

func bitCount(n uint) int {

        x := uint64(n)

        const m = 1<<64 - 1
        const m0 = 0x5555555555555555
        const m1 = 0x3333333333333333
        const m2 = 0x0f0f0f0f0f0f0f0f

        x = x>>1&(m0&m) + x&(m0&m)
        x = x>>2&(m1&m) + x&(m1&m)
        x = (x>>4 + x) & (m2 & m)
        x += x >> 8
        x += x >> 16
        x += x >> 32

        return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
        return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {

        // 4 + 1
        counter := make([]int, 5)

        for i := 0; i < 3; i++ {

                line := nextLine()
                spl := strSprit(line)

                counter[parseInt(spl[0])]++
                counter[parseInt(spl[1])]++
        }

        for _, v := range counter {
                if v >= 3 {
                        fmt.Println("NO")
                        return
                }
        }
        fmt.Println("YES")

}

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

int main() {
  int N;
  cin >> N;
  string S;
  bool flag = false;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "Y") {
      flag = true;
    }
  }
  cout << (flag ? "Four" : "Three") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
   long int n,a[10000],b,c,x,y=0,i,j,count,sum,max,flag=0,temp,k;
 
   scanf("%ld",&n);
   scanf("%ld",&a[0]);
   for(i=1;i<n;i++)
   {
      scanf("%ld",&a[i]);
     
   }
   for(i=0;i<n-1;i++)
   {
       for(j=i+1;j<n;j++)
       {
           if(a[i]>a[j])
           {
               temp=a[i];
               a[i]=a[j];
               a[j]=temp;
           }
       }
   }
   k=2;
 for(i=n-1;i>=0;i--)
 {
     if(k%2==0)
     {
         c+=a[i];
     }else{
         b+=a[i];
     }
     k++;
  
 }
   printf("%ld",abs(c-b));
     return 0;
}


Measured memory_bytes: 128
#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 ans=0;
void Main(){
    ll x;cin>>x;
    map<ll,ll> mp1,mp2;
    For(i,1,1001){
        ll t=i*i*i*i*i;
        mp1[i]=t;
        mp1[-i]=-t;
        mp2[t]=i;
        mp2[-t]=-i;
    }
    for(auto p:mp1){
        //cout << p.first << " " << p.second <<" " << x+p.second << endl;
        if(x+p.second==0){
            cout << "0 " << p.first << endl;
            return;
        }
        else if(mp2[x+p.second]!=0){
            cout << mp2[x+p.second]  << " " << p.first << endl;
            return;
        }
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3940
#include <stdio.h>
#include <stdlib.h>

#define DIV_INIT 0
#define LOOP_INIT 0
#define G_MAX 12
#define FIRST_ITEM 0
#define ONE 1
#define EXIT_SUCCESS 0
#define PREV_ITEM( x ) x - 1
#define THREE_TIMES( x ) x * 3
#define HALF( x ) x / 2

int main( void )
{
	unsigned long ulW_Dtc_cnt;
	int *aulW_Dtestcase;
	unsigned long ulW_Cloop_cnt;
	unsigned long ulW_Cloop_sub_cnt;
	unsigned long ulW_Csort_cnt = DIV_INIT;
	unsigned long ulW_Dinterval_num = ONE;//?????????????????????????????°
	unsigned long ulW_Dinterval_array[ G_MAX ];//?????????????????????
	unsigned long ulW_Dshell_div;
	signed long slW_Dsort_div;
	unsigned long ulW_Dcalc;

	scanf( "%d", &ulW_Dtc_cnt );
	aulW_Dtestcase = malloc ( sizeof( int ) * ulW_Dtc_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		scanf( "%d", &aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	ulW_Dinterval_array[ FIRST_ITEM ] = ONE;
	ulW_Dcalc = THREE_TIMES( ulW_Dinterval_array[ PREV_ITEM( ulW_Dinterval_num ) ] ) + ONE;
	while( ulW_Dcalc < ulW_Dtc_cnt ){
		ulW_Dinterval_array[ ulW_Dinterval_num ] = THREE_TIMES( ulW_Dinterval_array[ PREV_ITEM( ulW_Dinterval_num ) ] ) + ONE;
		ulW_Dinterval_num++;
		ulW_Dcalc = THREE_TIMES( ulW_Dinterval_array[ PREV_ITEM( ulW_Dinterval_num ) ] ) + ONE;
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < HALF( ulW_Dinterval_num ); ulW_Cloop_cnt++ ){
		ulW_Dshell_div = ulW_Dinterval_array[ ulW_Cloop_cnt ];
		ulW_Dinterval_array[ ulW_Cloop_cnt ] = ulW_Dinterval_array[ PREV_ITEM( ulW_Dinterval_num ) - ulW_Cloop_cnt ];
		ulW_Dinterval_array[ PREV_ITEM( ulW_Dinterval_num ) - ulW_Cloop_cnt ] = ulW_Dshell_div;
	}

	printf( "%d\n", ulW_Dinterval_num );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dinterval_num; ulW_Cloop_cnt++ ){
		if( ulW_Cloop_cnt == PREV_ITEM( ulW_Dinterval_num ) ){
			printf( "%d\n", ulW_Dinterval_array[ ulW_Cloop_cnt ] );
		}
		else{
			printf( "%d ", ulW_Dinterval_array[ ulW_Cloop_cnt ] );
		}
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dinterval_num; ulW_Cloop_cnt++){
		for( ulW_Cloop_sub_cnt = ulW_Dinterval_array[ ulW_Cloop_cnt ]; ulW_Cloop_sub_cnt < ulW_Dtc_cnt; ulW_Cloop_sub_cnt++ ){
			ulW_Dshell_div = aulW_Dtestcase[ ulW_Cloop_sub_cnt ];
			slW_Dsort_div = ulW_Cloop_sub_cnt - ulW_Dinterval_array[ ulW_Cloop_cnt ];
			while( ( slW_Dsort_div >= FIRST_ITEM ) && ( aulW_Dtestcase[ slW_Dsort_div ] > ulW_Dshell_div ) ){
				aulW_Dtestcase[ slW_Dsort_div + ulW_Dinterval_array[ ulW_Cloop_cnt ] ] = aulW_Dtestcase[ slW_Dsort_div ];
				slW_Dsort_div -= ulW_Dinterval_array[ ulW_Cloop_cnt ];
				ulW_Csort_cnt++;
			}
			aulW_Dtestcase[ slW_Dsort_div + ulW_Dinterval_array[ ulW_Cloop_cnt ] ] = ulW_Dshell_div;
		}
	}

	printf( "%d\n", ulW_Csort_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		printf( "%d\n", aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 4508
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <bits/stdc++.h>
#include <unordered_map>

using namespace std;

#define push push_back
#define make make_pair

int vacationHelper(vector<vector<int>> a){
    int r=a.size();
    int c=a[0].size();
    vector<vector<int>> dp(r,vector<int>(c,0));
    for(int i=0;i<c;i++){
        dp[0][i]=a[0][i];
    }
    for(int i=1;i<r;i++){
        for(int j=0;j<c;j++){
            for(int k=0;k<c;k++){
                if(k!=j){
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
                }
            }
        }
    }
    int m=INT_MIN;
    for(int i=0;i<c;i++){
      m=max(dp[r-1][i],m);
    }
    return m;
}


int main(){
    int n;
    cin>>n;
    vector<vector<int>> a(n,vector<int> (3,0));
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    int res=vacationHelper(a);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 16640
#N=5
#A=[ 32, 1, 87, 25, 36]
N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

A=sorted(A)

mf=0
ms=0
sf=0
ss=0
d=0
c=0
n=0


ml=N-1
mr=N-1
sl=0
sr=1
n=1
while(True):
    if(n==N):break
    d+=(A[ml]-A[sl])
    ml=mr-1
    n+=1
    if(n==N):break
    d+=(A[mr]-A[sr])
    mr=ml-1
    n+=1
    if(n==N):break
    d+=(A[ml]-A[sl])
    sl=sr+1
    n+=1
    if(n==N):break
    d+=(A[mr]-A[sr])
    sr=sl+1
    n+=1

ml=N-1
mr=N-2
sl=0
sr=0
n=1
while(True):
    if(n==N):break
    c+=(A[ml]-A[sl])
    sl=sr+1
    n+=1
    if(n==N):break
    c+=(A[mr]-A[sr])
    sr=sl+1
    n+=1
    if(n==N):break
    c+=(A[ml]-A[sl])
    ml=mr-1
    n+=1
    if(n==N):break
    c+=(A[mr]-A[sr])
    mr=ml-1
    n+=1

print(max(d,c))

Measured memory_bytes: 8364
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void LCS(char *x, char *y){
	int m = strlen(x+1);
	int n = strlen(y+1);
	int i, j, **c;
	
	c = malloc(sizeof(int)*(2000));
	for (i = 0; i <= m; i++)
		c[i] = malloc(sizeof(int)*(2000));
	
	for (i = 0; i <= m; i++){
		for (j = 0; j <= n; j++){
			c[i][j] = 0;
		}
	}
	
	for (i = 1; i <= m; i++){
		for (j = 1; j <= n; j++){
			if (x[i] == y[j])
				c[i][j] = c[i - 1][j - 1] + 1;
			else if (c[i - 1][j] >= c[i][j - 1])
				c[i][j] = c[i - 1][j];
			else
				c[i][j] = c[i][j - 1];
		}
	}
	
	printf("%d\n", c[i-1][j-1]);
	for (i = 0; i < m; i++)free(c[i]);
	free(c);
	
}

int main(){
	int i, n;
	char x[2000], y[2000];

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%s%s", x + 1, y + 1);
		LCS(x, y);
	}
	return 0;
}

Measured memory_bytes: 8604
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        String s[]=br.readLine().trim().split(" ");
        int K=Integer.parseInt(s[0]);
        N=Integer.parseInt(s[1]);

        int a[]=new int[N*2];
        s=br.readLine().trim().split(" ");
        for(i=0;i<N;i++)
            a[i]=Integer.parseInt(s[i]);
        for(i=N;i<2*N;i++) a[i]=a[i-N];

        int min=Integer.MAX_VALUE;
        for(i=0;i<N;i++)
        {
            if(a[i+N-1]>a[i]) min=Math.min(min,a[i+N-1]-a[i]);
            else min=Math.min(min,K-a[i]+a[i+N-1]);
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 47188
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#define ll long long 
#define dd double
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int s;
  cin>>s;
  string f;
  int x=s/100;
  int y=s%100;
  if(x>=1&&x<=12&&y>=1&&y<=12){
  	f=f+"AMBIGUOUS";
  }
  else if(x>12&&y>=1&&y<=12){
  	f=f+"YYMM";
  }
  
  else if(x>=1&&x<=12&&y>12){
  	f=f+"MMYY";
  }
  
  else if(x==0&&y>=1&&y<=12){
  	f=f+"YYMM";
  }
  
  else if(x>=1&&x<=12&&y==0){
  	f=f+"MMYY";
  }
  
  else{
  	f=f+"NA";
  }
  
  cout<<f<<endl;
  
  return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
 
int main(void) {
	char s[101];
	long long int k;
	int i,check;
	scanf("%s",&s);
	scanf("%d",&k);
 
	for(i=0;i<k;i++){
		check=s[i]-'0';
		if(check!=1){
			printf("%d",check);
			return 0;
		}
	}
	printf("1");
	return 0;
}

Measured memory_bytes: 128
X,Y = [int(x) for x in input().split()]
li = [300000, 200000, 100000]
if(X==Y==1):
    print(1000000)
else:
    ans = 0
    if(X<=3):
        ans += li[X-1]
    if(Y<=3):
        ans += li[Y-1]
    print(ans)

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

int main(){
	int n,k;
	int c[4][14] = {0};
	string s;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> s >> k;
		if(s == "S"){
			c[0][k] = 1;
		}
		if(s == "H"){
			c[1][k] = 1;
		}
		if(s == "C"){
			c[2][k] = 1;
		}
		if(s == "D"){
			c[3][k] = 1;
		}
	}
	for(int i=0;i<4;i++){
		for(int j=1;j<=13;j++){
			if(c[i][j] == 0){
				switch (i){
					case 0:
						cout << "S " << j;
						break;
					case 1:
						cout << "H " << j;
						break;
					case 2:
						cout << "C " << j;
						break;
					case 3:
						cout << "D " << j;
						break;

				}
				cout << endl;
			}
		}
	}
}

Measured memory_bytes: 1204
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll a[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    ll c, j;
    for (c = 1, j = 0; j < n; j++)
        if (a[j] == c)
            c++;
    c = n - c + 1;
    cout << (c < n ? c : -1);
    return 0;
}

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

#define ll long long int
#define fir first
#define sec second
#define endl '\n'
ll const mod = 1e9 + 7;

ll power(ll x, ll y, ll p) { 
    ll res = 1;    x = x % p;  
    while(y > 0) {
        if(y & 1) res = (res*x) % p; 
        y = y>>1;    x = (x*x) % p; 
    } return res; 
}

ll MIN(ll a, ll b) {
    if(a<b) return a;   return b;
}

ll MAX(ll a, ll b) {
    if(a>b) return a;   return b;
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int k, a, b;
    cin>>k>>a>>b;
    
    if(((a/k)*k>=a and (a/k)*k<=b) || ((a/k+1)*k>=a and (a/k+1)*k<=b)) cout<<"OK";
    else cout<<"NG";
    
	// your code goes here
	return 0;
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  string s,t;
  int sum=0;
  cin>>s>>t;
  REP(i,3){
    if(s[i]==t[i]){
      sum++;
    }
  }
  cout<<sum<<endl;
}



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


int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if( abs(a - c ) <= d)
	{
		cout << "Yes";
		return 0;
	}
	if(abs(a - b) <= d && abs(b - c) <= d)	
	{
		cout << "Yes";
		return 0;
	}

	cout << "No";
	return 0;
}

Measured memory_bytes: 256
/*
                                                                                                                                               
8b        d8                           888888888888                                             88b           d88                  ad88888ba   
 Y8,    ,8P                                 88                                        ,d        888b         d888                 d8"     "8b  
  Y8,  ,8P                                  88                                        88        88`8b       d8'88                 ""      a8P  
   "8aa8"  ,adPPYba,   88       88          88  8b,dPPYba,  88       88  ,adPPYba,  MM88MMM     88 `8b     d8' 88   ,adPPYba,          ,a8P"   
    `88'  a8"     "8a  88       88          88  88P'   "Y8  88       88  I8[    ""    88        88  `8b   d8'  88  a8P_____88         d8"      
     88   8b       d8  88       88          88  88          88       88   `"Y8ba,     88        88   `8b d8'   88  8PP"""""""         ""       
     88   "8a,   ,a8"  "8a,   ,a88          88  88          "8a,   ,a88  aa    ]8I    88,       88    `888'    88  "8b,   ,aa         aa       
     88    `"YbbdP"'    `"YbbdP'Y8          88  88           `"YbbdP'Y8  `"YbbdP"'    "Y888     88     `8'     88   `"Ybbd8"'         88       
                                                                                                                                               
*/
#include <bits/stdc++.h>
using namespace std;

int n, d[100005];

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

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}

	sort(d, d + n);

	cout << d[n / 2] - d[n / 2 - 1] << '\n';

	return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372037ll;

void solve()
  {
   int n,m,k;
   cin>>n>>m>>k;
   vector<int> a(n+1);
   map<int,int> b;
   a[0] = 0;
   b[0] = 0;
   int x,prev = 0;
   loop(i,1,n+1){
    cin>>x;
    prev+=x;
    a[i] = prev;
   }
   prev = 0;
   loop(i,1,m+1){
    cin>>x;
    prev += x;
    b[prev] = i;
   }
   int ans = 0;
   loop(i,0,n+1){
    auto it = b.upper_bound(k-a[i]);
    --it;
    if((*it).ff >=0 && (*it).ff + a[i] <=k)
       ans = max(ans,(*it).ss + i);
   }
   cout<<ans;
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 17184
#include <bits/stdc++.h>
using namespace std;
int main(){
  int c=0,n,k;cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  for(int i=0;i<n;++i){
    if(a[0]==a[n-1])break;
    if(a[i]==a[i+1])continue;
    for(int j=1;j<k;++j){
      if(i+j>=n)break;
      a[i+j]=a[i];
    }
    c++;
  }
  cout<<c;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define replb(i, a, b) for (ll i = a; i >= b; i--)
#define repl(i, a, b) for (ll i = a; i < b; i++)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define search(arr, c) binary_search(arr.begin(), arr.end(), c)
#define pb push_back
#define ll long long
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
}
int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
}
int cel(int a,int b){return((a-1)/b+1);} 
int gcd(int a, int b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a,int b){
    return (a*b)/gcd(a,b);
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,x,n;
    cin>>n;ll sum=0,k=0,m;vi v;
    rep(i,0,n){
        cin>>x;v.pb(x);
    }
    dsortA(v);
    if(n==1)cout<<0;
    else{
        sum=v[0];
        rep(i,1,n/2){
            sum+=(2*v[i]);
        }
        rep(i,n/2,n/2+n%2){
            sum+=v[i];
        }
        cout<<sum;
    }
    return 0;
}

Measured memory_bytes: 4284
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
#define MAX_N (50+10)
const double G = 9.8;
#define EPS 1e-06

int N,V,X,Y;
// (L[i],B[i]) , (R[i],T[i]) // 左下,右上
int L[MAX_N], B[MAX_N], R[MAX_N], T[MAX_N];

// 速度vyで上に打ち出した際のt秒後のy座標を計算する
double calc(double vy, double t) {
    return vy * t - G * t * t / 2;
}

// aのlbとubに対する相対的な位置
int cmp(double lb, double ub, double a) {
    return a < lb + EPS ? -1 : a > ub - EPS ? 1 : 0;
}

// 点(qx,qy)を通るように打ち出したときに豚に卵をぶつけられるか判定
bool check(double qx, double qy) {
    // 初速のx方向成分をvx,y方向成分をvyとし、(qx,qy)を通る時刻をtとしたときの連立方程式
    // vx^2 + vy^2 = V^2, vx * t = qx, vy * t - 1/2 g t^2 = qy を解く
    double a = 1.0/4.0 * G * G,
           b = qy * G - V * V,
           c = qx*qx + qy*qy;
    double D = b*b - 4*a*c;
    if(D<0 && D > -EPS) D = 0;
    if(D<0) return false; // 虚数
    for(int d=-1;d<=1;d+=2) { // 連立方程式の2つの解を試すループ
        double t2 = (-b + d * sqrt(D)) / (2 * a);
        if (t2 <= 0) continue;
        double t = sqrt(t2);
        double vx = qx / t, vy = (qy + G * t * t / 2) / t;

        // 豚より上を通過できるか判定
        double yt = calc(vy, X / vx);
        if (yt < Y - EPS) continue;

        bool ok = true;
        for(int i=0;i<N;i++) {
            if (L[i] >= X) continue;
            // 豚の真上まで来たときに、間に障害物がないか判定
            if (R[i] == X && Y <= T[i] && B[i] <= yt) ok = false;
            // 途中で障害物にぶつからないか判定
            int yL = cmp(B[i], T[i], calc(vy, L[i] / vx)); // 左端での相対位置
            int yR = cmp(B[i], T[i], calc(vy, R[i] / vx)); // 右端での相対位置
            int xH = cmp(L[i], R[i], vx * (vy / G)); // 最も高くなる地点の相対位置
            int yH = cmp(B[i], T[i], calc(vy, vy / G));
            if (xH == 0 && yH >= 0 && yL < 0) ok = false;
            if (yL * yR <= 0) ok = false;
        }
        if (ok) return true;
    }
    return false;
}

void solve() {
    // 豚より右にある障害物を縮めておく
    for(int i=0;i<N;i++) {
        R[i] = min(R[i], X);
    }
    bool ok = check(X, Y); // 直接ぶつける場合
    for(int i=0;i<N;i++) {
        ok |= check(L[i], T[i]); // 左上の角を通る場合
        ok |= check(R[i], T[i]); // 右上の角を通る場合
    }
    puts(ok ? "Yes" : "No");
}

main() {
    cin>>N>>V>>X>>Y;
    for(int i=0;i<N;i++) {
        cin>>L[i]>>B[i]>>R[i]>>T[i];
    }
    solve();
}

Measured memory_bytes: 1120
h,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
max_a=max(a for a, _ in ab)
dp=[10**18 for _ in range(h+max_a)]
dp[0]=0
for i in range(1,h+max_a):
  dp[i]=min(dp[i-a]+b for a,b in ab)
print(min(dp[h:]))

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

int base[3] = { 0,0,0 };
int score = 0;
int out = 0;

int hit()
{
	score += base[2];
	base[2] = base[1];
	base[1] = base[0];
	base[0] = 1;
	return 0;
}

int homerun()
{
	for (int i = 0; i < 3; i++)
	{
		score += base[i];
		base[i] = 0;
	}
	score++;
	return 0;
}

int outf()
{
	out++;
	if (out > 2)
	{
		out = 0;
		cout << score << endl;;
		score = 0;
		base[0] = base[1] = base[2] = 0;
	}
	return 0;
}

int main()
{
	int n;
	cin >> n;
	string state;
	while (cin >> state)
	{
		if (state == "HIT")
			hit();
		else if (state == "HOMERUN")
			homerun();
		else if (state == "OUT")
			outf();
	}

	return 0;
}

Measured memory_bytes: 3220
import math
N=int(input())
Z=[]*N
for i in range(N):
    A=list(map(int,input().split()))
    Z.append(A)
def D(x1,x2,y1,y2):
    return pow((x1-x2)**2+(y1-y2)**2,0.5)

ans=0
for i in range(N):
    for j in range(i,N):
        ans+=D(Z[i][0],Z[j][0],Z[i][1],Z[j][1])*math.factorial(N-1)*2
print(ans/math.factorial(N))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << endl;
#define pb push_back
using namespace std;

const int MAX_N = 1e5;
vector<int> adj[MAX_N + 1];
bool visited[MAX_N + 1];
int h[MAX_N + 1];

void DFS(int u) {
	visited[u] = true;
	int l = adj[u].size();
	for (int i = 0; i < l; i++) {
		int v = adj[u][i];
		if (not visited[v]) DFS(v);
		h[u] = max(h[u], 1 + h[v]);
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].pb(v);
	}
	for (int i = 1; i <= n; i++) {
		if (not visited[i]) DFS(i);
	}
	int answer = 0;
	for (int i = 0; i <= n; i++) {
		answer = max(answer, h[i]);
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 8320
#include<iostream>
using namespace std;
int main(){
	long long int n;
	long long int s;
	long long int a,b,c;
	int i,j,k;
	cin>>n;
	a=49+n/50;
	b=n%50;
	cout<<"50"<<endl;
	for(i=0;i<50;i++){
		if(i<b)s=a+50-(b-1);
		else s=a-b;
		cout<<s;
		if(i!=49)cout<<" ";
		else cout<<endl;
	}
	return 0;
}
	


Measured memory_bytes: 256
def main():
    from collections import deque

    N, L = map(int, input().split())
    *a, = map(int, input().split())

    def solve(a):
        dq = deque()
        s = 0
        ans = 0
        for x in a:
            if len(dq) > 1:
                t = dq.popleft()
                s -= t
            eat = max(0, s + x - L)
            if eat:
                x -= eat
                ans += eat
            s += x
            dq.append(x)
        return ans

    ans =solve(a) # reversed(a)確認しないとどうなるか

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14508
#include <iostream>
#include <map>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<int> num(n, -1), s(m), c(m);
    rep(i, m) {
        cin >> s[i] >> c[i];
        s[i]--;
    }

    rep(i, m) {
        if (num[s[i]] != -1 && num[s[i]] != c[i]) {
            cout << -1 << endl;
            return 0;
        }
        num[s[i]] = c[i];
    }

    if (n > 1) {
        if (num[0] == 0) {
            cout << -1 << endl;
            return 0;
        } else if (num[0] == -1) {
            num[0] = 1;
        }
        rep(i, n) {
            if (num[i] == -1) cout << 0;
            else cout << num[i];
        }
        cout << endl;
    } else {
        if (num[0] == -1) num[0] = 0;
        cout << num[0] << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){

    int n;cin>>n;
    vector<vector<ll>> a(n,vector<ll>(3));

    vector<vector<ll>> dp(n+1,vector<ll>(3));

    rep(i,n){
        rep(j,3){
            cin>>a[i][j];
        }
    }

    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(j == k) continue;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    ll ans = 0;
    rep(i,3) ans = max(ans,dp[n][i]);
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 11136
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n){
    if(n==1||n==1){
        return false;
    }
    for(int i=2;i<n;++i){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
int fact(int n){
    int ans = 1;
    for(int i = 1; i<= n; ++i){
        ans *= i;
    }
    return ans;
}


int main()
{
    int nums[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<nums[n-1]<<endl;
}

Measured memory_bytes: 256
def main():
    I = [int(_) for _ in input().split()]
    N = I[0]
    M = I[1]
    A = [int(_) for _ in input().split()]

    least = sum(A) / (4 * M)
    count = 0
    for i in A:
        if i >= least:
            count += 1

    if(count >= M):
        print("Yes")
    else:
        print("No")  



if __name__ == "__main__":
    main()


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

// #define ONLINE_JUDGE

#define V vector
#define P pair

using LL = long long;
#define FOR(i, x, y) \
    for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) \
    for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
    do {                                      \
        cerr << "\033[32;1m" << #x << " -> "; \
        err(x);                               \
    } while (0)
void err() { cerr << "\033[39;0m" << endl; }
template <template <typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) {
    for (auto v : a) cerr << v << ' ';
    err(x...);
}
template <typename T, typename... A>
void err(T a, A... x) {
    cerr << a << ' ';
    err(x...);
}
#else
#define dbg(...)
#endif
#define sz(x) (int)x.size()

LL bin(LL a, LL b, LL p) {
    LL res = 1;
    a = (a % p + p) % p;
    for (; b; b >>= 1, a = a * a % p)
        if (b & 1) res = res * a % p;

    return res;
}

const int N = 2e5+50;


void solve() {
    int k;
    scanf("%d", &k);
    int now = 0;
    for (int i=1; i<1001000; ++i) {
        now = (now * 10 + 7) % k;
        if (now == 0) {
            printf("%d\n", i);
            return;
        }
    }
    puts("-1");    
}

int main() {

    // int t;
    // cin >> t;
    // while (t--) solve();

    solve();

    return 0;
}

Measured memory_bytes: 3756
#include <stdio.h>
#define N 3200
int main (void)
{
    int a;
    char s[10];
    scanf("%d", &a);
    scanf("%s", &s);

    if(a>= N)
    {
        printf("%s", s);
    }
    else
    {
        printf("red");
    }  

return 0;
}


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

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

void minUpdate(int& a, int b) { a = min(a, b); }

int N, M, D[1010], C[1010], dp[1010][1010];
const int iINF = 1L << 30;

int main() {
	cin >> N >> M;
	for_(i,0,N) cin >> D[i];
	for_(i,0,M) cin >> C[i];
	
	for_(i,0,M+10) fill(dp[i], dp[i] + N + 10, iINF);
	
	dp[0][0] = 0;
	for_(i,0,M) for_(j,0,N+1) {
		minUpdate(dp[i+1][j], dp[i][j]);
		minUpdate(dp[i+1][j+1], dp[i][j] + D[j] * C[i]);
	}
	
	int ans = iINF;
	for_(i,0,M+1) minUpdate(ans, dp[i][N]);
	cout << ans << endl;
}

Measured memory_bytes: 5152