akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <queue>
#include <unordered_set>                // 0. include the library
#include <atomic>
#include <array>

using namespace std;

int main(){
    string str;
    cin >> str;
    int l = str.length() - 1;
    if('s' != str[l]){
        str.push_back('s');
    }
    else{
        str.push_back('e');
        str.push_back('s');
    }

    cout << str << endl;

    return (0);
}

Measured memory_bytes: 3044
def eratosthenes(N):
    is_prime = {i: True for i in range(2, N+1)}
    primes = []
    for i in range(2, N+1):
        if is_prime[i]:
            primes.append(i)
            if i**2 <= N:
                for j in range(i**2, N+1, i):
                    is_prime[j] = False
    return primes


def main():
    X = int(input())
    primes = eratosthenes(100010)
    ans = 0
    for p in primes:
        if p >= X:
            print(p)
            break


if __name__ == "__main__":
    main()


Measured memory_bytes: 48880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
ll qpow(ll x,ll y){
	ll base=x,ans=1;
	while(y>0){
		if(1&y) ans*=base;
		base*=base;
		y>>=1;
	}
	return ans;
}
int main(){
	ll n;
	cin>>n;
	cout<<qpow(2,int(log(n)/log(2))+1)-1<<endl;
	return 0;
}

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

int main() {
    int N;
    string S;
    cin >> S;
    N = int(S.size());
    
    stack<int> rem;
    //rem.push(S[0]);
    int cnt = 0;
    rep(i, N) {
        while(!rem.empty()) {
            if(i == N) break;
            if(rem.top() != S[i]) {
                i++;
                cnt += 2;
                rem.pop();
            } else {
                break;
            }
        }
        if(i != N) rem.push(S[i]);
    }    

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int W;
  cin >> W;
  long long int A[W], INF = 100000000000LL;
  for(int i = 0; i < W; ++i)
    cin >> A[i];
  
  vector<int> E;
  for(int i = 0; i < W; ++i){
    if(!A[i]) E.push_back(i);
  }

  int N = (int)E.size();
  long long int s, t;
  vector<long long int> ans(W,0LL);
  for(int i = 1; i < N; ++i){
    s = E[i-1], t = INF;
    for(int j = E[i-1]+1; j < E[i]; ++j){
      if(A[j] < 0){
	if(-A[j]-s+(long long int)j < t){
	  t = -A[j];
	  s = j;
	}
      }else{
	ans[j] = max(ans[j],min(A[j],t-j+s));
      }
    }
  }

  for(int i = N-2; i >= 0; --i){
    s = E[i+1], t = INF;
    for(int j = E[i+1]-1; j > E[i]; --j){
      if(A[j] < 0){
	if(-A[j]+s-j < t){
	  t = -A[j];
	  s = j;
	}
      }else{
	ans[j] = max(ans[j],min(A[j],t+j-s));
      }
    }
  }
  if(N){
    s = E[N-1]+1;
    t = INF;
    for(int i = E[N-1]+1; i < W; ++i){
      if(A[i] < 0){
	if(-A[i]-s+i < t){
	  //cout << s << " " << t << endl;
	  t = -A[i];
	  s = i;
	}
      }else{
	ans[i] = max(ans[i],min(A[i],t-i+s));
      }
    }
    s = E[0]-1;
    t = INF;
    for(int i = E[0]-1; i >= 0; --i){
      if(A[i] < 0){
	if(-A[i]+s-i < t){
	  //cout << s << " " << t << endl;
	  t = -A[i];
	  s = i;
	}
      }else{
	ans[i] = max(ans[i],min(A[i],t+i-s));
      }
    }
  }
  long long int sum = 0LL; 

  for(int i = 0; i < W; ++i){
    sum += (long long int)ans[i];
    //cout << ans[i] << " ";
  }
  //cout << endl;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second
 
ll mod = 1e9+7;
 
ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}

int main() {
	ll ttt;
	//cin>>ttt;
	ttt = 1;
	while(ttt--) {
		ld d,t,s; cin>>d>>t>>s;
		ld x = d/s;
		if(x>t) cout<<"No";
		else cout<<"Yes";
	}
	return 0;
}


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

void chmax(int& a, int b) { 
  if (a < b) a = b;
}

void chmin(int& a, int b) {
  if (a > b) a = b;
}

int main() {
  int N, M;
  cin >> N >> M;
  int L = 1;
  int R = N;
  
  for (int i = 0; i < M; i++) {
    int l, r;
    cin >> l >> r;
    
    chmax(L, l);
    chmin(R, r);
  }
  
  if (L > R) {
    cout << 0 << endl;
  } else {
    cout << R - L + 1 << endl;
  }
}

Measured memory_bytes: 256
//om namah shivaaay//
#include <bits/stdc++.h>
#define input int t;cin>>t;while(t--)
#define Om_namah_Shivaay ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout.precision(10)
 #define ll long long
 #define vi  vector<int>
 #define pb push_back
 #define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
 #define f(i, a, b) for (int i = 0; i < (b); i++)
 #define w(t) int t;cin>>t;while(t --)
#define fr(i, a, b) for (int i = (a); i >= (b); i--)
 const int N=1e5 +5;
 using namespace std;
 int main()
 {
    Om_namah_Shivaay;
    ll d,t,s;
    cin>>d>>t>>s;;
    if(t*s>=d)
    cout<<"Yes";
    else
    cout<<"No";
}


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

using namespace std;
#define ll long long
#define M 1000000007
vector<ll>a(100001,0),b(100001,0),c(100001,0);


int main()
{
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        ll q,w,e;
        cin>>q>>w>>e;
        a[i]=q,b[i]=w,c[i]=e;
    }
    vector<ll>dpa(n+1),dpb(n+1),dpc(n+1);
    dpa[n]=a[n];
    dpb[n]=b[n];
    dpc[n]=c[n];
    for(ll i=n-1;i>=0;i--)
    {
        dpa[i]=max(dpb[i+1],dpc[i+1])+a[i];
        dpb[i]=max(dpa[i+1],dpc[i+1])+b[i];
        dpc[i]=max(dpa[i+1],dpb[i+1])+c[i];
    }
    cout<<max(dpa[1],max(dpb[1],dpc[1]));
}

Measured memory_bytes: 4992
#include <stdio.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(int i=a;i<n;i++)
void fill(int a[],int b,int c){
    for(int i=0;i<b;i++) a[i]=c;
 	return;
}
int main(void){
    ll n,m;
    ll res=0;
    scanf("%lld %lld",&n,&m);
    if(n<m/2) res = n+(m-n*2)/4;
    else res = m/2;
    printf("%lld\n",res);
 	return 0;
}


Measured memory_bytes: 128
import sys

N = int(input())

def solve(i):
    if i % 2 != 0:
        return 0
    else:
        return 1 + solve(i // 2)

if N == 1:
    print(1)
    sys.exit()

box = []
for k in range(1, N+1):
    box.append(solve(k))
mb = max(box)
for i in range(1, N+1):
    if box[i] == mb:
        print(i+1)
        break

Measured memory_bytes: 3064
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}


fun solve(out: PrintWriter) {
    val (n, k) = readIntegerList()
    var ans = 0.0
    for (i in 1..n) {
        var p = 0
        var cur = i
        while (cur < k) {
            cur *= 2
            p++
        }
        ans += Math.pow(0.5, p.toDouble())
    }
    println(ans / n)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 35948
///                                                     ببِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define vec  vector
#define gcd  __gcd
#define pi   acos( -1 )
#define ll   long long
#define ld   long double
#define N    300256
#define M    1000000007
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define rep( a, b, c, d )  for( int a = b; a <= c; a += d )
#define rvv( a, b, c, d )  for( int a = b; a >= c; a -= d )
#define en                 printf( "\n" )
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() )
#define numcounts          __builtin_popcount
#define mxn( x, y, z )     max( x, min( y, z ) )
#define mnx( x, y, z )     min( x, max( y, z ) )
const int dx[ ] = { 1, -1, 0, 0 };
const int dy[ ] = { 0, 0, -1, 1 };
using namespace std;
ll ttt = 1;
int n, k, a, b, c, dp[N][5];
void solve()
{
    cin >> n;
    for( int i = 1; i <= n; i ++ )
    {
        cin >> a >> b >> c;
        dp[i][0] = dp[i][1] = dp[i][2] = 0;
        dp[i][0] = max( dp[i][0], dp[i-1][1] + a);
        dp[i][0] = max( dp[i][0], dp[i-1][2] + a);
        dp[i][1] = max( dp[i][1], dp[i-1][0] + b);
        dp[i][1] = max( dp[i][1], dp[i-1][2] + b);
        dp[i][2] = max( dp[i][2], dp[i-1][0] + c);
        dp[i][2] = max( dp[i][2], dp[i-1][1] + c);
    }
    cout << max( dp[n][0], max(dp[n][1], dp[n][2]) );
}
int main()
{
    //sc( "%I64d", &ttt );
    for( int i = 0; i < ttt; i ++ )
        solve();
}














Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> v(N);
  int ans=0;
  while(N--){
    int a;cin>>a;
    if(a>=K)ans++;
  }
  fin(ans);

}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> pos(n);
    for (int i = 0; i < n - 1; i++) {
        pos[i] = (s[i] == 'A' && s[i + 1] == 'C');
    }
    pos[n - 1] = 0;
    vector<int> sum(n);
    partial_sum(pos.begin(), pos.end(), sum.begin());
    while (q--) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        if (r - l < 0) {
            cout << 0 << '\n';
            continue;
        }
        cout << sum[r] - (l - 1 < 0 ? 0 : sum[l - 1]) - (pos[r] == 1) << '\n';
    }
    return 0;
}


Measured memory_bytes: 1872
N, A, B = map(int, input().split())

if N == 1 and A == B:
    print(1)
    exit()
elif N == A == B:
    print(1)
    exit()

if A >= B:
    print(0)
    exit()
elif N == 1 and A != B:
    print(0)
    exit()

digit = N - 1
min_calc = A*digit + B
max_calc = A + B*digit
ans = max_calc - min_calc + 1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  int H,W,h,w;

  while (1){
    scanf("%d %d",&H,&W);

    if (H == 0 && W == 0){
      break;
    }

    for (h = 1; h <= H; h++) {
      for (w = 1; w <= W; w++)
	putchar('#');
      putchar('\n');
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 576
S = input()

A = [1 if i % 2 == 0 else 0 for i in range(len(S))]
B = [1 if i % 2 != 0 else 0 for i in range(len(S))]

A_cost = 0
B_cost = 0

i = 0

for i in range(len(S)):
    if int(S[i]) != A[i]:
        A_cost += 1
    if int(S[i]) != B[i]:
        B_cost += 1

print(min(A_cost,B_cost))

Measured memory_bytes: 10736
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(std::string s){
    REP(i, s.size()) {
        if (s[i] == ',') cout << ' ';
        else cout << s[i];
    }
    cout << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    int[] dp = new int[100001];
    int X = 0;

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        X = scanner.nextInt();

        // 初期条件
        dp[0] = 0;

        // ループ
        d(0);

        System.out.println(dp[X]);
    }

    private boolean d(int i) {
        if (i > X) {
            return false;
        }

        if(dp[i] == 1) return false;

        if (i != 0) {
            dp[i] = 1;
        }

        d(i + 105);
        d(i + 104);
        d(i + 103);
        d(i + 102);
        d(i + 101);
        d(i + 100);

        return false;
    }


}

Measured memory_bytes: 23892
#include<stdio.h>

int main(void){
	
	int W,H,x,y,r;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(0<=x-r && x+r<=W){
		if(0<=y-r && y+r<=H){
			printf("Yes\n");
		}
		else{
		printf("No\n");
		}
	}
	
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
#sA = sum(As)
#sB = sum(Bs)
#if sA < sB:
#  print(-1)
#  exit()
Ds1 = [Bs[i]-As[i] for i in range(N) if As[i] < Bs[i]]
Ds2 = sorted([As[i]-Bs[i] for i in range(N) if As[i] > Bs[i]], reverse=True)
#print(Ds1, Ds2)
r = len(Ds1)
d = sum(Ds1)
for D in Ds2:
  if d <= 0:
    break
  d -= D
  r += 1
if d <= 0:
  print(r)
else:
  print(-1)


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

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

int main() {
	int n,m;cin>>n>>m;
	
	int a[n],tmp;
	rep(i,n)a[i]=0;
	rep(i,m){
	    cin>>tmp;
	    a[tmp-1]++;
	    cin>>tmp;
	    a[tmp-1]++;
	}
	rep(i,n)cout<<a[i]<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  ll K;
  cin>>S>>K;
  if(S.size()==1) {
    cout<<K/2<<endl;
    return 0;
  }
  ll ans = 0;
  if(S[0]!=S[S.size()-1]) {
    for(int i=0;i<S.size()-1;++i) {
      if(S[i]==S[i+1]) {
        ans++;
        i++;
      }
    }
    cout<<ans*K<<endl;
    return 0;
  }
  bool haji1 = false, haji2 = false;
  ll ans1 = 1, ans2 = 0;
  for(int i=1;i<S.size()-1;++i) {
    if(S[i]==S[i+1]) {
      if(i+1==S.size()-1) haji1 = true;
      ans1++;
      i++;
    }
  }
  for(int i=0;i<S.size()-1;++i) {
    if(S[i]==S[i+1]) {
      if(i+1==S.size()-1) haji2 = true;
      ans2++;
      i++;
    }
  }
  if(haji1 && haji2) {
    cout<<ans2*K<<endl;
  }
  else if(haji1 && !haji2) {
    cout<<ans2*((K+1)/2)+ans1*(K/2)<<endl;
  }
  else if(!haji1 && haji2) {
    cout<<ans2*K<<endl;
  }
  else {
    cout<<ans2+ans1*(K-1)<<endl;
  }
}


Measured memory_bytes: 3600
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2*1e5;
const ll M = 1e9+7;
int n, k;
vector<ll> po, ne;
int main(void)
{
	scanf("%d %d", &n, &k);

	for(int i=0; i < n ; ++i) 
	{
		ll in;
		scanf("%lld", &in);
		if(in >= 0) po.push_back(in);
		else ne.push_back(in);
	}
	if(n==k){
		ll cur = 1;
		for(auto i : po) cur = (cur*i)%M;
		for(auto i : ne) cur = (cur*i)%M;
		while(cur < 0) cur += M;
		cout << cur;
		return 0;
	}
	sort(po.begin(), po.end(), greater<ll>());
	sort(ne.begin(), ne.end());
	int sz_n = (int)ne.size(), sz_p = (int)po.size();
	int p_idx=k-1, n_idx=0;
	if(sz_p == 0)
	{
		ll cur = 1;
		if(k%2==0)
		{
			for(int i= 0 ; i < k ; ++i) cur = (cur*ne[i])%M;
			while(cur < 0) cur += M;
			cout << cur;
			return 0;
		}
		for(int i = sz_n-1; i >= sz_n-k ; --i) cur = (cur*ne[i])%M;
		while(cur < 0) cur += M;
		cout << cur;
		return 0;
	}
	if(k > sz_p)
	{
		p_idx = sz_p-1;
		n_idx = k-sz_p;
		if(n_idx%2)
		{
			++n_idx;
			--p_idx;
		}
	}
	for(int i = n_idx ; i < sz_n-1 ; i=i+2)
	{
		if(p_idx <= 0) break;
		if(ne[i]*ne[i+1] > po[p_idx]*po[p_idx-1])
		{
			n_idx += 2;
			p_idx -= 2;
		}
		else break;
	}
	ll cur = 1;
	for(int i = 0 ; i<=p_idx ; ++i) cur = (cur*po[i])%M;
	for(int i = 0 ; i<n_idx ; ++i) cur = (cur*ne[i])%M;
	while(cur < 0) cur += M;
	cout << cur;
	return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  string s; cin >> s;
  int n = s.size();
  int p1 = n / 2;
  int p2 = count(s.begin(), s.end(), 'p');
  int ans = p1 - p2;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
n, m = map(int, input().split())
p, y = zip(*[map(int, input().split()) for _ in range(m)])

city_data = {}
for i in range(m):
    city_data[i] = [p[i], y[i], None]

cities = list(city_data.keys())
cities.sort(key=lambda city: city_data[city])

pref = None
for city in cities:
    if city_data[city][0] == pref:
        yidx += 1
    else:
        yidx = 1
        pref = city_data[city][0]
    city_data[city][2] = '{:06d}{:06d}'.format(pref, yidx)

for i in range(m):
    print(city_data[i][2])


Measured memory_bytes: 61152
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int read(){
    int 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;
}
int a[20];
int n;
int main(){
	int n=read(),x;
	int sz=0;
	for(int i=1;i<=n;i++){
		x=read();
		if(x>=3200){
			sz++;continue;
		}
		a[x/400]++;
	}
	int cnt=0;
	for(int i=0;i<=8;i++){
		if(a[i])cnt++;
	}
	int ans1=max(cnt,sz?1:0);
	int ans2=cnt+sz;
	printf("%d %d\n",ans1,ans2);
	return 0;
}

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

typedef long long ll;

int main() {
    int n,k;
    cin >> n >> k;
    ll a[n];
    vector<ll> b;
    for (int i = 0;i < n;++i) cin >> a[i];

    ll sum = 0;
    for (int i = 0;i < n;++i) {
        sum = 0;
        for (int j = i;j < n;++j) {
            sum += a[j];
            b.push_back(sum);
        }
    }

    ll ret = 0;
    vector<bool> ans(n*(n+1)/2,true);
    for (int i = 41;i > 0;--i) {
        ll T = (1LL << i);
        for (int j = 0;j < n*(n+1)/2;++j) b[j] %= T;
        int cnt = 0;
        vector<bool> temp(n*(n+1)/2,true);
        for (int j = 0;j < n*(n+1)/2;++j) if (b[j] >= T >> 1 && ans[j]) cnt++;

        if (cnt >= k) {
            for (int j = 0;j < n*(n+1)/2;++j) if (b[j] < T >> 1) ans[j] = false;
            ret += T >> 1;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 6512
s = input()

l = len(s)
ans = 0

for i in range(1 if l % 2 else 2, l, 2):
    t = s[:-i]
    tl = (l-i)//2

    if t[:tl] == t[tl:]:
        ans = tl*2
        break


print(ans)


Measured memory_bytes: 8936
#include <iostream>
#include <math.h> 

using namespace std;

int main() 
{
    int x,y,z,i;
    cin>>i;
    x=floor(i/(3600));
    y=floor((i-x*3600)/60);
    z=i-x*3600-y*60;

    cout<<x<<":"<<y<<":"<<z<<endl;
}


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

int main() {
  string s;
cin>>s;
 int b=s.size();
char a;
  for(int i=0;i<b;i++){
  a=s.at(i);
    if(a=='D'||a=='?'){cout<<'D';}
    if(a=='P'){cout<<'P';}
    
  }
cout<<endl;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define endl "\n"
#define rep(i,n) for(int i=0;i<=n;i++)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;


int main(){
    fast;
    string s;
    cin >> s;
    int n = s.size();
    if(s[n-1]=='s'){
        s.push_back('e');
        s.push_back('s');
    }
    else s.push_back('s');
    cout << s;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int n; cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    int maxv = 0;
    map<string, int> mp;
    vector<string> ans;
    rep(i, n) { mp[s[i]]++; chmax(maxv, mp[s[i]]); }
    for(auto itr=mp.begin(); itr!=mp.end(); ++itr) {
        if(itr->second == maxv) ans.push_back(itr->first);
    }
    sort(ans.begin(), ans.end());
    for(auto s: ans) cout << s << endl;

    
    return 0;
}

Measured memory_bytes: 27120
N,M = map(int,input().split())
bridge=[]
for i in range(M) :
    array =list(map(int,input().split()))
    bridge.append(array)
bridge =  (sorted(bridge,key=lambda x : x[1]))
result = 0
B = 0

for i in range(M):
    a, b = bridge[i]
    if a>=B :
        B=b
        result+=1

print(result)

Measured memory_bytes: 29840
import java.util.*;
public class Main {
    public static void main(String args[]) {
     Scanner s=new Scanner(System.in);
    
    	int n=s.nextInt();
    	int w=s.nextInt();
    	int arr[][]=new int[n+1][3];
    	for(int i=1;i<=n;i++) {
    		for(int j=1;j<=2;j++) {
    		 arr[i][j]=s.nextInt(); // w v
    		                        //1   2
    		}
    	}
    	int maxval=n*1000;
    	long dp[][]=new long[n+1][maxval+1];
    	
    	for(int i=0;i<=maxval;i++) {
    		dp[1][i]=Integer.MAX_VALUE;
    	}
    	
    	dp[1][0]=0;
    	dp[1][arr[1][2]]=arr[1][1];
    	
    	for(int i=2;i<=n;i++) {
    		for(int v=0;v<=maxval;v++) {
    			dp[i][v]=dp[i-1][v];
    			if(arr[i][2]>v) {
    				continue;
    			}
    			dp[i][v]=Math.min(arr[i][1] + dp[i-1][v-arr[i][2]],dp[i][v]);
    		   
    		}
    	 }
    	long ans=0;
    	for(int i=0;i<=maxval;i++) {
    		
    			if(dp[n][i]<=w) {
    				ans=i;
    			}
    		
    	}
    	System.out.println(ans);
    	
    }
}

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

ll f(ll n) { return n*(n+1)/2;}

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ll r = n/i;
        ans += f(r)*i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
#include <iostream>
//#include <boost/math/common_factor.hpp>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define all(x) x.begin(), x.end()
#define reg(i,x) for(ll i=0;i<x;i++)
#define regi(i,a,x) for(ll i=a;i<x;i++)
#define rev(i,n) for(ll i=n-1;i>0;i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
//const ll INF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a*b)/gcd(a,b);
}
ll MAXN=10e9;
int main()
{
    string s;
    cin>>s;
    vi v;
    int cnt=0;
    v.pb(0);
    reg(i,s.size())
    {
        if(s[i]=='R') cnt++;
        else
        {
            if(cnt!=0) v.pb(cnt);
            cnt=0;
        }
    }
    if(cnt!=0) v.pb(cnt);
    cout<<*max_element(all(v))<<endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    for (int i = 0; i < k; i++) {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
import math
a,b,h,m = map(int,input().split())
h_ = 360/12*h + 360/(12*60)*m
m_ = 360/60*m
an = abs(h_-m_) if abs(h_-m_) <= 180 else 360 - abs(h_-m_)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(an))))


Measured memory_bytes: 9512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  rep(i, 3) {
    if (s[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int x[60];
long long f[60][2510];

int main(){
	int n, A;
	scanf("%d%d", &n, &A);
	for (int i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}
	f[0][0] = 1;
	for (int i = 0; i < n; i++){
		for (int j = n; j >= 1; j--){
			for (int k = 2500; k >= x[i]; k--){
				f[j][k] += f[j - 1][k - x[i]];
			}
		}
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++){
		ans += f[i][i * A];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a == b) System.out.println("a == b");
            else if (a > b) System.out.println("a > b");
            else System.out.println("a < b");
		}
	}
}


Measured memory_bytes: 26172
#include <bits/stdc++.h>
using namespace std;
//#pragma comment(linker, ”/STACK:36777216“)

typedef long long ll;
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db long double

int n;

int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output1.txt", "w", stdout);
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	ll ans = 0;
	int last = 0;
	while(a.size()){
		last = max(0, last - 1);
		if (a.back() < last) cout << -1, exit(0);
		if (a.back() != last) ans += a.back();
		last = a.back();
		a.pop_back();
	}
	if (last != 0) cout << -1, exit(0);
	cout << ans;
}

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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const LL MAX = 1e18;
LL X, Y;

void MAIN() {
    scanf("%lld%lld", &X, &Y);
    if (X % Y == 0) {
	puts("-1");
    } else {
	printf("%lld\n", X);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
import heapq

def main():
    N, M = map(int, input().split())
    A = [-v for v in list(map(int, input().split()))]
    heapq.heapify(A)
    for _ in range(M):
        v = heapq.heappop(A)
        heapq.heappush(A, v / 2)
    print(sum([int(-v) for v in A]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 92360
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int n;
int inds[114514];
vi a;
int main(){
	cin>>n;
	rep(i,n){
		int x;
		cin>>x;
		a.pb(x);
	}
	vi ans;
	int sz=0;
	rep(i,n){
		int sz=ans.size();
		if(sz==0){
			ans.pb(a[i]);
		}else{
			int mi=ans[sz-1];
			if(mi>=a[i]){
				ans.pb(a[i]);
			}else if(a[i]>ans[0]){
				ans[0]=a[i];
			}else{
				
				int ng=0,ok=sz-1;
				while(ok-ng>1){//自分より小さい最大の部分探索
					int mid=(ok+ng)/2;
					if(ans[mid]<a[i])ok=mid;
					else ng=mid;
				}
				ans[ok]=a[i];
			}
			
		}
	}
	cout<<ans.size()<<endl;
}

Measured memory_bytes: 1528
n,m=list(map(int,input().split()))
if n%2==0:
    for i in range(1,(m+1)//2+1):
        print(i+n//2,n-i+1)
    for i in range(1,m//2+1):
        print(i+1,n//2+1-i)
else:
    for i in range(1,m+1):
        print(i,n-i)


Measured memory_bytes: 9196
/*;

THE BEST IS YET TO COME

*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i, s, l) for (int i = s; i < l; i++)
#define rr(i, s, l) for (int i = s; i >= l; i--)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<int, int>
#define ss second
#define ff first
#define INF 1e18
#define N 2000005
#define all(a) a.begin(), a.end()
#define pb push_back
#define vi vector<int>
#define vip vector<pair<int, int>>
#define endl "\n"
#define ln length()
#define sz size()
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

signed main()
{

    fast();
    int n;
    unordered_map<string,int> mp;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        mp[s]++;
    }

    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    

    return 0;
}

Measured memory_bytes: 3660
N = int(input())
_A1 = [int(x) for x in input().split()]
_A2 = [int(x) for x in input().split()]


A1 = [0] * (N)
A2 = [0] * (N)

for i in range(0, N):
    if i == 0:
        A1[i] = _A1[i]
        A2[i] = _A2[i]
    else:
        A1[i] = A1[i - 1] + _A1[i]
        A2[i] = A2[i - 1] + _A2[i]

sum = 0

for i in range(0, N):
    u = A1[i]
    if i == 0:
        d = A2[N - 1]
    else:
        d = A2[N - 1] - A2[i-1]
    sum = max(u+d, sum)

print(sum)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
    int main() {
      string t;
      cin >> t;
      int x = t.size() - 1;
      int y = t.size() - 2;
      cout << t[0] << y << t[x] << endl;
      
	}

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

int main() {
  int h,w,n;
  cin>>h>>w>>n;
  
  int k=max(h,w);
  int a;
  
  if(n%k>0) a=n/k+1;
  else a=n/k;
  
  cout << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second     
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define repr(i,a,b)      for(int i=b-1;i>=a;i--)
#define trav(it,v)      for(auto it=v.begin();it!=v.end();it++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000009
#define bs            binary_search
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN          1000000000000000000

using namespace std;

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 


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

int power(int x, unsigned int y)  
{  
    int p=M;
    int res = 1;
    x = x % p; 
    if (x == 0) return 0; 
  
    while (y > 0)  
    {   
        if (y & 1)  
            res = (res*x) % p;  
  
         
        y = y>>1;   
        x = (x*x) % p;  
    }  
    return res;  
} 

void solve()
{
    int n;
    cin>>n;
    int a[n+1];
    a[0]=0;
    rep(i,1,n+1)
    cin>>a[i];
    int dp[n+1];
    dp[1]=0;dp[0]=0;
    dp[2]=abs(a[2]-a[1]);
    rep(i,3,n+1)
    {
        dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
    }
    cout<<dp[n];




}   
    


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> v(3);
  cin>>v.at(0)>>v.at(1)>>v.at(2);
  sort(v.begin(),v.end());
  cout<<10*v.at(2)+v.at(1)+v.at(0)<<endl;
}
 
  

Measured memory_bytes: 256
/*
 * FileName:     set_intersection
 * CreatedDate:  2020-06-09 16:10:58 +0900
 * LastModified: 2020-06-09 16:14:46 +0900
 */

#include <stdio.h>
#include <stdlib.h>
#define ultra 2e9
int main(void){
    int n;scanf("%d",&n);
    int *a = malloc((n+1)*sizeof(int));
    for(int i=0;i<n;i++)scanf("%d",a+i);
    a[n]=ultra;
    int m;scanf("%d",&m);
    int *b = malloc((m+1)*sizeof(int));
    for(int i=0;i<m;i++)scanf("%d",b+i);
    b[m]=ultra;
    int ia=0,ib=0;
    while(ia<n||ib<m){
        if(a[ia]<b[ib]){
            ia++;
        }
        else if(a[ia]>b[ib]){
            ib++;
        }
        else{
            printf("%d\n",a[ia]);
            ia++;
            ib++;
        }
    }
    free(a);
    free(b);
    return 0;
}



Measured memory_bytes: 3120
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	K := nextInt()

	a := 0
	for i := 1; i < 1000000; i++ {
		a = (10*a + 7) % K
		if a == 0 {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)
}


Measured memory_bytes: 1824
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;



int main(){
    int n,k;
    cin >> n >> k;
    vector<double> p(n);
    rep(i,n) cin >> p[i];
    
    map<int,double> prob;
    FOR(pr,1,1001){
        double a = 0.0;
        FOR(i,1,pr+1){
            a += (double) i;
        }
        a /= pr;
        prob[pr] = a;
    }
    
    rep(i,n) p[i] = prob[p[i]];
    double cumsum = 0.0;
    rep(i,k){
        cumsum += p[i];
    }
    double ans = cumsum;
    
    FOR(i,k,n){
        
        cumsum -= p[i-k];
        cumsum += p[i];
        ans = max(ans,cumsum);
    }
    

    printf("%.20f", ans);
}


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

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

    long long n;
    cin >> n;
    n--;

    string alp = "abcdefghijklmnopqrstuvwxyz";
    string ans = "";

    while(n >= 0){
        int r = n % 26;
        ans += alp[r];

        n /= 26;
        n--;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
  int h, w;
  cin >> h >> w;
  
  char map[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> map[i][j];
    }
  }
  
  vector<bool> height(h, false);
  vector<bool> width(w, false);
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (map[i][j] == '#') {
        height[i] = true;
        break;
      }
    }
  }
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      if (map[j][i] == '#') {
        width[i] = true;
        break;
      }
    }
  }
  
  for (int i = 0; i < h; i++) {
    if(!height[i]) {
      continue;
    }
    for (int j = 0; j < w; j++) {
      if(!width[j]) {
        continue;
      }
      cout << map[i][j];
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
def gcd(p,q):
    if p%q==0: return q
    else: return gcd(q,p%q)
n,x = map(int,input().split())
a = list(map(int,input().split()))
b = [abs(x-i) for i in a]
ans = b[0]
for i in range(1,n):
    ans = min(ans,gcd(ans,b[i]))
print(ans)

Measured memory_bytes: 19916
import heapq
N, M = map(int,input().split())
A = list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(A)

for _ in range(M):
    a = heapq.heappop(A)*(-1)
    a //= 2
    heapq.heappush(A,-a)

print(sum(A)*(-1))

Measured memory_bytes: 14180
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = get();
    let m = get();
    let ab: Vec<(i64, i64)> = (0 .. n).map(|_| {
        let a = get();
        let b = get();
        (a, b)
    }).collect();
    let cd: Vec<(i64, i64)> = (0 .. m).map(|_| {
        let a = get();
        let b = get();
        (a, b)
    }).collect();
    for &(a, b) in ab.iter() {
        let mut mi = 1 << 50;
        let mut mini = 0;
        for i in 0 .. m {
            let (c, d) = cd[i];
            let tmp = (a - c).abs() + (b - d).abs();
            if mi > tmp {
                mi = tmp;
                mini = i;
            }
        }
        println!("{}", mini + 1);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

    string s;
    cin>>s;
    int n=s.length();
    s="#"+s;
    int l=1,r=(n-1)/2;
    while (l<=r)
    {
        if(s[l]!=s[r])
        {
            cout<<"No";
            return 0;
        }
            l++;
            r--;
    }
    l=(n+3)/2;
    r=n;    
    while (l<=r)
    {
        if(s[l]!=s[r])
        {
            cout<<"No";
            return 0;
        }
            l++;
            r--;
    }
    l=1,r=n;
    while (l<=r)
    {
        if(s[l]!=s[r])
        {
            cout<<"No";
            return 0;
        }
            l++;
            r--;
    }
    cout<<"Yes";

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const ll LINF = 1e16 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int N;

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

  cin >> N;

  vector< ll > memoA(N + 1, 0ll);
  // ll aSum = 0ll;
  priority_queue< ll, vector< ll >, greater< ll > > a;
  REP(i, N) {
    LCIN(t);
    // aSum += t;
    memoA[0] += t;
    a.push(t);
  }

  vector< ll > b(N);
  REP(i, N) {
    cin >> b[i];
  }

  vector< ll > memoC(N + 1, 0ll);
  // ll cSum = 0ll;
  priority_queue< ll > c;
  REP(i, N) {
    LCIN(t);
    // cSum += t;
    memoC[0] += t;
    c.push(t);
  }

  REP(i, N) {
    a.push(b[i]);
    memoA[i + 1] = memoA[i] - a.top(); a.pop();
    memoA[i + 1] += b[i];

    c.push(b[N - i - 1]);
    memoC[i + 1] = memoC[i] - c.top(); c.pop();
    memoC[i + 1] += b[N - i - 1];
  }

  ll ans = -LINF;
  REP(i, N + 1) {
    // debug(memoA[i + 1]);
    // debug(memoC[N - i + 1]);
    ll tmp = memoA[i] - memoC[N - i];
    // debug(tmp);
    ans = max(ans, tmp);
  }

  cout << ans << endl;

  /*
  REP(i, N + 1) 
    debug(memoA[i]);

  cout << endl;
  
  REP(i, N + 1)
    debug(memoC[i]);
  */

  return 0;
}



Measured memory_bytes: 4980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define tl t<<1
#define tr t<<1|1
#define mid ((r + l) >> 1)
const int maxn = 3e5 + 5;
const int inf = 1e9;
int mx [maxn<<2];
void PushUp(int t)
{
    mx[t] = max (mx[tl] , mx[tr]);
}
void Build(int l,int r,int t)
{
    if(l == r)
    {
        mx[t] = 0;
        return ;
    }
    Build(l , mid , tl);
    Build(mid + 1 , r , tr);
    PushUp(t);
}
// 单点修改
void Update_One(int l , int r , int t , int pos , int c)
{
    if(l == r){
        mx[t] = max (mx[t] , c);
        return ;
    }
    if(pos <= mid)
        Update_One(l,mid,tl,pos,c);
    else
        Update_One(mid+1,r,tr,pos,c);
    PushUp(t);
    return ;
}

// 单点查询只需要 参数填写 L == R 即可
ll Query(int L,int R,int l,int r,int t)
{
    if(L <= l && r <= R){
        return mx[t];
    }
    ll ans=-inf;
    if(L <= mid)
        ans = max (ans , Query(L,R,l,mid,tl));
    if(R > mid)
        ans  = max (ans , Query(L,R,mid+1,r,tr));
    return ans;
}
int a[maxn] , dp[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n , k; cin >> n >> k;
    for (int i = 1 ; i <= n ; i++) cin >> a[i];
    dp[0] = 0;
    int up = 3e5;
    Build(1 , up , 1);
    int ans = 0;
    for (int i = 1 ; i <= n ; i++){
        int g = Query(max(0 , a[i] - k) , min(up , a[i] + k) , 1 , up , 1);
        dp[i] = g + 1;
        Update_One(1 , up , 1 , a[i] , dp[i]);
        ans = max (ans , dp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10048
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        System.out.println(a + b == c || a == b + c || b == a + c ? "Yes" : "No");
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#define ll long long
#define INF 100000000000
#define N 10000000
using namespace std;

int main(void){
    int x,y;
    cin>>x>>y;
    if (y%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    
    if(y<x*2){
        cout<<"No"<<endl;
        return 0;
    }
    
    if(y>x*4){
        cout<<"No"<<endl;
        return 0;
    }
    
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3644