akhauriyash/Code-Regression huggingface dataset:
// Problem : C - Connect Cities
// Contest : AtCoder - ACL Beginner Contest
// URL : https://atcoder.jp/contests/abl/tasks/abl_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define F first 
#define S second
#define IS insert
#define PI acos(-1)
#define PB pop_back
#define EB emplace_back
#define SZ(x) (int)x.size()
#define MP(x, y) make_pair(x, y)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 2 * N;

int n, m;
int h[N], e[M], ne[M], idx;
bool st[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void dfs(int u)
{
	st[u] = true;
	for (int i = h[u]; ~i; i = ne[i])
	{
		int j = e[i];
		if (!st[j]) dfs(j);
	}
}

int main()
{
	IOS
	
	memset(h, -1, sizeof h);
	cin >> n >> m;
	
	for (int i = 0; i < m; i ++ )
	{
		int a, b;
		cin >> a >> b;
		add(a, b), add(b, a);
	}
	
	int res = 0;
	for (int i = 1; i <= n; i ++ )
		if (!st[i])
		{
			dfs(i);
			res ++ ;
		}
	cout << res - 1 << '\n';
    return 0;
}


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

#define int long long

int N, A, B;
int X[101010];

signed main() {
  cin >> N >> A >> B;
  for (int i=1; i<=N; i++) {
    cin >> X[i]; 
  }
  
  int kouho1 = 0;
  for (int i=2; i<=N; i++) {
   	if ((X[i] - X[i-1]) * A < B) {
      kouho1 += (X[i] - X[i-1]) * A; 
    } else {
      kouho1 += B; 
    }
  }
  
  int kouho2 = B;
  for (int i=N-1; i>=2; i--) {
    if ((X[i+1] - X[i]) * A < B) {
      kouho2 += (X[i+1] - X[i]) * A; 
    } else {
      kouho2 += B; 
    }
  }
  
  cout << (kouho1 < kouho2 ? kouho1 : kouho2) << endl;
}

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

const int maxN = 100000;

int abc[maxN][3];
int64_t dp[maxN][3];

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

  memset(dp, 0, sizeof(dp));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> abc[i][j];

      if (i == 0) dp[0][j] = abc[0][j];
    }
  }

  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) continue;
        dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[i][j]);
      }
    }
  }

  int64_t ans = max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>

int main(void)
{
    char S[3];
    
    scanf("%s", S);
    
    if (S[0] == S[1] && S[1] == S[2]) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 03/May/20 06:07:48 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int n;
	cin >> n;
	int arr[n];
	fr (i, 0, n) cin >> arr[i];
	map< int, int > mp;
	int ans = 0;
	fr (i, 0, n) {
		int x = mp[i - arr[i]];
		ans += x;
		mp[i + arr[i]]++;
	}
	pr (ans);
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  map<int, long long> cnt;
  for (int p : a)
    ++cnt[p];
  int q;
  cin >> q;
  while (q--) {
    int b, c;
    cin >> b >> c;
    if (cnt.count(b)) {
      sum -= 1ll * b * cnt[b];
      sum -= 1ll * c * cnt[c];
      cnt[c] += cnt[b];
      cnt[b] = 0;
      sum += 1ll * c * cnt[c];
    }
    cout << sum << '\n';
  }   
  return 0;
}

Measured memory_bytes: 8640
cards = {
'S':[0 for i in range(13)],
'H':[0 for i in range(13)],
'C':[0 for i in range(13)],
'D':[0 for i in range(13)]
}
n = int(input())
for i in range(n):
    c, s = input().split()
    cards[c][int(s)-1] = int(s)
for i in ('S','H','C','D'):
    for j in range(13):
        if cards[i][j] == 0:
            print('{} {}'.format(i,j+1))

Measured memory_bytes: 7740
def cc043
    n = gets.chomp.to_i
    s = 0
    an = gets.chomp.split(/\s/).map{|x| s += x.to_i; x.to_i}
    av = s/n

    r1 = 0
    r2 = 0
    r3 = 0
    an.each do |a|
        r1 += (a-av)*(a-av)
        r2 += (a-av-1)*(a-av-1)
        r3 += (a-av+1)*(a-av+1)
    end

    puts [r1, r2, r3].min
end

cc043

Measured memory_bytes: 1788
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	s = 0
	for i in 1:n
		for j in 1:n
			for k in 1:n
				s += gcd(i,j,k)
			end
		end
	end
	println(s)
end

main()

Measured memory_bytes: 158716
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

const int N=2005;

int w[N][N],u[N][N],l[N][N];

char str[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):(v),ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

int getu(int a,int b,int c,int d) {
	return u[c][d]-u[a-1][d]-u[c][b-1]+u[a-1][b-1];
}

int getl(int a,int b,int c,int d) {
	return l[c][d]-l[a-1][d]-l[c][b-1]+l[a-1][b-1];
}

int sum(int a,int b,int c,int d) {
	return w[c][d]-w[a-1][d]-w[c][b-1]+w[a-1][b-1];
}

int main(void) {
	int n=read(),m=read(),T=read();
	rep(i,1,n) {
		scanf("%s",str+1);
		rep(j,1,m) {
			w[i][j]=str[j]-'0';
			if (w[i][j]==1&&w[i-1][j]==1) ++u[i][j];
			if (w[i][j]==1&&w[i][j-1]==1) ++l[i][j];
			u[i][j]=u[i-1][j]+u[i][j-1]-u[i-1][j-1]+u[i][j];
			l[i][j]=l[i-1][j]+l[i][j-1]-l[i-1][j-1]+l[i][j];
		}
	}
	rep(i,1,n) rep(j,1,m) w[i][j]+=w[i-1][j]+w[i][j-1]-w[i-1][j-1];
	for (;T--;) {
		int a=read(),b=read(),c=read(),d=read();
		printf("%d\n", sum(a,b,c,d)-getu(a+1,b,c,d)-getl(a,b+1,c,d));
	}
	return 0;
}

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

int main(){
    int k,s; cin >> k >> s;
    int ans = 0;
    rep(x,k+1){
        rep(y,k+1){
            int z = s - (x + y);
            if(0 <= z && z <= k){
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}


int main(){
    ll b,c,x,y,n,m,h,k,max=-10000000,min=1000000000,ans=1,sum=0;
    string s,t;
    VI a(1e5+5);
    bool f=false;
    cin >> n;
    for(int i=0; i<n;i++){
        cin >> x;
        if(i==0 && x!=0) f = true;
        a[x]++;
    }

    if(f || a[0]!=1) {
        cout << 0 << endl;
        return 0;
    }
    
    for(int i=1; i<n;i++){
        for(int j=0; j<a[i]; j++){
            ans *= a[i-1];
            ans %= 998244353; 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

type SortName [][]int

func (x SortName) Len() int           { return len(x) }
func (x SortName) Less(i, j int) bool { return x[i][1] < x[j][1] }
func (x SortName) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	k, _ := strconv.Atoi(stringLineScan())
	ans := 0
	for i := k + 1; i <= n; i++ {
		ans += smaller(n/i*(i-k)+larger(n-n/i*i-k+1, 0), n)
	}
	fmt.Println(ans)
}
func larger(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}


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

int h, w;
char a[51][51], b[1001];

int main()
{
	cin >> h >> w;

	while (h != 0 && w != 0) {
		int t = 0, pi = 0, pj = 0;

		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				cin >> a[i][j];

		cin >> b;

		for (int k = 0; b[k] != '\0'; k++) {
			bool f = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (a[i][j] == b[k]) {
						t += abs(pi - i) + abs(pj - j) + 1;
						pi = i;
						pj = j;
						f = 1;
						break;
					}
				}
				if (f)
					break;
			}
		}

		cout << t << endl;

		cin >> h >> w;
	}

	return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n;cin>>n;
    int t,a;cin>>t>>a;
    int h,ans;
    double sub=10000;
    for(int i=1;i<=n;i++){
        cin>>h;
        if(sub>abs(t-h*0.006-a)){
            sub=abs(t-h*0.006-a);
            ans=i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ar array
#define pb push_back
#define input(arr,n) for(int i = 0; i<n; i++) cin>>arr[i]
const int mod = 1e9+7;
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	if(s.back()!='s') s += "s";
	else s += "es";
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
int main(D){
    int i,DayToChirstmas;
    char s[101] = "Christmas";
    scanf("%d", &D);
    DayToChirstmas = 25-D;
    if (DayToChirstmas <= 3 && DayToChirstmas >= 1){
        for (i=1;i<=DayToChirstmas;i++)
        sprintf(s,"%s%s",s," Eve");
    }
    printf("%s\n",s);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
vector<int> v[200010];
ll res,r;
int par[200010],siz[200010];
int pare(int x)
{
	return (par[x]==x ? x : pare(par[x]));
}
bool join(int x,int y)
{
	x=pare(x),y=pare(y);
	if (x==y) return 0;
	if (siz[x]>siz[y]) swap(x,y);
	par[x]=y,siz[y]+=siz[x];
	return 1;
}
void build()
{
	for (int i=0;i<n;i++) siz[i]=1,par[i]=i;
	int t=0;
	for (int i=0;i<n;i++)
	{
		t++;
		for (int j=0;j<v[i].size();j++)
		{
			int x=v[i][j];
			if (x>=i) continue;
			t-=join(i,x); 
		}
		r+=t;
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		//x=1,y=i+1;
		x--,y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	build();
	res+=r;
	//cout <<r<<" ##\n";
	for (int i=0;i<n;i++)
	{
		sort(v[i].begin(),v[i].end());
		int bg=lower_bound(v[i].begin(),v[i].end(),i)-v[i].begin();
		r-=(bg<v[i].size() ? v[i][bg] : n)-i;
		//cout <<i<<" "<<r<<" ##\n";
		v[i].push_back(n);
		int t=0;
		for (int j=bg;j<v[i].size()-1;j++)
		{
			r+=(v[i][j+1]-v[i][j])*t;
			t++;
		}
		//cout <<i<<" "<<r<<" ##\n";
		res+=r;
	}
	printf("%lld",res);
	return 0;
} 


Measured memory_bytes: 17024
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<vector<pll>> G;
int Q,K;
vector<int> X,Y;

void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    G.resize(N);
    for (int i = 0; i < N-1; i++)
    {
        ll a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    cin >> Q >> K;
    K--;
    for (int i = 0; i < Q; i++)
    {
        int x,y;
        cin >> x >> y;
        x--,y--;
        X.push_back(x);
        Y.push_back(y);
    }
    
}

vector<ll> dp;
void dfs(int s,int p=-1){
    for(auto u:G[s]){
        if(u.first==p) continue;
        dp[u.first] = dp[s]+u.second;
        dfs(u.first,s);
    }
}

int solve(){
    dp.resize(N);
    dfs(K);
    for (int i = 0; i < Q; i++)
    {
        cout << dp[X[i]]+dp[Y[i]] << endl;
    }
    

    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


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

typedef struct node {
  int key;
  struct node *par;
  struct node *left;
  struct node *right;
} Node;

Node *root;

Node *makeNode(int key) {
  Node *new_node = (Node *)malloc(sizeof(Node));
  if(new_node == NULL) return NULL;
  new_node->key = key;
  new_node->par = NULL;
  new_node->left = NULL;
  new_node->right = NULL;
  return new_node;
}

void clearTree(Node *cur) {
  if(cur == NULL) return;
  clearTree(cur->left);
  clearTree(cur->right);
  free(cur);
}

void clear() {
  clearTree(root);
}

void insertNode(Node *new_node) {
  Node *par = NULL;
  Node *cur = root;
  while(cur != NULL) {
    par = cur;
    if(new_node->key < cur->key) cur = cur->left;
    else cur = cur->right;
  }
  new_node->par = par;
  if(par == NULL) root = new_node;
  else if(new_node->key < par->key) par->left = new_node;
  else par->right = new_node;
}

void insert(int key) {
  Node *new_node = makeNode(key);
  if(new_node == NULL) return;
  insertNode(new_node);
}

void inOrder(Node *cur) {
  if(cur == NULL) return;
  inOrder(cur->left);
  printf(" %d", cur->key);
  inOrder(cur->right);
}

void preOrder(Node *cur) {
  if(cur == NULL) return;
  printf(" %d", cur->key);
  preOrder(cur->left);
  preOrder(cur->right);
}

void print() {
  inOrder(root); puts("");
  preOrder(root); puts("");
}

int main() {
  int m;
  int i;
  scanf("%d", &m);
  root = NULL;
  for(i = 0; i < m; i++) {
    char cmd[256];
    scanf("%s", cmd);
    if(strcmp(cmd, "insert") == 0) {
      int key;
      scanf("%d", &key);
      insert(key);
    } else if(strcmp(cmd, "print") == 0) {
      print();
    }
  }
  clear();

  return 0;
}

Measured memory_bytes: 24048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main()
{
    long long n;
    scanf("%lld", &n);    
    long long v = 0;
    for (long long i = 1; i <= n; i++)
    {
        v += (i + 1) * i / 2;
    }
    long long e = 0;
    long long f = 0;
    for (long long i = 1; i < n; i++)
    {
        long long u, v;
        scanf("%lld %lld", &u, &v);
        if (u > v) swap(u, v);
        e += u * (n - v + 1);
    }
    printf("%lld\n", v - e + f);
    return 0;
}

Measured memory_bytes: 3740
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int n, k;
		int[] stock;
		int[] needs;
		StringTokenizer st;

		next: while ((line = br.readLine()) != null && !line.isEmpty()) {

			n = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			k = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
			if (n == 0 && k == 0) {
				break;
			}
			stock = new int[k];
			needs = new int[k];

			st = new StringTokenizer(br.readLine());
			for (int i = 0; i < k; i++) {
				stock[i] = Integer.parseInt(st.nextToken());
			}
			for (int i = 0; i < n; i++) {
				st = new StringTokenizer(br.readLine());
				for (int j = 0; j < k; j++) {
					needs[j] += Integer.parseInt(st.nextToken());
				}
			}
			for (int i = 0; i < k; i++) {
				if (stock[i] < needs[i]) {
					System.out.println("No");
					continue next;
				}
			}
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 41456
#include <stdio.h>

int main() {
    int n;
    int a[101];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    int max = a[0];
    int min = a[0];

    for (int i = 1; i < n; i++) {
        if (max < a[i]) {
            max = a[i];
        }
        if (min > a[i]) {
            min = a[i];
        }
    }
    printf("%d\n", max - min);
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		long n = in.nextInt();
		// not exists 0
		long x = cal(9, n);
		// not exists both 0 and 9
		long y = cal(8, n);
		// all case
		long z = cal(10, n);
		// all case - not exist 0 - not exist 9 + not exists both
		long ans = (2000000014 + z - x - x + y) % 1000000007L;
		System.out.println(ans);
	}

	private static long cal(long a, long n) {
		long ans = a;
		for (; n > 1; n--) {
			ans = (ans * a) % 1000000007L;
		}
		return ans;
	}

}


Measured memory_bytes: 35808
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
cnt = 0
for i in range(N):
    b = B[i]
    if A[i]<=b:
        b = b-A[i]
        cnt += A[i]
        cnt += min(b,A[i+1])
        A[i+1] = max(A[i+1]-b,0)
    else:
        cnt += b
print(cnt)

Measured memory_bytes: 82148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    int b[110];
    int a[110];
    rep(i,n-1) cin >> b[i];
    a[n-1] = b[n-2];
    rep(i,n-2){
        a[n - 2 - i] = min(b[n - 2 - i], b[n - 3 - i]);
    }
    a[0] = b[0];
    ll ans = 0;
    rep(i,n) {
        ans += a[i];
        // cout << a[i] << ", ";
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int dp[111][111][111];

int dfs(int a, int b, int c){
    if(dp[a][b][c] >= 0)
        return dp[a][b][c];
    if(a >= 100 || b >= 100 || c >= 100)
        return 1 << 29;

    if(a==b&&b==c)
        return 0;

    int res = 1 << 29;
    res = min(res, dfs(a + 2, b, c) + 1);
    res = min(res, dfs(a, b + 2, c) + 1);
    res = min(res, dfs(a, b, c + 2) + 1);

    for(int i = 0; i < 3; i++){
        for(int j = i + 1; j < 3; j++){
            int d[3] = {a, b, c};
            d[i]++;
            d[j]++;
            res = min(res, dfs(d[0], d[1], d[2]) + 1);
        }
    }
    
    return dp[a][b][c] = res;
}

int A, B, C;
int main(){
    cin >> A >> B >> C;
    memset(dp, -1, sizeof(dp));
    cout <<dfs(A, B, C) << endl;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
using P = pair<int, int>;
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;
    int a,b,c;
    cin>>a>>b>>c;
    int ans=-1,cnt=0;
    while(true){
        if(a%2||b%2||c%2){
            ans=cnt;
            break;
        }
        if(a==b&&b==c)break;
        int ma=a/2,mb=b/2,mc=c/2;
        a=mb+mc,b=ma+mc,c=ma+mb;
        cnt++;
    }
    cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  int a[n];
  REP(i, n) cin >> a[i];
  int q;
  cin >> q;
  while (q--) {
    int c, b, e;
    cin >> c >> b >> e;
    if (c == 0) {
      int mn = 1e9 + 1;
      for (int i = b; i < e; ++i) {
        mn = min(mn, a[i]);
      }
      cout << mn << endl;
    } else {
      int mx = -1 * (1e9 + 1);
      for (int i = b; i < e; ++i) {
        mx = max(mx, a[i]);
      }
      cout << mx << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3088
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Map<String, String> map = new HashMap<>();
		map.put("Sunny","Cloudy" );
		map.put("Cloudy", "Rainy");
		map.put("Rainy", "Sunny");
		Scanner sc = new Scanner(System.in);
		System.out.println(map.get(sc.next()));
	}
}


Measured memory_bytes: 19668
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

struct TEAM{
  int correct;
  int time;
  int num;
};

bool compare(const TEAM &a,const TEAM &b){
  if(a.correct==b.correct){
  	if(a.time==b.time) return a.num>b.num;
  	else return b.time>a.time;
  }
  else return a.correct>b.correct;
}


int main(void){
  int M,T,P,R;
  while(cin>>M>>T>>P>>R,M||T||P||R){
    int m,t,p,j;
    map<int,map<int,int> > ttime;
    map<int,int> times,correct;
    for(int i=0;i<R;++i){
      cin>>m>>t>>p>>j;
      if(j==0){
        correct[t]++;
        ttime[p][t]+=m;
        times[t]+=ttime[p][t];
      }else{
        ttime[p][t]+=20;
      }
    }
    vector<TEAM> tt(T);
    for(int i=1;i<=T;++i){
      tt[i-1].time=times[i];
      tt[i-1].correct=correct[i];
      tt[i-1].num=i;
    }
    sort(tt.begin(),tt.end(),compare);
    int oc=tt[0].correct,ot=tt[0].time;
    cout<<tt[0].num;
    for(int i=1;i<T;++i){
      if(oc==tt[i].correct,ot==tt[i].time)cout<<"=";
      else cout<<",";
      cout<<tt[i].num;
      oc=tt[i].correct,ot=tt[i].time;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1248
#include<iostream>
#include<map>
#include<vector>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
const int MAX_N = 10010;

vector<int> prime;
bool flg[MAX_N];

void make_prime(){
    flg[0] = true; flg[1] = true;
    rep(i, MAX_N){
        if(flg[i]) continue;
        prime.push_back(i);
        for(int j = i; j < MAX_N; j += i) flg[j] = true;
    }
}

int cnt_prime(int n){
    int ret = 0;
    rep(i, prime.size()){
        int sum = 0;
        for(int j = i; j < prime.size(); j++){
            sum += prime[j];
            if(sum == n) ret++;
        }
    }
    return ret;
}

int main(){
    make_prime();
    int n;
    while(cin >>n && n) cout <<cnt_prime(n) <<endl;
    return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	int S[2000], T[2000];
	rep(i, N) cin >> S[i];
	rep(i, M) cin >> T[i];

	int mod = 1e9 + 7;
	int dp[4001];
	int dpsa[4001] = {};

	rep(i, N + M + 1) dp[i] = 1;
	for (int i = N; i > 0; i--) {
		for (int j = i; j < i + M; j++) {
			if (S[N - i] == T[j - i]) {
				dp[j] = dp[j - 1] + dp[j + 1];
				dpsa[j] = dp[j + 1];
			}
			else {
				dp[j] = dp[j - 1] + dpsa[j + 1];
				dpsa[j] = dpsa[j + 1];
			}
			dp[j] %= mod;
		}
	}
	co(dp[M]);

	Would you please return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

   int n=0;
   int i=1;
   int x=0;

   scanf("%d", &n);

   for(i=1;i<=n;i++){
      x = i;
      if(x%3 == 0){
         printf(" %d", i);
      }else{
         while(x){
            if(x%10 == 3){
               printf(" %d", i);
               break;
            }           
            x /= 10;
         }
      }
   }
   printf("\n");
   return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m;
    scanf ("%lld%lld",&n,&m);
    if (n<=(n*2+m)/4) printf ("%lld",(n*2+m)/4);
    else printf ("%lld",m/2);
    return 0;
}

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

#define ED return 0;
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) int(pow(x,y))
const long long mod = 1000000007;

int main() {
    int N;
    cin >> N;
    if(N % 4 == 0 || N % 7 == 0){
        cout << "Yes" << endl;
        ED
    }
    while(true){
        if(N < 7){
            cout << "No" << endl;
            ED
        }
        N -= 7;
        if(N % 4 == 0){
            cout << "Yes" << endl;
            ED
        }
    }
}

Measured memory_bytes: 256
K,N = list(map(int,input().split()))
place_list = list(map(int,input().split()))
place = set()
for i in range(N-1):
    place.add(abs(place_list[i] - place_list[i+1]))
place.add(abs(K-place_list[N-1]+place_list[0]))
print(K-max(place))

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((a+b)==(c+d)){
        cout << "Balanced" << endl;
    }else if((a+b)>(c+d)){
        cout << "Left" << endl;
    }else{
        cout << "Right" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
	char x[10], y[10];
	int num[10], ans;
	scanf("%s", x);
	scanf("%s", y);
	
	strcat(x, y);
//	printf("%s", x);
	int z = strlen(x);
	
	for(int i = 0; i < z; i++){
		num[i] = x[i] - '0';
	}
//	for(int i = 0; i < z; i++){
//		printf("%d", num[i]);
//	}
	int ten = 1;
	for(int i = z-1; i >= 0; i--){
		ans += ten * num[i];
		ten *= 10;
	}
//	printf("%d", ans);
	int no = 1;
	for(int i = 1; i < 400; i++){
		if(i * i == ans){
			puts("Yes");
			no = 0;
			break;
		}
	}
	if(no)puts("No");
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()

int main() {
	int A, B, C;
	cin>>A>>B>>C;
	if(A == B && B == C) {
		cout << "No" << endl;
		return 0;
	} else if (A != B && A != C && B != C) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
 
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=2e5 + 5;
const int M=1e5 + 5;
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    int n,i,k;
    int s[N];
    cin>>n>>k;
    for(i=0;i<n;i++){
        cin>>s[i];
    }
    int mn[N],mx[N];
    set <int> st;
    for(i=0;i<k;i++){
        st.insert(-s[i]);
    }
    mx[k-1]=-(*(st.begin()));
    for(i=k;i<n;i++){
        st.erase(-s[i-k]);
        st.insert(-s[i]);
        mx[i]=-(*(st.begin()));
    }
    st.clear();
    for(i=n-1;i>=n-k;i--){
        st.insert(s[i]);
    }
    mn[n-k]=*(st.begin());
    for(i=n-k-1;i>=0;i--){
        st.erase(s[i+k]);
        st.insert(s[i]);
        mn[i]=*(st.begin());
    }
    int dp[N];
    dp[0]=1;
    bool ok = false;
    for(i=1;i<n;i++){
        if(s[i]>s[i-1]) dp[i]=dp[i-1]+1;
        else dp[i]=1;
    }
    for(i=0;i<n;i++){
        if(dp[i]>=k) ok=true;
    }
    int ans=0;
    if(ok) ans++;
    if(dp[k-1]<k) ans++;
    for(i=k;i<n;i++){
        if(dp[i]>=k) continue;
        if((s[i]!=mx[i]) || (s[i-k]!=mn[i-k])){
            ans++;
        }
    }
    cout << ans << endl;

 
    return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1000003;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

const int MAX_N = 2000;

bitset< MAX_N > dpl[MAX_N];
bitset< MAX_N > dpr[MAX_N];

int main() {
  int N;
  cin >> N;
  bitset< MAX_N > mat[MAX_N];
  for(int i = 1; i < N; i++) {
    string s;
    cin >> s;
    for(int j = 0; j < i; j++) {
      int x = (int) s[j] - '0';
      mat[i][j] = x;
      mat[j][i] = 1 - x;
    }
  }
  for(int i = 0; i < N; i++) {
    dpl[i][i] = dpr[i][i] = true;
  }
  for(int len = 1; len < N; len++) {
    for(int l = 0; l + len < N; l++) {
      int r = l + len;
      dpl[r][l] = (mat[l] & dpl[r] & dpr[l + 1]).any();
      dpr[l][r] = (mat[r] & dpl[r - 1] & dpr[l]).any();
    }
  }
  cout << (dpl[N - 1] & dpr[0]).count() << endl;
}




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

using namespace std;

int main(void){
    int a;
    string s;
    
    cin >> a;
    cin >> s;
    
    if(a>=3200){
        cout << s <<endl;
    }
    else{
        cout << "red" <<endl;
    }
    
    
    
    return 0;
}


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

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

typedef long long ll;

using namespace std;

ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }

map<ll,int> prime_factorize(ll a){
	map<ll,int> res;
	for(ll p=2;p*p<=a;p++) if(a%p==0) {
		int cnt=0;
		do{ a/=p; cnt++; }while(a%p==0);
		res[p]=cnt;
	}
	if(a>1) res[a]=1;
	return res;
}

int main(){
	ll a,b; cin>>a>>b;

	auto pf=prime_factorize(gcd(a,b));
	cout<<pf.size()+1<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C(I) cout<<(I)<<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc;
vector<ll> va,vb,vc;


int main(){
    cin>>n>>m;
    a=1;
    for(int i=0;i<n;i++){
        a+=min(a,m);
    }
    C(a);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int []a = new int [n];
		
		for(int i = 0 ;i < n ;i++) {
			a[i] = sc.nextInt();
		}
		
		int cnt = 1;
		
		for(int i = 0 ; i < n ;i++) {
			if(cnt == a[i]) {
				cnt++;
			}
		}
		if(cnt == 1) {
			System.out.println(-1);
		}
		else {
		System.out.println(n - cnt +1);

		}
	}

}


Measured memory_bytes: 85112
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
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)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	string s; cin>>s;
	int ans = 0;
	rep(i,s.size()){
		if(i%2 == 0){
			if(s[i] == 'p')--ans;
		}else{
			if(s[i] == 'g')++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3752
package main

// https://atcoder.jp/contests/abc088/tasks/abc088_b

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	var a []int

	sc.Split(bufio.ScanWords)
	n := nextInt()

	for i := 0; i < n; i++ {
		a = append(a, nextInt())
	}

	sort.Ints(a)

	isAlice := true
	Alice := 0
	Bob := 0

	for i := len(a) - 1; i >= 0; i-- {
		if isAlice {
			Alice += a[i]
		} else {
			Bob += a[i]
		}
		isAlice = !isAlice
	}
	fmt.Printf("%v\n", Alice-Bob)
}


Measured memory_bytes: 640
/**
*	created: 19.09.2020 20:58:10
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rrep(i,n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
using ll = long long;
using P = pair<int,int>;
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;
template<typename T> inline bool chmax(T &a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T> inline bool chmin(T &a, T b) {if (b < a) {a = b; return 1;} return 0;}
inline void print(P a) {cout << a.first << " " << a.second << endl;}
template<typename T> T pow(T a, ll n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
struct faster_io {faster_io() {cin.tie(0); ios_base::sync_with_stdio(false);}} faster_io_;

signed main() {
    string s; cin >> s;
    if (s[s.size()-1] == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define MAX 1e9+7
#define MIN -1e9-7
#define int long long
#define endl "\n"
#define s(n) scanf("%d",&n)
#define mem memset(a, 0, sizeof(a))
#define minimum(a)	*min_element(a.begin(), a.end())
#define maximum(a)	*max_element(a.begin(), a.end())
typedef vector<int> vi;
typedef vector<string> vs;
/*
* * * * * * * * * * * * * * * * * * * * * *
*       ☆꧁𝓑𝓐𝓒𝓚_𝓛𝓞𝓖꧂☆              **
*                                        ***
* * * * * * * * * * * * * * * * * * * * *****
*/ 

int32_t main()
{
  int n;
  cin>>n;
  vector<pair<int,int>>v;
  for(int i=0;i<n;i++)
  {
	  int a,b;
	  cin>>a>>b;
	  v.push_back({a,b});
  }
  int mx=-1;
  for(int i=0;i<n;i++)
  {
	  int count=0;
	  for(int j=i;j<n;j++)
	  {
		  if(v[j].first==v[j].second)
		  {
			  count++;
		  }
		  else
		  {
			  break;
		  }
	  }
	  mx=max(mx,count);
  } 
  if(mx>=3)
  {
	  cout<<"Yes"<<endl;
  }
  else
  {
	  cout<<"No"<<endl;
  }
return 0;

}




Measured memory_bytes: 3600
<?php
    fscanf(STDIN, "%d %d", $a, $b);
    if($a === $b){
        echo $a * 2;
    }else{
        if($a > $b){
            echo ($a * 2) -1;
        }else{
            echo ($b * 2) -1;
        }
    }
?>

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = 998244353;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


ll mod_pow(ll x,ll n){
  ll res=1;
  while(n){
    if(n%2) res=res*x%mod;
    x=x*x%mod;
    n/=2;
  }
  return res;
}


ll divi(ll a,ll b){
  return a * mod_pow(b,mod-2) % mod;
}

ll factorial(Int i){
  static vector<ll> k(1e6);
  if(!k[0]){k[0]=1;for(Int i=1;i<(Int)k.size();i++)k[i]=i*k[i-1]%mod;}
  return k[i];
}

ll nCr(ll n,ll r){
  if(r > n) return 0;
  ll a = mod_pow( factorial(r) * factorial(n-r) % mod ,mod-2);
  return factorial(n) * a % mod;
}

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int n, A,B,K;
  cin>>n>>A>>B>>K;
  Int ans = 0;
  
  for(Int a=0;a <= n; a++){
    Int sumA = A * a;
    Int b = (K - sumA)/B;
    Int sumB = B * b;
    if(a < 0 || b < 0 || sumA + sumB != K) continue;
    ans += nCr(n, a) * nCr(n, b)%mod;
    ans %= mod;
  }

  ans%=mod;
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 8064
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {

    int n, x;
    int cnt=0;
    cin >> n >> x;
    while(n!=0||x!=0){
        
                

            
        for(int i=1; i<=n; i++){
            for(int j=i+1; j<=n; j++){
                for(int k=j+1; k<=n; k++){
                    if(i+j+k==x)
                        cnt++;
                }
            }
        }

    cout << cnt << endl; 
    cin >> n >> x;
    cnt = 0;
    }
    
    
    
    return 0;
    
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
//#include <iostream>
#define int long long

using namespace std;

int gcd (int a, int b) {
	return b ? gcd (b, a % b) : a;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k, suma = 0;
    cin >> k;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int m = 1; m <= k; ++m) {
                suma += gcd(i, gcd(j, m));
            }
        }
    }
    cout << suma;
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
int main(){
    int n;
    int i;
    scanf("%d",&n);
    int a[n];
    for(i = 0;i < n;i++){
        scanf("%d",&a[i]);
    }
    for(i = n - 1;i >=0;i--){
        if(i != 0){
        printf("%d ",a[i]);
        }
        else{
            printf("%d\n",a[i]);
        }
}
return 0;
}


Measured memory_bytes: 2588
#define R(x)if(r>x)r=x;
main(r,D,t,a,b,c,d,e,A,B,C){for(;scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&A,&B,&C)>7;printf("%d\n",r)){
	r=a*A+b*B+c*C;
	if(C>=d)r=a*A+b*B+e*C;
	else if(D=d,d-=C,t=B<d?B:d,B-=t,d-=t,t=A<d?A:d,A-=t,d-=t,r>a*A+b*B+e*D)r=a*A+b*B+e*D;
}exit(0);}

Measured memory_bytes: 600
h,w,a,b = map(int,input().split())
s = [['0' for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if (i < b and j >= a) or (i >= b and j < a):
            s[i][j] = '1'
    print(''.join(map(str,s[i])))

Measured memory_bytes: 12916
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
print(min(N * A, B))


Measured memory_bytes: 5148
s = input()
sLen = len(s)
for i in range(2**(sLen-1)):
  tmpAns = 0
  tmpOp =''
  for j in range(sLen-1):
    if((i>>j)&1):
      tmpAns += int(s[sLen-1-j])
      tmpOp += '+'
    else:
      tmpAns -= int(s[sLen-1-j])
      tmpOp += "-"
  if tmpAns+int(s[0]) == 7:
    print(s[0]+tmpOp[2]+s[1]+tmpOp[1]+s[2]+tmpOp[0]+s[3]+"=7")
    break


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int N;

void solve(int a,int Max,string S) {
    if(a == N - 1) {
        cout << "a" << S << endl;
        return;
    }
    else {
        for(int i = 0;i < Max + 1;i++) {
            char A = 'a' + i;
            solve(a + 1,max(Max,i + 1),S + A);
        }
    }
    return;
}

int main() {
    cin >> N;
    solve(0,1,"");
}

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

int main() {
  string S;
  cin >> S;

  int x = (int)(S[5] - '0') * 10 + (int)(S[6] - '0');
  
  if (x > 4) cout << "TBD" << endl;
  else cout << "Heisei" << endl;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  if(s.size() > t.size()){
    for(int i = 0; i < t.size();++i){
      cout << s.at(i) << t.at(i);
    }
    cout << s.at(s.size()-1) << endl;
  } else if(s.size() < t.size()){
    for(int i = 0; i < s.size(); ++i){
      cout << s.at(i) << t.at(i);
    }
    cout << t.at(t.size()) << endl;
  } else {
    for(int i = 0; i < s.size(); ++i){
      cout << s.at(i) << t.at(i);
    }
    cout << endl;
  }
  
}


Measured memory_bytes: 256