akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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





void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> h(n);
    vector<int> c(n,1e9);
    
    rep(i,n) cin >> h[i];
    c[0] = 0;
    c[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
        c[i] = min(   c[i-1]+abs(h[i]-h[i-1])   ,   c[i-2]+abs(h[i]-h[i-2])   );
    }
    cout << c[n-1] << endl;
}



signed main() {
    
    
    solve();
    return 0;
}



Measured memory_bytes: 1792
import math
K=int(input())
ans=0
for i in range(K):
  for j in range(K):
    if math.gcd(i+1,j+1)==1:
      ans+=K
    else:
      for k in range(K):
        ans+=math.gcd(math.gcd(i+1,j+1),k+1)
print(str(ans))

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

int main(){
  int n;
  long long mo = 1000;
  int last, now;
  cin >> n;
  rep(i, n){
    cin >> now;
    //上がるなら買う
    if(i!=0 && last < now){
      long long num = mo/last;
      mo += num * (now-last);
      // cout << "(" << i << "," << mo << ")";
    }
    last = now;
  }

  cout << mo;
  return 0;
}


Measured memory_bytes: 3604
c1, c2, c3 = [list(map(int, input().split())) for _ in range(3)]

is_true = [0, 0]
for i in range(-100, 101):
    row = [v + i for v in c1]
    if row == c2:
        is_true[0] = 1
    if row == c3:
        is_true[1] = 1

print('Yes' if all(is_true) else 'No')

Measured memory_bytes: 3060
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<int> A(N+1,0);
	int MAX = 0;

	for(int i=1;i<=N;++i){
		cin >> A[i];
	}
	LL ans = 0;
	for(int i=1;i<=N;++i){
		int L,R;
		L = MAX + 1;//[0,i);
		R = A[i];
		if( L < R ){
			/*
			なるべくRを1にしたい(L以下)
			Lずつ削った時あまるのは
			[1,L-1]
			一回は必ず削れるので
			L+L-1をけずればよい
			*/
			int cnt = (R-1)/L;
			ans += cnt;
			R = 1;
		}
		//A[i] = R;
		MAX = max(MAX,R);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 640
/*
 ***
 Question Name:
 ***
 Question Link:
 
 ***
 Idea:
 */

#include <memory.h>
#include <iomanip>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef unordered_set<int> ui;
typedef pair<LL,LL> pLL;

int main(){
    int N;
    cin>>N;
    cout<<"ABC"<<N<<endl;
    return 0;
}

Measured memory_bytes: 256
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
ll power(ll x, ll y); 

const ll MOD = 1000000007;

int n;
vector<string> v;
 
int f(int s){
    int vis[n] = {0};
    vector<int> cur;
    cur.pb(s);
    vis[s] = 1;
    int ret = 0;
    while(1){
        ret++;
        vector<int> new_cur;
        for(auto &i : cur){
            for(int j = 0 ; j < n ; j++){
                if(v[i][j] == '0' || vis[j]) continue;
                vis[j] = 1;
                new_cur.pb(j);
            }
        }
        if(new_cur.size() == 0) break;
        cur = new_cur;
        for(auto &i : cur) for(auto &j : cur) if(v[i][j] == '1') return -1;
    }
    return ret;
}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    cin >> n;
    v.resize(n);
    for(auto &i : v) cin >> i;
    int res = -1;
    rep(i, 0, n) res = max(res, f(i));
    cout << res;
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int dp[50][50];
int main(){
	int w,h;
	while(true){
	cin>>w>>h;
	if(w==0&&h==0)
		break;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			cin>>dp[i][j];
	int count=0;
	while(true){
		bool t=true;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(dp[i][j]!=0)
					t=false;
			}
		}
		if(t==true)
			break;
		int x=0,y=0;
		while(true){
			x=0;
			while(true){
				if(dp[y][x]==1){
					t=true;
					break;
				}
				x++;
				if(x==w)
					break;
			}
			if(t==true)
				break;
			y++;
		}
		for(int f=max(0,y-1);f<=min(h-1,y+1);f++){
			for(int g=max(0,x-1);g<=min(w-1,x+1);g++){
				if(dp[f][g]==1)
				    dp[f][g]=2;
			}
		}
		dp[y][x]=0;
		while(true){
			t=true;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(dp[i][j]==2){
						for(int f=max(0,i-1);f<=min(h-1,i+1);f++){
			                for(int g=max(0,j-1);g<=min(w-1,j+1);g++){
								if(dp[f][g]==1)
				                    dp[f][g]=2;
			                }
						}
						dp[i][j]=0;
						t=false;
					}
				}
			}
			if(t==true)
				break;
		}
		count++;
	}
	cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<cmath>
#include<set>
#include<map>
#include<cstdio>
#include<ctime>
#include<vector>
#include<stdlib.h>

#define endl '\n'
#define ll long long
#define ull unsigned ll
#define x first
#define y second

using namespace std;



int main(){
    ll n;
    cin>>n;
    ll x=1,y=1;
    ll a,b;
    ll beshu,beshu1;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        beshu=1;
        if(a<x){
            if(!(x%a))beshu=x/a;
            else beshu=x/a+1;
        }
        if(b<y){
            beshu1=1;
            if(!(y%b)) beshu1=y/b;
            else beshu1=y/b+1;
            beshu=max(beshu,beshu1);
        }
        x=a*beshu;
        y=b*beshu;
    }
    cout<<x+y<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;
const int N=100010;
map <int,int> w;
int fa[N],a[N],s[N],v[N],st[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
int main() {
    int n,m,tp=0;
    long long sum=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++) fa[i]=i,a[i]=gi(),s[i]=1<<30;
    for(int i=1;i<=m;i++) {
	int x=gi()+1,y=gi()+1;
	fa[find(x)]=find(y);
    }
    for(int i=1;i<=n;i++) {
	int x=find(i);
	if(i==x) v[++tp]=i;
	st[i]=a[i],s[x]=min(s[x],a[i]);
    }
    if(tp==1) return puts("0"),0;
    for(int i=1;i<=tp;i++) sum+=s[v[i]],++w[s[v[i]]];
    sort(st+1,st+1+n);
    for(int i=1,j=1;i<tp-1;i++,j++) {
	while(j<=n&&w[st[j]]) --w[st[j]],++j;
	if(j>n) return puts("Impossible"),0;
	sum+=st[j];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 8960
#include<iostream>

using namespace std;

int main(){
  int n;
  cin>>n;
  int a[200000];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  long long ans=0,s=0;
  for(int i=0;i<n;i++){
    ans=((s*a[i])+ans)%(1000000000+7);
    s=(s+a[i])%(1000000000+7);
  }
  cout<<ans<<endl;
}

	   


Measured memory_bytes: 4400
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 30
#define MAX_D 400

    /*
    いろいろ
    int x = rand()%100;
    double x = (double)rand()/RAND_MAX;
    mt19937 get_rand_mt;
    shuffle(vec.begin(), vec.end(), get_rand_mt);
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, -1, 0, 1};
    char cc[4] = {'U','L','D','R'};
    */

int D;
int c[MAX_N];
int s[MAX_D][MAX_N];
int ma;
int ans[MAX_D];

int calc(){
    int las[26] = {};
    int res = 0;
    rep(i,D){
        res += s[i][ans[i]];
        las[ans[i]] = i+1;
        rep(j,26){
            res -= (i + 1 - las[j]) * c[j];
        }
    }
    return res;
}


int main() {
    srand((unsigned) time(NULL));
    clock_t start,end;
	start = clock();


    string fileNameIfs = "input_1.txt";
    const char* cstrIfs = fileNameIfs.c_str();
    ifstream ifs(cstrIfs);
    if(!ifs.is_open()){ // 標準入力する
        cin >> D;
        rep(i,26)cin >> c[i];
        rep(i,D)rep(j,26)cin >> s[i][j];
    }else{ // ファイル入力する
        ifs >> D;
        rep(i,26)ifs >> c[i];
        rep(i,D)rep(j,26)ifs >> s[i][j];
    }    
    

    rep(i,D){
        int max_s = -1;
        int arg = -1;
        rep(j,26){
            if(s[i][j] > max_s){
                max_s = s[i][j];
                arg = j;
            }
        }
        ans[i] = arg;
    }

    ma = calc();

    start = clock();
    while(true){
        int x = rand()%D;
        int y = rand()%26;

        int keep = ans[x];
        ans[x] = y;

        int tmp = calc();

        if(tmp >= ma){
            ma = tmp;
        }else{
            ans[x] = keep;
        }

        end = clock();
        if((double)(end-start)/CLOCKS_PER_SEC > 1.7)break;
    }


    rep(i,D){
        cout << ans[i] + 1 << endl;
    }

    string fileName = "sample_out1.txt";
    const char* cstr = fileName.c_str();
    ofstream ofs(cstr);
    rep(i,D){
        ofs << ans[i] + 1 << endl;
    }
    ofs.close();

    return 0;
}
 
 


Measured memory_bytes: 3720
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

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

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

//
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k;
  cin >> n >> k;

  if (k == 1)
    cout << 0 << endl;
  else
    cout << (n - k + 1) - 1 << endl;

  return 0;
}

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

bool f(int x){
  int keta = 0;
  while(x){
    keta++;
    x /= 10;
  }
  return keta%2 == 1;
}

int main(){
  int n;
  int count =0;
  cin >> n;

  for(int i=0; i<=n; ++i){
    if(f(i)) count++;    
  }

  cout << count << endl;
} 


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

end = n
dif = set()
count = 0
for i in range(1, n+1):
    while end-i in dif or n+i-end in dif or end-i == n+i-end:
        end -= 1
    print(i, end)
    dif.add(end-i)
    dif.add(n+i-end)
    end -= 1
    count += 1
    if count == m:
        break

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

const ll m = 1000000007;

int main(){
    int n;
    cin >> n;
    ll ans1 = 1;
    rep(i, n){
        ans1 *= 10;
        if(ans1 > m) ans1 %= m;
    }
    ll ans2 = 2;
    rep(i, n){
        ans2 *= 9;
        if(ans2 > m) ans2 %= m;
    }
    ll ans3 = 1;
    rep(i, n){
        ans3 *= 8;
        if(ans3 > m) ans3 %= m;
    }
    ll ans = ans1 - ans2 + ans3;
    if(ans < 0) ans += m;
    cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  int n = 0, w = 0, s = 0, e = 0;
  rep(i, S.size()) {
    switch (S[i]) {
      case 'N':
        n = 1;
        break;
      case 'W':
        w = 1;
        break;
      case 'S':
        s = 1;
        break;
      case 'E':
        e = 1;
        break;
    }
  }
  cout << (n == s && w == e ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace abc144_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] AB = Console.ReadLine().Split(' ');
            int A = Convert.ToInt32(AB[0]);
            int B = Convert.ToInt32(AB[1]);
            if(A<=9 && B <= 9)
            {
                Console.WriteLine(A * B);
            }
            else
            {
                Console.WriteLine(-1);
            }
            Console.ReadLine();
        }
    }
}


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

using namespace std;
typedef pair<char, int> P;

int n;
P card[100010], cpy[100010];

int partition(int p, int r) {
    int x = card[r].second, i = p - 1;
    for (int j = p; j < r; j++) {
        if (card[j].second > x) continue;
        i++;
        swap(card[i], card[j]);
    }
    swap(card[i + 1], card[r]);
    return i + 1;
}

void quickSort(int p, int r) {
    if (p >= r) return;
    int q = partition(p, r);
    quickSort(p, q - 1);
    quickSort(q + 1, r);
}

bool comp(const P& p1, const P& p2) {
    return p1.second < p2.second;
}

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> card[i].first >> card[i].second;
        cpy[i] = card[i];
    }

    quickSort(0, n - 1);
    stable_sort(cpy, cpy + n, comp);

    bool flag = false;
    for (int i = 0; i < n; i++) {
        if (card[i] == cpy[i]) continue;
        flag = true;
    }

    if (flag) cout << "Not stable\n";
    else cout << "Stable\n";
    
    for (int i = 0; i < n; i++)
        cout << card[i].first << " " << card[i].second << endl;

    return 0;
}


Measured memory_bytes: 5184
import java.util.Scanner;

public class Main {
    static String S;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        S = in.next();
        int len = S.length();
        long count = 0;
        int idx;
        String str;
        for (int i = 0; i < Math.pow(2, len - 1); i++) {
            idx = 0;
            // System.out.println("i:"+i);
            for (int j = 0; j < len - 1; j++) {
                if ((1 & i >> j) == 1) {
                    // System.out.println("i:" + i + ", j:" + j);
                    count += Long.parseLong(S.substring(idx, j + 1));
                    // System.out.println("count:" + count);
                    idx = j + 1;
                }
            }
            count += Long.parseLong(S.substring(idx));
            // System.out.println("count:" + count);
        }
        System.out.println(count);
    }
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    
    if(s == u)
        a--;
    if(t == u)
        b--;
    
    cout << a << ' ' << b << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
long long counter=0;
cin>>N;
  if(N%2==0){
   for (long long a = 10; a <= N; a*=5) {
      counter+=N/a;
        }
    cout<<counter<<endl;}
  else{
    cout<<0<<endl;}}
  


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

typedef long long ll;

const ll MOD = 998244353;

int n, S;
vector<ll> a;
vector<vector<int>> dp;

ll rec(int i, int s) {
	if (s < 0) return 0;
	if (s == 0) return n - i + 1;
	if (i == n) return 0;
	if (dp[i][s] != -1) return dp[i][s];
	if (s == S) return dp[i][s] = (((rec(i + 1, s) + rec(i + 1, s - a[i]) * ll(i+1)) % MOD)) % MOD;
	return dp[i][s] = (((rec(i + 1, s) + rec(i + 1, s - a[i])) % MOD)) % MOD;
}

int main() {
	cin.sync_with_stdio(false); cin.tie(nullptr);
	cin >> n >> S;
	a = vector<ll>(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	dp = vector<vector<int>>(n, vector<int>(S+1, -1));
	cout << rec(0, S) << endl;
	return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF = 1LL<<60;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)


vector<vector<ll>> d;
struct edge{int to, cost;};

void wf(){
    int n = d.size();
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,l; cin>>n>>m>>l;
	d = vector<vector<ll>>(n,vector<ll>(n,INF));
    rep(i,m){
        ll a,b,c;cin>>a>>b>>c;a--;b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    rep(i,n)d[i][i]=0;
    wf();
    rep(i,n)rep(j,n){
        if(i==j)d[i][j]=0;
        else d[i][j]=(d[i][j]<=l)?1:INF;
    }
    wf();
    ll q;cin>>q;
    rep(i,q){
        ll s,t;cin>>s>>t;s--;t--;
        cout<<(d[s][t]==INF?-1:d[s][t]-1)<<endl;
    }




    return 0;
}

Measured memory_bytes: 1280
use std::io;

fn solve(h: u64, w: u64) -> u64 {
    if h == 1 || w == 1 {
        return 1;
    }
    let (first_line, second_line) = if w % 2 == 0 {
        (w / 2, w / 2)
    } else {
        (w / 2 + 1, w / 2)
    };
    let (n_first_line, n_second_line) = if h % 2 == 0 {
        (h / 2, h / 2)
    } else {
        (h / 2 + 1, h / 2)
    };
    (first_line * n_first_line) + (second_line * n_second_line)
}

#[test]
fn test_solve() {
    assert_eq!(solve(4, 5), 10);
    assert_eq!(solve(7, 3), 11);
    assert_eq!(solve(1000000000, 1000000000), 500000000000000000);
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let mut iter = input.split_whitespace();
    let h: u64 = iter.next().unwrap().parse().unwrap();
    let w: u64 = iter.next().unwrap().parse().unwrap();
    println!("{}", solve(h, w));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define mkp make_pair
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<<endl;}}
#define print1d(mat,n){for(int i=0;i<(int)(n);i++)cout<<mat[i]<<" ";cout<<endl;}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define printpair(v) for(auto val: v){cout<<val.fi<<":"<<val.se<<", ";}cout<<endl;
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<endl;
#define init(v,x) for (auto &itr:v){itr=x;}
#define ln length()
const int mod = 998244353;
#define sz size()
const int inf = 1e18;
int n,w;
string s,t;
int nxt[3005][3005];
int dp[3005][3005];
int f(int i,int j){
    if(i==s.sz || j==t.sz){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    int ans=0;
    int ta;
    if(s[i]==t[j]){
        ta=f(i+1,j+1);
        if(ta+1>ans) {
            nxt[i][j]=0;
            ans = ta+1;
        }
    }
    ta=f(i+1,j);
    if(ta>ans){
        nxt[i][j]=1;
        ans=ta;
    }
    ta=f(i,j+1);
    if(ta>ans){
        nxt[i][j]=2;
        ans=ta;
    }
    dp[i][j]=ans;
    return ans;

}
void solve() {
    clr(dp,-1);
    clr(nxt,-1);
    cin>>s>>t;
    int x=f(0,0);
    int i=0,j=0;
    while(i<s.sz && j<t.sz){
        if(nxt[i][j]==0){
            cout<<s[i];
            i++;
            j++;
        }
        else if(nxt[i][j]==1){
            i++;
        }
        else{
            j++;
        }
    }
    cout<<endl;

}

int32_t main(){
    fastIO
#ifndef ONLINE_JUDGE
    freopen(R"(C:\Users\swast\CLionProjects\untitled\input.txt)", "r", stdin);
#endif
    int t=1;
//    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

ll memo[100033][32];

ll nCr(int n, int r)
{
	if (memo[n][r]) return memo[n][r];
	if (r == 0 || n == r) return memo[n][r] = 1;
	if (r == 1) return memo[n][r] = n;
	ll res = nCr(n-1, r-1) + nCr(n-1, r);
	return memo[n][r] = res % MOD;
}

int N, M;
vector<int> v;

void init()
{
	cin >> N >> M;
	int t = 2;
	while (M != 1) {
		v.PB(0);
		while (M % t) t++;
		while (M % t == 0) {
			v.back()++;
			M /= t;
		}
	}
}

void solve()
{
	ll res = 1;
	rep(i, v.size()) {
		res *= nCr(N-1+v[i], v[i]);
		res %= MOD;
	}
	cout << res << endl;
}


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

using namespace std;

constexpr int MAX_N = 100100;
constexpr int VAR = 3;

int n;
int arr[MAX_N][VAR];

int dp[MAX_N][VAR];

int main() {
    scanf(" %d", &n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < VAR; ++j) {
            scanf(" %d", &arr[i][j]);
        }
    }

    memset(dp, -1, sizeof(dp));

    for (int j = 0; j < VAR; ++j) {
        dp[0][j] = 0;
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < VAR; ++j) {
            for (int k = 0; k < VAR; ++k) {
                if (k == j) continue;
                if (dp[i - 1][k] == -1) continue;
                int cur = dp[i - 1][k] + arr[i][j];
                if (dp[i][j] == -1 || cur > dp[i][j]) {
                    dp[i][j] = cur;
                }
            }
        }
    }

    int ans = -1;
    for (int j = 0; j < VAR; ++j) {
        if (ans == -1 || dp[n][j] > ans) {
            ans = dp[n][j];
        }
    }

    printf("%d\n", ans);

    return 0;
}


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

using namespace std;

#define fto(i, s, e) for(int i = s; i <= e; ++i)
#define fto1(i, s, e) for(int i = s; i < e; ++i)
#define fdto(i, s, e) for(int i = s; i >= e; --i)
#define fit(var, it) for(__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define frit(var, it) for(__typeof(var.rbegin()) it = var.rbegin(); it != var.rend(); ++it)

#define newl '\n'
#define debugt cerr << 0.001*clock() << newl
#define debug1(x, i) cout << #x << '[' << i << "] = " << x[i] << newl
#define debug(v, l, r) fto(_i, l, r) debug1(v, _i)
#define debug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << newl
#define debug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << newl

#define ll long long
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define glen(v) int((v).size())

template<typename T1, typename T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.ff << ", " << v.ss << ')';
}

#define eps 1e-15
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 100003

int n, k;
int a[maxn];
bool f[maxn];

int main() {
	#ifndef ONLINE_JUDGE
		//freopen("main.inp", "r", stdin);
		//freopen("main.out", "w", stdout);
	#endif
	//ios_base::sync_with_stdio(0); cin.tie(0);

	scanf("%d%d", &n, &k);

	fto (i, 1, n) scanf("%d", &a[i]);

	sort(a + 1, a + 1 + n);

	fto (i, 1, k) {
		int mx = upper_bound(a + 1, a + 1 + n, i) - a - 1;
		fto (j, 1, mx) f[i] = max(f[i], !f[i - a[j]]);
	}

	puts(f[k] ? "First" : "Second");

	return 0;
}


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

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

    if(s[0]==s[1]){
      if(s[2]==s[3] && s[0]!=s[2]){
        cout << "Yes" << endl;
        return 0;
      }
    } else if(s[0]==s[2]){
      if(s[1]==s[3]){
        cout << "Yes" << endl;
        return 0;
      }
    } else if(s[0]==s[3]){
      if(s[1]==s[2]){
        cout << "Yes" << endl;
        return 0;
      }
    }

    cout << "No" << endl;
    return 0;
}


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

using namespace std;

int sumdigit(int x) {
	int sum = 0;
	while (x > 0) {
		sum += x % 10;
		x /= 10;
	}

	return sum;
}

int main() {

	int n, k,l[100];
	cin >> n >> k;

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

	sort(l, l + n,greater<int>());

	int sum = 0;

	for (int i = 0; i < k; i++) {
		sum += l[i];
	}

	cout << sum << endl;

return 0;
}




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

int main()
{
	int n =10;
	vector < int > hills;
	hills.resize(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> hills[i];
	}

	sort(hills.begin(), hills.end(), greater<int>());

	int output_num = 3;
	for(int i = 0; i < output_num; ++i)
	{
		cout << hills[i] << endl;
	}

	return 0;
}

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





int main(){
  while(1){


  
  int x,y;
  cin>>x>>y;
  if(x==0 && y==0){break;}
  int a[50]={};
  int b[50]={};
  int count=0;
  for(int i=0;i<x;i++){
    cin>>a[i];
    count+=a[i];
  }
  for(int i=0;i<y;i++){
    cin>>b[i];
    count+=b[i];
  }
  for(int i=0;i<x;i++){
    for(int t=0;t<y;t++){
      if(a[i]==b[t]  && b[t]!=0){
	count-=a[i];
	b[t]=0;
	break;
      }
    }
  }
  
  cout<<count<<endl;





  }
  
  return 0;
}



Measured memory_bytes: 3072
H,W=map(int,input().split())
S = [ input() for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j]=='#':

            continue
for h in range(H):
    l = ''
    for w in range(W):
        if S[h][w] == '#':
            l += '#'
        else:
            x = 0
            for dh in [ -1, 0, 1]:
                for dw in [-1, 0, 1]:
                    if 0 <= h + dh < H and 0 <= w + dw < W and S[h+dh][w+dw] == '#':
                        x += 1
            l += str(x)
    print(l)


Measured memory_bytes: 3064
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
void solve(){
	ll n;
	cin>>n; 
	cout<<(n+1)/2;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 507;
char a[N][N], b[N][N];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
            a[i][j] = b[i][j] = '.';

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (j < m - 1 && (j == 0 || i % 2 == 0))
                a[i][j] = '#';
            else
                b[i][j] = '#';
        }   
    }   
    
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            char c; cin >> c;
            if (c == '#')
                a[i][j] = b[i][j] = '#';
        }   
    }   

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j)
            cout << a[i][j];
        cout << endl;
    }   
    cout << endl;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j)
            cout << b[i][j];
        cout << endl;
    }   
        

}

Measured memory_bytes: 1280
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

vector<int>vec[1 << 17];
map<char,int>m;
int dp[1 << 21];

int32_t main(){_
    //freopen("input","r",stdin);
	string s;
	cin >> s;
	for(int i = 0;i < sz(s);i++) vec[(int)s[i]].pb(i);
	for(char c = 'a';c <= 'z';c++) m[c] = 1e9;
	for(int i = 0;i <= 300000;i++) dp[i] = 1;
	for(int i = sz(s) - 1;i >= 0;i--)
	{
		m[s[i]] = min(m[s[i]],i);
		dp[i] = 1e9;
		for(char c = 'a';c <= 'z';c++)
		{
			if(m[c] == 1e9) dp[i] = 1;
			else dp[i] = min(dp[i],dp[m[c] + 1] + 1);
		}
	}
	int lst = 0;
	string ans = "";
	for(int i = 0;i < dp[0];i++)
	{
		for(char c = 'a';c <= 'z';c++)
		{
			if(lower_bound(vec[(int)c].begin(),vec[(int)c].end(),lst) == vec[(int)c].end() || dp[*lower_bound(vec[(int)c].begin(),vec[(int)c].end(),lst) + 1] <= dp[0] - i - 1)
			{
				ans += c;
				if(lower_bound(vec[(int)c].begin(),vec[(int)c].end(),lst) != vec[(int)c].end())
				lst = *lower_bound(vec[(int)c].begin(),vec[(int)c].end(),lst) + 1;
				break;
			}
		}
	}
	rc(ans);
}

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

struct node_t {
	int key;
	struct node_t *parent;
	struct node_t *left;
	struct node_t *right;
};
typedef struct node_t Node;

Node *tree_insert(Node *top, Node *z) {
	Node *y, *x;

	y = NULL;
	x = top;
	while (x != NULL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NULL) {
		top = z;
	} else if (z->key < y->key) {
		y->left = z;
	} else {
		y->right = z;
	}
	return top;
}

int tree_find(Node *node, int key) {
	if (node == NULL)
		return 0;
	if (node->key == key)
		return 1;
	if (key < node->key)
		return tree_find(node->left, key);
	return tree_find(node->right, key);
}

void inorder_walk(Node *node) {
	if (node->left != NULL) {
		inorder_walk(node->left);
	}
	printf(" %d", node->key);
	if (node->right != NULL) {
		inorder_walk(node->right);
	}
}

void preorder_walk(Node *node) {
	printf(" %d", node->key);
	if (node->left != NULL) {
		preorder_walk(node->left);
	}
	if (node->right != NULL) {
		preorder_walk(node->right);
	}
}

int main(void) {
	int n, i, key;
	char cmd[20];
	Node *top = NULL, *p;

	scanf("%d ", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %d ", cmd, &key);
		if (cmd[0] == 'i') {
			p = malloc(sizeof(Node));
			p->key = key;
			p->parent = p->left = p->right = NULL;
			top = tree_insert(top, p);
		} else if (cmd[0] == 'f') {
			puts(tree_find(top, key) ? "yes" : "no");
		} else {
			inorder_walk(top);
			putchar('\n');
			preorder_walk(top);
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 19364
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define pb push_back
#define mp make_pair

typedef long long tint;
typedef unsigned long long utint;
typedef long double ldouble;

typedef vector<int> vint;

int toNumber (string s)
{
	int Number;
	if ( ! (istringstream(s) >> Number) ) Number = 0; // el string vacio lo manda al cero
	return Number;
}

string toString (int number)
{
    ostringstream ostr;
    ostr << number;
    return  ostr.str();
}

int main (){
	int n, a, b;
	cin>>n>>a>>b;
	string s;
	cin>>s;
	int ca=0, cb=0;
	forn(i, s.size()){
		if(s[i]=='a'){
			if(ca+cb<a+b){
				ca++;
				cout<<"Yes"<<endl;
				continue;
			}
		}
		if(s[i]=='b'){
			if(ca+cb<a+b && cb<b){
				cb++;
				cout<<"Yes"<<endl;
				continue;
			}
		}
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    pair<int,int> last;
    int x,y;
    cin >> x >> y;
    last.first = x;
    last.second = y;
    int curr = (x==y)? 1 : 0;
    int u,v;
    bool ok = false;
    for(int i=0; i<n-1; i++)
    {
        cin >> u >>v;
        if(u == v)
        {
            curr++;
            if(curr == 3)
            {
                ok = true;
                break;
            }
        }
        else
        curr = 0;
    }
    if(ok)
    cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;

int main(){
    int N; cin >> N;
    vector<double> x(N), y(N);
    for(int i=0; i<N; i++){
        cin >> x[i] >> y[i];
    }
    double left=0, right=1e6;
    while(right-left > 1e-7){
        double R=(left+right)/2;
        bool ok=false;
        for(int i=0; i<N; i++){
            for(int j=i+1; j<N; j++){
                double dist=sqrt(pow(x[i]-x[j], 2)+pow(y[i]-y[j], 2));
                if(dist > 2*R) continue;
                double h=sqrt(R*R-dist*dist/4);
                double ux, uy, vx, vy;
                ux=(x[i]+x[j])/2+h/dist*(-y[i]+y[j]);
                uy=(y[i]+y[j])/2+h/dist*(x[i]-x[j]);
                vx=(x[i]+x[j])/2+h/dist*(y[i]-y[j]);
                vy=(y[i]+y[j])/2+h/dist*(-x[i]+x[j]);
                bool ok_u=true, ok_v=true;
                for(int k=0; k<N; k++){
                    if(k == i || k == j) continue;
                    if(pow(x[k]-ux, 2)+pow(y[k]-uy, 2) > R*R) ok_u=false;
                    if(pow(x[k]-vx, 2)+pow(y[k]-vy, 2) > R*R) ok_v=false;
                }
                if(ok_v || ok_u) ok=true;
            }
        }
        if(ok) right=R;
        else left=R;
    }
    printf("%.6f\n", right);
    return 0;
}

Measured memory_bytes: 3808
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

using CostType = int;
struct Edge {
  int src, dst; CostType cost;
  Edge(int src, int dst, CostType cost = 0) : src(src), dst(dst), cost(cost) {}
  inline bool operator<(const Edge &x) const {
    return cost != x.cost ? cost < x.cost : dst != x.dst ? dst < x.dst : src < x.src;
  }
  inline bool operator<=(const Edge &x) const { return !(x < *this); }
  inline bool operator>(const Edge &x) const { return x < *this; }
  inline bool operator>=(const Edge &x) const { return !(*this < x); }
};

int main() {
  int n, m; cin >> n >> m;
  vector<vector<Edge> > graph(n);
  REP(_, m) {
    int u, v, s; cin >> u >> v >> s; --u; --v;
    graph[u].emplace_back(u, v, s);
    graph[v].emplace_back(v, u, s);
  }
  ll lb = 1, ub = LINF, ans;
  bool fixed = false;
  vector<ll> c(n, 0);
  vector<int> dist(n, INF);
  dist[0] = 0;
  function<void(int, int)> dfs = [&](int par, int ver) {
    for (const Edge &e : graph[ver]) {
      if (e.dst == par) continue;
      if (dist[e.dst] == INF) {
        dist[e.dst] = dist[ver] + 1;
        c[e.dst] = e.cost - c[ver];
        if (dist[e.dst] & 1) {
          chmin(ub, c[e.dst] - 1);
        } else {
          chmax(lb, -c[e.dst] + 1);
        }
        dfs(ver, e.dst);
      } else if (dist[ver] % 2 != dist[e.dst] % 2) {
        if (c[ver] + c[e.dst] != e.cost) {
          cout << "0\n";
          exit(0);
        }
      } else {
        ll now = e.cost - (c[ver] + c[e.dst]);
        if (abs(now) & 1) {
          cout << "0\n";
          exit(0);
        }
        now /= dist[ver] & 1 ? -2 : 2;
        if (now <= 0) {
          cout << "0\n";
          exit(0);
        }
        if (fixed) {
          if (ans != now) {
            cout << "0\n";
            exit(0);
          }
        } else {
          ans = now;
          fixed = true;
        }
      }
    }
  };
  dfs(-1, 0);
  if (fixed) {
    cout << (lb <= ans && ans <= ub ? "1\n" : "0\n");
  } else {
    cout << max(ub - lb + 1, 0LL) << '\n';
  }
  return 0;
}


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

const int maxn =1e5+5;
int h[maxn];

int book[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int N,K;cin>>N>>K;
    for(int i=1;i<=N;i++) cin>>h[i];
    for(int i=0;i<K;i++)
    {
        int a,b;
        cin>>a>>b;
        if(h[a]>h[b])
        {
            if(book[a]!=-1)
                book[a]=1;
            book[b]=-1;
        }
        else if(h[a]<h[b])
        {
            book[a]=-1;
            if(book[b]!=-1)
                book[b]=1;
        }
        else
        {
            book[a]=-1;
            book[b]=-1;
        }
    }
    int sum=0;
    for(int i=1;i<=N;i++)
        if(book[i]==1||book[i]==0) sum++;
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 4436
package main

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

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

func oneInt64() int64 {
	var a int64
	fmt.Scan(&a)
	return a
}

func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

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

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func permutation(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
		}
	} else if k > n {
		v = 0
	}
	return v
}

func factorial(n int) int {
	return permutation(n, n-1)
}

func combination(n int, k int) int {
	return permutation(n, k) / factorial(k)
}

func homogeneous(n int, k int) int {
	return combination(n+k-1, k)
}

type key struct {
	w uint
	v uint
}

type dpKey struct {
	i int
	w uint
}

var table map[int]key
var dp [][]uint

func main() {
	N := oneInt()
	W := uint(oneInt())

	table = make(map[int]key)
	dp = make([][]uint, N+1)
	for index := 0; index <= N; index++ {
		dp[index] = make([]uint, 110000)
	}

	for index := 0; index < N; index++ {
		table[index] = key{uint(oneInt()), uint(oneInt())}
	}

	for index := 0; index < N; index++ {
		var windex uint
		for windex = 0; windex <= W; windex++ {
			if table[index].w <= windex { // 対象の荷物が入るかチェック
				temp := table[index].v + dp[index][windex- table[index].w] 
				chmax(&dp[index+1][windex], temp)
			} //入るなら入れてみて、余った空間に入る最大の勝ちのものをDPテーブルから持ってくる
			chmax(&dp[index+1][windex], dp[index][windex])
		}
	}
	fmt.Print(dp[N][W])
}

func chmax(a *uint, b uint) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}


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

signed main(void)
{
	int l, r, d, cnt;
	cin >> l >> r >> d;
	cnt = 0;
	for (int i = l; i <= r; i++)
	{
		if (i % d == 0)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3596