akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int A, B, C, D;
	string S;
	cin >> S;
	vector<char>AA(10);
	AA = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
	rep(i, 10) {
		if (AA[i] == S[0]) {
			A = i;
		}
	}
	rep(i, 10) {
		if (AA[i] == S[1]) {
			B = i;
		}
	}
	rep(i, 10) {
		if (AA[i] == S[2]) {
			C = i;
		}
	}
	rep(i, 10) {
		if (AA[i] == S[3]) {
			D = i;
		}
	}
	vector<char>a(2);
	a = { '+','-' };
	int ans = 0;
	rep(i, 2) {
		rep(j, 2) {
			rep(k, 2) {
				ans = A;
				if (i == 0) {
					ans += B;
				}
				if (i == 1) {
					ans -= B;
				}
				if (j == 0) {
					ans += C;
				}
				if (j == 1) {
					ans -= C;
				}
				if (k == 0) {
					ans += D;
				}
				if (k == 1) {
					ans -= D;
				}
				if (ans == 7) {
					cout << A << a[i] << B << a[j] << C << a[k] << D << '=' << 7 << endl;
					return 0;
				}
			}
		}
	}
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define mp make_pair
#define pb push_back
#define MAXN 1000100
typedef long long ll;

struct blk_haha
{
	int l,val;
}qw[MAXN],qb[MAXN];

int n,m,f[MAXN],sumd[MAXN],qwl,qwr,qbl,qbr;
char s[MAXN],t[MAXN];

int getsum(int l,int r)
{
	int tmp=0;
	if(sumd[l]-sumd[l-1]==1)tmp=sumd[r]-sumd[l-1];
	else tmp=sumd[r]-sumd[l-1]+1;
	if(tmp&1)return (tmp+1)/2;
	else return (tmp)/2+1;
}

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	scanf("%s",t+1);
	sumd[1]=1;
	rep(i,2,n)
	{
		if(t[i]!=t[i-1])
			sumd[i]=1;
		sumd[i]+=sumd[i-1];
	}
	qwl=qbl=1;
	rep(i,1,n)
	if(s[i]!=t[i])
	{
		f[i]=getsum(max(i-m+1,1),i)+f[max(i-m,0)];
		f[i]=min(f[i],1+f[i-1]);
		if(t[i]=='B')
		{		
			while(i-m>=qb[qbl].l && qbl<=qbr)
			{
				qbl++;
			}
			
			if(qbl<=qbr)
			{
				int l=qb[qbl].l;
				f[i]=min(f[i],getsum(l,i)+f[l-1]);
			}
			
			if(sumd[i]!=sumd[i-1])
			{
				int tmp=1+f[i-1];
				while(qbl<=qbr && tmp<=getsum(qb[qbr].l,i)+f[qb[qbr].l-1])
				{
					qbr--;
				}
				qbr++;
				qb[qbr].l=i;
			}
		}
		else
		{		
			while(i-m>=qw[qwl].l && qwl<=qwr)qwl++;
			
			if(qwl<=qwr)
			{
				int l=qw[qwl].l;
				f[i]=min(f[i],getsum(l,i)+f[l-1]);
			}
			
			if(sumd[i]!=sumd[i-1])
			{
				int tmp=1+f[i-1];
				while(qwl<=qwr && tmp<=getsum(qw[qwr].l,i)+f[qw[qwr].l-1])
				{
					qwr--;
				}
				qwr++;
				qw[qwr].l=i;
			}
		}
	}
	else 
	{
		f[i]=f[i-1];
		if(t[i]=='B')
		{
			if(sumd[i]!=sumd[i-1])
			{
				int tmp=1+f[i-1];
				while(qbl<=qbr && tmp<=getsum(qb[qbr].l,i)+f[qb[qbr].l-1])
				{
					qbr--;
				}
				qbr++;
				qb[qbr].l=i;
			}
		}
		else
		{
			if(sumd[i]!=sumd[i-1])
			{
				int tmp=1+f[i-1];
				while(qwl<=qwr && tmp<=getsum(qw[qwr].l,i)+f[qw[qwr].l-1])
				{
					qwr--;
				}
				qwr++;
				qw[qwr].l=i;
			}
		}
	}
	printf("%d\n",f[n]);
	return 0;
}



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

int main(void) {
	int a, b, sum=0;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		string s = to_string(i);
		if (s[0] == s[4] && s[1] == s[3]) sum++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()	
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=1000000000000000000LL;
typedef pair<int,int> P;
vector<int> v[26];
vector<P> t;
struct BinaryIndexedTree{
    vector<int> bit;
    BinaryIndexedTree(int siz){
        bit.assign(++siz,0);
    }

    int sum(int k){
        int ret=0;
        for(++k;k>0;k-=k&-k){
            ret+=bit[k];
        }
        return ret;
    }

    void add(int k,int x){
        for(++k;k<bit.size();k+=k&-k){
            bit[k]+=x;
        }
    }
};
int main(){
    string s;cin>>s;
    int n=s.length();
    for(int i=0;i<n;i++){
        v[s[i]-'a'].push_back(i);
    }
    int id=-1;
    for(int i=0;i<26;i++){
        int m=v[i].size();
        if(m==0)continue;
        if(m%2){
            if(id==-1){
                id=v[i][m/2];
            }else{
                cout<<-1<<endl;
                return 0;
            }
        }
        for(int j=0;j<m/2;j++){
            t.push_back(P(v[i][j],v[i][m-j-1]));
        }
    }
    sort(all(t),greater<P>());
    ll ans=0;
    BinaryIndexedTree bit(n+1);
    for(int i=0;i<t.size();i++){
        int a=t[i].first,b=t[i].second;
        if(id!=-1&&a>id)ans++;
        if(id!=-1&&b<id)ans++;
        ans+=bit.sum(n)-bit.sum(b);
        bit.add(b,1);
        bit.add(a,1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3320
N = int(input())

a = [1]
n6 = 6
while n6 <= 100000:
    a.append(n6)
    n6 *= 6
n9 = 9
while n9 <= 100000:
    a.append(n9)
    n9 *= 9

#dp[i]=ちょうどi円払う場合に最小の操作回数
dp = [10**9] * (N+100010)
dp[0] = 0

for i in range(N):
    for n in a:
        dp[i+n] = min(dp[i+n], dp[i]+1)
print(dp[N])

Measured memory_bytes: 42476
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main(){
 
    string N;

    cin >> N;

    if((N[0]==N[1]&&N[1]==N[2])||(N[1]==N[2]&&N[2]==N[3])){
        cout << "Yes" <<endl;
    }else{
        cout << "No"  <<endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

void dfs(const vector<vector<int>> &edge, vector<bool> &visited)
{
  vector<int> stack;
  stack.push_back(0);

  while(!stack.empty())
  {
	int node = stack.back();
	stack.pop_back();
	visited[node] = true;
	
	for(int i : edge[node])
	{
	  if(!visited[i])
	  {
		stack.push_back(i);
	  }
	}
  }  
}

bool all(vector<bool> &visited, const int n)
{
  for(int i = 0; i < n; i++)
  {
	if(!visited[i]) return false;
  }
  return true;
}

int main()
{
  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> edge;
  for(int i = 0; i < n + m; i++)
  {
	edge.push_back(vector<int>());
  }
  
  for(int i = 0; i < n; i++)
  {
	int k;
	cin >> k;
	for(int j = 0; j < k; j++)
	{
	  int l;
	  cin >> l;
	  l--;
	  edge[i].push_back(n + l);
	  edge[n + l].push_back(i);
	}
  }

  vector<bool> visited(n + m);
  fill(visited.begin(), visited.end(), false);
  dfs(edge, visited);

  if(all(visited, n))
  {
	cout << "YES" << endl;
  }
  else
  {
	cout << "NO" << endl;
  }  
}


Measured memory_bytes: 9324
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

int main() {
	string a, b; cin >> a >> b;

	if (a.size() == b.size()) {
		if (a > b) {
			cout << "GREATER" << endl;
		}
		else if (a == b) {
			cout << "EQUAL" << endl;
		}
		else {
			cout << "LESS" << endl;
		}
	}
	else if (a.size() > b.size()) {
		cout << "GREATER" << endl;
	}
	else {
		cout << "LESS" << endl;
	}

	return 0;
}

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

int main(){
  int n,m,tl[10000],tr[10000],ta[20000],tri,tli,tai;
  int t;
  while (1){
    cin >> n >> m;

    if (n==0&&m==0) break;
    tri =0;
    tli=0;
    tai=0;
    for (int i=0;i<n;i++)
      cin >> tl[i];

    for (int i=0;i<m;i++)
      cin >> tr[i];

    while (tai<n+m){
      if (tri>=m){ ta[tai++]=tl[tli++];continue;}
      if (tli>=n){ ta[tai++]=tr[tri++];continue;}

      if (tr[tri]>tl[tli]){
	ta[tai++]=tl[tli++];
      }	else if(tr[tri]<tl[tli]){
        ta[tai++]=tr[tri++];
      }else {
	ta[tai++]=tl[tli++];
        ta[tai++]=tr[tri++];
      }
    }
    //for (int i=0;i<tai;i++)
    //  cout << ta[i]<<" ";
    //cout <<endl;
    t=ta[0];
    for (int i=1;i<tai;i++){
      if (t<ta[i]-ta[i-1]) t=ta[i]-ta[i-1];
    }
    cout << t <<endl;
  }
  return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define P push
#define B begin()
#define E end()
#define SI size()
#define RE return
#define C continue
#define W while
#define SF(x) scanf("%d",&x);
#define MEM(vis,i) memset(vis,i,sizeof(vis))
#define rep(i,x,n) for(int i=x;i<n;i++)
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> pll;
const long long MOD = 1e9+7;
const long long MAX = 1e14+8;
const long long MAXN = 1e5+8;
const long long eps = 1e-4;
ll t[103];
int main()
{
    ll n,M=0;
    cin>>n;
    if(n==2){
cout<<"Possible";
return 0;     }
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        M=max(M,x);
        t[x]++;
    }
    bool b=1;
    if(t[M]==1)b=0;
    if(t[1]>1)b=0;
    for(int i=M;i>=ceil(M/2.0);i--){
        if(t[i]==0)b=0;
    }
    for(int i=0;i<ceil(M/2.0);i++)
        if(t[i]!=0)b=0;
    ll ad=ceil(M/2.0);
    if(M%2==1){
        if(t[ad]!=2)b=0;
    }
    else{
        if(t[ad]!=1)b=0;
    }
    if(!b)cout<<"Impossible";
    else cout<<"Possible";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 2010

ll h, w;

int main() {
	cin >> h >> w;
	if (w % 3 == 0 || h % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = h*w;
	ll sma, smi;
	while (ans > 3 * min(h, w))ans -= 3 * min(h, w);
	REP(j, w) {
		sma = max(h*j, (w - j)*(h / 2 + (h % 2)));
		smi = min(h*j, (w - j)*(h / 2));
		ans = min(sma - smi, ans);
		sma = max(h*j, h*((w - j) / 2 + ((w - j) % 2)));
		smi = min(h*j, h*((w - j) / 2));
		ans = min(sma - smi, ans);
	}
	REP(i, h) {
		sma = max(w*i, (h - i)*(w / 2 + (w % 2)));
		smi = min(w*i, (h - i)*(w / 2));
		ans = min(sma - smi, ans);
		sma = max(w*i, w*((h - i) / 2 + ((h - i) % 2)));
		smi = min(w*i, w*((h - i) / 2));
		ans = min(sma - smi, ans);
	}
	cout << ans << endl;

}



Measured memory_bytes: 256
import static java.util.stream.Collectors.groupingBy;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    
    public static void main(String[] args) {
        int N = nint();
        int M = nint();
        
        List<City> cities = new ArrayList<>(1000000);
        for (int i = 1; i <= M; i++) {
            cities.add(new City(nint(), nint()));
        }
        
        Map<Integer, List<City>> map =
                cities.stream().collect(groupingBy(city -> city.pref));
        
        for (List<City> list : map.values()) {
            list.sort((c1, c2) -> c1.since - c2.since);
            
            for (int i = 1; i <= list.size(); i++) {
                list.get(i-1).no = i;
            }
        }
        
        StringBuffer sb = new StringBuffer();
        
        for (City city: cities) {
            sb.append(String.format("%06d%06d", city.pref, city.no));
            sb.append(System.lineSeparator());
        }
        
        System.out.println(sb.toString());
    }
    
    static class City {
        int pref;
        int since;
        int no;
        
        public City(int pref, int since) {
            this.pref = pref;
            this.since = since;
        }
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 173812
#include <iostream>
#include <algorithm>

using namespace std;

const int N_MAX = 101;
int d1[N_MAX], d2[N_MAX], cr[N_MAX];
int N;
string s1, s2;

int main() {
    cin >> N;

    while (N--) {
        cin >> s1;
        cin >> s2;

        reverse(s1.begin(), s1.end());
        reverse(s2.begin(), s2.end());

        fill(d1, d1 + N_MAX, 0);
        fill(d2, d2 + N_MAX, 0);
        fill(cr, cr + N_MAX, 0);

        for (int i = 0; i < s1.length(); i++) { d1[i] = s1[i] - '0'; }
        for (int i = 0; i < s2.length(); i++) { d2[i] = s2[i] - '0'; }

        string ans;
        int d;

        for (int i = 0; i <= max(s1.length(), s2.length()); i++) {
            d = d1[i] + d2[i] + cr[i];
            ans += to_string(d % 10);
            if (d >= 10) cr[i + 1] = 1;
        }

        if (ans.back() == '0') {
            ans.erase(ans.length() - 1, 1);
        }

        reverse(ans.begin(), ans.end());

        if (ans.length() > 80) {
            ans = "overflow";
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3136
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX 1400

int getLargestSquare( int H, int W, int G[MAX][MAX] ) {
  int dp[MAX][MAX];
  int maxWidth = 0;
  for ( int i = 0; i < H; i++ )
    for ( int j = 0; j < W; j++ ) {
      dp[i][j] = (G[i][j] + 1) % 2;
      maxWidth |= dp[i][j];
    }

  for ( int i = 1; i < H; i++ )
    for ( int j = 1; j < W; j++ ) {
      if ( G[i][j] ) {
        dp[i][j] = 0;
      } else {
        dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
        maxWidth = max(maxWidth, dp[i][j]);
      }
    }

  return maxWidth * maxWidth;
}

int main() {
  int H, W, G[MAX][MAX];
  scanf("%d %d", &H, &W);

  for ( int i = 0; i < H; i++ )
    for ( int j = 0; j < W; j++ ) scanf("%d", &G[i][j]);

  printf("%d\n", getLargestSquare(H, W, G));

  return 0;
}


Measured memory_bytes: 17920
#include <iostream>
#include <cmath>
#include <algorithm>
int main(){
    using namespace std;
    int a,b,c,k,x,ans;
    cin >> a >> b >> c >> k;
    ans = a+b+c;
    x = max({a,b,c});
    ans = ans - x + x*pow(2,k);
    cout << ans << endl;
    return 0;
}

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

int main(){
	double xa1, ya1;
	double xa2, ya2;
	double xb1, yb1;
	double xb2, yb2;
	while(cin >> xa1 >> ya1 >> xa2 >> ya2
		>> xb1 >> yb1 >> xb2 >> yb2)
	{
		if(max(xa1,xa2) >= min(xb1,xb2) && max(xb1,xb2) >= min(xa1,xa2)
			&& max(ya1,ya2) >= min(yb1,yb2) && max(yb1,yb2) >= min(ya1,ya2))
		{
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}		
	}
	return 0;
}

Measured memory_bytes: 0
S = input()

if len(set(S)) == 26:
  print("None")
else:
  for dam in ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]:
    if not dam in list(set(S)):
           break
  print(dam)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<int, int, int> tp;
///-------------------------

int main()
{
    Phuong_; /// <3333
    int n;
    cin >> n;
    double d;
    cin >> d;
    int ans=0;
    while(n--){
        ld x,y;
        cin >> x >> y;
        ld dis = sqrt(x*x + y*y);
        if(dis<=d) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3824
#include <stdio.h>

int main(void) {
    int n, k[10000], count, max;
    int i;

    while (1) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        }

        count = 0;
        max = -1;
        for (i=0; i<n; i++) {
            scanf("%d", &k[i]);
        
            if (max < k[i]) {
                max = k[i];
            }

            if (k[i] >= 1) {
                count++;
            }
        }

        if (max < 2) {
            printf("NA\n");
        }
        else {
            printf("%d\n", count+1);
        }
    }

    return 0;
}

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

int main() {
  int N, A, G = 0;
  vector<int> V(1e6+1);
  cin >> N;
  while (cin >> A) V.at(A)++, G = gcd(G, A);
  if (G > 1) return cout << "not coprime" << "\n", 0;
  for (int i = 2; i <= 1e6; i++) {
    for (int j = i, ex = 0; j <= 1e6; j += i) {
      if (V.at(j)) {
        if (ex) return cout << "setwise coprime" << "\n", 0;
        else ex = 1;
      }
    }
  }
  cout << "pairwise coprime" << "\n";
}

Measured memory_bytes: 7040
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

lo n,m,b,a[li],k,flag,cev,kul,yes=-1;
string s;
PII p[li];
vector<lo> v;

int main(void){
	scanf("%lld %lld",&n,&m);
	FOR{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1);
	//~ reverse(a+1,a+n+1);
	for(lo i=1;i<=m;i++){
		scanf("%lld %lld",&p[i].se,&p[i].fi);
	}
	sort(p+1,p+m+1);
	reverse(p+1,p+m+1);
	lo at=1;
	FOR{
		if(kul>=p[at].se){kul=0;at++;}
		if(at>m){yes=i;break;}
		
		if(a[i]>=p[at].fi){cev+=a[i];continue;}
		cev+=p[at].fi;
		//~ cout<<cev<<endl;
		kul++;
	}
	if(yes!=-1){
		for(lo i=yes;i<=n;i++){
			cev+=a[i];
		}
	}
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 2560
n=int(input())
a,b=map(int,input().split())
*p,=map(int,input().split())

A=len(list(filter(lambda x:x<=a,p)))
B=len(list(filter(lambda x:a+1<=x<=b,p)))
C=len(list(filter(lambda x:x>=b+1,p)))
print(min(A,B,C))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
 
using namespace std;
 
 
int main() {
	
	string a;
	cin>> a;
	for (int i = 0; i < a.size(); i++) {
		if (a[i]== ',')
			cout<<" ";
		else {
			cout << a[i];
		}
	}
 
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
    $input_line = trim(fgets(STDIN));
    
    $num = explode(" ",$input_line);
    
    $num[0] = intval($num[0]);
    $num[1] = intval($num[1]);
    $num[2] = intval($num[2]);
    
    if(($num[0] < $num[1]) && ($num[1] < $num[2])){
        echo "Yes";
    }else{
        echo "No";
    }

?>



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

int main() {
	int n;
	while (cin >> n, n) {
		int excel[11][11] = {};

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

		for (int i = 0;i < n;i++) {
			for (int j = 0;j < n;j++) {
				excel[i][n] += excel[i][j];
			}
		}

		for (int i = 0;i < n;i++) {
			for (int j = 0;j < n;j++) {
				excel[n][i] += excel[j][i];
			}
		}
		for (int i = 0;i <= n;i++) {
			for (int j = 0;j <= n;j++) {
				printf("%5d", excel[i][j]);
				if (j == n) { cout << endl; }
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3124
//
#include<cstdio>
using namespace std;
const int N=300005;
int a[N],v[N],n,next[2][N],tag[N],fr,end,cnt;

void solve()
{
	if(cnt==0)	
		v[++cnt]=a[1];
	fr=end=1;
	for(int i=2;i<=n;++i)
	{
		v[++cnt]=a[i];		
		int t=0;
		if(next[0][end]!=0)	t=1;
		next[t][end]=cnt;
		next[!t][cnt]=end;
		int tt=fr;
		fr=cnt,end=tt;
	}
}	

int main()
{
//	freopen("1.txt","r",stdin);
//	freopen("11.txt","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	solve();
	int t=0;
	if(next[1][fr])	t=1;	
	for(int i=fr;i!=end;i=next[t][i])
		printf("%d ",v[i]);
	printf("%d",v[end]);
	return 0;
}
		

Measured memory_bytes: 5888
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  vector<int> p;
  int tmp,n,k,sum=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>tmp;
    p.push_back(tmp);
  }
  sort(p.begin(),p.end());
  for(int i=0;i<k;i++){
    sum+=p[i];
  }
  cout<<sum<<endl;

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int preh;
    cin >> preh;
    int cnt = 0;
    int ans = 0;
    for (int i=0; i<n-1; i++) {
        int h;
        cin >> h;
        if (h <= preh) cnt++;
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
        preh = h;
    }
    ans = max(ans, cnt);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<cstring>
#include<cstdlib>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

char button1[5]={'.',',','!','?',' '};
char button2[3]={'a','b','c'};
char button3[3]={'d','e','f'};
char button4[3]={'g','h','i'};
char button5[3]={'j','k','l'};
char button6[3]={'m','n','o'};
char button7[4]={'p','q','r','s'};
char button8[3]={'t','u','v'};
char button9[4]={'w','x','y','z'};

int main(){
	string s;
	int n;
	cin>>n;
	cin.ignore();
	rep(a,n){
		getline(cin,s);
		int counta=0;
		string ans="";
		for(int i=0;i<s.size();i++){
			if(s[i]!='0'){
				counta=i;
				while(s[i]!='0' && i<s.size())i++;
				switch(s[counta]){
					case '1':
						ans+=button1[(i-counta-1)%5];
					break;
					case '2':
						ans+=button2[(i-counta-1)%3];
					break;
					case '3':
						ans+=button3[(i-counta-1)%3];
					break;
					case '4':
						ans+=button4[(i-counta-1)%3];
					break;
					case '5':
						ans+=button5[(i-counta-1)%3];
					break;
					case '6':
						ans+=button6[(i-counta-1)%3];
					break;
					case '7':
						ans+=button7[(i-counta-1)%4];
					break;
					case '8':
						ans+=button8[(i-counta-1)%3];
					break;
					case '9':
						ans+=button9[(i-counta-1)%4];
					break;
					default:
					break;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
ll A,B,a[N];
int n;
bool check(ll x){
	ll s=0;
	for(int i=1;i<=n;i++){
		if(a[i]-B*x<=0) continue;
		s+=(a[i]-B*x+A-B-1)/(A-B);
	}
	return s<=x;
}
int main(){
	scanf("%d%lld%lld",&n,&A,&B);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	ll l=0,r=1e9;
	while(l<r){
		ll mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%lld\n",l);
	return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,t;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>s>>t;
      rep(i,Size(s)){
        string co;
        rrep(j,i,Size(s)){
          cnt++;
          co+=s[j];
        }
        if(cnt!=Size(s)){
          rep(j,Size(s)-cnt)co+=s[j];
        }
        if(co==t){
          Cout("Yes");
          return 0;
        }
        cnt=0;
      }
      Cout("No");
     

       
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
    char S[101];
    int K;

    scanf("%d", &K);
    scanf("%s", &S[0]);

    if(strlen(S) <= K) {
        printf("%s\n", S);
    }
    else {
        S[K] = '\0';
        printf("%s", S);
        printf("...\n");
    }

    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int p, q, r, s, t;
  p = c * 2 * y + a * (x - y);
  q = c * 2 * x + b * (y-x);
  r = a * x + b * y;
  s =c *  2 * x;
  t = c * 2 * y;
  int aa, bb;
  aa = std::min(p,r);
  bb = std::min(q,r);
  if (x>y) {
    cout << std::min( aa, s) << endl;
  }
  else {
    cout << std::min(bb, t) << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
    #define MAX 6012
     
    int n;
     
    vector<bool> dp[MAX];
     
    vector<pair<int, int> > pos;  //b , a
    int mode[MAX];
    bool us[MAX];
     
    bool use[MAX];
    char buf[MAX];
    string s;
    vector<int> v1;
    vector<int> v2;
    bool cmp(vector<bool> a, vector<bool> b){
    	int lef = 0;
    	int rig = 0;
    	while (1){
    		while (lef < a.size() && a[lef] == false){
    			lef++;
    		}
    		while (rig < b.size() && b[rig] == false){
    			rig++;
    		}
    		if (rig == b.size())return true;
    		if (lef == a.size())return false;
    		if (s[lef] != s[rig])return s[lef] > s[rig];
    		lef++;
    		rig++;
    	}
    	return false;
    }
    vector<bool> dfs(int b){
    	if (b == n)return vector<bool>(2 * n, 0);
    	if (us[b])return dp[b];
    	us[b] = true;
    	dp[b] = dfs(b + 1);  //choose nothing
    	if(pos[b].first<pos[b].second){
			int til;
			vector<bool> flag(2*n,0);
			for(int j=b;j<pos.size();j++){
				if(pos[j].first>pos[b].second){
					break;
				}
				til=j;
				flag[pos[j].first]=flag[pos[j].second]=true;
			}
			for(int j=til+1;j<pos.size();j++){
				if(pos[j].first>pos[j-1].second)break;
				flag[pos[j].first]=flag[pos[j].second]=true;
				til=j;
			}
			auto nex=dfs(til+1);
			for(int i=0;i<2*n;i++){
				flag[i]=(flag[i]||nex[i]);
			}
			if(cmp(flag,dp[b])){
				dp[b]=flag;
			}
		}
		else{
			for(int j=b+1;j<pos.size();j++){
				if(min(pos[j].first,pos[j].second)>pos[b].first){
					auto nex=dfs(j);
					nex[pos[b].first]=nex[pos[b].second]=true;
					string ss;
					for(int i=0;i<nex.size();i++){
						if(nex[i])ss.push_back(s[i]);
					}
					if(cmp(nex,dp[b])){
						dp[b]=nex;
					}
					break;
				}
			}
			vector<bool> fl(2*n,false);
			fl[pos[b].first]=fl[pos[b].second]=true;
			if(cmp(fl,dp[b])){
				dp[b]=fl;
			}
		}
    	return dp[b];
    }
     
    int main(){
    	cin >> n;
    	scanf("%s", buf);
    	s = buf;
    	for (int i = 0; i < s.size(); i++){
    		if (s[i] == 'a'){
    			v1.push_back(i);
    		}
    		if (s[i] == 'b'){
    			v2.push_back(i);
    		}
    	}
    	for (int i = 0; i < v1.size(); i++){
    		pos.push_back(make_pair(v2[i], v1[i]));
    	}
    	vector<bool> uss = dfs(0);
    	//dfs2(0);
    	for (int i = 0; i < s.size(); i++){
    		if (uss[i]){
    			putchar(s[i]);
    		}
    	}
    	puts("");
    	return 0;
    }


Measured memory_bytes: 3712
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
N = int(input())
num = []
for _ in range(N):
  num.append(int(input()))
  
bingo = [
  [a11, a12, a13], 
  [a21, a22, a23], 
  [a31, a32, a33]
]
 
for n in range(3):
  for m in range(3): 
    if bingo[n][m] in num:
      bingo[n][m] = 0
 
row1 = bingo[0][0] + bingo[0][1] + bingo[0][2]
row2 = bingo[1][0] + bingo[1][1] + bingo[1][2]
row3 = bingo[2][0] + bingo[2][1] + bingo[2][2]
 
col1 = bingo[0][0] + bingo[1][0] + bingo[2][0]
col2 = bingo[0][1] + bingo[1][1] + bingo[2][1]
col3 = bingo[0][2] + bingo[1][2] + bingo[2][2]
 
cross1 = bingo[0][0] + bingo[1][1] + bingo[2][2]
cross2 = bingo[2][0] + bingo[1][1] + bingo[2][0]
 
if 0 in [row1, row2, row3, col1, col2, col3, cross1, cross2]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;

int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int w=0;
	for(int i=0;i<100000;i++){
		if((i*b+c)%a==0){w=1;break;}
	}
	if(w)printf("YES\n");
	else printf("NO\n");
	return 0;
}

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

int main() {
  string S;
  cin >> S;
	string ans;
  
  if(S == "Sunny") ans = "Cloudy";
  if(S == "Cloudy") ans = "Rainy";
  if(S == "Rainy") ans = "Sunny";
  
  cout << ans << endl;

}

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

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

  int64_t mod = 1000000000 + 7;
  int64_t power = 1;
  for (int i = 1; i <= n; i++) {
    power *= i;
    power %= mod;
  }

  cout << power << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
dd=[list(map(int,input().split()))for _ in range(N)]
i=0
now=0
S=0
while i<N:
    if len(set(dd[i]))==1:
        now+=1
    else:
        now=0
    S=max(now,S)
    i+=1
print('YNeos'[S<3::2])

Measured memory_bytes: 9192
#include<iostream>
#include<algorithm> 
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int N = 1e6+5;
const double pi = acos(-1.0);
const ll mod = 1e9+7;
int main()
{
 ll x,sum=100,ans=0;
   cin>>x;
while(sum<x){
	sum=sum+sum*0.01;
	ans++;
}
cout<<ans<<endl;
	return 0;
}


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

int main() {
  int n, d, cnt = 0;
  scanf("%d %d", &n, &d);
  for (int i = 0; i < n; i++) {
    int64_t x, y;
    cin >> x >> y;
    if(sqrt(x*x + y*y) <= d) cnt++;
  }
  cout << cnt;
}

Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long int lli;
#define REP(i, n) for(int (i)=0; (i)<(int)(n); (i)++)

int main(){
    int n;
    cin >> n;
    vector<pair<int, int> > ab(n);
    REP(i, n){
        int a,b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    sort(ab.begin(), ab.end());
    cout << ab.back().first + ab.back().second << endl;
    return 0;
}


Measured memory_bytes: 1024
public class Main {

	public void run(java.io.InputStream in, java.io.PrintStream out) {
		final java.util.Scanner sc = new java.util.Scanner(in);

		for (;;) {
			final int n = sc.nextInt();
			if (n == 0) break ;
			final int[] a = new int[n];
			for (int i = 0; i < n; ++i)
				a[i] = sc.nextInt();
			
			int res = Integer.MAX_VALUE;
			for (int i = 0; i < n; ++i)
			for (int j = i + 1; j < n; ++j) {
				res = Math.min(res, Math.abs(a[i]-a[j]));
			}
			out.println(res);
		}
	}
	
	public static void main(String[] args) {
		(new Main()).run(System.in, System.out);
	}

}

Measured memory_bytes: 49216
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

const int INF = 100000;

int main(){
  int N;
  cin >> N;
  int dp[100010];
  dp[0] = 0;
  for(int i = 1; i <= N; i++){
    dp[i] = INF;
    dp[i] = min(dp[i],dp[i-1] + 1);
    int power = 6;
    while(power <= i){
      dp[i] = min(dp[i],dp[i-power]+1);
      power *= 6;
    }
    power = 9;
    while(power <= i){
      dp[i] = min(dp[i],dp[i-power]+1);
      power *= 9;
    }
  }

  printf("%d\n",dp[N]);
  return 0;
}


Measured memory_bytes: 640
S, T = list(input()), list(input())
# print(S, T)


def create_new_T(_old_T):
  _newT = []
  for i in range(0, len(_old_T)):
    if i == 0:
      _newT.append(T[len(T) - 1])
    else:
      _newT.append(T[i - 1])
  return _newT

count = 0

for i in range(0, len(T)):
  T = create_new_T(T)
  if T == S:
    count += 1

if count == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if((a+b+c)<=21){
			System.out.println("win");
        }else{
			System.out.println("bust");
        }
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i = x; i < (int)(n); i++)
#define rep_ll(i,x,n) for(ll i = x; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
const long double PI = (acos(-1));
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
int main(){
    char a;
    cin >> a;

    if(isupper(a)) cout << "A";
    else cout << "a";

    return 0;
}

Measured memory_bytes: 3588
N, Y = map(int, input().split())
ans = []
for i in range(N + 1):
    # for j in range(N + 1):
    for j in range(N - i + 1):
        k = N - i - j
        if k < 0:
            break

        if 10000 * i + 5000 * j + 1000 * k == Y:
            ans = [i, j, k]

if ans == []:
    ans = [-1, -1, -1]

print(ans[0], ans[1], ans[2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    ll A[N][M];
    rep(i,N){
        rep(j,M){
            cin>>A[i][j];
            --A[i][j];
        }
    }
    vector<bool> kaisai(M,true);
    ll ans=INF;
    rep(k,M){
        vector<ll> ct(M,0);
        rep(i,N){
            ll saikousport;
            rep(j,M){
                if(!kaisai[A[i][j]]) continue;
                saikousport=A[i][j];
                break;
            }
            ++ct[saikousport];
        }
        ll maxnin=0,maxsport;
        rep(i,M){
            if(!kaisai[i]) continue;
            if(maxi(maxnin,ct[i])) maxsport=i;
        }
        kaisai[maxsport]=false;
        mini(ans,maxnin);
    }
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    set<long long int> st;
    for(int i=0; i<n; i++)
    {
        int p;
        long long int q;
        scanf("%d %lld", &p, &q);
        if(p==0)
        {
            st.insert(q);
            cout<<st.size()<<endl;
        }
        else if(p==1)
        {
            cout<<st.count(q)<<endl;
        }
    }
}



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

int main() {
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  for(int i = 0; i < tx - sx; i++){
    cout << "R";
  }
  for(int i = 0; i < ty - sy; i++){
    cout << "U";
  }
  for(int i = 0; i < tx - sx; i++){
    cout << "L";
  }
  for(int i = 0; i < ty - sy; i++){
    cout << "D";
  }
  
  cout << "D";
  for(int i = 0; i <= tx - sx; i++){
    cout << "R";
  }
  for(int i = 0; i <= ty - sy; i++){
    cout << "U";
  }
  cout << "LU";
  for(int i = 0; i <= tx - sx; i++){
    cout << "L";
  }
  for(int i = 0; i <= ty - sy; i++){
    cout << "D";
  }
  cout << "R" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int n;
int a[200009];
vector<int> G[200009];

int ans[200009];
int dp[200009];

void dfs(int v, int p) {
    auto it = lower_bound(dp, dp + n, a[v]);
    swap(*it, a[v]);
    ans[v] = lower_bound(dp, dp + n, 1 << 30) - dp;
    for(int u : G[v]) {
        if(u != p) dfs(u, v);
    }
    swap(*it, a[v]);
}

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

    cin >> n;
    fill(dp, dp + n, 1 << 30);
    rep(i, n) cin >> a[i];
    rep(i, n - 1) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(0, -1);

    rep(i, n) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 31196
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string s;
  while (getline(cin, s), s != ".") {
    stack<char> t;
    rep(i, s.size()) {
      if (s[i] == '[' || s[i] == '(') t.push(s[i]);
      if (s[i] == ')') {
        if (t.size() && t.top() == '(') {
          t.pop();
        } else {
          cout << "no" << endl;
          goto next;
        }
      }
      if (s[i] == ']') {
        if (t.size() && t.top() == '[') {
          t.pop();
        } else {
          cout << "no" << endl;
          goto next;
        }
      }
    }
    cout << (t.size() ? "no" : "yes") << endl;
  next:;
  }
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>

using namespace std;

typedef pair<int, int> P;

int main() {
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int gx, gy;
		cin >> gx >> gy;
		int p;
		cin >> p;
		vector< vector<long long int> > dp(gx+1, vector<long long int>(gy+1, 0));
		vector< vector< vector<P> > > d(gx+1, vector< vector<P> >(gy+1));
		int x1, y1, x2, y2;
		for (int j = 0; j < p; j++) {
			cin >> x1 >> y1 >> x2 >> y2;
			d[x1][y1].push_back(P(x2, y2));
			d[x2][y2].push_back(P(x1, y1));
		}
		dp[0][0] = 1;
		for (int j = 0; j <= gx; j++) {
			for (int k = 0; k <= gy; k++) {
				if (k < gy) {
					bool h = true;
					for (int m = 0; m < d[j][k].size(); m++) {
						if (d[j][k][m] == P(j, k+1)) {
							h = false;
							break;
						}
					}
					if (h) {
						dp[j][k+1] += dp[j][k];
					}
				}
				if (j < gx) {
					bool h = true;
					for (int m = 0; m < d[j][k].size(); m++) {
						if (d[j][k][m] == P(j+1, k)) {
							h = false;
							break;
						}
					}
					if (h) {
						dp[j+1][k] += dp[j][k];
					}
				}
			}
		}
		if (dp[gx][gy] != 0) {
			cout << dp[gx][gy] << endl;
		} else {
			cout << "Miserable Hokusai!" << endl;
		}
	}
	return 0;
}

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

int main(){
    ll ans=0;
    int N, K; cin>>N>>K;
    ll H[N];
    for(int i=0; i<N; i++) cin>>H[i];
    sort(H, H+N, greater<int>());

    for(int i=K; i<N; i++){
        ans+=H[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5152
import numpy as np
N, W = map(int, input().split())
wv = [map(int, input().split()) for i in range(N)]
dp = np.zeros((N+1, W+1), dtype = np.int)
for i, (w, v) in enumerate(wv):
    dp[i+1] = np.maximum(dp[i+1], dp[i])
    dp[i+1][w:] = np.maximum(dp[i+1][w:], dp[i][:-w] + v)
print(dp[N][W])

Measured memory_bytes: 105908
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    long long int n,a,b,x;
    cin>>n>>a>>b;
    if(a==b)
        cout<<"1"<<endl;
    else if(n==1||a>b)
     cout<<"0"<<endl;
     else
     {
         x=(((n-1)*b)+a)-(((n-1)*a)+b);
        cout<<x+1<<endl;
     }
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

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

    int ans = 0;
    int cur = 0;
    for(int i = 0; i < n; ++i) {
        if(s[i] == 'W') {
            ans += i-cur;
            cur++;
        }
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
         
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
#define ld long double
#define vll vector<ll>
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define F first
#define S second
#define pll pair<ll,ll> 
#define G(a,b) get<a>(b)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define MT make_tuple
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)    
#define endl "\n"
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define sz(x) (ll)x.size() 
#define ara cout<<"ara-ara\n"; 
const ld pi=3.141592653589793238;


void func()
{
  ll x;
  cin>>x;
  if(x>=30) cout<<"Yes\n";
  else cout<<"No\n";
}   
     
     
     
int main() 
{
    fast
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif // ONLINE_JUDGE
     
    ll ntc=1;
    //cin>>ntc;
     
    f(i,1,ntc+1)
    {
       //cout<<"Case #"<<i<<": ";
       //cout<<"\n";
       func();
    }
     
    return 0;
}


Measured memory_bytes: 3648
n = int(input())
abl = []
for _ in range(n):
   a,b = map(int,input().split())
   abl.append((a,b))

abl = reversed(abl)

ans = 0
for a,b in abl:
    a += ans
    if a % b != 0:
        ans += b - (a % b)

print(ans)

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 51;
bitset <51> state[21], cur;
vector <pii> a[N];
pii p[N];
long P[N], n, m;

void dfs(int u){
  for (pii x : a[u]){
    int v = x.first;
    if (p[v] == pii(0, 0)){
      p[v] = pii(u, x.second);
      dfs(v);
    }
  }
}

int main()
{
  fastio;
  cin >> n;
  for (int i = 1; i < n; i++){
    int u, v; cin >> u >> v; 
    a[u].push_back(pii(v, i - 1)); a[v].push_back(pii(u, i - 1));
  }
  //for (int i = 0; i < n - 1; i++) cur.set(i);
  cin >> m;
  for (int i = 0; i < m; i++){
    int u, v; cin >> u >> v;
    for (int j = 1; j <= n; j++) p[j] = pii(0, 0);
    p[u] = pii(u, 0); dfs(u);  
    int cnt = 0;
    while (v != u){
      state[i].set(p[v].second);
      v = p[v].first; cnt++;
    }
  }
  P[0] = 1;
  for (int i = 1; i <= n; i++) P[i] = P[i - 1] * 2;
  long res = 0;
  for (int mask = 0; mask < (1 << m); mask++){
    bitset <51> memo = cur; int d = 0;
    for (int i = 0; i < m; i++){
      if ((mask >> i) & 1){
        d++; memo |= state[i]; 
      }  
    }
    if (d % 2) res -= P[n - 1 - memo.count()];
    else res += P[n - 1 - memo.count()];
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 256
q = int(input())
for i in range(q):
    x = input()
    y = input()
    co = []

    for j, s in enumerate(x):
        co.append([])
        co[j].append(-1)
        if j == 0:
            end = y.find(s)
            if end != -1:
                co[j].append(end)
        else:
            for k, t in enumerate(co[j-1][:-1]):
                end = y.find(s, t+1)
                if end != -1:
                    co[j].append(min(end, co[j-1][k+1]))
                else:
                    co[j].append(co[j-1][k+1])
            end = y.find(s, co[j-1][-1]+1)

            if end != -1:
                co[j].append(end)

    print(len(co[-1])-1)


Measured memory_bytes: 20568