akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

const int N = 1e5;
ll dp[N];
int n , a[N] , k;

ll calc (int idx){

    if (idx == n-1)
        return 0;

    ll &ret = dp[idx];
    if (~ret)
        return ret;

    ret = 1e9;

    for (int i = 1 ; i <= k ; ++i){
        if (idx + i >= n)
            break;
        ret = min (ret , calc(idx+i) + abs(a[idx] - a[idx+i]));
    }

    return ret;

} 

void Suhaib_Sawalha (){

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

    memset(dp,-1,sizeof dp);
    cout << calc(0);

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 11016
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cstdlib>
using namespace std;
#define MAXN 200005
#define INF 0x3f3f3f3f
#define LL long long
vector<int>G[MAXN];
int siz[MAXN],n,cnt;
void dfs(int u,int p)
{
	siz[u]=1;
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if(v==p) continue;
		dfs(v,u);
		if(siz[v]==2) siz[v]=-1;
		else siz[u]+=siz[v];//删点
	}
	return ;
}
void dfs2(int u,int p)
{
	++cnt;
	int num=0;//统计叶子个数 
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if(v==p) continue;
		if(siz[v]==1) num++;
		if(siz[v]!=-1)
			dfs2(v,u); 
	}
	if(num>=2)
	{
		printf("First\n");
		exit(0);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0);
	dfs2(1,0);
	if(cnt==1) printf("First\n");//只剩下一个节点 先手必胜 
	else printf("Second\n");//不存在那样的节点 先手必败 
    return 0;
}


Measured memory_bytes: 8576
str = input().split()
mfw = ""
mlw = ""
maxF = 0
maxL = 0
for w in str:
    if str.count(w) > maxF:
        mfw = w
        maxF = str.count(w)
    if len(w) > maxL:
        mlw = w
        maxL = len(w)
print(mfw, mlw)

Measured memory_bytes: 7404
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repn(a,b,c) for(int a=b;a<=c;a++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  
#define mod (ll)1000000007
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
//sort pair by second values
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}


ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}


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

    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    
    if(k<=a){
        cout<<k<<endl;
    }
    else if(k<=a+b){
        cout<<a<<endl;
    }
    else{
        cout<<(a-(k-(a+b)))<<endl;
    }


    return 0;
}



Measured memory_bytes: 3544
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a); i >=(b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod1=1000000007;
ll mod2=67280421310721;
ll mod3=998244353;
ll INF=1e18;

ll binpow1(ll a,ll b){
    ll res=1;
    while (b>0){
        if (b&1)
        res=res*a;
        a=a*a;
        b>>=1;
    }
    return res;
}

ll binpow2(ll a,ll b,ll m){
    a%=m;
    ll res=1;
    while (b>0){
        if (b & 1)
        res=res*a%m;
        a=a*a%m;
        b>>=1;
    }
    return res;
}

ll gcd(ll a,ll b){
    if (b==0)
        return a;
    else
        return gcd(b,a%b);
}

map<ll,ll> fact(ll n) {
    map<ll,ll> factorization;ll c=0;
    while (n % 2 == 0) {
        c++;
        n /= 2;
    }
    if(c>0)
    {
        factorization.insert({2,c});
    }c=0;
    for (ll d = 3; d * d <= n; d += 2) {
        while (n % d == 0) {
            c++;
            n /= d;
        }
        if(c>0)
    {
        factorization.insert({d,c});
    }c=0;
    }
    if (n > 1)
       {
           factorization.insert({n,1});
       }
    return factorization;
}

int main()
{ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;ll f=0;
    if(a<=0 && b>=0)
    {
        f=1;
    }
    if(c<=0 && d>=0)
    {
        f=1;
    }
    ll m=b*d;
    m=max(m,b*c);
    m=max(m,a*d);
    m=max(m,a*c);
    if(f==1)
    {
        m=max(m,0LL);
    }
    cout<<m;




	return 0;
}













Measured memory_bytes: 3640
k, s = gets.split(' ').map(&:to_i)
#puts (0..k).to_a.product((0..k).to_a).map { |x, y| s - x - y } .select { |z| 0 <= z && z <= k } .size
#puts (k + 1).times.map { |x| (k + 1).times.map { |y| s - x - y } .select { |z| 0 <= z && z <= k}.size } .inject(&:+)
puts (0..k).map { |x| (0..k).map { |y| s - x - y } .select { |z| 0 <= z && z <= k}.size } .inject(&:+)


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

int main(){
int A, B, X;
  cin >> A >> B >> X;
  
  if(A > X) cout << "NO" << endl;
  else if(A + B < X) cout << "NO" << endl;
  else cout << "YES" << endl;
  
  return 0;
  
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    // 解の範囲(lb, ub]
    ll lb = -1, ub = 1e9;
    while (ub - lb > 1) {
        ll t = (lb + ub) / 2;
        ll cnt = 0;
        rep(i, n) {
            if (h[i] > t * b) {
                cnt += (ll)(ceil((double)(h[i] - t * b) / (a - b)));
            }
        }
        if (cnt <= t) {
            ub = t;
        } else {
            lb = t;
        }
    }
    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,k;
  string s;
  cin>>n;
  cin>>s;
  cin>>k;
  for(int i=0;i<n;i++){
    if(s[k-1]!=s[i]){
      s[i]='*';
    }
  }
  cout<<s;
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  
  int count = 1;
  for(int i = 1; i < n; i++){
    if(a[i] != a[i-1]){
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return x*f;
}
const int N=300010;
char s[N];
int s1[N],s2[N];
int main(){
	int n=read();
	scanf("%s",s+1);
	for (int i=1;i<=n;++i){
		if (s[i]=='W') s1[i]=s1[i-1]+1;
		else s1[i]=s1[i-1];
	}
	for (int i=n;i>=1;--i){
		if (s[i]=='E') s2[i]=s2[i+1]+1;
		else s2[i]=s2[i+1];
	}
	int ans=n;
	for (int i=1;i<=n;++i){
		ans=min(ans,s1[i-1]+s2[i+1]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template<class T>
class BIT {
    vector<T> bit;


public:
    BIT(int n): bit(vector<T>(n+1, 0)){}

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

    void add(int k, T x){
        for (++k; k < bit.size(); k  += (k & -k)) bit[k] += x;
    }
};


int main() {
    int n;
    cin >> n;
    vector<int> va, v;
    for (int i = 0; i < n; ++i) {
        int k;
        scanf("%d", &k);
        v.emplace_back(k);
    }
    va = v;
    sort(va.begin(), va.end());
    auto idx = [&](int x){return static_cast<int>(lower_bound(va.begin(), va.end(), x) - va.begin());};
    ll ans = 0;
    for (int i = 0; i < n; i += 2) {
        ans += abs(i-idx(v[i]))%2;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
 
#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)
#define pb push_back
 
 
using namespace std;
using namespace std::chrono;
 
char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
 

 
 
void solve() {
 
    int x,y;
    cin>>x>>y;
    if(!(y>=2*x&&4*x>=y)){
        cout<<"No"<<endl;
        return;
    }
   
    if((y-(2*x))%2==0 && ((4*x)-y)%2==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
 
}
   
   

 
 
int main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
        
        solve();
 
 
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M; cin >> M;
    int sum = 0, len = 0;
    rep(i, M) {
        int d, c;
        cin >>d >> c;
        sum += d * c;
        len += c;
    }
    //cerr << sum << " " << len << endl;
    cout << (len - 1) + (sum - 1) / 9 << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

ll sum[maxn];

int main(){
	int n = read();
	sum[0] = 0;
	for(int i=1; i<=n; i++){
		ll x = read();
		sum[i] = sum[i-1]+x;
	}

	ll tmp = 0;
	unsigned long long tt=0,ans=INFLL;


	if(sum[1] != 0){
		tmp = 0;
		if(sum[1] > 0){
			for(int i=2; i<=n; i++){
				ll kk = sum[i];
				if(i%2 == 0){
					kk += tmp;
					if(kk >= 0) tmp-=(kk+1),tt+=(kk+1);
				}else{
					kk += tmp;
					if(kk <= 0) tmp+=(1-kk),tt+=(1-kk);
				}
			}
		}else{
			for(int i=2; i<=n; i++){
				ll kk = sum[i];
				if(i%2 == 0){
					kk += tmp;
					if(kk <= 0) tmp+=(1-kk),tt+=(1-kk);
				}else{
					kk += tmp;
					if(kk >= 0) tmp-=(kk+1),tt+=(kk+1);
				}
			}
		}
		ans = tt;
	}
	// cout << ans << endl;

	tmp = 1-sum[1];
	tt = abs(tmp);
	for(int i=2; i<=n; i++){
		ll kk = sum[i];
		if(i%2 == 0){
			kk += tmp;
			if(kk >= 0) tmp-=(kk+1),tt+=(kk+1);
		}else{
			kk += tmp;
			if(kk <= 0) tmp+=(1-kk),tt+=(1-kk);
		}
	}
	ans = min(ans,tt);
	// cout << ans << endl;
	tmp = -1-sum[1];
	tt = abs(tmp);
	for(int i=2; i<=n; i++){
		ll kk = sum[i];
		if(i%2 == 0){
			kk += tmp;
			if(kk <= 0) tmp+=(1-kk),tt+=(1-kk);
		}else{
			kk += tmp;
			if(kk >= 0) tmp-=(kk+1),tt+=(kk+1);
		}
	}
	ans = min(ans,tt);
	// cout << ans << endl;

	cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
const long long mod=1e9+7; //10^9+7

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

    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int k, x;
    cin >> k >> x;
    
    if(500 * k >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;
    
int main(){
    int x,max=1;
    cin>>x;
    for(int i=2;i<=x;i++){
        for(int j=2;j<=x;j++){
            if(pow(i,j)<=x && pow(i,j)>=max) max=pow(i,j);
        }
    }
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [0, 0] + [int(input()) for _ in range(N - 1)]

child = [[] for _ in range(N + 1)]
for i, a in enumerate(A):
    child[a].append(i)

def depth(i):
    if not child[i]:
        return 0

    childDepth = [depth(to) for to in child[i]]
    childDepth.sort(reverse=True)
    ret = 0
    for j, d in enumerate(childDepth, start=1):
        ret = max(j + d, ret)
    return ret

ans = depth(1)
print(ans)

Measured memory_bytes: 231960
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	char b;

	cin >> b;

	if (b == 'A') {
		cout << "T" << endl;
	}
	else if (b == 'C') {
		cout << "G" << endl;
	}
	else if (b == 'G') {
		cout << "C" << endl;
	}
	else {
		cout << "A" << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int H = s.nextInt();
		int W = s.nextInt();
		for(;;){
			if(H == 0 && W == 0) break;
			for(int i = 0; i < H; i++){
				for(int n = 0; n < W; n++){
					System.out.print("#");
				}
				System.out.println();
			}
			H = s.nextInt();
			W = s.nextInt();
			System.out.println();
		}
		
	}
	public static void main(String[] args) {
		
		new Main().run();
		
	}
}

Measured memory_bytes: 35552
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

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

namespace IO {
  static const int SZ = 1 << 20;
  static FILE *fin = stdin, *fout = stdout;
  static char ibuf[SZ], *is = ibuf, *it = ibuf;
  static char obuf[SZ], *os = obuf, *ot = obuf + SZ;

  inline char nextChar() {
    if (is == it) {
      it = (is = ibuf) + fread(ibuf, sizeof(char), SZ, fin);
      if (is == it)
        return EOF;
    }
    return *is++;
  }
  template <typename T>
  inline void readInt(T &x) {
    x = 0;
    T flag(1);
    char ch;
    for (ch = nextChar(); isspace(ch); ch = nextChar())
      ;
    if (ch == '-')
      ch = nextChar(), flag = -flag;
    for (; isdigit(ch); ch = nextChar())
      x = x * 10 + ch - '0';
    x *= flag;
  }
  inline void readCh(char &now) {
    for (now = nextChar(); isspace(now); now = nextChar())
      ;
  }

  inline void flushBuffer() {
    fwrite(obuf, sizeof(char), os - obuf, fout);
    os = obuf;
  }
  inline void printChar(char ch) {
    if (os == ot)
      flushBuffer();
    *os++ = ch;
  }
  template <typename T>
  inline void printInt(T x) {
    static int dig[20], cnt;
    if (os + 20 > ot)
      flushBuffer();
    if (x < 0)
      *os++ = '-', x = -x;
    cnt = 0;
    do {
      dig[++cnt] = x % 10;
      x /= 10;
    } while (x);
    for (int i = cnt; i > 0; --i)
      *os++ = dig[i] + '0';
  }
}

using namespace IO;

const int N = 1e5 + 5;

int n;

ll lcm(ll a, ll b) {
  return a / __gcd(a, b) * b; 
}

int main() {
#ifdef LOCAL_DEBUG
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#endif
  readInt(n);
  ll res = 1;
  for (int i = 1; i <= n; ++i) {
    ll now = 0;
    readInt(now);
    res = lcm(res, now);
  }
  printInt(res);
  printChar('\n');
  flushBuffer();
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

def index(n):
    return [i for i in range(2 * n, N + 1, n)]


F = set()
for n in range(N, 0, -1):
    a = sum([1 if i in F else 0 for i in index(n)])
    if a % 2 != A[n]:
        F.add(n)

print(len(F))
L = list(map(str, F))
print(" ".join(L))


Measured memory_bytes: 24116
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint A, B, N; cin >> A >> B >> N;
    lint q = A / B, r = A % B;
    lint x = min(B - 1, N);
    cout << q * x + r * x / B << "\n";
}

Measured memory_bytes: 3668
N,M = map(int, input().split())

class UnionFind:
    def __init__(self, N):
        self.root = list(range(N + 1))
        self.size = [1] * (N + 1)

    def __getitem__(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x

    def merge(self, x, y):
        x = self[x]
        y = self[y]
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            x, y = y, x
            sx, sy = sy, sx
        self.root[y] = x
        self.size[x] += sy

    def find_max(self):
        return max(self.size)

uf = UnionFind(N)

answer = []
append = answer.append
merge = uf.merge

for i in range(M):
    a,b = map(int, input().split())
    merge(a,b)
print(uf.find_max())

Measured memory_bytes: 18392
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a;
  vi A(a),B(a);
  for(auto &a:A)cin>>a;
  for(auto &a:B)cin>>a;
  ll ans=B[0];
  vi C(a-1);
  for(auto &a:C)cin>>a;
  for(int i=1;i<a;i++){
    if(A[i]==A[i-1]+1){ans+=C[A[i-1]-1];}
    ans+=B[i];
  }
  cout<<ans<<endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define reps(i, s, n) for(int i = (int)s; i < (int)n; i++)
#define in(i) std::cin >> i;
#define print(i) std::cout << i;
#define println(i) std::cout << i << std::endl;

int main() {
    int n;
    std::string str;
    in(n)
    in(str)
    if((str.length()) <= n) {
        print(str)
        return 0;
    }
    int cnt = 0;
    for(auto i : str) {
        if(cnt == n) {
            print("...")
            break;
        }
        print(i)
        cnt++;
    }
    return 0;
}

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

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

    int n, m;
    cin >> n >> m;
    long long A[n][3];
    REP(i, n) REP(j, 3) cin >> A[i][j];

    long long maxi = -1e18;
    REP(i, 8){
        vector<long long> B(n);
        REP(j, n){
            long long cost = 0;
            REP(k, 3){
                cost += A[j][k] * ((i >> k) & 1 ? 1 : -1);
            }
            B[j] = cost;
        }
        sort(B.begin(), B.end(), greater<long long>());
        long long tmp = 0;
        REP(i, m) tmp += B[i];
        maxi = max(maxi, tmp);
    }
    cout << maxi << endl;  

    return 0;
}

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

using namespace std;

typedef long double ld;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 2e18;
const int M = 100100;

int add(int x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
  return x;
}

int udd(int &x, int y) {
  return x = add(x, y);
}

int sub(int x, int y) {
  return add(x, mod - y);
}

int uub(int &x, int y) {
  return x = sub(x, y);
}

int n;
int d[M];
int from[M];
int bon[M];
ll s[M];
ll a, b;

void read() {
  cin >> n;
  cin >> a >> b;
  if (a < b)
    swap(a, b);

  s[0] = -(a + 1);
  for (int i = 1; i <= n; ++i)
    cin >> s[i];

  s[n + 1] = s[n] + (a + 1);

  n += 2;
}

void kill() {
  for (int i = n - 1; i >= 0; --i) {
    from[i] = i;
    if (i + 1 < n && s[i + 1] - s[i] >= b)
      from[i] = from[i + 1];
  }

  d[0] = 1;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    ll prev = i > 0 ? s[i - 1] : -inf;
    sum = add(sum, bon[i]);
    udd(d[i], sum);

    if (i + 1 == n || s[i + 1] - prev < b)
      continue;

    int j = lower_bound(s, s + n, s[i] + a) - s;
    int up = from[i + 1] + 2;
    up = min(up, n);


    if (j < up) {
      int cur = d[i];
      //cerr << "at " << i << ", l = " << j << ", r = " << up << ", cur = " << cur << endl;
      udd(bon[j], cur);
      uub(bon[up], cur);
    }
  }

  //for (int i = 0; i < n; ++i)
    //cerr << i << " -> " << d[i] << endl;

  cout << d[n - 1] << endl;
}

int main() {
#ifdef LOCAL
  assert(freopen("c.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);
  
  read();
  kill();
}



Measured memory_bytes: 2304
/* 1_6_C.c */
/* Last Change: 2018/05/09 (Wed) 20:54:34. */

#include<stdio.h>
/* #include<stdlib.h> */
/* #include<string.h> */
/* #include<limits.h> */
/* #include<math.h> */
/* #include<time.h> */

int main(void){
	/* blabla */
	int n,x[4][3][10];
	int a,b,c,d;
	int i,j,k;
	for(i=0;i<4;i++)
		for(j=0;j<3;j++)
			for(k=0;k<10;k++)
				x[i][j][k]=0;
	scanf(" %d",&n);
	for(i=0;i<n;i++){
		scanf(" %d %d %d %d",&a,&b,&c,&d);
		x[a-1][b-1][c-1]+=d;
	}
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++)
				printf(" %d",x[i][j][k]);
			printf("\n");
		}
		printf("####################\n");
	}
	i=3;
		for(j=0;j<3;j++){
			for(k=0;k<10;k++)
				printf(" %d",x[i][j][k]);
			printf("\n");
		}
	return 0;
}




Measured memory_bytes: 2104
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
ll h,a;
int main(){
    cin>>h>>a;
    puts((h+a-1)/a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(a, n) for (int i = a; i < n; i++)
#define per(a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef double db;
const ll mod = 1000000007;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main() {
	int n;
	cin>>n;
	vector<int>v(n);
  vector<int> m(1000005);
  int g = 0;
  bool isCoprime = true;
  for (int i = 0; i < n; i++) {
      cin >> v[i];
      m[v[i]]++;
			if(m[v[i]]>1 && v[i]!=1){
				isCoprime = false;
			}
      if (g == 0) {
          g = v[i];
      } else {
          g = gcd(g, v[i]);
      }
	}
	if(isCoprime){
	vector<int>prime(1000005,true);
	prime[1] = false;
	for(int i=2;i<=1000000;i++){
		if(prime[i]){
			int cnt = 0;
			for(int j=i;j<=1000000;j+=i){
				prime[j] = false;
				if(m[j]){
					cnt ++;
				}
			}
      if (cnt > 1) {
				isCoprime = false;
      }
    }
	}
	}
	if(isCoprime){
        cout << "pairwise coprime";
    }
	else if(g == 1){
        cout << "setwise coprime";
    }
	else{
        cout << "not coprime";
    }
}

Measured memory_bytes: 14852
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int mod = 1e9 + 7;

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

/*-------------------------------------------*/
template <typename T> using mat = vector<vector<T>>;

int n;

template <typename T> mat<T> matmul(mat<T> &m1, mat<T> &m2) {
    mat<T> ret(n, vector<ll>(n, 0));
    rep(i, n) rep(j, n) rep(k, n)(ret[i][j] += m1[i][k] * m2[k][j]) %= mod;
    return ret;
}

template <typename T> mat<T> matpow(mat<T> &m, ll k) {
    mat<T> ret(n, vector<T>(n, 0));
    rep(i, n) ret[i][i] = 1;
    while(k > 0) {
        if(k & 1) ret = matmul(ret, m);
        m = matmul(m, m);
        k = k >> 1;
    }
    return ret;
}

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

    ll k;
    mat<ll> a;

    cin >> n >> k;
    a.assign(n, vector<ll>(n));

    rep(i, n) rep(j, n) cin >> a[i][j];

    a = matpow(a, k);

    ll ans = 0;
    rep(i, n) rep(j, n)(ans += a[i][j]) %= mod;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
// for(long long i = 0;i < num; i++){}
int main() {
    //
    double a, b, x;
    double theta;
    double pi = 3.1415926535;

    cin >> a >> b >> x;

    if (x > a * a * b / 2) {
        theta = atan(2 * (a * a * b - x) / (a * a * a));
    } else {
        theta = atan((a * b * b) / (2 * x));
    }

    theta *= 180 / pi;

    cout << setprecision(10) << theta;
    //
}


Measured memory_bytes: 4096
#include <stdio.h>

int main(){
  char a, b;
  scanf("%c %c", &a, &b);
  if(a == 'H'){
    if(b == 'H'){
      printf("H\n");
    }else if(b == 'D'){
      printf("D\n");
    }
  }else if(a == 'D'){
    if(b == 'H'){
      printf("D\n");
    }else if(b == 'D'){
      printf("H\n");
    }
  }
  return 0;
}


Measured memory_bytes: 128
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define M 1000000007
#define MAXN 100000

int m, n;
long a[MAXN], b[MAXN]; 

int input() {
	if (scanf("%d %d", &m, &n) < 0) return 0;
	for (int i=0; i<m; i++) scanf("%ld", &a[i]);
	for (int i=0; i<n; i++) scanf("%ld", &b[i]);
	return 1;
}

void init() {
}

long calc(long *a, int n) {
	n--;
	for (int i=0; i<n; i++)
		a[i] = a[i+1]-a[i];
	long s = 0, r = 0;
	for (int i=0; i<n; i++) {
		s += a[i] * (i+1);
		r += s;
		s %= M;
		r %= M;
	}
	return r;
}

long solve() {
	return calc(a, m) * calc(b, n) % M;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
 
using namespace std;

struct co{
	int x;
	int y;
	int d;
};

int mini(int p, int q){
	if( p > q ) return q;
	return p;
}

void push_q(int x, int y, vector< vector< bool > > *visited, queue< co > *q, vector< vector< bool > > *maze , int dist) {


	if( ( x < 0 ) || ( y < 0 ) )	return;
	if( y >= maze->size() )			return;
	if( x >= maze->at(y).size() )	return;
	if( maze->at(y).at(x) == true ) return;

	
	if ( visited->at(y).at(x) == false ) {
		co c;
		c.x = x;
		c.y = y;
		c.d = dist;
		visited->at(y).at(x) = true;
		q->push( c );
	}
}

//幅優先探索
int search_bfs(vector<vector<bool>> *visited, vector< vector<bool> > *maze, queue< co > *q , int w, int h){
	
	//if( x == 0 && y == 0 ) return depth;
	//x,yが範囲外の値かどうかチェック


	while( q->empty() == false ){
		co c;
		c = q->front();
		

		if( c.x == 0 && c.y == 0 ) return c.d;

		q -> pop();
		
		if( c.y % 2 == 0 ) {
			push_q(c.x + 1, c.y + 1, visited, q, maze, c.d + 1);
			push_q(c.x, c.y + 1, visited, q, maze, c.d + 1);
			push_q(c.x + 1, c.y - 1, visited, q, maze, c.d + 1);
			push_q(c.x, c.y - 1, visited, q, maze, c.d + 1);
			push_q(c.x, c.y + 2, visited, q, maze, c.d + 1);
			push_q(c.x, c.y - 2, visited, q, maze, c.d + 1);
		} else {
			push_q(c.x - 1, c.y + 1, visited, q, maze, c.d + 1);
			push_q(c.x, c.y + 1, visited, q, maze, c.d + 1);
			push_q(c.x - 1, c.y - 1, visited, q, maze, c.d + 1);
			push_q(c.x, c.y - 1, visited, q, maze, c.d + 1);
			push_q(c.x + 1, c.y, visited, q, maze, c.d + 1);
			push_q(c.x - 1, c.y, visited, q, maze, c.d + 1);
		}
	}

	return 0;
}


int main(void){
   //FILE* fp_in = freopen("data.txt", "r", stdin);
	
	while( 1 ) {
		//■■■■情報取得部分■■■■

		vector< vector< bool > > maze;
		int w, h;
		cin >> w >> h;
		if( w == 0 && h == 0 ) break;

		//最上段
		vector< bool > temp;
		for(int i = 0; i < w; i++) temp.push_back( true );
		maze.push_back( temp );

		//読み取り
		for(int i = 0; i < 2 * h - 1; i++) {
			vector< bool > newmaze;
			if( i % 2 == 0 ) {
				newmaze.push_back( true );
				for(int j = 0; j < w - 1; j++) {
					bool tmp;
					cin >> tmp;
					newmaze.push_back( tmp );
				}
				newmaze.push_back( true );
			} else {
				for(int j = 0; j < w; j++) {
					bool tmp;
					cin >> tmp;
					newmaze.push_back( tmp );
				}
			}
			maze.push_back( newmaze );
		}
	
		maze.push_back( temp );	//最下段
		maze.at( 0 ).at( 0 ) = false;
		maze.at( maze.size() - 1 ).at( maze.at( maze.size() - 1 ).size() - 1 ) = false;

		co c;
		c.y = maze.size() - 1;
		c.x = maze.at( maze.size() - 1 ).size() - 1;
		c.d = 0;
		queue< co > memo;
		memo.push( c );


		vector< vector< bool > > visited;
		for(int i = 0; i < maze.size(); i++) {
			vector< bool > visit;
			for(int j = 0; j < maze.at(i).size(); j++)
				visit.push_back(false);
			visited.push_back( visit );
		}

		visited.at(c.y).at(c.x) = true;
		

		cout << search_bfs(&visited, &maze, &memo, w, h) << endl;

	}


	//while(1){}
 
   return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e7+5;
ll f[N],n,ans;
int main(){
   for(int i=1;i<N;i++) for(int j=i;j<N;j+=i) f[j]++;
   cin>>n; for(int i=1;i<=n;i++) ans+=f[i]*i; cout<<ans;
}


Measured memory_bytes: 81720
# frozen_string_literal: true

def show(x)
  puts x
end

def solve(xs)
  n, a, b = xs
  range = (a..b)
  (1..n).reduce(0) do |a, i|
    s = i.to_s.chars.map(&:to_i).reduce(:+)
    a + (range.include?(s) ? i : 0)
  end
end

show solve gets.split.map(&:to_i)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int N=20,M=200000;
int a[N][N],f[M][N],g[M][N],n,m,x,y,z;
inline void read(int &x)
{
	char c=getchar();
	x=0;
	while (c>'9'||c<'0')
		c=getchar();
	while (c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
}
inline int work(int x,int y)
{
	int sum=0;
	for (int i=0;i<n;++i)
		if ((x>>i)&1)
			sum+=f[y][i];
	return sum;
}
int main()
{
	read(n);
	read(m);
	memset(g,0x3f,sizeof(g));
	for (int i=1;i<=m;++i)
	{
		read(x);
		read(y);
		read(z);
		--x;
		--y;
		a[x][y]=a[y][x]=z;
	}
	for (int i=0;i<(1<<n);++i)
		for (int j=0;j<n;++j)
			for (int k=0;k<n;++k)
				if ((i>>k)&1)
					f[i][j]+=a[j][k];
	g[1][0]=0;
	for (int i=0;i<(1<<n);++i)
		for (int j=0;j<n;++j)
			if ((i>>j)&1)
			{
				for (int k=0;k<n;++k)
					if (a[j][k]&&(!((i>>k)&1)))
						g[i|(1<<k)][k]=min(g[i|(1<<k)][k],g[i][j]+work(i,1<<k)-a[j][k]);
				int u=(1<<n)-1-i;
				for (int k=u;k;k=(k-1)&u)
					g[i|k][j]=min(g[i|k][j],g[i][j]+work(i^(1<<j),k));
			}
	printf("%d",g[(1<<n)-1][n-1]);
	return 0;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;

bool isPal(string s){
	string t=s;
	reverse(all(s));
	return s==t;	
}

string toString(int n){
	int r=n;
	string s="";
	while(r!=0){
		s+=r%10;
		r/=10;
	}
	return s;
}

void solve(){
	string s,t;
	cin>>s>>t;
	cout<<t+s;
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
x,y,z,k = map(int,input().split())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))
a_list.sort(reverse = True)
b_list.sort(reverse = True)
c_list.sort(reverse = True)
def check(p):
  count = 0
  for i in range(x):
    for j in range(y):
      for m in range(z):
        if a_list[i] + b_list[j] + c_list[m] < p:
          break
        count += 1
        if count >= k:
          return True
  return False

left = 1
right = 10**20
while right - left > 1:
  middle = (right + left)//2
  if check(middle) == True:
    left = middle
  else:
    right = middle
ans_list = []
for i in range(x):
    for j in range(y):
      for m in range(z):
        if a_list[i] + b_list[j] + c_list[m] < left +1:
          break
        elif a_list[i] + b_list[j] + c_list[m] >= left+1:
          ans_list.append(a_list[i] + b_list[j] + c_list[m])
nokori = k - len(ans_list)
for i in range(nokori):
  ans_list.append(left)
  
ans_list.sort(reverse = True)
for ans in ans_list:
  print(ans)
          


Measured memory_bytes: 49628
#include<iostream>
using namespace std;
#include<vector>
#include<cmath>
#include<set>
#define int long long int
const int maxn=21;
int bs(int start,int end,int n,int m)
{
	if(start>end)
	  return -1;
    else
    {
		int p=n;
		int q=m;
		int mid=(start+end)/2;
		if(p>=mid)
		{
			if(q>=2*mid)
			{
				int val=mid;
				int val2=bs(mid+1,end,n,m);
				if(val2==-1)
				  return val;
				else
				  return val2;
			}
			else
			{
				return bs(start,mid-1,n,m);
			}
		}
		else
		{
			int k=mid-p;
			if(q>=2*k)
			{
				q-=2*k;
				if(q>=2*mid)
				{
					int val=mid;
					int val2=bs(mid+1,end,n,m);
					if(val2==-1)
					  return val;
					else
					  return val2;
				}
				else
				{
					return bs(start,mid-1,n,m);
				}
			}
			else
			{
				return bs(start,mid-1,n,m);
			}
		}
	}
}
int32_t main()
{
   int n,m;
   cin>>n>>m;
   int answer=bs(0,1000000000000,n,m);
   cout<<answer<<endl;
}


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

using namespace std;

const int MAXN = 1e5 + 1;
char S[MAXN];

int main() {
    cin >> S;
    int N = strlen(S);
    
    int a = 0, b = 0;
    for (int i=0; i < N; ++i) {
        if ((S[i] == '0' && i%2 == 0) || (S[i] == '1' && i%2)) {
            a++;
        }
        
        if ((S[i] == '0' && i%2) || (S[i] == '1' && i%2 == 0)) {
            b++;
        }
    }
    
    cout << min(N-a, N-b) << endl;
    
    return 0;
}


Measured memory_bytes: 384
from sys import stdin, stdout
def readLine_str_list():return list(map(str, stdin.readline().split()))
def main():
    s = readLine_str_list()
    if s[1]=="+":
        print(int(s[0]) + int(s[2]))
    else:
        print(int(s[0]) - int(s[2]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
    char str[4];
    int cnt = 0, max = 0, i;
    scanf("%s", str);
    for(i = 0; i <= 2; i++) {
        if(str[i] == 'R') {
            cnt++;
            if(cnt > max) max = cnt;
        }
        else cnt = 0;
    }

    printf("%d", max);
}

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

int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		
		for(int i=0; i<9; i++){
			int a;
			cin >> a;
			n -= a;
		}
		cout << n << endl;
	}
	return 0;
}



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

using namespace std;


int main(){


	int X;
	cin >> X;

	int b,p;

	b = 2;
	p = 2;

	int max = 1;

   if(X <= 3){
	 cout << max << endl;
	 return 0;
   }


  while(true){
	if(pow(b,p) > X){
		break;
	}
	while(pow(b,p) <= X){
    	  if(pow(b,p)>=max){
    		 max = pow(b,p);
	      }
    	 p++;
	}
      b++;
      p = 2;
  }

   cout << max << endl;


    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	long long n, k;
	long long amari, min;

	scanf("%lld %lld", &n, &k);

	amari = n % k;
	min = (amari < k - amari) ? amari : k - amari;

	printf("%lld", min);
	return 0;
}


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

int main() {

  int A, B;
  cin >> A >> B;
  
  int count = 0;
  for (int i = A; i <= B; i++) {
    int _a, _b, _c, _d;
    
    _a = i % 10;
    _b = i / 10000 % 10;

    _c = i / 10 % 10;
    _d = i / 1000 % 10;

    if (_a == _b && _c == _d) {
      count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 998244353
#define maxn 300010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
struct Data{
	ll k,b;
	friend Data operator * (Data a,Data b){return (Data){a.k*b.k%mod,(a.k*b.b+a.b)%mod};}
	friend int operator * (Data a,int b){return (a.k*b+a.b)%mod;}
}a1[maxn],pre1[maxn],a2[maxn],pre2[maxn];
char s[maxn];
int n,m;
ll power(ll a,ll b)
{
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ans=ans*a%mod;
	return ans;
}
const ll base1=233,inv1=power(base1,mod-2),base2=666,inv2=power(base2,mod-2);
std::map<std::pair<int,int>,int>cnt;
int main()
{
	n=read();
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
		if(s[i]=='<')a1[i]=(Data){inv1,0},a2[i]=(Data){inv2,0};
		else if(s[i]=='>')a1[i]=(Data){base1,0},a2[i]=(Data){base2,0};
		else if(s[i]=='+')a1[i]=a2[i]=(Data){1,1};
		else a1[i]=a2[i]=(Data){1,mod-1};
	ll val1=0,val2=0;
	for(int i=n;i;i--){
		val1=a1[i]*val1;
		val2=a2[i]*val2;
	}
	pre1[0]=pre2[0]=(Data){1,0};
	for(int i=1;i<=n;i++){
		pre1[i]=pre1[i-1]*a1[i];
		pre2[i]=pre2[i-1]*a2[i];
	}
	ll ans=0;
	++cnt[std::make_pair(val1,val2)];
	for(int i=1;i<=n;i++){
		ll goal1=pre1[i].b,cur1=pre1[i]*val1,goal2=pre2[i].b,cur2=pre2[i]*val2;
		if(cnt.count(std::make_pair(goal1,goal2)))ans+=cnt[std::make_pair(goal1,goal2)];
		++cnt[std::make_pair(cur1,cur2)];
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 34304
import java.util.*;
class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        long x = sc.nextInt();
        
        long power1000 = 0;
        long power5 = 0;
        
        power1000 = x/500;
        power5 = (x%500)/5;
        
        System.out.println(1000*power1000+5*power5);
    }
}

Measured memory_bytes: 23892
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: 4-adjacent
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int f0 = 0, f1 = 0, f2 = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    if ((ai & 3) == 0) f2++;
    else if ((ai & 1) == 0) f1++;
    else f0++;
  }

  if (f1 > 0) {
    if (f2 >= f0) puts("Yes");
    else puts("No");
  }
  else {
    if (f2 >= f0 - 1) puts("Yes");
    else puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

int n;
int a[200200];

int main() {
	scanf("%d", &n);
	FOR(i,n) {
		scanf("%d", &a[i]);
		a[i] -= i;
		a[i] += n;
		if (i > 0 && a[i] > a[i-1]) {
			printf("-1\n");
			return 0;
		}
	}
	if (a[0] != n) {
		printf("-1\n");
		return 0;
	}
	ll res = 0;
	a[n] = -1;
	FOR(i,n) {
		if (a[i] != a[i+1]) {
			res += i - (n-a[i]);
		}
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner
import kotlin.system.exitProcess

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val h = scn.nextLong()
	val w = scn.nextLong()
	if (h==1L || w==1L) {
		println(1)
		exitProcess(0)
	}
	var ans = w*(h/2)
	if (h%2!=0L) ans += (w+1)/2
	println(ans)
}

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

int main() {
  int A,B,C,D;cin>>A>>B>>C>>D;
  cout << max(A*B,C*D) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define mp make_pair
using namespace std;
const int MX = 1e5+5;
string s;
int n,pR[MX],pL[MX],ans[MX];
int main(){
    cin >> s;
    memset(ans,0,sizeof(ans));
    n = s.length();
    int idx = 0;
    for(int i=1 ; i<n ; ++i){
        if(s[i] == 'R')
            idx = i;
        else
            pL[i] = idx;
    }
    idx = n-1;
    for(int i=n-2 ; i>=0 ; --i){
        if(s[i] == 'L')
            idx = i;
        else
            pR[i] = idx;
    }
    for(int i=0 ; i<n ; ++i){
        if(s[i] == 'R'){
            int d = pR[i]-i-1;
            if(d&1)
                ans[pR[i]]++;
            else
                ans[pR[i]-1]++;
        }else{
            int d = i-pL[i]+1;
            if(d&1)
                ans[pL[i]]++;
            else
                ans[pL[i]+1]++;
        }
    }
    for(int i=0 ; i<n ; ++i)
        cout << ans[i] << " ";
    puts("");
}

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

using namespace std;

using ll=long long;

void solve() {
    string s; cin >> s;
    ll K; cin >> K;
    ll cnt = 0;
    int n = s.size();
    bool all_same = true;
    for (int i = 1; i < n; i++) {
        all_same &= s[i] == s[0];
        if (s[i] != s[i-1]) continue;
        cnt++; i++;
    }
    if (all_same) {
        ll res = (n*K)/2;
        cout << res; return;
    }
    ll res = cnt*K;
    if (s[0] == s[n-1]) {
        int a = 0, b = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] != s[0]) break;
            a++;
        }
        for (int i = n-1; i >= 0; i--) {
            if (s[i] != s[n-1]) break;
            b++;
        }
        if ((a&1) && (b&1)) res += K-1;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256