akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

// セグメント木
class SegmentTree
{
public:
    typedef long long T1;
    typedef long long T2;

    // データの初期値、以下の条件を満たすこと
    //   uniteData(v, INIT_DATA) == v
    static const T1 INIT_DATA;

    // 2つの区間の計算結果v1,v2に対して、
    // その2つの区間を統合した区間における計算結果を返す
    static T1 uniteData(T1 v1, T1 v2){
        return max(v1, v2);
    }

private:
    // 前回の値がprevである要素に対して、
    // パラメータxを用いた更新処理を適用した後の計算結果を返す
    T1 updateData(T1 prev, T2 x){
        return x;
    }

    int n;
    vector<T1> data;
    void updateTree(int a, int k, int l, int r, T2 x){
        if(r - l == 1 && a == l){
            data[k] = updateData(data[k], x);
        }
        else if(l <= a && a < r){
            updateTree(a, k*2+1, l, (l+r+1)/2, x);
            updateTree(a, k*2+2, (l+r+1)/2, r, x);
            data[k] = uniteData(data[k*2+1], data[k*2+2]);
        }
    }
    T1 getValue(int a, int b, int k, int l, int r){
        if(a <= l && r <= b){
            return data[k];
        }
        else if(a < r && l < b){
            T1 v1 = getValue(a, b, k*2+1, l, (l+r+1)/2);
            T1 v2 = getValue(a, b, k*2+2, (l+r+1)/2, r);
            return uniteData(v1, v2);
        }
        else{
            return INIT_DATA;
        }
    }

public:
    SegmentTree(int n0){
        n = 1;
        while(n < n0)
            n *= 2;
        data.assign(2*n-1, INIT_DATA);
    }
    SegmentTree(const vector<T1>& v) : SegmentTree((int)v.size()){
        for(unsigned i=0; i<v.size(); ++i)
            data[n-1+i] = v[i];
        for(int k=n-2; k>=0; --k)
            data[k] = uniteData(data[k*2+1], data[k*2+2]);
    }
    // a番目の要素にパラメータxによる更新処理を適用
    void update(int a, T2 x){
        updateTree(a, 0, 0, n, x);
    }
    // 区間[a,b)の計算結果を返す
    T1 get(int a, int b){
        return getValue(a, b, 0, 0, n);
    }
};
const SegmentTree::T1 SegmentTree::INIT_DATA = 0;

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

    SegmentTree st(n);
    for(int i : index){
        long long x = st.get(0, i) + a[i];
        st.update(i, x);
    }
    cout << st.get(0, n) << endl;

    return 0;
}


Measured memory_bytes: 6656
#include <stdio.h>

int main(void)
{
	int n;
	int a[10000];

	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}

		for (int i = 0; i < n; i++){
			scanf("%d", a + i);
		}

		int ans = -100000;
		for (int i = 0; i < n; i++){
			int sum = 0;
			for (int j = i; j < n; j++){
				sum += a[j];
				if (ans < sum){
					ans = sum;
				}
			}
		}

		printf("%d\n", ans);
	}
	return (0);
}

Measured memory_bytes: 1048
#include <bits/stdc++.h>
using namespace std;
#define ll long double
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s, t;
    cin >> s >> t;
    s = t + s;
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100001];
int dp[100001];
int graph_1dp(int si,int v,int *dp){
    if(dp[si]>-1) return dp[si];
    bool leaf=false;
    int best=0;
    for(int i=0;i<graph[si].size();i++){
        leaf=true;
        best=max(best,graph_1dp(graph[si][i],v,dp));
    }
    return leaf? dp[si]=1+best:dp[si]=0;
}
int main() {
    int v,e;
    cin>>v>>e;
    for(int i=0;i<e;i++){
        int a,b;
        cin>>a>>b;
        graph[a-1].push_back(b-1);
    }
    memset(dp,-1,sizeof(dp));
    int ans=0;
    for(int i=0;i<v;i++){
        ans=max(ans,graph_1dp(i,v,dp));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9472
#include <stdio.h>

int main(){
   int a, b;
   scanf("%d %d",&a,&b);
   if(a<b){
      printf("a < b\n"); 
   } else if(a>b){
      printf("a > b\n"); 
   } else if(a==b){
      printf("a == b\n"); 
   } 
   return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
using namespace std;
int main()
{
    int n;
    cin >> n;
    set<int> st;
    int flag = 1;
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        if (st.count(t) > 0) flag = 0;
        else st.insert(t);
    }
    cout << (flag ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<vector<ll>> g(n+1);
    for(ll i = 0; i < m; i++){
        ll a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<p> vp;
    for(ll i = 0; i < k; i++){
        ll a, b;
        cin >> a >> b;
        vp.push_back(p(a, b));
    }
    map<ll, ll> I{};
    vector<ll> ans(n+1, 0);
    vector<bool> ok(n+1, false);
    vector<ll> s(n+1);
    ll count = 0;
    vector<ll> use(n+1, -1);
    for(ll i = 1; i <= n; i++){
        if(ok[i]==true) continue;
        ll sum = 1;
        queue<ll> que;
        que.push(i);
        use[i] = 1;
        s[i] = count;
        while(!que.empty()){
            ll v = que.front();
            que.pop();
            for(ll nv : g[v]){
                if(use[nv]!=-1) continue;
                que.push(nv);
                ok[nv] = true;
                use[nv] = 1;
                s[nv] = count;
                sum++;
            }
        }
        I[count] = sum;
        count++;
    }
    for(ll i = 1; i <= n; i++){
        ll a = s[i];
        ans[i] = I[a]-1-g[i].size();
    }
    for(ll i = 0; i < k; i++){
        ll a = vp[i].first, b = vp[i].second;
        if(s[a]==s[b]){
            ans[a]--; ans[b]--;
        }
    }
    for(ll i = 1; i <= n; i++)
        cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 15480
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-vo-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class UnionFind {
public:
    vector<int> par, rank;
    int cnt;
    vector<int> forest_size;

    UnionFind(int n) : cnt(n) {
        par = vector<int>(n);
        iota(par.begin(), par.end(), 0);
        rank = vector<int>(n, 0);
        forest_size.resize(n, 1);
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);

        if (x == y) return;

        int sz = forest_size[x] + forest_size[y];

        if (rank[x] < rank[y]) {
            par[x] = y;
            forest_size[y] = sz;
        } else {
            par[y] = x;
            forest_size[x] = sz;
            if (rank[x] == rank[y]) rank[x]++;
        }

        cnt--;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int get_fs(int idx) {
        return forest_size[root(idx)];
    }
};

signed main() {
    int N, M;
    cin >> N >> M;
    int A[M];
    int B[M];
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        A[i] = x;
        B[i] = y;
    }

    UnionFind uf = UnionFind(N);

    int score = N * (N - 1) / 2;
    vector<int> ans;
    ans.push_back(score);

    for (int i = M - 1; i >= 1; i--) {
        int sz = uf.get_fs(A[i]) * uf.get_fs(B[i]);
        if (!uf.same(A[i], B[i])) {
            score -= sz;
        }
        if (score < 0) score = 0;
        ans.push_back(score);
        uf.unite(A[i], B[i]);
    }

    reverse(ans.begin(), ans.end());
    for (int a : ans) {
        cout << a << endl;
    }

    return 0;
}

Measured memory_bytes: 6132
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

char get_max(string t){
	int temp = 0;
	string s = "abcdefghij";
	for (int i = 0; i < t.length(); i++){
		for (int j = 0; j < s.length(); j++){
			if (t[i] == s[j]){
				temp = max(temp, j);
				break;
			}
		}
	}
	return s[temp];
}

int main(){
	int n;
	cin >> n;
	string s = "abcdefghijklmnopqrstuvwxyz";
	vector<string> num[11];
	num[1].push_back("a");
	for (int i = 2; i <= n; i++){
		for (int k = 0; k < num[i-1].size(); k++){
			for (int j = 0; j < i; j++){
				if (get_max(num[i-1][k]) + 2 == s[j]) break;
				num[i].push_back(num[i-1][k]+s[j]);
			}	
		}
	}
	for (int i = 0; i < num[n].size(); i++){
			cout << num[n][i] << endl;
	}
	return 0;
 }



Measured memory_bytes: 9588
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

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

    if (N%2 != 0) {
        cout << 0 << endl;
        return 0;
    }
    LL c = 0;
    for (int i = 1; i <= 26; i++) {
        c += N / (2 * (LL) pow(5, i));
    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int n;cin>>n;
  	vector<int> a(n);
  	for (int i=0;i<n;i++){
    	cin>>a.at(i);
    }
  	sort(a.begin(),a.end());
  	cout<<abs(a.at(0)-a.at(a.size()-1))<<endl;
  	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k=0;
string s, t;

long long kaizyou(int x)
{
	if (x == 1)
		return 1;
	else
		return x * kaizyou(x - 1);
}

int main()
{
	cin >> n >> k;
	cout << n-k+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	char c;
	int num[26] = { 0 };
	while ( (c = getchar()) != EOF) {
		if (c > 64 && c!= 32) {
			if (c >= 97) {
				c -= (97-65);
			}
			num[c - 65]++;
		}
		
	}

	int i = 0;
	char alfabet = 'a';
	for (; i < 26; i++) {
		printf("%c : %d\n", alfabet + i, num[i]);
	}
	

	return 0;
}


Measured memory_bytes: 2068
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int n;
	int [] ondosa = {1,2,3,4,5,6,7};
	
	public void nyuryoku (){
		for(n = 0;n<= 6;n++){
		int saikou = sc.nextInt();
		int saitei = sc.nextInt();
		ondosa[n] = saikou - saitei;
	}
	}		
		public void syuturyoku(){
			for(n = 0;n <= 6;n++){
				System.out.println(ondosa[n]);
			}
		}
		


	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Main Main = new Main();
		Main.nyuryoku();
		Main.syuturyoku();

	}

}

Measured memory_bytes: 17364
from logging import *
basicConfig(level=DEBUG, format='%(levelname)s: %(message)s')
disable(CRITICAL)

def solve():
    can_positive = False
    if len(P) > 0:
        if k < n: can_positive = True
        else: can_positive = len(M)%2 == 0
    else: can_positive = k%2 == 0

    if not can_positive: return sorted(P+M, key=lambda x:abs(x))[:k]

    P.sort()
    M.sort(reverse = True)
    debug('k {} n {}'.format(k,n))
    debug('P {}'.format(P))
    debug('M {}'.format(M))
    p, m = [], []
    while len(p) + len(m) < k:
        if len(P) > 0 and len(M) <= 0: p.append(P.pop())
        elif len(P) <= 0 and len(M) > 0: m.append(M.pop())
        elif P[-1] < -M[-1]: m.append(M.pop())
        else: p.append(P.pop())

    debug('p {}'.format(p))
    debug('m {}'.format(m))
    debug('P {}'.format(P))
    debug('M {}'.format(M))

    if len(m)%2:
        Mi = M.pop() if len(p)*len(M) else 1  #  1 is no data
        Pi = P.pop() if len(m)*len(P) else -1 # -1 is no data
        if Mi < 0 and Pi >= 0:
            if abs(p[-1] * Pi) < abs(m[-1] * Mi):
                p.pop()
                m.append(Mi)
            else:
                m.pop()
                p.append(Pi)
        elif Mi < 0:
            p.pop()
            m.append(Mi)
        elif Pi >= 0:
            m.pop()
            p.append(Pi)
    return p + m

n, k = map(int, input().split())
P, M = [], [] # plus, minus
for a in map(int, input().split()):
    if a < 0: M.append(a)
    else: P.append(a)
ans, MOD = 1, 10**9 + 7
for a in solve(): ans *= a; ans %= MOD
ans += MOD; ans %= MOD
print(ans)


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

int main(){
    string s,t; cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    cerr << s << endl << t << endl;

    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a;
	if(a<1200) cout << "ABC" << endl;
	else if(a>=2800) cout << "AGC" << endl;
	else cout << "ARC" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c[]=new int[b];
		for(int i=0;i<a;i++) {
			int d=sc.nextInt();
			for(int j=0;j<d;j++) {
				int e=sc.nextInt();
				c[e-1]++;
			}
		}
		int ans=0;
		for(int i=0;i<b;i++) {
			if(c[i]==a) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;

ll dp[10007][11];

string solve(int i, int j, int n){
	//cout << i << ' ' << j << ' ' << n << '\n';
	string ans = "";
	ans.PB('0'+j);
	if(i == 0) return ans;
	if(j == 0){
		if(dp[i-1][j] >= n)
			ans += solve(i-1, j, n);
		else
			ans += solve(i-1, j+1, n - dp[i-1][j]);
	}else if(j == 9){
		if(dp[i-1][j-1] >= n)
			ans += solve(i-1, j-1, n);
		else
			ans += solve(i-1, j, n - dp[i-1][j-1]);
	}else{
		//cout << dp[i-1][j-1] << ' ' << dp[i-1][j] << ' ' << dp[i-1][j+1] << '\n';
		//cout << n << '\n';
		if(dp[i-1][j-1] >= n)
			ans += solve(i-1, j-1, n);
		else if(dp[i-1][j-1] + dp[i-1][j] >= n)
			ans += solve(i-1, j, n - dp[i-1][j-1]);
		else
			ans += solve(i-1, j+1, n - (dp[i-1][j-1] + dp[i-1][j]));
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	
	int n; cin >> n;
	for(int i = 0; i < 10; i++){
		dp[0][i] = 1;
	}
	for(int j = 1; j < 10007; j++){
		for(int i = 0; i < 10; i++){
			if(i == 0){
				dp[j][i] = dp[j-1][i] + dp[j-1][i+1];
			}else if(i == 9){
				dp[j][i] = dp[j-1][i] + dp[j-1][i-1];
			}else{
				dp[j][i] = dp[j-1][i-1] + dp[j-1][i] + dp[j-1][i+1];
			}
		}
	}

	int sum = 0;
	string ans = "";
	FOR(i, 10007){
		int j;
		for(j = 1; j < 10; j++){
			if(sum + dp[i][j] >= n){
				break;
			}
			sum+=dp[i][j];
		}
		if(j < 10){
			ans = solve(i, j, n-sum);
			break;
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
ll h,w;
vector<string> s(105);
int dp[105][105];
int cal_path(int r,int c){
    if(r==h-1 && c==w-1){
        return 0;
    }
    if(r==h||c==w) return 1e5;
    if(dp[r][c]!=-1) return dp[r][c];
    int op1 = cal_path(r+1,c);
    if(s[r][c]=='.' && s[r+1][c]=='#') op1++;
    int op2 = cal_path(r,c+1);
    if(s[r][c]=='.' && s[r][c+1]=='#') op2++;
    dp[r][c]=min(op1,op2);
    return dp[r][c];
}
 int main(){
  cin>>h>>w;
  for(int i=0;i<h; i++){
    cin>>s[i];  	
  }
  for(int i=0; i<105; i++) for(int j=0; j<105; j++) dp[i][j]=-1;
  if(s[0][0]=='#'){
      cout<<1+cal_path(0,0);
  }
  else {
      cout<<cal_path(0,0);
  }
 }

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

typedef long long ll;

void solve(long long N, long long x, std::vector<long long> a){
    ll cnt = x;
    sort(a.begin(), a.end());
    for(ll i = 0; i < N; ++i){
        if(i == 0){
            if(a[i] > x){
                cout << 0 << endl;
                return;
            }
        }
        cnt -= a[i];
        if(cnt < 0){
            cout << i << endl;
            return;
        }else if(cnt == 0){
            cout << i+1 << endl;
            return;
        }
    }
    cout << N-1 << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long x;
    scanf("%lld",&x);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, x, std::move(a));
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}


int frozenC[200010];
int frozenR[200010];

int main() {
    // Failed to predict input format
    int N, Q;
    cin >> N >> Q;

    int r = N - 1;
    int c = N - 1;

    long long blk = 1ll * (N - 2) * (N - 2);

    memset(frozenC, -1, sizeof(frozenC));
    memset(frozenR, -1, sizeof(frozenR));


    for (int i = 0; i < Q; i++) {
//        cout << blk << endl;
//        cout << "C ";
//        for(int i = 0 ; i <= N ; i++){
//            cout << frozenC[i] << " ";
//        }
//        cout << endl;
//        cout << "R ";
//        for(int i = 0 ; i <= N ; i++){
//            cout << frozenR[i] << " ";
//        }
//        cout << endl;

        int t, x;
        cin >> t >> x;
        --x;
        if (x == 0) {
            // 何もない
            continue;
        }

        if (t == 1) {
            int consume;
            if (c < x) {
                consume = frozenR[x] - 1;
            } else {
                for (int i = x; i < c; i++) {
                    frozenR[i] = r;
                }
                consume = r - 1;
                c = x;
            }
            blk -= consume;
        } else if (t == 2) {
            int consume;
            if (r < x) {
                consume = frozenC[x] - 1;
            } else {
                for (int i = x; i < r; i++) {
                    frozenC[i] = c;
                }
                consume = c - 1;
                r = x;
            }
            blk -= consume;
        }


    }
    cout << blk << endl;
    return 0;
}


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

int main(){
	int md[11] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
	int m, d;
	string str[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
	
	while(true){
		cin >> m >> d;
		
		if(m == 0 && d == 0) return 0;
		
		for(int i = 1; i < m; i++){
			d += md[i - 1];
		}
		
		cout << str[d % 7] << endl;
	}
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int H, W; cin >> H >> W;
	vector<vector<int>> c(H, vector<int>(W)),dp(H,vector<int>(W));

	int square_side = 0;
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			cin >> c[h][w];
			if (c[h][w] == 0) { dp[h][w] = 1; square_side = 1; }
			else { dp[h][w] = 0; }
		}
	}

	for (int h = 1; h < H; h++) {
		for (int w = 1; w < W; w++) {
			if (dp[h][w] == 0) continue;
			if(h == 0){	dp[h][w] = min(dp[h - 1][w - 1], min(dp[h - 1][w], dp[h][w - 1])) + 1; }
			dp[h][w] = min(dp[h - 1][w - 1], min(dp[h - 1][w], dp[h][w - 1])) + 1;
			square_side = max(square_side, dp[h][w]);
		}
	}

	cout << square_side * square_side << endl;
}

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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanVecInt(H, N);
    int leftmax = 0;
    int count = 0;
    for (auto&& h : H){
        if (leftmax <= h) count++;
        leftmax = max(leftmax, h);
    }
    cout << count << endl;
}


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;
using P = pair<int,int>;

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

class mint {
public:
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    ll get() const { return 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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); return (t & 1) ? a*a*(*this) : a*a; }
    operator ll () const { return x; }
    operator string () const { return to_string(x); }
    friend istream& operator>>(istream& is, mint& a) { is>>a.x; return is; }

    // 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 { return mint(*this) /= a; }
};

mint dp[100010]; // GCD が i になる個数

int main() {
    ll N, K;
    cin >> N >> K;

    for (ll i=K; i>=1; --i) {
        dp[i] += mint(K / i).pow(N);
        for (ll j=i*2; j<=K; j+=i) {
            dp[i] -= dp[j];
        }
    }

    mint sum(0);
    for (int i=1; i<=K; ++i) {
        sum += dp[i] * mint(i);
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x,y,a,b,c,ans=0;
    cin>>x>>y>>a>>b>>c;
    vector<int>p(a),q(b),r(c),xy={};
    rep(i,0,a){
        cin>>p[i];
    }
    rep(i,0,b){
        cin>>q[i];
    }
    rep(i,0,c){
        cin>>r[i];
    }
    sort(lla(p));
    sort(lla(q));
    sort(lla(r));
    rep(i,0,x){
        xy.push_back(p[i]);
        ans+=p[i];
    }
    rep(i,0,y){
        xy.push_back(q[i]);
        ans+=q[i];
    }
    sort(all(xy));
    int ind=0,ic=0;
    while(ind<x+y){
        if(r[ic]>xy[ind]){ans=ans-xy[ind]+r[ic];ind++;ic++;}
        else{break;}
    }
    cout<<ans<<endl;
}


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

int main() {

  int A, B, C;
  cin >> A >> B >> C;

  string answer = "No";

  if (A == B && B != C) {
    answer = "Yes";
  } else if (B == C && A != C) {
    answer = "Yes";
  } else if (A == C && B != C) {
    answer = "Yes";
  }

  cout << answer << endl;

  return 0;

}

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

int main(){
  int n, x, y;
  cin >> n >> x >> y;
  --x; --y;

  vector<int> ans(n);
  rep(nv,n){
  	vector<int> dist(n,-1);
  	queue<int> que;

  	auto push = [&](int v, int d){
  		if(dist[v] != -1) return;
  		dist[v] = d;
  		que.push(v);
  	};

  	push(nv,0);
  	while(!que.empty()){
  		int v = que.front(); que.pop();
  		int d = dist[v];
  		if(v >= 1) push(v-1, d+1);
  		if(v < n - 1) push(v+1, d+1);
  		if(v == x) push(y, d+1);
  		if(v == y) push(x, d+1);
  	}
  	rep(i,n) ++ans[dist[i]];
  }
  for(int k = 1; k < n; ++k){
  	cout << ans[k]/2 << endl;
  }
  return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin >> n;
	long long a[n];
	for(auto &x:a) cin >> x;
	long long sum = accumulate(a, a+n, 0ll);
	sum %= (long long)(1e9+7);
	long long mod = 1e9+7;
	long long ans=0ll;
	for(int i=0; i<n; ++i){
		sum = (sum+mod)%mod;
		sum -= a[i];
		ans += a[i]*sum;
		ans %= (long long)(1e9+7);
		//cout << ans << endl;
	}
	ans = (ans+mod)%mod;
	cout << ans << endl;
}


Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
#define lor(a,b,c) for(register int a=b;a<=c;++a)
#define ror(a,b,c) for(register int a=c;a>=b;--a)
typedef long long ll;

const int N=1e5+5;
int n,nxt[N]; ll a[N],sum[N],abssum[N],ans;

template <typename T> inline T read(){
	char tmp=getchar(); T sum=0; bool flag=false;
	while(tmp<'0'||tmp>'9'){
		if(tmp=='-') flag=true; tmp=getchar();
	}
	while(tmp>='0'&&tmp<='9'){
		sum=(sum<<1)+(sum<<3)+tmp-'0'; tmp=getchar();
	}
	return flag?-sum:sum;
}

int main(){
	n=read<int>(); lor(i,1,n) a[i]=read<ll>(),sum[i]=sum[i-1]+a[i],abssum[i]=abssum[i-1]+abs(a[i]); ans=sum[n];
	nxt[n+1]=n+1; sum[n+1]=sum[n]; abssum[n+1]=abssum[n]; ror(i,1,n) {if(a[i+1]<0) nxt[i]=i+1; else nxt[i]=nxt[i+1];}
	lor(i,1,n) if(a[i]<0){
		ans=max(ans,sum[i-1]+(abssum[n]-abssum[nxt[i]-1])-(abssum[nxt[i]-1]-abssum[i-1]));
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 2944
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N = In.int()
A = In.ints()

maxYet = 0

ans = 0

for h in A:
    if maxYet>h:
        ans+=maxYet-h
    maxYet = max(h, maxYet)

Out.int(ans)

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 103756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  set<ll> a;
  rep(i,0,n){
    ll x;
    cin>>x;
    a.insert(x);
  }
  if(n==a.size()) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 9600
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    ll n,m;
    std::cin >> n>>m;
    ll result = 0;
    result += min(n,m/2);
    n -= result;
    m -= 2*result;
    result += m/4;
    std::cout << result << std::endl;
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

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

ll inverse(ll x, ll p){
  ll ans = 1;
  while(p){
    if(p&1){
      ans *= x;
      ans %= MOD;
    }
    x *= x;
    x %= MOD;
    p >>= 1;
  }
  return ans;
}

ll xPy(ll x,ll y){
  if(x == 0)return 1;
  ll res = 1;
  rep(i,y){
    res *= x;
    x--;
  }
  return res;
}




int main(){

  ll N,M;
  cin >> N >> M;

  vector<ll> comb(N+1,1);
  for(int i = 1;i <= N;i++){
    comb[i] = (comb[i-1]%MOD*((N-i+1)%MOD*gen(i,MOD-2)%MOD)%MOD)%MOD;
  }

  vector<ll> permutation_m(N+1,1);
  for(int i = 1;i <= N;i++){
    permutation_m[i] = (permutation_m[i-1]%MOD*(M-i+1)%MOD)%MOD;
  }

  vector<ll> permutation_n(N+1,1);
  permutation_n[N] = 1;
  for(int i = N-1;i >= 1;i--){
    permutation_n[i] = (permutation_n[i+1]%MOD*(M-i)%MOD)%MOD;
  }

  ll all = (permutation_m[N]%MOD*permutation_m[N]%MOD)%MOD;
  ll minus = 0;

  for(int i = 1;i <= N;i++){
    ll add = 1;
    if(i%2==0)add *= -1;
    add = (add%MOD*comb[i]%MOD)%MOD;
    add = (add%MOD*permutation_m[i]%MOD)%MOD;
    add = (add%MOD*(permutation_n[i]%MOD*permutation_n[i]%MOD)%MOD)%MOD;
    minus = (minus%MOD+add%MOD)%MOD;
  }

  ll ans = (all%MOD - minus%MOD)%MOD;
  if(ans < 0)ans += MOD;

  cout << ans << endl;
  return 0;



/*

  ll an = 0;
  for(ll i = 1;i <= N;i++){
    ll add = per(M,i)*per(M-i,N-i)*per(M-i,N-i);
    if(i%2==0)add *= -1;
    {

    }
  }





  ll ans = 1;
  for(int i = 0;i < N;i++){
    ans = (ans*(M-i))%MOD;
  }

  for(int i = 1;i <= N;i++){
    ans = (ans*(gen(i,MOD-2))%MOD)%MOD;
  }

  cout << ans << endl;

  ll minus = 1;

  rep(i,N){
    minus = (minus*(M-1))%MOD;
  }

  ll ans2 = (minus-(M-N))%MOD;

  ans = (ans*ans2)%MOD;

  cout << ans << endl;
*/
}


Measured memory_bytes: 14880
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

// 5min
int main(void){

  int x;

  scanf("%d", &x);

  if(x == 3 || x == 5 || x == 7){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


double ans;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		double a;
		string h;
		cin >> a >> h;
		if (h == "BTC") { a *= 380000; }
		ans += a;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
left = 0
right = 0
left_t = 0
right_t = 0
t = "".join(list(reversed(s)))
for i in range(n):
    if s[i] == ")":
        if left == 0:
            right += 1
        else:
            left -= 1
    if s[i] == "(":
        left += 1
    if t[i] == "(":
        if right_t == 0:
            left_t += 1
        else:
            right_t -= 1
    if t[i] == ")":
        right_t += 1
ans = ("(" * right) + s + ")" * left_t
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
unsigned long long a[30]={},ans=0,l=0;
char c[200010]={};
int main(){
	scanf("%s",c+1),l=strlen(c+1);
	for(int i=1;i<=l;i++) a[c[i]-'a'+1]++;
	for(int i=1;i<26;i++) for(int j=i+1;j<=26;j++) ans+=a[i]*a[j];
	printf("%lld\n",ans+1);
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll n; cin>>n;
	vector<int> v;
	for(ll i=2; i*i<=n; i++){
		if(n%i==0){
			int e=0;
			while(n%i==0){
				n/=i; e++;
			}
			v.push_back(e);
		}
	}
	if(n>1) v.push_back(1);
	int ans=0;
	for(auto x:v){
		int i=0, s=0;
		while(1){
			if(s+i+1>x) break;
			i++;
			s+=i;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
    int W,H,i,j;
    while(1)
    {
        scanf("%d %d",&W,&H);
        if(W==0 && H==0)
        {
            return 0;
        }
        else
        {
            for(i=1;i<=W;i++)
            {
                if(i==1||i==W){
                for(j=1;j<=H;j++)
                {
                    printf("#");
                }
                printf("\n");
                }
                else{
                        for(j=1;j<=H;j++){
                    if(j==1||j==H){
                    printf("#");
                    }
                    else{
                        printf(".");
                    }
                        }
                        printf("\n");
                }
                }
            }
            printf("\n");
        }
    return 0;
}



Measured memory_bytes: 2096
#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;

const int shokin[3] = {300000,200000,100000};

int main(){
	int X,Y;
	cin >> X >> Y;
	if(1<=X && X<=3 && 1<=Y && Y<=3){
		if(X==1 && Y==1){
			cout << 300000*2 + 400000 << endl;
		}else{
			cout << shokin[X-1] + shokin[Y-1] << endl;
		}
	} else if (X>3 && 1<= Y && Y<=3){
		cout << shokin[Y-1] << endl;
	} else if (Y>3 && 1<=X && X<=3){
		cout << shokin[X-1] << endl;
	}else{
		cout << 0 << endl;
	}
    return 0;
}



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

int main(){
	int K, N, i;
	scanf("%d%d", &K, &N);
	vector<int> A(N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	int ans = A[N - 1] - A[0];
	for(i = 1; i < N; i++){
		ans = min(ans, K - (A[i] - A[i - 1]));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        int a = int.Parse(ReadLine());
        int b = a*100/108;
        if(b*108/100 == a){
            WriteLine(b);
        }else if((b+1)*108/100 == a){
            WriteLine(b+1);
        }else{
            WriteLine(":(");
        }
    }
}


Measured memory_bytes: 13140
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int main(void){

  int N;
  int sum = 0,ave,ans=0;

  vector<int>a;
  cin >> N;

  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
    sum += tmp;
  }

  ave = round((double)sum/N);
  
  for(int i = 0; i < N; i++){
    ans += pow(a.at(i) - ave, 2);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(),x.end(),x.begin() ,::toupper);
#define down(x) transform(x.begin(),x.end(),x.begin() ,::tolower);
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
    int n,l,a,b;
    cin >> n >> l;
    vector<string> c(n);
    rep(i,n)cin>>c[i];
    SORT(c);
    rep(i,n)cout<<c[i];
}

Measured memory_bytes: 256
x,y = map(int,input().split())

a = []

for i in range(x+1):
    s = i*2 + (x-i)*4
    t = i*4 + (x-i)*2
    a.append(s)
    a.append(t)
    
if y in a:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9172
s=int(input())
k=0
co=False
for i in range(s):
  a,b=map(int,input().split())
  if(a==b):
    k+=1
  else:
    k=0
  if(k>=3):
  	co=True
if(co):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9176
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ
 
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
 
int main(void){
    int N,A;
    scanf("%d%d",&N,&A);
 
    int* x;
    NEW(x,N);
    for(int i=0;i<N;i++){
        scanf("%d",&x[i]);
    }
 
    //DP[i][j][k]...x[0]~x[i]までで、j枚使って計kになる場合の数
    long DP[N][N+1][2501];
    for(int i=0;i<N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=2500;k++) DP[i][j][k]=0;
        }
    }
    //初期値
    DP[0][0][0]=1;
    DP[0][1][x[0]]=1;
 
    //DPを埋める
    for(int i=1;i<N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=50*i;k++){
                DP[i][j][k]+=DP[i-1][j][k];
                if(j+1<=N && k+x[i]<=2500)DP[i][j+1][k+x[i]]+=DP[i-1][j][k];
            }
        }
    }
 
    long ans=0;
    for(int i=1;i<=N;i++){
        ans+=DP[N-1][i][A*i];
    }
    printf("%ld\n",ans);
 
    return 0;
}

Measured memory_bytes: 50048
from collections import Counter
mod=998244353
n=int(input())
D=list(map(int,input().split()))
Count=Counter(D)
if Count[0]!=1 or D[0]!=0:print(0);exit()
ans=1
for i in range(1,max(Count)+1):
    ans *=Count[i-1]**Count[i]
    ans %=mod
print(ans)

Measured memory_bytes: 19936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int sx,sy,tx,ty,x,y;
    cin >> sx >> sy >> tx >> ty;
    x=sx;y=sy;

    while(y < ty){
        cout << 'U';
        y++;
    }
    while(x<tx){
        cout << 'R';
        x++;
    }
    while(sy<y){
        cout << 'D';
        y--;
    }
    while(sx-1<x){
        cout << 'L';
        x--;
    }
    
    while(y<ty+1){
        cout << 'U';
        y++;
    }
    while(x<tx){
        cout << 'R';
        x++;
    }
    y--;cout<<'D';
    x++;cout<<'R';

    while(sy-1<y){
        cout << 'D';
        y--;
    }
    cout << string(x-sx,'L');
    
    y++;cout << 'U'<<endl;
}
//string(文字数、中身)でstringを宣言できることを利用すると簡潔に書ける

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void){
    long X, A, B;
    scanf("%ld%ld%ld", &X, &A, &B);
    if(A >= B){
        printf("delicious\n");
        return 0;
    }
    if(X >= B - A) {
        printf("safe\n");
        return 0;
    }
    else{
        printf("dangerous\n");
        return 0;
    }

    return 0;
}


Measured memory_bytes: 128
from sys import stdin, setrecursionlimit
from collections import deque


def main():

    setrecursionlimit(2000001)

    n, q = [int(x) for x in stdin.readline().split()]

    tree = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        a, b = [int(x) for x in stdin.readline().split()]
        tree[a].append(b)
        tree[b].append(a)

    count = [0] * (n + 1)
    for _ in range(q):
        parent, x = [int(x) for x in stdin.readline().split()]
        count[parent] += x

    queue = deque([])
    visited = [False] * (n + 1)

    queue.append((0, 1))

    while len(queue) > 0:
        parent, current = queue.pop()
        visited[current] = True
        count[current] += count[parent]
        for child in tree[current]:
            if not visited[child]:
                queue.append((current, child))

    print(*count[1:])


main()

Measured memory_bytes: 58512
#include <cstdio>
#include <vector>
#include <queue>

const int MAXN = (int)1e5;

std::vector<int> a[MAXN];

int solve(int n, int m) {
  int res = 0;
  std::priority_queue<int> pq;
  for (int i = m - 1; i >= 0; --i) {
    for (const auto &cur : a[i]) {
      pq.push(cur);
    }
    if (!pq.empty()) {
      res += pq.top();
      pq.pop();
    }
  }
  return res;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0, u, v; i < n; ++i) {
    scanf("%d %d", &u, &v);
    if (m - u < 0) continue;
    a[m - u].emplace_back(v);
  }
  printf("%d\n", solve(n, m));
  return 0;
}


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

using namespace std;

int main()
{
    unsigned long long h, w;
    cin >> h >> w;
    if(h == 1 || w == 1)
    {
        cout << 1;
        return 0;
    }
    cout << h * w / 2 + (h * w) % 2;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    int n, m;
    cin >> n >> m;
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > q;
    
    rep(i, n){
        int a, b;
        cin >> a >> b;
        q.push(make_pair(a, b));
    }
    
    ll res = 0;
    while(m>0){
        pair<int, int> f = q.top(); q.pop();
        ll num = min(m, f.second);
        res += f.first * num;
        m-=num;
    }
    
    cout << res << endl;
    
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int n=N;
  int f=0;
  while(1){
    f+=N%10;
    N/=10;
    if(N==0) break;
  }
  //  cout << f << endl;
  if(n/f * f==n){
    cout << "Yes" << endl;
  }else cout << "No" << endl;
   
  return 0;

}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    int N, M; cin >> N >> M;
    vector<int> a(M);
    vector<bool> issafe;
    issafe.assign(N + 1, true);
    REP(i, M) {
        cin >> a[i];
        issafe[a[i]] = false;
    }

    vector<int> dp(N + 1, 0);

    dp[0] = 1;
    if(issafe[1]) dp[1] = 1;
    for(int i = 2; i <= N; ++i) {
        if(issafe[i - 1]) dp[i] += dp[i - 1];
        if(issafe[i - 2]) dp[i] += dp[i - 2];
        dp[i] = dp[i] % 1000000007;
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
  
using namespace std; 
int main() 
{ 
    string s;
    cin>>s;
  
    int n = s.length(); 
   
    char arr[n + 1]; 
  
    strcpy(arr, s.c_str()); 
  
    for (int i = 0; i < n; i++) {
    	if(arr[i]=='7'){
    		cout<<"Yes"<<endl;
    		
return 0;
    	}
    }
  cout<<"No"<<endl;
    return 0; 
} 


Measured memory_bytes: 3624