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

using namespace std;

int main(){
    #ifdef HOME
    freopen("input.txt", "rt", stdin);
    #endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    long long ans = -1;
    vector <long long> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++)
            ans = max(ans, max(a[i] - a[j], a[j] - a[i]));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace cola2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s_num = Console.ReadLine().Trim().Split(' ');
            int hight = int.Parse(s_num[0]);
            int width = int.Parse(s_num[1]);

            Console.WriteLine("{0} {1}", hight * width, 2 * width + 2 * hight);
        }
    }
}

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

int main(){

    int r, g, x;

    cin >> r >> g;

    x = 2 * g - r;

    if(r >= 0 && r <= 4500 && g >= 0 && g <= 4500) cout << x << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;

ll N;
ll A[200001];

int main(){
    cin >> N;
    for(int i=1;i<=N;i++) A[i] = 0;
    for(int i=2;i<=N;i++){
        ll a;
        cin >> a;
        A[a]++;
    }
    for(int i=1;i<=N;i++) cout << A[i] << endl;
    return 0;
}

Measured memory_bytes: 5128
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n;
	cin >> n;
	
	vvi can(n, vi(n));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> can[i][j];
			
	vi dp((1 << n));
	dp[0] = 1;
	for(int mask = 0; mask < (1 << n) - 1; mask++) {
		int a = __builtin_popcount(mask);
		for(int j = 0; j < n; j++) {
			if(can[a][j] && !((1 << j) & mask)) {
				dp[mask | (1 << j)] = (dp[mask] + dp[mask | (1 << j)]) % P;
			}
		}
	}
	
	cout << dp[(1 << n) - 1] << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 11380
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
void AddSubMul() {
	int A, B;
	cin >> A >> B;
	cout << max(A + B, max(A - B, A * B));
}

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

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

const int mod=1000000007;
LL N,M,fact[100010];

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

    int i;
    fact[0]=1;
    for (i=1; i<=max(N,M); i++)
        fact[i]=(1LL*i*fact[i-1])%mod;

    LL res=0;
    if (N==M-1 || N==M)
        res=(res+fact[N]*fact[M])%mod;

    if (M==N-1 || N==M)
        res=(res+fact[N]*fact[M])%mod;

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 1024
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)

// cout<<fixed<<setprecision(15)
static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

//点またはベクトル
class Point{
  public:
  double x,y;
  
  Point(double x=0, double y=0): x(x),y(y) {}
  
  Point operator+(Point p){return Point(x+p.x,y+p.y);}
  Point operator-(Point &p){return Point(x-p.x,y-p.y);}
  Point operator*(double a){return Point(a*x,a*y);}
  Point operator/(double a){return Point(x/a,y/a);}
  
  bool operator<(const Point &p) const{
    return x != p.x ? x<p.x : y<p.y;
  }
  
  bool operator==(const Point &p) const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
  }
};
typedef Point Vector;
//ベクトルの二乗和と絶対値
double norm(Point p){return p.x*p.x+p.y*p.y;}
double abs(Point p){return sqrt(norm(p));}
//線分または直線
struct Segment{Point p1,p2;};
typedef Segment Line;
//円
class Circle{
public:
  Point c;
  double r;
  Circle(Point c=Point(), double r=0.0): c(c), r(r) {}
};
//多角形
typedef vector<Point> Polygon;
//内積
double dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}
//外積
double cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}
//直交判定
bool isOrthgonal(Vector a,Vector b){return equals(dot(a,b), 0.0);}
//平行判定
bool isParallel(Vector a,Vector b){return equals(cross(a,b), 0.0);}
//射影
Point project(Segment s,Point p){
  Vector base=s.p2-s.p1;
  double r=dot(p-s.p1,base)/norm(base);
  return s.p1+base*r;
}
//反射
Point reflect(Segment s,Point p){return p+(project(s,p)-p)*2.0;}
//点と点の距離
double getDisPP(Point a,Point b){return abs(a-b);}
//直線と点の距離
double getDisLP(Line l,Point p){return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);}
//線分と点の距離
double getDisSP(Segment s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0) return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0) return abs(p-s.p2);
  return getDisLP(s,p);
}
//線分と線分の距離
double getDisSS(Segment s1,Segment s2){
//  if(intersect(s1,s2)) return 0.0;
  return min(min(getDisSP(s1,s2.p1),getDisSP(s1,s2.p2)),
             min(getDisSP(s2,s1.p1),getDisSP(s2,s1.p2)));
}
//反時計周りCounter-Clockwise
int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>EPS) return COUNTER_CLOCKWISE;
  if(cross(a,b)<-EPS) return CLOCKWISE;
  if(dot(a,b)<-EPS) return ONLINE_BACK;
  if(norm(a)<norm(b)) return ONLINE_FRONT;
  return ON_SEGMENT;
}
//線分の交差判定
bool intersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 &&ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}
bool intersect(Segment s1,Segment s2){return intersect(s1.p1,s1.p2,s2.p1,s2.p2);}

int main(){
  Point p0,p1,p2,p3;
  int q;
  cin>>q;
  
  rep(i,q){
    cin>>p0.x>>p0.y>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y;
    cout<<intersect(p0,p1,p2,p3)<<endl;
  }
    
  return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
const ll MOD = (ll) 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);

	ll n; cin >> n;
	ll k; cin >> k;

	vl a(n); FOR(i,0,n) cin >> a[i];

	vvl dp(n + 1, vl(k + 1, 0));
	dp[0][0] = 1;

	FOR(i,1,n+1) {
		ll len = 0;
		ll ges = 0;
		FOR(j,0, k+1) {
			ges = (ges + dp[i-1][j]) % MOD;
			if (len == a[i-1] + 1) {
				ges = ((ges - dp[i-1][j - a[i-1] - 1]) + MOD) % MOD;
			} else {
				len++;
			}
			dp[i][j] = ges;
		}
	}

	cout << dp[n][k] << endl;

	return 0;
}


Measured memory_bytes: 80256
#include <stdio.h>
#include <algorithm>

int main() {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	int time = 0;
	while ((A % 2 == 0 && B % 2 == 0 && C % 2 == 0) && !(A == B && B == C && C == A)) {
		time++;
		int TA = (B + C) / 2;
		int TB = (A + C) / 2;
		int TC = (A + B) / 2;
		A = TA;
		B = TB;
		C = TC;
	}
	if (A == B && B == C && C == A && A % 2 == 0)
		printf("%d\n", -1);
	else
		printf("%d\n",time);
}

Measured memory_bytes: 888
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> A(n);

    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    
    vector<int> vec(n);

    for(int i=0;i<n;i++){
        vec[i] = A[i] - (i+1);
    }

    sort(vec.begin(),vec.end());

    ll ans = 0,ans1 = 0,ans2 = 0;

    if(n%2==1){
        int b = vec[n/2];
        //cout << n/2 +1 << " " << vec[n/2 + 1] << endl;
        //cout << n/2 + 1 << endl;
        //cout << b << endl;
        for(int i=0;i<n;i++){
            //cout << vec[i] << " ";
            ans += abs(vec[i] - b);
        }
    }
    else{
        int b = (vec[n/2-1] + vec[n/2])/2;
        for(int i=0;i<n;i++){
            ans += abs(vec[i] - b);
        }
        for(int i=0;i<n;i++){
            ans1 += abs(vec[i] - b - 1);
        }    
        for(int i=0;i<n;i++){
            ans2 += abs(vec[i] - b + 1);
        }
        ans = min(ans,min(ans1,ans2));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <ctype.h>
using namespace std;
int a,b,n;
int main(void)
{
    cin >> a >> b;
    cout << a-b+1 << endl;

    return 0;
}

Measured memory_bytes: 764
n, D = map(int, input().split())
x = list(map(int, input().split()))
Q = int(input())
q = list(map(int, input().split()))

ind = [D]
for i in range(n):
	ind.append(min(ind[-1], abs(ind[-1] - x[i])))
#print(ind)

l = [1]
for i in range(n-1, -1, -1):
	if x[i] < 2*l[-1]:
		l.append(x[i] + l[-1])
	else:
		l.append(l[-1])
l = l[::-1]

for i in range(Q):
	if l[q[i]] <= ind[q[i]-1]:
		print("YES")
	else:
		print("NO")

Measured memory_bytes: 78512
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        high = sh + abs(sx - i) + abs(sy - j)
        judge = -1
        for x, y, h in lis:
            if h > 0 and high != h + abs(x - i) + abs(y - j):
                judge = 0
                break
        if judge == 0:
            continue
        for x, y, h in lis:
            if h == 0 and high > abs(x - i) + abs(y - j):
                judge = 0
                break
        if judge == 0:
            continue
        
        print(i, j, sh + abs(sx - i) + abs(sy - j))
        exit()

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
//const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll H;
	cin >> H;

	
	ll power = 0;
	while (H != 0) {

		if (H != 1) {
			H /= 2;
			power++;
		}
		else {
			H = 0;
			power++;
			break;
		}


	}

	cout << ll(pow(2,power)-1);

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

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

int selectionSort(vector<int>& data, int N){
    int count = 0;
    int min_i;

    for (int i = 0; i < N; i++)
    {
        int min = 101;
        for(int j = i; j < N; j++){
            if(data.at(j) < min){
                min_i = j;
                min = data.at(j);
            }
        }
        if(i != min_i){
            swap(data.at(i), data.at(min_i));
            count++;
        }
    }

    rep(i, N){
        cout << data.at(i);
        if(i < N - 1) cout << ' ';
    }
    cout << endl;
    return count;
}

int main(){
    int N;
    cin >> N;
    vector<int> data(N);
    rep(i, N)
    {
        cin >> data.at(i);
    }
    cout << selectionSort(data, N) << endl;
    return 0;
}


Measured memory_bytes: 3104
program abc129_d
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: h,w,x,y
    integer(int32):: l
    integer(int32), allocatable:: a(:,:),ta(:)
    character(1), allocatable:: s(:,:)


    read*, h,w
    allocate(a(w,h), s(w,h))

    input_s : block
        character(w):: inpt_s
        do y=1,h
            read*, inpt_s
            do x=1,w
                s(x,y) = inpt_s(x:x)
            end do
        end do
    end block input_s

    allocate(ta(0:w+1))
    a(:,:) = 0
    do y=1,h
        ta(:) = 0
        do x=1,w
            if (s(x,y) == '.') then
                ta(x) = ta(x-1) + 1
            else
                ta(x) = 0
            end if
        end do
        a(:,y) = a(:,y) + ta(1:w)
        ta(:) = 0
        do x=w,1,-1
            if (s(x,y) == '.') then
                ta(x) = ta(x+1)+1
            else
                ta(x) = 0
            end if
        end do
        a(:,y) = a(:,y) + ta(1:w)
    end do

    deallocate(ta)
    allocate(ta(0:h+1))

    do x=1,w
        ta(:) = 0
        do y=1,h
            if (s(x,y) == '.') then
                ta(y) = ta(y-1) + 1
            else
                ta(y) = 0
            end if
        end do
        a(x,:) = a(x,:) + ta(1:h)
        ta(:) = 0
        do y=h,1,-1
            if (s(x,y) == '.') then
                ta(y) = ta(y+1) + 1
            else
                ta(y) = 0
            end if
        end do
        a(x,:) = a(x,:) + ta(1:h)
    end do

    a(:,:)=a(:,:)-3
    print'(i0)', maxval(a)
end program abc129_d

Measured memory_bytes: 19712
A,B,M = map(int,input().split())
Frigo = list(map(int,input().split()))
Micro = list(map(int,input().split()))
Discount = []
for i in range(M):
  x,y,c = map(int,input().split())
  Discount.append(Frigo[x-1]+Micro[y-1]-c)
Best_discount = min(Discount)
print(min((min(Frigo)+min(Micro)),Best_discount))
             

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

int main() {

	int n; cin >> n;

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

	sort(a.begin(),a.end());

	ll ans;
	if (n % 2 != 0) {
		ll b = a[n / 2];
		for (int i = 0; i < n; i++) {
			ans += abs(a[i] - b);
		}
	}
	else{
		ll ans_left = 0;
		ll ans_right = 0;
		ll b_left = a[n / 2 - 1];
		ll b_right = a[n / 2];

		for (int i = 0; i < n; i++) {
			ans_left += abs(a[i] - b_left);
			ans_right += abs(a[i] - b_right);			
		}
		ans = min(ans_left, ans_right);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        int X = sc.nextInt();
        for (int i = 0 ; i < N ; i++) {
            int A = sc.nextInt();
            X += (D - 1)/A + 1;
        }
        System.out.println(X);
    }

}


Measured memory_bytes: 22996
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
   int a,b,C;
   double S,L,h,x,PI;
   PI = 3.141592653589;
   cin >> a >> b >> C;
   x = C*PI/180;
   S = a*b*sin(x)/2;
   L = a+b+(sqrt(a*a+b*b-2*a*b*cos(x)));
   h = S*2/a;
   cout << fixed << setprecision(5) << S << endl << L << endl << h << endl;
}


Measured memory_bytes: 3476
/*
 * Author : Sadi
 * Tue 21/07/2020
 * 18:14:11.73
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n, m;
    cin >> n >> m;
    vector<int> height(n + 1), ma(n + 1, 0);
    for(int i = 1; i <= n; ++i) {
        cin >> height[i];
    }
    for(int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        ma[u] = max(ma[u], height[v]);
        ma[v] = max(ma[v], height[u]);
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        ans += height[i] > ma[i];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3972
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007


int main()
{
	string s;
	long long int k;
	cin >> s >> k;
	int cnt = 0;
	while(cnt < s.length() && cnt + 1 < k && s[cnt] == '1') cnt++;
	if(cnt == s.length()) cout << 1 << endl;
	else cout << s[cnt] << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
*A,=map(int,input().split())
mod=10**9+7

def nC2(n):
  return n*(n-1)//2

inv=0
for i in range(N-1):
  for j in range(i+1,N):
    if A[j]<A[i]: inv += 1
      
inv2=0
B = sorted(A,reverse=True)
for i in range(N-1):
  for j in range(i+1,N):
    if B[j]<B[i]: inv2 += 1

print((inv*K+inv2*nC2(K))%mod)

Measured memory_bytes: 9208
import qualified Data.Map as M
import Data.List

data ABC = AB | BC | AC deriving Read

main = do
  li <- getLine
  let [n,a,b,c] = map read $ words li
  co <- getContents
  let ss = map read $ lines co
  let ans = compute n a b c ss
  putStrLn ans

{-
一見、Greedyに、指定された両者のうち大きい方から小さい方へ値を移せばよさそう。
示されているNo例は、0で詰みになっているものばかり。
問題は、両者が等しいときに、いずれかの操作をしなくてはならないので、
そこで将来の可能性が増えてしまう。
それは全部パラに扱う、でいけないだろうか。
可能性が消えたらアウトということで。
-}

compute :: Int -> Int -> Int -> Int -> [ABC] -> String
compute n a b c ss =
  case loop (M.singleton (a,b,c) "") ss of
    Nothing -> "No"
    Just ts -> "Yes\n" ++ intersperse '\n' (reverse ts)

loop :: M.Map (Int,Int,Int) String -- (A,B,C)とそれに至る着手のひとつ
     -> [ABC]                      -- list of s_i
     -> Maybe String
loop m [] = snd <$> M.lookupMin m
loop m (abc:abcs) = loop (M.fromList $ filter check $ concatMap (f abc) $ M.assocs m) abcs
-- このloopはfoldlでまとめられる

check ((a,b,c),_) = a >= 0 && b >= 0 && c >= 0

-- Lensを使えばこのクローンはきれいにできそうだが。checkも込みで。
f AB ((a,b,c),st) = [((succ a, pred b, c),'A':st) | a <= b] ++ [((pred a, succ b, c),'B':st) | a >= b]
f AC ((a,b,c),st) = [((succ a, b, pred c),'A':st) | a <= c] ++ [((pred a, b, succ c),'C':st) | a >= c]
f BC ((a,b,c),st) = [((a, succ b, pred c),'B':st) | b <= c] ++ [((a, pred b, succ c),'C':st) | b >= c]


Measured memory_bytes: 13156
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			char ch[] =in.next().toCharArray();
			if((ch[0]=='o'&&ch[1]=='o'&&ch[2]=='o')||(ch[3]=='o'&&ch[4]=='o'&&ch[5]=='o')||(ch[6]=='o'&&ch[7]=='o'&&ch[8]=='o')
					||(ch[0]=='o'&&ch[3]=='o'&&ch[6]=='o')||(ch[1]=='o'&&ch[4]=='o'&&ch[7]=='o')||(ch[2]=='o'&&ch[5]=='o'&&ch[8]=='o')
					||(ch[0]=='o'&&ch[4]=='o'&&ch[8]=='o')||(ch[2]=='o'&&ch[4]=='o'&&ch[6]=='o'))
				System.out.println("o");
			else
				if((ch[0]=='x'&&ch[1]=='x'&&ch[2]=='x')||(ch[3]=='x'&&ch[4]=='x'&&ch[5]=='x')||(ch[6]=='x'&&ch[7]=='x'&&ch[8]=='x')
						||(ch[0]=='x'&&ch[3]=='x'&&ch[6]=='x')||(ch[1]=='x'&&ch[4]=='x'&&ch[7]=='x')||(ch[2]=='x'&&ch[5]=='x'&&ch[8]=='x')
						||(ch[0]=='x'&&ch[4]=='x'&&ch[8]=='x')||(ch[2]=='x'&&ch[4]=='x'&&ch[6]=='x'))
					System.out.println("x");
				else
					System.out.println("d");
		}
	}
}

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

int main() {

	int a, b;

	cin >> a >> b;

	if (((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0) && (a > 0 || b > 0)) cout << "Possible\n";

	else cout << "Impossible\n";



}

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

ll logceil( ll x , ll y, vector<ll> &A ){
    ll c=x; 
    for(int i=0; i< A.size(); i++ ){
        if( A.at(i)*x >= y ) return i; 
    }
}


int main(void){
    // Your code here!
    ll N, K;
    cin >> N >> K;
    
    vector<ll> pot(32); 
    pot.at(0)=1;  
    for(int i=1; i<32; i++){
        pot.at(i)=2*pot.at(i-1);  
    }
    
    
    ll count =0;
    
    if(N>=K){
            for(int i=1; i<=K-1; i++){
                count = count + pot.at(24- logceil( i, K, pot ));  
            }    
            long double A = (long double) (N-K+1)/N;
            long double B = (long double) count/(N*pot.at(24));
            cout << fixed << setprecision(10) <<  A+B << endl;
        
    }else{
        for(int i=1; i<=N; i++){
                count = count + pot.at(24- logceil( i, K, pot ));  
            }  
            cout << fixed << setprecision(10) << (long double) count/(N*pot.at(24)) << endl;
    }

    
}

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 vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};


int Knapsack_01(int N,int W,vector<int> v,vector<int> w) {

  int dp[N+1][W+1];
//std::vector<std::vector<int> > dp(N + 1, std::vector<int>(W + 1, 0));
  for (int i = 0; i <= N; i++) dp[i][0] = 0;
  for (int j = 0; j <= W; j++) dp[0][j] = 0;

  REP(i, N) REPS(j, 1, W+1){
      if (j < w[i]) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j], dp[i+1][j - w[i]] + v[i]);
  }
  return dp[N][W];
}


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

  int N, W;
  cin >> N >> W;

  vvint(v, w, N);

  cout << Knapsack_01(N, W, v, w) << endl;

}

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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w;
    cin>>h>>w;
    char a[h+1][w+1];
    int nr[h+1]={0};
    int nc[w+1]={0};
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='.')
            {
                nr[i]++;
                nc[j]++;
            }
        }
    }
    for(int i=1;i<=h;i++)
    {
        if(nr[i]!=w)
        {
            for(int j=1;j<=w;j++)
            {
                if(nc[j]!=h)
                {
                    cout<<a[i][j];
                }
            }
            cout<<"\n";
        }

    }
}


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

int n, q;
string s;
bool tree[1 << 20][26];

void update(int x, int c, bool b) {
	x += 1 << 19;
	tree[x][c] = b;
	while (x) {
		x /= 2;
		tree[x][c] = (tree[x + x][c] | tree[x + x + 1][c]);
	}
}

bool calc(int l, int r, int c) {
	l += 1 << 19;
	r += 1 << 19;
	while (l <= r) {
		if (tree[l][c] | tree[r][c])
			return true;
		l = (l + 1) / 2;
		r = (r - 1) / 2;
	}
	return false;
}

int main() {
	cin >> n >> s >> q;
	for (int i = 0; i < n; i++) update(i, s[i] - 'a', true);

	for (int i = 0; i < q; i++) {
		int t;
		cin >> t;
		if (t == 1) {
			int i;
			char c;
			cin >> i >> c;
			i--;
			update(i, s[i] - 'a', false);
			s[i] = c;
			update(i, s[i] - 'a', true);
		}
		else {
			int l, r;
			cin >> l >> r;
			l--; r--;
			int cnt = 0;
			for (int i = 0; i < 26; i++) {
				cnt += calc(l, r, i);
			}
			cout << cnt << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 27524
#include <stdio.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll d,e;
	while(scanf("%lld%lld",&d,&e),d){
		double ans=1e10;
		rep(x,0,d)ans=min(ans,fabs(hypot(x,d-x)-e));
		printf("%f\n",ans);
	}
}



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

using ll = long long;
const ll mod = 1e9 + 7;

const auto ready = []()
{
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios_base::sync_with_stdio(false);
	return true;
}();

ll fast_pow(ll a, ll b, ll m)
{
	if (b == 0)
		return (m == 1) ? 0 : 1;
	if (b % 2 == 0) {
		ll t = fast_pow(a, b / 2, m);
		return t * t % m;
	}
	return fast_pow(a, b - 1, m) * a % m;
}

ll inv(ll a)
{
	return fast_pow(a, mod - 2, mod);
}

const int mx = 2e6 + 10;
int facts[mx];
int revFacts[mx];

const auto precalc = []()
{
	facts[0] = 1;
	revFacts[0] = 1;
	for (int i = 1; i < mx; ++i) facts[i] = 1LL * facts[i - 1] * i % mod;
	revFacts[mx - 1] = inv(facts[mx - 1]) % mod;
	for (int i = mx - 2; i > 0; --i) revFacts[i] = 1LL * revFacts[i + 1] * (i + 1) % mod;
	return true;
}();

ll C(int n, int k)
{
    ll ans = 1;
    for(ll i = n; i >= (n - k + 1); --i) ans = (ans * i) % mod;
    return ans * revFacts[k] % mod;
}

int main()
{
    int x1, y1, x2, y2;
    int x3, y3, x4, y4;
    std::cin >> x1 >> y1 >> x2 >> y2;
    if(!(((x1 <= x2) && (y1 <= y2)) || ((x2 <= x1) && (y2 <= y1)))) std::swap(x1, x2);
    if(x1 >= x2 && y1 >= y2) std::swap(x1, x2), std::swap(y1, y2);
    ++x2, ++y2;
    x3 = x2; y3 = y1; x4 = x1; y4 = y2;
    ll ans = C(x1 + y1, x1) + C(x2 + y2, x2) - C(x3 + y3, x3) - C(x4 + y4, x4);
    ans %= mod;
    if(ans < 0) ans += mod;
    std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 19256
# -*- coding: utf-8 -*-
"""
D - We Like AGC
https://atcoder.jp/contests/abc122/tasks/abc122_d

"""
import sys
import re

N = None
memo = None

def ok(last4):
    if re.search(r'AGC|GAC|ACG|A.GC|AG.C', last4):
        return False
    return True


def dfs(cur, last3):
    global memo
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1

    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:]+c)) % (10**9 + 7)
    memo[cur][last3] = ret
    return ret


def main(args):
    global N, memo
    N = int(input())
    memo = [dict() for i in range(N+1)]
    ans = dfs(0, 'TTT')
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 4084
import java.util.*;

class Main{
  public static void main(String[] args){
    try(Scanner sc = new Scanner(System.in)){
      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());
      int c = Integer.parseInt(sc.next());
      int d = Integer.parseInt(sc.next());
      int right = c + d;
      int left = a + b;
      if(left > right){
        System.out.println("Left");
      }
      if(left == right){
        System.out.println("Balanced");
      }
      if(left < right){
        System.out.print("Right");
      }
    }
  }
}
      
    

Measured memory_bytes: 21844
//#pragma GCC optimize(2)
//ÄÏ¾©ÊÐµÚÈýÇøOIÎ¯ÌáÐÑÄú£º
//´úÂëÇ§ÍòÌõ£¬-O2µÚÒ»Ìõ¡£
//-O2²»¹æ·¶£¬³¬Ê±Á½ÐÐÀá¡£
// Happy TLE and WA every day!
// by: zxb
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
#define read            ZXBs_fast_input
#define write           ZXBs_fast_output
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool write(int x){
	if(x >= 10) write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int X, A;
	cin >> X >> A;
	if(X < A) cout << "0\n";
	else  cout << "10\n";
	return 0;
}


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

#define endl '\n'

using namespace std;

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

    int n;
    cin >> n;
    unordered_map<char, int> mapa;
    
    while (n--)
    {
        string s;
        cin >> s;
        ++mapa[s[0]];
    }
    cout << "AC x " << mapa['A'] << endl;
    cout << "WA x " << mapa['W'] << endl;
    cout << "TLE x " << mapa['T'] << endl;
    cout << "RE x " << mapa['R'] << endl;

    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

struct TCoordinate
{
	double x;
	double y;
};

TCoordinate GetCenterPoint(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	double x1 = P1.x;
	double x2 = P2.x;
	double x3 = P3.x;
	double y1 = P1.y;
	double y2 = P2.y;
	double y3 = P3.y;
	double x, y, r;
	if(y1 == y2 || y2 == y3 || y3 == y1){
		if(y2 == y3){
			swap(x3, x1);
			swap(y3, y1);
		}else if(y3 == y1){
			swap(x2, x3);
			swap(y2, y3);
		}
		double xa = (x2 + x3) / 2;
		double ya = (y2 + y3) / 2;
		double a  = (-x3 + x2) / (y3 - y2);
		x = (x1 + x2) / 2;
		y = a * (x - xa) + ya;
	}else{
		double xa = (x1 + x2) / 2;
		double ya = (y1 + y2) / 2;
		double a  = (-x2 + x1) / (y2 - y1);
		double xb = (x2 + x3) / 2;
		double yb = (y2 + y3) / 2;
		double b  = (-x3 + x2) / (y3 - y2);
		x = (b * xb - a * xa - yb + ya) / (b - a);
		y = a * (x - xa) + ya;
	}
	return {x, y};
}

double GetRadius(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	double x1 = P1.x;
	double x2 = P2.x;
	double x3 = P3.x;
	double y1 = P1.y;
	double y2 = P2.y;
	double y3 = P3.y;
	double x, y, r;
	if(y1 == y2 || y2 == y3 || y3 == y1){
		if(y2 == y3){
			swap(x3, x1);
			swap(y3, y1);
		}else if(y3 == y1){
			swap(x2, x3);
			swap(y2, y3);
		}
		double xa = (x2 + x3) / 2;
		double ya = (y2 + y3) / 2;
		double a  = (-x3 + x2) / (y3 - y2);
		x = (x1 + x2) / 2;
		y = a * (x - xa) + ya;
	}else{
		double xa = (x1 + x2) / 2;
		double ya = (y1 + y2) / 2;
		double a  = (-x2 + x1) / (y2 - y1);
		double xb = (x2 + x3) / 2;
		double yb = (y2 + y3) / 2;
		double b  = (-x3 + x2) / (y3 - y2);
		x = (b * xb - a * xa - yb + ya) / (b - a);
		y = a * (x - xa) + ya;
	}
	return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		TCoordinate P1, P2, P3;
		cin >> P1.x >> P1.y >> P2.x >> P2.y >> P3.x >> P3.y;
		TCoordinate CenterPoint = GetCenterPoint(P1, P2, P3);
		double Radius = GetRadius(P1, P2, P3);
		cout << fixed << setprecision(3) << CenterPoint.x << ' ' << CenterPoint.y << ' ' << Radius << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
 
#define ll long long 
# define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std ;
 
ll z , o , ans ;

ll N = 1e4 + 15820 ;

int main(){ skorost ;

	string s ;

	cin >> s ;

	deque<char>vc;

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

		if( s[i] == '0' ){

			vc.push_back('0');

		}

		if( s[i] == '1' ){

			vc.push_back('1') ;

		}

		if( s[i] == 'B' ){

			if( vc.size() > 0 ){

				vc.pop_back();

			}

		}

	} 

	for( int i = 0 ; i < (int) vc.size() ; i ++ ){

		cout << vc[i] ;

	}

	cout << endl ;

}

Measured memory_bytes: 256
#n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

#n = int(input())
n,m = map(int,input().split())
a_L = list(map(int,input().split()))

ans = n-sum(a_L)

if ans >= 0:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 68096
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	int n, k;
	cin >> n >> k;
	long h[100000];
	long dp[100000];


	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}

	dp[0] = 0;
	for (int i = 1; i < n; i++)
	{
		long min = -1;
		for (int j = 1; j <= k && i - j >= 0; j++)
		{
			long cost = dp[i - j] + abs(h[i] - h[i - j]);
			if (min == -1 || min > cost)
			{
				min = cost;
			}
		}
		dp[i] = min;
	}
	cout << dp[n - 1];
}


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

using namespace std;

#define first ff
#define second ss

typedef long long ll;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 7;

ll f[MAXN];

ll bin_pow(ll x, ll k) {
    if (k == 0) {
        return 1;
    }
    if (k % 2 == 0) {
        ll res = bin_pow(x, k / 2);
        return (res * res) % MOD;
    } else {
        return (bin_pow(x, k - 1) * x) % MOD;
    }
}

ll C(ll n, ll k) {
    ll res = (f[n] * bin_pow(f[n - k], MOD - 2) % MOD) * bin_pow(f[k], MOD - 2) % MOD;
    return res;
}

int main() {
#ifdef LOCAL
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#else
    // freopen("levenshtein.in", "r", stdin);
    // freopen("levenshtein.out", "w", stdout);
#endif

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

    ll n, k;
    cin >> n >> k;
    k = min(n - 1, k);

    ll ans = 0;

    f[0] = 1;

    for (int i = 1; i <= n; i++) {
        f[i] = f[i - 1] * i % MOD;
    }

    for (ll i = 0; i <= k; i++) {
        ans = (ans + C(n, i) * C(n - 1, n - i - 1)) % MOD;
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include <string>

using namespace std;

int main(){
    string o,e;
    cin >> o >> e;
    if(o.size() > e.size()){    
        for(int i=0;i<e.size();i++){
            cout << o[i];
            cout << e[i];
        }
        cout << o[o.size()-1];
    }

    else if(o.size() == e.size()){    
        for(int i=0;i<o.size();i++){
            cout << o[i];
            cout << e[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        s = S()
        t = S()
        l = len(t)
        def f(s):
            i = 0
            for c in s:
                while i < l and t[i] != c:
                    i += 1
                if i == l:
                    return False
                i += 1
            return True

        if f(s[0::2]) or f(s[1::2]):
            rr.append('Yes')
        else:
            rr.append('No')

        break



    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0028
{
	class Program
	{
		static void Main(string[] args)
		{
			int[]	num	= new int[ 101 ];

			while( true ) {
				var	s	= Console.ReadLine();
				if( s == null ) {
					break;
				}
				num[ int.Parse( s ) ]++;
			}
			
			int	max	= 0;
			for( int i = 1; i <= 100; i++ ) {
				if( num[ i ] > max ) {
					max	= num[ i ];
				}
			}

			for( int i = 1; i <= 100; i++ ) {
				if( num[ i ] == max ) {
					Console.WriteLine( i );
				}
			}
		}
	}
}

Measured memory_bytes: 17888
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define li long long int
#define mod 1000000000+7
li n,k;
li a[105];
li dp[100000+5];
void f()
{
    li i,j;
    dp[0]=0;


    for(i=1;i<=k;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i<a[j])
            {
                continue;
            }
            if(dp[i-a[j]]==0)
            {
                dp[i]=1;

            }
        }
    }


}

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

    memset(dp,0,sizeof(dp));
    li i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }

    f();

    if(dp[k])
    {
        cout<<"First";
    }
    else
    {
        cout<<"Second";
    }
    return 0;
}


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

int main() {
    char b;
    cin >> b;

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

    cout << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    vector<vector<bool>> F(H, vector<bool>(W, 1));
    for (int i = 0; i < N; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < x; j++) {
                    F[i][j] = 0;
                }
            }
        } else if (a == 2) {
            for (int i = 0; i < H; i++) {
                for (int j = x; j < W; j++) {
                    F[i][j] = 0;
                }
            }
        } else if (a == 3) {
            for (int i = 0; i < W; i++) {
                for (int j = 0; j < y; j++) {
                    F[j][i] = 0;
                }
            }
        } else {
            for (int i = 0; i < W; i++) {
                for (int j = y; j < H; j++) {
                    F[j][i] = 0;
                }
            }
        }
    }
    
    int sum = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            sum += F[i][j];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 384
n = int(input())
cs = input()

cand1 = cs[:cs.count('R')].count('W')
cand2 = cs[cs.count('W'):].count('R')
if cand1 < cand2:
  print(min(cand1, cand2))
else:
  print(max(cand1, cand2))

Measured memory_bytes: 9468
#include<iostream>
using namespace std;
int main() {
	int n,ba=100001,fr=99999;

	int a[200001];
	int b[200001];

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

	b[100000] = a[0];
	for (int i = 1; i < n; i++) {
		if (i % 2 == n % 2) {

			b[ba] = a[i];
			ba++;
		}
		else {
			b[fr] = a[i];
			fr--;
			}
		

		}
	







	for (int i = fr + 1; i < ba - 1; i++) {

		cout << b[i] << " ";

	}

	cout << b[ba - 1] << endl;

}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int N,A,B,C;
vector<int> l(8);
int dfs(int cur,int a,int b,int c);
int main(){
    cin>>N>>A>>B>>C;
    for(int i=0;i<N;i++)cin>>l[i];
    cout<<dfs(0,0,0,0)<<endl;
    return 0;
}
int dfs(int cur,int a,int b,int c){
    if(cur==N){
        if(min(a,min(b,c))>0){
            return abs(a-A)+abs(b-B)+abs(c-C)-30;
        }
        else{
            return 1e9;
        }
    }
    int ret0,ret1,ret2,ret3;
    ret0=dfs(cur+1,a,b,c);
    ret1=dfs(cur+1,a+l[cur],b,c)+10;
    ret2=dfs(cur+1,a,b+l[cur],c)+10;
    ret3=dfs(cur+1,a,b,c+l[cur])+10;
    return min(min(ret0,ret1),min(ret2,ret3));
}


Measured memory_bytes: 256
"""
~~ author : dokueki
~~ created : 10~05~2020
"""

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    s1 = input()
    s2 = input()
    print("Yes" if s1 == s2[:len(s2)-1] else "No")


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


Measured memory_bytes: 61716
#include <iostream>
    #include <fstream>
    #include <bits/stdc++.h>
    #include <map>
    #define pb push_back
    #define ll long long
    using namespace std;
    const int siz = 510;
    int n;
    const ll inf=LLONG_MAX-1;
    ll d[siz],m[siz][siz];
    ll sume[siz];
    void initializareSuma()
    {
        int i;
        ll s=0;
        for(i=1;i<=n;i++)
        {
            s+=d[i];
            sume[i]=s;
        }
    }
    int main()
    {
        ifstream fin("podm.in");
        ofstream fout("podm.out");
        cin>>n;
        for(int i = 1 ; i <= n ;i++){
            cin>>d[i];
        }
        initializareSuma();
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++){
            m[i][j]=inf;
        }
        for(int i=1;i<=n;i++){
            m[i][i]=0;
        }
        int p;
        for(int i=1;i<=n-1;i++)
            for(int j=1;j<=n-i;j++){
            p=i+j;
            for(int k=j;k<=p-1;k++){
                m[j][p]=min(m[j][p],m[j][k]+m[k+1][p]+sume[p]-sume[j-1]);
            }
        }
        cout<<m[1][n];
        fin.close();
        fout.close();
        return 0;
    }

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int n, r;
    scanf("%d %d", &n, &r);
    if (n >= 10 )
    {
        printf("%d", r);
    }
    else
    {
        printf("%d", r + 100 * (10 - n));
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@mt
def slv(M, A):
    from fractions import Fraction
    d = Fraction(0)
    for a in A:
        d += Fraction(1, a)

    return float(1 / d)





def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


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

struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<int> size;
	
	UnionFind(int N) : par(N), rank(N), size(N){
		rep(i,N){
			par[i] = i;
			rank[i] = 0;
			size[i] = 1;
		}
	}
	
	int root(int x) {
		if (par[x] == x) return x;
		par[x] = root(par[x]);
		return par[x];
	}
	
	void unite(int x, int y){
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		if(rank[rx] < rank[ry]){
			par[rx] = ry;
			size[ry] += size[rx];
		}else{
			par[ry] = rx;
			size[rx] += size[ry];
			if(rank[rx] == rank[ry]) rank[rx]++;
		}
	}
	
	bool same(int x, int y){
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main(){
	ll N,M;
	cin >> N >> M;
	vector<pair<ll,ll>> p(M);
	UnionFind tree(N);
	rep(i,M){
		ll a,b;
		cin >> a >> b;
		a--;b--;
		p[i] = make_pair(a,b);
	}
	
	vector<ll> ans(M);
	ans[0] = N*(N-1)/2;
	
	REP(i,M-1){
		auto pair = p[M-i];
		if(tree.same(pair.first, pair.second)){
			ans[i] = ans[i-1];
		}else{
			ans[i] = ans[i-1] - tree.size[tree.root(pair.first)]*tree.size[tree.root(pair.second)];
		}
		tree.unite(pair.first,pair.second);
	}
	
	reverse(ans.begin(),ans.end());
	rep(i,M){
		cout << ans[i] << endl;
	}
    return 0;
}



Measured memory_bytes: 4864