akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int H, W, count = 0;
  string S, Si;
  cin >> H >> W;
  
  for(int i = 0; i < H; i++){
    cin >> Si;
    S += Si;
  }
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(S.at(i * W + j) == '#'){
        cout << '#'; 
        continue;
      }
      if(j != 0){
        if(i != 0){
          if (S.at((i - 1) * W + j - 1) == '#') count++;
        }
        if (S.at(i * W + j - 1) == '#') count++;
        if(i != H - 1){
          if (S.at((i + 1) * W + j - 1) == '#') count++;
        }
      }
      if(j != W - 1){
        if(i != 0){
          if (S.at((i - 1) * W + j + 1) == '#') count++;
        }
        if (S.at(i * W + j + 1) == '#') count++;
        if(i != H - 1){
          if (S.at((i + 1) * W + j + 1) == '#') count++;
        }
      }
      if(i != 0){
        if (S.at((i - 1) * W + j) == '#') count++;
      }
      if(i != H - 1){
        if (S.at((i + 1) * W + j) == '#') count++;
      }
      cout << count;
      count = 0;
    }
    cout << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    double x[n];
    double y[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<n;i++){
        cin>>y[i];
    }
    double d1=0;
    for(int i=0;i<n;i++){
        d1+=fabs(y[i]-x[i]);
    }
    cout<<fixed<<setprecision(8)<<d1<<endl;
    double d2=0;
    for(int i=0;i<n;i++){
        d2+=pow(fabs(y[i]-x[i]),2);
    }
    cout<<pow(d2,0.5)<<endl;
    double d3=0;
    for(int i=0;i<n;i++){
        d3+=pow(fabs(y[i]-x[i]),3);
    }
    cout<<pow(d3,1.0/3)<<endl;
    double dmax=0;
    for(int i=0;i<n;i++){
        dmax=max(dmax,fabs(y[i]-x[i]));
    }
    cout<<dmax<<endl;
}


Measured memory_bytes: 3444
#include <iostream>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll power(ll x,ll n){
  if(!n) return 1;
  ll res = power(x * x % mod , n / 2);
  if(n & 1) res = res * x % mod;
  return res;
}

int main(){
  ll m,n;

  cin >> m >> n;
  cout << power(m,n) << endl;

  return 0;
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    map<int,int> m;
    
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    ll num = 1;
    int cur = 0;
    ll ret = 0;
    m[0]++;
    for(int i=0;i<(int)s.size();++i){
        cur = (cur + (s[i] - '0')*num)%2019;
        num = (num * 10)%2019;
        ret += m[cur];
        m[cur]++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3748
#include<stdio.h>

#define Max 2000000

int h, A[Max + 1];

void maxHeapify(int i){
  int l, r, largest, n;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= h && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= h && A[r] > A[largest]) largest = r;

  if(largest != i){
    n = A[i];
    A[i] = A[largest];
    A[largest] = n;

    maxHeapify(largest);
  }
}


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

  for(i = 1 ; i <= h ; i++) scanf("%d", &A[i]);

  for(i = h / 2 ; i >= 1 ; i--) maxHeapify(i);

  for(i = 1 ; i <= h ; i++){
    printf(" %d", A[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int main(){
	init();
	ll N,M;cin>>N>>M;
	UnionFind uf(N);
	for(int i=0;i<M;i++){
		ll a,b,c;cin>>a>>b>>c;
		a--;b--;
		uf.unite(a,b);
	}
	set<ll>set;
	for(int i=0;i<N;i++)set.insert(uf.find(i));
	cout<<set.size()<<endl;
}


Measured memory_bytes: 5376
#include<stdio.h>
#include<string.h>

int main(){
    char in_num[100000];
    int i, j, len;
    char s[] = "01";
    int ans1, ans2;

    for(i=0; i<10000; i++){
        scanf("%s", &in_num[i]);
    }
    len = strlen(in_num); 

    for(i=0; i<len; i++){
        j = i % 2;
        if(in_num[i] == s[j]){
            ans1 += 1;
        }
        j = (i+1) % 2;
        if(in_num[i] == s[j]){
            ans2 += 1;
        }
    }

    if(ans1 < ans2){
        printf("%d", ans1);
    }else{
        printf("%d", ans2);
    }

    return 0;
}

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

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

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

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int u[N][2];
int in[N];
bool red[N];  


int main () {
	SpeedForce;
	cin >> n >> m;
	red[1] = 1;
	for (int i = 1; i <= n; i ++) in[i] = 1;
	
	for (int i = 1; i <= m; i ++) {
		int x, y;
		cin >> x >> y;
		if (in[x] == 0) continue;
		red[y] |= red[x];
		in[x]--;
		in[y]++;
		if (!in[x]) red[x] = 0;
	}

	int ans = 0;
	for (int i = 1; i <= n; i ++) if (red[i]) {
		ans ++;
	}
	cout << ans << '\n';


   	return Accepted;
}

// B...a

Measured memory_bytes: 768
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
#include "atcoder/all"

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

    bool is_union(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        return ra == rb;
    }
};


ll solve() {
    int n, m;
    cin >> n >> m;

    UnionFind uf(n);
    rep(_, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.connect(a, b);
    }

    set<int> uni;
    rep(i, n) uni.insert(uf.root(i));

    return uni.size() - 1;


}

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


Measured memory_bytes: 7784
cin = open(0).read().strip().split('\n')
n, m, q = map(int, cin[0].split(' '))
abcd = [tuple(map(int, a.split(' '))) for a in cin[1:]]

ret = 0
import itertools
for case in itertools.combinations_with_replacement(list(range(1,m+1)), n):
    tmp = 0
    for c in abcd:
        if case[c[1]-1] - case[c[0]-1] == c[2]:
            tmp += c[3]
    ret = max(ret, tmp)
print(ret)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char s1[100];
    cin>>s1;
    int i=0,cn=0;
    while(s1[i]!='\0'){
        if(s1[i]=='1'){
            cn++;
        }
        i++;
    }
    cout<<cn<<endl;
    return 0;
}



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

int main(int argc, char **argv)
{
    int K, N;
    std::cin >> K >> N;
    std::vector<int> A(N);
    for (unsigned int i = 0; i < N; i++)
    {
        std::cin >> A.at(i);
    }
    std::vector<int> d(N);
    d.at(0) = (K - A.at(N - 1)) + A.at(0);
    for (int i = 1; i < N; i++)
    {
        d.at(i) = A.at(i) - A.at(i - 1);
    }

    //   for(unsigned int i = 0; i < N; i++){
    //       std::cout << d.at(i) << std::endl;
    //   }

    std::sort(d.begin(), d.end());

    int ans = 0;
    for (unsigned int i = 0; i < N - 1; i++)
    {
        ans += d.at(i);
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    int x;
    int y;
    
    for(int i=1;;i++){
           cin>>x;
           cin>>y;
        if(x==0&&y==0) break;
        if(x>y)swap(y,x);
         cout<<x<<" "<<y<<endl;
    }
    
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a=1;
  for(int i=0;i<n;i++){
    if(a>k)a+=k;
    else a*=2;
  }
  cout<<a<<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;
using ll = long long;

int main (){
  int n, m;
  cin >> n >> m;
  map<int, vector<string>> result;
  vector<int> p(m);
  vector<string> s(m);

  rep(i, m) {
    cin >> p[i] >> s[i];
    if (result[p[i]].empty()) { result[p[i]] = vector<string>();}
    result[p[i]].push_back(s[i]);
  }

  int ACs = 0, penalties = 0;
  for (pair<int, vector<string>> p : result) {
    int key = p.first;
    vector<string> value = p.second;
    bool ACed = false;
    int i = 0;
    int WAs = 0;
    while (!ACed) {
      if (p.second[i] == "WA") WAs++;
      if (p.second[i] == "AC") ACed = true;
      i ++;
      if (p.second.size() == i) break;
    }

    if (ACed) {
      ACs++;
      penalties += WAs;
    }
  }

  cout << ACs << " " << penalties << endl;
  return 0;

}


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

int main(){
    int n;
    cin >> n;
    int ans =0;
    while(n>=7){
        if(n%4==0){
            cout << "Yes" << endl;
            return 0;
        }
        n -= 7;
        ans ++;
    }
    if(n == 0)cout << "Yes" << endl;
    else if(n == 4)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
using namespace std;

static const int MAX_N = 110, INF = 999;
typedef pair<int, int> Pr;

int main(void){
  //入力
  int N;
  int a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N];
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < N; i++){
    cin >> c[i] >> d[i];
  }
  Pr red[MAX_N], blue[MAX_N];//red(x, y), blue(x, y)とした。
  for(int i = 0; i < N; i++){
    red[i].first = b[i];
    red[i].second = a[i];
    blue[i].first = c[i];
    blue[i].second = d[i];
  }

  //Greedyにとく二部マッチング
  sort(red, red + N, greater<Pr>());//redは降順
  sort(blue, blue + N);//blueは昇順
  //redの大きい方から，マッチングをとっていく。redより大きく，その中で一番小さいblueとマッチングしていく。
  int numPair = 0;
  //red[i]とblue[j]のマッチング
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(blue[i].first > red[j].second && blue[i].second > red[j].first){
        numPair++;
        red[j].first = INF;
        red[j].second = INF;
        break;
      }
    }
  }
  cout << numPair << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np

n, L = map(int, input().split())

aji = []
for i in range(n):
    aji.append(L + i)

sa = 1000
for i in range(len(aji)):
    tmp = aji[i]
    if abs(tmp) <= abs(sa):
        sa = tmp
        idx = i

sum_ = np.sum(aji)
ans = sum_ - sa

# min_ab_aji = np.min(np.abs(aji))
# sum_ = np.sum(aji)
# ans = sum_ - min_ab_aji

print(ans)


Measured memory_bytes: 12508
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define pye cout << "Yes" << endl;
#define pno cout << "No" << endl;
#define prin(num) cout << num << endl;
#define sprin(str) cout << "str" << endl;
#define INF 1000000000
#define MOD 1000000007
#define MAX 100001
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

ll modpow(ll x, ll n) {
    ll res=1;
    
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}


int main() {
    ll N, i;
    ll a[MAX];
    ll cnt[MAX]={0};
    cin >> N;
    for(i=0; i<N; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        if((N%2==0 && a[i]%2==0) || (N%2==1 && a[i]%2==1)) {
            prin(0);
            return 0;
        }
    }
    
    if(N%2==0) {
        for(i=1; i<N; i+=2) {
            if(cnt[i]!=2) {
                prin(0);
                return 0;
            }
        }
        prin(modpow(2, N/2));
    }else {
        if(cnt[0]!=1) {
            prin(0);
            return 0;
        }
        
        for(i=2; i<N; i+=2) {
            if(cnt[i]!=2) {
                prin(0);
                return 0;
            }
        }
        prin(modpow(2, N/2));
    }
    
    
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int w,n;
	cin >> w >> n;
	vector<int> b(n);
	vector<int> temp(n);
	if(w == 0 && n == 0) break;
	REP(i,n) cin >> b[i];
	temp = b;
	sort(ALL(temp));
	int l,m,h;
	int s,count;
	h = 1500000;
	l = 0;
	m = (h+l)/2;
	while(h-l>1){
	    s = 0;
	    count = 0;
	    if(temp.back() > m){
		l = m;
		m = (h+l)/2;
		continue;
	    }
	    REP(i,n){
		if((s+b[i]) > m){
		    s = 0;
		    count++;
		}
		s += b[i];
	    }

	    if(count < w){
		h = m;
	    }else{
		l = m;
	    }
	    m = (h+l)/2;
	}
	cout << h << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <map>
#define MAX_NUM 100
#define INFTY 1000000000
#define NIL -1

using namespace std;

//think easy make easy

int n;//num of input


pair<int,int> MatrixChain[MAX_NUM+1];
map<pair<int,int>,int> mapMC;

int calc(int s,int e){//s~eの連鎖行列積の最少計算回数を出力
	int min_time  = INFTY;
	int min_tmp;

	if(mapMC[pair<int,int>(s,e)] != NIL)
		return mapMC[pair<int,int>(s,e)];

	if(s == e){
		return 0;
	}
	for(int i=s;i<e;i++){
		min_tmp = calc(s,i) + calc(i+1,e) 
			+MatrixChain[s].first*MatrixChain[i].second*MatrixChain[e].second;
		if(min_tmp < min_time)
			min_time = min_tmp;
	}
	mapMC[pair<int,int>(s,e)] = min_time;//メモ
	return min_time;
}

int main(){
	scanf("%d",&n);
	int r,c;//row,column

	for(int i=0;i<n;i++){
		scanf("%d %d",&r,&c);
		MatrixChain[i] = pair<int,int>(r,c);//i:1~n-1
	}
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			mapMC[pair<int,int>(i,j)] = NIL;
		}
	}

	cout <<calc(0,n-1) <<endl;

	return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
//#define endl "/n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
struct sai{
    ll ue,mae,migi;
};
int main(){
    ll h,w;cin>>h>>w;
    string st[h];
    rep(i,0,h-1)cin>>st[i];
    bool b[h][w];
    rep(i,0,h-1){
        rep(j,0,w-1){
            b[i][j]=false;
        }
    }
    b[0][0]=true;
    queue<pair<sai,l_l>> q;
    sai s;
    s.ue=1;s.migi=3;s.mae=2;
    q.push(make_pair(s,make_pair(0,0)));
    while(q.size()>0){
        pair<sai,l_l> p=q.front();q.pop();
        s=p.first;
        sai sa;
        ll x=p.second.first;ll y=p.second.second;
        //cout<<x<<' '<<y<<endl;
        if(x>0){
            if(st[x-1][y]!='#' && b[x-1][y]==false){
                if(7-s.mae==st[x-1][y]-'0'){
                    b[x-1][y]=true;
                    sa.ue=s.mae;
                    sa.mae=7-s.ue;
                    sa.migi=s.migi;
                    q.push(make_pair(sa,make_pair(x-1,y)));
                }
            }
        }
        if(y>0){
            if(st[x][y-1]!='#' && b[x][y-1]==false){
                if(7-s.migi==st[x][y-1]-'0'){
                    b[x][y-1]=true;
                    sa.ue=s.migi;
                    sa.mae=s.mae;
                    sa.migi=7-s.ue;
                    q.push(make_pair(sa,make_pair(x,y-1)));
                }
            }
        }
        if(x<h-1){
            if(st[x+1][y]!='#' && b[x+1][y]==false){
                if(s.mae==st[x+1][y]-'0'){
                    b[x+1][y]=true;
                    sa.ue=7-s.mae;
                    sa.mae=s.ue;
                    sa.migi=s.migi;
                    q.push(make_pair(sa,make_pair(x+1,y)));
                }
            }
        }
        if(y<w-1){
            if(st[x][y+1]!='#' && b[x][y+1]==false){
                if(s.migi==st[x][y+1]-'0'){
                    b[x][y+1]=true;
                    sa.ue=7-s.migi;
                    sa.mae=s.mae;
                    sa.migi=s.ue;
                    q.push(make_pair(sa,make_pair(x,y+1)));
                }
            }
        }
    }
    if(b[h-1][w-1]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3252
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int main() {
    string s;
    cin >> s ;
    int begin_number,end_number;
    bool finished =true;
    int size = s.size();
    for(int i=0;i<size;i++){
        if(s[i] == 'A'){
            begin_number= i;
            for(int j=begin_number;j<size;j++){
                if(s[j]=='Z'){
                    end_number= j;
                    
                }

            }
            if(finished){
            break;
            }
        }
        
    }
    int length = (end_number - begin_number + 1);
    cout << length << endl;
}

Measured memory_bytes: 3760
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def init_fact_inv(MAX: int, MOD: int) -> list:
    """
    階乗たくさん使う時用のテーブル準備
    MAX：階乗に使う数値の最大以上まで作る
    """
    # 階乗テーブル
    factorial = [1] * MAX
    factorial[0] = factorial[1] = 1
    for i in range(2, MAX):
        factorial[i] = factorial[i-1] * i % MOD
    # 階乗の逆元テーブル
    inverse = [1] * MAX
    # powに第三引数入れると冪乗のmod付計算を高速にやってくれる
    inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
    for i in range(MAX-2, 0, -1):
        # 最後から戻っていくこのループならMAX回powするより処理が速い
        inverse[i] = inverse[i+1] * (i+1) % MOD
    return factorial, inverse

# 組み合わせの数(必要な階乗と逆元のテーブルを事前に作っておく)
def nCr(n, r, factorial, inverse):
    if n < r: return 0
    # 10C7 = 10C3
    r = min(r, n-r)
    # 分子の計算
    numerator = factorial[n]
    # 分母の計算
    denominator = inverse[r] * inverse[n-r] % MOD
    return numerator * denominator % MOD

def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD

N,A,B,C=MAP()

fact,inv=init_fact_inv(N*2+1, MOD)

# MODの割り算
AAB=fermat(A, A+B, MOD)
BAB=fermat(B, A+B, MOD)

ans=0
for m in range(N, N*2):
    # (引き分けを考えずに)m回で終わる確率
    x=(pow(AAB, N, MOD) * pow(BAB, m-N, MOD) + pow(BAB, N, MOD) * pow(AAB, m-N, MOD)) * nCr(m-1, N-1, fact, inv)
    # 引き分け以外の試合がm回行われるまでの試合数の期待値
    y=fermat(m*100, A+B, MOD)
    ans=(ans+x*y)%MOD
print(ans)


Measured memory_bytes: 20724
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
  int N, Y;
  cin >> N >> Y;
  for(int x=0; x<=N; ++x)
  {
    for(int y=0; y<=N, N-(x+y)>=0; ++y)
    {
      if(10000*x+5000*y+1000*(N-(x+y)) == Y)
      {
        printf("%d %d %d\n", x, y, N-(x+y));
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}

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

int main(){
	int N , K , S; cin >> N >> K >> S;
	for(int i = 1 ; i <= K ; ++i) cout << S << ' ';
	for(int i = K + 1 ; i <= N ; ++i) cout << (S == 1e9 ? 1 : 1000000000) << ' ';
	return 0;
}


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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var l = Console.ReadLine().Split().Select(int.Parse).ToList();
            Console.WriteLine(l.Sum() - l.Max() > l.Max() ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 28252
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define lp(i,n) for(int i=0;i<(n);i++)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define CTOI(x) (x - 'A') 
#define ctoi(x) (x - 'a')
#define BIT(x) (1 << (x))
#define int long long
using namespace std;

signed main(){
    int n, m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
int a;
int D[100000];
struct node{
    int x,y;
}num[100000];
int main(){
    int h,w,d;
    scanf("%d%d%d",&h,&w,&d);
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            scanf("%d",&a);
            num[a].x=i;
            num[a].y=j;
        }
    }
    int q,k1,k2;
    for(int i=d+1;i<=h*w;i++){
        D[i]=D[i-d]+abs(num[i-d].x-num[i].x)+abs(num[i].y-num[i-d].y);
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        int sum=0;
        scanf("%d%d",&k1,&k2);
        printf("%d\n",D[k2]-D[k1]);
    }
    return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, long long A, long long B){
    if((B-A) % 2 ==0){
        cout<< (B-A)/2<<endl;
        return;
    }
    cout << min(A-1+(B-A+1)/2, N-B + (B-A+1)/2) <<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
    a,b=min(a,b),max(a,b)
    if a==0:
        return b
    else:
        return gcd(b%a,a)

n=int(input())
l=[int(input()) for i in range(n)]
a=l[0]
for i in range(1,n):
    b=gcd(a,l[i])
    a=a*l[i]//b
print(a)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    string S; cin >> S;
    if(S.size()%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    REP(i,S.size()/2){
        if(S[2*i]!='h' || S[2*i+1]!='i'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

vector<string> str;
map<string, int> mp;
int h, w, maximum, co;
string ans;


void check(int y, int x){
	vector<vector<int>> used(h,vector<int>(w,0));
	int count = 1;
	string res;
	// cout<<"y = "<<y<<" x = "<<x<<endl;
	for(int i = -1; i <= 1; i++){
		for(int j = -1; j <= 1; j++){
			string temp;
			// cout<<"i = "<<i<<" j = "<<j<<endl;
			for(int ny = y, nx = x; count != used[ny][nx]; nx = (j+w+nx)%w, ny = (i+h+ny)%h){
				used[ny][nx] = count;
				temp.push_back(str[ny][nx]);
				// cout<<temp<<endl;
				if(temp.size() <= 1) continue;
				
				if(++mp[temp] != 2) continue;
				if(ans.size() < temp.size()){
					ans = temp;
				} else if(ans.size() == temp.size() && ans > temp){
					ans = temp;
				}
			}
			
			count++;
		}
	}
	
	
	// return res;
}

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	while(true){
		mp.clear();
		ans.clear();
		
		cin>>h>>w;
		
		if(!h && !w) break;
		
		str.clear();
		str.resize(h);
		
		for(int i = 0; i < h; i++){
			cin>>str[i];
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				check(i,j);
			}
		}
		
		cout<<(ans.size()?ans:"0")<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 37972
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#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 <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    string S;cin >> S;
    string T = "";
    bool ok = true;
    for(int i = S.size()-1;i>=0;i--){
        if(S.at(i) == 'm'){
            T = "dream" + T;
            i -= 4;
            continue;
        }
        if(S.at(i) == 'e'){
            i -= 4;
            T = "erase" + T;
            continue;
        }
        if(S.at(i) == 'r'){
            i -= 2;
            if(S.at(i) == 'm'){
                T = "dreamer" + T;
                i -= 4;
                continue;
            }
            else if(S.at(i) == 's'){
                i -= 3;
                T = "eraser" + T;
                continue;
            }
        }
        //cout << T << endl;
    }
    if(S == T){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define ll long long
const int MAXN=60,Mod=1e9+7;
ll ans;
int n,pre;
char s1[MAXN],s2[MAXN];
int main()
{
	scanf("%d",&n);
	scanf("%s",s1);scanf("%s",s2);
	for(register int i=0;i<strlen(s1);++i)
	{
		if(s1[i]==s2[i])
			if(!pre)
			{
				ans=3;
				pre=1;
				continue;
			}
			else
			{
				if(pre==1)ans=(ans*2)%Mod;
				pre=1;
				continue;
			}
		else
			if(!pre)
			{
				ans=6;
				pre=2;
				i++;
				continue;
			}
			else
			{
				if(pre==1)ans=(ans*2)%Mod;
				if(pre==2)ans=(ans*3)%Mod;
				i++;
				pre=2;
				continue;
			}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef pair<int, pi> pii;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define fax(i, a) for (int i = 0; i < (a); i++)
#define f0x(i, a, b) for (int i = (a); i < (b); i++)
#define faxd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define f0xd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define memeset memset
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
 
const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 500005;
const ld PI = 4*atan((ld)1);
ll tree[4*MX]; ll in[MX];
void build(int v, int l, int r) {
  if (l == r) {
    tree[v] = 0;
  } else {
    int m = (l + r) / 2;
    build(2 * v + 1, l, m);
    build(2 * v + 2, m + 1, r);
    tree[v] = tree[2 * v + 1] + tree[2 * v + 2];
  }
}
 
void update(int v, int l, int r, int i, int x) {
  if (i > r || i < l) {
    return;
  } else if (l == r) {
    tree[v] += x;
  } else {
    int m = (l + r) / 2;
    update(2 * v + 1, l, m, i, x);
    update(2 * v + 2, m + 1, r, i, x);
    tree[v] = tree[2 * v + 1] + tree[2 * v + 2];
  }
}
 
ll query(int v, int l, int r, int ql, int qr) {
  if (l > qr || r < ql) {
    return 0;
  } else if (l >= ql && r <= qr) {
    return tree[v];
  } else {
    int m = (l + r) / 2;
    ll a = query(2 * v + 1, l, m, ql, qr);
    ll b = query(2 * v + 2, m + 1, r, ql, qr);
    return a + b;
  }
}
 
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
map<int, int> compress; int cnt = 0; set<int> vals; vector<pi> queries[MX]; int pre[MX], ret[MX];
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n,q; cin >> n >> q;
   fax(i,n){
      cin >> in[i];
      vals.insert(in[i]);
   }
   trav(curr,vals){
      compress.insert({curr, cnt});
      cnt++;
   }
   fax(i,q){
      int a,b; cin >> a >> b;
      a--; b--;
      queries[b].pb({a, i});
   }
   build(0,0,n-1);
   memeset(pre, -1, sizeof(pre));
   fax(i,n){
      int comp = compress[in[i]];
      // cout << i << " " << pre[comp] << "\n";
      if(pre[comp] == -1){
         update(0,0,n-1,i,1);
         pre[comp] = i;
      }
      else{
         update(0,0,n-1,pre[comp], -1);
         update(0,0,n-1,i,1);
         pre[comp] = i;
      }
      for(pi val : queries[i]){
         // cout << val << " ";
         ret[val.s] = query(0,0,n-1,val.f,i);
      }
      // cout << endl;  
   }
   fax(i,q){
      cout << ret[i] << "\n";
   }
}

Measured memory_bytes: 88328
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#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);  
cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif    

    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[k]<a[i]+a[j] && a[i]!=a[j] && a[j]!=a[k])
                {
                    ans++;
                }

            }
        }
    }
    cout<<ans;

}


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

int main()
{
	int N, count = 0;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++){
	cin >> A[i];
  }
  
  bool flag;
  bool odd = false;
  bool even = true;
  while(A[0]%2 == 0){
    for(int i = 0; i < N; i++){
      if(A[i]%2 == 0)
        flag = even;
      else{
        flag = odd;
        break;
      }
    }
    if(flag){
      count++;
      for(int i = 0; i < N; i++){
        A[i] /= 2;
      }
    }
    else
      break;
  }
	cout << count << endl;
}

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

int dt[1001];
int main(){
    int a,b,ans;
    
    scanf("%d%d", &a,&b);
    ans = b - a;
    for(int i=1; i<=999; i++)
        dt[i] = dt[i-1] + i;
    
    printf("%d", dt[ans-1]-a);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define lint                     long long 
#define setbits(x)              __builtin_popcountll(x)
#define zrbits(x)               __builtin_ctzll(x)
#define zlbits(x)               __builtin_clzll(x)
#define parsbits(x)             __builtin_parityll(x)
#define mem(a, b)               memset(a, (b), sizeof(a))
#define MOD                     1000000007
#define inf                     1e17 
#define neginf                  -1e17 
#define sp(x,y)                 fixed<<setprecision(x)<<y
#define testcase(t)             lint t; cin>>t; while(t--)
#define power(a,b)              (double)pow((double)a,(double)b)
#define FOR(i,n)                for(lint i=0;i<n;i++)
#define gcd(a,b)                __gcd(a,b)
#define PI                      3.1415926535
#define pb                      push_back
#define umap                    unordered_map           
#define ummap                   unordered_multimap
#define uset                    unordered_set
#define umset                   unordered_multiset

	         
typedef unsigned long long   ull;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
	         
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//	#ifndef ONLINE_JUDGE
  //  freopen("input1.txt", "r", stdin);
    //freopen("output1.txt", "w", stdout);
//#endif

}

lint me(lint x, lint y, lint p)  
{  
	lint 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;  
}

struct hash_pair { 
	template <class T1, class T2> 
	size_t operator()(const pair<T1, T2>& p) const
	{ 
		 auto hash1 = hash<T1>{}(p.first); 
		 auto hash2 = hash<T2>{}(p.second); 
		 return hash1 ^ hash2; 
	} 
};


/*---------------------------SOLUTION---------------------------------*/

void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	lint n,l;
	cin>>n>>l;
	vector<string> v(n);
	FOR(i,n)
	cin>>v[i];
	sort(v.begin(),v.end());
	for(lint i=0;i<n;i++)
	{
		cout<<v[i];
	}
	cout<<endl;
}


int main()
{
	c_p_c();
	lint flg99=0;
	if(flg99==1)
	{
		testcase(t)
	        {
	        	solve();
	        }
	}
	else
	{
	        solve();
	}
	return 0;
}	        




Measured memory_bytes: 3616
#include <iostream>

using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N; ++i){
		//read input data and test it
		bool ok = true;
		int a, b;
		a = b = 0;
		for(int j = 0; j < 10; ++j){
			int c;
			cin >> c;
			if(b > c){
				ok = false;
			}else if(a > c){
				b = c;
			}else{
				a = c;
			}
		}
		if(ok){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long

using namespace std;

const int N=1e5+10;
int n,m,x,y,cnt,head[N],col[N],sz,flag; ll t[3],ans;
struct edge{int to,nxt,w;}e[N<<1];

void adde(int x,int y,int w){
	e[++cnt].to=y; e[cnt].nxt=head[x]; head[x]=cnt; e[cnt].w=w;
}

void dfs(int u,int c){
	t[col[u]=c]++;
	for (int i=head[u],v;i;i=e[i].nxt){
		v=e[i].to,sz+=e[i].w==1;
		if (col[v]!=-1) flag|=col[v]!=(c+e[i].w)%3;
		else dfs(v,(c+e[i].w)%3);
	}
}

int main(){
	scanf("%d%d",&n,&m);
	rep (i,1,m) scanf("%d%d",&x,&y),adde(x,y,1),adde(y,x,2);
	memset(col,-1,sizeof(col));
	rep (i,1,n) if (col[i]==-1){
		flag=sz=t[0]=t[1]=t[2]=0,dfs(i,0);
		if (flag) ans+=(t[0]+t[1]+t[2])*(t[0]+t[1]+t[2]);
		else if (!t[0]||!t[1]||!t[2]) ans+=sz;
		else ans+=t[0]*t[1]+t[1]*t[2]+t[2]*t[0];
	}
	printf("%lld\n",ans);
	return 0;
}


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

int BubbleSort(int array[], int array_size){
    int i, j;
    int cnt = 0;
    bool flag = 1;

    for(i = 0; flag; i++){
        flag = 0;
        for(j = array_size - 1; j > i; j--){
            if(array[j-1] > array[j]){
                swap(array[j-1], array[j]);
                flag = 1;
                cnt++;
            }
        }
    }
    
    return cnt;
}


int main(){
    int n;
    cin >> n;
    int A[100];
    for(int i = 0;i < n; i++) cin >> A[i];

    
    int cnt = BubbleSort(A, n);
    rep(i,n){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;

    return 0;

}



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

typedef long long ll;

struct Edge{ //边类型定义
	ll u,v; //起点和终点
	ll l;   //边长-----------------------------******（可能是浮点型）
};
ll n,m;   //n是点数，m是边数
const ll N=1005,M=2006; //问题中给出的可能的最大点数和最大边数（无向边算两条边）-----------------*******（根据实际问题修改）
const ll MAXL = 1e15;   //边的无限长
Edge edge[M+10];  //边集
ll pre[N+10];    //从源点到该点的路径上该点的前驱(以源点为根的路径树，根结点的值为-1）
ll dist[N+10];   //从源点到该点的最短距离

//松弛操作
bool relax( Edge e ){
	if( dist[e.v] > dist[e.u]+e.l ){
		dist[e.v] = dist[e.u]+e.l;
		pre[e.v] = e.u;
		return true;  //进行更新的话返回真值
	}
	return false;
}

bool relaxX(Edge e){
	if( dist[e.v] > dist[e.u]+e.l ){
		dist[e.v] = dist[e.u]+e.l;
		pre[e.v] = e.u;
		if((e.u)==(n-1)||(e.v==(n-1)))return true;  //进行更新的话返回真值
	}
	return false;
}

bool bellman(int s){
    //初始化dist[] 和 pre[]
	for(ll i=0 ; i<n ; i++){
		dist[i] = MAXL;
		pre[i] = -1;
	}
	dist[s] = 0;
	
	bool change = false;  //使用标记优化，提高效率
	for(ll i=1 ; i<n ; i++){
		change = false;
		for(ll j=0 ; j<m ; j++){
		    if( relax(edge[j]) )
              change = relax;
        }
		if( !change ) //如果对所有边进行的一次relax()操作没有更新说明已经找到了到所有点的最短路
		  break;
	}
	
    for(ll i=0 ; i<m ; i++){
		if( relaxX(edge[i]) )
			return false; //再对所有边进行一次relax()操作，如果有更新dist[]则说明存在负权回路
	}
	return true;
}

int main(){
	scanf("%lld%lld",&n,&m);
	ll a,b,c;
	for(int i=0;i<m;i++){
		scanf("%lld%lld%lld",&a,&b,&c);
		edge[i].u=a-1;
		edge[i].v=b-1;
		edge[i].l=-c;
	}
	if(bellman(0)){
		printf("%lld",-dist[n-1]);
	}else printf("inf");
	return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn main() {
    let n: usize = read();
    let mut max_id = 0_usize;
    let mut max1 = 0_usize;
    let mut max2 = 0_usize;
    for i in 0..n {
        let a: usize = read();
        if a > max2 {
            if a > max1 {
                max2 = max1;
                max1 = a;
                max_id = i;
            } else {
                max2 = a;
            }
        }
    }

    for i in 0..n {
        if i != max_id {
            println!("{}", max1);
        } else {
            println!("{}", max2);
        }
    }
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>>  var(n, vector<int>(m, 0))
#define vecb2(var, n, m)   vector<vector<bool>> var(n, vector<bool>(m, false))
#define vecll2(var, n, m)  vector<vector<ll>>   var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------
ll gcd(ll a, ll b){ return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){ return a/gcd(a,b)*b;}

int main(void) {
  ll n, x;
  cin >> n >> x;
  arrll(a,n);

  rep(i,n){
    a[i] = abs(a[i]-x);
  }
  ll ans=a[0];
  rep(i,n){
    ans = gcd(ans, a[i]);
  }
  prt(ans);

}


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


using namespace std;

bool isPlindrome(string s){
    string temp=s;
    reverse(temp.begin(),temp.end());
    return s==temp;
}

int main(void){

    string S;
    cin >> S;
    bool ans = true;
    if(!isPlindrome(S)){
        ans = false;
    }
    if(!isPlindrome(S.substr(0,S.size()/2))){
        ans = false;
    }

    cout << (ans ? "Yes" : "No") << endl;



    return 0;
}

Measured memory_bytes: 256