akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/abc161
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here

        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int k = in.nextInt();
        Queue<Long>  queue = new LinkedList<>();
        for (long i = 1; i <= 9; i++) {
            queue.add(i);
        }
        int count = 0;
        while (true){
            count++;
            Long x = queue.poll();
            if (count == k){
                out.println(x);
                out.close();
                return;
            }
            if (x % 10 != 0) queue.add(10 * x + (x % 10) -1);
            queue.add(10 * x + (x % 10));
            if (x % 10 != 9) queue.add(10 * x + (x % 10) +1);
        }

    }
}


Measured memory_bytes: 35412
#include <iostream>
#include <string>
#include <queue>
using namespace std;

int main(){
    int n,q,t;
    int sum=0;
    string s;
    
    queue<string> que1;
    queue<int> que2;
    
    cin>>n>>q;
    
    for(int i=0;i<n;i++){
        cin>>s>>t;
        que1.push(s);
        que2.push(t);
    }
    while(que2.empty()==0){
        s=que1.front();
        t=que2.front();
        if(t-q>0){
            sum += q;
            que1.pop();
            que1.push(s);
            que2.pop();
            que2.push(t-q);
        }
        else{
            sum += t;
            cout<<que1.front()<<" "<<sum<<endl;
            que1.pop();
            que2.pop();
        }
    }
    return 0;
}



Measured memory_bytes: 5784
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;	
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) {
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}

template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
int modulo = 1e9 + 7;

int fpow(int a, int n) {
	int ans = 1;
	while (n) {
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s,t; cin >> s >> t;
	int ans = 0;
	For(i,0,s.size()) {
		if (s[i] == t[i])
			++ans;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String[] SS = S.split("",S.length());
		int[] N = new int[SS.length];

		for(int i=0;i<S.length();i++){
			N[i] = Integer.parseInt(SS[i]);
		}
		int ans = 0;

		for(int j =0;j<N.length-1;j++){
			if(N.length==1)break;
			if(N[j]==N[j+1]&&N[j+1]==1){
				N[j+1] = 0;
				ans++;
			}else if(N[j]==N[j+1]&&N[j+1]==0){
				N[j+1] = 1;
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 34516
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair <int,int> ii;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int n,m;
	cin>>n>>m;
	vector <ii> mv(m);
	int c=0;
	for(int i=0;i<m;i++){
		cin>>mv[i].first>>mv[i].second;
		if(mv[i].first == 1&&mv[i].second==0)c++;
	}
	if(c&&n>1){
		cout<<-1<<endl;
		return 0;
	}
	sort(mv.begin(),mv.end());
	for(int i=1;i<m;i++){
		if(mv[i].first==mv[i-1].first&&mv[i].second != mv[i-1].second){
			cout<<-1<<endl;
			return 0;
		}
	}
	if(c){
		cout<<0<<endl;
		return 0;
	}
	int lc =1;
	if(m&&mv[0].first==1){
		cout<<mv[0].second;
	}
	else if(n>1)cout<<1;
	else cout<<0<<endl;
	for(int i=0;i<m;i++){
		while(lc<mv[i].first-1){
			lc++;
			cout<<0;
		}
		if(lc==mv[i].first-1){
			lc++;
			cout<<mv[i].second;
		}
	}
	while(lc<n){
		cout<<0;
		lc++;
	}
	cout<<endl;
	return 0;
}

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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);

    for (int i = 2; i <= n; i++)
    {
        int k = 1;
        while (i * k <= n)
        {
            int t = i * k;
            a[t]++;
            k++;
        }
    }

    int sum = 0;
    rep1(i, n + 1)
    {
        sum += i * (a[i] + 1);
    }
    cout << sum << endl;

    return 0;
}


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


int main()
{
	int n,k;
	cin >> n;
	char s[11];
	
	cin >> s;
	cin >> k;

	char key = s[k-1];

	for (int i = 0; i < n; i++) {
		if (s[i] != key) {
			s[i] = '*';
		}
		
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2") 
#pragma GCC optimization ("unroll-loops")

using namespace std;
using ll = long long;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define Ceil(x, y) ((x+y-1)/y)
#define PI acos(-1)
const int mod = (int) 1000000007;
int r, c, cc, cr, dr, dc;
vector<vector<int>> M(1005, vector<int>(1005));
auto vis = M;
int k=1;
vector<int> G[600000];
int pred[600000], dist[600000]; 


void dfs(int i, int j)
{
    if(i < 0 || j < 0 || i >= r || j >= c || vis[i][j] || M[i][j] == 0)
        return;
    vis[i][j] = k;
    dfs(i, j+1);
    dfs(i, j-1);
    dfs(i+1, j);
    dfs(i-1, j);
}

void makeEdge(int a, int b)
{
    set<int> s;
    for(int i=max(0, a-2); i<=min(r-1, a+2); i++)
    {
        for(int j=max(0, b-2); j<=min(c-1, b+2); j++)
            if(vis[i][j] && vis[a][b] != vis[i][j])
            {
                s.insert(vis[i][j]);
            }
    }
    for(auto i : s)
        G[vis[a][b]].push_back(i);
}

bool BFS(int src, int dest, int v) 
{ 
    list<int> queue; 
    bool visited[v]; 
    for (int i = 0; i < v; i++) { 
        visited[i] = false; 
        dist[i] = INT_MAX; 
        pred[i] = -1; 
    } 
  
    visited[src] = true; 
    dist[src] = 0; 
    queue.push_back(src); 
  
    while (!queue.empty()) { 
        int u = queue.front(); 
        queue.pop_front(); 
        for (int i = 0; i < G[u].size(); i++) { 
            if (visited[G[u][i]] == false) { 
                visited[G[u][i]] = true; 
                dist[G[u][i]] = dist[u] + 1; 
                pred[G[u][i]] = u; 
                queue.push_back(G[u][i]); 
  
                if (G[u][i] == dest) 
                    return true; 
            } 
        } 
    } 
  
    return false; 
} 

void solve()
{
    
    cin>>r>>c;
    cin>>cr>>cc;
    cin>>dr>>dc;

    for(int i=0; i<r; i++)
    {
        string str;
        cin>>str;
        for(int j=0; j<c; j++)
            if(str[j] != '#')
                M[i][j] = 1;
    }
    for(int i=0; i<r; i++)
    {
        for(int j=0; j<c; j++)
            if(not vis[i][j] && M[i][j])
            {
                dfs(i, j);
                k++;
            }
    }
    if(vis[cr-1][cc-1] == vis[dr-1][dc-1])
    {
        cout<<0;
        return;
    }
    for(int i=0; i<r; i++)
    {
        for(int j=0; j<c; j++)
            if(M[i][j])
                makeEdge(i, j);
    }
    
    if(BFS(vis[cr-1][cc-1], vis[dr-1][dc-1], 600000) == false) 
        cout<<-1;
    else
        cout<<dist[vis[dr-1][dc-1]]<<endl;
}
 

int main(int argc, char *argv[])
{
    clock_t clk_start = clock();
    fast;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    int cases = 1;
    // cin>>cases;
    while(cases--)
    {
        solve();
    }
    cerr<<"Execution Time: "<<fixed<<double(clock() - clk_start)/double(CLOCKS_PER_SEC)<<setprecision(6)<<" sec\n"; 
}


Measured memory_bytes: 37504
#include <iostream>
#include <string>
#include <algorithm>  
using namespace std;
 
int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
  if(2*count(s.begin(),s.end(),'R')>s.size()) cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 256
import fractions

A, B, C, D = map(int, input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

lcm_cd = lcm(C, D)

mod_ac = A % C
mod_ad = A % D
mod_lcm = A % lcm_cd

c_num = 0
d_num = 0
cd_num = 0

if mod_ac == 0:
    c_num = B//C - A//C + 1
else:
    c_num = B//C - A//C

if mod_ad == 0:
    d_num = B//D - A//D + 1
else:
    d_num = B//D - A//D

if mod_lcm == 0:
    cd_num = B//lcm_cd - A//lcm_cd + 1
else:
    cd_num = B//lcm_cd - A//lcm_cd

ans = B - A + 1 - (c_num + d_num - cd_num)
print(ans)

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

int main()
{
	int l, r, d;
	cin >> l >> r >> d;
	int num = 0;
	for(int i = l; i <= r; i++){
		if((i % d) == 0){
			num++;
		}
	}
	cout << num <<endl;
	return 0;
}

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

using namespace std;

int main()
{
   int n;
   cin>>n;
   string s[n];
   int t[n];
   int sum=0;
   for(int i=0;i<n;i++)
   {
       cin>>s[i]>>t[i];
       sum=sum+t[i];
   }
    string ss;
    cin>>ss;
    int tt=0;
    for(int i=0;i<n;i++)
    {
        if(ss==s[i])
        {
            sum=sum-t[i];
            tt=1;
        }
        if(tt==0)
        {
            sum=sum-t[i];
        }

    }
    cout<<sum<<endl;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int main() {
	int n;
	while (cin >> n, n) {
		int d[10][10];
		fill(d[0], d[10], INF);
		
		REP(i, n) {
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);
			chmin(d[a][b], c);
			chmin(d[b][a], c);
			d[a][a] = 0;
			d[b][b] = 0;
		}
		
		REP(k, 10) REP(i, 10) REP(j, 10) chmin(d[i][j], d[i][k] + d[k][j]);
		
		int anss = INF, ansp = -1;
		REP(i, 10) if (!d[i][i]) {
			int sum = 0;
			REP(j, 10) if (d[i][j] != INF) sum += d[i][j];
			if (chmin(anss, sum)) ansp = i;
		}
		
		printf("%d %d\n", ansp, anss);
	}
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


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

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

int main(){
  string s; cin >> s;
  int s_size = s.size();
  int w = s_size/2;
  string a,b;
  int r = 0;
  if(s_size%2==0){
    a = s.substr(0,w);
    b = s.substr(w,w);
  }else{
    a = s.substr(0,w);
    b = s.substr(w+1,w);
  }
  REP(i,w){
    if(a[i]!=b[(w-1)-i]){r++;}
  }
  cout << r << '\n';
}
  

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n;
	cin >> n;
	long long int sum = 0;
	vector<int> s;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s.push_back(a);
	}
	for (int i = 0; i < n-1; i++) {
		for (int j = i + 1; j < n; j++) {
			sum = sum + s[i] * s[j];
		}
	}
	cout << sum;
}

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

int x,y,a;

int main(){
  int w,h,n;
  cin>>w>>h>>n;
  int lx=0,hx=w,ly=0,hy=h;
  for(int i=0;i<n;i++){
    cin>>x>>y>>a;
    if(a==1){
      lx=max(lx,x);
    }else if(a==2){
      hx=min(hx,x);
    }else if(a==3){
      ly=max(ly,y);
    }else if(a==4){
      hy=min(hy,y);
    }
  }
  if((hx-lx)<0 || (hy-ly)<0){
    cout<<0<<endl;
    return 0;
  }
  cout<<(hx-lx)*(hy-ly)<<endl;

}


Measured memory_bytes: 256
import sys

def resolve():
    N = int(input())
    D, X = list(map(int, input().split(" ")))
    A = []
    [A.append(int(input())) for i in range(N)]
    chocos = [0 for i in range(D+1)]
    for a in A:
        day = 1
        while True:
            if day > D:
                break
            chocos[day] += 1
            day = day + a
    print(sum(chocos)+X)

if '__main__' == __name__:
    resolve()

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

using namespace std;

typedef long long  ll;
typedef vector<ll> VL;
typedef pair<ll,ll> PLL;
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define inf 1000*1000*1000+5
const ll mod=998244353;


int main()
{
	ll n;
	cin>>n;
	ll ans=20;
	for(ll i =1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ll x=i;
			ll y=n/i;
			ll ct=0;
			while(x)
			{
				ct++;
				x/=10;

			}
			//ans=min(ans,ct);
			ll ct2=0;
			while(y)
			{
				ct2++;
				y/=10;
			}
			ct=max(ct,ct2);
			ans=min(ans,ct);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
K = int(input())
list1 = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list1[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


void solve()
{
	long long int K, A, B;
	cin >> K >> A >> B;
	if (A + 2 >= B)
	{
		cout << K + 1 << endl;
		return;
	}
	long long int has = 1;
	if (K - has >= A)
	{
		K -= A - has;
		has = A;
	}
	else
	{
		has += K;
		K = 0;
	}
	if (has >= A)
	{
		if (K >= 2)
		{
			has -= A;
			has += B;
			K -= 2;
		}
		else if(K == 1)
		{
			has++;
			K--;
		}
	}
	has += (B - A) * (K / 2);
	if (K % 2 == 1)
	{
		has++;
	}
	cout << has << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String before, after;
		int cnt = 0;
		while(sc.hasNext()) {
			before = sc.next();
			
			StringBuffer sb = new StringBuffer(before);
			after = String.valueOf(sb.reverse());
			
			if(before.equals(after)) {
				cnt++;
			}
		}
		
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26136
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;
using ll = long long;

int n, k, r, s, p;
string S;

void input(){
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> S;
}

int count(char a){
  if(a == 'r'){
    return p;
  }else if(a == 's'){
    return r;
  }else{
    return s;
  }
}

ll solve(){
  ll ans = 0;
  for(int i = 0; i < n; ++i){
    if(i >= k){
      if(S[i - k] == S[i]){
        S[i] = 'g';
      }else{
        ans += count(S[i]);
      }
    }else{
      ans += count(S[i]);
    }
  }
  return ans;
}

int main(){
  input();
  cout << solve() << endl;
}

Measured memory_bytes: 512
# %%
K, N = map(int, input().split())
A = list(map(int , input().split(" ")))

# %%
ma = 0
for i in range(N-1):
    ma = max(ma, A[i+1]- A[i])

# %%
print(min(K-ma,A[N-1]-A[0]))

# %%

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

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 1010;
    int slen = s.size();
    int tlen = t.size();
    rep(i, slen-tlen+1){
        string str = s.substr(i, tlen);
        int cnt = 0;
        rep(j, tlen){
            if(str[j] != t[j]){
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
using namespace std;

int main()
{
	ll n,a,sum=0;
    cin>>n;
    vector<ll> h;
    
    for(ll i=0;i<n;i++)
    {
        cin>>a;
        h.push_back(a);
    }
    
    for(ll i=0;i<n-1;i++)
    {
        if(h[i+1]<h[i])
        {
            sum+=h[i]-h[i+1];
            h[i+1]=h[i];
            
           
        }
       
    }
    
  
   cout<<sum;

	return 0;
}

Measured memory_bytes: 5360
a=input()
b=a.split()
A=int(b[0])
V=int(b[1])
c=input()
d=c.split()
B=int(d[0])
W=int(d[1])
T=int(input())
if (A == B):print("YES")
elif (A < B):
    if A - B >= T * (W - V):print("YES")
    else: print("NO")
else :
    if A - B <= T * (V - W):
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
#define intl long long int 

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	intl i,j;
	cin>>j;
	intl ans=0;
	i=1;
	while(j){
		ans+=i;
		j/=2;
		i*=2;
	}
	cout<<ans<<"\n";
}


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

using namespace std;

int main()
{
    int K, N;
    cin >> K >> N;
    
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.emplace_back(a);
    }
    int max = 0;
    int prev = -(K - A.back());
    for (int i = 0; i < N; i++) {
        int dist = abs(A[i] - prev);
        if (max < dist) {
            max = dist;
        }
        prev = A[i];
    }
    
    cout << (K - max) << endl;
}

Measured memory_bytes: 1400
N, K = gets.split(' ')
ans = 0
N.to_i.times do |i|
    t = i+1
    p = 1
    while t < K.to_i do
        t = t*2
        p = p*Rational(1,2)
    end
    ans += p
end

print sprintf("%.12f", ans/N.to_i)

Measured memory_bytes: 1788
using System.Collections.Generic;
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        var dict = new Dictionary<int, int>();
        var lst = new List<int>();
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var s = line;
            if (s == "") break;
            string[] ss = line.Trim().Split(',');
            var c = int.Parse(ss[0]);
            if (dict.ContainsKey(c)) dict[c] += 1;
            else dict[c] = 1;
        }
        string line2;
        for (; (line2 = Console.ReadLine()) != null;)
        {
            string[] ss2 = line2.Trim().Split(',');
            var c = int.Parse(ss2[0]);
            if (dict.ContainsKey(c))
            {
                dict[c] += 1;
                lst.Add(c);
            }
        }
        var lst2 = lst.Distinct().ToList();
        lst2.Sort();
        foreach (var x in lst2)
        {
            var disp = dict[x];
            Console.WriteLine("{0} {1}", x, disp);
        }

    }
}

Measured memory_bytes: 10108
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  cout << n*(n-1)/2+m*(m-1)/2 << endl;
}

Measured memory_bytes: 256
n=int(input())
srgb=input()
red=srgb.count("R")
green=srgb.count("G")
blue=n-red-green
ans=red*green*blue
counter=0
for i in range(n):
    for j in range(i+1,n):
        k=j-i+j
        if k<n:
            if srgb[i]!=srgb[j] and srgb[j]!=srgb[k] and srgb[k]!=srgb[i]:
                counter+=1
ans-=counter
print(ans)

Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization_level 3
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(){
	ll h,w;
	cin>>h>>w;

	ll rw1,rw2;
	rw2=0;
	if (w==1)
	{
		cout<<1;
		return 0;
	}
	
	if (w%2==0)
	{
		rw1 = w/2;
		// cout<<rw1<<endl;
	}else
	{
		rw1 = w/2+1;
		// cout<<rw1<<endl;
	}
	if (h>1)
	{
	rw2 = w/2;
	} else {
		cout<<1;
		return 0;
	}
	
	// cout<<rw2<<endl;

	if (h==1)
	{
		cout<<1;
		return 0;
	} else	if (h%2==0)
	{
		cout<<(rw1*(h/2))+(rw2*(h/2));
		// cout<<1;
	}else
	{
		cout<<rw1*(h/2+1)+rw2*(h/2);
	}
	
	
	
	
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

    

    class Program
    {
        
        
        static void Main(string[] args)
        {
            
            while(true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int n = int.Parse(input[0]);
                

                if(n == 0)
                {
                    break;
                }

                List<int> income = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

                long sum = 0;

                for(int i = 0; i < n; i++)
                {
                    sum += income[i];
                }

                long income_ave = sum / n;

                int num_under_ave = 0;
                
                for(int i = 0; i < n; i++)
                {
                    if(income[i] <= income_ave)
                    {
                        num_under_ave++;
                    }
                }

                Console.WriteLine(num_under_ave);

            }
            
        }
    }
}


Measured memory_bytes: 17436
import math
n,m = map(int, input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if n >= 2:
	a = combinations_count(n,2)
else:
    a = 0
    
if m >= 2:
	b = combinations_count(m,2)
else:
    b = 0

print(a+b)

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

main(){

ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

long long i,j,k,l,m,n;

while(cin>>l){
vector<int>a(l),b(l);

for(i=0;i<l;i++)cin>>a[i];
for(i=0;i<l;i++)cin>>b[i];
if(a>b)swap(a,b);
k=0;
while(a!=b){
    next_permutation(a.begin(),a.end());
    k++;
}
cout<<k<<endl;
}

 return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A1,A2,A3;
    scanf("%d %d %d",&A1,&A2,&A3);
    if(A1+A2+A3>=22)
    {
        printf("bust");
    }
    else{
        printf("win");
    }


    return 0;
}


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

int main() {   
int64_t n,a,b,ans,t;
  ans=0;
  t=0;
  cin>>n;
for(int64_t i=0;i<n;i++){
cin>>a;
  cin>>b;
  if(a==b){ans++;}
  else{ans=0;}
  if(ans>=3){
    t=1;
   cout<<"Yes"<<endl;
            break;}
} 
  if(t==0){cout<<"No"<<endl;}
} 

Measured memory_bytes: 3600
#include<cstdio>

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

using namespace std;

int m,n,a,b;

bool traceAmida(const bool amd[30][9]){
	int p=a;
	rep(i,m){
		if     (p<n-1 && amd[i][p])	p++;
		else if(0<p && amd[i][p-1])	p--;
	}
	return p==b;
}

int main(){
	for(;scanf("%d%d%d%d",&n,&a,&b,&m),n;){
		a--,b--;
		bool amd[30][9];
		rep(i,m){
			char s[10];	scanf("%s",s);
			rep(j,n-1)	amd[i][j]=(s[j]=='1');
		}

		bool ok=false;
		if(traceAmida(amd)){ puts("0"); ok=true; }
		else{
			int ii,jj;
			rep(i,m){
				if(!amd[i][0] && !amd[i][1]){
					amd[i][0]=true;
					if(traceAmida(amd)){ ok=true; ii=i,jj=0; goto FOUND; }
					amd[i][0]=false;
				}
				for(int j=1;j<n-2;j++){
					if(!amd[i][j-1] && !amd[i][j] && !amd[i][j+1]){
						amd[i][j]=true;
						if(traceAmida(amd)){ ok=true; ii=i,jj=j; goto FOUND; }
						amd[i][j]=false;
					}
				}
				if(!amd[i][n-3] && !amd[i][n-2]){
					amd[i][n-2]=true;
					if(traceAmida(amd)){ ok=true; ii=i,jj=n-2; goto FOUND; }
					amd[i][n-2]=false;
				}
			}

			FOUND:
			if(ok)	printf("%d %d\n",ii+1,jj+1);
		}
		if(!ok)	puts("1");
	}

	return 0;
}

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

bool IsPrime(int n){
    for(int i = 2; i*i <= n; i++){
        if(n % i == 0)
            return false;
    }
    return true;
}

int main(void){
    int n, c = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        if(IsPrime(p)==true){
            c++;
        }
    }
    cout << c << endl;
    
    return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  for(int i=0; i<N; i++){
    cin >> P[i];
    if(i==0) Q[i]=P[i];
    else if(P[i]<Q[i-1]){
      Q[i]=P[i];
    }
    else Q[i]=Q[i-1];
  }
  
  int cnt=0;
  for(int i=0; i<N; i++){
    if(P[i]==Q[i]) cnt++;
  }
  cout << cnt << endl;
}

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

int N,K;
int A[5010];
bool dp[5010][5010] = {{0}};

void dym(int n){
	for(int i=0;i<=N;i++){
		for(int j=0;j<=K;j++){
			dp[i][j] = false;
		}
	}
	for(int i=1;i<=N;i++){
		if(i!=n){
			dp[i][min(A[i],K)] = true;
			for(int j=0;j<=K;j++){
				dp[i][j] = (dp[i-1][j] | dp[i][j]);
				dp[i][min(j+A[i],K)] = (dp[i-1][j] | dp[i][min(j+A[i],K)]);
			}
		}else{
			for(int j=0;j<=K;j++){
				dp[i][j] = dp[i-1][j];
			}
		}
		//cout << dp[i][2] << endl;
	}
	//cout << "A" << dp[N][2] << endl;
}

int main(){
	cin >> N >> K;
	for(int i=1;i<=N;i++){
		cin >> A[i];
	}
	sort(&A[1],&A[N+1]);
	//cout << A[1] << " " << A[N] << endl;
	int l = 0,r = N+1;
	while(l+1<r){
		int m = (l+r)/2;
		bool judge = true;
		if(A[m]<K){
			dym(m);
			for(int i=K-A[m];i<K;i++){
				if(dp[N][i]) judge = false;
			}
		}else judge = false;
		if(judge) l = m;
		else r = m;
	}
	cout << l << endl;
	/*if(r==N){
		if(A[N]>=K) cout << l << endl;
		else cout << r << endl;
	}*/
}

Measured memory_bytes: 24704
#include<iostream>
using namespace std;
int main(){
    int U[4][3][10]={{{}}};
    int b,f,r,v,n;
    cin >> n;
    int i;
    for(i=0;i<n;i++){
            cin >>b >>f >> r >>v;
            U[b-1][f-1][r-1]+=v;
            
    }
    int j,k;
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                cout<<" ";
                cout<<U[i][j][k];
            }
            cout<<endl;
        }
        if(i<3)cout<<"####################"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
s = list(input())

s1 = int(s[0]) * 10 + int(s[1])
s2 = int(s[2]) * 10 + int(s[3])

if(s1 > 12 and s2 > 12):
    print("NA")
elif(s1 < 13 and s2 < 13 and s1 > 0 and s2 > 0):
    print("AMBIGUOUS")
elif(s1 < 13 and s1 > 0):
    print("MMYY")
elif(s2 > 0):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
def main():
    n = int(input())
    p_lst = list(map(int, input().split()))

    min_val = n + 1
    ans = 0

    for i in range(n):
        if min_val >= p_lst[i]:
            min_val = p_lst[i]
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 99968
n = gets.to_i
a = []
for i in 0...n do
  a[i] = gets.to_i
end
count = 0
b = Array.new(n, false)
i = 0
b[i] = true
while i != 1 do
  i = a[i] - 1
  if b[i] == true
    count = -1
    break
  else
    b[i] = true
    count += 1
  end
end
puts count


Measured memory_bytes: 3912
#include <stdio.h>
#include <string.h>
#define MAX 1500000
#define N -100000
   
int size = 1;
 
int parent(int i) {
  return i/2;
}
int left(int i) {
  return 2*i;
}
int right(int i) {
  return 2*i + 1;
}
   
void mheapi(int *A, int i) {
  int l = left(i);
  int r = right(i);
  int lar;
   
  if (l <= size && A[l] > A[i]) {
    lar = l;
  } else {
    lar = i;
  }
  if (r <= size && A[r] > A[lar]) {
    lar = r;
  }
   
  if (lar != i) {
    r = A[lar];
    A[lar] = A[i];
    A[i] = r;
   
    mheapi(A, lar);
  }
}
   
void heapkey(int *A, int i, int key) {
  if (key < A[i]) {
    return;
  }
   
  A[i] = key;
  while (i > 1 && A[parent(i)] < A[i]) {
    key = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = key;
    i = parent(i);
  }
}
     
void ins(int *A, int key) {
  size++;
  A[size] = N;
  heapkey(A, size, key);
}
 
int getM(int *A) {
  if (size < 1) {          
    return -1;
  }
   
  int m = A[1];
  A[1] = A[size];
  size--;
  mheapi(A, 1);
  return m;
}
int main(void) {
  int key;
  int ary[MAX];
  char order[10];
  int m;
   
  while (1) {
    scanf("%s %d", order, &key);
    if (order[0] == 'i') {
      ins(ary, key);
    } else if (order[1] == 'x') {
      m = getM(ary);
      printf("%d\n", m);
    } else {
      break;
    }
  }
  return 0;
}

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>>a(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a.at(i).at(j);
    }
  }
  vector<vector<int>>cost(h,vector<int>(w));
  cost.at(0).at(0)=(a.at(0).at(0)=='#');
  for(int i=1;i<w;i++){
    if(a.at(0).at(i-1)=='.'&&a.at(0).at(i)=='#')
      cost.at(0).at(i)=cost.at(0).at(i-1)+1;
    else
      cost.at(0).at(i)=cost.at(0).at(i-1);
  }
  for(int i=1;i<h;i++){
    if(a.at(i-1).at(0)=='.'&&a.at(i).at(0)=='#')
      cost.at(i).at(0)=cost.at(i-1).at(0)+1;
    else
      cost.at(i).at(0)=cost.at(i-1).at(0);
  }
  for(int i=1;i<h;i++){
    for(int j=1;j<w;j++){
      cost.at(i).at(j)=min(cost.at(i-1).at(j)+(a.at(i-1).at(j)=='.'&&a.at(i).at(j)=='#'),cost.at(i).at(j-1)+(a.at(i).at(j-1)=='.'&&a.at(i).at(j)=='#'));
    }
  }
  cout << cost.at(h-1).at(w-1) << endl;
  return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define maxn 1000
#define mod 1000000007
using namespace std;
//errichto

int h,w;
bool gd[maxn][maxn];
int  dp[maxn][maxn];

int main(){
	cin >> w >> h;
	for (int i = 0; i < w; ++i){
		for (int j = 0; j < h; ++j){
			char a;
			cin >> a;
			if(a == '#')
				gd[i][j] = true;
			else
				gd[i][j] = false;
		}
	}

	dp[w-1][h-1] = 1;

	for (int i = h-2; i >=0; --i){
		if(gd[w-1][i])
			break;
		dp[w-1][i] = 1;
	}
	for (int i = w-2; i >=0; --i){
		if(gd[i][h-1])
			break;
		dp[i][h-1] = 1;
	}

	for (int i = w-2; i >=0; --i){
		for (int j = h-2; j >=0; --j){
			if(gd[i][j])
				continue;
			dp[i][j] = (dp[i+1][j] + dp[i][j+1]) % mod;
		}
	}

	cout << dp[0][0] << endl;

	return 0;
}

Measured memory_bytes: 5120
n = int(input())
res=[0]*4
for _ in range(n):
    s = input()
    if s == "AC":
        res[0]+=1
    elif s == "WA":
        res[1]+=1
    elif s == "TLE":
        res[2]+=1
    else:
        res[3]+=1
print("AC x "+str(res[0]))
print("WA x "+str(res[1]))
print("TLE x "+str(res[2]))
print("RE x "+str(res[3]))

Measured memory_bytes: 9028
//wawando's template

#include <iostream>
#include <string>
#include <fstream>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>  //clock_t , clock() , CLOCKS_PER_SEC
#include <cstring>
#include <cctype>
#include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

//MACROS
#define pb              push_back
#define mp              make_pair
#define INF             1000000000     //1 billion safer for floyd warshall, avoid overflow

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

bool cmp(pair<string, int> a, pair<string, int> b) {
  if(a.first == b.first) return (a.second > b.second);
  else return (a.first < b.first);
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(0);
  int N,L;
  cin >>N >>L;
  int sum = 0;
  int mini = INF;
  int sgn = 0;
  for(int i = 1; i <= N; i++) {
    int s = L + i - 1;
    if(abs(s) < mini) {
      mini = abs(s);
      sgn = (s < 0 ? -1 : 1);
    }
    sum += s;
  }
  cout <<sum - sgn * mini <<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << h; if (sizeof...(t)) cerr << ", "; DBG(t...); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	int x; cin >> x;
	cout << (x >= 30 ? "Yes" : "No") << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		//cout << "Case #" << i << ": ";
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)


//0-index ?????????????????¶?????°?????????(????????????) verified AOJ DSL_2_G, (((CODEFESTIVAL2015-D)))
template<class T>
class lazySegmentTree{
private:
    vector<T> dat;
    vector<T> lazy;
    int _size;  //the number of leaves
    T _init;
    
public:
    lazySegmentTree( vector<T> vec, T init = numeric_limits<T>::max() ): _init(init){
        int size = vec.size();
        if(size==0)return ;
        
        _size = 1;
        while(_size<size)_size*=2;
        dat.resize(_size*2);
        rep(i,vec.size())dat[i+_size] = vec[i];
        lazy.resize(_size*2,_init);
    }
    
    
    void eval(int num, int l, int r){
        if(lazy[num]==0) return ;
        dat[num] += lazy[num];
        
        
        if(r-l>1){  //?????§?????????
            lazy[num*2] += lazy[num]/2;
            lazy[num*2+1] += lazy[num]/2;
        }
        lazy[num] = 0;
    }
    
    
    
    T update(int s, int t, T x, int num=1, int l=0, int r=-1){
        if(r==-1)r =_size;
        
        eval(num,l,r);
        
        if(r<=s || t<=l) return dat[num];   //????±??????????
        if(s<=l && r<=t){
            lazy[num] += x * (r-l);
            eval(num,l,r);
        }
        else{
            int res1 = update(s, t, x, num*2, l, (l+r)/2);
            int res2 = update(s, t, x, num*2+1, (l+r)/2, r);
            dat[num] = res1+res2;
        }
        return dat[num];
    }
    
    
    T find(int s, int t, int num=1, int l=0, int r=-1){
        if(r==-1)r = _size;
        
        eval(num,l,r);
        
        
        if(r<=s || t<=l) return _init;  //????±??????????
        if(s<=l && r<=t) return dat[num];
        else{
            return find(s, t, num*2, l, (l+r)/2) + find(s, t, num*2+1, (l+r)/2, r);
        }
    }
    
    int size(){ return _size; }
};

signed main(){
    int n,q;
    cin>>n>>q;
    
    lazySegmentTree<int> seg(vector<int>(n,0), 0);
    
    rep(i,q){
        int type,s,t,x;
        cin>>type;
        if(type==0){
            cin>>s>>t>>x;
            s--;
            seg.update(s,t,x);
        }else{
            cin>>s>>t;
            s--;
            cout<<seg.find(s,t)<<endl;
        }
    }
}

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

int main() 
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int dp[n];
	for(int i=0;i<n;i++)
	{
		dp[i]=INT_MAX;
	}
	dp[0]=0;
	
	
	for(int i=0;i<n;i++)
	{
		if((i+1)<n)
		{
			dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
		}
		if((i+2)<n)
		{
			dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
		}
	}
	cout<<dp[n-1];

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

//繰り返し二乗法
ll EX(ll x,ll n){
    if(n == 0) return 1;
    else if(n%2 == 1) return EX(x,n-1)*x%mod;
    else return EX(x*x%mod,n/2)%mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    vector<int> bit(60,0);
    for(int j = 0; j < n; j++){
        for(int i = 0; i < 60; i++){
            if(a[j] & (1ll << i)) bit[i]++;
        }
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 60; j++){
            ll now = EX(2,j);
            if(a[i] & (1ll << j)){
                bit[j]--;
                ans += now*(n-i-1-bit[j])%mod;
                ans %= mod;
            } else ans += now*bit[j]%mod;
        }
    }

    cout << (ans+mod)%mod << endl;

    return 0;
}

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

#define array_sort_asc(array,size) sort(array, array+size);
#define array_sort_desc(array,size) sort(array, array+size,greater<>());

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

    REP(i,10) {
        REP(j,10) {
            int tmp = i*j;
            if(n == tmp){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

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


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

	int R[200], tmp;
	int count = 0;
	for (int i = 0; i<n; i++) {
		cin >> R[i];
	}

	

	for (int i = 0; i < n - 1; i++) {
		for (int j = n - 1; j > i; j--) {
			if (R[j - 1] > R[j]) {
				tmp = R[j - 1];
				R[j - 1] = R[j];
				R[j] = tmp;
				count++;
			}
		}
	}

	for (int i = 0; i <n; i++) {
		cout << R[i];
		if(i!=n-1){
		    cout <<" ";
		}
	}
	cout << endl;
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
using namespace std;




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


if(s.size()!=a+b+1){
cout<<"No"<<endl;
  return 0;
}

for(ll i=0;i<s.size();i++){




if(i==a){
  if(s[a]!='-'){
    cout<<"No"<<endl;
      return 0;
  }
}
else{
  if('0'>s[i]||s[i]>'9'){
    cout<<"No"<<endl;
      return 0;
  }
}


}

cout<<"Yes"<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{
  IO; 
  ll n; 
  cin>>n; 
  ll o=n/2; 
  ll e=n-o; 
  cout<<o*e<<endl ;
return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int ans = 10000000;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<100;i++){
    int cost = 0;
  for(int j=0;j<n;j++){
    cost += (a[j]-i)*(a[j]-i);
  }
   if(ans > cost){
     ans = cost;
   }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
  std::string a,b,c;
  //std::string ryk;

  cin >> a >> b >> c;

  a[0]=::toupper(a[0]);
  b[0]=::toupper(b[0]);
  c[0]=::toupper(c[0]);
  //ryk=a[0]+b[0]+c[0];
  cout << a[0] << b[0] << c[0] << endl;
  //cout << ryk << endl;

  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int i;
string s;
int main()
{
	i=0;
	cin>>s;
	while(i<s.size())
    {
        if(s[i]=='B')
        {
			if(i>0)
			{
				s.erase(i-1,2);
				i--;
			}
			else
			{
				s.erase(i,1);
			}
    	}
    	else
    	{
    		i++;
    	}
    }
    cout<<s<<endl;
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	if (s == "SUN")cout << 7 << endl;
	else if (s == "MON")cout << 6 << endl;
	else if (s == "TUE")cout << 5 << endl;
	else if (s == "WED")cout << 4 << endl;
	else if (s == "THU")cout << 3 << endl;
	else if (s == "FRI")cout << 2 << endl;
	else if (s == "SAT")cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));
struct Unionfind{
    vector<int> data;
    Unionfind(int size):data(size, -1) {}
    bool unite(int x, int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x!=y;
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    int root(int x){
        return (data[x] < 0) ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

signed main(){
    int n,m; cin >> n >> m;
    Unionfind uni(n);
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        uni.unite(a,b);
    }
    int ans=0;
    rep(i,n){
        chmax(ans,uni.size(i));
    }
    cout << ans << endl;
}




Measured memory_bytes: 4044
<?php

fscanf(STDIN, '%d', $n);
$dll = new \SplDoublyLinkedList();
for ($i = 0; $i < $n; $i++) {
    $line = trim(fgets(STDIN));
    if ($line[0] === 'i') {
        $dll->unshift(substr($line, 7));
    } elseif ($line[6] === 'F') {
        $dll->shift();
    } elseif ($line[6] === 'L') {
        $dll->pop();
    } else {
        $check = substr($line, 7);
        foreach ($dll as $key => $val) {
            if ($val === $check) {
                $dll->offsetUnset($key);
                break;
            }
        }
    }
}

$str = array();
while (true) {
    try {
        $val = $dll->shift();
        $str[] = $val;
    } catch (Exception $e) {
        echo implode(' ', $str), PHP_EOL;
        break;
    }
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	vector<char> result;
	for (char c : s) {
		if (c == 'B') {
			if (result.size() > 0) {
				result.pop_back();
			}
		}
		else {
			result.push_back(c);
		}
	}
	for (char c : result) {
		cout << c;
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 256