akhauriyash/Code-Regression huggingface dataset:
from operator import itemgetter
tik = [[1,2],[7,3],[4,4],[5,5],[3,5],[2,5],[9,6],[8,7],[6,6]]
dic = {"1":2,"7":3,"4":4,"5":5,"3":5,"2":5,"9":6,"8":7,"6":6}

n,k = map(int, input().split())
x = list(map(int, input().split()))
dp = [0]+[-1]*(n+10)
q = []
for i in range(k):
    q.append([x[i],dic[str(x[i])]])

q = sorted(q, key=itemgetter(1), reverse=False)

s = []
p=0
t = 0
for i in range(n):
    for j in range(k):
        if i+q[j][1] <=n:
            if dp[i]!=-1:
            
                if  dp[i]==0:
                    ko = q[j][0]
                    dp[i+q[j][1]] = max(q[j][0],dp[i+q[j][1]])

                else:
                    ko = dp[i]+q[j][0]
                    dp[i+q[j][1]] = max(dp[i]*10+q[j][0], dp[i+q[j][1]])
        #if i+q[j][1] ==n:
            #print(dp[20])
s = list(str(dp[n]))
s.sort()
s = s[::-1]
print(''.join(s))

Measured memory_bytes: 14708
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1000000007;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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


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

  int32_t N, K;
  cin >> N >> K;
  COMinit();

  int64_t res = 0;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    res += COM(i, K-1) * A[i];
    res -= COM(N - i -1, K -1) * A[i];
    res %= MOD;
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
int main(){
  ll N; cin >> N;
  vector<ll> A(N); vector<ll> B(N);
  vector<pair<ll,ll>> Sum(N);
  
   for(ll i = 0; i < N; i++){ cin >> A[i] >> B[i]; 
     Sum[i].first = A[i]+B[i]; Sum[i].second = i;}
  
 
   sort(Sum.rbegin(),Sum.rend());
  ll t = 0; ll a = 0;
  for(ll i = 0; i < N; i++){
    if( (i % 2) == 0){// Takahashi
      t += A[Sum[i].second]; }
    else{
      a += B[Sum[i].second]; }
  }

  cout << t-a << endl; return 0;}
  

Measured memory_bytes: 3328
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

int main()
{
    string s,a,b;
    
    cin >> s;
    a+=s[0];
    a+=s[1];
    b+=s[2];
    b+=s[3];
    
    int n = stoi(a);
    int m = stoi(b);

    if((1<=n) && (n<=12) && (0 == m || (13<=m))) {
        cout << "MMYY" << endl;
    } else if ((1<=m) && (m<=12) && (n == 0 || (13<=n))) {
        cout << "YYMM" << endl;
    } else if ((1<=m) && (m<=12) && (1<=n) && (n<=99)){
        cout << "AMBIGUOUS" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int a[101],b[101];
int solve(){
    cin>>n; int f=1;
    rep(i,1,n) cin>>a[i];
    rep(i,2,n) if(a[i]<a[i-1]) f=0;
    if(f){
        cout<<"YES";
        return 0;
    }
    rep(i,1,n){
        rep(j,i+1,n){
            rep(k,1,n) b[k]=a[k];
            swap(b[i],b[j]);
            f=1;
            rep(k,2,n) if(b[k]<b[k-1]) f=0;
            if(f){
                cout<<"YES";
                return 0;
            }
        }
    }
    cout<<"NO";
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,M;
    ll ans=0;
    cin >> N >>M;
    ll i=0;
    for(i=N;i<=M;i++){
      if(i/10000==i%10 && i/1000%10==i/10%10)ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split(" "))
height = []
for i in range(N):
    height.append(int(input()))
height.sort()
min = 10**9
n = N-K+1
for j in range(n):
    hmin = height[j]
    hmax = height[j+K-1]
    hei = hmax-hmin
    if hei <= min:
        min = hei
print(min)

Measured memory_bytes: 7384
s = input()
if "01" <= s[:2] <= "12" and "01" <= s[2:] <= "12":
    print("AMBIGUOUS")
elif "00" <= s[:2] and "01" <= s[2:] <= "12":
    print("YYMM")
elif "01" <= s[:2] <= "12" and "00" <= s[2:]:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3060
# your code goes here
A,B,K = map(int,input().split())

if K > (B - A)/2.0:
	for i in range(A,B+1):
		print(i)
else:
	for i in range(A,A+K):
		print(i)
	for i in range(B-K+1,B+1):
		print(i)

Measured memory_bytes: 3060
import kotlin.math.*

fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toInt() }

    val rad: Double = PI * 2.0 * ( h/12.0 + ( (m/60.0) / 12.0 - m/60.0 ) )

    val rsq: Double = (a * a + b * b) - (2.0 * a * b) * cos(rad)

    println(sqrt(rsq))
}

Measured memory_bytes: 36592
#include <cstdio>
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
	int a, b, c;
	int count = 0;

	cin >> a >> b >> c;

	for (int i = a; i <= b ; ++i)
	{
		if (c % i == 0)
		{
			count++;
		}
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 1144
from collections import defaultdict
N,*A = map(int, open(0).read().split())
dp_not = defaultdict(lambda :-10**18)
dp_take = defaultdict(lambda :-10**18)
dp_not[(0,0)] = 0
for i,x in enumerate(A,1):
  for j in ((i-1)//2,(i-1)//2+1):
    dp_not[(i,j)] = max(dp_not[(i-1,j)],dp_take[(i-1,j)])
    dp_take[(i,j)] = dp_not[(i-1,j-1)] + x
print(max(dp_not[(N,N//2)], dp_take[(N,N//2)]))

Measured memory_bytes: 231996
#include<stdio.h>
long long int n, a[200100][2],sum,s,t;
int main(){
	int i,j=0;
	scanf("%lld",&n);
	for(i=1;i<=n;i++){
		scanf("%lld",&a[i][0]);
		t=0;
		while(a[i][0]<a[j][0]){
			t=t+a[j][1];			
			s=s-(a[j][0]*a[j][1]);	
			j--;		
		}
		a[++j][1]=t+1;
		a[j][0]=a[i][0];
		s=s+a[i][0]*(t+1);
		sum=sum+s;
	}
	printf("%lld",sum);
}

Measured memory_bytes: 3328
import java.util.*;
import java.io.*;

public class Main {

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
	    int n=sc.nextInt();
	    int m=sc.nextInt();
	    char[][] a=new char[n+3][m+3];
	    boolean[][] b=new boolean[n+3][m+3];
	    for(int i=2;i<=n+1;i++) {
	      char aa[]=sc.next().toCharArray();
	      for(int j=2;j<=m+1;j++) {
	        a[i][j]=aa[j-2];
	        b[i][j]=true;
	      }
	    }
	    for(int i=1;i<=n+2;i++) {
       for(int j=1;j<=m+2;j++) {
         if(b[i][j]==false)
         a[i][j]='#';
       }
     }
	    for(int i=1;i<=n+2;i++) {
       for(int j=1;j<=m+2;j++) {
        System.out.print(a[i][j]);
     }
       System.out.println();
}
	}

	      static long gcd(long a, long b) 
	      { 
	          if (a == 0) 
	              return b; 
	          return gcd(b % a, a); 
	      } 

static long nCr(int n,int r) {
  int dp[][]=new int[2001][2001];
  for(int i=0;i<2001;i++) {
    dp[0][i]=0;
  }
  for(int i=0;i<2001;i++) {
    dp[i][0]=1;
  }
  for(int i=1;i<2001;i++) {
    for(int j=1;j<2001;j++) {
      if(i==j) {
        dp[i][j]=1;
      }else {
        dp[i][j]=dp[i-1][j-1]+dp[i][j-1];
      }
    }
  }
  return dp[n][r];
}


      
}
class pair {
  int src;
 int  des;
 long val;
  pair(int src,int des,long val){
    this.src=src;
    this.des=des;
    this.val=val;
    
  }

//  @Override
//  public int compareTo(pair o) {
//   
//    return this.wt-o.wt;
//  }
}

Measured memory_bytes: 38696
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define in(e,l) (std::find(l.begin(), l.end(), e) != l.end())
#define asort(l) (std::sort(l.begin(), l.end()))
#define dsort(l) (std::sort(l.rbegin(), l.rend()))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;

int main() {
  ll N;
  cin >> N;
  --N;
  cout << (N + 1) * N / 2 << endl;
  return 0;
}



Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
  int a, b, k, i;
  scanf("%d %d %d", &a, &b, &k);

  for(i = 1;i <= k; i++){
    if(i % 2 != 0){
      if(a % 2 != 0){
        a -= 1;
        }

      a /= 2;
      b += a;
    }

    else{
      if(b % 2 != 0){
        b -= 1;
      }

      b /= 2;
      a += b;
    }

    }
  

  printf("%d %d", a, b);

  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] v = new int[N];
        int[] odd_count = new int[100001];
        int[] even_count = new int[100001];
        for (int i = 0; i < N; i++) {
            v[i] = scan.nextInt();
            if (i % 2 == 0) {
                even_count[v[i]] += 1;
            } else {
                odd_count[v[i]] += 1;
            }
        }
        List<Pair> even_list = new ArrayList<>();
        List<Pair> odd_list = new ArrayList<>();
        for (int i = 1; i <= 100000; i++) {
            if (0 < even_count[i]) {
                Pair p = new Pair();
                p.x = i;
                p.count = even_count[i];
                even_list.add(p);
            }
            if (0 < odd_count[i]) {
                Pair p = new Pair();
                p.x = i;
                p.count = odd_count[i];
                odd_list.add(p);
            }
        }
        int[] etop2 = top2(even_list);
        int[] otop2 = top2(odd_list);
        long answer = 0;
        if (etop2[0] != otop2[0]) {
            int a = even_count[etop2[0]];
            int b = odd_count[otop2[0]];
            long t= Math.abs(a-N/2) + Math.abs(b-N/2);
            answer = t;
        } else {
            int a1 = even_count[etop2[0]];
            int b1 = odd_count[otop2[0]];
            int a2 = even_count[etop2[1]];
            int b2 = odd_count[otop2[1]];
            long t1= Math.abs(a1-N/2) + Math.abs(b2-N/2);
            long t2= Math.abs(a2-N/2) + Math.abs(b1-N/2);
            answer = Math.min(t1, t2);
        }
        System.out.println(answer);
    }
    public int[] top2(List<Pair> list) {
        list.sort(new PairComparator());
        int[] top2 = new int[2];
        while(!list.isEmpty()) {
            Pair p = list.remove(0);
            if (top2[0] == 0) {
                top2[0] = p.x;
                continue;
            }
            if (top2[1] == 0) {
                top2[1] = p.x;
                break;
            }
        }
        return top2;
    }
    class Pair {
        int x;
        int count;
    }
    class PairComparator implements Comparator<Pair> {
        @Override
        public int compare(Pair o1, Pair o2) {
            if (o1.count == o2.count) {
                return Integer.compare(o1.x, o2.x);
            }
            return -Integer.compare(o1.count, o2.count);
        }
    }
}


Measured memory_bytes: 66772
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string S;
    cin >> S;
    int count = 0;
    for(int i=0;i<S.length();i++){
        if(S[i] == 'x'){
            count++;
        }
    }
    if(count >= 8)cout << "NO" << endl;
    else cout << "YES" << endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<P> A(N);
    rep(i, N) {
        int a;
        cin >> a;
        A[i] = {a, i + 1};
    }
    sort(A.begin(), A.end());
    for (P p : A) {
        cout << p.second << '\n';
    }


}

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


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, A;
	cin >> N >> A;
	if ((N % 500) <= A) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            
            for(int i = 1; i < N + 1; i++)
            {
                int result = 0;

                for(int x = 1; x < Math.Sqrt(N) + 1; x++)
                {
                    for(int y = 1; y < Math.Sqrt(N) + 1; y++)
                    {
                        if (x * x + y * y + x * y > i)
                            break;
                        else
                        {
                            for (int z = 1; z < Math.Sqrt(N) + 1; z++)
                            {
                                int n = x * x + y * y + z * z + x * y + y * z + z * x;
                                if (n > i)
                                    break;
                                if (n == i)
                                    result++;
                            }
                        }
                    }
                }
                Console.WriteLine(result);
            }
        }
    }
}


Measured memory_bytes: 27608
#include <stdio.h>
#include <iostream>
using namespace std;

struct Card {char suit,value;};
/*?????\?????????(0??????????????????)*/
void selection(struct Card A[],int N){
	for(int i=0;i<N;i++){
		int mini =i;
		for(int j=i;j<N;j++){
			if(A[j].value<A[mini].value)mini=j;

		}
		Card t=A[i];A[i]=A[mini];A[mini]=t;
	}
}

void bubble(struct Card A[],int N){
	for(int i=0;i<N;i++)for(int j=N-1;j>=i+1;j--)
		if(A[j].value<A[j-1].value){
			Card t =A[j];A[j]=A[j-1];A[j-1]=t;
		}

}

void print(struct Card A[],int N){
	for(int i=0;i<N;i++){
		if(i)cout <<" ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}
//????????????????????¨?????????????????????????????????
bool isStable(struct Card C1[],struct Card C2[],int N){
	for(int i=0;i<N;i++){
		if(C1[i].suit<C2[i].suit)return false;
	}
	return true;
}
int main(){
	Card C1[100],C2[100];
	int N;
	char ch;

	cin >> N;
	for (int i = 0; i < N; ++i){
		cin>>C1[i].suit>>C1[i].value;
		/* code */
	}
	for (int i = 0; i < N; ++i)
	{
		C2[i]=C1[i];
	}
	bubble(C1,N);
	selection(C2,N);
	print(C1,N);
	cout <<"Stable" << endl;
	print(C2,N);
	if(isStable(C1,C2,N))cout << "Stable" << endl;
	else cout << "Not stable" << endl;

}

Measured memory_bytes: 3088
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	string s;
	vector<bool>list(100005, false);


	cin >> s;

	bool iro = false;//false=黒、true=白

	for (int i = 0; i < s.length(); i++) {// 0は黒、1は白
		if (s[i] == '0') {
			list[i] = false;
		}
		else if (s[i] == '1') {
			list[i] = true;
		}
	}

	int cnt1 = 0, cnt2 = 0;

	for (int i = 0; i < s.length(); i++) {
		if (iro != list[i]) {
			cnt1++;
		}

		//iro = not iro;
		iro = !iro;
	}

	iro = true;

	for (int i = 0; i < s.length(); i++) {
		if (iro != list[i]) {
			cnt2++;
		}

		iro = not iro;
	}


	cout << min(cnt1, cnt2) << endl;

	return 0;
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    vector<int> water;
    for (int i=0;100*i<=F;i++){
        for (int j=0;100*j<=F;j++){
            int x = 100*A*i + 100*B*j;
            if (x<=F) water.push_back(x);
        }
    }
    vector<int> sugar;
    for (int i=0;i<=F;i++){
        for (int j=0;j<=F;j++){
            int y = C*i + D*j;
            if (y <= F) sugar.push_back(y);
        }
    }
    
    double mx = 0.0;
    pair<int,int> ans = make_pair(100*A,0);
    for (int i=0;i<water.size();i++){
        for (int j=0;j<sugar.size();j++){
            int w = water[i];
            int s = sugar[j];
            if (w+s>F) continue;
            if (w/100*E >= s && 100.0F*s/(w+s) > mx) {
                mx = 100.0F*s/(w+s);
                ans = make_pair(w, s);
            }
        }
    }
    cout << ans.first + ans.second << " " << ans.second << "\n";
}

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

int main(){
  int A;
  cin >> A;
  int cnt=0;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(A==i*j)cnt=1;
    }
  }
  if(cnt){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}

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

signed main()
{   
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;

    int x=tx-sx;
    int y=ty-sy;
    
    cout<<string(y,'U')<<string(x,'R');
    cout<<string(y,'D')<<string(x,'L');

    cout<<'L'<<string(y+1,'U')<<string(x+1,'R')<<'D';
    cout<<'R'<<string(y+1,'D')<<string(x+1,'L')<<'U';
}


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

ll calc_attack_number(ll h){
    if(h == 1LL) return 1;

    return 2LL * calc_attack_number(h / 2LL) +1;
}

int main() {
    ll H;
    cin >> H;

    cout << calc_attack_number(H) << endl;
}

Measured memory_bytes: 256
import           Control.Monad
import           Data.List

main = do
    n <- readLn :: IO Int
    s <- sort . map sort <$> replicateM n getLine :: IO [String]
    print $ (sum . map (\i -> i * (i - 1) `div` 2) . map (fromIntegral . length)
            $ group s :: Integer)


Measured memory_bytes: 113020
import sys

a, b = input().split()
a = int(a)
b = int(b)

if a == b:
    print("Draw")
    sys.exit()
elif a > b:
    if b == 1:
        print("Bob")
        sys.exit()
    print("Alice")
    sys.exit()
elif a == 1:
    print("Alice")
    sys.exit()
print("Bob")


Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
  int n,i,j,t;
  int data[4][13];
  char c;
  char gara[4]={'S','H','C','D'};
  scanf("%d",&n);

  for (i=0;i<4;i++){
    for (j=0;j<13;j++){
      data[i][j]=0;
    }
  }
  scanf("%d",&n);

  for (i=0;i<n;i++){
    scanf(" %c",&c);
    scanf("%d",&t);
    if (c=='S'){
      data[0][t-1]=1;
    }else if (c=='H'){
      data[1][t-1]=1;
    }else if (c=='C'){
      data[2][t-1]=1;
    }else if (c=='D'){
      data[3][t-1]=1;
    }
  }

  for (i=0;i<4;i++){
    for (j=0;j<13;j++){
      if (data[i][j]==0){
          printf("%c %d\n",gara[i],j+1);
      }
    }
  }

  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(void){
  int a,b,n,x,i;

  for(;;){
    i=0;
    scanf("%d%d",&n,&x);
    if(n+x == 0) break;

    for(a=1;a<=n;a++)
      for(b=a+1;b<=n;b++)
        if(b < x-a-b && x-a-b <= n)
          i++;

    printf("%d\n", i);
  }

  return 0;
}



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

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

    int n, k, q;
    cin >> n >> k >> q;
    vector<int> p(n, 0);

    REP(i, q) {
        int tmp;
        cin >> tmp;
        tmp--;
        p[tmp]++;
    }

    REP(i, n) {
        if (k + p[i] - q > 0) cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>

bool prime[1000001], dp[1000001];

int main(){
	for(int i=0;i<=1000000;i++){
		prime[i] = true;
	}
	prime[0] = prime[1] = 0;
	for(int i=2;i<=1000000;i++){
		if(prime[i]){
			for(int j=i*2;j<=1000000;j+=i)prime[j] = false;
		}
	}

	int n, x, a[30];
	while(std::cin >> n >> x, n){
		for(int i=0;i<=x;i++){
			dp[i] = false;
		}

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

		int res = 0;

		dp[0] = true;
		for(int i=1;i<=x;i++){
			for(int j=0;j<n;j++){
				if(i-a[j] >= 0 && dp[i-a[j]]){
					dp[i] = true;
					break;
				}
			}
			if(dp[i] && prime[i]){
				res = i;
			}
		}

		if(res != 0){
			std::cout << res << std::endl;
		}else{
			std::cout << "NA" << std::endl;
		}
	}
}

Measured memory_bytes: 3112
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var a = ReadLine().Split(" ");
        for (int i = 0; i < a.Length; i++)
        {
            if(a[i] == "0")
            {
                WriteLine(i + 1);
                return;
            }
        }
        return;
    }
}


Measured memory_bytes: 25768
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string a, b;
    cin>>a>>b;
    int cnt = 0;
    for (int i = 0; i < 3; ++i)
    {
        if (a[i] == b[i])
            cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
function main(input){
    let lines =input.split("\n");
    let n = parseInt(lines.shift());
    let A = lines.shift().split(" ").map(x=>parseInt(x));
    let q = parseInt(lines.shift());
    let m = lines.shift().split(" ").map(x=>parseInt(x));
    
    for(let i=0;i<q;i++){
        let ans = solve(0,m[i],n,A);
        if(ans){
            console.log("yes");
        }else{
            console.log("no");
        }
    }

    
}
function solve(i,m,n,A){
    if(m===0){
        return true;
    }
    if(i>=n){
        return false;
    }
    let res = solve(i+1,m,n,A) || solve(i+1,m-A[i],n,A);
    return res;
    
}


main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 16860
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
long long sousuu = 1, ans;

int main()
{
	bool d = true;
	int n; cin >> n;
	string a, b;
	cin >> a >> b;
	int m = 0;
	int size = n * 2;
	for (int i = 1; i <= n; i++)
	{
		d = true;
		REP(j, i) {
			if (a[n - i+j] != b[j ]) {
				d = false; break;
			}
		}
		if (d == true) {
			m = i;
		}
	}
	cout << size - m;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

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

  int n, m; cin >> n >> m;
  vector<vector<int> > vec(n, vector<int>(0));
  REP(i, m) {
    int temp1, temp2; cin >> temp1 >> temp2; --temp1; --temp2;
    vec[temp1].push_back(temp2);
    vec[temp2].push_back(temp1);
  }
  vector<int> num(n-1); FOR(i, 1, n) num[i-1] = i;
  int ans = 0;
  do {
    vector<int> temp(n);
    temp[0] = 0;
    REP(i, n-1) temp[i+1] = num[i];
    bool ok = true;
    REP(i, n-1) {
      bool hantei = false;
      for (int aa : vec[temp[i]]) {
        if (aa == temp[i+1]) {
          hantei = true;
          break;
        }
      }
      if (!hantei) {
        ok = false;
        break;
      }
    }
    if (ok) ++ans;
  } while (next_permutation(ALL(num)));
  cout << ans << "\n";
  return 0;
}


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

int h, w;
char grid[20][20];
int seen[20][20];
int maxi = -1;

void seen_init(){
    rep(i, 20){
        rep(j, 20){
            seen[i][j] = INF;
        }
    }
}

void dfs(int x, int y, int cnt){

    // 範囲内かを判定する
    if( x < 0 || y < 0 || h <= y || w <= x){
        return;
    }
    // 壁かを判定する
    if(grid[y][x] == '#'){
        return;
    }
    // 手数が最短かを判定する
    if(seen[y][x] <= cnt){
        return;
    }
    // 最小値を更新する
    seen[y][x] = cnt;
    int xs[4] = {1, 0, -1, 0};
    int ys[4] = {0, 1, 0, -1};
    rep(i, 4){
        dfs(x + xs[i], y + ys[i], cnt + 1);
    }
}

int main() {
    cin >> h >> w;
    rep(i, h){
        rep(j, w){
            cin >> grid[i][j];
        }
    }
    rep(i, h){
        rep(j, w){
            seen_init();
            int start_x = j;
            int start_y = i;
            dfs(start_x, start_y, 0);

            int biggest = -1;
            rep(n, h){
                rep(m, w){
                    if(seen[m][n] != INF && seen[m][n] > biggest && grid[m][n] == '.'){
                        biggest = seen[m][n];
                    }
                }
            }
            maxi = max(maxi, biggest);
        }
    }
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def sum_digit(n):
    s = str(n)
    l = list(map(int, s))
    return sum(l)


def main():
    n = read_int()
    s = sum_digit(n)
    if n % s == 0:
        res = 'Yes'
    else:
        res = 'No'
    print(res)


main()


Measured memory_bytes: 3700
//????????????????????£???????????????
#include<iostream>
#include<list>
#include<utility> //pair
#include<algorithm>
using namespace std;

int main() {
	list<int> L;	//int type list : L
	
	int n;
	cin >> n;
	pair<string,int> u;
	for(int i=0;i<n;i++) {
	cin >> u.first;
	
	if (u.first[0] == 'i')
	{
	cin >> u.second;
	L.push_front(u.second);
	}
	else if (u.first[6] == 'F')	//4???????????\?????\?????°??????
	{L.pop_front();
	}
	else if (u.first[6] == 'L')
	{L.pop_back();
	}
	else if (u.first[0] == 'd')
	{
	cin >> u.second;
	for (list<int>::iterator it = L.begin(); it != L.end(); it++){
		if (*it==u.second) {L.erase(it); break;}
	}
	}
	}
	int i=0;	//it?????°?????¨???????????????????????????????????§..
	for (list<int>::iterator it = L.begin(); it != L.end(); it++){
		if (i++) cout << " ";
		cout << *it;
	}
	cout << endl;
	return 0;
}

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

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<llint> count(100000 + 1, 0);

    for(int i = 0; i < N; i ++){
        int A;

        cin >> A;

        count[A] ++;
    }
    llint ans = 0;

    for(int i = 1; i <= 100000; i ++){
        ans += i * count[i];
    }
    int Q;

    cin >> Q;

    for(int i = 0; i < Q; i ++){
        int B, C;

        cin >> B >> C;

        ans += (C - B) * count[B];

        count[C] += count[B];
        count[B] = 0;

        cout << ans << endl;
    }
}

Measured memory_bytes: 4040
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;

const double PI = 3.14159265358979;

struct Card {
	char suit;
	int val;
};


void merge(Card a[], int left, int mid, int right) {

	//if (right - left == 1) return;

	int Llen = mid - left;
	int Rlen = right - mid;
	Card* L = new Card[Llen + 1];
	Card* R = new Card[Rlen + 1];

	for (int i = 0; i < Llen; i++) {
		L[i] = a[left + i];
	}
	L[Llen].val = INT_MAX;
	for (int i = 0; i < Rlen; i++) {
		R[i] = a[mid + i];
	}
	R[Rlen].val = INT_MAX;

	int ll = 0, rr = 0;
	for (int i = left; i < right; i++) {

		if (L[ll].val <= R[rr].val) {
			a[i] = L[ll++];
		}
		else {
			a[i] = R[rr++];
		}
	}

	delete[] L;
	delete[] R;
}

void mergeSort(Card a[], int left, int right) {

	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a, left, mid, right);
	}
}


void printArr(Card a[], int len) {

	for (int i = 0; i < len; i++) {
		printf("%c %d\n", a[i].suit, a[i].val);
	}
}


int partition(Card a[], int left, int right) {

	//if (right - left <= 1) return left;

	int i = left - 1;

	for (int j = left; j < right - 1; j++) {

		if (a[j].val <= a[right - 1].val) {
			i++;
			swap(a[i], a[j]);
		}
	}
	swap(a[++i], a[right - 1]);
	return i;
}

void quickSort(Card a[], int left, int right) {

	if (right > left) {
		int pos = partition(a, left, right);
		quickSort(a, left, pos);
		quickSort(a, pos+1, right);
	}
}


int main() {

	int n; scanf("%d", &n);
	Card* a1 = new Card[n];
	Card* a2 = new Card[n];
	char str[5];
	for (int i = 0; i < n; i++)	{
		Card c;
		scanf("%s%d", str, &c.val);
		c.suit = str[0];
		a1[i] = c;
		a2[i] = c;
	}

	quickSort(a1, 0, n);
	mergeSort(a2, 0, n);

	int flag = true;
	for (int i = 0; i < n; i++) {
		if (a1[i].suit != a2[i].suit) {
			flag = false;
			break;
		}
	}
	if (flag) cout << "Stable\n";
	else cout << "Not stable\n";

	printArr(a1, n);

	delete[] a1;
	delete[] a2;
	return 0;
}



Measured memory_bytes: 5164
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
typedef pair<ld,ld> point;

ld dist(point x, point y)
{
	return sqrt((x.fi-y.fi)*(x.fi-y.fi)+(x.se-y.se)*(x.se-y.se));
}

ld distcirc(point x, ld r1, point y, ld r2)
{
	ld tmp = dist(x,y);
	tmp -= (r1+r2);
	tmp=max(tmp,ld(0));
	return tmp;
}

ld d[1011];
ld score[1011][1011];
vector<pair<point,ld> > vec;
const ld eps = 1e-10;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ld a, b, c, dd;
	cin>>a>>b>>c>>dd;
	int n; cin>>n;
	vec.resize(n+2);
	vec[0].fi = mp(a,b);
	vec[0].se = 0;
	vec[1].fi = mp(c,dd);
	vec[1].se = 0;
	for(int i = 2; i < n + 2; i++)
	{
		cin>>vec[i].fi.fi>>vec[i].fi.se>>vec[i].se;
	}
	priority_queue<pair<ld,int>, vector<pair<ld,int> >, greater<pair<ld,int> > > pq;
	for(int i = 0; i < n + 2; i++)
	{
		d[i] = ld(1e18);
	}
	for(int i = 0; i < n + 2; i++)
	{
		for(int j = 0; j < n + 2; j++)
		{
			score[i][j] = distcirc(vec[i].fi,vec[i].se,vec[j].fi,vec[j].se);
		}
	}
	d[0] = 0;
	pq.push(mp(0,0));
	while(!pq.empty())
	{
		ld di = pq.top().fi; int s = pq.top().se;
		pq.pop();
		for(int i = 0; i < n + 2; i++)
		{
			ld dis = di + score[s][i];
			if(dis+eps<d[i])
			{
				d[i] = dis;
				pq.push(mp(d[i],i));
			}
		}
	}
	cout<<fixed<<setprecision(12)<<d[1]<<'\n';
}


Measured memory_bytes: 26476
N = int(input())
W = list(map(int, input().split()))

ans = sum(W)
tmp_first = 0
tmp_last = sum(W)
for i in range(N):
    tmp_first += W[i]
    tmp_last -= W[i]
    ans = min(ans, abs(tmp_first - tmp_last))

print(ans)

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from numba import njit

@njit('(i4[:],)', cache=True)
def solve(S):
    dp = np.zeros(2019, np.int64)
    pow10 = 1
    answer = 0
    for x in S[::-1]:
        dp[0] += 1
        x = x * pow10 % 2019
        newdp = np.zeros_like(dp)
        newdp[x:] += dp[:-x]
        newdp[:x] += dp[-x:]
        answer += newdp[0]
        pow10 *= 10
        pow10 %= 2019
        dp = newdp
    return answer


S = np.array(list(read().rstrip()), dtype=np.int32) - ord('0')
print(solve(S))


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

int main() {
  int64_t a,b,k;
  cin >>a >>b >>k;
  if(a>=k){
    cout <<a-k <<' ' <<b <<endl;
  }
  else if((a+b)<=k){
    cout <<0 <<' ' <<0 <<endl;
  }
  else{
    cout <<0 <<' ' <<(a+b)-k <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
int main() {
	double n, t, a, h[1000], ans, min = 100000, ans1;
	cin >> n >> t >> a;
	for (int  i = 0; i < n; i++) {
		cin >> h[i];
		h[i] = h[i] *0.006;
		ans = t - h[i];
		if (a >= ans)ans = a - ans;
		else ans = ans - a;
		if (min > ans) { 
			ans1 = i + 1;
			min = ans;
		}
	}
	cout << ans1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<string>
#include<utility>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)

long long N,K;

int max(int a,int b){
	if(a<b){
		return b;
	}
	else return a;
}




int main() {
	cin>>N>>K;
	long long count =0;
	if(K!=0){
	for(long long b=K+1;b<=N;b++){
		long long n = (N-K)/b;
		long long m = b-K;
		count += ((n+1)*m-max(0,n*b+b-1-N));
	}
	cout<<count<<endl;
	}
	if(K==0){
		cout<<N*N<<endl;
	}
	
	
	return 0;
}

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

using namespace std;
typedef long double ld;

ld dp[3007];
ld tab[3007];

int main()
{
    int N;
    cin >> N;
    dp[0]=1;
    for(int i=1; i<=N; i++)
    {
        ld p;
        cin >> p;
        for(int j=0; j<i; j++)
        {
            tab[j+1] += dp[j]*p;
            tab[j] += dp[j]*(1-p);
        }
        for(int j=0; j<=i; j++)
        {
            dp[j]=tab[j];
            tab[j]=0;
        }
    }
    ld wynik=0;
    for(int i=N/2+1; i<=N; i++)
        wynik+=dp[i];
    cout << setprecision(9) << fixed << wynik;
}

Measured memory_bytes: 384
function Scanner(input) {
	var self = this;
	self.itemNo = 0;
	self.orgStr = input;
	self.splitedStrs = (function(target) {
		var result = [];
		var target = target.replace(/[\n \t]+/g, " ");
		var strs = target.split(" ");
		for (var i = 0, len = strs.length; i < len; i++) {
			result.push(strs[i]);
		}
		return result;
	}(input));

	self.next = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? result : null;
	}

	self.nextInt = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseInt(result) : null;
	}

	self.nextBigDecimal = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseFloat(result) : null;
	}
	
	self.nextByte = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? new Int8Array(result) : null;
	}

}

function Main(sc) {

	var X = sc.nextInt();
	var ans = 0;
	var multed = 100;
	
	for (var i = 0; i < 1000000000000000000; i++) {
		multed = parseInt(multed * 1.01);
		ans++;
		if (multed >= X) break;
	}
	
	console.log(ans);
}
Main(new Scanner(require("fs").readFileSync("/dev/stdin", "utf8")));
// Main(new Scanner("33"));

// var str1 = sc.next(); // Stringで取得
// var int1 = sc.nextInt(); // intで取得
// var bd1 = sc.nextBigDecimal(); // BigDecimalで取得
// var byte1 = sc.nextByte(); // byteで取得


Measured memory_bytes: 30040
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem103c(n, a))
}

fun problem103c(n: Int, a: List<Int>): Int {
    return a.map { it - 1 }.sum()
}

Measured memory_bytes: 36472
N = int(input())
T,A = (int(X) for X in input().split())
H = [int(X) for X in input().split()]
MIN = pow(10,9)
MII = 0
for X in range(0,N):
    Diff = abs(A-(T-0.006*H[X]))
    if Diff<MIN:
        MIN = Diff
        MII = X+1
print(MII)

Measured memory_bytes: 9128
-- vim: set fdm=marker : -- {{{
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Control.Monad.Fix (fix)
import Data.Maybe
import Data.Array.Unboxed (Array, Ix, array, (!), range)
import qualified Data.ByteString.Char8 as BS

type Index = Int
type Value = Integer
type Data  = Array Index Value

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

--Input functions with ByteString
readInt :: Num a => BS.ByteString -> a
readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntTuple :: Num a => BS.ByteString -> (a, a)
readIntTuple = tuplify2 . map readInt . BS.words
readIntList :: Num a => BS.ByteString -> [a]
readIntList = map readInt . BS.words

getInt :: Num a => IO a
getInt = readInt <$> BS.getLine
getIntList :: Num a => IO [a]
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

genArray n xs = array (0, n-1) [x | x <- zip [0..n] xs]
-- }}}

main = do
    s <- getLine
    putStrLn $ if solve s then "YES" else "NO"

solve :: String -> Bool
solve s = (15 - length s) + win >= 8 where
    win = count (== 'o') s

count :: Ord a => (a -> Bool) -> [a] -> Int
count f = foldl (\acc x -> if f x then acc + 1 else acc) 0


Measured memory_bytes: 380
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1])
sa = 0
check = 1
for a,b in ab:
    sa += a
    if sa > b:
        check = 0
        break
print('Yes' if check else 'No')

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

double memo[305][305][305];
bool vis[305][305][305];
int n;

double dp(int s1, int s2, int s3){
	if(s1<0 || s2<0 || s3<0) return 0.0;
//	cout << s1 << " " << s2 << " " << s3 << endl;
	if(s1+s2+s3 == 0) return 0.00;
	double &ret = memo[s1][s2][s3];
	if(vis[s1][s2][s3]) return ret;
	vis[s1][s2][s3] = 1;
	ret = (double)s1*dp(s1-1,s2,s3) + (double)s2*dp(s1+1,s2-1,s3) + (double)s3*dp(s1,s2+1,s3-1) + (double)n;
	ret/=(double)(s1+s2+s3);
	return ret;
}

int s1,s2,s3;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(x==1) s1++;
		else if(x==2) s2++;
		else s3++;
	}
//	cout << s1 << " " << s2 << " " << s3 << endl;
	double ans = dp(s1,s2,s3);
	printf("%.11lf\n",ans);
	return 0;
}

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

using namespace std;
using ll = long long;

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

	int c = 1000, f = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'C') { c = min(c, i); }
		if (s[i] == 'F') { f = max(f, i); }
	}

	if (c < f) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}


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

int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    int len=s.length();
    int i;
    string s2="...";
    if(len<=k)
    cout<<s<<endl;
    else
    {
        string s1=s.substr(0,k);
        cout<<s1+s2<<endl;
    }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
偶機を当てる
連結成分の個数？
*/

ll n,m,d[100010]={},ans=0;
vector<ll> v[100010],c[100010];

void init(){
	cin>>n>>m;
	rep(i,m){
		ll a,b,d;
		cin>>a>>b>>d;
		v[a].push_back(b);
		v[b].push_back(a);
		c[a].push_back(d%2);
		c[b].push_back(d%2);
	}
}

int main(void){
	init();
	reg(i,1,n){
		if(d[i]==0){
			ans++;
			queue<ll> Q;
			Q.push(i);
			d[i]=i;
			while(!Q.empty()){
				ll p = Q.front();Q.pop();
				for(ll q:v[p]){
					if(d[q]==0){
						d[q]=i;
						Q.push(q);
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14312
<?php

class Operator
{
    private $linked_list;
    private $operations_count;

    public function doOperations()
    {
        fscanf(STDIN, '%d', $this->operations_count);
        $this->linked_list = new \SplDoublyLinkedList();
        for (;$this->operations_count > 0;$this->operations_count -= 1) {
            $operation = explode(' ', trim(fgets(STDIN)));
            if ($operation[0] === 'insert') {
                $this->linked_list->unshift($operation[1]);
            } elseif ($operation[0] === 'deleteFirst') {
                $this->linked_list->shift();
            } elseif ($operation[0] === 'deleteLast') {
                $this->linked_list->pop();
            } elseif ($operation[0] === 'delete') {
                foreach ($this->linked_list as $key => $element) {
                    if ($element === $operation[1]) {
                        $this->linked_list->offsetUnset($key);
                        break;
                    }
                }
            }
        }
    }

    public function getAnswer()
    {
        $keys_operated = array();

        while (count($this->linked_list) > 0) {
            $keys_operated[] = $this->linked_list->shift();
        }
        echo implode(' ', $keys_operated), PHP_EOL;
    }
}

$operator = new Operator();
$operator->doOperations();
$operator->getAnswer();



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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int dp[200010];
int num[26];
map<int, int> T;
string s;

int main() {
	string s;
	cin >> s;
	int n = s.size();

	T[0] = 0;
	int bit = 0;

	rep(i, n) {
		int c = s[i] - 'a';
		++num[c];
		bit ^= (1<<c);

		int mn = n;

		if (T.count(bit)){
			mn = min(mn, T[bit]);
		}

		rep(i, 26) {
			bit ^= (1<<i);

			if (T.count(bit)) {
				mn = min(mn, T[bit]);
			}
			bit ^= (1<<i);
		}

		if (T.count(bit)) {
			T[bit] = min(T[bit], mn + 1);
		} else {
			T[bit] = mn + 1;
		}

		dp[i+1] = mn + 1;
	}

	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 10628
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	ll k, a, b; cin >> k >> a >> b;
    if(b <= a + 2) {
        cout << k + 1 << endl;
    } else {
        cout << 1LL + min(a - 1, k) + (max(k - a + 1, 0LL) / 2LL) * (b - a) + (max(k - a + 1, 0LL) % 2LL) << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<LL> A(N, 0), B(N, 0);
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++) cin >> B[i];
  LL sum = 0;
  LL base = 0;
  stack<LL> data;
  for(int i=0; i<N; i++) {
    sum += A[i] - B[i];
    data.push(sum);
    base += abs(sum);
  }
  data.pop();
  base -= sum;

  priority_queue<LL> pq;
  while(!data.empty()) {
    LL cur = data.top();
    data.pop();
    if(cur<=0) {
      pq.push(0);
    }
    if(cur>0) {
      if(cur > sum) cur = sum;
      pq.push(-cur);
      pq.push(-cur);
   
      LL best = pq.top();
      pq.pop();
      base += best;
    }
  }
  
  
  cout << base << endl;
  
  return 0;
}



Measured memory_bytes: 3636