akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {

    public static void main(String[] args) {
        System.out.println(process(readAll(System.in)));
    }

    protected static String process(String data) {
        final String[] lines = splitForLines(data);

        final int[] array = split(lines[1]);

        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        long sum = 0;

        for(int i : array){
            min = Math.min(i, min);
            max = Math.max(i, max);
            sum += i;
        }

        return min + " " + max + " " + sum;
    }

    private static String readAll(InputStream is) {
        InputStreamReader r = null;
        BufferedReader br = null;

        try {
            r = new InputStreamReader(is);
            br = new BufferedReader(r);
            StringBuilder sb = new StringBuilder();
            String s;

            while ((s = br.readLine()) != null) {
                sb.append(s).append('\n');
            }

            return sb.toString();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                }
            }
            if (r != null) {
                try {
                    r.close();
                } catch (IOException e) {
                }
            }
        }
    }

    private static int[] split(String s) {
        final String[] s0 = s.split(" ");
        int[] ia = new int[s0.length];

        for (int i = 0; i < s0.length; i++) {
            ia[i] = Integer.parseInt(s0[i]);
        }

        return ia;
    }

    private static String[] splitForLines(String lines) {
        return lines.split("\\n");
    }

}

Measured memory_bytes: 25584
n=int(input())
l=[list(map(int,input().split()))    for _ in range(n)]

def chk():
  v=0
  for j in range(n):
    for i in range(n):
      f=True
      for k in range(n):
        if l[i][j]>l[i][k]+l[k][j]:
          return -1
        if l[i][j]==l[i][k]+l[k][j] and i!=k and k!=j:
          f=False
      if f:v+=l[i][j]
  return v//2
print(chk())

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

int main() {
    int n, t;
    long long all = 0;
    cin >> n;
    int max = -1000000, min = 1000000;
    for (int i = 0; i < n; i++) {
        cin >> t;
        if (t > max) max = t;
        if (t < min) min = t;
        all += t;
    }
    cout << min << " " << max << " " << all << endl;
    return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e19;
/*ll power(ll x,ll y,ll m)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%m;
        x=(x*x)%m;
        y=y/2;
    }
    return res;
}*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    ll i;
    cin>>s;
    for(i=0;i<s.size();i++)
        cout<<'x';
    cout<<endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("unroll-loops")

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

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

const int mod = 1e9 + 7;
const int inf = 9e18;
const int N = 2e5 + 5;

int i,n,k;

void solve(){
    cin>>n>>k;
    int ways=0;
    for(i=k;i<=n+1;++i){
        int start=i*(i-1)/2;
        int end=i*n-i*(i-1)/2;
        ways+=end-start+1;
        ways%=mod;
    }
    cout<<ways;
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

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

typedef long long ll;
int main(){
  ll n,m;
  cin>>n>>m;
  if(n*2+1>m){cout<<m/2<<"\n"; return 0;}
  ll ans=0;
  m = m-n*2;
  cout<<m/4+n<<"\n";
}


Measured memory_bytes: 256
module Main where
import Data.Char
int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = words
printer = unlines . (:[])

solver = (\x->if x then "Four" else "Three") . (>0) . length . filter (=="Y")

Measured memory_bytes: 508
import collections, sys

n = sys.stdin.readline()
s = []
for _ in range(0,int(n)):
  s.append(sys.stdin.readline().replace('\n',''))

c = collections.Counter(s)
max = c.most_common()[0][1]
l = sorted(list(dict(filter(lambda x: x[1]==max, c.items())).keys()))
for k in l:
  print(k)

Measured memory_bytes: 54248
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x <<": "<<x<<"\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> using vec = std::vector<T>;
template <class T = int> T in(){T x; cin>>x;return(x);}
template <class T > void print(T& x){cout<<x<<"\n";}
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//差が-1であるが連続していない。
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N=in<int>();
  vec<int>H(N);
  REP(i,N){
      cin >>H[i];
  }
  bool flg = true;
  REPR(i,N-2){
      if (H[i+1]-H[i]<=-2){
          flg = false;
          break;
      }
      if (H[i+1]-H[i]==-1){
          H[i]--;
      }
  }
  cout << (flg?"Yes":"No") <<endl;


}

Measured memory_bytes: 1024
//JSD
#include<iostream>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#define ll long long 
using namespace std;
ll calc(ll a,ll c){
	return (a/c);
}
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll q=calc(b,c)-calc(a-1,c);
	ll p=calc(b,d)-calc(a-1,d);
	ll lc=(c*d)/__gcd(c,d);
	ll z=calc(b,lc)-calc(a-1,lc);
	cout<<b-a-p-q+z+1;
	
	return  0;
}


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

int main(){
 	long h,w;
	cin >> h >> w;
	if(h%3 == 0 || w %3 == 0) {
		printf("0\n");
		return 0;
	}
	long mini = min(h,w);
  	long tmp;
	for(long x = 1; x <= w-1; x++) {
		tmp = (h%2 == 0) ?abs(x*h/2 - (w-x) *h ) :
      max(abs(x*(h/2) - (w-x) *h ), abs(x*(h/2+1) - (w-x) *h ));
      	if(mini > tmp) {
    		mini =  tmp;
		}
	}
	for(long y = 1; y <= h-1; y++) {
		tmp = (w%2 == 0) ?abs(y*(w/2) - (h-y) *w ) :
      max( abs(y*(w/2) - (h-y) *w ),  abs(y*(w/2+1) - (h-y) *w ));
       	if(mini > tmp) {
			mini = tmp;
		}
	}
	printf("%d\n",mini);
}


Measured memory_bytes: 256
cnt = 0

def merge(array, left, middle, right):
    n1 = middle - left
    n2 = right - middle
    L = array[left:left + n1] + [float("inf")]
    R = array[middle:middle + n2] + [float("inf")]
    i = 0
    j = 0
    for k in range(left, right):
        global cnt
        cnt += 1
        if L[i] <= R[j]:
            array[k] = L[i]
            i += 1
        else:
            array[k] = R[j]
            j += 1


def mergeSort(array, left, right):
    if left + 1 < right:
        middle = int((left + right) / 2.)
        mergeSort(array, left, middle)
        mergeSort(array, middle, right)
        merge(array, left, middle, right)


n = int(input())
array = [int(x) for x in input().split()]
mergeSort(array, 0, len(array))
print(*array)
print(cnt)


Measured memory_bytes: 61672
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))

using namespace std;
int n;
int t[200];
int m;
int wa;

int main(){
  cin >> n;
  REP(i,n){
    cin >> t[i];
    wa += t[i];
  }
  cin >> m;
  REP(i,m){
    int p,x;
    cin >> p >> x;
    cout << wa-t[p-1]+x << endl; 
  }
  return 0;
}


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

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

 typedef long long ll;
 const long long INF = 1LL << 60;



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

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

    int dp[100010][3];
    for(int i = 0; i < 100010; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            dp[i][j] = 0;
        }
    }
    
    for(int i = 1; i <=n; i++)
    {
        chmax(dp[i][0], dp[i-1][1] + d[i-1][0]);
        chmax(dp[i][0], dp[i-1][2] + d[i-1][0]);
        chmax(dp[i][1], dp[i-1][0] + d[i-1][1]);
        chmax(dp[i][1], dp[i-1][2] + d[i-1][1]);
        chmax(dp[i][2], dp[i-1][0] + d[i-1][2]);
        chmax(dp[i][2], dp[i-1][1] + d[i-1][2]);
    }

    int ans = max(dp[n][0], dp[n][1]);
    ans = max(ans, dp[n][2]);

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <ll, ll> P;

const ll MOD=1000000007;
int N;
P A[1<<18];
ll dp[1<<18];
P getmax(P x, P y){
    ll a[4];
    a[0]=x.fr; a[1]=x.sc; a[2]=y.fr; a[3]=y.sc;
    sort(a,a+4);
    return P(a[3], a[2]);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,0,1<<N){
        ll a;
        cin>>a;
        A[i]=P(a,0);
    }
    rep(i,0,N){
        rep(j,0,1<<N){
            if (j&(1<<i)){
                A[j]=getmax(A[j], A[j^(1<<i)]);
            }
        }
    }
    dp[1]=A[1].fr+A[1].sc;
    cout <<dp[1]<<"\n";
    rep(i,2,1<<N){
        dp[i]=max(dp[i-1], A[i].fr+A[i].sc);
        cout <<dp[i]<<"\n";
    }
}

Measured memory_bytes: 9216
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
inline int Read(){
	char ch=getchar();int u=0,f=1;
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){u=u*10+ch-48;ch=getchar();}
	return u*f;
} 
int cnt,k;int dis[100500],head[100500];
struct edge{
	int to,next,w;
}e[500500];
bool flag[100500];
inline void insert(int x,int y,int w){e[++cnt].to=y;e[cnt].w=w;e[cnt].next=head[x];head[x]=cnt;}
void spfa(){
	queue<int>q;
	memset(dis,127,sizeof(dis));
	q.push(1);dis[1]=0; 
	while(!q.empty()){
		int x=q.front();q.pop();flag[x]=0;
		for(register int i=head[x];i;i=e[i].next){		
			if(dis[x]+e[i].w<dis[e[i].to]){
				dis[e[i].to]=dis[x]+e[i].w;
				if(!flag[e[i].to]){
					flag[e[i].to]=1;
					q.push(e[i].to);
				}
			}
		}	
	}
}
int main(){
	k=Read();//k>=2 不用特判1 
	for(register int i=0;i<k;i++){
		insert(i,(i+1)%k,1);
		insert(i,(i*10)%k,0);
	}
	spfa();
	printf("%d",dis[0]+1);	
	return 0;
}

Measured memory_bytes: 7168
using System;

class Simple_Calculator
{
    public static void Main()
    {
    	while(true)
    	{
    		string number_str = Console.ReadLine();
	        string[] tmp_number = number_str.Split(' ');
	        int a = int.Parse(tmp_number[0]);
	        int b = int.Parse(tmp_number[2]);
	        string op = tmp_number[1];

	        if (op == "+")
	        {
	            Console.WriteLine(a + b);
	        }
	        else if (op == "-")
	        {
	            Console.WriteLine(a - b);
	        }
	        else if (op == "*")
	        {
	            Console.WriteLine(a * b);
	        }
	        else if (op == "/")
	        {
	            Console.WriteLine(a / b);
	        }
	        
    		if(op == "?")
    		{
    			break;
    		}
    	}
    }
}

Measured memory_bytes: 9236
#include <stdio.h>
 
int main()
{
	long long d,t,s;
  scanf("%lld %lld %lld",&d,&t,&s);
  long long ans = t*s;
  if(ans >= d){
  	printf("Yes\n");
  }
  else{
  	printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,x=0,y=0,ans;
    scanf("%lld %lld",&n,&m);
    if(n==1&&m==1)
    {
        printf("1");
        return 0;
    }
    if(n==1||m==1)
    {
        x=2;
    }
    else
    {
        x=n*2;
        x+=(m*2-4);
    }
    ans=m*n-x;
    printf("%lld",ans);
    return 0;

}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	OUT(max(0, min(B, D) - max(A, C)));
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cout<<"ACL";
	cout<<endl;
}

Measured memory_bytes: 3636
S = input()

f = int(S[0])*10 + int(S[1])
b = int(S[2])*10 + int(S[3])
ans = ''
if (1<= f and f <= 12) and (1<= b and b <= 12):
    ans = 'AMBIGUOUS'
elif (1<=b and b <= 12):
    ans = 'YYMM'
elif (1<=f and f <= 12):
    ans = 'MMYY'
else:
    ans = 'NA'
print(ans)


Measured memory_bytes: 38256
package main

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

var sc = bufio.NewScanner(os.Stdin)

// nextLine is to read next line.
func nextLine() int {
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	return num
}

// splitElement return elements of one line.
func splitElement() []int {
	var nums []int
	sc.Scan()
	strs := strings.Split(sc.Text(), " ")
	for _, v := range strs {
		n, _ := strconv.Atoi(v)
		nums = append(nums, n)
	}
	return nums
}

// trace print Array content.
func trace(a [100]int, n int) {
	for i := 0; i < n; i++ {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Printf("%d", a[i])
	}
	fmt.Println()
}

func insertionSort(a [100]int, n int) {
	for i := 0; i < n; i++ {
		v := a[i]
		j := i - 1
		for j >= 0 && a[j] > v {
			a[j+1] = a[j]
			j--
		}
		a[j+1] = v
		trace(a, n)
	}
}

func main() {
	var a [100]int

	n := nextLine()
	for i, v := range splitElement() {
		a[i] = v
	}

	insertionSort(a, n)
}



Measured memory_bytes: 1240
n, m = map(int, input().split())

a = []
for i in range(n):
    alst = list(map(int, input().split()))
    a.append(alst)

b = []
for i in range(m):
    b.append(int(input()))

c = [0]*n
for i in range(n):
    for j in range(m):
        c[i] += a[i][j]*b[j]

# for i in range(n):
    print(c[i])


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

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

    int a, b, c;
    cin >> a >> b >> c;

    int amul = a + a;
    int bmod = a%b;

    if(a%b==c || amul%b==c){
        puts("YES");
        return 0;
    }

    while(amul%b != bmod){
        amul += a;
        if(amul%b == c){
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=100111;

vector<int> con[maxn];
int f[maxn];int gf(int x){return x==f[x]?x:f[x]=gf(f[x]);}

int n,m,a[maxn],b[maxn],ord[maxn];
bool cmp(int x,int y){return mp(a[x],x)<mp(a[y],y);}

LL s[maxn],dp[maxn];
int main()
{
	get2(n,m);
	for(int i=1;i<=n;i++)
	{
		get2(a[i],b[i]);
		a[i]=max(a[i]-b[i],0);
		ord[i]=i;f[i]=i;
	}
	for(int i=1,u,v;i<=m;i++)
	{
		get2(u,v);
		con[u].pb(v);con[v].pb(u);
	}
	
	sort(ord+1,ord+n+1,cmp);
	for(int _=1;_<=n;_++)
	{
		int x=ord[_];
		dp[x]=a[x];s[x]=b[x];
		for(auto v:con[x])if(mp(a[x],x)>mp(a[v],v)&&gf(v)!=x)
		{
			int vv=gf(v);
			s[x]+=s[vv];
			dp[x]=min(dp[x],dp[vv]+max(0ll,a[x]-s[vv]-dp[vv]));
			f[vv]=x;
		}
	}
	printf("%lld\n",dp[ord[n]]+s[ord[n]]);
	return 0;
}

Measured memory_bytes: 9084
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <tuple>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#include <cmath>

using namespace std;
using lint = long long int;


int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;

	if (a * 2 > w || b * 2 > h) {
		cout << "No" << endl;
		return 0;
	}

	int** s = new int* [h];
	for (int i = 0; i < h; i++) {
		s[i] = new int[w];
	}

	int invA = w - a;
	int invB = h - b;
	
	for (int hi = 0; hi < invB; hi++) {
		// 行
		int wi = 0;
		for (; wi < invA; wi++) {
			s[hi][wi] = 1;
		}
		for (; wi < w; wi++) {
			s[hi][wi] = 0;
		}
	}
	for (int hi = invB; hi < h; hi++) {
		// 行
		int wi = 0;
		for (; wi < invA; wi++) {
			s[hi][wi] = 0;
		}
		for (; wi < w; wi++) {
			s[hi][wi] = 1;
		}
	}

	for (int hi = 0; hi < h; hi++) {
		for (int wi = 0; wi < w; wi++) {
			cout << s[hi][wi];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll MOD=1e9+7;
const ll HF=5e8+4;

ll tim(ll a, ll b){
	return (a*b)%MOD;
}
ll adm(ll a, ll b){
	return (a+b)%MOD;
}

int main(){
	int N;
	cin>>N;
	string S;
	cin>>S;
	int M=sz(S);
	ll dp[5005][5005];
	rep(i,N+1)rep(j,i+1)dp[i][j]=0;
	dp[0][0]=1;
	rep(i,N)rep(j,i+1){
		dp[i+1][j+1]=adm(tim(dp[i][j],2), dp[i+1][j+1]);
		dp[i+1][max(j-1,0)]=adm(dp[i][j], dp[i+1][max(j-1,0)]);
	}
	ll ans=dp[N][M];
	rep(_,M)ans=tim(ans, HF);
	cout<<ans<<endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    int c = 0;
    while(n--) {
        int a;
        cin >> a;
        while(a % 2 == 0) {
            a /= 2;
            c++;
        }
    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,e;
	cin>>a>>b>>c;
	d=c;
	a--;
	while(a--)
	{
		cin>>e;
	    c=__gcd(e,c);
		d=max(e,d);
	}
	if(b%c==0&&b<=d)cout<<"POSSIBLE\n";
	else cout<<"IMPOSSIBLE\n";
}

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

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

    int r = n;
    int sum = 0;
    int digit = log10(n);
    for(int i=digit;i>=0;i--){
        sum += r / int(pow(10,i));
        r %= int(pow(10,i));
    }

    cout << (n%sum ? "No" : "Yes") << endl;


    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin>>n;
    cout<<(n+1)/2<<endl;
    
    

 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;

int main(void){
    int n, a[30000];
    cin >> n;
    
    int num = 0;
    for (int i = 3; i <= 9; i++) {
        for (int j = 0; j < pow(3, i); j++) {
            int b = 0, ic = i, jc = j;
            for (int l = 0; l < i; l++) {
                if (jc % 3 == 0) b += 3;
                if (jc % 3 == 1) b += 5;
                if (jc % 3 == 2) b += 7;
                b *= 10;
                jc /= 3;
            }
            b /= 10;
            //cout << b << endl;
            
            int c3 = 0, c5 = 0, c7 = 0, bc = b;
            for (int k = 0; k < i; k++) {
                if (bc % 10 == 3) c3++;
                if (bc % 10 == 5) c5++;
                if (bc % 10 == 7) c7++;
                bc /= 10;
            }
            if (c3 > 0 && c5 > 0 && c7 > 0 && c3 + c5 + c7 == i) {
                a[num] = b;
                num++;
            }
        }
    }
    
    sort(a, a + num);
    int ans = 0;
    for (int i = 0; i < 26484; i++) {
        if (a[i] <= n) ans++;
        else break;
    }
    
    cout << ans << endl;
    
    
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = Array(N) { readLine()!!.toLong() }

    var res = 0L
    var mx = 0L

    for (i in A.indices) {
        val t = (A[i] - 1) / (mx + 1)
        res += t
        val a = A[i] - (mx + 1) * t

        mx = Math.max(mx, if (t != 0L) 1L else A[i] - (mx + 1) * t)
        A[i] = a
    }

    println(res)
}


Measured memory_bytes: 39816
#include<iostream>

using namespace std;

int main()
{
    int t, c1 = 0, c2 = 0, c3 = 0, c4 = 0;

    cin >> t;

    while(t--)
    {
        string ans;
        
        cin >> ans;

        if(ans == "AC")
            c1++;
        else if (ans == "WA")
            c2++;
        else if(ans == "TLE")
            c3++;
        else
        {
            c4++;
        }
    }

    cout << "AC x " << c1 << "\n" << "WA x " << c2 << "\n" << "TLE x " << c3 << "\n" << "RE x " << c4 << "\n";
}

Measured memory_bytes: 3628
import java.io.*;
import java.util.ArrayDeque;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(br.readLine());
        ArrayDeque<String> list = new ArrayDeque<String>();
        String[] input;

        for (int i = 0; i < n; i++) {
            input = br.readLine().split(" ");

            if (input[0].equals("insert")) {
                list.addFirst(input[1]);
            } else if (input[0].equals("delete")) {
                list.remove(input[1]);
            } else if (input[0].equals("deleteFirst")) {
                list.removeFirst();
            } else {
                list.removeLast();
            }
        }

        StringBuilder sb = new StringBuilder("");
        sb.append(list.poll());
        for (String element: list) {
            sb.append(" ").append(element);
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 227960
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

    Node[] nodes = new Node[200_001];
    for (int i = 0; i < 200_001; i++) nodes[i] = new Node(i);
    int N = scanner.nextInt();
    for (int i = 0; i < N; i++) {
      int x = scanner.nextInt();
      int y = scanner.nextInt() + 100_000;
      nodes[x].adjacents.add(nodes[y]);
      nodes[y].adjacents.add(nodes[x]);
    }

    boolean[] visited = new boolean[200_001];
    long res = 0;
    for (int i = 0; i < 200_001; i++) {
      if (!visited[i]) {
        Result result = new Result();
        dfs(nodes[i], visited, result);
        res += (long) result.nx * result.ny - result.m / 2;
      }
    }
    System.out.println(res);
  }

  private static void dfs(Node node, boolean[] visited, Result result) {
    visited[node.id] = true;
    if (node.id <= 100_000) result.nx++;
    else result.ny++;
    for (Node n : node.adjacents) {
      result.m++;
      if (!visited[n.id]) {
        dfs(n, visited, result);
      }
    }
  }

  private static class Result {
    int nx;
    int ny;
    int m;
  }

  private static class Node {
    private final int id;
    private List<Node> adjacents = new ArrayList<>();
    public Node(int id) {
      this.id = id;
    }
  }
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int k, s;cin >> k >> s;
    int ans = 0;
    inc(i, 0, k+1){
        inc(j, 0, k+1){
            int l = s-i-j;
            if(l >= 0 && l <= k){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
def func(n, i):
    ans = 0
    while n>0:
        ans += n%i
        n //= i
    return ans
b=n
for i in range(n+1):
    tmp = func(i, 6) + func(n-i, 9)
    b = min(tmp, b)
print(b)

Measured memory_bytes: 41068
import java.util.Scanner;

class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int count1 = sc.nextInt();
    int count0 = sc.nextInt();
    int countMinus1 = sc.nextInt();
    int count = sc.nextInt();
    
    sc.close();
    

    int x = 0;
    int y = 0;
    int z = 0;
    
    x = count - count1 > 0 ? count1 : count;
    count -= x;
    
    if (count != 0) {
      y = count - count0 > 0 ? count0 : count;
      count -= y;
      
      if (count != 0) {
        z = count - countMinus1 > 0 ? countMinus1 : count;
      }
    }
    int answer = 1 * x + 0 * y + (-1 * z);
    
    System.out.println(answer);
    
  }
}

Measured memory_bytes: 35720
/**
 *　　　　　　  　　┏┓　　 　┏┓
 * 　　　　　  　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　  　　┃　　　　　　　┃ 　
 * 　　　　　  　　┃　　　━　　 　┃
 * 　　　　　  　　┃　＞　　　＜　┃
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃...　⌒　... 　┃
 * 　　　　　　  　┃              ┃
 * 　　　　　　  　┗━┓          ┏━┛
 * 　　　　　　　　　┃          ┃　Code is far away from bug with the animal protecting　　　　　　　　　　
 * 　　　　　　　　　┃          ┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃          ┃　　　　　　　　　　　
 * 　　　　　　　　　┃          ┃  　　　　　　
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃　　　　　　　　　　　
 * 　　　　　　　　　┃          ┗━━━┓
 * 　　　　　　　　　┃              ┣┓
 * 　　　　　　　　　┃              ┏┛
 * 　　　　　　　　　┗┓┓┏━━━━━━━━┳┓┏┛
 * 　　　　　　　　　　┃┫┫       ┃┫┫
 * 　　　　　　　　　　┗┻┛       ┗┻┛
 */ 
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
//#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define inf 1000000000
#define maxn 100000+5
#define maxm 100005
#define eps 1e-10
#define for0(i,maxn) for(int i=1;i<=(maxn);++i)
#define for1(i,maxn) for(int i=1;i<=(maxn);++i)
#define for2(i,x,y) for(int i=(x);i<=(y);++i)
#define for3(i,x,y) for(int i=(x);i>=(y);--i)
#define mod 1000000007
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=10*x+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{
    int n;
    n=read();
    if(n<1200) puts("ABC");
    else if(n<2800) puts("ARC");
    else puts("AGC");
 }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, m, k;
bool bl[1000010];

signed main() {
	cin >> n >> m >> k;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			int x = j * (n - i) + i * (m - j);
			bl[x] = true;
		}
	}
	if (bl[k])cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
int main(void){
  int n,k,l[50],i,j;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  int max,tmp,index;
  for(i=0;i<n-1;i++){
    index=i;
    max=0;
    for(j=i;j<n;j++){
      if(l[j]>max) {
        max=l[j];
        index=j;
      }
    }
    tmp=l[i];
    l[i]=max;
    l[index]=tmp;
  }
  int sum=0;
  for(i=0;i<k;i++){
    sum+=l[i];
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i32, m: i32, q: i32,
        ad: [(i32, i32, i32, i32); q],
    }
    // annotate for rust-analyzer
    let n: i32 = n;
    let m: i32 = m;
    let q: i32 = q;
    let abcd: Vec<(i32, i32, i32, i32)> = ad;

    let mut ans = 0;
    for i in 2..=n {
        for mut v in (1..=m).combinations_with_replacement(i as usize) {
            v.insert(0, 1);
            let mut sum = 0;
            for &(a, b, c, d) in &abcd {
                if a <= i && b <= i && v[b as usize - 1] - v[a as usize - 1] == c {
                    sum += d;
                }
            }
            if ans < sum {
                ans = sum;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2204
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7

using namespace std;

ll n,freq[N];
pi ar[N];
set < pi > s;
ll cnt = 1;

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

    cin >> n;

    rep(i,0,n)
    {
        cin >> ar[i].first;
        ar[i].first *= -1;
        ar[i].second=i;
        s.insert(ar[i]);
    }

    while(s.size() != 1)
    {
        pi cur = *(s.begin());

       //cout << -cur.first << " " << cur.second << " " << cnt << endl;

        s.erase(s.begin());

        if((*s.begin()).first == cur.first)
        {
            s.erase(s.begin());
            cnt++;
            s.insert(cur);
        }
        else
        {
         //   cout << "here " << cnt*(-cur.first + (*s.begin()).first)<<"\n";
            freq[cur.second] += cnt*(-cur.first+(*s.begin()).first);
            cur.first = (*s.begin()).first;
            s.insert(cur);
        }
    }

    freq[0] -= cnt*(*s.begin()).first;

    rep(i,0,n)
        cout << freq[i] << "\n";

    return 0;
}


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

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

int W, H, N, X[100], Y[100], A[100];

int main(){
    cin >> W >> H >> N;
    for(int i=0;i<N;i++)    cin >> X[i] >> Y[i] >> A[i];

    int WH[100][100];
    memset(WH, 0, sizeof(WH));

    for(int i=0;i<N;i++){
        if(A[i] == 1){
            for(int y=0;y<H;y++){
                for(int x=0;x<X[i];x++) WH[y][x] = 1;
            }
        } else if(A[i] == 2){
            for(int y=0;y<H;y++){
                for(int x=X[i];x<W;x++) WH[y][x] = 1;
            }
        } else if(A[i] == 3){
            for(int y=0;y<Y[i];y++){
                for(int x=0;x<W;x++) WH[y][x] = 1;
            }
        } else {
            for(int y=Y[i];y<H;y++){
                for(int x=0;x<W;x++) WH[y][x] = 1;
            }
        }
    }

    int ans = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(WH[i][j] == 0)   ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
            
int main() {
    int a, b = 0;
    std::cin >> a >> b;
            
    if(a > b) {
        std::cout << "a > b" << std::endl;
    }       
    else if(a < b) {
        std::cout << "a < b" << std::endl;
    }       
    else {  
        std::cout << "a == b" << std::endl;
    }       
            
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    bool ok = false;
    for (int i = 0; i <= k; i++) {
        if (a < (b * pow(2, i)) && b * pow(2, i) < (c*pow(2, k - i))) ok = true;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4036
#include<stdio.h>
#include<ctype.h>
int main(void)
{
	char ch;
	while(1)
	{
		scanf("%c",&ch);
		if(islower(ch))
		{
			ch=toupper(ch);
		} else {
			ch=tolower(ch);
		}
		printf("%c",ch);
		if(ch=='\n')break;
	}
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>
#include <deque>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    int n = get<int>();
    vector<int> a(n);
    for (int i = 0; i < n; i++) a[i] = get<int>();
    deque<int> b;

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        bool f = false;

        auto it = lower_bound(b.begin(), b.end(), a[i]);
        if (it == b.begin()) {
            b.push_front(a[i]);
        } else {
            it--;
            *it = a[i];
        }
    }
    cout << b.size() << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const int MAX= 1e6+100;



int main(){
	fastio;
	ll tc,n;
	cin>>n;
	ll x;
	queue<ll> q;
	f(i,1,10) q.push(i);
	f(i,1,n+1){
		x = q.front(); q.pop();
		if(x%10!=0) q.push(x*10+x%10-1);
		q.push(x*10+x%10);
		if(x%10!=9) q.push(x*10+x%10+1);
	}
	cout<<x<<endl;
  	return 0;	
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, a[200010];
vector<int> vec[1000010];
bool bl[1000010];
int cnt[1000010];
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		bl[a[i]] = true;
		cnt[a[i]]++;
	}
	for (int i = 1; i <= 1000000; i++) {
		for (int j = i * 2; j <= 1000000; j += i)vec[j].push_back(i);
	}
	for (int i = 0; i < n; i++) {
		bool b = true;
		for (int j = 0; j < (int)vec[a[i]].size(); j++)if (bl[vec[a[i]][j]])b = false;
		if (1 < cnt[a[i]])b = false;
		if (b)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 123416
//#####   #####   #####   #####   #####   #       #####   #   #//
//#   #   #   #   #       #       #   #   #       #   #   ## ##//
//#####   #####   #####   #       #####   #       #####   # # #//
//##      #   #       #   #       #   #   #       #   #   #   #//
//# #     #   #       #   #       #   #   #       #   #   #   #//
//#  #    #   #       #   #       #   #   #       #   #   #   #//
//#   #   #   #   #####   #####   #   #   #####   #   #   #   #//


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ppb pop_back
#define cs(n) cout<<n<<" "
#define cn(n) cout<<n<<"\n"
#define rep(i,j,k) for(int i=j;i<k;i++)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll bin(ll a, ll b, ll mod)
{
	if(b==0)
		return 1;
	if(b%2==0)
		return bin((a*a)%mod , b/2 , mod)%mod;
	return ((a%mod)*(bin((a*a)%mod , b/2 , mod)%mod))%mod;
}
void solve()
{
	int x;
	cin>>x;
	if(x>=30){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif
	fastio;
	int t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

typedef int itn;
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

    int n;
    cin >> n;
    int digitsum = 0;
    int t = n;
    digitsum += (t/1000000000); t %= 1000000000;
    digitsum += (t/100000000);  t %= 100000000;
    digitsum += (t/10000000);   t %= 10000000;
    digitsum += (t/1000000);    t %= 1000000;
    digitsum += (t/100000);     t %= 100000;
    digitsum += (t/10000);      t %= 10000;
    digitsum += (t/1000);       t %= 1000;
    digitsum += (t/100);        t %= 100;
    digitsum += (t/10);         t %= 10;
    digitsum += (t/1);
    if (n % digitsum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n,i,a[100],ap=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0){
        ap=0;
      }
    }
  }
  if(ap==0){
    printf("DENIED");
  }
  else printf("APPROVED");
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
using namespace std;

int main(void){
    int n, a[100], b[100];
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    for(int i = 0; i < n; i++) scanf("%d", &b[i]);
    for(int j = 1; j < 4; j++){
        long sum = 0;
        for(int i = 0; i < n; i++) sum += pow(abs(a[i] - b[i]), j);
        printf("%lf\n", pow(sum, 1.0 / j));
    }
    int max = 0;
    for(int i = 0; i < n; i++) max = (max < abs(a[i] - b[i]) ? abs(a[i] - b[i]) : max);
    printf("%lf\n", (double)max);

    return 0;
}



Measured memory_bytes: 2928
#include <stdio.h>

int main()
{
    int A,B,m;
    int a[100000],b[100000],x[100000],y[100000],c[100000];

    int i,j;

    int mina = 100000000,minb = 100000000,ans = 1000000000;

    scanf("%d %d %d",&A,&B,&m);
    for (i = 0; i < A; i++)
    {
        scanf("%d",&a[i]);
        if(mina > a[i])mina = a[i];
    }
    for (i = 0; i < B; i++)
    {
        scanf("%d",&b[i]);
        if(minb > b[i])minb = b[i];
    }
    ans = mina + minb;
    for (i = 0; i < m; i++)
    {
        scanf("%d %d %d",&x[i],&y[i],&c[i]);
        if(a[x[i] - 1] + b[y[i] - 1] - c[i] < ans)ans = a[x[i] - 1] + b[y[i] - 1] - c[i];
    }
    printf("%d",ans);
}


Measured memory_bytes: 2176
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,a=LI()
  c=0
  for _ in range(100000):
    if h<=0:
      return c
    h-=a
    c+=1

# main()
print(main())


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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define eps 1e-9
#define fast_cin ios_base::sync_with_stdio(false)

const int MOD = 1e9+7;

typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	//freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	fast_cin;
	int r, c;
	cin >> r >> c;
	int n;
	cin >> n;
	std::vector<int> v;
	for (int i = 0; i < n; ++i)
	{
		int x; cin >> x;
		v.pb(x);
	}
	int array[r][c];
	int q=0;
	for (int i = 0; i < r; ++i)
	{
		if (i%2 == 0)
		{
			for (int j = 0; j < c; ++j)
			{
				if (v[q]!=0)
				{
					array[i][j] = q +1;
					v[q]--;
				}
				else{
					q++;
					array[i][j] = q +1;
					v[q]--;
				}
			}
		}
		else{
			for (int k = c-1; k >=0; k--)
			{
				if (v[q]!=0)
				{
					array[i][k] = q +1;
					v[q]--;
				}
				else{
					q++;
					array[i][k] = q +1;
					v[q]--;
				}
			}
		}
	}
	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c; ++j)
		{
			cout << array[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 512