akhauriyash/Code-Regression huggingface dataset:
N = int(input()) - 1

x = 26
c = 0
while N >= x :
  N -= x
  x *= 26
  c += 1

ret = []
while c >= 0 :
  y = N % 26
  N //= 26
  c -= 1
  ret.append(chr(ord('a') + y)) 

ret = ret[::-1]
print(''.join(ret))

Measured memory_bytes: 61668
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int main() {
    int a, b, c;
    unordered_map<int, int> mp;
    cin >> a >> b >> c;
    mp[a]++, mp[b]++, mp[c]++;
    each(m, mp) {
        if (m.second == 1) {
            cout << m.first << endl;
            return 0;
        }
    }
    return 0;
}

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

#define int        long long
// #define mp      make_pair
#define eb         emplace_back
#define pb         push_back
#define ss         second
#define ff         first
#define IOS        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod        998244353
#define MOD        (1000*1000*1000+7)
#define MN         LLONG_MIN
#define MX         LLONG_MAX
#define v1d        vector<int>
#define v2d        vector<vector<int>>
#define vip        vector<pair<int,int> >
#define v1s        vector<string>
#define pa         pair<int,int>
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define print(v)   for(auto i:v)cout<<i<<" ";cout<<"\n";
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)     for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)     for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define endl       "\n"
#define input(b,n) for(int i=0;i<n;i++)cin>>b[i];
#define Sort(v)    sort(v.begin(),v.end())
#define RSort(v)   sort(v.rbegin(),v.rend())
#define all(v)     v.begin(),v.end()
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//string s = bitset<64>(a).to_string();
int lb = 1000;
#define Exit    lb--;if(lb<0){cout<<"exit";exit(0);}

void azmuth(int n=12){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout<<setprecision(n)<<fixed;
	#ifndef ONLINE_JUDGE
		 freopen("input.txt",  "r",  stdin);
		 freopen("output.txt", "w", stdout);
	#endif
}

//____________________________________________________________________________________


void solve(){
	int n;cin >> n;
	int ans = 0;
	for(int i=2;i<=10000000;i++){
		if(n%i == 0){
			int cnt = 0;
			while(n && n%i == 0){
				cnt ++ ;
				n /= i;
			}
			for(int p=30;p>=1;p--){
				if(p*(p+1)/2 <= cnt){
					ans += p;break;
				}
			}
		}
	}
	ans += n > 1;
	cout << ans;
}

int32_t main(){
	azmuth();
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
	}
	


	return 0;
}

Measured memory_bytes: 3648
n = int(input())

start = []
end = []

for i in range(n):
    a, b = map(int, input().split())
    start.append(a)
    end.append(b)

start.sort()
end.sort()

if n % 2 == 1:
    print(end[n // 2] - start[n // 2] + 1)
else:
    print(end[n // 2 - 1] + end[n // 2] - start[n // 2 - 1] - start[n // 2] + 1)


Measured memory_bytes: 25560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
 
const ll INF = 1ll<<60;
 
int main() {
  int n;
  cin >> n;
  vector<ll> s(n);
  rep(i,n) cin >> s[i];
  ll ans = 0;
  for (int c = 1; c < n; ++c) {
    ll score = 0;
    vector<bool> f(n);
    for (int x = 0; (x+1)*c < n-1 ; ++x) {
      int l = x*c, r = n-1-l; 
      if ( f[l] ) break;
      score += s[l], f[l] = true;
      if ( f[r] ) break;
      score += s[r], f[r] = true;
      ans = max(ans,score);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3972
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <numeric>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int main(void){
  int n,m;
  while(cin>>n>>m){
    if(n==0) break;
    vector<int> taro(n);
    vector<int> hanako(m);
    REP(i,n)cin>>taro[i];
    REP(i,m)cin>>hanako[i];
    sort(taro.begin(),taro.end());
    sort(hanako.begin(),hanako.end());
    int s1 = accumulate(taro.begin(),taro.end(),0);
    int s2 = accumulate(hanako.begin(),hanako.end(),0);
    bool output = false;
    if((s1-s2)%2){
      cout<<-1<<endl;
      continue;
    }
    for(int i=0; i<taro.size(); i++){
      vector<int>::iterator it = find(hanako.begin(),hanako.end(),
          taro[i]-(s1-s2)/2);
      if(it!=hanako.end()){
        printf("%d %d\n",taro[i],*it);
        output=true;
        break;
      }
    }
    if(!output) cout<<-1<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vector<vector<P>> g(n);
  rep(i, n) {
    ll a;
    cin >> a;
    rep(j, a) {
      P p;
      cin >> p.first >> p.second;
      p.first--;
      g[i].push_back(p);
    }
  }
  ll ans = 0;
  rep(i, 1 << n) {
    vl s(n, -1);
    bool ok = true;
    vl t(n, 0);
    rep(j, n) {
      if(i >> j & 1) {
        t[j] = 1;
        for(auto v : g[j]) {
          ll x = v.first;
          ll y = v.second;
          if(s[x] != y && s[x] != -1) ok = false;
          s[x] = y;
        }
      }
    }
    rep(k, n) {
      rep(j, n) {
        if(s[j] == 1) {
          for(auto v : g[j]) {
            ll x = v.first;
            ll y = v.second;
            if(s[x] != y && s[x] != -1) ok = false;
            s[x] = y;
          }
        }
      }
    }
    rep(j, n) if(t[j] == 1 && s[j] == 0) ok = false;
    if(ok) ans = max(ans, ll(accumulate(all(t), 0)));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <string>
    #include <cmath>
    #include <iomanip>
    #include <numeric>
     
    using namespace std;
     
    #define FOR(i, a, b) for (int i = (a); i < (b); i++)
    #define REP(i, n) FOR(i, 0, n)
    #define SORT(c) sort((c).begin(), (c).end())
    #define INF (ll)1e18
    #define MOD (ll)1e9 + 7
     
    typedef long long ll;
    typedef pair<int, int> P;
    typedef vector<int> V;
    typedef map<int, int> M;
    int main()
    {
        int a,b,c,x,y;
        cin>>a>>b>>c>>x>>y;
        int m=(int)1e9;
        for(int i=0;i<100001;i++){
            m=min(m,i*2*c+a*max(0,x-i)+b*max(0,y-i));
        }
        cout<<m<<endl;
        return 0;
    }


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{
    int i,x=0;
    string s;
    cin>>s;
    for(i=0; i<s.length(); i++)
    {
        if((i+1)%2!=0)
        {
            if(s[i]!='R'&&s[i]!='U'&&s[i]!='D')
            {
                x=1;
                cout<<"No"<<endl;
                break;
            }
        }
        else
        {
            if(s[i]!='L'&&s[i]!='U'&&s[i]!='D')
            {
                x=1;
                cout<<"No"<<endl;
                break;
            }
        }
    }
    if(x==0)
        cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
t,a = map(int, input().split())
li = list(map(int, input().split()))
li_2 = []

for i in range(n):
    li_2.append(abs(a - t +li[i] *0.006))
    
x = li_2.index(min(li_2)) + 1
print(x)

Measured memory_bytes: 3060
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int n, m;
	char a[50][50], b[50][50];
	bool isincluded = true;
	scanf("%d%d", &n, &m);
	rep(i, n)scanf("%s", a[i]);
	rep(i, m)scanf("%s", b[i]);

	rep(i, n - m + 1) {
		rep(j, n - m + 1) {
			rep(k, m) {
				rep(l, m) {
					if (a[i + k][j + l] != b[k][l])isincluded = false;
				}
			}
			if (isincluded) {
				printyn(isincluded);
				return 0;
			}else isincluded = true;
		}
	}

	printyn(false);

	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
#define P 1000000007

using namespace std;

int n, m, F[2222][2222], B[2222][2222], C[2222][2222], L[2222], R[2222], Fac2[2222], ans = 0;

int powmod(int x, int y = P - 2, int p = P) {
    int ans = 1;
    while(y) {
        if(y & 1) ans = ans * x % p;
        x = x * x % p;
        y >>= 1;
    }
    return ans;
}

signed main() {
    scanf("%lld%lld", &n, &m);
    n *= 2;
    for(int i = 1; i <= n; i++)
        for(int j = i; j < i + n; j++)
            B[i][j] = 1;
    Fac2[0] = 1;
    Fac2[1] = 1;
    for(int i = 2; i <= n; i++) Fac2[i] = Fac2[i - 1] * (i * 2 - 1) % P;
    for(int i = 1; i <= m; i++) {
        scanf("%lld%lld", &L[i], &R[i]);
        if(L[i] > R[i]) swap(L[i], R[i]);
        for(int I = 1; I <= L[i]; I++)
            for(int j = L[i] + 1; j < R[i]; j++)
                B[I][j] = 0;
        for(int I = L[i] + 1; I < R[i]; I++)
            for(int j = R[i]; j <= n; j++)
                B[I][j] = 0;
        for(int I = 1; I < L[i]; I++) B[I][L[i]] = 0;
        for(int j = R[i] + 1; j <= n; j++) B[R[i]][j] = 0;
        for(int I = 1; I <= L[i]; I++)
            for(int j = R[i]; j <= n; j++)
                C[I][j]++;
    }
    for(int g = 1; g < n - 1; g += 2)
        for(int l = 1; l <= n; l++) {
            int r = l + g;
            if(B[l][r] == 0 || r >= n) continue;
            F[l][r] = Fac2[(g + 1) / 2 - C[l][r]];
            for(int i = l + 1; i < r; i += 2)
                if(B[l][i] && B[i + 1][r])
                    F[l][r] = (F[l][r] - F[l][i] * Fac2[(r - (i + 1) + 1) / 2 - C[i + 1][r]]) % P;
            ans = (ans + F[l][r] * Fac2[(n - g - 1) / 2 - (m - C[l][r])]) % P;
        }
    printf("%lld\n", (((ans + Fac2[n / 2 - m]) % P + P) % P));
    return 0;
}

Measured memory_bytes: 35968
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
using namespace std;

int main(void){

    int K, A, B, num;
    int flag = 0;

    cin >> K >> A >> B;

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

    if(flag == 0){
        cout << "NG" << endl;
    }


}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt(),X=sc.nextInt();
		int[] L=new int[N];
		
		for(int i=0;i<N;i++) {
			L[i]=sc.nextInt();
		}
		
		int zahyo=0;
		int count=1;
		
		for(int i=0;i<N;i++) {
			zahyo+=L[i];
			if(zahyo>X) {
				break;
			}else {
				count++;
				
			}
			
		}
		
		System.out.println(count);
		
		
	}
}




Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int R=0,B=0;
  for (int i=0;i<S.length();i++){
    if (S[i]=='0') R++;
    else B++;
  }
  cout << S.length()-(max(R,B)-min(R,B)) << endl;
}


Measured memory_bytes: 512
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <sstream>
#include <cstring>
#include <numeric>
#include <ctime>
#include <cassert>
#include <random>
#include <valarray>
//#include <fstream>
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

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

    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes"<<endl;

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

    return 0;
}

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

long long int N, M, F, S;
 
class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node) return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v) return;
		if (rank[u] < rank[v]) parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v]) rank[u]++;
		}
	}
	bool Check(int u, int v) {
		return Find(u) == Find(v);
	}
};
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> N >> M;
	vector<int> sequence(N);
	rep (i, N) {
		cin >> F;
		F--;
		sequence[i] = F;
	}
	UnionFind uf(N);
	rep (i, M) {
		cin >> F >> S;
		F--, S--;
		uf.Unite(F, S);
	}

	int ans = 0;
	rep (i, N) {
		if (uf.Check(i, sequence[i]))
			ans++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b,c;
    while(cin>>a>>b>>c){
        cout<<((a+b+c)-max(a,max(b,c)))<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N=2000;
typedef long long ll;

struct edge
{
    ll head,w,to;
}ed[10*N];

int tot=1;
ll dis[N];
int num[N];
int n,m;
int vis[N];
ll ans;
void Bellman_ford(int x)
{

    for(int i=0;i<=n;i++) dis[i]=1e18;
    dis[x]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int x=ed[j].head,y=ed[j].to;
            if(dis[y]>dis[x]+ed[j].w){
                dis[y]=dis[x]+ed[j].w;
            }
        }
    }
    ans=dis[n];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int x=ed[j].head,y=ed[j].to;
            if(dis[y]>dis[x]+ed[j].w){
                dis[y]=dis[x]+ed[j].w;
                vis[x]=1;
                vis[y]=1;
            }
        }
    }
}
int main() {

    cin>>n>>m;
    for(int i=1;i<=m;i++){
        ll x,y,z;
        cin>>x>>y>>z;
        ed[i].head=x;
        ed[i].to=y;
        ed[i].w=-z;
    }
    Bellman_ford(1);
    if(vis[n]) puts("inf");
    else cout<<-ans<<endl;
    return 0;
}




Measured memory_bytes: 3596
import java.math.BigDecimal
import java.util.Scanner

fun main(args: Array<String>) {
  val scanner = Scanner(System.`in`)
  val BTCtoJPY = BigDecimal(380000)
  var sum = BigDecimal.ZERO
  for (i in 1..scanner.nextInt()) {
    sum += scanner.nextBigDecimal() * if (scanner.next() == "BTC") BTCtoJPY else BigDecimal.ONE
  }
  scanner.close()
  print(sum)
}

Measured memory_bytes: 31256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrimeNumberGenerator pg = new PrimeNumberGenerator();

		while(true){
			String[] strarray = br.readLine().split(" ");

			int a = Integer.parseInt(strarray[0]);
			int d = Integer.parseInt(strarray[1]);
			int n = Integer.parseInt(strarray[2]);
			
			if(a == 0 && d == 0 && n == 0){
				break;
			}
			
			int primeNum = 0;
			int i = 0;
			while(true){
				if(pg.isPrime(a+i*d)){
					primeNum++;
					if(n == primeNum){
						System.out.println(a+i*d);
						break;
					}
				}
				
				i++;
			}
		}
	}

}

class PrimeNumberGenerator {
    private boolean[] isPrime= new boolean[100000001];
 
    public PrimeNumberGenerator() {
        //Date from = new Date();
        Arrays.fill(isPrime, true);
 
        
        isPrime[0] = false;
        isPrime[1] = false;
        isPrime[2] = true;
 
        for(int i = 3; i <= Math.sqrt( isPrime.length ); i+=2){
            /*
            if(i % 2 == 0){
                isPrime[i] = false;
                continue;
            }
            */
 
            if(isPrime[i] == false){
                continue;
            }
 
            for(int j = i * 2; j <= isPrime.length - 1; j += i){
                isPrime[j] = false;
            }
        }
        //Date to = new Date();
        //System.out.println("init takes "+ (to.getTime() - from.getTime())+ "milli sec");
    }
 
    public boolean isPrime(int index){
        if(index % 2 == 0 && index != 2){
            return false;
        }
        return isPrime[index];
    }
}

Measured memory_bytes: 124284
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			long h = cin.Long();
			long w = cin.Long();

			if (h == 1 || w == 1) {
				Console.WriteLine(1);
				return;
			}

			long odd = (w + 1) / 2;
			long even = w / 2;

			long ans = (h / 2) * (odd + even);
			if (h % 2 != 0) {
				ans += odd;
			}

			Console.WriteLine(ans);
		}

		
	}

	public static class Helper
	{
		public static void UpdateMin32<T>(T array, int index, int value) where T : IList<int>
			=> array[index] = Math.Min(array[index], value);
		public static void UpdateMax32<T>(T array, int index, int value) where T : IList<int>
			=> array[index] = Math.Max(array[index], value);
		public static void UpdateMin64<T>(T array, int index, long value) where T : IList<long>
			=> array[index] = Math.Min(array[index], value);
		public static void UpdateMax64<T>(T array, int index, long value) where T : IList<long>
			=> array[index] = Math.Max(array[index], value);

		public static T[] Array<T>(int n, Func<int, T> init)
			=> Enumerable.Range(0, n).Select(x => init(x)).ToArray();
		public static List<T> List<T>(int n, Func<int, T> init)
			=> Enumerable.Range(0, n).Select(x => init(x)).ToList();
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
    int n, m;
    cin >> n >> m;
    vector<int>box(n, 1), x(m), y(m);
     vector<bool>box2(n, false);
    int cnt = 0;
    rep(i, 0, m){
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    box2[0] = true;
    rep(i, 0, m){
        box[x[i]]--;
        box[y[i]]++;
        if(box2[x[i]]) box2[y[i]] = true;
        if(box[x[i]]==0) box2[x[i]] = false;
    }
    rep(i, 0, n){
        if(box2[i])cnt++;
        //cout << box2[i] << endl;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;
 
#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)
 
typedef long long ll;
 
template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}
 
const int N=2e5+50,P = 998244353;
 
 
int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }
void upd(int &a,int b){ a=add(a,b); }
int powMod(int x, int k) {
	int res = 1;
	for (;k;k >>= 1, x = mul(x, x)) if (k & 1) res = mul(res, x); 
	return res;
}
int inv(int x) { return powMod(x, P - 2); } 
int frac(int a,int b){ return mul(a, inv(b)); }
 
int n,a[N],b[N];
long long ans;
struct F{
bool operator()(int x,int y){return a[x]>a[y];}} fff;
queue<int> Q;
 
void chk(int i){
	int l = (i - 1 + n) % n, r = (i + 1) % n;
	if(a[i]>b[i]&&a[i]-(a[l]+a[r])>=b[i])Q.push(i);
}
 
void calc(int i) {
	int l = (i - 1 + n) % n, r = (i + 1) % n;
	if(a[i]<b[i])return;
	int t = (a[i] - b[i]) / (a[l] + a[r]);
	a[i] -= t * (a[l] + a[r]),ans+=t;
	chk(l),chk(r);
}
 
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("d.in", "r", stdin); 
#endif
	read(n); 
	lop(i,0,n)read(b[i]);
	lop(i, 0, n) read(a[i]); 
	lop(i,0,n)chk(i);
	while(!Q.empty()){
		int t=Q.front();
		Q.pop();
		calc(t);
	//	lop(i,0,n)printf("%d ",b[i]);puts("");
	}
	bool suc=true;
	rep(i,1,n)suc&=a[i]==b[i];
	printf("%lld\n",suc?ans:-1);
	return 0;
}

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

using namespace std;

typedef long long ll;

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

	ll N;
	cin >> N;

	if(N == 1){
		cout << 0 << endl;
		return 0;
	}

	if(N == 2){
		cout << 0 << endl;
		return 0;
	}

	ll ans = 0;
	for(ll d = 1; d * d <= N; d++){
		if(N % d > 0) continue;

		ll x = d-1;
		if(x > 0 && N / x == N % x) ans += x;

		if(d * d == N) continue;
		ll y = N / d - 1;
		if(y > 0 && N / y == N % y) ans += y;
	}

	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll GetCnt(ll n) {
    string s = to_string(n);
    int ret = 0;
    for(int i = s.length()-1; i >= 0; --i) {
        if(s[i] != '0') { break; }
        ret++;
    }
    return ret;
}

ll brute_force2(ll n) {
    ll ret = 0;
    ll cur = 1;
    ll border = 10000000000LL;
    while(n > 2) {
        cur *= n;
        n -= 2;

        ll cnt = GetCnt(cur);
        if(cnt > 0) {
            DBG("cur: %lld n: %lld cnt: %lld\n", cur, n + 2, cnt);
            ret += cnt;
            ll tmp = 1;
            REP(i, cnt) { tmp *= 10; }
            cur /= tmp;
        }
        if(cur > border) {
            cur %= border;
        }
    }
    return ret;
}

ll brute_force(ll n) {
    int cur = 10;
    int ret = 0;

    while(n >= cur) {
        ret += GetCnt(cur);
        cur += 10;
    }

    return ret;
}

ll solve(ll n) {
    ll ret = n / 10;
    n /= 10;
    ll cur = 5;
    while(n >= cur) {
        ret += n / cur;
        cur *= 5;
    }
    return ret;
}

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

    ll N;
    cin >> N;

    if(N % 2 != 0) {
        printf("0\n");
        return 0;
    }

#if 0
    ll ans = brute_force(N);
    printf("b1: %lld\n", ans);
    ans = brute_force2(N);
    printf("b2: %lld\n", ans);
#endif

    ll cand = solve(N);
    printf("%lld\n", cand);

    return 0;
}


Measured memory_bytes: 384
#define REP(i, n) for (int i = 0; i < (n); ++i)

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

signed main() {
  ios::sync_with_stdio(false);
  long long a, b, k;
  cin >> a >> b >> k;
  int ans = 1000;
  for(int i=100;k;i--) {
    if(a % i == 0 && b % i == 0) {
        ans = i;
        k--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
abcd = [int(i) for i in input()]
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = abcd[0]
            res = "" + str(abcd[0])
            if i:
                ans += abcd[1]
                res += "+" + str(abcd[1])
            else:
                ans -= abcd[1]
                res += "-" + str(abcd[1])
            if j:
                ans +=  abcd[2]
                res += "+" + str(abcd[2])
            else:
                ans -=  abcd[2]
                res += "-" + str(abcd[2])
            if k:
                ans +=  abcd[3]
                res += "+" + str(abcd[3])
            else:
                ans -=  abcd[3]
                res += "-" + str(abcd[3])
            if ans == 7:
                print(res+"=7" )
                exit()

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    long MOD = (long)1e9 + 7;

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[][][][] dp = new long[n + 1][5][5][5];
        // 0: null, 1: A, 2: G, 3: C, 4: T
        dp[0][0][0][0] = 1;

        for (int i = 1; i <= n; i++) {
            for (int a = 0; a <= 4; a++) for (int b = 0; b <= 4; b++) for (int c = 0; c <= 4; c++) for (int d = 1; d <= 4; d++) {
                if (d == 3 && c == 2 && b == 1) continue;
                if (d == 3 && c == 1 && b == 2) continue;
                if (d == 2 && c == 3 && b == 1) continue;
                if (d == 3 && c == 2 && b == 4 && a == 1) continue;
                if (d == 3 && c == 4 && b == 2 && a == 1) continue;
                if (d == 3 && c == 2 && b == 2 && a == 1) continue;
                dp[i][d][c][b] += dp[i - 1][c][b][a];
                dp[i][d][c][b] %= MOD;
            }
        }
        long ans = 0;
        for (int a = 0; a <= 4; a++) for (int b = 0; b <= 4; b++) for (int c = 0; c <= 4; c++) {
            ans += dp[n][c][b][a];
            ans %= MOD;
        }

        System.out.println(ans);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

#define REP(i, n) for (int i = 0; i < n; ++i)

int main(void){
    const char c[4] = {'A', 'C', 'G', 'T'};
    string s;
    int cnt = 0, max_cnt = 0;
    bool flg;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    REP(i, s.length()) {
        flg = false;
        REP(j, 4) {
            if (s[i] == c[j]) {
                flg = true;
                cnt++;
            }
        }
        if (!flg) {
            max_cnt = max(max_cnt, cnt);
            cnt = 0;
        }
    }

    cout << max(max_cnt, cnt) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 1e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n, k,q;
  cin >> n >> k>>q;
  vi p(n, k-q);
  rep(i,q){
    ll a;
    cin >> a;
    p[a - 1]++;
  }
  rep(i,n){
    if(p[i]<=0){
      print("No");
    }
    else{
      print("Yes");
    }
  }
}

Measured memory_bytes: 1408
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] g = new int[101];
		while(sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a == 0 && b == 0) {
				boolean flag = true;
				for(int i = 3; i < 101; i++) {
					if(g[i] % 2 == 1) {
						flag = false;
						break;
					}
				}
				if(g[1] % 2 == 0 || g[2] % 2 == 0) {
					flag = false;
				}
				Arrays.fill(g, 0);
				if(flag) {
					System.out.println("OK");
				}else {
					System.out.println("NG");
				}
			}else {
				g[a]++;
				g[b]++;
			}
		}
		sc.close();
	}
}


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

int main(){
int n,m;
cin >> n>>m;
int a[102];
rep(i,n) cin >> a[i];

int sum = 0;
rep(i,n){sum += a[i];}
int count =0;
rep(i,n){
    if(a[i]*4*m>=sum) count +=1;
}
if (count >= m) cout << "Yes" << endl;
else cout << "No" << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test lli t;cin>>t;while(t--)
#define vll vector<lli>
#define mll map<lli,lli>
#define vvll vector<vector<lli>>
#define vpll vector<pair<lli,lli>>
#define vvpll vector<vector<pair<lli,lli>>>
#define mpll map<pair<lli,lli>,lli>
#define pll pair<lli,lli>
#define sll stack<lli>
#define qll queqe<lli>
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define mod 1000000007
#define ma 1000000000000000000
#define mi -1000000000000000000
int main()
{
  #ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
  fastio
 lli n,m,k,i,u,l,ans=0,t,mid;
 cin>>n>>m>>k;
 lli a[n+1],b[m+1],pa[n+1],pb[m+1];
 pa[0]=0;
 pb[0]=0;
 for(i=1;i<=n;i++)
 {
 	cin>>a[i];
    pa[i]=pa[i-1]+a[i];
 }
 for(i=1;i<=m;i++)
 {
 	cin>>b[i];
 	pb[i]=pb[i-1]+b[i];
 }
 l=0;u=n+m;
 while(l<=u)
 {
 	mid=(l+u)/2;
 	t=ma;
 	for(i=0;i<=mid;i++)
 	{
 		if(i<=n&&(mid-i)<=m)
 		{
 			t=min(t,pa[i]+pb[mid-i]);
 		}
 	}
 	
 	if(t==k)
 	{
 		ans=mid;
 		break;
 	}
 	else if(t<k)
 	{
 		ans=mid;
       l=mid+1;
 	}
 	else if(t>k)
 	{
       u=mid-1;
 	}
 }
 cout<<ans;
	return 0;
}


Measured memory_bytes: 9848
#include<iostream>
#include<utility>
using namespace std;
 
int main(){
    
    long long a, n, sum, max, min, i;
    
    cin >> n;
    cin >> a;
    
    sum = max = min =a;
    
    for ( i = 0; i < n-1; i++ ){
        cin >> a;
        sum += a;
        
        if ( max < a ) {
        swap(max ,a);
        }

        if ( min > a ) {
        swap(min ,a);
        }
    }

    cout << min << " " << max << " " << sum << endl;

    return 0;		 
}



Measured memory_bytes: 3104
#include <stdio.h>


int main(void)
{	
	int h, w, i, j;
	
	for( ; ; ){
		scanf(" %d %d", &h, &w );
		if(h==0 && w==0) break;
		
		for(i=0; i<h; i++){
			for(j=0; j<w; j++){
				if(i==0 || i==h-1 || j==0 || j==w-1 ) {
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	
	}
	
	//getchar();
	//getchar();
	return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    string s; cin >> s;
    int m = s.size();
    vl bs(m+1,0),ws(m+1,0);
    rep(i,m){
        bs[i+1] = bs[i]+(s[i]=='#'?1:0);
        ws[i+1] = ws[i]+(s[i]=='.'?1:0);
    }
    ll res = L_INF;
    rep(i,m+1){
        ll cnt = 0;
        cnt += bs[i];
        cnt += ws[m] - ws[i];
        res = min(res,cnt);
    }
    cout << res << endl;
}


Measured memory_bytes: 3860
#include<stdio.h>
int s[5];
int top=0;
void push(int x){
  top ++;
  s[top]=x;
}
int pop(){
  top--;
  return s[top+1];
}

int main(){
  char a[8];
  int c,b;
  while(scanf("%s",a)!=EOF){
    if(a[0]=='+')push(pop()+pop());
    else if(a[0]=='-'){
      c=pop();
      b=pop();
      push(b-c);}
    else if(a[0]=='*')push(pop()*pop());
    else push(atoi(a));
  }
  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin >> x;
  for(int i=0;i<1000;i++){
    for(int j=-999;j<1000;j++){
      long long A = pow(i,5);
      long long B = pow(j,5);
      if(x == A-B){
        cout << i << " " << j << endl;
        return 0;
      } 
    }
  }
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REP1(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << '\n';
const int MOD = (int)1e9 + 7;
const int INF = 1145141919;
using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using l_l = pair<ll, ll>;
using d_d = pair<double, double>;
using vint = vector<int>;

struct unionfindtree {
    vint parent;

    unionfindtree(int n) : parent(n) {
        REP(i, n) {
            parent[i] = i;
        }
    }

    int root(int x) {
        if (parent[x] == x)
            return x;
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y) {
        int rootx = root(x), rooty = root(y);
        if (rootx != rooty)
            parent[rootx] = rooty;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};
int main() {
    int n, m;
    cin >> n >> m;
    vint p(n);
    for (auto &x : p) {
        cin >> x;
        x--;
    }
    unionfindtree uft(n);

    int x, y;
    REP(i, m) {
        cin >> x >> y;
        uft.unite(x - 1, y - 1);
    }
    int ans = 0;
    REP(i, n) {
        if (uft.same(i, p[i]))
            ans++;
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int n, d, x,sum=0;
	cin >> n >> d >> x;
	vector<int>a(n);
	for (int& t : a)cin >> t;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j*a[i]+1 <= d; j++) {
			sum += 1;
		}
	}
	cout << x+sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 1000000007
#define MAXN 51
#define MAXC 100000000000014
#define MAXV 1000000009

int h, w;
char s[MAXN][MAXN];
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}, rec;


int main()
{
    cin >> h >> w;
    REP(i, 0, h){
        REP(j, 0, w){
            cin >> s[i][j];
        }
    }
    REP(i, 0, h){
        REP(j, 0, w){
            rec = 0;
            if(s[i][j] == '#'){
                REP(k, 0, 4){
                    int nx = i + dx[k];
                    int ny = j + dy[k];
                    if(0 <= nx && nx < h && 0 <= ny && ny < w){
                        if(s[nx][ny] == '#')rec++;
                        //printf("%d %d rec++\n", nx, ny);
                    }
                }
                if(rec == 0){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}













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

int main(){
  int a, b;
  cin >> a >> b;
  int coin = 0;
  
  for(int i = 0; i < 2; i++){
    coin += max(a, b);
    if(a > b) a--;
    else b--;
  }
  
  cout << coin << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(b==1)
        printf("0");
    else
    {
        int ans = 1;
        int num = b-a;
        if(num)
            ans += num/(a-1);
        if(a+(ans-1)*(a-1)<b)
            ans++;
        printf("%d",ans);
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()


int main(){
  ll N,L,t=-1;
  cin >> N >> L;
  vector<ll> A(N);
  rep(i,N) cin >> A.at(i);
  rep(i,N-1){
    if(A.at(i)+A.at(i+1)>=L){
      t=i;
      cout << "Possible" << endl;
      break;
    }
  }
  if(t==-1){
    cout << "Impossible" << endl;
    return 0;
  }
  rep(i,t){
    cout << i+1 << endl;
  }
  for(ll i=N-2;i>t;i--){
    cout << i+1 << endl;
  }
  cout << t+1 << endl;
  
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
#define INF  1e18 
ll dp[500][500];
 
ll sum(int *arr,int s,int e) {
    ll sum1 = 0;
    for(int i = s; i <=e; i++) {
        sum1 += arr[i];
    }
    return sum1;
};
 
int main() {
	int n;
    cin>>n;
    int arr[n];
    
    for(int i=0; i<n; i++) cin>>arr[i];
    
    for(int i = n-1; i >= 0; i--) {
        for(int j = i; j < n ; j++) {
            if(i == j) {
                dp[i][j] = 0;
            }
            else {
                dp[i][j] = INF;
                ll s = sum(arr, i, j);
                for(int k = i; k <= j-1; k++) {
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + s);
                }
            }
        }
    } 
    cout<<dp[0][n-1];
   
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int H,W;
        String work[] = new String[2];
 
        while(true){
 
            try {
                work = br.readLine().split("[\\s]+");
 
                if(work[0].equals("0") && work[1].equals("0"))break;
 
                H = Integer.parseInt(work[0]);
                W = Integer.parseInt(work[1]);
 
                for(int row = 0; row < H; row++){
                    for(int col = 0; col < W; col++){
                        if((row+col)%2 == 0){
                            System.out.printf("#");
                        }else{
                            System.out.printf(".");
                        }
                    }
                    System.out.printf("\n");
                }
 
                System.out.printf("\n");
 
 
            } catch (IOException e) {
 
                e.printStackTrace();
            }
        }
    }
}


Measured memory_bytes: 59168
N, M = map(int, input().split())
H = list(map(int, input().split()))

A = [0]*M
B = [0]*M

for i in range(M):
  A[i], B[i] = map(int, input().split())
  
C = [1]*N
  
for i in range(M):
  if H[A[i]-1] < H[B[i]-1]:
    C[A[i]-1] = 0
  elif H[A[i]-1] == H[B[i]-1]:
    C[A[i]-1] = 0
    C[B[i]-1] = 0
  else:
    C[B[i]-1] = 0
    
print(int(sum(C)))

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

int main() {
  int s1s2s3;
  cin >> s1s2s3;
  int a=s1s2s3/100;
  int b=(s1s2s3-a*100)/10;
  int c=s1s2s3-a*100-b*10;
  cout << a+b+c << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let input = get_vec_input();
    let x1: f64 = input[0];
    let y1: f64 = input[1];
    let x2: f64 = input[2];
    let y2: f64 = input[3];

    let x_diff = (x2 - x1).powi(2);
    let y_diff = (y2 - y1).powi(2);
    println!("{}", (x_diff + y_diff).sqrt());
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

#[allow(dead_code)]
fn get_string_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.trim().to_string()
}



Measured memory_bytes: 5060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n,m;
    cin >> n >> m;
    priority_queue<ll> a;
    for(int i = 0; i < n; i++){
        ll k;
        cin >> k;
        a.push(k);
    }
    ll sum = 0;
    while(m > 0){
        ll f = a.top();
        a.pop();
        f /= 2;
        m--;
        a.push(f);
    }
    for(int i = 0; i < n; i++){
        sum += a.top();
        a.pop();
    }
    cout << sum << endl;
}

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

int main(){
    int k, a, b; cin >> k >> a >> b;

    for(int i = a; i<= b; i++){
        if(i %k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}

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

using namespace std;

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    double n;
    cin>>n;
    long double a,b,c;
    a=n/3;
    b=n/3;
    c=n/3;
    cout<<fixed;
    cout<<setprecision(12)<<a*b*c<<'\n';
    return 0;
}

Measured memory_bytes: 256
open System

let readInt () = stdin.ReadLine() |> int
let readIntArray () = stdin.ReadLine().Split(' ') |> Array.map int
let readString () = stdin.ReadLine()

let s = readString ()

let solve () : unit = 
    s
    |> Seq.map (fun c -> if c = '1' then 1 else 0)
    |> Seq.sum
    |> printfn "%d"

[<EntryPoint>]
let main argv = 
    solve()
    0


Measured memory_bytes: 14044
n = int(input())
d = list(map(int, input().split()))

if d[0] != 0:
    print(0)
    exit()

d.sort()

if d[1] != 1:
    print(0)
    exit()

i = 1
dis = 1
sep = [0] * (10 ** 5)
sep[0] = 1
ans = 1
while i < n:
    if d[i] != dis:
        print(0)
        exit()
    while i < n and d[i] == dis:
        sep[dis] += 1
        i += 1
    ans *= sep[dis-1] ** sep[dis]
    ans %= 998244353
    dis += 1
print(ans)



Measured memory_bytes: 14396