akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc010.contest.atcoder.jp/tasks/agc010_b>
問題文============================================================
 N 個の箱が円環状に並んでおり、i 番目の箱には Ai 個の石が入っています。
 
 以下の操作を繰り返して、全ての石を取り除くことができるか判定してください。
 
 箱を一か所選ぶ。それを i 番目としたとき、1 から N の各 j に対して、i+j 番目の箱から石をちょうど j 個取り除く。
 ただし、N+k 番目と表される箱は k 番目の箱と同一視するものとする。
 各操作において、取り除きたい個数の石がない箱があるときは、その操作を行えないことに注意してください
=================================================================

解説=============================================================

 操作回数 k = (石の総和) / (N*(N+1)/2) でわかる
 
 ここで
 d[i] = Ai+1 - Ai
 とすると
 
 一回の操作で d[i] は　一箇所だけ +(n-1)され　その他は (-1) される。
 ここで問題は d[i] を k回操作を行うことによって　全て 0 にできるかどうかということになる
 
 操作に関して、もっと簡単にすると
 
 d[i]をk回全て一様に -1 にして、その後　k回の操作毎に 1つ選んで+N すると言い換えることができるので
 条件として
 
 d[i] - k が 負であり　N の倍数　となることが必要十分となる
 =============================================================
*/
string solve(){
    ll N; cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    for(auto &in:A){ cin >> in; sum += in; }
    if(sum%(N*(N+1)/2) != 0) return "NO";
    ll k = sum / (N*(N+1)/2);
    for(int i = 0; i < N;i++){
        ll d = A[(i+1)%N] - A[i];
        if(d - k > 0 || abs(d-k)%N != 0) return "NO";
    }
    return "YES";
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int H,W;
  int i,j;
  while(1)
    {
      scanf("%d %d",&H,&W);
      if (H == 0 && W == 0)break;
      for(j = 0; j < H;j++)
        {
          for (i = 0; i < W; i++)
            {
              if((i+j)%2 == 0)printf("#");
              else if((i+j)%2 == 1)printf(".");
              if(i == W-1)printf("\n");
            }
        }
      printf("\n");
    }
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
 
int main() {
    int n;
    cin>>n;
    int ans=false;

    rep(i,10)   rep(j,10) {
        if(i*j==n)  ans=true;
    }

    if(ans==true)   puts("Yes");
    else    puts("No");
    
 return 0;
}

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



int main()
{
    //freopen("input.txt", "r", stdin);


    ll x;
    cin >> x;
    ll sum = 0;
    ll i = 0;
    while (sum < x)
    {
        i++;
        sum += i;
    }

    cout << i;


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	int n, m; scanf("%d%d", &n, &m);
	std::vector<std::vector<int>> g(n);
	std::vector<int> a(m), b(m);
	for(int i = 0; i < m; i++) {
		scanf("%d%d", &a[i], &b[i]);
		a[i]--; b[i]--;

		g[a[i]].push_back(i);
		g[b[i]].push_back(i);
	}

	std::vector<bool> used(n);
	auto dfs = [&](auto&& dfs, int v) {
		if(used[v]) return 0;
		used[v] = true;

		int ret = 1;
		for(int id: g[v]) {
			int to = a[id] ^ b[id] ^ v;
			ret += dfs(dfs, to);
		}
		return ret;
	};

	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(used[i]) continue;

		ans = std::max(ans, dfs(dfs, i));
	}

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


Measured memory_bytes: 28244
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    vector<int> ans(5, 0);
    for(int i=1; i<n-1; ++i){
        if(a[i] == a[i-1] || a[i] != a[i+1])
            continue;
        int j = i;
        while(j < n && a[i] == a[j])
            ++ j;
        if(j == n)
            continue;

        if(a[i-1] < a[i] && a[j-1] > a[j])
            ++ ans[0];
        if(a[i-1] > a[i] && a[j-1] < a[j])
            ++ ans[1];
        if(a[i-1] < a[i] && a[j-1] < a[j])
            ++ ans[2];
        if(a[i-1] > a[i] && a[j-1] > a[j])
            ++ ans[2];
    }
    for(int i=1; i<n-1; ++i){
        if(a[i-1] < a[i] && a[i] > a[i+1])
            ++ ans[3];
        if(a[i-1] > a[i] && a[i] < a[i+1])
            ++ ans[4];
    }

    cout << ans[0];
    for(int i=1; i<5; ++i)
        cout << ' ' << ans[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 1524
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)

#define mp make_pair
#define P pair<int,int>
#define ll __int64
int t[100];
int main(){
	rep(i,6)cin>>t[i];
	sort(t,t+4);
	sort(t+4,t+6);
	cout<<t[1]+t[2]+t[3]+t[5]<<endl;
	
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int a,z;
  for(int i = 0; true; i++){
    if(s.at(i) == 'A'){
      a = i + 1;
      break;
    }
  }
  for(int i = s.size() - 1; true; i--){
    if(s.at(i) == 'Z'){
      z = i + 1;
      break;
    }
  }
  cout << z - a + 1 << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <time.h>
void insertionSort(int *p,int n);
int main ()
{
    int number,*p,i;
    scanf("%d",&number);
    p = (int *)malloc(number*sizeof(int));
    for(i = 0; i < number ; i++)
    {
        scanf("%d",&p[i]);
    }
    for(i = 0;i < number;i++)
    {
        if(i>0)
        printf(" ");
        printf("%d",p[i]);
    }
    printf("\n");
    insertionSort(p,number);
    free(p);
    return 0;
}
void insertionSort(int *p,int n)
{
    int i,j,v;
    for(i = 1; i < n; i++)
    {
        v = p[i];
        for(j = i - 1; p[j] > v&&j > -1; j--)
        {
            p[j+1] = p[j];
        }
        p[j+1] = v;
        for(j = 0; j < n; j++)
        {
            if(j>0)
            printf(" ");
            printf("%d",*(p+j));
        }
        printf("\n");
    }
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)

ll N;
ll ans[505][505];
ll i, j,k, ans2;
int main(){
    scanf("%lld", &N);

    fornum(i,0,N){
        fornum(j,i+1,N){
            fornum(k,1,30){
                ll a = (1 << k) - 1;
                if((i&a)!=(j&a)){
                    if(k>ans2){
                        ans2 = k;
                    }
                    printf("%lld ", k);
                    break;
                }
            }
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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

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

    vector<ll> H(N);
    for(int i=0; i<N; i++) cin >> H[i];
    sort(H.begin(), H.end());
    ll min_h = 1e10;

    for(int i=0; i<N-K+1; i++) {
        min_h = min(min_h, abs(H[i] - H[i+K-1]));
    }
    cout << min_h << endl;
}

Measured memory_bytes: 4032
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def inpl(): return [int(i) for i in input().split()]
T = int(input())
for _ in range(T):
    A, B, C, D = inpl()
    if A < B or B > D:
        print('No')
        continue
    if C >= B:
        print('Yes')
        continue
    gcdbd = gcd(B, D)
    if (1+(C-A%B)//gcdbd)*gcdbd+A%B >= B:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <queue>
#include <vector>

using namespace std;

int main()
{
    double a,b,c;
    int n,i;
    priority_queue<double, vector<double>, greater<double>> que;
    cin >> n;
    for(i = 0; i < n; i++)
    {
        cin >> a >> b >> c;
        que.push(a);
        que.push(b);
        que.push(c);
        a = que.top();
        que.pop();
        b = que.top();
        que.pop();
        if(pow(que.top(), 2.0) == pow(a, 2.0) + pow(b, 2.0))
           cout << "YES" << endl;
        else
            cout << "NO" << endl;
        que.pop();
    }

    return 0;
}

Measured memory_bytes: 3176
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int r, g, b;
    cin >> r >> g >> b;

    if ((r * 100 + g * 10 + b) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
int main()
{
 int n,m,c,i,j,ans=0,count=0;
  scanf("%d%d%d",&n,&m,&c);
  int b[m],a[n][m];
  for(i=0;i<m;i++)
    scanf("%d",&b[i]);
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
    scanf("%d",&a[i][j]);
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      ans=ans+b[j]*a[i][j];
    }
    if((ans+c)>0)
      count++;
    ans=0;
  }
  printf("%d",count);
return 0; 
}

Measured memory_bytes: 128
N, M = map(int, input().split())
Hs = list(map(int, input().split()))

goods = [True] * N
for _ in range(M):
	A, B = map(int, input().split())
	A -= 1
	B -= 1
	HA = Hs[A]
	HB = Hs[B]
	if HA <= HB:
		goods[A] = False
	if HB <= HA:
		goods[B] = False

count = 0
for g in goods:
	if g:
		count += 1
print(count)



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

int main() {
  long n;
  cin >> n;
  long result = 0;
  if (n%2 != 0) {
    
    cout << result << endl;
    return 0;
  }
  n /= 2;
  
  while(n != 0) {
    n /= 5;
    result += n;
  }
  cout << result << endl;
}




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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

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

vector<ll> sieve(ll n){
  int p = 0;
  vector<bool> is_prime(n+1,true);
  vector<ll> res;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      res.push_back(i);
      for(int j=2*i;j<=n;j+=i){
        is_prime[j] = false;
      }
    }
  }
  return res;
}

vector<ll> divisor(ll n){
  vector<ll> list;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      list.push_back(i);
      if(n/i != i){
        list.push_back(n/i);
      }
    }
  }
  return list;
}

umap<int,int> prime_factor(ll n){
  umap<int,int> fac;
  for(int i=2;i*i<=n;i+=2){
    if(n%i == 0){
      int count = 0;
      while(n%i == 0){
        count++;
        n /= i;
      }
      fac[i] = count;
    }
  }
  if(n!=1)fac[n] = 1;
  return fac;
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;
  ll d;
  cin >> n >> d;
  ll x[n];
  ll y[n];
  int count = 0;
  REP(i,n){
    cin>>x[i]>>y[i];
    if(x[i]*x[i] + y[i]*y[i] <= d*d){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 6772
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
int H,W,K;
cin>> H;
cin>> W;
cin>> K;
int black;
int ans;
char c[10][10];

for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
		cin>> c[i][j];
	}
}
	for(int maskR =0;maskR<(1<<H)-1;maskR++){ //1<<H is 2^H which is the no.of.combinations that can be obtained for rows. 2^H -1 because the first combination is mapped to i=0. example one of the ith combination can be 0111 if there were 4 rows
		for(int maskC=0;maskC<(1<<W)-1;maskC++){ //example one of the jth combination can be 0001 if there were 4 columns 
				
		  black = 0; //for each new pair of combination a new chessboard is formed. So for each pair of combination black must be counted fresh (that is why it is refreshed to 0 inside this loop)
				for (int i =0; i< H;i++){
					for(int j=0;j< W; j++){
						if(((maskR >> i) & 1) == 0 && ((maskC >> j) & 1) == 0)
			            {
				            if(c[i][j] == '#')black++;
			            }
					}
				}	
				    if (black == K) 
					ans = ans + 1;
		
		
		}



	}

cout<< ans;









}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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;
}



int main() {
    ll n;
    cin >> n;
    vector<int> p(n), q(n);
    REP(i, n){
        cin >> p[i];
    }
    REP(i, n){
        cin >> q[i];
    }

    vector<int> first;
    FOR(i, 1, n + 1){
        first.push_back(i);
    }
    ll a, b;
    ll count = 0;
    do {
        count++;
        if(first == p) a = count;
        if(first == q) b = count;
    }
    while (next_permutation(first.begin(), first.end()));

    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int N = 5000;
const int K = 5000;
vector<int> a;
bool formableL[N+2][K];
bool formableR[N+2][K];
int n_, k;
int is_unnecessary(int i)
{
    vector<int> L; L.reserve(k);
    vector<int> R; R.reserve(k);
    for(int s = 0; s < k; s++)
    {
        if(formableL[i-1][s])
            L.push_back(s);
        if(formableR[i+1][s])
            R.push_back(s);
    }

    int ri = R.size()-1;
    for(int li = 0; li < L.size(); li++)
    {
        //find the smallest ri such that K-a[i] <= L[li]+R[ri]
        if(k-a[i] <= L[li]+R.back())
            for(; ri > 0; ri--)
                if(k-a[i] <= L[li]+R[ri] && !(k-a[i] <= L[li]+R[ri-1]))
                    break;
    
        if(k-a[i] <= L[li]+R[ri] && L[li]+R[ri] < k)
            return 0;
        //cout<<L[li]<<"+"<<R[ri]<<endl;
    }
    return 1;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n_ >> k;
    a.reserve(n_);
    a.push_back(0); //1-indexed elements
    for(int i = 0; i < n_; i++)
    {
        int x; cin >> x;
        if(x < k)
            a.push_back(x);
    }
    int n = a.size()-1;

    memset(formableL,0,sizeof formableL);
    memset(formableR,0,sizeof formableR);
    formableL[0][0] = 1;
    for(int i = 1; i <= n; i++)
        for(int s = 0; s < k; s++)
            if(formableL[i-1][s] || (a[i] <= s && formableL[i-1][s-a[i]]))
                formableL[i][s] = true;
    formableR[n+1][0] = 1;
    for(int i = n; i >= 1; i--)
        for(int s = 0; s < k; s++)
            if(formableR[i+1][s] || (a[i] <= s && formableR[i+1][s-a[i]]))
                formableR[i][s] = true;
    
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        //find the smallest sum of a subset w/out i such that
        // k-a[i] <= s < k
        //cout<<i<<endl;
        ans += is_unnecessary(i);
    }
    cout<<ans<<endl;

    cout<<flush;
    return 0;
}

Measured memory_bytes: 49152
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (x, y) = readListOfString()
    println(if(x == y) "=" else if(x > y) ">" else "<")
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
    }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37840
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=1010,M=1e9+7,OO=1e18;
struct ed{
    int x,y,w;
}es[N+N];
int p[N],rk[N];
vector<pii> g[N];
int get(int x){return x==p[x]?x:(p[x]=get(p[x]));}
bool un(int x,int y){
    if((x=get(x))==(y=get(y)))return 0;
    if(rk[x]<rk[y])swap(x,y);
    rk[x]+=(rk[x]==rk[y]),p[y]=x;
    return 1;
}
// int u[N];
int mst(int n,int m,int good,int bad){
    for(int i=1;i<=n;++i)p[i]=i,rk[i]=0;
    int w=0;
    if(good!=-1){
        un(es[good].x,es[good].y);
        w+=es[good].w;
    }
    forn(i,m){
        if(i==bad)continue;
        if(un(es[i].x,es[i].y)){
            g[es[i].x].pb(es[i].y,es[i].w);
            g[es[i].y].pb(es[i].x,es[i].w);
            w+=es[i].w;
            // if(mark)u[i]=mark;
        }
    }
    for(int i=1;i<=n;++i)if(get(i)!=get(1))return OO;
    return w;
}
int32_t main(){
    int n,m,tar;
    cin>>n>>m>>tar;
    forn(i,m)cin>>es[i].x>>es[i].y>>es[i].w;    
    sort(es,es+m,[](const ed&p1,const ed&p2){return p1.w<p2.w;});
    int w=mst(n,m,-1,-1);
    int cnt=0,ans=1,ov=0;
    dbg(w);
    if(w==tar){
        forn(i,m)if(mst(n,m,i,-1)==w)cnt++;
        // dbg(cnt);
        forn(i,cnt)(ans*=2)%=M;
        ans-=2;
        forn(i,m-cnt)(ans*=2)%=M;
        ans+=M;
        ans%=M;
    }else{
        forn(i,m){
            int res=mst(n,m,i,-1);
            if(res==tar)cnt++;
            if(res>tar)ov++;
            // if(!u[i]){
                // int mx=kek(es[i].x,es[i].y);
                // if(w-mx+es[i].w>tar)ov++;
                // else if(w-mx+es[i].w==tar)cnt++;
            // }
        }
        forn(i,cnt)(ans*=2)%=M;
        ans--;
        forn(i,ov+1)(ans*=2)%=M;
        ans+=M;
        ans%=M;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 75916
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mii map<int,int>
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b)  (x/gcd(x,y))*y
#define inf (long long) 1e18
#define neg_inf (long long) (-1*1e18)
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define rep(i,n)  for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cout << #x << "=" << x <<"\n";
const int N = 1e9 + 7;

int pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); res %= N; y = y >> 1; x = ((x) * (x)); } return res; }
int pow(int x, 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; }


vector<int> adj[100001];
vector<int> dp(100001,-1);

int dfs(int s)
{
    if(dp[s]!=-1)
        return dp[s];

    for(auto x:adj[s])
    {
        dp[s]=max(dp[s],dfs(x)+1);
    }
    return dp[s];
}


void solve()
{
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(dp[i]==-1)
            auto x=dfs(i);
        // cout<<dp[i]<<" ";
        ans=max(ans,dp[i]);
    }
    // cout<<"\n";
    cout<<ans+1;
} 



int32_t main()
{
  // #ifndef ONLINE_JUDGE
 //    freopen("gymnastics.in", "r", stdin);
 //    freopen("gymnastics.out", "w", stdout);
  // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t=1;
    // cin>>t;

   while(t--)
   {
      solve();
   }
}






//code by-Roshan











//unnecessary
// bool cmp(pair<int,int> &a,pair<int,int> &b)
// {
//  if(a.F==b.F)
//    return (a.S<b.S);
//  else 
//    return (a.F<b.F);
//  //< =chota wala pehle
//  //> =chota wala baad me
// }


//better use this structure
// struct s{
//  int a;
//  bool operator <(const s &x) const
//  {
//    return (a>x.a);
//  }
// };



//  priority_queue<int,vector<int>,greater<>> p;(priority queue as min heap)



Measured memory_bytes: 11540
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
     ll k;
     cin>>k;
     string s;
     cin>>s;
     if(s.length()>k)
       cout<<s.substr(0,k)<<"...";
     else
       cout<<s;
   }
}

Measured memory_bytes: 3656
package main

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

type Dice struct {
	Faces []int
}

func NewDice(n []int) *Dice {
	d := &Dice{
		Faces: n,
	}

	return d
}

func (d *Dice) move(direction string) {
	switch direction {
	case "E":
		d.Faces[0], d.Faces[2], d.Faces[5], d.Faces[3] =
			d.Faces[3], d.Faces[0], d.Faces[2], d.Faces[5]
	case "W":
		d.Faces[0], d.Faces[2], d.Faces[5], d.Faces[3] =
			d.Faces[2], d.Faces[5], d.Faces[3], d.Faces[0]
	case "N":
		d.Faces[0], d.Faces[1], d.Faces[5], d.Faces[4] =
			d.Faces[1], d.Faces[5], d.Faces[4], d.Faces[0]
	case "S":
		d.Faces[0], d.Faces[1], d.Faces[5], d.Faces[4] =
			d.Faces[4], d.Faces[0], d.Faces[1], d.Faces[5]
	}
}

func (d *Dice) Move(direction string) *Dice {
	newDice := &Dice{
		Faces: make([]int, len(d.Faces)),
	}
	copy(newDice.Faces, d.Faces)
	newDice.move(direction)

	return newDice
}

func (d *Dice) Equal(another *Dice) bool {
	return d.equal(another, 0)
}

func (d *Dice) equal(another *Dice, depth int) bool {
	if reflect.DeepEqual(d.Faces, another.Faces) {
		return true
	}

	if depth == 3 {
		return false
	}

	return d.equal(another.Move("E"), depth+1) ||
		d.equal(another.Move("W"), depth+1) ||
		d.equal(another.Move("N"), depth+1) ||
		d.equal(another.Move("S"), depth+1)
}

func MultiEqual(dices []*Dice) bool {
	for i := 0; i < len(dices)-1; i++ {
		for j := i + 1; j < len(dices); j++ {
			if dices[i].Equal(dices[j]) {
				return true
			}
		}
	}
	return false
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	dices := make([]*Dice, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		f := make([]int, 6)
		for i, s := range strings.Split(sc.Text(), " ") {
			f[i], _ = strconv.Atoi(s)
		}
		dices[i] = NewDice(f)
	}

	if !MultiEqual(dices) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 6516
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,A,B;
  cin>>N>>A>>B;
  if(N*A<=B)
  {
    cout<<N*A<<endl;
  }
  else
  {
    cout<<B<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
D,N = map(int,input().split())
if D == 0 and N == 100:
    print(101)
    exit()
if D == 1 and N == 100:
    print(10100)
    exit()

if D == 2 and N == 100:
    print(1010000)
    exit()

print(100**D*N)


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

bool hasElement(const vector<int>& vec, int target) {
    auto itr = find(vec.begin(), vec.end(), target);
    size_t index = distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int n, m; cin >> n >> m;
    map<int, vector<int> > mp;
    for(int i = 0;i < m; i++){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        mp[a].push_back(b);
        mp[b].push_back(a);
    }

    vector<int> v(n - 1);
    iota(v.begin(), v.end(), 1);

    int ans = 0;
    do {
        vector<int> root(1);
        root[0] = 0;
        copy(v.begin(),v.end(),std::back_inserter(root));

        bool ret = true;
        for(int i = 0; i < n - 1; ++i){
            if( !hasElement(mp[root[i]], root[i + 1]) ){
                ret = false;
                break;
            }
        }
        if(ret){
            ++ans;
        }


    } while( next_permutation(v.begin(), v.end()) );

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)

using namespace std;
ll N = 1000000007;


int main(){
    ll dp[100009] = {0};
	dp[0] = 0;
	dp[1] = 1;
	for(int i = 2; i < 100009; i++){
		dp[i] = dp[i-1] + dp[i-2];
        if(dp[i] > N){
            dp[i] %= N;
        }
	}
    int n,m;
    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> b(m+1);
    vector<ll> c(m+1);
    ll ans = 1;
    if(m == 0){
        cout << dp[n+1] << endl;
        return 0;
    }
    rep(i,m){
        ll temp;
        //scanf("%llu",&temp);
        cin >> temp;
        a.at(i) = temp;
        if(i > 0 && a.at(i-1) + 1 == a.at(i)){
            cout << 0 << endl;
            return 0;
        }
        if(i == 0 && a.at(i) != 0) b.at(i) = a.at(i);
        else if(i != 0)b.at(i) = a.at(i) - a.at(i-1) - 1; 
        else if(a.at(i) == 0) b.at(i) = 1;
    }
    b.at(m) = n - a.at(m-1);
    rep(i,m+1){
        c.at(i) = dp[b.at(i)];
        // if(ans > N) ans  = ans * c.at(i) % N;
        ans *= c.at(i);
    //    cout << c.at(i) << endl;
        if(ans > N) ans %= N;
    }
    
    cout << ans << endl;
    // cout <<dp[5];
    return 0;
    
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);

		char tch;
		char[] str = new char[32];
		str = cin.next().toCharArray();
		for(int i=0,j=str.length-1; i<j; i++,j--)
		{
			tch=str[i]; str[i]=str[j]; str[j]=tch;
		}
		
		System.out.println(str);
	}
}

Measured memory_bytes: 11000
n = int(input())
h = list(map(int,input().split()))

leng = 0
lent = 0
flag = 1
tp = 0
for i in range(0,n-1):
    """
if(flag == 1):
        flag = 0
"""
    if(h[i] >= h[i+1]):
        lent += 1
    else:
        leng = max(leng,lent)
        lent = 0
    
print(max(lent,leng))

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

using namespace std;

int main() {
    int X;
    cin >> X;
    int num = X;
    bool flag = false;
    while(!flag) {
        flag = true;
        for(int i = 2; i < num; i++) {
            if(num % i == 0) {
                flag = false;
                break;
            }
        }
        if(flag) {
            cout << num << endl;
        } else {
            num++;
        }
    }
}

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

int main(void){
	int a,b,c,temp;
	cin>>a>>b>>c;
	if(a<b&&a<c){
		cout<<a<<" ";
		if(b<c)cout<<b<<" "<<c<<endl;
		else cout<<c<<" "<<b<<endl;
	}
	else if(b<a&&b<c){
		cout<<b<<" ";
		if(a<c)cout<<a<<" "<<c<<endl;
		else cout<<c<<" "<<a<<endl;
	}
	else{
		cout<<c<<" ";
		if(a<b)cout<<a<<" "<<b<<endl;
		else cout<<b<<" "<<a<<endl;
	}

}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,t;
	cin>>n>>t;
	vector<ll> d(n);
	REP(i,n) cin>>d[i];
	sort(ALL(d));
	vector<ll> cnt(n);
	REP(i,n) {
		auto ite=lower_bound(ALL(d),d[i]-t);
		cnt[i]=i-(ite-d.begin());
	}
	ll ans=1;
	for(ll i=1; i<n; i++) {
		ans*=(cnt[i]+1);
		ans%=MOD;
	}
	cout<<ans<<endl;
}




Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string s;
    cin >> s;
    int flag = 1;
    if(s[2]!=s[3]) flag = 0;
    if(s[4]!=s[5]) flag = 0;
    if(flag==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}







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

struct Restaurant {
    int n;
    string s;
    int p;
    
    Restaurant(int arg_n, string arg_s, int arg_p) {
        n = arg_n;
        s = arg_s;
        p = arg_p;
    }
};

bool cmp(const Restaurant &a, const Restaurant &b) {
    if (a.s != b.s) {
        return (a.s < b.s);
    }
    
    return (a.p > b.p);
}

int main() {
    int n;
    vector<Restaurant> r;
    string s;
    int p;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> s >> p;
        r.push_back(Restaurant(i + 1, s, p));
    }
    
    sort(r.begin(), r.end(), cmp);
    
    for (int i = 0; i < n; i++) {
        cout << r[i].n << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    ll c0=0,c1=0;
    rep(0,i,s.length()){
        string rs=s.substr(i,1);
        if(rs=="0")++c0;
        else if(rs=="1")++c1;
    }
    cout<<2*min(c0,c1)<<endl;
}

Measured memory_bytes: 512
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

#         0 1 2 3 4 5 6 7 8 9
SEGTBL = [6,2,5,5,4,5,6,3,7,6]

maxnum = [None] * (N + 1 + 10)
maxnum[0] = (0, 0)

if 9 in A and 6 in A:
    A.remove(6)

if 5 in A and 2 in A:
    A.remove(2)
if 5 in A and 3 in A:
    A.remove(3)

if 3 in A and 2 in A:
    A.remove(2)

if 1 in A and 4 in A:
    A.remove(4)
if 1 in A and 6 in A:
    A.remove(6)
if 1 in A and 9 in A:
    A.remove(9)

if 7 in A and 6 in A:
    A.remove(6)
if 7 in A and 9 in A:
    A.remove(9)

# print(A)

i = 0
while i < N:
    n = maxnum[i]
    if not n is None:
        for a in A:
            m = (n[0] + 1, 10 ** n[0] * a + n[1])
            j = i + SEGTBL[a]
            prem = maxnum[j]
            maxnum[j] = m if prem is None else max(prem, m)
    i += 1

print(maxnum[N][1])


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

void Impossible(){
	print(-1);
	exit(0);
}

const int Nmax=100010;
vi tr[Nmax];
void AddEdge(int a,int b){
	tr[a].PB(b);
	tr[b].PB(a);
}
int dfs(int v,int p,int d){
	int res=d;
	for(auto to:tr[v])
		if(to!=p)
			res+=dfs(to,v,d+1);
	return res;
}

signed main(){
	int n=read();
	vector<pi> di(n);
	REP(i,n){
		di[i]=pi(read(),i);
	}
	sort(ALL(di));
	vi sub(n,1);
	for(int i=n-1;i>=1;i--){
		int s=sub[di[i].second];
		cerr<<endl;
		if(s*2>=n)Impossible();
		cerr<<endl;
		int v=di[i].first-(n-s*2);
		auto itr=lower_bound(ALL(di),pi(v,-1));
		cerr<<i<<" "<<s<<" "<<di[i]<<" "<<v<<endl;
		if(itr==di.end()||itr->first!=v)
			Impossible();
		cerr<<endl;
		int j=itr-di.begin();
		AddEdge(di[i].second,di[j].second);
		sub[di[j].second]+=s;
	}
	cerr<<endl;
	if(dfs(di[0].second,-1,0)!=di[0].first)
		Impossible();
	REP(i,n)
		for(auto j:tr[i])
			if(i<j){
				print(i+1,2);
				print(j+1);
			}
}


Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std; 
#define ll long long
#define rep(i,x,y)  for(ll i=x;i<y;++i)
#define For(i,x,y)  for(ll i=x;i<=y;++i) 
#define FOr(i,x,y)  for(ll i=x;i>=y;--i) 
#define pi acos(-1)
#define mk make_pair<ll,ll>
#define pa pair<ll,ll>
#define lf else if
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)		(x)*(x)
#define abs(x)		(x)>0?(x):-(x)
#define Mul(x,y)    x=x*(y)%mod
#define Add(x,y)    x=(x+(y))%mod
#define Max(x,y)	x=x<(y)?(y):x
#define Min(x,y)	x=x>(y)?(y):x
#define E(x) 		return writeln(x),0
#define p(x)		printf("~%d~\n",x)
#define pp(x,y)		printf("~~%d %d~~\n",x,y)
#define ppp(x,y,z)	printf("~~~%d %d %d~~~\n",x,y,z)
#define f_in(x)		freopen(x".in","r",stdin)
#define f_out(x) 	freopen(x".out","w",stdout)
#define open(x)		f_in(x),f_out(x)
#define fi first
#define se second
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_;
#endif 
#define NEG 0
    const int L=2333333;
    char SZB[L],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,L,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,f=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') f=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*f; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
    inline void writeln(ll x){  write(x);   puts("");   }
}using namespace SHENZHEBEI;
const ll N=110,mod=998244353;
ll n;	char ch[N];
map<vector<ll>,ll>mp;
vector<ll>g;
ll work(vector<ll> s){
	if (mp.count(s))	return mp[s];
	if (s.size()==1)	return mp[s]=1+s[0];
	ll n=s.size();	ll f[n+1];	memset(f,0,sizeof f);f[0]=1;
//	rep(i,0,n)printf("%d ",s[i]);puts("");
	rep(i,0,n){
		Add(f[i+1],f[i]*(s[i]+1));
		For(d,1,n)if (i+d<=n){
			vector<ll>frog;	ll lbc=i;
	//		pp(i,d);
			rep(j,0,d)	frog.push_back(s[lbc++]);
	//		p(lbc);
			while(1){
				rep(j,0,d)	if (lbc<n)	frog[j]&=s[lbc++];
				else	lbc++;
				if (lbc>n)	break;
//				rep(j,0,d)	printf("%d ",frog[j]);puts("");
				Add(f[lbc],work(frog)*f[i]);
			}
		}
	}
	return mp[s]=f[n];
}
int main(){
	readstr(ch);	n=strlen(ch);
	rep(i,0,n)	g.push_back(ch[i]-'0');
	writeln(work(g));
}
/*
101010101010011111010101111111
*/

Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#define NMAX 105
#define WMAX 10005
 
using namespace std;
 
struct Item {
    int value, weight;
};
 
int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1];
 
void compute(int &maxValue) {
    for (int w = 0; w <= W; w++) {
        C[0][w] = 0;
    }
 
    for (int i = 1; i <= N; i++)C[i][0] = 0;
 
    for (int i = 1; i <= N; i++) {
        for (int w = 1; w <= W; w++) {
            C[i][w] = C[i - 1][w];
            if (items[i].weight > w)continue;
            if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w]) {
                C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
            }
        }
    }
 
    maxValue = C[N][W];
}
 
void input() {
    cin >> N >> W;
    for (int i = 1; i <= N; i++) {
        cin >> items[i].value >> items[i].weight;
    }
}
 
int main() {
    int maxValue;
    input();
    compute(maxValue);
 
    cout << maxValue << endl;
 
    return 0;
}


Measured memory_bytes: 7068
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
int digits(int n)
{
	  if(n==0)
	  	return 1;
	  int count=0;
	  while(n>0)
	  {
	  	   count++;
	  	   n/=10;
	  }
	  return count;
}
signed main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 int n,m;
	 cin>>n>>m;
	 int s[m],c[m];
	 for(int i=0;i<m;i++)
	 {
	 	   cin>>s[i]>>c[i];
	 	   --s[i];
	 }
	 for(int i=0;i<=999;i++)
	 {
	 	     if(digits(i)==n)
	 	     {
                   vector<int>digits;
                   int x=i;
                   while(x>0)
                   {
                   	    digits.emplace_back(x%10);
                   	    x/=10;
                   }
                   if(i==0)
                   	digits.emplace_back(0);
                   reverse(digits.begin(),digits.end());
                   bool ok=true;
                   for(int i=0;i<m;i++)
                   {
                   	      if(s[i]>=(int)digits.size())
                   	      {
                   	      	ok=false;break;
                   	      }
                   	      ok&=digits[s[i]]==c[i];
                   }
                   if(ok)
                   {
                   	  cout<<i<<endl;
                   	  return 0;
                   }

	 	     } 
	 }
	 cout<<-1<<endl;
	 return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    string last;
    cin >> last;
    set<string> st;
    st.insert(last);
    for (int i = 1; i < n; i++) {
        string s;
        cin >> s;
        if (st.count(s) != 0) {
            cout << "No" << endl;
            return 0;
        }
        st.insert(s);
        if (last.back() != s[0]) {
            cout << "No" << endl;
            return 0;
        }
        last = s;
    }
    cout << "Yes" << endl;
}


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

int main(){
  string weather;
  cin >> weather;
  
  if(weather == "Sunny")
  	cout << "Cloudy";
  
  if (weather == "Cloudy")
  	cout << "Rainy";
  
  if (weather == "Rainy")
    cout << "Sunny";
}

Measured memory_bytes: 256
def gcd(a, b)
  return a if b.zero?
  gcd(b, a % b)
end

N = gets.to_i
Ts = Array.new(N) { gets.to_i }

ans = Ts[0]
(1...N).each { |i| ans = ans * Ts[i] / gcd(ans, Ts[i]) }

puts ans


Measured memory_bytes: 3836
#!/usr/bin/env python
a, b, c, x, y = map(int, input().split())
ans = a*x+b*y
for i in range(1, max(x, y)+1):
    if i <= min(x, y):
        ans = min(ans, ans-a-b+2*c)
    else:
        if x < y:
            ans = min(ans, ans-b+2*c)
        else:
            ans = min(ans, ans-a+2*c)
print(ans)

Measured memory_bytes: 3064
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,i,ans=0;cin>>n;
	vector<tuple<int,int,int>>ten(n+n);
	for(i=0;i<n;i++){
		int x,y;cin>>x>>y;
		ten[i]=mt(x,y,1);
	}
	for(i=0;i<n;i++){
		int x,y;cin>>x>>y;
		ten[i+n]=mt(x,y,2);
	}
	SO(ten);
	set<int>aka;
	for(i=0;i<n+n;i++){
		int x,y,c;
		tie(x,y,c)=ten[i];
			if(c==1){aka.ins(y);}
		else{
			if(aka.lower_bound(y)!=aka.begin()){
				aka.erase(prev(aka.lower_bound(y)));
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

void swap(int *a, int *b){
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
  return ;
}

void selectionSort(int a[], int n){
  int count  = 0;
  for(int i = 0; i < n; i++){
    int min_j = i;
    for(int j = i; j < n; j++){
      if(a[j] < a[min_j]) min_j = j;
    }
    if(i != min_j){
      swap(&a[i], &a[min_j]);
      count++;
    }
  }
  for(int i = 0; i < n-1; i++){
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
  cout << count << endl;

  return ;
}

int main(){
  int n, a[101];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  selectionSort(a, n);
  return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int N,A,B,C,l[9],ans=1e9;
void rec(int i,int a,int b,int c,int mp){
  if(i==N){
    if(a&&b&&c)ans=min(ans,abs(A-a)+abs(B-b)+abs(C-c)+mp);
    return;
  }
  rec(i+1,a,b,c,mp);
  rec(i+1,a+l[i],b,c,mp+10*(a>0));
  rec(i+1,a,b+l[i],c,mp+10*(b>0));
  rec(i+1,a,b,c+l[i],mp+10*(c>0));
}
int main(){
  cin>>N>>A>>B>>C;
  for(int i=0;i<N;i++)cin>>l[i];
  rec(0,0,0,0,0);
  cout<<ans<<endl;
}


Measured memory_bytes: 256