akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
using ll = long long;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++){
    ll tmp;
    cin>>tmp;
    a[i]=tmp-i;
  }
  ll med1=0,med2=0,ans1=0,ans2=0;
  bool flag=0;
  sort(a,a+n);
  // for(int i=0;i<n;i++){
  //   cout<<a[i]<<",";
  // }
  // cout<<endl;
  if(n%2==0){
    // cout<<"n/2-1="<<n/2-1<<",n/2="<<n/2<<endl;
    med1=a[n/2-1];
    med2=a[n/2];
  }else{
    med1=a[n/2];
    flag=1;
  }
  if(flag){
    for(int i=0;i<n;i++){
      ans1+=abs(a[i]-med1);
    }
    cout<<ans1<<endl;
  }else{
    for(int i=0;i<n;i++){
      ans1+=abs(a[i]-med1);
      ans2+=abs(a[i]-med2);
    }
    // cout<<"med1="<<med1<<",med2="<<med2<<endl;
    // cout<<"ans1="<<abs(ans1)<<",ans2="<<abs(ans2)<<endl;
    cout<<min(ans1,ans2)<<endl;
  }
  return 0;
}


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

int main(){
    string S;
    cin >> S;
    int l = S.length();
    int count0 = 0;
    int count1 = 0;

    

    for(int i = 0;i < l;i++){
        if(strncmp("0",&S.at(i),1) == 0){
            count0++;
        }else{
            count1++;
        }
    }
  
    cout << 2*min(count0,count1) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    int n;
    cin >> n;
    map<ll,ll> mp;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    ll ans = 0;
    
    for(auto p : mp){
        if(p.second>=4) ans = p.first * p.first;
    }
    ll max1=0,max2=0;
    for(auto p : mp){
        if(p.second>1){
            max2 = max1;
            max1 = p.first;
        }
    }
    ans = max(max1*max2,ans);
    
    
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 6528
#include <cstdio>
typedef long long ll;
const int Maxn=200000;
int n,q;
struct Segment_Node{
	int lson,rson;
	int num,lazy;
}seg[Maxn*100+5];
int Root_1,Root_2;
int id_tot;
void update_tag(int &root,int x){
	if(root==0){
		root=++id_tot;
	}
	seg[root].lazy=x;
	seg[root].num=x;
}
void push_down(int root){
	if(seg[root].lazy==-1){
		return;
	}
	update_tag(seg[root].lson,seg[root].lazy);
	update_tag(seg[root].rson,seg[root].lazy);
	seg[root].lazy=-1;
}
void update(int l,int r,int a,int &root,int left=1,int right=n-2){
	if(l>right||r<left){
		return;
	}
	if(root==0){
		root=++id_tot;
		seg[root].lazy=-1;
	}
	if(l<=left&&r>=right){
		seg[root].num=a;
		seg[root].lazy=a;
		return;
	}
	push_down(root);
	int mid=(left+right)>>1;
	update(l,r,a,seg[root].lson,left,mid);
	update(l,r,a,seg[root].rson,mid+1,right);
}
int query(int x,int root,int left=1,int right=n-2){
	if(left==right){
		return seg[root].num;
	}
	if(root==0){
		return n-2;
	}
	push_down(root);
	int mid=(left+right)>>1;
	if(x<=mid){
		return query(x,seg[root].lson,left,mid);
	}
	else{
		return query(x,seg[root].rson,mid+1,right);
	}
}
int main(){
	scanf("%d%d",&n,&q);
	ll num=1ll*(n-2)*(n-2);
	update(1,n-2,n-2,Root_1);
	update(1,n-2,n-2,Root_2);
	int last_1=n-2,last_2=n-2;
	for(int i=1;i<=q;i++){
		int op,x;
		scanf("%d%d",&op,&x);
		x--;
		if(op==1){
			int tmp=query(x,Root_1);
			num-=tmp;
			if(x<=last_1){
				update(1,last_2,x-1,Root_2);
				last_1=x-1;
			}
		}
		else{
			int tmp=query(x,Root_2);
			num-=tmp;
			if(x<=last_2){
				update(1,last_1,x-1,Root_1);
				last_2=x-1;
			}
		}
	}
	printf("%lld\n",num);
	return 0;
}


Measured memory_bytes: 12588
#include<iostream>
using namespace std;
void C(int depth,int j,long long int kakeru,long long int &sum,int *chr){
  for(int i=j+1;i<=26-depth+1;i++){
    if(depth==1){
     
        
        sum=(sum+kakeru*chr[i-1])%1000000007;
    }else{
      long long int temp=kakeru;
      temp=(kakeru*chr[i-1])%1000000007;
      C(depth-1,i,temp,sum,chr);
    }
  }
}

int main(){
  int n;
  string s;
  
  cin>>n>>s;
  int chr[26];
  for(int i=0;i<26;i++){
    chr[i]=0;
  }
  for(int i=0;i<n;i++){
    chr[(int)(s[i])-97]++;
  }
  long long int sum=0;
 
  
  for(int i=1;i<=26;i++){
    C(i,0,1,sum,chr);
  }
  cout<<sum;
    
  
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
    
using namespace std;
    
int main(){
 int a,b;
 string s1;
 while (1) {
  cin >> a;
  cin >> s1;
  cin >> b;
  if (s1=="?") break;
  if (s1=="+") {
   cout << a+b <<endl;
  } else if (s1=="-") {
   cout << a-b <<endl;
  } else if (s1=="*") {
   cout << a*b <<endl;
  } else {
   cout << a/b <<endl;
  }
 } 
 return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define fi(i,a,b) for(int i=a; i<=b; i-=-1)
#define fid(i,a,b) for(int i=a; i>=b; i--)
#define ll long long
#define F first
#define S second
#define VanLoi "a"
#define maxn 100005
#define pii pair<int, int>
#define MOD 1000000007
#define B 107
#define gb(i,j) ((i >> j) & 1)
#define pb push_back
#define reset(x) memset(x, 0, sizeof(x))
#define Block 400
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

int n, l[maxn], k, a[maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen(VanLoi".inp","r",stdin);
    freopen(VanLoi".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin >> n >> k;
    fi(i, 1, n) cin >> a[i];
    l[1] = 0;
    fi(i, 2, n) l[i] = 1e9;
    fi(i, 2, n)
        fi(j, max(i - k, 1), i - 1) l[i] = min(l[i], l[j] + abs(a[i] - a[j]));
    cout << l[n];
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long> data(N);
  long ans = 0;
  for(int i = 0; i < N; i++)cin >> data.at(i);
  for(int i = 0; i < N; i++){
    if(data.at(i) == i + 1){
      ans++;
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

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


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,a[202],s;
int main(){
    cin>>n;n*=2;
	while(n)cin>>a[n--];
	sort(a+1,a+201);
	n=200;
	while(a[n])
	  s+=min(a[n],a[n-1]),
      n-=2;
	cout<<s;
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  int k, t;
  int a[105];

  cin >> k >> t;
  for (int i = 0; i < t; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < t - 1; i++) {
    sort(a, a + t);
    a[t - 1] -= a[i];
    a[i] = 0;
  }
  int ans = a[t - 1] - 1;
  if (ans < 0) ans = 0;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,k = map(int, input().split())

p_list=list(map(int, input().split()))

p_list.sort()

#print(p_list)
#money = p_list.sort()
pricelist = p_list[:k]
pricesum = 0
for i in pricelist:
  pricesum += i

print(pricesum)


Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int q[100001];
vi w;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int sol = 0;
    vector<tuple<int, int, int>> v;
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        v.emplace_back(a, 0, i);
        v.emplace_back(b - 1, 1, i);
    }
    sort(all(v));
    for (auto p : v)
    {
        int a, b, c;
        tie(a, b, c) = p;
        if (b == 0)
        {
            w.push_back(c);
        }
        else
        {
            if (q[c]) continue;
            sol++;
            for (int x : w)
                q[x] = 1;
            w.clear();
        }
    }
    cout << sol;
}


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

int main()
{
  ll a,b,c;
  cin>>a>>b>>c;
  map<ll,ll>mp;
  mp[a]++;
  mp[b]++;
  mp[c]++;
  if(mp.size()==2)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b)
        printf("a < b\n");
        else if(a>b)
            printf("a > b\n");
        else if(a==b)
            printf("a == b\n");
        else
            return 0;
}



Measured memory_bytes: 2020
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	vector<string> A(N*2);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i] = A[i] + A[i];
		A[i + N] = A[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		bool flag = true;
		for (int j = 0; j < N; j++)for (int k = 0; k < N; k++) {
			if (A[j][i + k] != A[k][j+i])flag = false;
		}
		if (flag) ans += N;
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  for (int i = 0; i < A; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> b[i];
  }

  vector<int> x(M), y(M), c(M);
  for (int i = 0; i < M; i++) {
    cin >> x[i] >> y[i] >> c[i];
    x[i]--;
    y[i]--;
  }

  ll ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());

  for (int i = 0; i < M; i++) {
    ll tmp = a[x[i]] + b[y[i]] - c[i];

    if (ans > tmp) {
      ans = tmp;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;
const double PI = acos(-1);

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
const double EPS = 1e-9;
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define ps_edge(PS,i) PS[i],PS[(i+1)%PS.size()]

namespace std {
    bool operator<(const Point a, const Point b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

double dot(Point a, Point b) {
    return a.X*b.X + a.Y*b.Y;
}

double cross(Point a, Point b) {
    return a.X*b.Y - a.Y*b.X;
}

int ccw(Point a, Point b, Point c) {
    b -= a;  c -= a;
    if (cross(b,c) >  EPS) return +1;  // counter clockwise
    if (cross(b,c) < -EPS) return -1;  // clockwise
    if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
    if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
    return 0;                          // a--c--b on line or a==c or b==c
}

bool arg_compare(const Point &a, const Point &b) {
    return arg(a) < arg(b);
}

int main(void){
    int n;
    cin >> n;
    VP ps(n);
    rep(i,n){
        double x,y;
        cin >> x >> y;
        ps[i] = Point(x,y);
    }
    sort(all(ps), arg_compare);
    double M = 100000;
    double res = 0;
    rep(i,M){
        Point inf = polar(1e9, 2.0*PI*(i/M));
        VP used;
        Point p(0,0);
        rep(j,n){
            if (abs(ps[j]-inf) < 1e9) {
                p += ps[j];
            }
        }
        res = max(res, abs(p));
    }
    printf("%.20f\n", res);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int gcd(int a, int b);

int main()
{
	int i, a, b, k, g, cnt = 0;
	
	scanf("%d %d %d", &a, &b, &k);
	
	g = gcd(a, b);
	
	for(i = g; i > 0; i--){
		if(g % i == 0)
			cnt++;
		if(cnt == k){
			printf("%d", i);
			break;
		}
	}

	return 0;
}

int gcd(int a, int b){
	
	int tmp, r;
	
	if(a < b){
		tmp = a;
		a = b;
		b = tmp;
	}
	
	r = a % b;
	while(r!=0){
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

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

int main()
{
    int h,w;
    cin >> h >> w;
    string a[h];
    for(int i = 0; i < h; i++) cin >> a[i];

    for(int i = 0; i < h + 2; i++){
        if(i == 0 || i == h + 1){
            for(int j = 0; j < w + 2; j++){
                cout << '#';
            }
            cout << endl;
        }else{
            cout << '#' << a[i-1] << '#' << endl;
        }
    }

    return 0;
}

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int w,r;
    w = r = 0;
    rep(i,S.size()) {
        if (S[i]=='W') w++;
        else r++;
    }
    int ans = 0;
    rep(i,r) {
        if (S[i]=='W') ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3660
S=input()
flag=0
if S==S[::-1]:
  s = S[:(len(S)-1)//2]
  if s==s[::-1]:
    s2 = S[(len(S)+3)//2-1:]
    if s2==s2[::-1]:
      flag=1
if flag:print('Yes')
else:print('No')

Measured memory_bytes: 9052
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    int c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }
    int count=0;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            if(c[i][j]-c[i][j+1]!=c[i+1][j]-c[i+1][j+1]){
                count++;
            }
            if(c[i][j]-c[i+1][j]!=c[i][j+1]-c[i+1][j+1]){
                count++;
            }
        }
    }
    if(count>0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

int main(){
	int N, K;
	string S;
	cin >> N >> S >> K;
	for(int i; i < N; i++){
		if(S.at(i) != S.at(K-1)) S.at(i) = '*';
	}
	cout << S << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi pair<ll,int> 
#define pii pair<int,ll>
 
ll mod = 1e9+7;
ll INF = 1e17;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
int main()
{
    IOS
    bool arr[3][3];
    memset(arr,false,sizeof(arr));
    ll brr[3][3];
    for(ll i=0;i<3;i++)
    {
        for(ll j=0;j<3;j++)
        cin>>brr[i][j];
    }
    ll n;
    cin>>n;
    while(n--)
    {
        ll c;
        cin>>c;
        for(ll i=0;i<3;i++)
        {
            for(ll j=0;j<3;j++)
            {
                if(brr[i][j]==c)
                arr[i][j]=true;
            }
        }
    }
    ll flag1=0;
    for(ll i=0;i<3;i++)
    {
        ll flag=0;
        for(ll j=0;j<3;j++)
        {
            if(arr[i][j]==false)
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            flag1=1;
            break;
        }
    }
    if(flag1==0)
    {
        for(ll j=0;j<3;j++)
        {
            ll flag=0;
            for(ll i=0;i<3;i++)
            {
                if(arr[i][j]==false)
                {
                    flag=1;
                    break;
                }
            }
            if(flag==0)
            {
                flag1=1;
                break;
            }
        }
    }
    if(flag1==0)
    {
        if((arr[0][0]==true && arr[1][1]==true && arr[2][2]==true)||(arr[0][2]==true && arr[1][1]==true && arr[2][0]==true))
        flag1=1;
    }
    if(flag1)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int H,W;
    cin>>H>>W;
    int Ch,Cw,Dh,Dw;
    cin>>Ch>>Cw>>Dh>>Dw;
    Ch--;Cw--;Dh--;Dw--;
    auto S = make_v<char>(H,W);
    auto dist = make_v<int>(H,W);
    fill_v(dist,1000000000);
    dist[Ch][Cw]=0;
    for (size_t i = 0; i < H; i++)
    {
        for (size_t j = 0; j < W; j++)
        {
            cin>>S[i][j];
        }
        
    }
    using P = pair<int,int>;
    using T = pair<P,int>;
    deque<T> deq;
    deq.push_back({{Ch,Cw},0});
    const int dx[] = {0,1,0,-1};
    const int dy[] = {1,0,-1,0};
    while (!deq.empty())
    {
        auto [cur,cost] = deq.front();
        deq.pop_front();
        auto [y,x] = cur;
        if(dist[y][x] < cost)continue;
//        dist[y][x]=cost;
        for (size_t i = 0; i < 4; i++)
        {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(ny < H and 0 <= ny and nx < W and 0 <= nx and S[ny][nx] != '#')
            {
                if(dist[ny][nx] <= cost)
                continue;

                dist[ny][nx]=dist[y][x];
                deq.push_front({{ny,nx},dist[y][x]});
            }
        }
        for (int i = -2; i < 3; i++)
        {
            for (int j = -2; j < 3; j++)
            {
                int ny = y + i;
                int nx = x + j;
                if(0 <= ny and ny < H and 0 <= nx and nx < W and S[ny][nx] != '#')
                {
                    if(dist[ny][nx] <= cost + 1)
                    continue;
                    dist[ny][nx]=dist[y][x]+1;
                    deq.push_back({{ny,nx},dist[y][x]+1});
                }
            }
            
        }
        
    }
    cout<<((dist[Dh][Dw] < 1000000000) ? dist[Dh][Dw] : -1) <<endl;
/*    for (size_t i = 0; i < H; i++)
    {
        for (size_t j = 0; j < W; j++)
        {
            cout<<dist[i][j]<<" ";
        }
        cout<<endl;
    }*/
    
    return 0;
}

Measured memory_bytes: 8696
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <random>
#include <functional>

using namespace std;

#define F first
#define S second
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << ": "; for (auto& xxxx: a) cerr << xxxx << " "; cerr << endl;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)a.size()
#define pw(n) (1ll << (n))
#define equal equalll
#define less lesss

typedef double dbl;
typedef long long ll;
const int N = -1;
const int INF = 1.01e9;
typedef vector<int> vi;



int main(){
#ifdef HOME 
    assert(freopen("in", "r", stdin));
#endif
    string s;
    cin >> s;
    if (s.find("AC") != string::npos) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
        
    
#ifdef HOME 
    epr("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
#endif
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
  string s,t;
  ll a,b;
  cin>>s>>t;
  cin>>a>>b;
  string u;
  cin>>u;
  if(u==s)
  {
    --a;
    cout<<a<<" "<<b<<'\n';
  }
  else
  {
    --b;
    cout<<a<<" "<<b<<'\n';
  }  
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    char ans = 'a';
    bool check;
    while (ans <= 'z') {
        check = true;
        for (int i = 0; i < N; i++) {
            if (S.at(i) == ans) {
                ans = ans + 1;
                check = false;
                break;
            }
        }
        if (check) {
            cout << ans << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}


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

int main() {
	
	int d,t,s;
	cin>>d>>t>>s;
	
	float mn = float(d)/float(s);
//	cout<<mn<<" ";
	if(t>=mn)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3644
a,b,k=map(int,input().split())
for i in range(k):
    if i%2==0:
        if a%2==1:
            a-=1
            a//=2
        else:
            a//=2
        b+=a
    else:
        if b%2==1:
            b-=1
            b//=2
        else:
            b//=2
        a+=b
print(a,b)

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


int main()
{
    long long a,b,c,k;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
    if(k%2==0)
        printf("%lld\n",a-b);
    else
        printf("%lld\n",b-a);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static long max(long a, long b, long c){
        if(a >= b && a >= c)
            return a;
        else if(b >= c)
            return b;
        return c;
    }
    public static long min(long a, long b, long c){
        if(a <= b && a <= c)
            return a;
        else if(b <= c)
            return b;
        return c;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        System.out.println(min(a,b,c) + " " + max(a,b,c));
    }
}


Measured memory_bytes: 26412
#include <stdio.h>
int main(void){
int n,m,i,count=0;
double sum=0;

scanf("%d %d",&n,&m);
int c[n];
for(i=0;i<n;i++){
scanf("%d",&c[i]);
sum+=c[i];}
for(i=0;i<n;i++){
    if(sum/(4*m)<=c[i])
    count++;
}
if(m<=count)
puts("Yes");
else
puts("No");
return 0;
}


Measured memory_bytes: 1644
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();
        int[] a = r.ii();
        println((a[0]*a[1])%2 == 0 ? "Even" : "Odd");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int Int(String s){
            return Integer.parseInt(s);
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }

    }
}

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

signed main(){
  
  int n;
  cin>>n;
  
  vector<int> A(n);
  
  for(int i=0;i<n;i++) cin>>A[i];
  
  int negcnt = 0;
  
  for(int a : A ) negcnt += ( a < 0 );
  
  for(int i=0;i<n;i++) A[i] = abs( A[i] );
  
  sort( A.begin(), A.end() );
  
  int ans = 0;
  
  for(int i=0;i<n;i++){
    if( i == 0 && negcnt % 2 ) ans -= A[i];
    else ans += A[i];
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 1024
s = input()

ans = 'AC'

if s[0] != "A":
    ans = "WA"
count = 0

for i in range(1,len(s)):
    if s[i].isupper():
        if i == 1 or i == len(s)-1 or s[i] != "C":
            ans = "WA"
        count += 1

if count != 1:
    ans = "WA"

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

 
int main(void)
{
	int  a,b, c;
	
	scanf("%d" , &a);
	scanf("%d" , &b);
	scanf("%d" , &c);
		
	if((a<b)&& (b<c)) {
		printf("Yes\r\n");		
	}
	else{
		printf("No\r\n");				
	}

	 return 0;	 
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
 
const int INF = 1001001001;

int main(){
	int n, m; cin >> n >> m;
	int l=-1, r = INF;
	rep(i,m){
		int L, R; cin >> L >> R;
		chmin(r, R);
		chmax(l, L);
	}
	cout << max(0, r-l+1) << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
          int a , b , h , k;
          scanf("%d%d", &a, &b) ;
          if( (a+b) % 2 != 0 ) printf("IMPOSSIBLE\n") ;
          else
          {
                    h = (a+b)/ 2 ;

                    printf("%d\n", h) ;
          }

}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

ll mod2(ll n) {
    ll ans = 0;
    while (n % 2 == 0) {
        n /= 2;
        ans++;
    }
    return ans;
}

typedef tuple<ll, ll, ll> Cake;

int main() {

    ll n, m;
    cin >> n >> m;

    vector<Cake> cakes;

    rep(i, n) {
        ll x, y, z;
        cin >> x >> y >> z;

        Cake cake(x, y, z);
        cakes.push_back(cake);

    }

    ll ans = 0;
    for (int i = 0; i < (1 << 3); i++) {
        
        int x_s = 1;
        int y_s = 1;
        int z_s = 1;

        if (i & 1 == 1) {
            x_s = -1;
        }
        if (((i >> 1) & 1) == 1) {
            y_s = -1;
        }
        if (((i >> 2) & 1) == 1) {
            z_s = -1;
        }


        vector<ll> ary;
        for (Cake cake : cakes) {
            ll x = get<0>(cake);
            ll y = get<1>(cake);
            ll z = get<2>(cake);

            x *= x_s;
            y *= y_s;
            z *= z_s;

            ary.push_back(x + y + z);
        }

        sort(ary.rbegin(), ary.rend());
        ll now = 0;
        for (int j = 0; j < m; j++) {
            now += ary[j];
        }
        ans = max(now, ans);
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (1) {
        C -= B;
        if (C <= 0) {
            puts("Yes");
            return 0;
        }
        A -= D;
        if (A <= 0) {
            puts("No");
            return 0;
        }
    }
}

Measured memory_bytes: 3632
n = int(input())
d = list(map(int,input().split()))
d.sort()
cs = [0]
ans = 0
l= 0
for i in range(d[-1]):
  temp = 0
  while(True):
    if i == d[l]:
      temp += 1
      l += 1
    else:
      break

  cs.append(cs[i]+temp)

ans = cs.count(n/2)
print(ans)

Measured memory_bytes: 56940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,a,s=100;
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> a;
    int k = 0;
    while (a%2==0) {
      a /= 2;
      k++;
    }
    if (k<s) {
      s = k;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int 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 + -1*(k-a-b) << endl;
    }


    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

vector<int> makePrimes(int n) { 
    vector<int> res, pr(n + 3, 1);
    pr[0] = pr[1] = 0;
    for(int p=2;p<sqrt(n+2)+2;p++){
      if (pr[p]){
       for (int x = p * 2; x <= n+2; x += p){
        pr[x] = 0;
       }
      }
   }
    for(int p=2;p<n + 1;p++){ 
    	if (pr[p]) res.push_back(p);
    }
    return res;
}

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

	auto pn = makePrimes(N+2);
	int ans=0;
	for(int i=0;i<pn.size()-1;i++){
		if(pn[i+1]-pn[i]==2)ans++;
	}
	cout << ans*2 << endl;
}



Measured memory_bytes: 46052
#include <bits/stdc++.h>
using namespace std;
#define p for(int i = 0;i < 10;i++)
int main(void)
{
	int n[10]={0},m[10]={0},w=0,k=0;
	
	p{
		cin >> n[i] ;
	}
	p{
		cin >> m[i] ;
	}
	sort(n,n+10);
	w = n[9] + n[8] + n[7] ;
	sort(m,m+10);
	k = m[9] + m[8] + m[7] ;
	cout << w << " " << k << endl ;
	
	return 0;
}

Measured memory_bytes: 3148
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  int N, Q;
  string S;
  cin >> N >> Q >> S;

  vector<int> a(N, 0);
  int num = 0;
  for(int i = 0; i < N-1; i++){
    a[i] = num;
    if(S.at(i) == 'A' && S.at(i+1) == 'C'){
      num++;
    }
  }
  a[N-1] = num;


  int s, g;
  rep(i, Q){
    cin >> s >> g;
    cout << a[g-1] - a[s-1] << endl;
  }  

}


Measured memory_bytes: 1408
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------
vector<ll> v[200001];
ll ar[200001];
void dfs(ll ver,ll p,ll ch)
{
	ar[ver]+=ch;
	//debug2(ver,ch);
	for(ll i=0;i<v[ver].size();i++)
	{
		if(v[ver][i]!=p)
		{
			dfs(v[ver][i],ver,ar[ver]);
		}
	}
}
int main()
{
	boost
	ll n,q;
	cin>>n>>q;
	for(ll i=0;i<n-1;i++)
	{
		ll a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	
	while(q--)
	{
		ll ver,x;
		cin>>ver>>x;
		ar[ver]+=x;
	}
	dfs(1,-1,0);
	for(ll i=1;i<=n;i++)
	{
		cout<<ar[i]<<" ";
	}
	return 0;
}


Measured memory_bytes: 24320
h,w=map(int,input().split())
lis=[]
for i in range(h):
  lis.append(input())
tate=[]
yoko=[]
for i in range(0,w):
  for j in range(0,h):
    if lis[j][i]=="#":
      tate.append(i)
      break

for i in range(0,h):
  for j in range(0,w):
    if lis[i][j]=="#":
      yoko.append(i)
      break

for x in yoko:
  for y in tate:
    if y != tate[len(tate)-1]:
      print(lis[x][y],end="")
    else:
      print(lis[x][y])

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


int N, K, Q;
vector<int> A;
const int INF = 1e9;


void input() {
    cin >> N >> K >> Q;
    A = vector<int>(N);
    rep(i, N) cin >> A[i];
}


void insert_l(vector<int> &l, vector<int> &w) {
    sort(w.begin(), w.end());
    rep(i, w.size() - K + 1) l.push_back(w[i]);
}


int solve(int x) {
    vector<int> l, w;
    for (int a : A) {
        if (a > x) {
            w.push_back(a);
        } else {
            insert_l(l, w);
            w = {};
        }
    }
    insert_l(l, w);
    sort(l.begin(), l.end());
    if (l.size() < Q) {
        return INF;
    } else {
        return l[Q-1] - l[0];
    }
}


int main() {
    input();
    set<int> S;
    for (int a : A) S.insert(a);
    int ans = solve(0);
    for (int s : S) {
        int x = solve(s);
        if (x == INF) break;
        ans = min(ans, x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
from sys import stdin

input=list(stdin.readline().rstrip())

counter=0
word=[]
for i in input:
    if counter==0:
        word.append(i)
        counter+=1
    else:
        if i not in word:
            counter+=1
            word.append(i)

if counter==2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main{

	public static void main(String[] args) throws Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> list = new ArrayList<Integer>();

		while(true){

			int num = Integer.parseInt(br.readLine());

			if(num != 0){
				list.add(num);
			}else{
				break;
			}

		}

		for(int i = 0; i < list.size(); i++){
			System.out.println("Case " + (i + 1) + ": " + list.get(i));
		}

	}
}

Measured memory_bytes: 33124
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
ll fac[32];
int tot;//质因子
bool prime[1000006];
ll p[1000006],cnt;

void initprim(){
	int i,j;
    cnt = 0;
    memset(prime,true,sizeof(prime));
    for(i=2; i<1000006; i++)
    {
        if(prime[i])
        {
            p[cnt++] =(ll)i;
            for(j=i+i; j<1000006; j+=i)
                prime[j] = false;
        }
    }
}

bool check(ll x){
    int i;
    for(i=0;i<tot;i++){
        if(x==fac[i]) return true;
    }
    return false;
}

int main(){
	ll a,b;
	int i;
	int ans=1;
	initprim();
	scanf("%lld%lld",&a,&b);
        for(i=0,tot=0;i<cnt&&p[i]*p[i]<=a;i++){
            if(a%p[i]==0){
                while(a%p[i]==0){
                    a=a/p[i];
                }
                fac[tot++]=p[i];
            }
        }
        if(a>1){
            fac[tot++]=a;
        }

        for(i=0;i<cnt&&p[i]*p[i]<=b;i++){
            if(b%p[i]==0){
                while(b%p[i]==0){
                    b=b/p[i];
                }
                if(check(p[i])) ans++;
            }
        }
        if(b>1){
            if(check(b)) ans++;
        }
        printf("%d\n",ans);
        return 0;
}


Measured memory_bytes: 3328
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

H, W, D = MAP()
A = [LIST() for _ in range(H)]

dic = defaultdict(tuple)

for y in range(H):
	for x in range(W):
		dic[A[y][x]] = (y+1, x+1)

power = [[] for _ in range(D)]
for i in range(1, H*W+1):
	if i <= D:
		power[i%D].append(0)
	else:
		idx = i%D
		tmp = abs(dic[i][0]-dic[i-D][0]) + abs(dic[i][1]-dic[i-D][1])
		power[i%D].append(tmp)

#print(power)
power_acc = []
for x in power:
	power_acc.append(list(accumulate(x)))
power_acc[0].insert(0, 0)
#print(power_acc)

Q = INT()
for _ in range(Q):
	L, R = MAP()
	print(power_acc[R%D][R//D] - power_acc[L%D][L//D])

Measured memory_bytes: 45056
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    // 6 5 6 5
    long long ans = 0;
    long long x;
    cin >> x;
    ans += x/11 * 2;
    x = x%11;
    if(x == 0){
        cout << ans << endl;
    }else if(x <= 6){
        cout << ans+1 << endl;
    }else{
        cout << ans+2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    for (auto& c : s)
        if (c == '?')
            c = 'D';
    cout << s << "\n";
    return 0;
}

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

char mat[101][101];
int l[101][101] = {}, u[101][101] = {};

int main(){
    int n, m, d;
    cin >> n >> m >> d;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> mat[i][j];
            if(mat[i][j] == '.')    u[i][j] = u[i-1][j]+1;
        }
    }

    for(int j = 1; j <= m; j++){
        for(int i = 1; i <= n; i++){
            if(mat[i][j] == '.')    l[i][j] = l[i][j-1]+1;
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            ans += (l[i][j] >= d) + (u[i][j] >= d);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  int N = S.length();
  int start=0;
  int l_check;
  int r_check=-1;
  int ans[N]={};
  int r_num,l_num;
  
  for(int i=1;i<N;i++){ //R->Lを探す
    if(i<r_check)continue;
    if(S.at(i)=='R')continue;
    else { 
      l_check=i;
      for(int j=l_check;j<N;j++){ //Lが見つかったのでRを探す
        if(S.at(j)=='L'){
          if(j==N-1){
            r_check=j+1;
            break;
          }
        }
        else {
          r_check=j;
          break;        
        }
      }
      
      //チェック終了、数値処理をする
      r_num = l_check-start;
      l_num = r_check-l_check;
      
      ans[l_check-1]+=(r_num/2+r_num%2)+(l_num/2);
      ans[l_check]+=(r_num/2)+(l_num/2+l_num%2);
      
      start = r_check;      
    }
  }
  for (int k=0;k<N;k++)
  cout << ans[k] << endl;
}


Measured memory_bytes: 1024
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, z, w;
  rd(n, z, w);
  auto a = readln.split.to!(int[]);

  import std.math : abs;

  struct P {
    int i, t, p;
  }

  int[P] memo;
  int f(int i, int t, int pre) {
    if (i + 1 == n) {
      return abs(a[i] - pre);
    } else {
      auto key = P(i, t, pre);
      if (key in memo) {
        return memo[key];
      }
      int ret = t ? 2 * 10 ^^ 9 : 0;
      if (t) {
        for (int j = i; j + 1 < n; j++) {
          ret = min(ret, f(j + 1, t ^ 1, a[j]));
        }
        ret = min(ret, abs(a[n - 1] - pre));
      } else {
        for (int j = i; j + 1 < n; j++) {
          ret = max(ret, f(j + 1, t ^ 1, a[j]));
        }
        ret = max(ret, abs(a[n - 1] - pre));
      }
      return memo[key] = ret;
    }
  }

  writeln(f(0, 0, w));
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


// Write From This Line
int main()
{
	int s,w ;
	cin >> s >>w ;
	if( s > w ){
		puts("safe");
	} else {
		puts("unsafe");
	}
}


Measured memory_bytes: 3620
#include<stdio.h>

int main(){
int A[3][3];
int N;

for (int i = 0; i < 3; i++){
  for (int j = 0; j < 3; j++){
    scanf("%d",&A[i][j]);
  }
}
scanf("%d",&N);
int B[N];
for (int i = 0; i < N; i++)
{
  scanf("%d",&B[i]);
}

for (int h = 0; h < N; h++){  
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      if (B[h] == A[i][j]) A[i][j] = 0;
    }
  }
}

if ((A[0][0]+A[1][0]+A[2][0]) == 0){
    printf("Yes");
}else if ((A[0][1]+A[1][1]+A[2][1]) == 0){
    printf("Yes");
}else if ((A[0][2]+A[1][2]+A[2][2]) == 0){
    printf("Yes");
}else if ((A[0][0]+A[0][1]+A[0][2]) == 0){
    printf("Yes");
}else if ((A[1][0]+A[1][1]+A[1][2]) == 0){
    printf("Yes");
}else if ((A[2][0]+A[2][1]+A[2][2]) == 0){
    printf("Yes");
}else if ((A[0][0]+A[1][1]+A[2][2]) == 0){
    printf("Yes");
}else if ((A[0][2]+A[1][1]+A[2][0]) == 0){
    printf("Yes");
}else
{
  printf("No");
}

return 0;
}

Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::{min, max};
use itertools::Itertools;
use std::ops::{Add, AddAssign};
use num_integer::{Integer, gcd, lcm};
use std::collections::VecDeque;
use smallvec::alloc::collections::LinkedList;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn read_tuple3<T: FromStr, S: FromStr, R: FromStr>() -> (T, S, R) {
    let a = read();
    let b = read();
    let c = read();
    (a, b, c)
}

fn lower_bound<T: Copy, F>(v: &Vec<T>, f: F) -> Option<usize> where
    F: Fn(T) -> bool
{
    let mut left = 0;
    let mut right = v.len() - 1;
    if !f(v[left]) {
        return None;
    }
    if f(v[right]) {
        return Some(right);
    }
    loop {
        if right - left == 1 {
            return Some(left);
        }
        let mid = (left + right) / 2;
        if f(v[mid]) {
            left = mid;
        } else {
            right = mid;
        }
    }
}

fn main() {
    let n:u32 = read();
    let ss:Vec<String> = (0..n).map(|_|read()).collect();
    let mut ac:u32 = 0;
    let mut wa:u32 = 0;
    let mut tle:u32 = 0;
    let mut re:u32 = 0;
    for s in ss {
        if &s == "AC" {
            ac += 1;
        }
        if &s == "WA" {
            wa += 1;
        }
        if &s == "TLE" {
            tle += 1;
        }
        if &s == "RE" {
            re += 1;
        }
    }
    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);

}



Measured memory_bytes: 7512
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++)
			A[i] = sc.nextInt();
		
		int[] odd = new int[N-N/2];
		int[] even = new int[N/2];
		
		for(int i=0; i<N; i++)
			if(i%2==0)
				odd[i/2]=A[i];
			else
				even[i/2]=A[i];
		
		Arrays.sort(A);
		Arrays.sort(odd);
		Arrays.sort(even);
		
		int ans = 0;
		int oi=0,ei=0;
		for(int i=0; i<N; i++) {
			if(oi<N-N/2 && A[i]==odd[oi]) {
				if(i%2!=0)
					ans++;
				oi++;
			} else {
				if(i%2==0)
					ans++;
				ei++;
			}
		}
		
		System.out.println(ans/2);
		sc.close();
	}
}


Measured memory_bytes: 23868
import java.util.Scanner;

public class Main {

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

	    int a= gi();
	    int b= gi();
	    int c= gi();
        int d=3;
        if (a==b)d--;
        if (b==c)d--;
        if (c==a)d--;
        if(d==0)d++;
	    System.out.print(d);
	   
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35568