akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();
		int min = 1000;
		min = Math.min(min, P + Q);
		min = Math.min(min, P + R);
		min = Math.min(min, Q + R);
		System.out.println(min);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// UnionFind tree(N);
// int tree.root(x);
// void tree.unite(x, y);
// bool tree.same(x, y);
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q; cin >> N >> Q;
  UnionFind tree(N);
  vector<int> c(Q, 0);
  vector<int> x(Q, 0);
  vector<int> y(Q, 0);
  REP(i, Q){
    cin >> c[i] >> x[i] >> y[i];
  }
  REP(i, Q){
    if(c[i] == 0){
      tree.unite(x[i], y[i]);
    }else{
      if(tree.same(x[i], y[i])){
        cout << 1 << endl;
      }else{
        cout << 0 << endl;
      }
    }
  }
}


Measured memory_bytes: 4068
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    K = int(readline())
    a = 0
    ans = 0
    for _ in range(K+1):
        a = 10*a+7
        a %= K
        ans += 1
        if a%K == 0:
            break

    if ans == K+1: 
        print(-1)
    else:
        print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9116
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    long n, k;
    cin >> n >> k;
    long ans1=n/k, ans2=(n-k/2)/k+1;

   if (k % 2 == 0 && n >= k / 2) {
        cout << ans1*ans1*ans1 + ans2*ans2*ans2 << endl;
   }
   else {
        cout << ans1*ans1*ans1 << endl;
   }


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

int area(const pint& t) { return t.first * t.second; };
int main()
{
	int n, W, H;
	while (cin >> n >> W >> H, W)
	{
		vector<pint> cake;
		cake.push_back(pint(W, H));
		while (n--)
		{
			int p, s;
			cin >> p >> s;
			pint t = cake[p - 1];
			cake.erase(cake.begin() + (p - 1));

			int w = t.first, h = t.second;
			int r = s % (w + h);
			pint a, b;
			if (r < w)
			{
				a = pint(r, h);
				b = pint(w - r, h);
			}
			else
			{
				r -= w;
				a = pint(w, r);
				b = pint(w, h - r);
			}
			if (area(a) > area(b))
				swap(a, b);
			cake.push_back(a);
			cake.push_back(b);
		}
		vector<int> res;
		for (int i = 0; i < cake.size(); ++i)
			res.push_back(area(cake[i]));
		sort(all(res));
		for (int i = 0; i < res.size(); ++i)
			printf("%d%c", res[i], i + 1 == res.size() ? '\n' : ' ');
	}
}

Measured memory_bytes: 0
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}



enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    long a, b, c, d;
    scan(a, b, c, d);
    auto ans = f(b, c, d) - f(a - 1, c, d);
    writeln(ans);
}

long f(long x, long c, long d) {
    return x - (x / c) - (x / d) + (x / lcm(c, d));
}

long lcm(long a, long b) {
    return a / gcd(a, b) * b;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll a;
    cin>>a;
    cout<<a*(1+a+a*a);}
    
    
    
    
    
    
    
    
    
    
   
      

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

#define NIL NULL

typedef struct Node
{
  int key;
  struct Node *right,*left,*parent;
}Node;

Node *root;

Node * find(Node *u,int k)
{
  while(u!=NIL && k!=u->key)
  {
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k)
{
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z=malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL)
  {
    y=x;
    if(z->key < x->key)
    {
      x=x->left;
    }else
    {
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL)
  {
    root=z;
  }else
  {
    if(z->key < y->key)
    {
      y->left=z;
    }else
    {
      y->right=z;
    }
  }
}

void inorder(Node *u)
{
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u)
{
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main()
{
  int n,i,a;
  char com[20];

  scanf("%d",&n);

  for(i=0;i<n;i++)
  {
    scanf("%s",com);
    if(com[0]=='f')
    {
      scanf("%d",&a);
      Node *t=find(root,a);
      if(t!=NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(com[0]=='i')
    {
      scanf("%d",&a);
      insert(a);
    }
    else if(com[0]=='p')
    {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      }
  }
  return 0;
}


Measured memory_bytes: 20488
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            int count500 = int.Parse(Console.ReadLine());
            int count100 = int.Parse(Console.ReadLine());
            int count50 = int.Parse(Console.ReadLine());
            int total = int.Parse(Console.ReadLine());

            int res = 0;
            for (int i = 0; i <= count500; i++)
            {
                for (int j = 0; j <= count100; j++)
                {
                    for (int k = 0; k <= count50; k++)
                    {
                        var sum = 500 * i + 100 * j + 50 * k;

                        if (total == sum)
                        {
                            res++;

                        }
                    }
                }
            }

            //出力
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

map<pair<int,ll>,ll> dp;
ll num[60];
 
ll rec(int n,ll k){
    if(k==0)return 0;
    if(n==0)return k==1;
    if(dp[make_pair(n,k)])return dp[make_pair(n,k)];
    ll ret=0;
    ret+=rec(n-1,min(k-1,num[n-1]));
    if(k>=num[n-1]+2){
        ++ret;
        ret+=rec(n-1,min(num[n-1],k-num[n-1]-2));
    }
    return dp[make_pair(n,k)]=ret;
}
 
int main(){
    ll n,k;
    cin>>n>>k;
    num[0]=1;
    rep(i,50)num[i+1]=2*num[i]+3;
    cout<<rec(n,k)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
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; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> E,Z;
    int es = 0, zs = 0;
    if(S.size() == 1){
        cout << 1 << endl;
        return 0;
    }
    else if(S.size() == 2){
        cout << 2 << endl;
        return 0;
    }
  
    if(S[0] == '0') E.push_back(0);
    REP(i,S.size()-1){
        if(S[i] == '1'){
            es++;
            if(S[i+1] == '0'){
                E.push_back(es);
                es = 0;
            }
        }
        else if(S[i] == '0'){
            zs++;
            if(S[i+1] == '1'){
                Z.push_back(zs);
                zs = 0;
            }
        }
      
        if(i == S.size()-2){
          if(S[i+1]== '1'){
            es++;
            E.push_back(es);
          }
          else{
            zs++;
            Z.push_back(zs);
          }
        }
    }
    if(S[S.size()-1] == '0') E.push_back(0);
    int sum = 0;
    int maxv = 0;
    if(Z.size() <= K){
        cout << N << endl;
        return 0;
    }
    REP(i,E.size()-K){
        REP(k,K){
            sum += E[i+k] + Z[i+k];
        }
        sum += E[i+K];
        maxv = max(maxv,sum);
        sum = 0;
    }
    cout << maxv << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(void){
    ll n, a;
    cin >> n >> a;

    ll ans = 1e18;

    REP(i,40){
        int d = i + 1;
        ll p = pow(n, 1.0/d);
        int x;
        REP(j,d+1){
            ll s = 1;
            REP(k,d-j) s *= p;
            REP(k,j) s *= (p+1);
            if (s >= n){
                x = j;
                break;
            }
        }
        ans = min(ans, a*i + p*d + x);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B;
    cin >> A >> B;

    int konsent = 1;
    int ans = 0;

    while (konsent < B) {
        ans++;
        konsent += A - 1;
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. 162C.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 K          PIC  9(3) COMP.
01 A          PIC  9(3) COMP.
01 B          PIC  9(3) COMP.
01 C          PIC  9(3) COMP.
01 X          PIC  9(3) COMP.
01 Y          PIC  9(3) COMP.
01 Z          PIC  9(3) COMP.
01 S          PIC  9(3) COMP.
01 R          PIC  9(3) COMP.
01 GK         PIC  9(9) COMP.
01 OUT        PIC  Z(8)9.
01 GCD-TBL.
   03 G-T1    OCCURS 200.
      05 G    PIC 9(3) OCCURS 200. 
*>
PROCEDURE DIVISION.
  ACCEPT K.
*>
  MOVE ZERO TO GK GCD-TBL.
  PERFORM VARYING A FROM 1 BY 1 UNTIL A > K
    PERFORM VARYING B FROM 1 BY 1 UNTIL B > K
    *>IF (A >= B) AND (G(B, A) > 0)
    *>  MOVE G(B, A) TO Z
    *>ELSE
      EVALUATE TRUE
        WHEN G(A, B) > 0
          MOVE G(A, B) TO Z
        WHEN G(B, A) > 0
          MOVE G(B, A) TO Z
        WHEN OTHER
          MOVE A TO X
          MOVE B TO Y  
          PERFORM GCD
          MOVE X TO Z 
          IF (A <= B)
            MOVE Z TO G(A, B)
          ELSE
            MOVE Z TO G(B, A)
          END-IF
      END-EVALUATE  
    *>END-IF
*>      
      PERFORM VARYING C FROM 1 BY 1 UNTIL C > K
        EVALUATE TRUE 
          WHEN G(Z, C) > 0
            MOVE G(Z, C) TO X
          WHEN G(C, Z) > 0
            MOVE G(C, Z) TO X
          WHEN OTHER
            MOVE Z TO X  
            MOVE C TO Y  
            PERFORM GCD
            IF (Z <= C)
              MOVE X TO G(Z, C)
            ELSE
              MOVE X TO G(C, Z)
            END-IF
        END-EVALUATE
*>         
        ADD X TO GK
      END-PERFORM
    END-PERFORM
  END-PERFORM.
*>
  MOVE GK TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.
*>---------------------------------------------<*
GCD SECTION.
  PERFORM UNTIL Y = 0
    DIVIDE X BY Y GIVING S REMAINDER R
    MOVE Y TO X
    MOVE R TO Y  
  END-PERFORM.
*>
  EXIT.

Measured memory_bytes: 4008
s = gets.chomp
k = gets.chomp.to_i

squeezed_s = [[s[0], 1]]
s[1..-1].chars.each do |s|
  if squeezed_s[-1][0] == s
    squeezed_s[-1][1] += 1
  else
    squeezed_s.push [s, 1]
  end
end

if s[0] == "1" && k > squeezed_s[0][1]
  puts squeezed_s[1][0]
else
  puts squeezed_s[0][0]
end

Measured memory_bytes: 14416
import java.util.*;

public class Main {
  static int n;
  static ArrayList[] e;
  static HashMap[] elen;
  static int[] c;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    e = new ArrayList[n];
    elen = new HashMap[n];
    c = new int[n];
    for(int i = 0; i < n; i++) {
      e[i] = new ArrayList<Integer>();
      elen[i] = new HashMap<Integer, Integer>();
    }
    for(int i = 0; i < n - 1; i++) {
      int u = sc.nextInt() - 1;
      int v = sc.nextInt() - 1;
      int w = sc.nextInt();
      e[u].add(v);
      e[v].add(u);
      elen[u].put(v, w);
      elen[v].put(u, w);
    }
    dfs(0, -1);
    for(int i = 0; i < n; i++) {
      System.out.println(c[i]);
    }
  }

  public static void dfs(int now, int p) {
    ArrayList<Integer> l = e[now];
    HashMap<Integer, Integer> h = elen[now];
    for(int i = 0; i < l.size(); i++) {
      int g = l.get(i);
      if(g != p) {
        int len = h.get(g);
        if(len % 2 == 0) {
          c[g] = c[now];
        } else {
          c[g] = 1 - c[now];
        }
        dfs(g, now);
      }
    }
  }
}


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

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

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

	sort( B.begin(), B.end() );
	map<long long, int> m;
	int v = 1;
	long long last = -1;
	for ( int i = 0; i < n; i++ ) {
		if( B[i] != last ) {
			last = B[i];
			m[ B[i] ] = v;
			v++;
		}
	}
	BIT bit( m.size() + 1 );
	long long ans = 0;
	for ( int i = 0; i < n; i++ ) {
		ans += i - bit.sum( m[ A[i] ] );
		bit.add( m[ A[i] ], 1 );
	}

	cout << ans << endl;
}



Measured memory_bytes: 19180
#include <iostream>
#include <vector>
using namespace std;
#define MAX_N 100010

int main() {
    vector<int> is_prime(MAX_N, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX_N; i++) {
        if (!is_prime[i]) continue;
        for (int j = i * 2; j < MAX_N; j+=i) {
            is_prime[j] = 0;
        }
    }

    vector<int> a(MAX_N, 0);
    for (int i = 0; i < MAX_N; i++) {
        if (i % 2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }

    vector<int> S(MAX_N+1, 0);
    for (int i = 0; i < MAX_N; i++) S[i+1] = S[i] + a[i];

    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        int l, r; cin >> l >> r;
        cout << S[r + 1] - S[l] << endl;
    }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

typedef unsigned long long ULL;
typedef long long ll;

int n;

struct node{
    double x,y;
    char dir[4];
}A[100050];

double cal(double x){
    double ml=1e10,mr=-1e10,mu=-1e10,md=1e10;
    FOR(i,1,n){
        pair<double,double>tmp;
        tmp.first=A[i].x,tmp.second=A[i].y;
        switch(A[i].dir[0]){
            case 'U':tmp.second+=x;break;
            case 'D':tmp.second-=x;break;
            case 'L':tmp.first-=x;break;
            case 'R':tmp.first+=x;break;
        }
        ml=min(ml,tmp.first);
        mr=max(mr,tmp.first);
        mu=max(mu,tmp.second);
        md=min(md,tmp.second);
    }
    //cout<<x<<" "<<(mr-ml)*(mu-md)<<endl;
    return (mr-ml)*(mu-md);
}

int main(){
    cin>>n;
    FOR(i,1,n){
        scanf("%lf%lf%s",&A[i].x,&A[i].y,A[i].dir);
    }
    double l=0,r=1e12,ans=1e18;
    FOR(k,0,300){
        double m1=(l+(r-l)/3),m2=(l+(r-l)*2/3);
        double tmp1=cal(m1),tmp2=cal(m2);
        if(tmp1>tmp2)l=m1;
        else r=m2;
        ans=min(ans,tmp1);
        ans=min(ans,tmp2);
    }
    printf("%.10f",ans);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pri 1000000007
#define PB push_back
#define MP make_pair
using namespace std;

void run(){
   string s;
   string t;
   cin>>s>>t;
   
   ll s1=s.length();
   ll t1=t.length();
 
   ll dp2[s1][t1]={0};
   for(ll i=0;i<s1;i++){
         for(ll j=0;j<t1;j++){dp2[i][j]=0;}}

  for(ll i=0;i<s1;i++){
         for(ll j=0;j<t1;j++){
                                      
                                  if(s[i]==t[j])      dp2[i][j]=((j>=1&&i>=1)?dp2[i-1][j-1]:0)+1;
                                  else  dp2[i][j]=max(((j>=1)?dp2[i][j-1]:0),((i>=1)?dp2[i-1][j]:0));
         	                      //cout<<i<<" "<<j<<" "<<dp2[i][j]<<endl;
         	                      	  
         	           }}
ll l=dp2[s1-1][t1-1],i=s1-1,j=t1-1;
string a="";
//cout<<l<<endl;

while(l>0){
if(dp2[i][j]==l&&s[i]==t[j]){	
		a=a+s[i];
		i--;
		j--;
		l--;
	
	
}
else if(i>=1&&dp2[i-1][j]==l){
	i=i-1;
	
}
else if(j>=1&&dp2[i][j-1]==l){
	j=j-1;
}

}
ll z=a.length();

for(ll i=z-1;i>=0;i--){cout<<a[i];}
	
}
int main() {
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 70528
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;


int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	long long int  str,s[200][200];
	//cout << fixed << setprecision(10);
	long long int n, m, a, b, c, k, res = 0,cou=0,memo,ma,mi;

	cin >> n;
	cout << 180*n-360;
}


Measured memory_bytes: 256
n=int(input())
s=list(input())
cnt_w = [0]*(n+1)
for i in range(1,n+1):
  cnt_w[i] = cnt_w[i-1] + (s[i-1]=='W')
ans = n + 1
for i in range(n):
  tmp = cnt_w[i] + (n-i-1) - (cnt_w[n] - cnt_w[i+1])
  ans = min(tmp,ans)
print(ans)

Measured memory_bytes: 23000
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 998244353
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
int main()
{
    ios::sync_with_stdio(0) ;
    cin.tie(0); 
    ll k,n;ll ans=0;
    cin>>n;
    if(n==2)
    {
        cout<<1<<endl;return 0;
    }
    if(n==3)
    {
        cout<<2<<endl;return 0;
    }
    ll r=sqrt(n);
    
    if(r*r==n)
    { 
       ans+=1;
       for(k=2;k<r;k++)
        {
        ll y=n;
        while(y%k==0)
        y/=k;
        y%=k;
        if(y==1)
        ans+=1;
        y=n-1;
        if(y%k==0&&y/k!=k)
        {
            ans+=1;
        }
        
    }
       
   }
    else
    {
        for(k=2;k<=r;k++)
        {
            ll y=n;
             while(y%k==0)
             y/=k;
             y%=k;
             if(y==1)
             ans+=1;
             y=n-1;
             if(y%k==0&&y/k!=k)
             {
                 ans+=1;
             }
         } 
    }
    cout<<ans+2;
    return 0;
}
//make all values ll


Measured memory_bytes: 256
n=int(input())
s=input()
i=0
while i<len(s)-1:
    if s[i]==s[i+1]:
        #print(s[i],s[i+1])
        #print(s,i)
        s=s[:i]+s[i+1:]
        #print(s,i)
    else:
        i+=1
print(len(s))

Measured memory_bytes: 3400
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
vector<P> pv;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  FOR(i, 1, n + 1) {
    int a;
    cin >> a;
    pv.push_back(P(a, i));
  }

  sort(pv.begin(), pv.end());

  REP(i, n) {
    cout << pv[i].second << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1780
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)

	S := getString()
	K := getInt()

	for i, v := range S {
		// out(i, K, string(v))
		if v == '1' {
			if K == i+1 {
				out(string(v))
				return
			}
		} else {
			out(string(v))
			return
		}
	}
}


Measured memory_bytes: 640
n,c=map(int,input().split())
xpos=[]
ypos=[]
pos=[]
for _ in range(n):
  x,y=map(int,input().split())
  xpos.append(x)
  ypos.append(y)
  pos.append([x,y])
xpos=sorted(xpos)
ypos=sorted(ypos)
ans=10**20
for i in range(n):
  for j in range(i+1,n):
    for k in range(n):
      for l in range(k+1,n):
        lx,rx=xpos[i],xpos[j]
        ly,ry=ypos[k],ypos[l]
        cnt=0
        for tx,ty in pos:
          if lx<=tx<=rx and ly<=ty<=ry:
            cnt+=1
        if cnt>=c:
          ans=min(ans,(rx-lx)*(ry-ly))
print(ans)


Measured memory_bytes: 51196
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~ Aashutosh Rathi~~~~~~
// ~~~~~~~~aashutoshrathi~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
// Use memcpy while copying matrix :D
// o_O Never do calculation in if block -_- 
// Use __builtin_popcount(z) to get set bit count of z
 
#include <bits/stdc++.h> 	// Apne aap me sab kuch hai isme 
#include <stdio.h>

using namespace std;	// Kyuki yahi mai-baap hai
 
#define mod(x) 			x%1000000007
#define MIN(n1, n2)     ((n1) > (n2) ? (n2) : (n1))
#define MAX(n1, n2)     ((n1) > (n2) ? (n1) : (n2))
#define MID(s, e)       (s+(e-s)/2)
#define fast fin; fout; fio;
#define fin cin.tie(NULL)
#define fout cout.tie(NULL)
#define fio ios::sync_with_stdio(false)
typedef pair <long, long> lpairs;
typedef long long ll;

// ll getDen(ll a[], ll n) {
//     ll left[n], right[n];
//     ll ret = 0;
//     memset(left, 0, sizeof(left));
//     memset(right, 0, sizeof(right));
//     left[0] = 1;
//     right[n-1] = 1;
//     for(int i=1; i<n; i++) {
//         left[i] = left[i-1]*a[i-1];
//     }
//     for(int i=n-2; i>-1; i--) {
//         right[i] = right[i+1]*a[i+1];
//     }
//     for(int i=0; i<n; i++) {
//         ret += left[i]*right[i];
//     }
//     return ret;
// }

int main() {
    fast
    ll n;
    cin >> n;
    ll a[n];
    long double num = 0.0;
    for(ll i=0; i<n; i++) {
        cin >> a[i];
        num += 1.0/a[i];
    }
    long double res = 1.0/num;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
AC=[0]*n
cnt=[0]*n
ans=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    s=str(s)
    if s=='WA' and AC[p-1]==0:
        cnt[p-1]+=1
    if s=='AC' and AC[p-1]==0:
        AC[p-1]=1
        ans+=cnt[p-1]
print(sum(AC),ans)

Measured memory_bytes: 10268
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;

int n,k;

int main(){
	cin >> n >> k; n = (1 << n);
	if(k >= n){ cout << -1 << endl; return 0; }
	if(n == 1){ cout << 0 << ' ' << 0 << endl; return 0; }
	if(n == 2){
		if(k == 0) cout << 0 << ' ' << 0 << ' ' << 1 << ' ' << 1 << endl;
		else cout << -1 << endl; return 0;
	}
	for(int i = 0;i < n;i ++) if(i != k) cout << i << ' ';
	cout << k << ' ';
	for(int i = n - 1;i >= 0;i --) if(i != k) cout << i << ' ';
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std ;
int main(){
    int N, k ;
    cin >> N ;
    vector<int> vec(N) ;
     for(int i = 0; i < N; i++){
         cin >> vec.at(i) ;
     }
    sort(vec.begin(), vec.end() ) ;
        if(vec.at(N/2 - 1) != vec.at(N/2) && vec.at(N/2 - 1) - vec.at(N/2) != 1 ){
        k = vec.at(N/2) - vec.at(N/2 - 1) ;
        cout << k  << endl ;
    }
    else if(vec.at(N/2 - 1) == vec.at(N/2) || vec.at(N/2 - 1) - vec.at(N/2) != 1 ){
        cout << 0 << endl ;
    }

    return 0 ;
 
}

Measured memory_bytes: 768
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

#define LL long long int

LL gcd(LL a, LL b) { return b?gcd(b,a%b):a;}
LL lcm(LL a, LL b) { return a/gcd(a,b)*b;}
 
LL A,B;

LL ans = 0;

vector<pair<LL,LL>> factorial(LL x){//xを素因数分解する 素数LLが何個入っているかを返す
	vector<pair<LL,LL>> ret;
	for(LL i=2;i*i<=x;i++){
		if(x%i==0){
			LL counter = 0;
			while(1){
				if(x%i!=0) break;
				x /= i;
				counter++;
			}
			ret.push_back(make_pair(i,counter));
		}
	}
	if(x!=1) ret.push_back(make_pair(x,1));
	return ret;
}
 
void solve(){
	LL gcd_AB = gcd(A,B);//A,Bの最大公約数
	vector<pair<LL,LL>> fact = factorial(gcd_AB);//それを素因数分解
	ans = fact.size()+1;
}
 
int main(){
	cin>>A>>B;

	solve();

	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{
   int n,m;
   cin >> n >> m;
   if(n==m)cout<<"Yes";
   else cout<<"No";
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 23680
using System;
using System.Collections.Generic;

namespace B___Beautiful_Strings
{
    class Program
    {
        static void Main(string[] args)
        {
            var w = Console.ReadLine();
            var a = "abcdefghijklmnopqrstuvwxyz";
            for (var i = 0; i < a.Length; i++)
            {
                var b = w.Length - w.Replace(a[i].ToString(), "").Length;
                if (b % 2 == 1)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int N, a, b;
long long res;

// mod. m での a の逆元 a^{-1} を計算する
long long Modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


/*二分累乗法*/
long long Modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long ModComb(long long n, long long a, long long mod){
  long long i = 0;
  long long res = 1;
  while(a > 0){
    res *= ((n-i) * Modinv(a, MOD)) % MOD;
    res %= MOD;
    --a; ++i;
  }

  return res;
}


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

  res = (2 * MOD + Modpow(2, N, MOD) - ModComb(N, a, MOD) - ModComb(N, b, MOD) - 1) % MOD;
  cout << res << endl;
  return 0;
}




    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
int main()
{

    ll n , k ;
    cin>> n >> k ;
    unordered_set<ll > arr ;
    for( ll i = 1 ; i <=  n ;i++ )
    {
        arr.insert(i) ;

    }

    while(k)
    {

        k--  ;
        ll  j ;
        cin>>j ;
        while(j)
            {

                j-- ;
                ll h ;
                cin>>h ;
                if(arr.find(h)!=arr.end())
                {

                    arr.erase(h) ;
                }
            }
    }

    cout<< arr.size() <<endl ;
}


Measured memory_bytes: 3636
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      aa: [isize; n],
    }
    let mut aa = aa;
    aa.insert(n, 0);
    aa.insert(0, 0);

    let mut s = 0;
    for i in 1..n+2 {
        s += (aa[i] - aa[i-1]).abs();
    }
    for i in 1..n+1 {
        let d1 = (aa[i+1] - aa[i-1]).abs();
        let d2 = (aa[i] - aa[i-1]).abs();
        let d3 = (aa[i+1] - aa[i]).abs();
        // println!("{} d1={} d2={} d3={}", s, d1, d2, d3);
        println!("{}", s + d1 - d2 - d3);
    }
}


Measured memory_bytes: 5244
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vector<pii> red(n), blue(n);
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    red[i] = pii(a,b);
  }
  rep(i,n) {
    int c, d;
    cin >> c >> d;
    blue[i] = pii(c,d);
  }

  sort(red.begin(), red.end());
  sort(blue.begin(), blue.end());

  int ans = 0;
  rep(i,n) {
    int ry_max = -1;
    int red_j = -1;
    rep(j,red.size()) {
      if (red[j].fi < blue[i].fi && red[j].se < blue[i].se) {
        if (ry_max < red[j].se) {
          ry_max = red[j].se;
          red_j = j;
        }
      }
    }
    if (red_j != -1) {
      ans++;
      red.erase(red.begin()+red_j);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a==b)
	{
		if(b!=c) 
		{
			printf("Yes\n");
			return 0;
		}
	}
	else if(a==c)
	{
		if(b!=c) 
		{
			printf("Yes\n");
			return 0;
		}
	}
	else if(c==b)
	{
		if(a!=c) 
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

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

using namespace std;

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

	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << '\n';

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 998244353
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pie 3.141592653589793
#define fi first
#define se second
using namespace std ;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define maxn   200005
lli A[maxn]; 
lli BIT[maxn*2],n;
void update(lli x, lli val)
{
	  A[x]=val;
      for(; x <= n; x += x&-x)
        {BIT[x] += val;BIT[x]%=mod;}
}
lli query(lli x)
{
     lli sum = 0;
     for(; x > 0; x -= x&-x)
        {sum += BIT[x];sum=sum%mod;}
     return sum;
}
void solve()
{

	lli k;
	cin>>n>>k;
	pll arr[k];
	for(lli i=0;i<k;i++){
		cin>>arr[i].fi>>arr[i].se;
	}
	update(1,1);
	//build();
	lli ani=0;
	for(lli i=2;i<=n;i++){
		lli tani=0;
		for(lli j=0;j<k;j++){
			lli fr=i-arr[j].se-1,to=i-arr[j].fi;
			if(to<=0)continue;
			//cout<<i<<" "<<fr<<" "<<to<<" "<<query(fr,to)<<endl;
			if(fr<0)fr=0;
			//cout<<i<<" "<<fr<<" "<<to<<" "<<query(to)-query(fr)<<endl;
			tani+=(query(to)-query(fr)+mod)%mod;
		}
		A[i]=tani;
		update(i,tani);

	}
	cout<<A[n]%mod;

}
int main()
{
/////////////////////////////////////
    fastio;
/////////////////////////////////////  
    lli t,m;
    //cin>>t;
    t=1;
    while(t--)
    {
    	solve();  
    	m++;  
    	cout<<endl;
    }
}

Measured memory_bytes: 6756
n =int(input())
H = list(map(int,input().split()))

max_H = H[0]
for i in range(1, n):
    if H[i-1]>H[i]:
        max_H = max(H[i-1], max_H)
        if abs(max_H - H[i])>1:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 14396
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N, A, B;
vector<ll> vec;

//解法
void solve() {

	SORTL2S(ll, vec);

	ll len = 0;
	rep(i, vec.size() - 1) {
		len += vec[i + 1];
	}

	if (vec[0] < len) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return;
}

int main() {
	//入力

	cin >> N;
	vec.resize(N);
	rep(i, N) cin >> vec[i];

	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, m;
  cin >> n >> m;
  vector<pair<ll,ll>> v(n);
  rep(i, 0, n) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());

  ll ans = 0;
  int c = 0;
  rep(i, 0, n) {
    if (c + v[i].second > m){
      ans += (m - c) * v[i].first;
      break;
    }
    else
      ans += v[i].second * v[i].first;
    c += v[i].second;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4780
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

// ABC179B
let n = readInt()
var dij: [[Int]] = []
for _ in 1...n {
    dij.append(readInts())
}
var count = 0
var result = "No"
for d in dij {
    if d[0] == d[1] {
        count += 1
    } else {
        count = 0
    }
    if count == 3 {
        result = "Yes"
        break
    }
}
print(result)


Measured memory_bytes: 13600
fun main(args: Array<String>) {
    var (a,b,c,x,y) = readLine()!!.split(" ").map(String::toInt)
    var one_chg = Math.min(a+b,c*2)
    var ans = Math.min(x,y)*one_chg
    var sa = Math.abs(x-y)
    if(x>y) ans += Math.min(sa*a,sa*c*2)
    else ans += Math.min(sa*b,sa*c*2) 
    println(ans)
}

Measured memory_bytes: 37848
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int n, t, minimum=INF, maxbenefit=0, c=0;
 cin >> n >> t;
 int a[n], benefit[n];
 for(int i=0;i<n;i++){
 	cin >> a[i];
 	minimum=min(a[i],minimum);
    benefit[i]=a[i]-minimum;
    maxbenefit=max(maxbenefit, benefit[i]);
 }
   for(int i=0;i<n;i++) if (benefit[i]==maxbenefit) c++;
 cout<< c;
  
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

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

    ll ans = 0;
    for (int mask = 0; mask < (1 << n); mask++) {
        ll tmp = 0;
        for (int i = 0; i < n; i++) {
            if (mask & (1 << i)) {
                tmp = tmp * 10 + s[i] - '0';
            } else {
                ans += tmp; tmp = 0;
            }
        }
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define lp(i, a, b) for (int i=a;i<=(int)b;++i)
#define lp2(i, a, b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define pr(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define clr(c, x) memset(c,x,sizeof(c));
template<class T> using OS = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int N = (int) 2e5 + 5;
const ll mod = 998244353;

int main() {
    FAST;
    ll x, r, d;
    cin >> r >> d >> x;
    lp(i, 1, 10) {
        x = r * x - d;
        cout << x << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
# from datetime import date, timedelta
# from heapq import *
import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


def cnk(a, b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1, MOD) % MOD
    return ret


class UnionFind:
    def __init__(self, n):
        self.sz = [-1 for i in range(n)]

    # 検索
    def find(self, x):
        if self.sz[x] < 0:
            return x
        else:
            self.sz[x] = self.find(self.sz[x])
            return self.sz[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.sz[x] > self.sz[y]:
            x, y = y, x
        self.sz[x] += self.sz[y]
        self.sz[y] = x

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xが含まれている集合のサイズを求める
    def size(self, x):
        return -self.sz[self.find(x)]


def main():
    h, a = map(int, input().split())

    if h % a == 0:
        print(h // a)
    else:
        print(h//a + 1)



            


    




    


if __name__ == '__main__':
    main()


Measured memory_bytes: 5112
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    primes = []
    for i in range(2, 55556):
        is_prime = True
        for j in range(2, int(math.sqrt(i) ) + 1):
            if i % j == 0:
                is_prime = False
                break
        if is_prime == True:
            primes.append(i)
    #print primes, len(primes)

    ok_list = []
    for p in primes:
        if (p - 1) % 6 == 0 and (p - 1) % 5 == 0:
            ok_list.append(p)

    for i in range(N):
        print ok_list[len(ok_list) - 1 - i],


if __name__ == '__main__':
    main()


Measured memory_bytes: 5104