akhauriyash/Code-Regression huggingface dataset:
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;


int main(){
    int n,x;
    cin>>n>>x;
    vector<int>a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    SORT(a);
    int count=0;
    int total=0;
    for(int i=0;i<n;i++){
        total+=a[i];
        if(total<=x) count++;
        else break;
    }
    if(total>=x) cout<<count<<endl;
    else cout<<count-1<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    int n, m, start;
    ArrayList<ArrayList<Edge>> es;
    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        start = sc.nextInt();
        es = new ArrayList<ArrayList<Edge>>(n);
        for (int i = 0; i < n; i++)
            es.add(new ArrayList<Edge>());
        for (int i = 0; i < m; i++) {
            int f = sc.nextInt();
            int t = sc.nextInt();
            int c = sc.nextInt();
            es.get(f).add(new Edge(f, t, c));
        }
    }

    private void solve() {
        PriorityQueue<Node> queue =
                new PriorityQueue<>(new Comparator<Node>() {
                    @Override
                    public int compare(Node node, Node t1) {
                        return Integer.compare(node.getTotalCost(), t1.getTotalCost());
                    }
                });
        int[] log = new int[n];
            queue.add(new Node(start, 0));
            Arrays.fill(log, Integer.MAX_VALUE);
            while (!queue.isEmpty()) {
                Node n = queue.poll();
                if (n.totalCost >= log[n.current])
                    continue;
                log[n.current] = n.totalCost;
                int tmp;
                    for (Edge e : es.get(n.current)) {
                        tmp = n.totalCost + e.cost;
                        if (tmp < log[e.to])
                            queue.add(new Node(e.to, tmp));
                    }
            }
        for (int ans: log) {
                if (ans == Integer.MAX_VALUE)
                    System.out.println("INF");
                else
                     System.out.println(ans);
        }
    }

     private class Edge {
        int from, to;
        int cost;
        Edge(int f, int t, int c) {
            from = f; to = t; cost = c;
        }
    }

    private class Node {
        int current;
        int totalCost;
        Node (int c, int t) {
            current = c;
            totalCost = t;
        }

        int getTotalCost() {
            return totalCost;
        }
    }
}

Measured memory_bytes: 330160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;
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 const INF = 1 << 30;


int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> u(n+1),v(n+1);
    rep(i,n) u[i+1] = u[i] + (s[i] != 'R');
    drep(i,n) v[i] = v[i+1] + (s[i] != 'W');

    int res = INF;
    rep(i,n+1) chmin(res,max(u[i],v[i]));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5060
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

def f(x)
  cnt = 0

  A.each do |a|
    next if a <= x

    cnt += (a / x.to_f).ceil - 1
  end

  cnt <= K
end

ok = 10 ** 10
ng = 0

while (ok - ng).abs > 1
  x = (ok + ng) / 2

  if f(x)
    ok = x
  else
    ng = x
  end
end

puts ok


Measured memory_bytes: 27712
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.length()-1;i++){
    if(s[i]=='A' && s[i+1]=='C'){
      cout << "Yes" <<endl;
      return 0;
    }
  }
  cout << "No" <<endl;
  return 0;
}


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

int main()
{
	int n;
	int a[100];
		
	while (1) {
		cin >> n;
		if (n == 0) {
			break;
		}
		int max = 0;
		int min = 1000;
		int total = 0;
		int answer = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			total += a[i];
			if (a[i] > max) {
				max = a[i];
			}
			if (a[i] < min) {
				min = a[i];
			}
		}
		answer = (total - max - min) / (n - 2);
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
s = input()
s1= s[:1]
s2 = s[1:2]
s3 = s[2:3]
s4 = s[3:4]
if s1 == s2:
	if s3 == s4:
		if s1 != s3:
			print("Yes")
			sys.exit(0)
if s1 == s3:
	if s2 == s4:
		if s1 != s2:
			print("Yes")
			sys.exit(0)
if s1 == s4:
	if s2 == s3:
		if s1 != s3:
			print("Yes")
			sys.exit(0)
print("No")

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

using namespace std;
int main() {
  int x, y, z;
  cin >> x >> y >> z;
  int result = 1;
  for (; result < 100000; result++) {
    long temp = result * y + (result - 1) * z + 2 * z;
    if (temp > x) {
      break;
    }
  }
  cout << (result - 1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long aa;bool bb;char ch;
long long scan()
{
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	ch=='-'?(bb=1,aa=0):(bb=0,aa=ch-48);
	while(ch=getchar(),(ch>='0'&&ch<='9'))
		aa=aa*10+ch-48;
	return (bb?(-aa):(aa));
}
long long ans=10000000000;
long long Abs(long long u){return u>0?u:(-u);}
long long Max(long long u,long long v){return u>v?u:v;}
long long Min(long long u,long long v){return u<v?u:v;}
long long Max3(long long a,long long b,long long c)
{
	return Max(a,Max(b,c));
}
long long Min3(long long a,long long b,long long c)
{
	return Min(a,Min(b,c));
}
void work1(long long h,long long w,long long a)
{
	//cout<<h<<" "<<w<<" "<<a<<endl;
	long long b,c;
	if(h*w%2==0)
	{
		//cout<<h*w/2<<" "<<a<<endl;
		if(ans>Abs(h*w/2-a))
			ans=Abs(h*w/2-a);
		return;
	}
	b=h/2*w;
	c=h*w-b;
	//cout<<a<<" "<<b<<" "<<c<<endl;
	//cout<<Max3(a,b,c)<<" "<<Min3(a,b,c)<<endl;
	//cout<<ans<<endl;
	if(b>0&&c>0)
	{
		if(ans>Max3(a,b,c)-Min3(a,b,c))
			ans=Max3(a,b,c)-Min3(a,b,c);
	//cout<<Max3(a,b,c)<<" "<<Min3(a,b,c)<<endl;
	//cout<<ans<<endl;
	}
	b=w/2*h;
	c=h*w-b;
	//cout<<a<<" "<<b<<" "<<c<<endl;
	//cout<<Max3(a,b,c)<<" "<<Min3(a,b,c)<<endl;
	//cout<<ans<<endl;
	if(b>0&&c>0)
	{
		if(ans>Max3(a,b,c)-Min3(a,b,c))
			ans=Max3(a,b,c)-Min3(a,b,c);
		
	//cout<<Max3(a,b,c)<<" "<<Min3(a,b,c)<<endl;
	//cout<<ans<<endl;
	}
}
int main()
{
	long long h,w;
	scanf("%lld%lld",&h,&w);
	if(h%3==0||w%3==0)
	{
		puts("0");
		return 0;
	}
	
	if(h/3>0&&h/3<h)
		work1(h-h/3,w,h/3*w);
	//cout<<"h/3*w"<<h/3*w<<endl;
	if(h/3+1>0&&h/3+1<h)
		work1(h-(h/3+1),w,(h/3+1)*w);
	//cout<<"(h/3+1)*w"<<(h/3+1)*w<<endl;
		
	if(w/3>0&&w/3<w)
		work1(h,w-w/3,w/3*h);
	//cout<<"w/3*h"<<w/3*h<<endl;
		
	if(w/3+1>0&&w/3+1<w)
		work1(h,w-(w/3+1),h*(w/3+1));
	//cout<<"h*(w/3+1)"<<h*(w/3+1)<<endl;
	cout<<ans<<endl;
}

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

int main()
{
    string s;
    cin >> s;
    int former = stoi(s.substr(0, 2));
    int later = stoi(s.substr(2));
    if (former >= 1 && former <= 12)
    {
        if (later >= 1 && later <= 12)
        {
            cout << "AMBIGUOUS" << endl;
        }
        else
        {
            cout << "MMYY" << endl;
        }
    }
    else
    {
        if (later >= 1 && later <= 12)
        {
            cout << "YYMM" << endl;
            return 0;
        }
        else
        {
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

ll ans=0,dp[51][51][2501];

int main() {
  int N,A; cin >> N >> A;
  int x[N], total =0; 
  for (int i =1; i<N+1; i++) {
    cin >> x[i]; total += x[i];
  }
 
  for (int i =0; i<=N; i++) {
    for (int j =0; j<=N; j++) {
      for (int k =0; k<=total; k++) {
        if (i == 0 && j == 0 && k == 0) dp[i][j][k] = 1;
        else if (i >= 1 && k < x[i]) dp[i][j][k] = dp[i-1][j][k];
        else if (i >= 1 && j >= 1 && k >= x[i]) dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k - x[i]];
        else dp[i][j][k] = 0;
      }       
    }
  } 
  
  for (int i =1; i<N+1; i++) ans += dp[N][i][i * A];
  cout << ans << endl; 
}

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

#define PI 3.14159265359
#define EPS 1e-16
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = (a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (a); i <= (long long)(n); i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

ll p[100][100];

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

    v_ll v(n);

    irep(i, n) { cin >> v[i]; }
    sort(v.rbegin(), v.rend());

    double ans = 0;  

    irep(i, a) { ans += v[i]; }
    ans /= a;

    printf("%.6f\n", ans);
    
    irep(i, 51) { 
        p[i][0] = 1; 
        p[i][i] = 1;
    }
    
    irep2(i, 0, 50) {
        irep2(k, 0, i+1) {
            p[i+1][k] = p[i][k];
            if(k>0) { p[i+1][k] += p[i][k-1]; }
        }
    }

    ll max_v = v[0];
    int max_cnt = 1;

    irep2(i, 1, n-1) {
        if(max_v == v[i]) { max_cnt++; }
    }
    
    ll comb = 0;
    if(max_cnt >= a) {
        irep2(i, a, min(b, max_cnt)) {
            comb += p[max_cnt][i];
        }
        cout << comb << endl;
        return 0;
    }

    max_v = v[0];
    max_cnt = 1;

    irep2(i, 1, a-1) {
        if(max_v != v[i]) {
            max_v = v[i];
            max_cnt = 1;
        } else {
            max_cnt++;
        }
    }
    
    int k = max_cnt;

    irep2(i, a, n-1) {
        if(max_v == v[i]) {
            max_cnt++;
        }
    }
    cout << p[max_cnt][k] << endl;

    return 0;
}



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

using namespace std;

int main(){
	
	int yy, mm, dd;
	
	string str;
	
	while(true){
		cin >> yy;
		
		if(cin.eof()){
			break;
		}
		
		cin >> mm >> dd;
		
		if(yy < 1868){
			printf("pre-meiji\n");
		}else if(yy > 1989){
			printf("heisei %d %d %d\n", yy - 1988, mm, dd);
		}else{
			str = "pre-meiji";
			for(int y = 1868; y < 1990; y++){
				for(int m = 1; m <= 12; m++){
					for(int d = 1; d <= 31; d++){
						if(y == 1868 && m == 9 && d == 8){
							str = "meiji";
						}else if(y == 1912 && m == 7 && d == 30){
							str = "taisho";
						}else if(y == 1926 && m == 12 && d == 25){
							str = "showa";
						}else if(y == 1989 && m == 1 && d == 8){
							str = "heisei";
						}
						if(y == yy && m == mm && d == dd){
							if(str == "pre-meiji"){
								printf("pre-meiji\n");
							}else if(str == "meiji"){
								printf("meiji %d %d %d\n", yy - 1867, mm, dd);
							}else if(str == "taisho"){
								printf("taisho %d %d %d\n", yy - 1911, mm, dd);
							}else if(str == "showa"){
								printf("showa %d %d %d\n", yy - 1925, mm, dd);
							}else if(str == "heisei"){
								printf("heisei %d %d %d\n", yy - 1988, mm, dd);
							}
						}
					}
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1216
//C - Incremental Scoring
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;


int N = 26;
int D;

vector<int> c(N+1);
vector<vector<int>> s;
vector<int> t;




ll scoring(){
    vector<int> last(N+1, 0);
    ll score = 0;
    for(int d = 1; d <= D; d++){

        score += s[d][t[d]];
        last[t[d]] = d;

        int penalty = 0;
        for(int i = 1; i <= N; i++){
            penalty += c[i]*(d-last[i]);    
        }
        
        score -= penalty;            
    }
    return score;
}


ll exchange(int d, int q){
    t[d] = q;
    return scoring();

}



int main(){

    cin>> D;

    s.resize(D+1);
    for(int i=0; i<=D; i++){
        s[i].resize(N+1);
    }
    t.resize(D+1);

    for(int i=1; i<=N; i++){
        cin>>c[i];
    }
 
    for(int i=1; i<=D; i++){
        for(int j=1; j<=N; j++){
            cin>>s[i][j];
        }
    }
    for(int i=1; i<=D; i++){
        cin>>t[i];
    }
    
    //cout<<scoring()<<endl;


    //解交換
    int M;
    cin>>M;

    vector<int> ex_d(M);
    vector<int> q(M);
    for(int i=0; i<M; i++){
        cin>>ex_d[i]>>q[i];   
    }
    for(int i=0; i<M; i++){
        /*
        for(int i=1; i<D+1; i++){
            cout<<t[i]<<" ";
        }
        cout<<endl;
        */
        cout<<exchange(ex_d[i], q[i])<<endl;
    }

    return 0;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
static const int MAX_N = 1e5;
int n;
vector<pair<int, int>> g[MAX_N];
int color[MAX_N];

void dfs(int v, int c)
{
	if (color[v] < 0)
	{
		color[v] = c;
		for (auto &p : g[v])
		{
			if (p.second == 0)
			{
				dfs(p.first, c);
			}
			else
			{
				dfs(p.first, 1 - c);
			}
		}
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n - 1; ++i)
	{
		int u, v, w;
		cin >> u >> v >> w;
		--u;
		--v;
		w %= 2;
		g[u].emplace_back(v, w);
		g[v].emplace_back(u, w);
	}

	for (int i = 0; i < n; ++i)
		color[i] = -1;

	dfs(0, 0);
	for (int i = 0; i < n; ++i)
	{
		cout << color[i] << endl;
	}
}

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

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

  vector<int> p(n);
  //vectorに全入力値を代入する
  rep(i,n) cin >> p[i];

  //整数で扱うため、配列内の期待値の２倍した値を算出する(期待値は「(配列の値)+1/2」)
  rep(i,n) p[i]++;

  int mx = 0;
  int s = 0;
  queue<int> q;
  
  //１つ追加したら、一番左を１つ減らしてシフトさせる
  rep(i,n) {
    s += p[i];
    q.push(p[i]);
    if (q.size() > k) {
      s -= q.front(); q.pop();
    }
    if (q.size() == k) {
      mx = max(mx,s);//MAX値が常に更新されていく
    }
  }
  double ans = mx;
  ans /= 2;
  printf("%.10f\n", ans);
}

Measured memory_bytes: 1792
using System;
using System.Linq;
 
class P{
  static void Main(){
    string S = Console.ReadLine();
    long K = long.Parse(Console.ReadLine());
    
    for(int i = 0; i < K; i++){
      if(S[i] != '1'){
        Console.WriteLine(S[i]);
        return;
      }
    }
    Console.WriteLine(1);
  }
}

Measured memory_bytes: 13140
/**
*	created: 23.08.2020 22:59:20
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int dis[1100][1100];
vector<string> s;
int h, w, sx, sy, gx, gy;
deque<P> dq;

void bfs() {
    dis[sx][sy] = 0;
    dq.emplace_back(sx,sy);
    while(!dq.empty()) {
        int i = dq.front().first;
        int j = dq.front().second;
        dq.pop_front();
        int d = dis[i][j];
        rep(v,4) {
            int ni = i + dx[v], nj = j + dy[v];
            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (s[ni][nj] == '#') continue;
            if (dis[ni][nj] <= d) continue;
            dis[ni][nj] = d;
            dq.emplace_front(ni,nj);
        }
        rep2(di,-2,3) rep2(dj,-2,3) {
            int ni = i + di, nj = j + dj;
            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (s[ni][nj] == '#') continue;
            if (dis[ni][nj] <= d+1) continue;
            dis[ni][nj] = d+1;
            dq.emplace_back(ni,nj);
        }
    }
}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    cin >> h >> w;
    cin >> sx >> sy;
    cin >> gx >> gy;
    sx--; sy--; gx--; gy--;
    rep(i,h) {
        string t; cin >> t;
        s.push_back(t);
    }
    rep(i,1100) rep(j,1100) dis[i][j] = INF;
    bfs();
    int ans = dis[gx][gy];
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string S;
int sum[100050];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    cin >> S;
    S = "#" + S;
    for(int i = 1; i < S.size() - 1; i++) {
        sum[i] = sum[i-1];
        if(S[i] == 'A' && S[i+1] == 'C') sum[i]++;
    }
    sum[S.size()] = sum[S.size() - 1];
    while(Q--) {
        int l, r;
        cin >> l >> r;
        cout << sum[r-1] - sum[l-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1388
<?php
  $w = trim(fgets(STDIN));
  for($i=0;$i<strlen($w);$i++){
      $wc[$w[$i]]++;
  }

  foreach ($wc as $d){
      if($d%2 == 1){
          echo "No";
          exit;
      }
  }
  echo "Yes";

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

int main(){
    int n;
    cin >> n;
    int N = n%10;
    string ans;
    if(N == 2 || N == 4 || N == 5|| N == 7|| N == 9) ans = "hon";
    else if(N == 0 || N == 1 || N == 6|| N == 8) ans = "pon";
    else ans = "bon";
    cout << ans << endl;
}

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

using namespace std;

typedef long long  ll;
typedef vector<ll> VL;
typedef pair<ll,ll> PLL;
#define pb push_back
#define F first
#define S second
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=998244353;


void solve()
{
	ll n,m,sum=0;
	cin>>n>>m;
	VL arr(n);
	fr(i,0,n)
	{
		cin>>arr[i];
		sum+=arr[i];
	}
	ll ck=sum/(4*m);
	if(sum%(4*m)!=0)
	{
		ck++;
	}
	ll ct=0;
	fr(i,0,n)
	{
		if(arr[i]>=ck)
		{
			ct++;
		}
	}
	if(ct>=m)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	solve();
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
//#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
int main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        if(b%a==0)
        cout<<a+b;
        else
        cout<<b-a;
    }
    
}
// 🍪 🍪 🍪


Measured memory_bytes: 3640
/*
minh(v) 表示达到价值 v 的最低高度，则显然 h 单调递增
minh(0) = 0
遍历完第一个元素 a[i], h[i] 后，minh[1] = (h[i], a[i])
依次遍历下一个元素 k，在 minh 中找到小于 h[k] 的最近 minh[j].h，新组成 (h[k], minh[j].a + a[k])
已知 h[k] <= minh[j+1].h，
如果 minh[j].a + a[k] > minh[j+1].a，则删掉 j+1

需要线段树？红黑树就可以搞定，可以尝试 c++
*/

#include <iostream>
#include <set>

using namespace std;
typedef long long int64;

const int N = 2e5 + 5;
int64 a[N];
int h[N];

struct Node {
  int h;
  int64 v;
  bool operator < (const Node& other) const {
    return h < other.h;
  }
  friend ostream& operator<< (ostream &out, const Node& node) { 
    out << "{ " << node.h << ", " << node.v << " }";
    return out;
  }
};

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

  set<Node> s;
  s.insert(Node{0, 0});
  for (int i = 0; i < n; i++) {
    auto it = s.lower_bound(Node{h[i], 0});
    auto newV = (--it)->v + a[i];
    it++;
    
    auto end = it;
    for (; end != s.end() && end->v <= newV; end++) ;
    s.erase(it, end);
    s.insert(Node{h[i], newV});
  }

  cout << s.rbegin()->v << endl;
  return 0;
}

Measured memory_bytes: 18324
#include <stdio.h>

int main(void){
    int goal,start,end,num,sum;
    while(1){
        sum=0;
        scanf("%d",&goal);
        if(goal == 0)
            break;
        scanf("%d",&num);
        while(num){
            scanf("%d %d",&start,&end);
            sum+=end-start;
            num--;
        }
        if(goal <= sum)
            printf("OK\n");
        else
            printf("%d\n",goal-sum);
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k, s;
  cin >> k >> s;
  
  int count = 0;
  for (int x = 0; x < k+1; x++) {
    for (int y = 0; y < k+1; y++) {
      int z = s - x - y;
      if(0 <= z && z <= k){
          count++;
      }
    }
  }
  
  cout << count << endl;
 

}
             
 

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"

using namespace std;

int main() {
    string t = "aeiou";
    char s;
    cin >> s;
    for (char c : t) {
        if (c == s) {
            cout << "vowel";
            return 0;
        }
    }
    cout << "consonant";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 998244353
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N, S;
	cin >> N >> S;
	vl A(N);
	rep(i, N) {
		cin >> A[i];
	}
	vector<vl> DP(N + 1);
	rep(i, N + 1) {
		DP[i].resize(S + 1, 0);
	}
	DP[0][0] = 1;
	rep(i, N) {
		rep(s, S + 1) {
			ll snew = s;
			DP[i + 1][snew] += DP[i][s] * 2;
			DP[i + 1][snew] %= mod;
			snew = s + A[i];
			if (snew > S)
				continue;
			DP[i + 1][snew] += DP[i][s];
			DP[i + 1][snew] %= mod;
		}
	}
	cout << DP[N][S] << endl;
	return 0;
}

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


int main(){
    int N;
    cin >> N;
    string s(N,' ');
    for(int i=0;i<N;i++){
        cin >> s.at(i);
        // cout << s.at(i)<<endl;
    }
    // string check = s.at(0);
    int count = 1;
    for(int i=1;i<N;i++){
        if(s.at(i-1)!=s.at(i)){
            count++;
        }
    }
    cout << count << endl;
}



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

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

    bool f = false;
    ll ans = 0;
    ll tmp = 1;
    while (tmp <= H) {
        ans += tmp;
        tmp *= 2LL;

        //cout << tmp << endl;
    }

    cout << ans << endl;
}


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

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

	int A = 999;

	int N = S.size();

	for (int i = 0; i <= N - 3; i++) {
		string Q = S.substr(i, 3);

		int num = atoi(Q.c_str());

		A = min(A, abs(num - 753));
	}

	cout << A << endl;
}

Measured memory_bytes: 3624
#include<cstdio>
int main()
{
	int n,d,x,ans=0;scanf("%d%d%d",&n,&d,&x);
	for(int i=1;i<=n;i++)
	{
		int a;scanf("%d",&a);
		ans+=(d-1)/a+1;
	}
	printf("%d\n",ans+x);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
m = int(input())
x = [list(map(int,input().split())) for i in range(n)]

s = m
M = m

for i in range(n):
    s += x[i][0] - x[i][1]
    if s < 0:
        M = 0
        break
    M = max(M,s)
print(M)



Measured memory_bytes: 6724
#include <iostream>
 
using namespace std;
 
int main(){
    long long int a[4],max=-1000000000000000000;
    cin>>a[0]>>a[1]>>a[2]>>a[3];
    for(int i=0;i<2;i++){
        for(int j=2;j<4;j++){
            if(a[i]*a[j]>max)max=a[i]*a[j];
        }
    }
    printf("%lld\n",max);
}

Measured memory_bytes: 3760
#include <iostream>
#include <utility>
#include <queue>
#include <vector>

using namespace std;

int main() {
	int N;
	cin >> N;
	
	vector< vector< pair<int,long long> > > adjList(N+1);
	int a,b;
	long long weight;
	for (int i = 0; i < N-1; ++i) {
		cin >> a >> b >> weight;
		adjList[a].push_back(make_pair(b,weight));
		adjList[b].push_back(make_pair(a,weight));
	} 
	
	int Q,K;
	cin >> Q >> K;
	
	vector<long long> dist(N+1,-1);
	priority_queue< pair<int,long long>, vector< pair<int, long long> >, greater< pair<int, long long> > > pq;
	dist[K] = 0;
	pq.push(make_pair(K,0));
	while (!pq.empty()) {
		pair<int, long long> cur = pq.top();
		pq.pop();
		int x = cur.first;
		long long d = cur.second;
		
		if (d > dist[x]) continue;
		for (vector< pair<int,long long> >::iterator it = adjList[x].begin(); it != adjList[x].end(); ++it) {
			int nx = it->first;
			long long nd = d + it->second;
			if (dist[nx] != -1 && dist[nx] <= nd) continue;
			dist[nx] = nd;
			pq.push(make_pair(nx,nd));
		}
	}
	
	int from,to;
	vector<long long> ans;
	for (int i = 0; i < Q; ++i) {
		cin >> from >> to;
		ans.push_back(dist[from] + dist[to]);
	}
	
	for (int i = 0; i < Q; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 12528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int H,W;cin >> H >> W;
  rep(i,H){
    string s;
    cin >> s;
    cout << s << endl << s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
//#define int long long
using namespace __gnu_pbds;
using namespace std;

signed main()
{
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	cout<<((s[0]==s[1]&&s[1]==s[2])?"No":"Yes")<<endl;	
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
ts, xs, ys = [0], [0], [0]
(1..N).each do |i|
    ts[i], xs[i], ys[i] = gets.split.map(&:to_i)
end

N.times do |i|
    dist = (xs[i+1] - xs[i]).abs + (ys[i+1] - ys[i]).abs
    dt = ts[i+1] - ts[i]
    unless dist <= dt && (dist - dt) % 2 == 0
        puts 'No'
        exit
    end
end
puts 'Yes'

Measured memory_bytes: 4272
S=gets.chomp

def palindrome?(s)
  l = 0
  r = s.length-1
  while l < r
    if s[l] != s[r]
      return false
    end
    l += 1
    r -= 1
  end
  true
end

len = S.length
if palindrome?(S) && palindrome?(S[0..(len-1)/2-1]) && palindrome?(S[(len+3)/2-1..-1])
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
import java.util.Scanner;

class P{
	int x;
	int y;

	P(int _x, int _y){
		this.x = _x;
		this.y = _y;
	}
}

public class Main {

	static int[][] checked;
	static int n;

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

		while(true){
			n = stdIn.nextInt();
			if(n==0){
				return;
			}
			P[][] pos = new P[n][n];
			checked = new int[n][n];
			int loopCnt = 0;
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					int x = stdIn.nextInt();
					int y = stdIn.nextInt();
					pos[i][j] = new P(x,y);
				}
			}

//			for(int i=0;i<n;i++){
//				for(int j=0;j<n;j++){
//					System.out.print(pos[i][j].x+" "+pos[i][j].y);
//				}
//				System.out.println();
//			}

			// Process
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					TwotoOne();
//					System.err.println("テゥツ??"+i+" "+j);
					if(checked[i][j]==0){
						// テ・ツコツァテヲツィツ?i,j)テ」ツ?凝」ツつ嘉」ツδォテ」ツδシテ」ツδ療」ツ?ォテ」ツ?ェテ」ツつ凝ヲツ篠「テァツエツ「テ」ツつケテ」ツつソテ」ツδシテ」ツδ?
//						System.err.println("テ」ツδォテ」ツδシテ」ツδ療ヲツ篠「テァツエツ「テ」ツつケテ」ツつソテ」ツδシテ」ツδ?"+i+" "+j);
						int x = j;
						int y = i;
						boolean inc = true; // テ」ツつ、テ」ツδウテ」ツつッテ」ツδェテ」ツδ。テ」ツδウテ」ツδ暗」ツ?療」ツ?ヲテ」ツつ暗」ツ??」ツ??
						while(true){
							if(checked[y][x]==0){
								// テ」ツ?セテ」ツ??・ツ按ーテゥツ?氾」ツ?療」ツ?ヲテ」ツ?ェテ」ツ??」ツ?ョテ」ツ?ァテァツカツ堙」ツ?妥」ツつ?
								// ティツカツウティツキツ。テ」ツ?、テ」ツ?妥」ツつ?
								checked[y][x] = 2;
								// テヲツャツ。テ」ツ?ョテ・ツコツァテヲツィツ凖」ツつ津ヲツ崢エテヲツ鳴ーテ」ツ?凖」ツつ?
//								System.err.print(x+" "+y+"=>");
								int zx = x;
								int zy = y;
								x = pos[zy][zx].x;
								y = pos[zy][zx].y;
//								System.err.println(""+x+" "+y);

							}
							else if(checked[y][x]==1){
								// テゥツ?偲・ツ篠サテ」ツ?ョテ」ツδォテ」ツδシテ」ツδ療」ツ?ォテァツェツ?・ツ?・テ」ツ?療」ツ??
//								System.err.println("テゥツ?偲・ツ篠サテ」ツ?ョテ」ツδォテ」ツδシテ」ツδ療ァツェツ?・ツ?・テ」ツ?ァテ」ツ?療」ツ??/ テ」ツ?、テ」ツ?・テ」ツ?妥」ツ?セテ」ツ??);
								checked[y][x] = 2;
								inc = false;	// テゥツ?偲・ツ篠サテ」ツδォテ」ツδシテ」ツδ療」ツδ陛」ツδゥテ」ツつー
//								break;
							}
							else if(checked[y][x]==2){
								// テヲツ篠「テァツエツ「テ・ツ慊ーテァツつケテ」ツ?セテ」ツ?ァテヲツ按サテ」ツつ?
//								System.err.println("テァツオツづ、ツコツ?);
								if(inc) {
									// テヲツ篠津、ツサツ姪」ツδォテ」ツδシテ」ツδ療」ツ?ョテァツ卍コティツヲツ?
//									System.err.println("テヲツ篠津、ツサツ姪」ツδォテ」ツδシテ」ツδ療」ツ?ョテァツ卍コティツヲツ?);
									loopCnt++;
								}
								break;  // while(true)テ」ツ?ョbreak
							}
						}
					}
				}
			}
			System.out.println(loopCnt);
		}
	}

	private static void TwotoOne() {
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(checked[i][j]==2){
					checked[i][j] = 1;
				}
			}
		}

	}
}

Measured memory_bytes: 62188
#include <stdio.h>

int main(){
    int a,b,c,d;
    scanf("%d¥n",&a);
    scanf("%d¥n",&b);
    scanf("%d¥n",&c);
    scanf("%d¥n",&d);
    if(a>b){if(c>d){printf("%d",b+d);
}else{printf("%d",b+c);
}}else{if(c>d){printf("%d",a+d);
}else{printf("%d",a+c);
}}return 0;
}

Measured memory_bytes: 128
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         String input = infile.readLine();
         if(input.length() <= N)
            System.out.println(input);
         else
            System.out.println(input.substring(0, N)+"...");
      }
   }

Measured memory_bytes: 36344
import sys

n, q = list(map(int, input().split()))
MOD = 10 ** 9 + 7
INV2 = (MOD + 1) // 2
lines = sys.stdin.readlines()
aaa = list(map(int, lines[:n]))
mat = [[0] * n for _ in [0] * n]
for i in range(n):
    for j in range(n):
        mat[i][j] = int(aaa[i] < aaa[j])
# print(*mat, sep='\n')
for line in lines[n:]:
    x, y = map(int, line.split())
    x -= 1
    y -= 1
    mat[x][y] = mat[y][x] = (mat[x][y] + mat[y][x]) * INV2 % MOD
    for i in range(n):
        if i == x or i == y:
            continue
        mat[x][i] = mat[y][i] = (mat[x][i] + mat[y][i]) * INV2 % MOD
        mat[i][x] = mat[i][y] = (mat[i][x] + mat[i][y]) * INV2 % MOD
    # print(x, y)
    # print(*mat, sep='\n')

ans = sum(sum(row[:i]) for i, row in enumerate(mat)) % MOD
ans = (ans << q) % MOD
print(ans)


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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; }

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll dp(n+1,n);
  rep(i,n){
    dp[i]=i;
  }
  dp[0]=0;
  rep(i,n){
    for(ll pow=6;pow+i<=n;pow*=6){
      chmin(dp[pow+i],dp[i]+1);
    }
    for(ll pow=9;pow+i<=n;pow*=9){
      chmin(dp[pow+i],dp[i]+1);
    }
  }
  cout<<dp[n]<<endl;
}

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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    string s;
    cin>>s;
    if(s=="BBB" || s=="AAA")
    {
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;


















    return 0;

}













Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define pool(i,m,n) for(lli i=m; i>n; i++)
#define maxe *max_element
#define mine *min_element
#define plli pair<lli, lli>
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define mpp make_pair
#define inp1(a) cin >> a
#define inp2(a, b) cin >> a >> b
#define inp3(a, b, c) cin >> a >> b >> c
#define inp4(a, b, c, d) cin >> a >> b >> c >> d
#define inp5(a, b, c, d, e) cin >> a >> b >> c >> d >> e
#define inp6(a, b, c, d, e, f) cin >> a >> b >> c >> d >> e >> f
#define pr0() cout << " "
#define pr1(a) cout << a << " "
#define pr2(a, b) cout << a << " " << b << " "
#define pr3(a, b, c) cout << a << " " << b << " " << c << " "
#define pr4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << " "
#define emp emplace //used to push a pair etc..
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x, 0;
#define all(v) v.begin(),v.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
//especially for deque both sides dynamic
#define pf push_front
//list doubly linked lists can insert at mid. splice fn can be used
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if(a==0) return b;
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli modi(lli n,lli m=mod){ 
    if(n==0) return 0;
    n%=m;
    n+=m;
    n%=m;
    return n;
}
 
lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}
const lli INF=1e18;
const lli N=2e5+5;
const ldb pi=4*atan(1);

lli n,m,k,t;
//lli a,b,c,d;
lli p,q,l,r;
lli arr[N];
//lli a[N],b[N],c[N],d[N];
lli a,b,c,d;
lli x[1000005],y[1000005];
map<char,lli> m1,m2;
string s,s1,s2,s3;
vector<lli> v,v1,v2;
lli pre[N],suff[N];
//lli vis[N]={0};
char grid[11][11];
vector<pair<lli,lli>> pl;

bool sortbysec(const pair<lli,lli> &a, pair<lli,lli> &b){
    return (a.se>b.se);
}

int32_t main(){
    fast_io
    lli i = 0,j=0;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout << fixed << setprecision(22);
    

    cin >>n >> m;
    lli sum=0;
    loop(i,0,m){
        cin >> a;
        sum+=a;
    }

    if(n-sum<0) cout << -1 << endl;
    else cout << n-sum << endl;


}

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

using namespace std;

enum Face
{
	TOP = 0,
	FRONT = 1,
	RIGHT = 2,
	LEFT = 3,
	BACK = 4,
	BOTTOM = 5,
};

void roll(vector<int> &f, char d, int n)
{
	int tmp;
	for (int i = 0; i < n; i++)
	{
		switch (d)
		{
		case 'E':
			tmp = f[TOP];
			f[TOP] = f[LEFT];
			f[LEFT] = f[BOTTOM];
			f[BOTTOM] = f[RIGHT];
			f[RIGHT] = tmp;
			break;
		case 'N':
			tmp = f[TOP];
			f[TOP] = f[FRONT];
			f[FRONT] = f[BOTTOM];
			f[BOTTOM] = f[BACK];
			f[BACK] = tmp;
			break;
		case 'S':
			tmp = f[TOP];
			f[TOP] = f[BACK];
			f[BACK] = f[BOTTOM];
			f[BOTTOM] = f[FRONT];
			f[FRONT] = tmp;
			break;
		case 'W':
			tmp = f[TOP];
			f[TOP] = f[RIGHT];
			f[RIGHT] = f[BOTTOM];
			f[BOTTOM] = f[LEFT];
			f[LEFT] = tmp;
			break;
		default:
			break;
		}
	}
}

int main()
{
	vector<int> f(6);
	int q;
	int top_init, front_init;
	int top, front;
	for (int i = 0; i < 6; i++)
	{
		cin >> f[i];
		if (i == TOP)
		{
			top_init = f[i];
		}
		else if (i == FRONT)
		{
			front_init = f[i];
		}
	}
	cin >> q;
	vector<int> res(q);
	for (int i = 0; i < q; i++)
	{
		cin >> top >> front;
		if (top != f[TOP])
		{
			if (top == f[FRONT])
			{
				roll(f, 'N', 1);
			}
			else if (top == f[RIGHT])
			{
				roll(f, 'W', 1);
			}
			else if (top == f[LEFT])
			{
				roll(f, 'E', 1);
			}
			else if (top == f[BACK])
			{
				roll(f, 'S', 1);
			}
			else if (top == f[BOTTOM])
			{
				roll(f, 'N', 2);
			}
		}
		if (front == f[FRONT])
		{
			res[i] = f[RIGHT];
		}
		if (front == f[RIGHT])
		{
			roll(f, 'W', 1);
			roll(f, 'S', 1);
			roll(f, 'E', 1);
			res[i] = f[RIGHT];
		}
		else if (front == f[LEFT])
		{
			roll(f, 'E', 1);
			roll(f, 'S', 1);
			roll(f, 'W', 1);
			res[i] = f[RIGHT];
		}
		else if (front == f[BACK])
		{
			roll(f, 'W', 1);
			roll(f, 'S', 2);
			roll(f, 'E', 1);
			res[i] = f[RIGHT];
		}
	}
	for (int i = 0; i < q; i++)
	{
		cout << res[i] << endl;
	}
}


Measured memory_bytes: 3112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		String line1 = br.readLine();
		String[]lineArr1 = line1.split(" ");
		int num = Integer.parseInt(lineArr1[0]);
		String[] strArr = new String[num];

		for (int i = 0; i < num; i++) {
			strArr[i] = br.readLine();
		}
		Arrays.asList(strArr).sort(null);;

		String answer = String.join("", strArr);
		System.out.println(answer);

	}

}


Measured memory_bytes: 8020
def main():
    n,m=map(int,input().split())
    s=list(map(int,input().split()))
    t=list(map(int,input().split()))
    dp=[[0]*(m+1) for _ in [0]*(n+1)]
    for i in range(n+1):
        dp[i][m]=1
    for i in range(m+1):
        dp[n][i]=1
    for i in range(n-1,-1,-1):
        for j in range(m-1,-1,-1):
            dp[i][j]=(dp[i+1][j]+dp[i][j+1]-(s[i]!=t[j])*dp[i+1][j+1])%(10**9+7)
    print(dp[0][0])
main()


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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

#define dodebug(i, n, arr)	for(int i=0;i<n;++i)	cout<<arr[i]<<" ("<<i<<")\n";

ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

	int n,m;
	cin>>n>>m;
	vector<int> edge[n+1];
	vector<int> indegree(n+1, 0);
	int a,b;
	for(int i=0;i<m;++i){
		cin>>a>>b;
		a--;
		b--;
		edge[a].push_back(b);
		indegree[b]++;
	}

	queue<int> q;
	for(int i=0;i<n;++i){
		if(indegree[i] == 0)	q.push(i);
	}

	vector<int> dp(n, 0);
	dp[q.front()] = 0;
	while(!q.empty()){
		// dp[q.front()] = x;
		// x++;
		for(auto i:edge[q.front()]){
			dp[i] = max(dp[i], dp[q.front()]+1);
			indegree[i]--;
			if(indegree[i] == 0)	q.push(i);
		}
		q.pop();
	}
	int maxlen = dp[0];
	for(auto i:dp)	maxlen = max(maxlen, i);
	cout<<maxlen<<"\n";

	return 0;
}

Measured memory_bytes: 9408
S = input()
N = len(S)

sarch_string = "L"
R_count = 0
L_count = 0

# 法則メモ
# RRRLL のようにRとLがぶつかったところに子供があつまる
# RとLがぶつかったとき、それまでのRの個数とLの個数で数が変わる
# R = L = 偶数, R = L = 奇数なら、境のRとLに同じ数が入る
# 例：RRRLLLなら 003300
# R = 偶数、L = 奇数　や　R = 奇数、　L = 偶数なら、奇数に1多く集まる
# 例：RRRLLなら 00320, RRLLLなら 02300

children = []


def append_children(R_cou, L_cou):
    # RかLが1つ多いフラグ
    R_1up = 0
    L_1up = 0

    if R_cou % 2 == 1 and L_cou % 2 == 0:
        R_1up = 1
    elif R_cou % 2 == 0 and L_cou % 2 == 1:
        L_1up = 1

    # Rの存在した回数 - 1回、0を挿入
    for _ in range(R_cou - 1):
        children.append(0)

    # 右端Rの個数を挿入
    children.append((R_cou + L_cou) // 2 + R_1up)

    # 左端Rの個数を挿入
    children.append((R_cou + L_cou) // 2 + L_1up)

    # Lの存在した回数 - 1回、0を挿入
    for _ in range(L_cou - 1):
        children.append(0)


for i in range(N):
    if  S[i] == sarch_string:
        if sarch_string == "L":
            sarch_string = "R"
            L_count += 1
        else:
            append_children(R_count, L_count)
            
            # 初期化
            sarch_string = "L"
            R_count = 1
            L_count = 0

    else:
        if sarch_string == "L":
            R_count += 1
        else:
            L_count += 1
        
# 右端にたどり着いた時点での子供も追加
append_children(R_count, L_count)
            
print(*children)

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

#define f first
#define s second
#define pb push_back

#define ll long long

#define mp make_pair

#define int ll

using namespace std;
                        

const int inf = 1e9 + 7;

const ll ll_inf = 1e18 + 7;
const int K = 18;
const int N = 3e5 + 100;
                        

ll binpow (ll a, ll n)
{
    ll res = 1;
    while (n) {
        if (n & 1)
        {
            res *= a;
            res %= inf;
        }
        a *= a;
        n >>= 1;
        a %= inf;
    }                      	
    return res;
}   

void boost()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int sum;                                                                                                

int a;       

main()
{                  
	cin >> a;
	int ans = (a * (a + 1)) / 2;
	int ch = (a / 3);
	ch = (ch * (ch + 1)) / 2;
	ch *= 3;
	ans -= ch;
	ch = a / 5;
	ch = (ch * (ch + 1)) / 2;
	ch *= 5;
	ans -= ch;
	ch = a / 15;
	ch = (ch * (ch + 1)) / 2;
	ch *= 15;
	ans += ch;
	cout << ans;
}

Measured memory_bytes: 3620