akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std ;



int main(){
    char S[16];

    cin >> S;

    int o_count = 0;
    int x_count = 0;

    for(int i=0;!(S[i]=='\0');i++){
        
        if(S[i]=='x'){
            x_count++;
        }

        if(S[i]=='o'){
            o_count++;
        }
        
    }

    if((15-x_count)>=8){
        cout << "YES" << endl;
    }

    else{
        cout << "NO" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

int main(void){
    int n;
    while(cin>>n,n){
        int w,h;
        cin>>w>>h;
        vector<valarray<int>> f(h+1,valarray<int>(0,w+1));
        rep(i,n){
            int x,y; cin>>x>>y;
            f[y][x]=1;
        }
        rep(i,h+1) partial_sum(begin(f[i]),end(f[i]),begin(f[i]));
        rep(i,h) f[i+1]+=f[i];
        int s,t,ans=0;
        cin>>s>>t;
        for(int y=t;y<=h;y++){
            for(int x=s;x<=w;x++){
                ans=max(ans, f[y][x]-f[y-t][x]-f[y][x-s]+f[y-t][x-s]);
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3124
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    REP(i, 3){
        if(s[i] == t[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;

#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define F0R(i, a) for(ll i = 0; i < a; i++)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //

int main() {
  ios:: sync_with_stdio(0);
  cin.tie(0);
  int k;
  cin >> k;
  if (k%7 == 0) k/=7;
  if (__gcd(10, k) != 1) cout << "-1" << "\n";
  else {
    int count = 1;
    int a = (1%k);
    while(a != 0){
      a = (10 * a + 1) % k;
      count++;
    }
    cout << count << "\n";
  }

  return 0;
}


Measured memory_bytes: 3648
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
max = 0
for i in range(1,2 ** 10):
    tmp = 0
    for j in range(N):
        count = 0
        for k in range(10):
            if (1 & i>>k) and (F[j][k] == 1):
                count += 1
        tmp += P[j][count]
    if i == 1:
        max = tmp
        continue
    if max < tmp:
        max = tmp
print(max)

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

using namespace std;
typedef long long int ll;
    
int main()
{
    int N;
    cin >> N;

    int ans = 0;
    ans = ceil(N / 2.0);
    cout << ans << endl;
}


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

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	long long N, ans = 1e14;
	scanf("%lld", &N);
	for(long long i = 1; i * i <= N; i++)
		if(N % i == 0) {
			long long j = N / i;
			ans = min(ans, i + j - 2);
		}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	while (true)
	{
                cin>>a>>b;
		if(a==0 && b==0)break;
		if(a>b) cout<<b<<" "<<a<<endl;
		else cout<<a<<" "<<b<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<std::unordered_map<int,int>> vvi;

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

bool sol(int n, int x, vvi& dp, std::vector<int>& l){
  if ( n == 0 && x == l[0] ) return true;
  if ( n == 0 && x != l[0] ) return false;
  if ( dp[n].count(x) != 0 ) return dp[n][x];
  return dp[n][x] = ( sol(n-1, x-l[n], dp, l) || sol(n-1, x+l[n], dp, l) );
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string s; std::cin >> s;
  int x, y; std::cin >> x >> y;
  
  std::vector<int> Lx(1), Ly(1);
  bool isx = true;
  rep(i,sz(s)){
    if ( s[i] == 'F' ) {
      if( isx ) Lx[sz(Lx)-1]++;
      else Ly[sz(Ly)-1]++;
    }
    else {
      isx = !isx;
      if(isx) Lx.push_back(0);
      else Ly.push_back(0);
    }
  }
  
  // A +- B +- C +- D +- E ... de suuzi tukureruka
  vvi dpx(sz(Lx)), dpy(sz(Ly));
  if ( sol(sz(Lx)-1, x, dpx, Lx) && sol(sz(Ly)-1, y, dpy, Ly) ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 155392
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <fstream>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef vector<PI> VPI;
typedef unsigned long long ull;
typedef long long ll;

#define FOR(i, n) for(int i=0;i<(n);++i)
#define REP(i,s,n) for(int i=s;i<=n;++i)
#define SZ(x) ((int)(x).size())
#define LOOP(i,x) FOR(i,SZ(x))
#define IT(it,x) for(typeof((x).begin()) it = (x).begin();it!=(x).end();++it)
#define ALL(x) (x).begin(), (x).end()
#define ST first
#define ND second
#define MP make_pair
#define PB push_back
#define gc getchar

const int INF = 1e9 + 5;
/*
map<pair<int, int>, string> memo;

string lcs(string &a, string &b, int i, int j, string cur) {
	if (i == a.length() || j == b.length()) return cur;
	if (memo.count({i, j})) return memo[{i, j}];
	//cout << i << " " << j << endl;
	if (a[i] == b[j]) return lcs(a, b, i + 1, j + 1, cur + a[i]);
	string c1 = lcs(a, b, i, j + 1, cur);
	string c2 = lcs(a, b, i + 1, j, cur);
	memo[{i, j}] = c1.length() >= c2.length() ? c1 : c2;
	return memo[{i, j}];
} */

void max_self(pair<int, pair<int, int>> &a, pair<int, pair<int, int>> b) {
	a = max(a, b);
}

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

	string s, t;
	cin >> s >> t;

	int slen = s.length();
	int tlen = t.length();

	vector<vector<pair<int, pair<int, int>>>> dp(
		slen + 1,
		vector<pair<int, pair<int, int>>>(tlen + 1, {-INF, {0, 0}}));
	dp[0][0] = {0, {0, 0}};

	for (int i = 0; i < slen; i++) {
		for (int j = 0; j < tlen; j++) {
			if (s[i] == t[j]) {
				max_self(dp[i + 1][j + 1], {dp[i][j].first + 1, {i, j}});
			}

			max_self(dp[i + 1][j], {dp[i][j].first, {i, j}});
			max_self(dp[i][j + 1], {dp[i][j].first, {i, j}});
		}
	}

	//cout << lcs(s, t, 0, 0, "") << endl;

	pair<int, pair<int, int>> anspair = {0, {0, 0}};

	for (int i = 0; i <= slen; i++) {
		for (int j = 0; j <= tlen; j++) {
			max_self(anspair, {dp[i][j].first, {i, j}});
		}
	}

	//cout << ":::" << anspair.second.first << " " << anspair.second.second  << endl;

	pair<int, int> cur = anspair.second;
	string ans = "";
	while(true) {
		int x = cur.first;
		int y = cur.second;
		if (x == 0 || y == 0) break;
		pair<int, int> prev = dp[x][y].second;

		if (prev == make_pair(x - 1, y - 1)) {
			assert(s[x - 1] == t[y - 1]);
			//cout << x << " " << y << endl;
			ans += s[x - 1];
		}

		cur = prev;
	}

	reverse(ans.begin(), ans.end());
	
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main(void) {
  int K, A, B;
  cin >> K >> A >> B;

  for (int i = A; i <= B; i++) {
    if (i%K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 3632
//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1


int n;


int main()
{
	cin >> n;
	int x = n;
	int a=0, b=0;
	REP(i, 8)
	{
		a = n % 10;
		n = (n-a)/10;
		b += a;
		if(n == 0) break;
	}
	
	if(x % b ==0) cout << "Yes";
	else cout << "No";
	cout << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	int n,m,i,j,x,y;
	string a[55],b[55];
	bool flag,ans=false;
	cin >> n >> m;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=0; i<m; ++i){
		cin >> b[i];
	}
	for(i=(n-m); i>=0; --i){
		for(j=(n-m); j>=0; --j){
			flag = true;
			for(x=0; x<m; ++x){
				for(y=0; y<m; ++y){
					if(a[i+x][j+y]!=b[x][y]){
						flag = false;
						break;
					}
				}
				if(!flag){
					break;
				}
			}
			if(flag){
				ans = true;
				break;
			}
		}
		if(ans){
			break;
		}
	}
	cout << ((ans)?"Yes":"No") << endl;
	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int x,t;
    cin>>x>>t;
    cout<<max(0,x-t)<<endl;
    return 0;
}


Measured memory_bytes: 384
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)



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

      int ctr=n;

      rep(i,0,n+1)
      {
            int l=0,x=i,y=n-i;

            while(x>0)
            l+=x%6,x/=6;

            while(y)
            l+=y%9,y/=9;

              ctr=min(ctr,l);
      }

      prin(ctr);
}

Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int d = 0;
		for (int i = 1; i * a <= b; i++) {
			d = i;
			if (i == c) {
				break;
			}

		}
		System.out.println(d);

	}

}


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

int main(){
  int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  k--;
  
  cout<<a[k]<<endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0;n > i;i++)
    cin >> a[i];
  for (int i = n - 1;i >= 0;i--) {
    if (a[i] < a[i-1] && a[i] == a[i-1] - 1)
      a[i-1]--;
    if (a[i] < a[i-1] && a[i] != a[i-1] -1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
      

Measured memory_bytes: 640
N,x=map(int,input().split())
a=list(map(int,input().split()))
b=a.copy()
if a[0]>x:
    a[0]=x
for i in range(N-1):
    s=a[i]+a[i+1]
    d=s-x
    if d>0:
        if a[i+1]>=d:
            a[i+1]-=d
        else:
            a[i+1]=0
            a[i]=x
ans=0
for z in zip(a,b):
    ans+=z[1]-z[0]
print(ans)


Measured memory_bytes: 14252
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

bool isprime(ll N){
  if(N==1){
    return 0;
  }
  if(N==2 || N==3){
    return 1;
  }
  Rep(i,2,sqrt(N)+1){
    if(N%i==0){
      return 0;
    }
  }
  return 1;
}

int main(){
  ll X;
  cin >> X;
  while(1){
    if (isprime(X)){
      cout << X << endl;
      return 0;
    }
    X++;
  }
}

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

int main() {
	vector<vector<int>>c(3, vector<int>(3, 0));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}

	int a[3], b[3];
	a[0] = 0;
	for (int i = 0; i < 3; i++) {
		if (i)a[i] = c[i][0] - b[0];
		b[i] = c[i][i] - a[i];
	}

	bool match = true;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (c[i][j] != a[i] + b[j])match = false;
		}
	}
	cout << (match ? "Yes" : "No") << endl;

	return 0;
}

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

typedef long long ll;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x * f;
}

const int MAXN = 100010;
int n, K, a[MAXN];
ll b[MAXN], ans;

int main() {

	n = read(), K = read();
	for(int i = 1; i <= n; i++) {
		a[i] = read(), b[i] = read();
		if((a[i]&K) == a[i]) ans += b[i];
	}

	for(int i = 29; i >= 0; i--) {
		if(!((K>>i)&1)) continue;
		ll res = 0;
		for(int j = 1; j <= n; j++) {
			if(!((a[j]>>i)&1)) {
				if(((a[j]>>i)&(K>>i)) == (a[j]>>i)) res += b[j];
			}
		}
		ans = max(ans, res);
	}
	cout << ans << endl;
	//printf("%lld\n", ans);
	return 0;
}


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

int main(){
	int x,y;
	cin >> x >> y;
	while(x!=0||y!=0){
		if(x>y){
			swap(x,y);
		}
		cout << x <<' '<< y << endl;
		cin >> x >> y;
	}
	return 0;
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;
ll d[1000005] = {0};

int main (){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C;
    ll ans = 0;
    cin >> A >> B;

    if (A == 1 && B == 1){
        cout << 1 << endl;
    } else {
        REP(i, 2, 1000001){
            if (A % i == 0){
                d[i] = 1;
            }
            while (A % i == 0)
            {
                A /= i;

            }
        }

        REP(i, 2, 1000001){
            if (B % i == 0 && d[i] == 1){
                ans++;
            }
            while (B % i == 0)
            {
                B /= i;

            }
        }
        if ( A != 1 && B != 1 && A == B){
            ans += 1;
        }
        cout << ans + 1 << endl;
    }



}

Measured memory_bytes: 2304
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N,M,K = I()
for i in range(N+1):
    for j in range(M+1):
        if i*(M-j)+j*(N-i) == K:
            print("Yes")
            sys.exit()

print("No")


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

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[1 << 18];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N;
	cin >> N;
	int n = (1 << N);
	int S[1 << 18];
	rep(i, (1 << N)) {
		cin >> S[i];
	}
	pakuri_sort(n, S);
	int A[1 << 17];
	A[0] = S[n - 1];
	int OK = 1;
	rep(i, N - 1) {
		int p = n - (1 << i);
		for (int j = (1 << i) - 1; j >= 0; j--) {
			while (p >= 0 && S[p] >= A[j]) p--;
			if (p < 0) {
				OK = 0;
				break;
			}
			A[j + (1 << i)] = S[p];
			S[p] = 1e9;
			p--;
		}
		if (!OK) break;
		pakuri_sort(n - (1 << i), S);
		pakuri_sort(1 << (i + 1), A);
	}
	int i = N - 1;
	int p = n - (1 << i);
	for (int j = (1 << i) - 1; j >= 0; j--) {
		while (p >= 0 && S[p] >= A[j]) p--;
		if (p < 0) {
			OK = 0;
			break;
		}
		S[p] = 1e9;
		p--;
	}

	if (OK) co("Yes");
	else co("No");

	Would you please return 0;
}

Measured memory_bytes: 2816
h, w = map(int, input().split())
G = [list(input()) for _ in range(h)]
flg = True
for i in range(h):
    for j in range(w):
        if G[i][j] == "#":
            count = 1
            for u, v in ((0, 1), (1, 0), (-1, 0), (0, -1)):
                y, x = i + u, j + v
                if 0 <= x < w and 0 <= y < h:
                    # print(i, j, G[y][x])
                    if G[y][x] == "#":
                        count += 1
            if count < 2:
                flg = False
                break
    if not flg:
        break

print("Yes" if flg else "No")

Measured memory_bytes: 9156
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	getline(cin,s);
	for(int i=0;i<s.size()-4;i++){
		if(s.substr(i,5)=="apple"){
			s[i] = 'p';
			s[i+1] = 'e';
			s[i+2] = 'a';
			s[i+3] = 'c';
			s[i+4] = 'h';
		}
		else if(s.substr(i,5)=="peach"){
			s[i] = 'a';
			s[i+1] = 'p';
			s[i+2] = 'p';
			s[i+3] = 'l';
			s[i+4] = 'e';
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 1188
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>
 
using namespace std;
 
int N;
vector<long long> v;
vector<vector<long long>> dp; 
long long LIM = std::numeric_limits<long long>::min();
 
long long deque(long long i, long long j)
{
  long long c = (N - (j + 1 - i)) % 2 == 0 ? 1 : -1; 
 
  if (i == j) return v[i] * c;
  if (dp[i+1][j] == LIM) dp[i+1][j] = deque(i+1, j); 
  if (dp[i][j-1] == LIM) dp[i][j-1] = deque(i, j-1);
 
  long long a = v[i]*c + dp[i+1][j];
  long long b = v[j]*c + dp[i][j-1];
 
  dp[i][j] = c < 0 ? min(a, b) : max(a, b); 
  return dp[i][j];
}
 
int main()
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
 
  std::cin >> N;
  v.resize(N);
  dp = vector<vector<long long>>(N+1, vector<long long>(N+1, LIM));
 
  for (int i = 0; i < N; ++i)
  {
    long long val;
    cin >> val;
    v[i] = val;
  }
 
  std::cout << deque(0, N-1);
 
  return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() { 
  int n,t;
  cin >> n >> t;
  vl a(n);
  rep(i,n){
    cin>>a[i];
  }
  map<ll,int>mp;

  ll mi = a[0],mx =0;
  srep(i,1,n){
    ll d = a[i] - mi;
    mins(mi,a[i]);
    maxs(mx,d);
    if(d>=0)mp[d]++;
  }
  cout<<mp[mx]<<endl;
  return 0;
}

Measured memory_bytes: 7296
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int N, K, ans = 0;
	cin >> N >> K;

	while (N > 0)
	{
		N = N / K;
		ans++;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int main() {
	int N, Q; cin >> N >> Q;
	vector<pair<int, i_i> > p;
	while (Q--) {
		int a, b, c; scanf("%d%d%d", &a, &b, &c);
		p.pb(make_pair(c, i_i(a, b)));
		p.pb(make_pair(c + 1, i_i(a + 1, b)));
	}
	sort(p.begin(), p.end());
	Q = p.size();
	int k = 0;
	union_find uf(N);
	ll ans = 0;
	vector<i_i> E1, E2;
	for (int c = p[0].first; uf.size(0) < N; c++) {
		for (; k < Q && p[k].first == c; k++)
			E1.pb(i_i(p[k].second));
		vector<i_i> _E;
		for (i_i e: E1) {
			if (uf.same(e.first % N, e.second % N)) continue;
			uf.unite(e.first % N, e.second % N);
			ans += c;
			e.first++; e.second++;
			_E.pb(e);
		}
		E1 = _E;
		swap(E1, E2);
	}
	cout << ans << endl;
}


Measured memory_bytes: 10860
#include <stdio.h>
int main(void){

  int a=0,b=0,c=0;

  scanf("%d %d %d",&a,&b,&c);

  if(a!=b && a != c && b != c){
    printf("No\n");
  }
  else if(a==b && a == c && b == c){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }
  return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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 (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    vector<int> A(N),B(N),C(N);
    rep(i,N){
        cin >> A[i];
        A[i]--;
    }
    rep(i,N) cin >> B[i];
    rep(i,N-1) cin >> C[i];
    
    //-----------------------------------
    int ans=0,bef=-3;
    rep(i,N){
        ans+=B[A[i]];
        if(bef+1==A[i])ans+=C[bef];
        bef=A[i];
    }


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

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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

#define dodebug(i, n, arr)	for(int i=0;i<n;++i)	cout<<arr[i]<<" ("<<i<<")\n";

ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

	int n;
	cin>>n;
	vector<double> dp(n+1, 0);

	dp[0] = 1;

	double p;
	for(int i=0;i<n;++i){
		cin>>p;
		for(int j=i+1;j>0;--j)	dp[j] = p*dp[j-1] + (1-p)*dp[j];
		dp[0] = (1-p)*dp[0];
	}
	double ans = 0;
	for(int i=n;i>n/2;--i)	ans += dp[i];

	cout<<setprecision(11)<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int s, w;
	cin >> s >> w;
	if (s <= w)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;

	return 0;
}

Measured memory_bytes: 3132
n = gets.to_i
spots = gets.split.map(&:to_i)

spots.unshift 0
spots.push 0

distances = spots.each_cons(2).map { |a, b| (a - b).abs }
sum = distances.sum

answers = (0...n).map { |i|
  sum - (distances[i] + distances[i + 1]) + (spots[i] - spots[i + 2]).abs
}

puts answers


Measured memory_bytes: 23224
// https://atcoder.jp/contests/abc074/tasks/arc083_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

const int INF = 1e15;

bool ng[301][301];

template <typename T> using Matrix = vector<vector<T>>;
template <typename T> void warshall_floyd(Matrix<T> &g, T = INF) {
    REP(k, g.size()) REP(i, g.size()) REP(j, g.size()) {
        if (g[i][k] == INF || g[k][j] == INF)
            continue;
        if (g[i][j] == g[i][k] + g[k][j] && i != k && k != j) {
            // 迂回して距離が同じなら、道路を作らない
            ng[i][j] = true;
        }
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    Matrix<int> g(N, vector<int>(N, INF));
    REP(i, N) REP(j, N) { cin >> g[i][j]; }
    auto cp = g;
    // 全点対間最短路(Warshall-Floyd)
    warshall_floyd(g);
    // 距離が変わらなければ最短経路
    if (cp == g) {
        int ans = 0;
        REP(i, N) FOR(j, i + 1, N) {
            if (!ng[i][j]) {
                ans += g[i][j];
            }
        }
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 4768
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z')
        cout << "A";
    else
        cout << "a";

    return 0;
}

Measured memory_bytes: 3032
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<iostream>
//#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
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 chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	string S, T;
	cin >> S >> T;
	int N = S.size();
	int M = T.size();

	short dp[3001][3001];
	dp[0][0] = 0;
	rep1(i, N) dp[i][0] = 0;
	rep1(j, M) dp[0][j] = 0;
	rep(i, N) {
		rep(j, M) {
			if (S[i] == T[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
			else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
		}
	}
	char kotae[3000];
	int k = dp[N][M];
	int i = N, j = M;
	while (k > 0) {
		while (i > 0 && dp[i - 1][j] == dp[i][j]) i--;
		while (j > 0 && dp[i][j - 1] == dp[i][j]) j--;
		i--;
		j--;
		kotae[--k] = S[i];
	}
	fwrite(kotae, 1, dp[N][M], stdout);

	Would you please return 0;
}

Measured memory_bytes: 17920
#include<bits/stdc++.h>
#define ii pair<int,int>

using namespace std;

int main(){
    int n;cin>>n;
    vector<ii>a(n);
    for(int i = 0;i <n;i++){
        cin>>a[i].first;
        a[i].second = i;
    }
    sort(a.begin(),a.end());
    for(int i = 0;i <n;i++){
        if(a[n-1].second!=i){
            cout<<a[n-1].first;
        }
        else{
            cout<<a[n-2].first;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3200
#![allow(dead_code, unused_imports, non_snake_case)]

use std::io::*;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::str::FromStr;

const MOD: i32 = 1_000_000_007;

fn main() {
    let mut n: i64 = input();
    let mut v: Vec<char> = Vec::new();
    let mut i: u32 = 1;
    if n == 0 {
        println!("0");
        return;
    }
    loop {
        if n.abs() % 2i64.pow(i) == 0 {
            v.push('0');
        } else {
            v.push('1');
            n -= (-2 as i64).pow(i-1);
        }
        i += 1;
        if n == 0 { break; }
    }
    println!("{}", v.into_iter().rev().collect::<String>());
}

trait Read {
    fn read(s: &str) -> Self;
}

fn input<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl {
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}

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

using namespace std;

bool check(int n){
  string s;
  for(int i=0; n; i++){
    int x = n % 10;
    s += x + '0';
    n /= 10;
  }
  return (s[0] == s[4] && s[1] == s[3]);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for(int i=a; i<=b; i++) if(check(i)) ans++;
  cout << ans << endl;
  return 0;
}


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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    int n;
    cin >> n;
    vector<bool> c(n - 1);
    int last = -1;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (i > 0 && x == last + 1) {
            c[last - 1] = 1;
        }
        last = x;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        ans += x;
    }
    for (int i = 0; i < n - 1; ++i) {
        int x;
        cin >> x;
        if (c[i]) {
            ans += x;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vll = vector<ll>;
using vvll = vector<vll>;

int main()
{
  int H, W,white=0;
  cin >> H >> W;
  vvc s(H, vc(W));
  rep(i,H)
  {
    rep(j,W)
    {
      cin >> s[i][j];
      if(s[i][j]=='.')
        white++;
    }
  }
  int inf = 100000000;
  vvi checked(H, vi(W, inf));
  int sx = 0, sy = 0, gx = H - 1, gy = W - 1;
  queue<PAIR> que;
  que.push(PAIR(sx, sy));
  checked[sx][sy] = 0;
  while(que.size())
  {
    PAIR p = que.front();
    que.pop();

    if(p.first==gx&&p.second==gy)
      break;

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

    rep(i,4)
    {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if(0<=nx&&nx<H&&0<=ny&&ny<W&&checked[nx][ny]==inf&&s[nx][ny]=='.')
        {
          checked[nx][ny] = checked[p.first][p.second] + 1;
          que.push(PAIR(nx, ny));
        }
    }
  }

  if(checked[gx][gy]==inf)
    cout << -1 << endl;
    else
    {
      cout << white - (checked[gx][gy] + 1) << endl;
    }

}


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

using namespace std;

vector<char> getAnd(const vector<char> v1,const vector<char> v2){
    int cnt1=0,cnt2=0;
    vector<char> res;
    while(cnt1<v1.size() && cnt2<v2.size()){
        if(v1[cnt1]==v2[cnt2]){
            res.push_back(v1[cnt1]);
            cnt1++;
            cnt2++;
        }else if(v1[cnt1]>v2[cnt2]){
            cnt2++;
        }else{
            cnt1++;
        }
    }
    res.push_back(0);
    return res;
}

int main() {
    int n,cnt;
    vector<vector<char> > vvc;
    
    string buf;
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        cin >> buf;
        vector<char> vc;
        for(int j=0;j<buf.size();j++)
            vc.push_back(buf[j]);
        vvc.push_back(vc);
    }

    for(int i=0;i<n;i++){
        sort(vvc[i].begin(),vvc[i].end());
    }
        

    vector<char> res;
    if(n!=1){
        res = getAnd(vvc[0],vvc[1]);
        for(int i=2;i<n;i++){
            res = getAnd(res,vvc[i]);
        }
    }else{
        for(int i=0;i<vvc[0].size();i++)
            res.push_back(vvc[0][i]);
            res.push_back(0);
    }

    for(int i=0;i<res.size();i++){
        if(res[i]!=0)
            printf("%c",res[i]);
    }
    
    
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  string S, T;
  cin >> S >> T;
  ll A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if (U == S) A--;
  else B--;
  cout << A << " " << B << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    while(1){
        string s=to_string(n);
        unordered_set<char>st(all(s));
        if(int(st.size())==1){
            return cout<<n,0;
        }
        ++n;
    }
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c){
    cout<<1<<endl;
  }
  else if(a==b||b==c||c==a){
    cout<<2<<endl;
  }
  else{
    cout<<3<<endl;
  }
}

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


int main() {
    string S;
    cin >> S;
    bool ans = true;
    for (int i = 0; i < S.size(); i++) {
        if ((i+1)%2 == 1) {
            if (S.at(i) == 'L') ans = false;
        } else {
            if (S.at(i) == 'R') ans = false;
        }
    }

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

}

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

int main()
{
	ll n,c;
	cin >> n >> c;
	vector<pair<ll,ll>> xy(n);
	for(int i = 0;i<n;i++)cin >> xy[i].first >> xy[i].second;
	vector<pair<ll,ll>> yx(n);
	for(int i = 0;i<n;i++)yx[i] = pair<ll,ll>(c-xy[i].first,xy[i].second);
	reverse(yx.begin(),yx.end());
	vector<ll> lv(n);//右にどれだけとって戻ってきたか
	lv[0] = yx[0].second ;
	for(int i = 1;i<n;i++)
	{
		lv[i] = lv[i-1] + yx[i].second;
	}
	for(int i =0;i<n;i++)lv[i] -= yx[i].first*2;
	//for(int i = 0;i<n;i++)cout << lv[i] << endl;
	vector<ll> rmx(n);//右にiまで行けるときの最大値
	vector<ll> rsum(n);
	rsum[0] = xy[0].second;
	for(int i = 1;i<n;i++)rsum[i] += rsum[i-1] + xy[i].second;
	rmx[0] = max(0LL,rsum[0]-xy[0].first);

	for(int i = 1;i<n;i++)rmx[i] = max(rmx[i-1],rsum[i]-xy[i].first);
	ll ans = rmx.back();
	for(int i = 0;i<n-1;i++)
	{
		ll now = lv[i] + rmx[n-2-i];
		ans = max(ans,now);
		//cout << now << endl;
	}
	
	vector<ll>rv(n);
	rv[0] = xy[0].second;
	for(int i= 1;i<n;i++)rv[i] = rv[i-1] + xy[i].second;
	for(int i = 0;i<n;i++)rv[i] -= xy[i].first*2;
	vector<ll> lmx(n),lsum(n);
	lsum[0] = yx[0].second;
	for(int i = 1;i<n;i++)lsum[i] += lsum[i-1] + yx[i].second;
	lmx[0] = max(0LL,lsum[0]-yx[0].first);
	for(int i = 1;i<n;i++)lmx[i] = max(lmx[i-1],lsum[i]-yx[i].first);
	ans = max( ans,lmx.back());
	for(int i = 0;i<n-1;i++)
	{
		ll now = rv[i] + lmx[n-2-i];
		ans = max(ans,now);
		//cout << now << endl;
	}


	cout << ans << endl;



	
}


Measured memory_bytes: 11164
X,N = map(int,input().split())
if N != 0:
  p = input().split()

for i in range(N):
    p[i] = int(p[i])
    
if N == 0:
    print(X)
else:    
    for i in range(2*N):
        if not (X-i) in p:
            print(X-i)
            break
        elif not (X+i) in p:
            print(X+i)
            break
        else:
          continue

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

int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("input.txt","r",stdin);
// #endif
    string s;
    cin>>s;
    if(s=="Sunny")cout<<"Cloudy"<<endl;
    if(s=="Cloudy")cout<<"Rainy"<<endl;
    if(s=="Rainy")cout<<"Sunny"<<endl;    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[101];
int n, x, c, s, k;

int main()
{
  cin >> n >> x;
  k = 1;
  for(int i=1;i<=n;i++)
  {
    cin >> c;
    s += c;
    if (s > x)
    {
      cout << k;
      return 0;
    }
    k += 1;
  }
  cout << k;
  return 0;
}


Measured memory_bytes: 256