akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
ll exp(ll x,ll y){
    if(y==0)return 1;
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    ll t=exp(x,y/2);
    return (t*t);
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

struct unionfind{
  vector<int> par;
  void begin(int n){
    par.resize(n,-1);
  }
  int find(int x){
    if(par[x]==-1)return x;
    return par[x]=find(par[x]);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y)return;
    par[x]=y;
  }
};

int main(){
  int n,m;cin >> n >> m;
  vector<pair<int,int>> edge(m);
  rep(i,m){
    cin >> edge[i].first >> edge[i].second;
    edge[i].first--;edge[i].second--;
  }
  int cnt=0;
  rep(i,m){
    unionfind uf;
    uf.begin(n);
    rep(j,m){
      if(j==i)continue;
      uf.unite(edge[j].first,edge[j].second);
    }
    if(uf.find(edge[i].first)!=uf.find(edge[i].second))cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//
        int N, M, X;
        cin >> N >> M >> X;

        for (int i = N; i <= M; i++)
        {
                if ((i - N) < X)
                {
                        cout << i << endl;
                }
                else if ((M - i) < X)
                {
                        cout << i << endl;
                }
        }

        return 0;
}


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

int main(){
   int n,k,b=0;
   cin >> n >> k;
   int a[n];
   bool flag = 0;
   for(int i=0;i<n;i++) cin >> a[i];
   int c = a[0];
   for(int i=0;i<n;i++){
       if(k==a[i]) flag = 1;
       b = max(a[i],b);
       c = __gcd(c,a[i]);
   }
   if(flag){
       cout << "POSSIBLE" << endl;
       return 0;
   } 
   if(b<k){
       cout << "IMPOSSIBLE" << endl;
       return 0;
   }
   if(k%c==0) cout << "POSSIBLE" << endl;
   else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 640
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const input = stdin.split('\n')

const N = input[0]

const H = input[1].split(' ').map(Number)

const ans = () => {
  let streak = 0

  let max = 0

  for (let i = 0; i < N - 1; i++) {
    if (H[i] >= H[i + 1]) {
      streak++
    } else {
      max = Math.max(max, streak)
      streak = 0
    }
  }

  max = Math.max(max, streak)

  console.log(max)
}

ans()


Measured memory_bytes: 17816
#include<iostream>
#include<string>
using namespace std;
int a;
struct NodeDiv2 {
int key;
NodeDiv2 *parent, *left, *right;
};
NodeDiv2 *root, *NIL;
void preTreeWalkDiv2(NodeDiv2 *u){
if (u == NIL) { return; }
cout << ' ' << u->key;
preTreeWalkDiv2(u->left);
preTreeWalkDiv2(u->right);
}
void inTreeWalkDiv2(NodeDiv2 *u) {
if (u == NIL) { return; }
inTreeWalkDiv2(u->left);
cout << ' ' << u->key;
inTreeWalkDiv2(u->right);
}
void insertDiv2(int k) {
NodeDiv2 *y = NIL;
NodeDiv2 *x = root;
NodeDiv2 *z;
z = (NodeDiv2*)malloc(sizeof(NodeDiv2));
z->key = k;
z->right = NIL;
z->left = NIL;
while (x != NIL) {
y = x;
if (z->key < x->key) { x = x->left; }
else { x = x->right; }
}
z->parent = y;
if (y == NIL) { root = z; }
else if (z->key < y->key) { y->left = z; }
else { y->right = z; }
}
int q;
string S;
int main() {
cin >> q;
for (int i = 0; i < q; i++) {
cin >> S;
if (S == "print") {
inTreeWalkDiv2(root); cout << endl;
preTreeWalkDiv2(root); cout << endl;
}
else {
cin >> a;
insertDiv2(a);
}
}
return 0;
}

Measured memory_bytes: 26580
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
const i64 MOD = 1e9 + 7;
i64 comb[1010][1010];
void setComb(const int n = 1010) {
    comb[0][0] = 1;
    for(int i : in(1, n)) {
        comb[i][0] = 1;
        for(int j : in(1, i + 1))
          comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % MOD;
    }
}
template<typename T>
T mod_pow(T x, T n, const T mod) {
    T res = 1;
    for(; n > 0; n >>= 1) {
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}

template <typename T>
T mod_inv(T x, T mod) {
    return mod_pow(x, mod - 2, mod);
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    setComb();
    vector<i64> dp(n + 1, 0LL);
    auto dp_ = dp;
    dp[0] = 1LL;
    for(int i : in(a, b + 1)) {
        dp_ = dp;
        for(int j : in(n + 1)) {
            if(dp[j] == 0) continue;
            int rest = n - j, val = 0;
            i64 tcom = 1LL;
            for(int k : in(d)) {
                if(rest < i) break;
                (tcom *= comb[rest][i]) %= MOD;
                (tcom *= mod_inv((i64)(k + 1), MOD)) %= MOD;
                rest -= i;
                val += i;
                if(k < c - 1) continue;
                (dp_[j + val] += dp[j] * tcom) %= MOD;
            }
        }
        dp = dp_;
    }
    cout << dp[n] << endl;
    return 0;
}

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

using namespace std;
int main()
{
	int n;
	cin >> n;
	int x,xx ;
	cin >> xx;
	int cnt = 0;
	int maxx = -1;
	for(int i = 1; i < n; i ++){
		cin >> x;
		if(x <= xx){
			cnt ++;
			xx = x;
		}else{
			maxx = max(maxx, cnt);
			cnt = 0;
		} 
		xx = x;
	}
	maxx = max(maxx,cnt);
	cout << maxx << endl;
}


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

const int MAXN = 100005;
typedef long long ll;


int a[MAXN];
int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    sort(a, a + N);

    ll sum = 0;
    int idx = 0;
    for (int i = 0; i < N-1; i++)
    {
        sum += (ll)a[i];
        if (2*sum < a[i+1])
            idx = i+1;
    }

    cout << N - idx;


    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	string s;
	cin >> s;
	if(s.size()>=4 && s.substr(0,4)==string("YAKI"))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-09 23:57:16
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-20 22:47:42
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
const int mod=998244353;
const int maxn=400000+10;
char num[maxn];
ll ans[maxn];
ll pow_2[maxn];
char tw[maxn];
int N;
int mystrcmp(char* c1,char* c2)
{
    for(int i=1;i<=N;i++)
    {
        if(c1[i]>c2[i])
        return 1;
        if(c1[i]<c2[i])
        return -1;
    }
    return 0;
}
int main()
{
    read(N);
    for(int i=1;i<=N;i++)
    {
        char s;
        s=getchar();
        num[i]=s;
    }
    pow_2[0]=1;
    for(int i=1;i<maxn;i++)
    pow_2[i]=pow_2[i-1]*2%mod;
    for(int k=1;k<=N;k++)
    {
        if(N%k==0&&N/k%2==1)
        {
            
            ll res=0;
            for(int i=k;i>=1;i--){
            res=(res+(((num[i]-'0')==1)?pow_2[k-i]:0))%mod;
            }
            res++;
            for(int i=1;i<=N;i+=2*k)
            {
                int ca=0;
                for(int j=i;j<=i+k-1;j++)
                tw[j]=num[++ca];
                ca=0;
                for(int j=i+k;j<=i+2*k-1;j++)
                tw[j]=num[++ca]=='0'?'1':'0';
            }
            if(mystrcmp(tw,num)>0) {res=(res-1+mod)%mod;}
            ans[k]=res%mod;
        }
    }
    for(int i=1;i<=N;i++)
    {
        if(N%i==0&&N/i%2==1)
        {
        for(int j=2*i;j<=N;j+=i)
        ans[j]=(ans[j]-ans[i]+mod)%mod;
        }
    }
    ll sum=0;
    for(int i=1;i<=N;i++)
    if(N%i==0&&(N/i)%2==1)
    sum=(sum+2*i*ans[i])%mod;
    cout<<sum;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    string s;
    lint k;
    cin >> s >> k;
    int n = s.length();
    string s1 = s + "#";
    string s2 = s + s + "#";
    int l = 0, r = n - 1;
    for (int i = 0; i < n; i++) {
        if (s[0] != s[i]) {
            break;
        }
        l = i;
    }
    for (int i = n - 1; i >= 0; i--) {
        if (s[n - 1] != s[i]) {
            break;
        }
        r = i;
    }
    if (l >= r) {
        cout << (k * n) / 2 << endl;
        return 0;
    } else {
        int flag = 0;
        lint x = 0;
        for (int i = l + 1; i < r; i++) {
            if (s[i] == s[i + 1]) {
                flag++;
            }
            if (flag > 0 && s[i] != s[i + 1]) {
                x += (flag + 1) / 2;
                flag = 0;
            }
        }
        lint ans = 0;
        ans += (l + 1) / 2;
        ans += (n - r) / 2;
        ans += x * k;
        if (s[0] == s[n - 1]) {
            ans += (l + 1 + n - r) / 2 * (k - 1);
        } else {
            ans += ((l + 1) / 2 + (n - r) / 2) * (k - 1);
        }
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{ int a,b,c;
    while(~scanf("%d",&a))
{if(a==1)
 printf("Hello World\n");
 if(a==2)
 {scanf("%d%d",&b,&c);
 printf("%d\n",b+c);
 }
}
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    string s, t;
    cin, n, s, t;
    REP(i, 0, n) {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

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


int main(void) {
  ll N, M;
  cin >> N >> M;
  ll a[MAX], b[MAX];
  ll cnt[MAX]={};
  ll i;
  
  for(i=0; i<N; i++) {
    cin >> a[i];
    b[i]=a[i]/2;
    
    ll t=b[i];
    while(t%2==0) {
      cnt[i]++;
      t/=2;
    }
    
  }
  sort(b, b+N);
  
  sort(cnt, cnt+N);
  if(cnt[0]!=cnt[N-1]) {
    pt(0);
    return 0;
  }
  
  ll L=1;
  for(i=0; i<N; i++) {
    L=lcm(L, b[i]);
  }
  
  pt((M/L+1)/2);
  
}


Measured memory_bytes: 2560
import java.io.*;
import java.util.*;

class Main{
	public void run(){
        String s = next();
        out.printf("%s %s\n", s.substring(0, 4), s.substring(4, 12));
	}

	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().run();
		out.flush();
	}

	public Main(){
	}

	int ni(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;	}

	long nl(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	double nd(){
		return Double.parseDouble(next());
	}

	String next(){
		int c;
		while(!isAlNum(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	String nextLine(){
		int c;
		while(!isAlNumOrSpace(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNumOrSpace(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
	private static boolean isAlNumOrSpace(int c){
		return isAlNum(c) || c == ' ' || c == '\t';
	}
	void debug(Object... os){
		out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 8400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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 a,b; cin>>a>>b;
    if(a!=1 && b!=1) cout<<1<<endl;
    else if(a!=2 && b!=2) cout<<2<<endl;
    else cout<<3<<endl;
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int N; string S;
ll ans = 0;
void dfs(vector<int> &A) {
  if(A.size() == 3) {
    int tmp = 0;
    for(int i = 0; i < S.size(); i++) {
      if(char_to_int(S[i]) == A[tmp]) {
        tmp++;
      }
      if(tmp == 3) {
        ans++;
        return;
      }
      if(i == S.size() - 1) {
        return;
      }
    }
  }

  for(int i = 0; i <= 9; ++i) {
    A.push_back(i);
    dfs(A);
    A.pop_back();
  }
}

int main() {
  cin >> N; cin >> S;
  vector<int> A;
  dfs(A);
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  long long int a,b,c,d=0,f,g,h;
  cin>>a>>b>>c;
  if(a%2==0)cout<<a;
  else cout<<a*2;
}

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

using namespace std;

int main() {
    vector<int> a(3);
    for (auto& e : a) cin >> e;
    sort(a.begin(), a.end());

    int ans = 0;
    while (a[0] < a[1]) {
        a[0] += 2;
        ++ans;
    }
    if (a[0] > a[1]) {
        ++a[1];
        ++a[2];
        ++ans;
    }

    while (a[0] < a[2]) {
        ++a[0];
        ++a[1];
        ++ans;
    }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int xmove[8001];
int ymove[8001];
int xmove_len=0, ymove_len=0;
 
char S[8001];
int goalx,goaly;
 
char dp[8001][16001];
 
//#define DEBUG
int abs(int a){ return (a < 0)? -a : a;}
char possible(int goal, int * move, int move_len){
#ifdef DEBUG
    puts("move:");
    for(int i = 0; i < move_len; i++) printf("%d,", move[i]);
    puts(""); printf("movelen=%d\n",move_len);
#endif
    if(move_len == 0){
        if(goal == 0) return 1;
        else          return 0;
    }
    
    int sum = 0;
    for(int i = 0; i < move_len ; i++) sum += move[i];
      
    if((sum+goal) % 2 == 1) return 0;

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    dp[0][move[0]]=1;
    for(int i = 1; i < move_len; i++){
        for(int j = 0; j <= (sum+goal)/2 ; j++){
            dp[i][j] |= dp[i-1][j];
            if(j-move[i] >= 0) dp[i][j] |= dp[i-1][j-move[i]];    
        }
    }
#ifdef DEBUG
    for(int i = 0; i < move_len; i++){
        for(int j = 0; j <= (sum+goal)/2 && j <= 8000; j++){
           printf("%d,",dp[i][j]);
        }
       puts("");
    }
#endif
    return dp[move_len-1][(sum+goal)/2];
}
 
int main(void){
    scanf("%s",S);
    scanf("%d %d",&goalx,&goaly);
    /*
    goalx=-8000; goaly=0;
    for(int i = 0; i < 8000 ; i++){
        S[i]='F';
    }S[8000]=0;*/
 
    int xmove_ind = 0, ymove_ind = 0;
    char dir_x = 1;
    int count = 0;
    for(int i = 0; i <= strlen(S); i++){
        if(i == strlen(S) || S[i] == 'T' ){
            if(dir_x) xmove[xmove_ind++] = count;
            else      ymove[ymove_ind++] = count;
            
            dir_x = !dir_x;
            count = 0;
        }else{
            count++;
        }
    }
    xmove_len = xmove_ind;
    ymove_len = ymove_ind;
#ifdef DEBUG
    puts("xmove:");
    for(int i = 0; i < xmove_len; i++){
        printf("%d,",xmove[i]);
    }printf("xmovelen=%d\n",xmove_len);
    
    puts("ymove:");
    for(int i = 0; i < ymove_len; i++){
        printf("%d,",ymove[i]);
    }printf("ymovelen=%d\n",ymove_len);
#endif
    if(possible(abs(goaly),ymove,ymove_len)){
        if(xmove_len==1){
            if(goalx == xmove[0]) puts("Yes");
            else                  puts("No");
        }else{
            if(possible(abs(goalx-xmove[0]), &(xmove[1]), xmove_len-1)) puts("Yes");
            else                                                        puts("No");
        }
    }else{
        puts("No");
    }
    
    return 0;
}

Measured memory_bytes: 125184
import java.util.*;
import java.util.function.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int h = sc.nextInt();
		int w = sc.nextInt();
		Grid grid = new Grid(h, w);
		for(int i = 0; i < h; i++){
		    String s = sc.next();
		    grid.set(i, s);
		}
		
		
		// 計算
		Grid result = new Grid(h, w);
		result.init('0');
		result.proc((i, j) -> (ni, nj) -> {
		    if(grid.get(i, j) == '#'){
		        if(grid.get(ni, nj) != '#'){
		            char tmp = result.get(ni, nj);
		            result.set(ni, nj, ++tmp);
		        }else{
		            result.set(ni, nj, '#');
		        }
		    }
		});
		
		// 出力
		System.out.println(result.toString());
	}
}

class Grid {
    int h;
    int w;
    char[][] grid;
    int[] dx = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; // 9
    int[] dy = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; // 9
    //int[] dx = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; // 8
    //int[] dy = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; // 8
    //int[] dx = {0, -1, 1, 0}; // 4
    //int[] dy = {-1, 0, 0, 1}; // 4
    
    public Grid(int h, int w){
        this.h = h;
        this.w = w;
        this.grid = new char[h][w];
    }
    
    public void init(char c){
        for(int i = 0; i < h; i++){
            Arrays.fill(grid[i], c);
        }
    }
    
    public void set(int indexH, String s){
        grid[indexH] = s.toCharArray();
    }
    
    public void set(int indexH, int indexW, char c){
        grid[indexH][indexW] = c;
    }
    
    public void set(int index, char c){
        int indexH = index/w;
        int indexW = index%w;
        grid[indexH][indexW] = c;
    }
    
    public char get(int indexH, int indexW){
        return grid[indexH][indexW];
    }
    
    public char get(int index){
        int indexH = index/w;
        int indexW = index%w;
        return grid[indexH][indexW];
    }
    
    public boolean isValid(int indexH, int indexW){
        return 0 <= indexH && indexH < h && 0 <= indexW && indexW < w;
    }

    public String toString(){
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < h; i++){
            sb.append(grid[i]);
            sb.append('\n');
        }
        return sb.toString();
    }
    
    public void proc(BiFunction<Integer, Integer, BiConsumer<Integer, Integer>> proc){
        for(int i = 0; i < h; i++){
		    for(int j = 0; j < w; j++){
		        for(int k = 0; k < dx.length; k++){
		            int ni = i + dy[k];
		            int nj = j + dx[k];
		            if(isValid(ni, nj)){
		                proc.apply(i, j).accept(ni, nj);
		            }
		        }
		    }
		}
    }
}


Measured memory_bytes: 27604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305,mod=1e9+7;
ll dp[N][N*N],sum[N][N*N];
int n,k;
int main()
{
    scanf("%d%d",&n,&k);
    dp[n+1][0]=1;
    int mx=0;
    for(int i=n+1;i>1;i--)
    {
        int t=mx;
        for(int j=0;j<=t;j++)
        {
            if(!dp[i][j]&&!sum[i][j]) continue;
            for(int h=0;h<=k;h++)
            {
                if(h<=i-1)
                {
                    mx=max(mx,j+(h+j)/(i-1));
                    int s=j+(h+j)/(i-1);
                    dp[i-1][s]=(dp[i-1][s]+dp[i][j])%mod;
                    sum[i-1][s]=(sum[i-1][s]+sum[i][j]+(h+j)%(i-1)*dp[i][j])%mod;
                }
                else
                {
                    dp[i-1][j]=(dp[i-1][j]+dp[i][j])%mod;
                    sum[i-1][j]=(sum[i-1][j]+sum[i][j]+(h+j)*dp[i][j]%mod)%mod;
                }
            }
        }
    }
    ll ans=0;
    for(int j=0;j<=mx;j++)
        ans=(ans+sum[1][j])%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 147712
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 3e3 + 9;
int mem[N][N], n, s, mod = 998244353;
vi v1;
int solve(int idx, int sum) {
	if (sum > s) return 0;
	if (idx == n) return 0;
	int& ret = mem[idx][sum];
	if (ret != -1) return ret;
	ret = solve(idx + 1, sum);
	ll ch = solve(idx + 1, sum + v1[idx]);
	if (sum + v1[idx] == s)
		ch = n - idx;
	ret += ch;
	ret %= mod;
	return ret;
}
int main() {
	//file();
	fast();
	memset(mem, -1, sizeof mem);
	cin >> n >> s;
	v1 = vi(n);
	for (auto& it : v1) cin >> it;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += solve(i, 0);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 
signed main(){
    int n,k;
    cin>>n>>k;
    double ans=0.0;
    for(int i=1;i<=n;i++){
        int p=1;
        while(p<k/(double)i){
            p*=2;
        }
        ans+=(1.0/(double)p);

    }
    cout<<fixed<<setprecision(10)<<ans*(1.0/(double)n)<<endl;
}

Measured memory_bytes: 256
#pragma region

#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int N;
  cin >> N;
  vi A(N);
  cin >> A;

  unordered_set<int> a;
  rep(i, N) a.insert(A[i]);
  out(a.size() == N ? "YES" : "NO");
}


Measured memory_bytes: 9288
#include<iostream>
#include<string>

using namespace std;

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

	char hidden;
	for(int i = 0; i < N; ++i){
		if(i == K-1) hidden = S[i];
	}

	for(int i = 0; i < N; ++i){
		if(S[i] != hidden) cout << "*";
		else cout << S[i];
	}

	cout << endl;

	return 0;
}


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

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long N, std::vector<long long> P){
    ll min=LLONG_MAX;
    ll ans=0;
    rep(i,N){
        if(P[i]<=min){
            min=P[i];
            ans++;
        }
    }
    op(ans)
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(P));
    return 0;
}


Measured memory_bytes: 1792
cnt = 0
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
j = 1

for i in 0..n-1
    if a[i] != j
        cnt += 1
    else
        j+=1
    end
end

if !(a.include?(1))
    cnt = -1
end

puts cnt

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

int main() {
  string s; cin >> s;
  int N = s.size();
  for(int i = 0; i + 2 <= N; ++i) {
    if(s[i] == s[i+1]) {
      cout << i+1 << ' ' << i+2 << endl;
      return 0;
    }
  }
  for(int i = 0; i + 3 <= N; ++i) {
    if(s[i] == s[i+2]) {
      cout << i+1 << ' ' << i+3 << endl;
      return 0;
    }
  }
  cout << "-1 -1" << endl;
  return 0;
}


Measured memory_bytes: 512
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::min;
use std::mem::swap;

#[fastout]
fn main() {
    input! {
    mut a: usize,
    mut b: usize
    }
    if a < b {swap(&mut a, &mut b)}
    for _ in 0..a {
        print!("{}", b)
    }
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,a[100000],sum=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2!=0){
      sum++;
    }
  }
if(sum%2!=0){
  cout<<"NO\n";
}else{
  cout<<"YES\n";
}
}

Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, d) = scan!(usize, usize);
    let vs = scan!(i64;;n);

    let mut ans = 0;
    for i in 0..n {
        for j in i + 1..n {
            let mut sum = 0;
            for l in 0..d {
                let d = vs[i][l] - vs[j][l];
                sum += d * d;
            }
            for m in 1..4000 {
                if m * m == sum {
                    ans += 1;
                    break;
                }
            }
        }
    }
    println!("{}", ans)
}


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

using namespace std; 
#define ll long long
#define ld long double
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
int main()
{
	ll n;
	cin >> n;
	ll arr[n];
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		cin >> arr[i];
		if(i%2==0 && arr[i]%2)
			ans+=1;
	}
	cout << ans << "\n";

}

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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1000000000 + 7;
const int N = 1e6 + 5;

typedef long long ll;

ll v[N], d[N], ds[N], c[N], u[N], ans[N];
vector <ll> g[N];

void dfs(ll x, ll di, ll cl)
{
    if(ds[x] >= di) return ;
    if(!ans[x])
        ans[x] = cl;
    u[x] = 1;
    ds[x] = di;
    for(int i = 0; i < g[x].size(); i ++)
    {
        ll to = g[x][i];
        if(u[to]) continue ;
        dfs(to, di - 1, cl);
    }
    u[x] = 0;
}

inline void solve()
{
    ll n, m, q;
    scanf("%lld %lld", &n, &m);

    for(int i = 1; i <= m; i ++)
    {
        ll a, b;
        scanf("%lld %lld", &a, &b);
        g[a].pb(b);
        g[b].pb(a);
    }

    for(int i = 1; i <= n; i ++)
        ds[i] = -1;

    scanf("%lld", &q);

    for(int i = 1; i <= q; i ++)
        scanf("%lld %lld %lld", &v[i], &d[i], &c[i]);
    for(int i = q; i >= 1; i --)
        dfs(v[i], d[i], c[i]);
    for(int i = 1; i <= n; i ++)
        printf("%lld\n", ans[i]);
}

int tests = 1;

int main()
{
//    scanf("%d", &tests);

    while(tests --)
        solve();
}


Measured memory_bytes: 43380
class UnionFind:

    def __init__(self, n):
        self.d = [-1 for _ in range(n)]
    
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.d[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return -self.d[self.find(x)]

N, M, K = map(int, input().split())
dame = [[] for _ in range(N)]
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)
    dame[a].append(b)
    dame[b].append(a)

for i in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if not uf.same(c, d):
        continue
    dame[c].append(d)
    dame[d].append(c)

for i in range(N):
    ans = uf.size(i) - 1
    ans -= len(dame[i])
    print(ans, end=" ")

print()



Measured memory_bytes: 31192
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
using Graph = vector<vector<ll>>;

ll n;
ll M[110][110]; // kyori
const int white = 0, gray = 1, black = 2;

ll prim(){
  ll u, minv;
  ll d[10000], p[10000], color[10000];

  rep(i, 0, n){
    d[i] = INF;
    p[i] = -1; // parent
    color[i] = white;
  }
  d[0] = 0;
  while(1){
    minv = INF;
    u = -1;
    rep(i, 0, n){
      if(minv > d[i] && color[i] != black){
        u = i;
        minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = black;
    rep(v, 0, n){
      if(color[v] != black && M[u][v] != INF){
        if(d[v] > M[u][v]){
          d[v] = M[u][v];
          p[v] = u;
          color[v] = gray;
        }
      }
    }
  }
    ll sum = 0;
    rep(i, 0, n){
    if(p[i] != -1) sum += M[i][p[i]];
    }

    return sum;
}

int main() {
  cin >> n;
  rep(i, 0, n){
    rep(j, 0, n){
      ll a; cin >> a;
      M[i][j] = (a == -1) ? INF : a;
    }
  }

  cout << prim() << endl;

  return 0;
}



Measured memory_bytes: 3112
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInts(5)
	k := scanInt()

	for i := 0; i < 4; i++ {
		for j := i + 1; j < 5; j++ {
			if n[j]-n[i] > k {
				fmt.Println(":(")
				return
			}
		}
	}

	fmt.Println("Yay!")
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


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

int main(void)
{
    //入力
    int N;
    cin >> N;
    vector<int> A(N,0);
    vector<long long int> B;
    for( int i = 0; i < N; i++){
        cin >> A[i];
    }

    //計算
    sort(A.begin(), A.end(),greater<int>());
    for( int i = 0; i < N-1; i++){
        if( A[i] == A[i+1] ){
            B.push_back(A[i]);
            i++;
        }
    }
    if( B.size() < 2){
        cout << 0;
        return 0;
    }
    cout << B[0] * B[1];

    return 0;
}

Measured memory_bytes: 1276
from numpy import *

n, m = map(int, input().split())
s = [[int(x) for x in input().split()][1:] for y in range(m)]
p = [int(z) for z in input().split()]
ans = 0

for i in range(2**n):
    b = array([(i>>j)&1 for j in range(n)])
    if [sum(b[array(k) - 1]) % 2 for k in s] == p:
        ans += 1
print(ans)

Measured memory_bytes: 21044
#include <iostream>

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, h, w;
  cin >> n >> h >> w;

  int ans = (n - h + 1) * (n - w + 1);



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

Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        A:i32,B:i32
    }
    let Amin = (A * 100 + 7) / 8;
    let Amax = ((A + 1) * 100 + 7) / 8;
    let Bmin = B * 10;
    let Bmax = (B + 1) * 10;
    if Bmax <= Amin || Amax <= Bmin {
        println!("-1");
        return;
    }
    let ans = std::cmp::max(Amin, Bmin);
    println!("{}", ans);
}


Measured memory_bytes: 2176
n=int(input())
s=input()
from collections import Counter
l=Counter()
l["R"]=[]
l["G"]=[]
l["B"]=[]
for j,i in enumerate(s):
    if l[i]==0:
        l[i]=[]
    l[i].append(j)
ans=0
import bisect
import itertools
ll=Counter()
ll["R"]=len(l["R"])
ll["G"]=len(l["G"])
ll["B"]=len(l["B"])
for i,j in itertools.combinations(range(n),2):
    if s[i]!=s[j]:
        c="RGB".replace(s[i],"").replace(s[j],"")
        idx=bisect.bisect_left(l[c],j)
        ans+=ll[c]-idx
        if 2*j-i<n:
            if s[2*j-i]==c:
                ans-=1
print(ans)




Measured memory_bytes: 69724
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



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

  int N;
  cin >> N;
  int A[N];
  map<int, int> mp;
  rep(i,N){
    cin >> A[i];
    mp[A[i]]++;
  }
  int ans = 0;
  for(auto p : mp){
    int x = p.second;
    ans += x*(x-1)/2;
  }

  rep(i,N){
    cout << ans - mp[A[i]] + 1 << endl;
  }

}

Measured memory_bytes: 11136
N = int(input())
arr = sorted(list(map(int, input().split())))
divider = arr[0]
all = False
while not all:
  all = True
  new_arr = []
  for i in range(len(arr)):
    if arr[i] % divider > 0:
      all = False
      new_arr.append(arr[i] % divider)
  new_arr.append(divider)
  arr = sorted(new_arr)
  divider = new_arr[0]

print(divider)

Measured memory_bytes: 14224
def solve():
    #start here
    n, W = map(int,input().split())
    l = []
    dp = [[0 for i in range(W+1)] for j in range(n)]
    for i in range(n):
        w, v = map(int,input().split())
        for j in range(1, W+1):
            if(w>j):
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = max(dp[i-1][j], v+dp[i-1][j-w])
    print(dp[n-1][W])
solve()

Measured memory_bytes: 218832
package main

import (
	"fmt"
	"strconv"
)

func reverseStr(s string) string {

	runes := []rune(s)

	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}

	return string(runes)
}

func main() {
	// Code for B - Palindromic Numbers
	var A, B int
	fmt.Scanf("%d %d", &A, &B)

	var answer int
	for i := A; i <= B; i++ {
		S := strconv.Itoa(i)
		if S == reverseStr(S) {
			answer++
		}
	}

	fmt.Println(answer)
}


Measured memory_bytes: 3300
n=int(input())
l=[]
for i in range(n):
  l.append(int(input()))
s=sum(l)
l.sort()
if s%10!=0:
  print(s)
  exit()
for i in l:
  b=s-i
  if b%10!=0:
    print(b)
    exit()
print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string str;
	while(cin >> str)
	{
		if( str[0] == 'o' && str[1] == 'o' && str[2] == 'o' ||
			str[3] == 'o' && str[4] == 'o' && str[5] == 'o' ||
			str[6] == 'o' && str[7] == 'o' && str[8] == 'o' ||
			str[0] == 'o' && str[3] == 'o' && str[6] == 'o' ||
			str[1] == 'o' && str[4] == 'o' && str[7] == 'o' ||
			str[2] == 'o' && str[5] == 'o' && str[8] == 'o' ||
			str[0] == 'o' && str[4] == 'o' && str[8] == 'o' ||
			str[2] == 'o' && str[4] == 'o' && str[6] == 'o')
		{
			cout << "o" << endl;
		}
		else if(str[0] == 'x' && str[1] == 'x' && str[2] == 'x' ||
				str[3] == 'x' && str[4] == 'x' && str[5] == 'x' ||
				str[6] == 'x' && str[7] == 'x' && str[8] == 'x' ||
				str[0] == 'x' && str[3] == 'x' && str[6] == 'x' ||
				str[1] == 'x' && str[4] == 'x' && str[7] == 'x' ||
				str[2] == 'x' && str[5] == 'x' && str[8] == 'x' ||
				str[0] == 'x' && str[4] == 'x' && str[8] == 'x' ||
				str[2] == 'x' && str[4] == 'x' && str[6] == 'x')
		{
			cout << "x" << endl;
		}
		else
		{
			cout << "d" << endl;
		}
	}
}

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

Measured memory_bytes: 1176
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var cnt = new long[5];
            var dct = new Dictionary<char, long>() {
                { 'M',0},
                { 'A',1},
                { 'R',2},
                { 'C',3},
                { 'H',4},
            };
            for (var i = 0; i < N; ++i)
            {
                var s = ReadLine()[0];
                if (dct.ContainsKey(s))
                    ++cnt[dct[s]];
            }
            var ans = 0L;
            for (var i = 0; i < Pow(2, 5); ++i)
            {
                var selnum = 0L;
                var s = i;
                var sum = 1L;
                for (var j = 0; j < 5; ++j)
                {
                    if (0 != (s & 1))
                    {
                        sum *= cnt[j];
                        ++selnum;
                    }
                    s >>= 1;
                }
                if (selnum == 3)
                    ans += sum;
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 15444
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int m,d;
  cin >> m >> d;
  int ans = 0;
  REP(i,1,m + 1){
    REP(j,1,d + 1){
      if(j < 22)continue;
      string tmp = to_string(j);
      int a = tmp[0] - '0',b = tmp[1] - '0';
      if(b < 2)continue;
      if(i == a * b){ans++;}
    }
  }
  cout << ans << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s1,s2;int c = 0;
 cin >> s1 >> s2;
 for(int i=0;i<3;i++)
 {
  if(s1[i]==s2[i])
  c++;
 }
 cout << c << endl;
}

Measured memory_bytes: 256