akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int[] numbers = new int[] {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};

		System.out.println(numbers[k - 1]);
		scan.close();
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std ;
int n , m ;
struct E{
	int st , ed ;
}p[1000005];
inline bool Cmpr(E a , E b){return a.ed < b.ed ;}
inline bool Cmpl(E a , E b){return a.st < b.st ;}
int Ans ;
int r[1000005] ;
int vis[1000005] ;
int main(){
//	freopen("data.in","r",stdin);
//	freopen("me.out","w",stdout) ;
	cin >> n >> m ;
	for(int i = 1 ; i <= m ; i ++ )
		cin >> p[i].st >> p[i].ed ;
	if(m == 0 ){
		cout << 0 << endl ;
		return 0 ;
	}
	if(m == 1){
		cout << 1 << endl ;
		return 0 ;
	}
	sort(p + 1 , p + m + 1 , Cmpr) ;
	for(int i = 1 ; i <= m ; i ++ ) r[i] = p[i].ed , ++ vis[r[i]];
	int upp = 1 ;
	sort(p + 1 , p + m + 1 , Cmpl) ;
	for(int i = 1 ; i <= m ; i++){
		if(p[i].st >= r[upp]){
			++Ans ;
			while((r[upp] <= p[i].st || vis[r[upp]] == 0 ) && upp < m) upp++ ;
		}
		vis[p[i].ed] -- ; 
	}
	cout << Ans + 1  << endl ;
	return 0 ;
}


Measured memory_bytes: 8832
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) ((1+x)*x)/2
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}
int main(void){
  initialize();
  ll w,h,x,y,i,j,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  ld half;
  
  scanf("%lld %lld %lld %lld",&w,&h,&x,&y);
  half = h*w/2.0;
  if(w/2.0==x&&h/2.0==y) result=1;
  printf("%6Lf %lld",half,result);
  
  return 0;
}

Measured memory_bytes: 128
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll X;
    in(X);

    ll ans = 0;
    ans += 1000 * (X / 500);
    X %= 500;

    ans += 5 * (X / 5);
    X %= 5;

    outl(ans);

    return 0;
}

Measured memory_bytes: 3640
import 'dart:io';

main(List<String> args) {
  List ABCD = stdin.readLineSync().split(' ').map((x) => int.parse(x)).toList();
  if ((ABCD[0] / ABCD[3]).ceil() < (ABCD[2] / ABCD[1]).ceil())
    print("No");
  else
    print("Yes");
}


Measured memory_bytes: 13100
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))


signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    while(true){
        int n,x;
        scanf("%d%d",&n,&x);
        if(n==0&&x==0) break;
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                int k=x-i-j;
                if(k<=j||n<k) continue;
                ans++;
            }
        }
        cout << ans << endl;
    }
}



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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf=1e9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};	

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

	cout<< (n%2?n/2+1:n/2) <<endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>

typedef long long ll;

constexpr long long INFLL = 1e18;

using namespace std;

int main()
{
    map<int, int> m;
    int n;
    cin >> n;
    int temp;
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        sum += temp;
        m[temp]++;
    }
    int q;
    cin >> q;
    cout << endl;
    int count;
    int b, c;
    while (q > 0)
    {
        cin >> b;
        cin >> c;

        count = m[b];
        m[b] = 0;
        m[c] += count;
        sum = sum + (c - b) * count;
        /*m[c] += m[b];
        sum = sum + (c - b) * m[b];
        m.erase(b);*/
        cout << sum << endl;
        q--;
    }

    return 0;
}

Measured memory_bytes: 7560
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end());

const int MOD = 1000000007;
const int INF = INT_MAX;



int main()
{

    int h, w;
    cin >> h >> w;
    char s[h+2][w+2];
    rep(i, h+2){
        rep(j, w+2){
            s[i][j] = '.';
        }
    }
    for (int i=1; i < h+1; i++){
        for (int j=1; j < w+1; j++){
            cin >> s[i][j];
        }
    }

    int flag = 1;

    for (int i=1; i < h+1; i++){
        for (int j=1; j < w+1; j++){
            if (s[i][j] == '#' && (s[i][j-1] == '#' || s[i][j+1] == '#' ||
                s[i+1][j] == '#' || s[i-1][j] == '#')){
                ;
            }
            else if (s[i][j] == '.') ;
            else flag = 0;
        }
    }

    if (flag == 0) cout << "No" << endl;
    else cout << "Yes" << endl;

    



    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 256
ans=0

from collections import defaultdict
n=int(input())
s=input()
a=s[:n]
b=s[n:][::-1]
def coloring(x):
    N=1<<n
    dc=defaultdict(int)
    for i in range(N):
        r=''
        b=''
        for j in range(n):
            if i>>j&1:
                r+=x[j]
            else:
                b+=x[j]
        dc[r+'-'+b]+=1
    return dc    

fd=coloring(a)
ld=coloring(b)

for i,j in fd.items():
    ans+=ld[i]*j

print(ans)


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

int main(){
    int n, ans = 1;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];

    sort(s.begin(), s.end());
    for(int i = 1; i < n; i++){
        if(s[i] != s[i - 1]) ans++;
    }

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

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
vll a;
vll b;
vll c;
lli ans = 0;

int main(){
  cin >> n;
  a = vll(n);
  b = vll(n);
  c = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i] >> b[i];
  for(lli i = 0;i < n;i++) c[i] = a[i]+b[i];
  sort(c.rbegin(), c.rend());
  ans += accumulate(a.begin(), a.end(), 0ll);
  ans -= accumulate(b.begin(), b.end(), 0ll);
  for(lli i = 0;i < n;i++){
    if(i%2 == 0) ans += c[i];
    else ans -= c[i];
  }
  cout << ans/2 << endl;


}


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

using namespace std;

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

    vector<int> A(N);

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

    int upto = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == upto + 1) {
            upto++;
        }
    }
    if (upto == 0) {
        cout << "-1" << endl;
        return 0;
    }

    cout << N - upto << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool solve(string s, string t) {
	if (s == t) {
		return true;
	}

	int n = s.size();
	set<pair<int, int>> se;

	vector<char> sConv(26, '?'), tConv(26, '?');
	for (int i = 0; i < n; i++) {
		int sCharNum = s[i] - 'a';
		int tCharNum = t[i] - 'a';

		sConv[sCharNum] = sConv[sCharNum] == '?' ? t[i] : sConv[sCharNum];
		tConv[tCharNum] = tConv[tCharNum] == '?' ? s[i] : tConv[tCharNum];

		if (sConv[sCharNum] != t[i] || tConv[tCharNum] != s[i]) {
			return false;
		}
	}

	return true;
}

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

	string s, t;
	cin >> s >> t;

	cout << (solve(s, t) ? "Yes" : "No") << endl;
	return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    int stones[n+1],memo[n+1]; 
    for(int i = 1 ; i <= n ; i++) {
        cin >> stones[i];
        memo[i] = 1e9+5;  
    }

    memo[0] = 0;
    memo[1] = 0;
    for(int i =1; i<= n;i++){
        for(int j = 1; j <= k ; j++){
            if (i-j > 0){
                memo[i] = min(memo[i], abs(stones[i]-stones[i-j]) + memo[i-j]);
            }

        }
    }
    cout << memo[n] <<   endl;
    
    return 0;

}


Measured memory_bytes: 4396
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) cerr << #x << " = " << (x) << " " << endl;
#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
 
template<typename T>
T gcd(T a, T b)
{
  T c;
  while (a != 0) {
    c = a; a = b%a;  b = c;
  }
  return b;
}
 
class Solver {
public:
  int N;
  vector<int> a;

  void solve() {
    cin >> N;
    a.resize(N);
    rep(i, N) cin >> a[i];

    sort(all(a), greater<int>());

    int b = 0;
    int c = 0;
    for (int i = 0; i < N; i += 2) {
      b += a[i];
      if (i + 1 < N) c += a[i+1];
    }
    cout << b - c << endl;
  }
};
 
signed main()
{
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {    
  //     auto ptr = new Solver();
  //     ptr->solve();
  //     delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'


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

using namespace std;

long long MOD = 1e9+7;
int MAX_INT = 1e9;

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

  int H, W, N;
  cin >> H >> W >> N;

  int max_len = max(H, W);
  if(N % max_len == 0) cout << (N / max_len) << endl;
  else cout << (N / max_len) + 1 << endl;

  return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
       double a = scanner.nextInt();
       double b = scanner.nextInt();
       double ave = (a + b)/ 2 ;
       int result = (int)Math.ceil(ave);

       System.out.println(result);
    }

}

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

using namespace std;

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

	int a, b;
	cin >> a >> b;
	cout << (b - 1 + a - 2) / (a - 1);

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(void){
  string ans;
  char s[1];
  cin >> s;
  if (s[0]=='a'||s[0]=='i'||s[0]=='u'||s[0]=='e'||s[0]=='o')
    ans = "vowel";
  else
    ans = "consonant";
  cout << ans << endl;
}

Measured memory_bytes: 256
s=list(reversed(input()))
mod=10**9+7
memo=[0 for _ in [0]*13]
m13=[(10**i)%13 for i in range(12)]
memo[0]=1
for i in range(len(s)):
    memo2=[0 for _ in [0]*13]
    a=m13[i%12]
    if s[i]=="?":
        list_=[0,1,2,3,4,5,6,7,8,9]
    else:
        list_=[int(s[i])]
    list_=[(a*j)%13 for j in list_]
    for l in list_:
        for j in range(13):
            memo2[(l+j)%13]+=memo[j]
    memo=[j%mod for j in memo2]
print(memo[5])

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vpi;
typedef vector<bool> vbool;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define forall(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define F0(i,n) for(ll i = 0; i < n; i++)
#define F1(i,n) for(ll i = 1; i <= n; i++)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = b-1; i >= a; i--)
#define FIN ios::sync_with_stdio(false);cin.tie(0);
#define db(x) cout<<#x<<" = "<<x<<"\n"
#define all(v) v.begin(),v.end()
#define modulo(a,b) ((a%b)+b)%b
#define F first
#define S second
#define INF 1000000010
#define eps 0.000000000001
#define mod 1000000007
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//=======================//
const int maxn=3000;
string s,t,res;
pair<int, pair<int,int>> dp[maxn][maxn];
int n,m;

pair<int, pair<int,int>> hacerDP(int i, int j) {
	if (i>=n||j>=m) return {0,{i,j}};
	if (dp[i][j].F != -1) return {dp[i][j].F ,{i,j}};
	if  (s[i] == t[j]) {
		auto r = hacerDP(i+1, j+1);
		dp[i][j] = {r.F + 1, r.S};
		return {r.F + 1, {i,j}};
	}
	auto r1 = hacerDP(i+1,j);
	auto r2 = hacerDP(i,j+1);
	if (r1.F > r2.F) {
		dp[i][j] = r1;
		return {r1.F, {i,j}};
	}
	else {
		dp[i][j] = r2;
		return {r2.F, {i,j}};
	}
}

void getRes() {
	int i=0, j=0;
	while(i<n && j<m) {
		if (s[i] == t[j]) res += s[i];
		pair<int,int> r = dp[i][j].S;
		i = r.F; j = r.S;
	}
}

int main () {
	//FIN

	cin >> s >> t;
	n = s.size(); m = t.size();
	F0(i,n) F0(j,m) dp[i][j] = {-1,{-1,-1}};
	hacerDP(0,0);
	getRes();
	cout << res << "\n";

	return 0;
}










Measured memory_bytes: 109628
import sys, math, re
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, K = mi()
    L, R = i2(K)

    dp = [0]*(N+5)
    dp[1] = 1

    for i in range(2, N+1):
        dp[i] = dp[i-1]
        for j in range(K):
            if i-L[j] >= 0:
                dp[i] += dp[i-L[j]]
            if i-R[j]-1 >= 0:
                dp[i] -= dp[i-R[j]-1]

        dp[i] %= 998244353

    print((dp[N]-dp[N-1])%998244353)




if __name__ == "__main__":
    main()

Measured memory_bytes: 17636
fn main() {
    let s = getline();
    let list: Vec<_> = s.trim().split(' ').collect();

    let x: i32 = list[0].parse().unwrap();
    let y: f32 = x as f32;

    let z = y.sqrt().floor() as i32;

    let mut max: i32 = 1;

    for i in 2..(z + 1) {
        let mut tmp = 1;
        while tmp * i <= x {
            tmp *= i;
            if max < tmp {
                max = tmp;
            }
        }
    }
    println!("{}", max);
}


fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int min = Integer.MAX_VALUE;
        int ans = 0;
        for (int i = 0; i < n - 1; i++) {
            int sa = Math.abs(a[n - 1] - a[i] * 2);
            if (sa < min) {
                min = sa;
                ans = a[i];
            }
        }
        System.out.print(a[n - 1] + " ");
        System.out.println(ans);

    }
}


Measured memory_bytes: 50452
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>

using namespace std;

struct edge {
  int v, w;
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<edge>> g(n);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  vector<int> sign(n, 0);
  vector<long long> sum(n);
  queue<int> q;
  q.push(0);
  sign[0] = 1;
  auto check = [&](long long x) {
    queue<int> q;
    q.push(0);
    vector<long long> val(n, -1);
    val[0] = x;
    while (!q.empty()) {
      int u = q.front(); q.pop();
      for (edge e : g[u]) {
        if (val[e.v] == -1) {
          val[e.v] = e.w - val[u];
          if (val[e.v] < 1) return false;
          q.push(e.v);
        } else if (val[u] + val[e.v] != e.w) {
          return false;
        }
      }
    }
    return true;
  };
  while (!q.empty()) {
    int u = q.front(); q.pop();
    for (edge e : g[u]) {
      if (sign[e.v] == 0) {
        // x + sum[u] -> - x + e.w - sum[u]
        sign[e.v] = -sign[u];
        sum[e.v] = e.w - sum[u];
        q.push(e.v);
      } else if (sign[e.v] == -sign[u]) {
        if (sum[e.v] != e.w - sum[u]) {
          cout << 0 << endl;
          return 0;
        }
      } else {
        // x + sum[e.v]
        // x + sum[u] -> e.w - x - sum[u]
        // 2x = e.w - sum[u] - sum[e.v]
        int tmp = e.w - sum[u] - sum[e.v];
        tmp *= sign[e.v];
        if (tmp <= 0 || tmp % 2 == 1) {
          cout << 0 << endl;
          return 0;
        }
        if (check(tmp / 2)) {
          cout << 1 << endl;
        } else {
          cout << 0 << endl;
        }
        return 0;
      }
    }
  }
  long long L = 1;
  long long R = 2e9;
  for (int i = 0; i < n; i++) {
    if (sign[i] == 1) {
      // x + sum[i] >= 1
      L = max(L, 1 - sum[i]);
    } else {
      // -x + sum[i] >= 1
      R = min(R, sum[i] - 1);
    }
  }
  cout << max(0LL, R - L + 1) << endl;
}

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


bool p[(int)1e5 + 43];

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


	memset(p, 1, sizeof p);
	for(long long i = 2; i <= 1e5 + 41; ++i){
	if(p[i]){
		for(long long j = i * i; j <= 1e5 + 41; j += i)
			p[j] = 0;
		}
	}
	int x;
	cin >> x;
	p[1] = 0;
	for(int i = x; ; ++i)
		if(p[i])
			return cout << i << '\n', 0;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll; 
const int N = 1e5+5;
const ll M = 1e9+7;

char mp[10][10];
int n,m,k;

inline bool check(int x,int y){
	int res = 0;
	for(int i = 0;i < n;++i){
		for(int j = 0;j < m;++j){
			if((x & (1 << i)) || (y & (1 << j))) continue;
			if(mp[i][j] == '#') res++;
		}
	}
	return res == k;
}

int main()
{	
	scanf("%d%d%d",&n,&m,&k);
	for(int i = 0;i < n;++i) scanf("%s",mp[i]);
	
	int ans = 0;
	for(int i = 0;i < (1 << n);++i){
		for(int j = 0;j < (1 << m);++j){
			if(check(i,j)) ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  //vector<bool> see(n);
  ll count = 0;
  ll nowmax = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i];
    //see[i] = false;
    if(a[i] > nowmax){
      //see[i] = true;
      count++;
      nowmax = a[i];
    }
  }
  //cout << count << endl;
  if(k - count <= 0){
    cout << 0 << endl;
    return 0;
  }
  ll res = 0;
  res = pow(10,18);
  for(int i = 0;i < (1<<n); i++){//2のa乗回繰り返す(0 ~ 2^a- 1)
    ll nowcost = 0;
    ll keta = 0;
    ll purasu = 0;
    ll maxhigh = 0;
    for(int j = 0;j < n;j++){
      //if(!see[j]){
        if(i & (1<<j)){//小さい方からj桁目(0から)が1であったら
          if(a[j] < maxhigh + 1)purasu++,nowcost += maxhigh + 1 - a[j];
          //if(i == 31)cout << maxhigh << endl;
          //if(i == 11)cout << "j" << j << " " << nowcost << " " << maxhigh << endl;
              maxhigh = max(a[j],maxhigh + 1);
        }
      //}
      else{
        if(maxhigh < a[j])purasu++;
        maxhigh = max(maxhigh,a[j]);
      }
      if(purasu >= k){
        res = min(res,nowcost);
        //cout << nowcost << endl;
        //if(nowcost == 8)cout << "i" << i << endl;
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import sys
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False

def ddprint(x):
  if DBG:
    print(x)

n = inn()
if n<=8:
    a = [0,0,0, '2 5 63', '2 5 20 63',
        '2 3 4 6 9', '2 3 4 6 9 12', '2 3 4 6 8 9 10',
        '2 3 4 6 8 9 10 12']
    print(a[n])
    exit()
m = (n-1)//8
r = (n-1)%8
b = ['6 ', '2 4 ', '2 4 6 ', '2 3 4 9 ',
        '2 3 4 6 9 ', '2 3 4 8 9 10 ', '2 3 4 6 8 9 10 ',
        '2 3 4 6 8 9 10 12 ']
printn(b[r])
for i in range(1,m+1):
    p = 12*i
    printn('{} {} {} {} {} {} {} {} '.format
      (p+2,p+3,p+4,p+6,p+8,p+9,p+10,p+12))
print('')


Measured memory_bytes: 39280
#include <stdio.h>
#include <math.h>

int main()
{
     long long int n,t;
     scanf("%lld %lld",&n,&t);
     long long int a[n],sum=t;
     for(int i=0;i<n;i++)
     {
         scanf("%lld",&a[i]);
     }
     for(int i=1;i<n;i++)
     {
         if(a[i]-a[i-1]>=t)
            sum+=t;
         else
         {
             sum+=a[i]-a[i-1];
         }
     }


     printf("%lld",sum);
}

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

int main(){

    int N;
    cin >> N;

    vector<int> A(N);
    for (int i=0; i<N; i++){
        cin >> A.at(i);
    }

    /*
    int max_num = N, max_length = 0, min_num = 1, min_length = 1;
    vector<int> X(N);
    vector<int> Y(N);
    */

    map<int64_t, int64_t> ans;

    for (int i=0; i<N; i++){
        ans[A.at(i) + (i+1)]++;
    }

    int64_t sum = 0;

    for (int i=0; i<N; i++){
        sum += ans[(i+1) - A.at(i)];
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 26556
#include<stdio.h>
int main(void)
{
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a+b>c+d) printf("Left");
  else if(a+b==c+d) printf("Balanced");
  else printf("Right");
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;

int main() {
    stack<int> S1;
    stack<pair<int, int> >S2;
    char s[20000 + 10];
    scanf("%s", s);
    int i = 0, sum = 0;
    while (s[i] != '\0') {
        // 若是\则压入栈
        if (s[i] == '\\')
            S1.push(i);
        else if (s[i] == '/' && !S1.empty()) {
            int j = S1.top(); S1.pop();
            // 加上新形成的面积
            sum += i - j;
            int a = i - j;

            // 同一块的合在一起
            while (!S2.empty() && S2.top().first > j) {
                a += S2.top().second; S2.pop();
            }
            S2.push(make_pair(j, a));
        }
        i++;
    }

    vector<int> ans;
    while (!S2.empty()) {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    printf("%d\n", sum);
    int len = ans.size();
    printf("%d", len);
    for (int i = len - 1; i >= 0; i--) {
        printf(" %d", ans[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3384
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete



main = do
    n <- getInt
    [d, x] <- getInts
    a <- map (d `divCeil`) <$> replicateM n getInt
    print $ x + sum a

Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll A,B;
	cin>>A>>B;
	ll g = __gcd(A,B);
	map<ll,ll> com;
	com[1LL]++;
	for(ll i = 2LL; i*i<=g; ++i){
		while(g%i==0LL){
			com[i]++;
			g /= i;
		}
	}
	if(g != 1LL)com[g]++;
	cout<<com.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    Int n, d;
    cin >> n >> d;
    double x[30][30];
    for (Int i = 0; i < n; i++) {
        for (Int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }
    Int cnt = 0;
    for (Int i = 0; i < n - 1; i++) {
        for (Int j = i + 1; j < n; j++) {
            double p = 0.0;
            for (Int k = 0; k < d; k++) {
                p += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            p = sqrt(p);
            if (p == (Int)p) cnt++;
        }
    }
    dump(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ITM_MAX		200000									// 最大景品数
#define D_CHAR_MAX		15										// 最大文字数

// 内部変数
static FILE *szpFpI;											// 入力
static char sc2Itm[D_ITM_MAX][D_CHAR_MAX];						// 景品
static int siICnt;												// 景品数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 改行カット
// 戻り値：文字数
int
fCutCrLf(
	char *pcpStr				// <I> 文字列
)
{
	int i;

	for (i = 0; pcpStr[i] != '\0'; i++) {
		if (pcpStr[i] == '\n') {
			pcpStr[i] = '\0';
			break;
		}
	}

	return i;
}

// 比較関数 - 昇順
int
fCmpFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	char *lcpVal1 = (char *)pzpVal1;
	char *lcpVal2 = (char *)pzpVal2;

	// 昇順
	return strcmp(lcpVal1, lcpVal2);
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 景品数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siICnt);

	// 景品 - 取得
	for (i = 0; i < siICnt; i++) {
		fgets(sc2Itm[i], sizeof(sc2Itm[0]), szpFpI);
		fCutCrLf(sc2Itm[i]);
	}

	// 景品 - 重複カット
	qsort(sc2Itm, siICnt, sizeof(sc2Itm[0]), fCmpFnc);
	int liTo = 1;
	int liDCnt = 0;
	for (i = 1; i < siICnt; i++) {
		if (strcmp(sc2Itm[i], sc2Itm[liTo - 1])) {
			strcpy(sc2Itm[liTo], sc2Itm[i]);
			liTo++;
		}
		else {
			liDCnt++;
		}
	}

	return siICnt - liDCnt;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 7320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
ll n,m,ans=0;
int main(){
  cin >> n >> m;
  ans += (n*2 <= m?n:m/2);
  if(n*2 <= m){
    m -= n*2;
    ans += m/4;
  }
  cout << ans << endl;
}


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

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

    int cnt=0;
    for(int i=1;i<n-1;i++){
        if((p[i]<p[i+1] && p[i-1]<p[i])||(p[i]<p[i-1] && p[i+1]<p[i])){
            cnt ++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
PROGRAM ATCODER

implicit none
character(len=10**5) :: s
integer :: count1=0,count2=0,size_s,i

read*, s

size_s = len_trim(s)

! 10101010....とした場合
do i = 1, size_s, 1
  if ( mod(i,2) == 1 ) then
    if ( s(i:i) /= '1' ) then
      count1 = count1 + 1
    end if
  else
    if ( s(i:i) /= '0' ) then
      count1 = count1 + 1
    end if
  end if
end do

! 010101010....とした場合
do i = 1, size_s, 1
  if ( mod(i,2) == 1 ) then
    if ( s(i:i) /= '0' ) then
      count2 = count2 + 1
    end if
  else
    if ( s(i:i) /= '1' ) then
      count2 = count2 + 1
    end if
  end if
end do

print'(i0)', min(count1,count2)

END PROGRAM ATCODER

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(int x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(int x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int W,H,N;
    Scd3(W,H,N);

    vii a(N);
    int x,y;
    Rep(i,N){
        Scd2(x,y);
        a[i] = {x,y};
    }

    vi w(W);
    vi h(H);

    Rep(i,N){
        x = a[i].first;
        y = a[i].second;
        if( x ) w[x-1] = max( w[x-1], y );
        if( y ) h[y-1] = max( h[y-1], x );
    }

    RRepe(i,W,1){
        w[i] = max( w[i], w[i+1] );
    }
    RRepe(i,H,1){
        h[i] = max( h[i], h[i+1] );
    }

    int ans = INF;

    Rep(i,W){
        ans = min( ans, i + w[i] );
    }
    Rep(i,H){
        ans = min( ans, i + h[i] );
    }

    printf ("%d\n", ans );

    return 0;
}

/*
 * ....x 2
 * ..x.. 1
 * ..... 1
 * .x... 0
 * x.... 0
 * 
 * 41000
 */




Measured memory_bytes: 4392
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> P2;


int main(){
    ll l, r;
    cin >> l >> r;

    ll res = LLONG_MAX;
    for(ll i = l; i <= l + 2030; i++){
        for(ll j = i + 1; j <= i + 2030; j++){
            if(i < r && j <= r){
                res = min(res, i * j % 2019);
            }
        }
    }

    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 256
n=int(input())
flg = 0
if n < 0:
    n *= -1
    flg = 1
l=list(map(int,str(bin(n))[2:]))
for i in range(1,len(l)+3): 
    try:
        if l[-i] == 2:
            l[-i] = 0
            if i == len(l):
                l.insert(0,1)
            else:
                l[-(i+1)]+=1
        if i%2==flg and l[-i]==1:
            if i == len(l):
                l.insert(0,1)
            else:
                l[-(i+1)]+=1
    except:
        pass
s = ''.join([str(x) for x in l])
print(s)

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	private static Node[] V;
	private static ArrayList<Integer> sort = new ArrayList<>();
	
	public static void main(String[] args) {
		int Vn = sc.nextInt();
		int En = sc.nextInt();
		
		V = new Node[Vn];
		for(int i=0; i<Vn; i++) {
			V[i] = new Node();
			V[i].id = i;
		}
		
		for(int i=0; i<En; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			V[s].nbr.add(t);
		}
		
		for(int i=0; i<Vn; i++) {
			if(V[i].visited == 0) {
				V[i].visit();
			}
		}
		
		System.out.println(0);
	}
	
	static class Node {
		int id;
		HashSet<Integer> nbr = new HashSet<>();
		int visited = 0;
		
		void visit() {
			if(visited == 1) {
				System.out.println(1);
				System.exit(0);
			} else if(visited == 0) {
				visited = 1;
				for(int x : nbr) {
					V[x].visit();
				}
				
				visited = 2;
				sort.add(id);
			} 
		}
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 25560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i, n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  int ans = 0;
  for (auto e : mp) {
    if (e.second%2)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pii;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define sz(a) ll(a.size())
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front 
#define MAXN 100010
#define N 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define debug(x) cout << '>' << #x << ':' << x << " ";
#define nl '\n'
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define int long long int
main()
{
    IO;
	int T = 1;
    // cin >> T;
    fo(c, 1, T){
        // cout<<"Case #"<<c<<": ";
        string s, t;
        cin >> s >> t;
        int n = s.size(), m = t.size();
        int ans = INF;
        for(int i = 0; i < n; i++){
            int cnt = 0;
            if(i+m > n)break;
            for(int j = i; j < min(i + m, n); j++){
                if(s[j] == t[j-i]){
                    cnt++;
                }
            }
            ans = min(ans, m-cnt);
        }
        cout << ans << nl;
    }
    return 0;
}

Measured memory_bytes: 3648
#! /usr/bin/env python3

def main():
    S = input()
    cnt = 0
    l = list(S)
    while 1:
        for i in set(''.join(l)):
            if all((1 if i in x else 0) for x in l):
                print(cnt)
                return
        cnt += 1
        l = [l[x]+S[x+cnt] for x in range(len(l)-1)]
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
using namespace std;
typedef long long int lli;

struct work
{
    lli time;
    lli deadline;

    bool operator<(const work &another) const
    { //演算子のオーバーロード
        if (deadline == another.deadline)
        {
            return time < another.time; //かかる時間
        }
        return deadline < another.deadline; // 締切
    }
};

int main()
{   
    vector<work> works;
    lli N;
    int i;
    bool tf = true;
    cin >> N;
    lli sum = 0;
    for (i = 0; i < N; i++)
    {
        work wo;
        cin >> wo.time >> wo.deadline;
        works.push_back(wo);
    }
    sort(works.begin(), works.end());
    for (i = 0; i < N; i++)
    {
        sum += works[i].time;
//        cout << sum << "  " << works[i].deadline << endl;
        if(works[i].deadline < sum){
            tf = false;
            break;
        }
    }
    if(tf){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 6512
import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


inp = []
ok = False
for _ in range(Num()):
    a, b = List()
    inp.append([a, b])
for i in range(len(inp) - 3 + 1):
    if inp[i][0] == inp[i][1] and inp[i + 1][0] == inp[i + 1][1] and inp[i + 2][0] == inp[i + 2][1]:
        ok = True
        break
print("Yes" if ok else "No")


Measured memory_bytes: 9200