akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

void solve() {
    //const i64 mod = 1'000'000'007;
    string S;
    cin >> S;

    const i64 x=753;
    i64 ans=inf64;
    rep(i,0,S.size()){
        if(i+3>S.size()) break;
        i64 y=stoi(S.substr(i,3));
        chmin(ans,abs(x-y));
    }
    
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

struct HeavyLight {
  vector<vector<int> > len,tree;
  int pathCount,n;
  vector<int>size,parent,in,out,path,pathSize,pathPos,pathRoot;

  HeavyLight(vector<vector<int> > t,int n)
    :tree(t),n(n),size(n),parent(n),in(n),out(n),
     path(n),pathSize(n),pathPos(n),pathRoot(n){
    int time=0;
    dfs(0,-1,time);
    buildPaths(0,newPath(0));
  }

  void dfs(int u, int p, int &k){
    in[u]=k++, parent[u]=p, size[u]=1;
    EACH(v,tree[u])if(*v!=p)dfs(*v, u, k),size[u]+=size[*v];
    out[u]=k++;
  }

  int newPath(int u){ pathRoot[pathCount]=u; return pathCount++; }

  void buildPaths(int u, int pt){
    path[u]=pt, pathPos[u]=pathSize[pt]++;
    EACH(v,tree[u])if(*v != parent[u])
      buildPaths(*v, 2*size[*v] >= size[u] ? pt : newPath(*v));
  }

  bool isAncestor(int p, int ch){
    return in[p] <= in[ch] && out[ch] <= out[p];
  }

  int lca(int a,int b){
    for(int root; !isAncestor(root=pathRoot[path[a]],b);a=parent[root]);
    for(int root; !isAncestor(root=pathRoot[path[b]],a);b=parent[root]);
    return isAncestor(a,b)?a:b;
  }
};

//Usage: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C
int main(void){
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<int> >tree(n);
  
  REP(i,n){
    int k;
    cin >> k;
    REP(j,k){
      int ch;
      cin >> ch;
      tree[i].push_back(ch);
    }
  }

  HeavyLight hl = HeavyLight(tree,n);

  int q;
  cin >> q;
  while(q--){
    int u,v;
    cin >> u >> v;
    cout << hl.lca(u,v) << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 24696
#include<stdio.h>
#include<algorithm>
using namespace std;
int perm[4];
char e[]="+-*";
int main(){
	int a,b,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d),a+b+c+d){
		perm[0]=a;perm[1]=b;perm[2]=c;perm[3]=d;
		std::sort(perm,perm+4);
		bool ok=false;
		do{
			for(int i=0;!ok&&i<3*3*3;i++){
				int val=perm[0];
				int m=i;
				for(int j=0;j<3;j++){
					switch(m%3){
						case 0:
							val+=perm[j+1];
							break;
						case 1:
							val-=perm[j+1];
							break;
						case 2:
							val*=perm[j+1];
							break;
					}
					m/=3;
				}
				if(val==10){
					ok=true;
					m=i;
					printf("(((%d",perm[0]);
					for(int j=0;j<3;j++){
						printf("%c%d)",e[m%3],perm[j+1]);
						m/=3;
					}
					printf("\n");
				}
			}
			for(int i=0;!ok&&i<3;i++){
				for(int j=0;!ok&&j<3;j++){
					for(int k=0;!ok&&k<3;k++){
						int val1=perm[0];
						int val2=perm[2];
						switch(i){
							case 0:
								val1+=perm[1];
								break;
							case 1:
								val1-=perm[1];
								break;
							case 2:
								val1*=perm[1];
								break;
						}
						switch(j){
							case 0:
								val2+=perm[3];
								break;
							case 1:
								val2-=perm[3];
								break;
							case 2:
								val2*=perm[3];
								break;
						}
						switch(k){
							case 0:
								val1+=val2;
								break;
							case 1:
								val1-=val2;
								break;
							case 2:
								val1*=val2;
								break;
						}
						if(val1==10){
							ok=true;
							printf("((%d%c%d)%c(%d%c%d))\n",perm[0],e[i],perm[1],e[k],perm[2],e[j],perm[3]);
						}
					}
				}
			}
		}while(!ok&&next_permutation(perm,perm+4));
		if(!ok)printf("0\n");
	}
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;

int main(){
    int n; cin>>n;
    if(n==1){
        cout<<"Hello World";
        return 0;
    }
    int a,b; cin>>a>>b;
    cout<<a+b;
}

Measured memory_bytes: 256
a, b, q = [int(i) for i in input().split(" ")]

s = [0] * a
t = [0] * b
x = [[0, 0]] * q

#a, b, q = [2, 3, 4]
#s = [100, 600]
#t = [400, 900, 1000]
#x = [[0, 150], [1, 2000], [2, 899], [3, 799]]

sd = 0
td = 0

for i in range(0, a):
    s[i] = int(input())
    
for i in range(0, b):
    t[i] = int(input())
    
for i in range(0, q):
    x[i] = [i, int(input())]

x = sorted(x, key = lambda k: k[1])
ans = [[0, 0]] * q

def sdd(i, x):
    if i < 0 or i >= a:
        return 10**12
    else:
        return abs(s[i] - x)
    
def tdd(i, x):
    if i < 0 or i >= b:
        return 10**12
    else:
        return abs(t[i] - x)
        
for j in range(0, q):
    bf = False
    for i in range(sd, a):
        if s[i] > x[j][1]:
            sd = i
            bf = True
            break
    if not bf:
        sd = a
        
    bf = False

    for i in range(td, b):
        if t[i] > x[j][1]:
            td = i
            bf = True
            break
    if not bf:
        td = b
    
    xj = x[j][1]
    a1 = min(max(sdd(sd - 1, xj), tdd(td - 1, xj)), max(sdd(sd, xj), tdd(td, xj)))
    a2 = min(2 * sdd(sd - 1, xj) + tdd(td, xj), 2 * tdd(td - 1, xj) + sdd(sd, xj), sdd(sd - 1, xj) + 2 * tdd(td, xj), tdd(td - 1, xj) + 2 * sdd(sd, xj))
    ans[j] = [x[j][0], min(a1, a2)]

ans = sorted(ans, key = lambda k: k[0])
for i in range(0, q):
    print(ans[i][1])

Measured memory_bytes: 43368
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define sc(aa) scanf("%lld",&aa)
#define pr(aa) printf("%lld",aa)
#define line printf("\n")
#define space printf(" ")
#define loop(aa) for(ll ii=0;ii<aa;ii++)
using namespace std;
int main()
{
    ll n;
    while(sc(n)==1)
    {
        ll ans=1;
        for(ll i=1;i<=3;i++)ans=ans*n;
        pr(ans);
        line;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
 
const int INF=1000000000;
 
using namespace std;
 
struct edge{int to,cost;};
typedef pair<int,int>P;
 
int V,d[101];
vector<edge>G[101];
 
void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P> >que;
  fill(d,d+V,INF);
  d[s]=0;
  que.push(P(0,s));
 
  while(!que.empty()){
    P p=que.top();
    que.pop();
    int v=p.second;
    if(d[v]<p.first)continue;
 
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
    d[e.to]=d[v]+e.cost;
    que.push(P(d[e.to],e.to));
      }
    }
  }
}
 
int main(void){
 
  int n,m,c,s,g,x,y,D,C;
  int p[21],q[21][51],r[21][51];
  int graph[21][101][101],Cost[21][20001];
   
  while(cin >> n >> m >> c >> s >> g,n|m|c|s|g){
   
    for(int i=0;i<101;i++)G[i].clear();
 
    for(int i=0;i<21;i++)
      for(int j=0;j<101;j++)
    for(int k=0;k<101;k++)
      graph[i][j][k]=INF;
 
    for(int i=0;i<21;i++)
      for(int j=0;j<101;j++)
    graph[i][j][j]=0;
     
    for(int i=0;i<m;i++){
      cin >> x >> y >> D >> C;
      graph[C][x][y]=graph[C][y][x]=min(graph[C][x][y],D);
    }
  
    for(int i=1;i<=c;i++)cin >> p[i];
 
    for(int i=1;i<=c;i++){
      for(int j=1;j<p[i];j++)cin >> q[i][j];
      for(int j=1;j<=p[i];j++)cin >> r[i][j];
    }
     
    for(int i=0;i<21;i++)
      for(int j=0;j<20001;j++)
    Cost[i][j]=0;
   
    for(int i=1;i<=c;i++){
      for(int j=1,k=1;j<20001;j++){
    if(k<p[i] && q[i][k]<j)k++;
    Cost[i][j]=Cost[i][j-1]+r[i][k];
      }
    }
     
    for(int l=1;l<=c;l++){
      for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
        graph[l][i][j]=min(graph[l][i][j],graph[l][i][k]+graph[l][k][j]);
      }
    }
      }
    }
     
    for(int k=1;k<=c;k++)
      for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      if(graph[k][i][j]!=INF)
        graph[0][i][j]=min(graph[0][i][j],Cost[k][graph[k][i][j]]);
     
 
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
    if(graph[0][i][j]==INF)continue;
    edge e;
    e.to=j;
    e.cost=graph[0][i][j];
    G[i].push_back(e);
      }
    }
     
     
    V=n+1;
    dijkstra(s);
 
    if(d[g]==INF)cout << -1 << endl;
    else cout << d[g] << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
 
const int lim = 1e6 + 5;
const int Inf = 1000000007;
const long long mod = 1000000007;//998244353;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
long long l, r;
long long a[200005];

int main()
{
	Fastio();
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	l = 2;
	r = 2;
	for(int i = n; i >= 1; i--)
	{
		if(l > r)
		{
			cout << -1;
			return 0;
		}
		if(l % a[i] != 0)
		{
			int temp = l % a[i];
			l += (a[i] - l % a[i]);
		}
		r = r - r % a[i];
		if(l > r)
		{
			cout << "-1";
			return 0;
		}
		r += a[i] - 1;
	}
	cout << l << ' ' << r;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

//#include "All.h"

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

int N;
string S[200010];
vector<string> s[200010];

int main() {

    cin >> N;
    rep(i, N) {
        string T;
        cin >> T;
        S[i] = T;
    }
    
    sort(S, S + N);

    S[N] = "";

    int a = 1;
    int a_max = a;

    REP(i, 1, N + 1) {
        
        if (S[i] == S[i - 1]) {
            a++;
        }
        else {
            a_max = max(a_max, a);
            s[a].push_back(S[i - 1]);
            a = 1;
        }

    }
    for (int i = 0; i < s[a_max].size(); i++) {
        cout << s[a_max][i] << endl;
    }
}

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

int main() {
  int n,k;
  cin >> n >> k;
  ll ans=0;
  
  for(int b=1;b<=n;b++){
    int p=n/b;
    int r=n%b;
    ans += p * max(0,b-k);
    ans += max(0,r-k+1);
  }
  
  if(k == 0){
    cout << ans - n<< endl;
  }else{
    cout << ans << endl;
  }
  
  return(0);
}

Measured memory_bytes: 3628
def check(st) : 

	n = len(st) 
	digitSum = 0
	
	for i in range(0,n) : 
		digitSum = digitSum + (int)(st[i]) 

	
	return (digitSum % 9 == 0) 


st =input()

if(check(st)) : 
	print("Yes") 
else : 
	print("No") 
	


Measured memory_bytes: 9236
import numpy as np
N = int(input())
X = np.array(list(map(int, input().split())))
ans = np.sum(X**2)
for i in range(0,int(np.max(X))+1):
  l = X - i
  a = np.sum(l**2)
  if a < ans:
    L = l
    ans = a
print(ans)

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

int main() {
    int n, d;
    cin >> n >> d;
    int x = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a--;
        a %= (d + 1);
        x ^= a;
    }
    cout << (x ? "First" : "Second") << endl;
}


Measured memory_bytes: 3076
n = input()
A = [0]
p = range(1, n)
a = [[0 for i in range(n)]for j in range(n)]
 
for i in range(n):
    a[i] = map(int, raw_input().split() )
 
l = 0
 
while p != []:
    a_min = 10000
    for i in A:
        for j in p:
            if 0 <= a[i][j] < a_min:
                a_min = a[i][j]
                add_A = j
    A.append(add_A)
    p.remove(add_A)
    l += a_min
 
print l

Measured memory_bytes: 6392
import sys
def inpl(): return [int(i) for i in input().split()]

H, W = inpl()
if H%3 == 0 or W%3 == 0:
    print(0)
    sys.exit()
if H == 2 or W == 2:
    print(1)
    sys.exit()

a = W//3
b = W%3
c = H//3
d = H%3

ans = float('inf') 

for i in range(b+1):
    ans = min(ans,max(H*(a+i),(H//2+H%2)*(W-a-i),(H//2)*(W-a-i))-\
              min(H*(a+i),(H//2+H%2)*(W-a-i),(H//2)*(W-a-i)))
for i in range(d+1):
    ans = min(ans,max(W*(c+i),(W//2+W%2)*(H-c-i),(W//2)*(H-c-i))-\
              min(W*(c+i),(W//2+W%2)*(H-c-i),(W//2)*(H-c-i)))
print(min(ans,H,W)) 


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

#if DEBUG && !ONLINE_JUDGE
    #include "header.h"
#else
    #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
    return;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    preprocess();
    int a, b; cin>>a>>b;
    if((a+b)%2) cout<<"IMPOSSIBLE"<<endl;
    else cout<<(a+b)/2<<endl;
}



Measured memory_bytes: 256
s = gets.split('')
exist_c = false
exist_f = false
num = 0
s.each do |t|
  if exist_c
    if t == 'F'
      exist_f = true
      break
    else
      num += 1
    end
  else
    if t == 'C'
      exist_c = true
    else
      num += 1
    end
  end
end
puts exist_c && exist_f ? "Yes" : "No"

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


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

  int n;
  cin >> n;
  map<int,int> amap;
  ll ans = 0;
  rep(i,n){
    int a;
    cin >> a;
    amap[a]++;
    ans += a;
  }
  int q;
  cin >> q;
  rep(i,q){
    int b,c;
    cin >> b >> c;
    if(amap[b]!=0){
      ans += c*amap[b] - b*amap[b];
      amap[c] += amap[b];
      amap[b] = 0;
    }
    cout << ans << endl;
  }
  return 0;
    

}


Measured memory_bytes: 7888
#include <iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if ((x+r)<=W && (y+r)<=H && (x-r)>=0 && (y-r)>=0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  long long cost;
  if (A + B > C * 2) {
    cost = min(X, Y) * 2 * C;
    int D = X > Y ? A : B;
    int r = abs(X - Y);
    if (D > C * 2) {
      cost += r * C * 2;
    } else {
      cost += r * D;
    }
  } else {
    cost = A * X + B * Y;
  }
  cout << cost << endl;

  return 0;
}
/* vim:set fdm=marker: */


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



int main()
{
    int N;
    std::cin >> N;
    std::vector<int> H;

    for(int i =0; i<N; ++i){
        int a;
        std::cin >>a;
        H.push_back(a);
    }
    int max_height = H[0];
    int count = 0;
    for(int i = 0; i<N; ++i){
        if(max_height <= H[i]){
            max_height = H[i];
            count++;
        }
    }
    std::cout << count << std::endl;
    return 0;
}


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

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

void SMTB2019D()
{
	int N;
	cin >> N;
	string S;
	cin >> S;
	vi d1(10, -1);
	for (int k = 0; k < N; ++k)
	{
		int i = S[k] - '0';
		const char x = S[k];
		int j = atoi(&x);
      
		if (x - '0' != i)
			throw "Bad";
		if (d1[i] < 0)
			d1[i] = k;
	}
	vi d2(100, -1);
	for (int k = 1; k < N; ++k)
	{
		int i = S[k] - '0';
		char x = S[k];
		int j = atoi(&x);
//		if (i != j)
//			throw "Bad";
		for (int j = 0; j < 10; ++j)
		{
			if (d1[j] >= 0 && d1[j] < k && d2[j * 10 + i] < 0)
				d2[j * 10 + i] = k;
		}
	}
	vi d3(1000, -1);
	for (int k = 2; k < N; ++k)
	{
		int i = S[k] - '0';
		char x = S[k];
		int j = atoi(&x);
//		if (i != j)
//			throw "Bad";
		for (int j = 0; j < 100; ++j)
		{
			if (d2[j] >= 0 && d2[j] < k && d3[j * 10 + i] < 0)
				d3[j * 10 + i] = k;
		}
	}
	int ct = 0;
	for (int i = 0; i < 1000; ++i)
	{
		if (d3[i] > 0)
		{
			++ct;
		}
	}
	cout << ct << endl;
}int main()
{
	SMTB2019D();
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;

int N;
vector <int> T;
vector <int> A;

vector <bool> T_val;
vector <bool> A_val;

int main()
{


	cin >> N;

	for(int i=0; i<N; i++){
		int input;
		cin >> input;
		T.push_back(input);
		if (i==0) T_val.push_back(1);
		else if (T[i]!=T[i-1]) T_val.push_back(1);
		else T_val.push_back(0);
	}
	for(int i=0; i<N; i++){
		int input;
		cin >> input;
		A.push_back(input);
	}
	for (int i=0; i<N; i++){
		if (i==N-1) A_val.push_back(1);
		else if (A[i]!=A[i+1]) A_val.push_back(1);
		else A_val.push_back(0);
	}



	long long ans=1;
	long long div = 1000000007;
	for(int i=0; i<N; i++){
		if (T_val[i]==1 && A_val[i]==1){
			if (T[i]!=A[i]){
				cout << "0" << endl;
				return 0;
			}
		}
		else if (T_val[i]==1){
			if (T[i]>A[i]){
				cout << "0" << endl;
				return 0;
			}
		}
		else if (A_val[i]==1){
			if (A[i]>T[i]){
				cout << "0" << endl;
				return 0;
			}
		}

		else if (T_val[i]==0 && A_val[i]==0){
			long long mul=0;
			mul=min(T[i], A[i])%div;
			ans = ans * mul;
			ans = ans%div;
		}
	}
	cout << ans<<endl;

	return 0;
}


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

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    double L;
    cin>>L;

    cout<<fixed<<setprecision(10)<<L*L*L/27<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
namespace mint {
  constexpr int md = 1'000'003;
  inline void add (int &a, int b) {
    a += b; if (a >= md) a -= md;
  }
  inline void sub (int &a, int b) {
    a -= b; if (a < 0) a += md;
  }
  inline int sum (int a, int b) {
    add(a, b); return a;
  }
  inline int dif (int a, int b) {
    sub(a, b); return a;
  }
  template<class... A>
  inline int prod (A... args) {
    long long ret = 1;
    for (int a : initializer_list<int>{args...}) {
      assert(a >= 0);
      ret *= a;
      ret %= md;
    }
    return (int)(ret % md);
  }
  inline void mul (int &a, int b) {
    a = prod(a, b);
  }
  inline int inv (int a) {
    a %= md;
    if(a < 0) a += md;
    int b = md, u = 0, v = 1;
    while (a) {
      int t = b / a;
      b -= a * t; swap(a, b);
      u -= v * t; swap(u, v);
    }
    assert(b == 1);
    if(u < 0) u += md;
    return u;
  }
  inline int quat (int a, int b) {
    return prod(a, inv(b));
  }
  inline void div (int& a, int b) {
    a = quat(a, b);
  }
  inline int pow (int a, long long b) {
    int res = 1;
    for (; b; b >>= 1) {
      if (b & 1) mul(res, a);
      mul(a, a);
    }
    return res;
  }
  namespace factorials {
    int sz;
    vector<int> fact, finv;
    void init (int n) {
      sz = n;
      fact.resize(n); finv.resize(n);
      fact[0] = 1;
      for (int i = 1; i < n; i++) fact[i] = prod(fact[i - 1], i);
      finv[n - 1] = inv(fact[n - 1]);
      for (int i = n - 2; i >= 0; i--) finv[i] = prod(finv[i + 1], i + 1);
    }
  }
  inline int fct (int i) {
    using namespace factorials;
    assert(0 <= i && i < sz);
    return fact[i];
  }
  inline int fnv (int i) {
    using namespace factorials;
    assert(0 <= i && i < sz);
    return finv[i];
  }
  inline int binom (int n, int k) {
    using namespace factorials;
    assert(0 <= n && n < sz);
    if (0 < k || n < k) return 0;
    return prod(fact[n], finv[k], finv[n - k]);
  }
}
template<typename T>
class fixed_point : T {
  public:
    explicit constexpr fixed_point (
        T&& t
      ) noexcept
      : T(forward<T>(t))
      {
      }
    template<typename... Args>
    constexpr decltype(auto)
    operator()(
        Args&&... args
      ) const
      {
        return T::operator()(*this, forward<Args>(args)...);
      }
};
template<typename T>
static inline constexpr decltype(auto)
  fix (T&& t) noexcept {
    return fixed_point<T>{forward<T>(t)};
  }
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int q;
  cin >> q;
  mint::factorials::init(mint::md);
  auto cal = fix([&] (auto cal, int x, int d, int n) -> int {
    if (d == 0) return mint::pow(x, n);
    if (d != 1) return mint::prod(
        mint::pow(d, n),
        cal(mint::quat(x, d), 1, n)
      );
    if (x == 0 || mint::md <= x + n - 1) return 0;
    return mint::prod(mint::fct(x + n - 1), mint::fnv(x - 1));
  });
  while (q--) {
    int x, d, n;
    cin >> x >> d >> n;
    cout << cal(x, d, n) << endl;
  }
  return 0;
}

Measured memory_bytes: 10496
/*------------------------Original Copyright belongs to-------------------------/
!      																			!
!      ##  ##                                                		##  ##	    !
!      #   #             											#   #		!		                
!      				 ###  ####  ###   ###     ##         #                      !
!					#     #  #  #  #  #  #   #  #       ##                      !
!					#	  #  #  ###   ###    ####        #                      !
!					#     #  #  #  #  #  #   #  #        #                      !
!					 ###  ####  ###   #   #  #  #  ###  ### 			        !
!                                                                               !
/------------------------------------------------------------------------------*/
#include<bits/stdc++.h>
using namespace std;
//------------Template begins--------------------//
#define ss string
#define last(s) s.length()-1
#define lli long long int
#define v(type) vector<type>
#define pr(type1,type2) pair<type1,type2>
#define ma(type1,type2) map<type1,type2>
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define L(i,start,end) for(lli i=start;i<=end;i++)
#define R(i,start,end) for(lli i=start;i>=end;i--)
#define inp(var,start,end,array) for(var=start;var<=end;var++) cin>>array[var];
#define whatIs(x) cout<<#x<<" is "<<x<<endl
#define dbg1D(i,start,end,arr) for(lli i=start;i<=end;i++) cout<<i<<"th : "<<arr[i]<<endl;
#define dbg2D(i,j,s1,e1,s2,e2,arr) for (lli i=s1;i<=e1;i++) {cout<<i<<"th :"; for(lli j=s2;j<=e2;j++)cout<<arr[i][j]<<" ";cout<<endl;}

lli dx[4]={-1, 0, 0, +1};
lli dy[4]={0, -1, +1, 0};
const lli LINF = 1e18;
const lli INF = 1e9;
const lli mod = 1e9+7;
lli power(lli a,lli b,lli m){ if(b==0) return 1; if(b==1) return a%m;
 		lli t=power(a,b/2,m); t=(t*t)%m; if(b&1) t=(t*a)%m; return t;}
lli modInverse(lli a, lli m) { return power(a, m-2, m); }
//---------------Template ends------------------//
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	//freopen("ip.txt","r",stdin);
	//freopen("op.txt","w",stdout);
	#endif
//#################### CATCH HERE ##########################
   	/* Uncomment if t test cases
	lli t;
	cin>>t;
	while(t--)
	{
		lli n,ans,i,j;

		cout<<ans<<endl;
	}
	*/
	lli n,i,x=0;
	ss s;
	cin>>s;
	L(i,0,s.length()-1)
	{
		if(s.at(i)=='x')
			x++;
	}
	if(x<=7)
		cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

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

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

typedef unsigned long long ull;
 
mt19937_64 r(std::chrono::high_resolution_clock::now().time_since_epoch().count());

ull const MASK30 = (1<<30)-1;
ull const MASK31 = INT_MAX;
ull const MOD = (1LL<<61)-1;
ull const MOD5 = MOD*5;
ull const base = r()%MOD;
 
struct RollingHash {
private:
    vector<ull> power,hash;
public:
    inline ull mul(ull a,ull b) {
        ull au = a>>31;
        ull ad = (a&MASK31);
        ull bu = b>>31;
        ull bd = (b&MASK31);
        ull mid = au*bd+ad*bu;
        return ((au*bu)<<1)+ad*bd+(mid>>30)+((mid&MASK30)<<31);
    }

    inline ull calcmod(ull a) {
        a = (a&MOD)+(a>>61);
        if (a > MOD) a -= MOD;
        return a;
    }

    RollingHash(string& s) {
        int n = s.size();
        power.resize(n+1);
        hash.resize(n+1);
        power[0] = 1;
        hash[0] = 0;
        for (int i = 0;i < n;++i) power[i+1] = calcmod(mul(power[i],base));
        for (int i = 0;i < n;++i) hash[i+1] = calcmod(mul(hash[i],base)+s[i]);
    }

    ull get(int l, int r)  {
        if (l) return calcmod(hash[r]+MOD5-mul(hash[l],power[r-l]));
        return hash[r];
    }
 
 
    ull connect(ull h1,int l,int r) {
        ull h2 = get(l,r);
        return calcmod(mul(h1,power[r-l])+h2);
    }
 
    int LCP(int l1,int r1,RollingHash& rh,int l2,int r2) {
        int ok = 0,ng = min(r1-l1,r2-l2)+1;
        while (ng-ok > 1) {
            int mid = (ok+ng)/2;
            if (get(l1,l1+mid) == rh.get(l2,l2+mid)) ok = mid;
            else ng = mid;
        }
        return ok;
    }
};

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    RollingHash rh(s);
    for (int i = 0;i < n-1;++i) for (int j = i+1;j < n;++j) {
        ans = max(ans,min(j-i,rh.LCP(i,j,rh,j,n)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
	ll ch2[3]={};
int main() {
	ll n;
	cin>>n;
	ll ch[100010];

	for(ll i=0;i<n;i++){
		cin>>ch[i];
	}
	ll ans=1;
	for(ll i=0;i<n;i++){
		ll cnt=0;
		ll now=ch[i];
		ll num=1;
		for(ll j=0;j<3;j++){
		 if(now==ch2[j]){
		 	ch2[j]+=num;
		 	num--;
		 	num=max(ll(0),num);
		 	cnt++;
		 }
		}
		ans*=cnt;
		ans%=inf;
	}
	cout<<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 4360
fn main() {
    let mut reader = acio::Reader::new();
    let x = reader.read::<u8>();
    let a = reader.read::<u8>();
    if a <= x {
        print!("1");
    }
    println!("0");
}

/// IO Module for AtCoder
#[allow(dead_code)]
mod acio {
    use std::fmt::Debug;
    use std::io::{stdin, Stdin};
    use std::str::FromStr;

    pub struct Reader {
        input: Stdin,
        stack: Vec<String>,
    }

    impl Reader {
        pub fn new() -> Self {
            Reader {
                input: stdin(),
                stack: vec![],
            }
        }

        pub fn read_by<F>(&mut self, count: usize) -> Vec<F>
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            let mut v = vec![];
            for _ in 0..count {
                v.push(self.read());
            }
            return v;
        }

        pub fn read<F>(&mut self) -> F
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            if self.stack.is_empty() {
                let mut line = self.read_line();
                self.stack.append(&mut line);
                self.stack.reverse();
            }
            self.stack.pop().unwrap().parse().unwrap()
        }

        fn read_line(&mut self) -> Vec<String> {
            let mut buf = String::new();
            self.input.read_line(&mut buf).unwrap();
            buf.split_whitespace().map(|s| s.to_string()).collect()
        }
    }
}


Measured memory_bytes: 4352
/**
 *      ABC 49 C
 *      author  : kyomukyomupurin
 *      created : 2018-10-08 21:58:41
**/

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define int64 long long
using namespace std;

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

    while (1){
        if (S.empty()){
            cout << "YES" << endl; return 0;
        }
        else if ((int) S.size() == 5){
            if (S == "dream" || S == "erase"){
                cout << "YES" << endl; return 0;
            }
            else {
                cout << "NO" << endl; return 0;
            }
        }
        else if ((int) S.size() == 6){
            if (S == "eraser"){
                cout << "YES" << endl; return 0;
            }
            else {
                cout << "NO" << endl; return 0;
            }
        }
        else if ((int) S.size() == 7){
            if (S == "dreamer"){
                cout << "YES" << endl; return 0;
            }
            else {
                cout << "NO" << endl; return 0;
            }
        }
        else if ((int) S.size() <= 4){
            cout << "NO" << endl; return 0;
        }
        else if (S.substr((int) S.size() - 5, 5) == "dream" || S.substr((int) S.size() - 5, 5) == "erase"){
            for (auto i = 0; i < 5; ++i) {
                S.pop_back();
            }
        }
        else if (S.substr((int) S.size() - 6, 6) == "eraser"){
            for (auto i = 0; i < 6; ++i) {
                S.pop_back();
            }
        }
        else if (S.substr((int) S.size() - 7, 7) == "dreamer"){
            for (auto i = 0; i < 7; ++i) {
                S.pop_back();
            }
        }
        else {
            cout << "NO" << endl; return 0;
        }
    }
    
    return 0;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll x, y, flag = 0, minVal, maxVal ;
    cin >> x >> y ;
    minVal = x * 2, maxVal = x * 4 ;

    for (int i = minVal; i <= maxVal; i += 2) {
        if (i == y) flag = 1 ;
    }
    if (flag)   cout << "Yes" ;
    else    cout << "No" ;



    return 0 ;
}


Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
using namespace std;
 
using ll = long long;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  
  ll da = (a - a / 2) * b * c - a / 2 * b * c;
  ll db = (b - b / 2) * a * c - b / 2 * a * c;
  ll dc = (c - c / 2) * a * b - c / 2 * a * b;
  
  cout << min(da, min(db, dc)) << endl;
  
  return 0;
}

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

using namespace std;

const string IOI = "IOI";
const string JOI = "JOI";

int main(){
	while(1){
		string str;
		cin >> str;
		
		if(str == "")break;
		
		int ioicnt = 0;
		int joicnt = 0;
		int len = str.length();

		for(int i=0;i<len;i++){
			if(str[i] == IOI[0]){
				if(i+1 < len && i+2 < len && str[i+1] == IOI[1] && str[i+2] == IOI[2]){
					ioicnt++;
				}
				else if(i+1 < len && str[i+1] == JOI[0]){
					i++;
					goto JOI;
				}
			}
			else if(str[i] == JOI[0]){
				JOI:
				if(i+1 < len && i+2 < len && str[i+1] == JOI[1] && str[i+2] == JOI[2]){
					joicnt++;
					i++;
				}
			}
		}


		cout << joicnt << endl;

		cout << ioicnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
class EqualCutter
  attr_accessor :arr, :culm
  attr_accessor :left, :center, :right
  def initialize(arr)
    @arr = arr
    @left = 0
    @center = 1
    @right = 2
    @culm = [arr[0]]
    (1..arr.size() - 1).each do |i|
      @culm[i] = @culm[i - 1] + arr[i]
    end
  end

  def p
    @culm[@left]
  end

  def nextP
    @culm[@left+1]
  end

  def q
    @culm[@center] - @culm[@left]
  end

  def nextQ
    @culm[@center] - @culm[@left+1]
  end

  def r
    @culm[@right] - @culm[@center]
  end

  def nextR
    @culm[@right+1] - @culm[@center]
  end

  def s
    @culm[@arr.size() - 1] - @culm[@right]
  end

  def nextS
    @culm[@arr.size() - 1] - @culm[@right+1]
  end

  def leftIncrementable
    (p - q).abs > (nextP - nextQ).abs && @left+1 < @center
  end

  def rightIncrementable
    (r - s).abs > (nextR - nextS).abs && @right+1 < @arr.size() - 1
  end

  def diff
    [p, q, r, s].max - [p, q, r, s].min
  end

  def print
    puts("left: #{@left}, center: #{@center}, right: #{@right}")
    puts("p: #{p}, q: #{q}, r: #{r}, s: #{s}")
  end
end

n = gets().chomp().to_i()
arr = gets().chomp().split().map!(&:to_i)

diff = 1000000001

ec = EqualCutter.new(arr)

(1..n - 3).each do |center|
  ec.center = center
  while(ec.leftIncrementable) do
    ec.left += 1
  end
  
  while(ec.rightIncrementable) do
    ec.right += 1
  end

  diff = ec.diff if diff > ec.diff
end

puts diff


Measured memory_bytes: 23388
class SegmentTree:
    seg_len = 1
    node = []
    def __init__(self, n):
        while self.seg_len < n:
            self.seg_len <<= 1
        self.node = [ 0 for _ in range(self.seg_len*2) ]

    def add(self, l, r, x):
        l += self.seg_len
        r += self.seg_len
        while l < r:
            if l & 1 == 1:
                self.node[l] += x
                l += 1
            if r & 1 == 1:
                self.node[r-1] += x
                r -= 1
            l >>= 1; r >>= 1;

    def get(self, idx):
        idx += self.seg_len
        ret = self.node[idx]
        while True:
            idx >>= 1
            if idx == 0:
                break
            ret += self.node[idx]
        return ret

n, q = map(int, input().split())
seg_tree = SegmentTree(n)

for _ in range(q):
    query = [ int(x) for x in input().split() ]
    if len(query) == 4:
        _, l, r, x = query
        l -= 1; r -= 1
        seg_tree.add(l, r+1, x)
    if len(query) == 2:
        _, i = query
        i -= 1;
        print(seg_tree.get(i))




Measured memory_bytes: 11008
#include <iostream>
using namespace std;
const int Mod = 998244353;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% Mod + Mod) % Mod) {};
	void operator - () {
		x = (-x % Mod + Mod) % Mod;
	}
	void operator += (const mll& a) {
		if ((x += a.x) >= Mod) x -= Mod;
	}
	void operator ++ () {
		*this += 1;
	}
	void operator ++(int) {
		operator++();
	}
	void operator -= (const mll& a) {
		if ((x += Mod - a.x) >= Mod) x -= Mod;
	}
	void operator *= (const mll& a) {
		(x *= a.x) %= Mod;
	}
	mll operator + (const mll& a) const {
		mll ans = *this;
		ans += a;
		return ans;
	}
	mll operator - (const mll& a) const {
		mll ans = *this;
		ans -= a;
		return ans;
	}
	mll operator * (const mll& a) const {
		mll ans = *this;
		ans *= a;
		return ans;
	}
	bool operator < (const mll& a) {
		return this->x < a.x;
	}
	void pow(long long n) {
		long long xx = x;
		x = 1;
		while (n > 0) {
			if (n & 1) x = x * xx % Mod;
			xx = xx * xx % Mod;
			n >>= 1;
		}
	}
	mll inv() {
		long long a = x, b = Mod, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= Mod;
		if (u < 0) u += Mod;
		a = u;
		return mll(a);
	}
};
int main() {
	int N, M, K;
	cin >> N >> M >> K;
	mll ans = 0, C = 1;
	for (int i = 0; i <= K; i++) {
		mll now = M;
		mll a = M - 1;
		a.pow(N - i - 1);
		if (i > 0) {
			C *= N - i;
			mll b = i;
			C *= b.inv();
		}
		now *= a;
		now *= C;
		ans += now;
	}
	cout << ans.x << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    string ans = "";
    REP(i,N) {
        cin >> A[i];
        if (i >= K) {
            ans += (A[i] > A[i-K]) ? "Yes\n" : "No\n";
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 5028
#include<stdio.h>
#include<math.h>

struct Point{ double x,y;};

void koch(int n, Point a,Point b){
    if(n==0) return;
    Point s,t,u;
    double th = M_PI * 60.0 /180.0; //度からラジアンへ単位を変換

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,b);
}

int main(){
    Point a,b;
    int n;
    scanf("%d", &n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);

    return 0;
}


Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5;
int main(){
	int n,s=0;
	int a[10],b[10];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
	for(int i=0;i<n;i++)
        scanf("%d",&b[i]);
    if(a[0]>b[0])
        swap(a,b);
    while(1){
        int j;
        for(j=0;j<n;j++)
            if(a[j]!=b[j])
                break;
        if(j==n)  break;
        next_permutation(a,a+n);
        s++;
        //for(int i=0;i<n;i++)printf("%d ",a[i]);puts("");
    }
	printf("%d\n",s);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll K;

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

  queue<ll> q;
  for (int i = 1; i < 10; i++) {
    q.push(i);
  }
  ll cnt = 0;
  ll ans = 0;
  while (cnt != K) {
    ll v = q.front();
    q.pop();
    ans = v;
    cnt++;
    if (v % 10 != 0) {
      q.push(v * 10 + (v % 10) - 1);
    }
    q.push(v * 10 + (v % 10));
    if ((v % 10) + 1 != 10) {
      q.push(v * 10 + (v % 10) + 1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
    int f=1;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            f=0;
    }
    if(f)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int ans;
  
  for(int i = 0; i < N; i++) {
    int h;
    cin >> h;
    if(h >= K) {
      ans++;
    }
  }
  
  cout << ans;
}

Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))
ans = -1

for t in range(n - 1):
    a = 0
    b = 0
    for i in range(t + 1):
        a += w[i]
    for i in range(t + 1, n):
        b += w[i]
    if ans == -1:
        ans = abs(a - b)
    else:
        if ans > abs(a - b):
            ans = abs(a - b)
        else:
            pass

print(ans)


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int H,A;
    cin >> H >> A;
    
    for (int i = 0; i < 100000; i++){
        if ((H - A * i) <= 0){
            cout << i ;
            break;
        }
        
    }
    cout << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
    var n int
    fmt.Scanf("%d", &n)

    var gacha []string
    var sc = bufio.NewScanner(os.Stdin)
    for {
        sc.Scan()
        if sc.Text() == "" {
            break
        }
        gacha = append(gacha, sc.Text())
    }

    res := make(map[string]int)
    for i := 0; i < n; i++ {
        res[gacha[i]] += 0
    }

    fmt.Printf("%d\n", len(res))
}


Measured memory_bytes: 27124
import numpy as np
N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
F = np.array(input().split(), dtype=np.int64)
A = np.sort(A)
F = np.sort(F)[::-1]


def C(x):
    train = np.maximum(0, A - x // F).sum()
    return train <= K


left = -1
right = 10 ** 12 + 1
while right > left + 1:
    mid = (right + left) // 2
    if C(mid):  # 食べきれる場合
        right = mid
    else:
        left = mid

ans = right
print(ans)


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

using namespace std;



int main() {
	long long k = 7, mod; cin >> mod;
	int cnt = 0;
	while(1) {
		k = k % mod; cnt++;
		if(!k) break;
		if(cnt > 1000000) break;
		k = k * 10 + 7;
	}
	if(cnt > 1000000) cnt = -1;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
 
  vector <string> a,b;
  string tmp;
  int n,i;
 
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>tmp;
    a.push_back(tmp);
  }

  b.assign(a.begin(),a.end());

  for(i=0;i<n-1;i++)
  {
   for(int j=n-2;j!=i-1;j--) 
   {
    if(a[j][1]>a[j+1][1])
    {
     swap(a[j],a[j+1]);
    }
   }
  }

  for(i=0;i<n-1;i++)
  {
   cout<<a[i]<<" ";
  }
  cout<<a[n-1]<<endl<<"Stable"<<endl;
 
  for(i=0;i<n-1;i++)
  {
    int now,minnum=101;
    for(int j=i;j<n;j++)
    {
      if(minnum>b[j].at(1)-'0')
      {
        now=j;
        minnum=b[j].at(1)-'0';
      }
    }
    if(i!=now)  swap(b[i],b[now]);
  }
 
  for(i=0;i<n-1;i++)
  {
    cout<<b[i]<<" ";
  }

  cout<<b[n-1]<<endl;

  if(a==b)
  {
   cout<<"Stable"<<endl;
  }else{
    cout<<"Not stable"<<endl;
  }

  return 0;
 
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}

map<int,int> prime_fac(int n){
  map<int,int> ret;
  for(int i=2;i*i<=n;i++){
    while(n%i==0){
      ret[i]++;
      n/=i;
    }
  }
  if(n!=1)ret[n]=1;
  return ret;
}


signed main(){
  int n;
  cin>>n;
  map<int,int> ans=prime_fac(n);
  cout<<n<<':';
  for(auto x:ans){
    rep(i,x.second)cout<<' '<<x.first;
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int a1,b1;
char n[1002][1002];
int b[1002][1002],sum=0;
int main()
{
	cin>>a1>>b1;
    for(int i=1;i<=a1;i++)
    for(int j=1;j<=b1;j++)
    {
    	cin>>n[i][j];
	}
	for(int i=1;i<=a1;i++)
    for(int j=1;j<=b1;j++)
    {
    	if(n[i][j]=='#')
    	{
			b[i+1][j]++;
			b[i+1][j+1]++;
			b[i+1][j-1]++;
			b[i][j-1]++;
			b[i][j+1]++;
			b[i-1][j-1]++;
			b[i-1][j]++;
			b[i-1][j+1]++;
		}
	}
	for(int i=1;i<=a1;i++)
	{
		for(int j=1;j<=b1;j++)
        {
			if(n[i][j]=='#')
			{
			    cout<<'#';
		    }
			else
			{
			    cout<<b[i][j];
			}
	    }
	    cout<<endl;
	}
    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());

            long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();


            var ls = new List<long>();
            ls.AddRange(s);
            ls.Sort();

            var before = ls[(n / 2) - 1];
            var after = ls[n / 2];
            for (int i = 0; i < n; i++)
            {
                if (s[i] > before)
                {
                    WriteLine(before);
                }
                else WriteLine(after);
            }
        }
        
    }



}

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

using namespace std;

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

vector<string> board(80);
string memo[80][80];
int W, H;

inline bool isDigit(int x, int y)
{
    if ('0' <= board[y][x] && board[y][x] <= '9')
        return true;
    else
        return false;
}

string Rec(int x, int y)
{
    if (memo[y][x].size() != 0)
        return memo[y][x];

    string s, tmp;
    for (int d = 0; d < 2; ++d) {
        int nx = x + dx[d];
        int ny = y + dy[d];

        if (nx < 0 || nx >= W || ny < 0 || ny >= H || !isDigit(nx, ny))
            continue;

        tmp = Rec(nx, ny);
        if (tmp.size() > s.size() || (tmp.size() == s.size() && tmp > s))
            s = tmp;
    }

    return memo[y][x] = board[y][x] + s;
}

int main()
{
    while (cin >> W >> H, W || H) {
        // Input
        for (int i = 0; i < H; ++i)
            cin >> board[i];

        // Init
        for (int i = 0; i < H; ++i)
            for (int j = 0; j < W; ++j)
                memo[i][j] = "";

        // Solve
        string tmp, ans;
        for (int i = 0; i < H; ++i)
            for (int j = 0; j < W; ++j)
                if (isDigit(j, i) && memo[i][j].size() == 0) {
                    tmp = Rec(j, i);
                    int index = 0;
                    while (tmp[index] == '0')
                        index++;
                    tmp = tmp.substr(index);

                    if (tmp.size() > ans.size() || (tmp.size() == ans.size() && tmp > ans))
                        ans = tmp;
                }

        // Output
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1396