akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;


int main(){
  int H,W;
  string s[60];
  cin >> H >> W;

  rep(i,H){
    cin >> s[i];
  }

  auto answer = [&](int i, int j){
    bool can = false;
    if (i-1 >= 0 ) {
      if (s[i-1][j] == '#') {
        can = true;
      }
    }
    if (j-1 >= 0) {
      if (s[i][j-1] == '#') {
        can = true;
      }
    }
    if (j+1 < W) {
      if (s[i][j+1] == '#') {
        can = true;
      }
    }
    if (i+1 < H) {
      if (s[i+1][j] == '#') {
        can = true;
      }
    }
    return can;
  };

  rep(i,H){
    rep(j,W){
      if (s[i][j] == '#') {
        bool can2 = answer(i,j);
        if (can2 == false) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }

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


Measured memory_bytes: 256
// C.

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

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	LL k, a, b;
	cin >> k >> a >> b;
	LL ans = 1 + k;
	if (b > a) {
		LL r = k - (a - 1);
		if (r >= 0) {
			LL x = a + (b - a) * (r / 2) + (r % 2);
			ans = max(ans, x);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n,m=[int(_)for _ in input().split()]

ab=[[int(_) for _ in input().split()]for i in range(n)]
cd=[[int(_) for _ in input().split()]for i in range(m)]


def dist(p1,p2):
  return abs(p1[0]-p2[0])+abs(p1[1]-p2[1])

for i in range(n):
  d=1000000000
  ans=0
  for j in range(m):
    if d>dist(ab[i],cd[j]):
      ans=j+1
      d=dist(ab[i],cd[j])
  print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
int main() {
  string s;
  cin>>s;
  set<char>k;
  for(int i=0;i<s.size();i++){
    k.insert(s[i]);
  }
  for(char i='a';i<='z';i++){
    if(!k.count(i)){cout<<i<<endl;return 0;}
  }
  cout<<"None"<<endl;
  return 0;  
}

Measured memory_bytes: 3740
/*
[abc150] A - 500 Yen Coins
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

int K, X;

bool solve() { return 500 * K >= X; }

int main() {
    cin >> K >> X;

    cout << (solve() ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;
 
typedef tuple<ll,ll,ll> T;


string a="";
string b="";
	
string check(string x, string y){
	string r;
	printf("%s\n%s\n", (a+x).c_str(), (b+y).c_str()); fflush(stdout);
	cin >> r;
	if(r=="end")
		return r;
	else if(r=="T"){
		a=a+x;
		b=b+y;
	}
	return r;
}

string check2(string x, string y){
	string r;
	printf("%s\n%s\n", (x+a).c_str(), (y+b).c_str());
	cin >> r;
	if(r=="end")
		return r;
	else if(r=="T"){
		a=x+a;
		b=y+b;
	}
	return r;
}

int main(){
	int N;
	cin >> N;
	while(1){
		while(1){
			string r=check(".",".");
			if(r=="end")
				return 0;
			else if(r=="T")
				continue;

			r=check("#",".");
			if(r=="end")
				return 0;
			else if(r=="T")
				continue;
			
			r=check(".","#");
			if(r=="end")
				return 0;
			else if(r=="T")
				continue;
			
			r=check("#","#");
			if(r=="end")
				return 0;
			else if(r=="T")
				continue;
			else
				break;
		}

		while(1){
			string r=check2(".",".");
			if(r=="end")
				return 0;
			else if(r=="T")
				continue;

			r=check2("#",".");
			if(r=="end")
				return 0;
			else if(r=="T")
				continue;
			
			r=check2(".","#");
			if(r=="end")
				return 0;
			else if(r=="T")
				continue;
			
			r=check2("#","#");
			if(r=="end")
				return 0;
			else if(r=="T")
				continue;
			else
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      String S = sc.nextLine();
      String T = sc.nextLine();

      char s;
      char t;
      int count = 0;



      for(int i = 0;i<S.length();i++){
        s = S.charAt(i);
        t = T.charAt(i);
        if(s==t){
          count++;
        }
      }

      System.out.println(count);

  }
}

Measured memory_bytes: 21972
#include<stdio.h>

int main(){


        char s[4];
        scanf("%s",s);
        int loop;
        int count=0;

        for(loop=0; loop < 3; loop++){
                if(s[loop] == '1'){
                        count++;
                }
        }

        printf("%d\n",count);

        return 0;
}

Measured memory_bytes: 128
n = gets.to_i
w = gets.split.map(&:to_i)
sumw = Array.new(n+1)
sumw[0] = 0
for i in 1..n
  sumw[i] = w[i-1] + sumw[i-1]
end
min = 9999999999
for i in 1..(n-1)
  de = (sumw[i] - (sumw[n] - sumw[i])).abs
  min = de if min > de
end
puts min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v, x) binary_search(v.begin(), v.end(), x)
#define popf pop_front
#define p() cout << '\n'
#define p0(x) cout << x << " "
#define p1(x) cout << x << '\n'
#define p2(x, y) cout << x << " " << y << '\n'
#define p3(x, y, z) cout << x << " " << y << " " << z << '\n'
#define printv(v)                   \
  for (ll i = 0; i < v.size(); ++i) \
    cout << v[i] << " ";            \
  cout << '\n'
#define pr1(x) cout << fixed << setprecision(15) << x << '\n'
#define mod 1000000007
#define mod1 998244353
#define fio                         \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define get(n) \
  ll n;        \
  cin >> n
#define getvec(v, n)         \
  vector<ll> v(n);           \
  for (ll i = 0; i < n; i++) \
    cin >> v[i];
#define getstr(s) \
  string s;       \
  cin >> s
#define all(x) x.begin(), x.end()
#define countBits(x) __builtin_popcount(x)
using namespace std;

ll bfs(int node, vector<vl> &adj, vector<bool> &vis)
{
  vis[node] = true;
  queue<ll> q;
  q.push(node);
  ll ans = 1;
  while (!q.empty())
  {
    ll curr = q.front();
    q.pop();
    for (ll x : adj[curr])
    {
      if (vis[x])
        continue;
      vis[x] = true;
      q.push(x);
      ++ans;
    }
  }
  return ans;
}

void mainSolve()
{
  get(n);
  get(m);
  vector<vl> adj(n + 1);
  while (m--)
  {
    get(a);
    get(b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<bool> vis(n + 1, false);
  vl v;
  for (int i = 1; i <= n; i++)
  {
    if (!vis[i])
    {
      v.pb(bfs(i, adj, vis));
    }
  }
  sort(all(v));
  //printv(v);
  ll ans = 0;
  ll sub = 0;
  for (int i = 0; i < v.size(); i++)
  {
    v[i] = max(0ll, v[i] - sub);
    ans += v[i];
    sub += v[i];
  }
  p1(ans);
}

int main()
{
  fio;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  //get(t);
  ll t = 1;
  while (t--)
  {
    mainSolve();
  }
  return 0;
}


Measured memory_bytes: 16924
n, h, w = gets.chomp.split(" ").collect(&:to_i)
as = []
bs = []
n.times {
    a, b = gets.chomp.split(" ").collect(&:to_i)
    as.push a
    bs.push b
}

ans = 0
(0...n).each{ |i|
    if as[i] >= h && bs[i] >= w
        ans += 1
    end
}

puts ans


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll A[200200],F[200200];
int n;
ll k;

bool isOK(ll x){
    ll rep = 0;
    for(int i=0;i<n;i++) rep += max((ll)0, A[i] - x/F[i]);
    if(rep <= k) return true;
    else return false;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> A[i];
    for(int i=0;i<n;i++) cin >> F[i];
    sort(A,A+n);
    sort(F,F+n,greater<>());

    ll ok = 100100100100100100;
    ll ng = -1;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(isOK(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 3328
//"I'll live the focused life, because it's the best kind there is" - Winifred Gallagher
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl

int main(){
	//freopen("input.txt", "r",stdin);
	int n, k; cin>>n>>k;
	vector<int> a(n), dp(n, 1e9 + 7);
	for(int i =0; i<n; i++){
		cin>>a[i];
	}
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j<= i + k; j++){
			if(j<n){
				dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}
	


Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n,c,k;
ll t[100001];

int main(void){
	scanf("%lld%lld%lld",&n,&c,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&t[i]);
	}
	sort(t,t+n);
	int cnt=0;
	int l=0,r=0;
	while(l<n){
		cnt++;
		while(t[r]-t[l]<=k && r<n && r-l<c){
			r++;
		}
		l=r;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>

int main(void){
    int N, L;
    scanf("%d %d", &N, &L);
    char **S = (char**)malloc(N * sizeof(char*));
    int i, j;
    for(i=0; i<N; i++) { 
        S[i] = (char*)malloc((L+1) * sizeof(char));
        scanf("%s", S[i]);
    }
    char *temp = (char*)malloc((L+1) * sizeof(char));
    
    for(i=0; i<N-1; i++) {
        for(j=i; j<N; j++) {
            if(strcmp(S[i], S[j]) > 0) {
                strcpy(temp, S[i]);
                strcpy(S[i], S[j]);
                strcpy(S[j], temp);
            }
        }
    }
    for(i=0; i<N; i++) {
        printf("%s", S[i]);
    }
    printf("\n");


    for(i=0; i<N; i++) { 
        free(S[i]);
    }
    free(S);
    free(temp);
    return 0;
}

Measured memory_bytes: 128
n, x = map(int,input().split())
A = list(map(int,input().split()))

ans = 10**18
mins = [a for a in A]
for k in range(n):
    for i in range(n):
        if k <= i:
            mins[i] = min(A[i-k], mins[i])
        else:
            mins[i] = min(A[n-(k-i)], mins[i])
    ans = min(sum(mins)+k*x, ans)
print(ans)


Measured memory_bytes: 3188
n, t = [int(i) for i in input().split()]
ab = []
for _ in range(n):
    ab.append([int(i) for i in input().split()])
ab.sort(key=lambda x:x[0])
aa = t+max([i[0] for i in ab])+1
c = [0] * aa
for i in ab:
    d = c[:]
    for j in range(t):
        k = d[j]
        l = i[0] + j
        if l >= aa:
            continue
        c[l] = max(c[l], d[j] + i[1])
print(max(c))


Measured memory_bytes: 49880
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

void solve(){
  ll a, b, c, k, ans = 0; cin >> a >> b >> c >> k;
  if(k <= a) ans = k;
  else if(k <= a + b) ans = a;
  else if(k <= a + b + c)ans = a - (k - (a + b));
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 3596
a = [int(i) for i in input().split()] 
if a[0] == 0:
 ans = a[1]
elif a[0] == 1:
 ans = 100*a[1]
else:
 ans =10000*a[1]
if a[1] == 100:
 ans += pow(100, a[0])
     
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

int d[50][50];
int cnt[3][50];
int n,c;

int main()
{
	scanf("%d%d",&n,&c);
	for (int i=1;i<=c;i++)
		for (int j=1;j<=c;j++)
			scanf("%d",&d[i][j]);
			
	int x;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			scanf("%d",&x),cnt[(i+j)%3][x]++;	
			
	long long ans=0x3f3f3f3f; 
	for (int i=1;i<=c;i++)
		for (int j=1;j<=c;j++)	
				for (int k=1;k<=c;k++)
				{
					long long sum=0;
					if (i == k || j == k || i == j) continue;
					for (int x=1;x<=c;x++) sum+=d[x][i]*cnt[0][x]+d[x][j]*cnt[1][x]+d[x][k]*cnt[2][x];
					if (sum<ans) ans=sum;
				}		
	printf("%lld\n",ans);
	return 0;	
} 

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

int main()
{
    int n, x;
    int sum=0;
    for(int i=0; ; i++){
        cin >> n >> x;
        if(n==0 && x==0) break;
        for(int a=1; a<=n; a++){
            for(int b=a+1; b<=n; b++){
                for(int c=b+1; c<=n; c++){
                    if(a+b+c==x){
                        sum++;
                    }
                }
            }
        }
        cout << sum << endl;
        sum = 0;
    }
    
    return 0;
}

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
#define N 100000
#define SWP(T, X, Y) {T _; _=(X);(X)=(Y);(Y)=_;}

int partition(int a[], int p, int r){
  int piv = a[r];
  int i = p-1;
  
  for (int j=p; j<r; j++){
    if (a[j] <= piv){
      i++;
      SWP(int, a[i], a[j]);
    }
  }
  SWP(int, a[i+1], a[r]);
  return i+1;
}

int main(void){
  int n, a[N], piv;
  
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  piv = partition(a,0,n-1);
  for (int i=0; i<n; i++){
    if (i==piv){
      cout << "[" << a[i] << "]";
    } else {
      cout << a[i];
    }
    cout << (i==n-1?"\n":" ");
  }
  
  return 0;
}


Measured memory_bytes: 3476
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> vec(n+10,0),Sum(n+10,0);
    rep(i,n){ 
        cin >> vec[i];
        vec[i]++;
    }
    Sum[0] = vec[0];
    reps(i,1,n){
        Sum[i] += (Sum[i-1] + vec[i]);
    }
    int m = Sum[k-1];
    rep(i,n-k+1){
        m = max(m,Sum[i+k]-Sum[i]);  
    }
    printf("%2.12f\n",(double)m/2);
    return 0;
}

Measured memory_bytes: 4776
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int32_t N;
  cin >> N;
  vector<int32_t> A(N, INT32_MAX);
  for (int32_t i = 0; i < N - 1; ++i) {
    int32_t b;
    cin >> b;
    A[i] = min(A[i], b);
    A[i + 1] = min(A[i + 1], b);
  }
  int32_t sum_value = 0;
  for (const int32_t value : A) {
    sum_value += value;
  }
  cout << sum_value << endl;
  return 0;
}


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

using namespace std;


int main(){
  int n;
  cin >> n;
  vector<int> b;
  vector<int> ans;
  int tmp;
  
  for(int i=0; i<n; i++){
    cin >> tmp;
    b.push_back(tmp);
  }
  for(int i=0; i<n; i++){
    for(int j=n-i; j>=1; j--){
      if(b[j-1] == j){
        b.erase(b.begin()+j-1);
        ans.push_back(j);
        break;
      }
      if(j==1){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  for(int i=0; i<n; i++){
    cout << ans[n-i-1] << endl;
  }
  return 0;
}

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

const int N = 200005;

int n;
vector<int> edges[N];

int depth[N];
void dfs(int u, int p) {
  for (int v: edges[u]) {
    if (v == p) continue;
    
    depth[v] = depth[u] + 1;
    dfs(v, u);
  }
}

int main() {
  scanf("%d", &n);
  if (n == 1) return 0 * printf("First\n");
  if (n == 2) return 0 * printf("Second\n");
  
  for (int i=1; i<n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;
 
    edges[u].push_back(v);
    edges[v].push_back(u);
  }
  
  depth[0] = 0;
  dfs(0, -1);
  
  int root = 0;
  for (int i=1; i<n; i++) if (depth[i] > depth[root]) root = i;
  
  depth[root] = 0;
  dfs(root, -1);
  
  int maks = 0;
  for (int i=0; i<n; i++) maks = max(maks, depth[i]);
  
  if (maks % 3 == 1) printf("Second\n");
  else printf("First\n");
  return 0;
}


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

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

	int have_500 = money / 500;
	int tmp = money - 500 * have_500;
	int have_5 = tmp / 5;

	int hapiness = 1000 * have_500 + 5 * have_5;

	cout << hapiness << "\n";

	return 0;
}

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

int main(){
    int m, n;
    cin >> m >> n;
    vector<int> a(n);
    int sum = 0;

    rep(i, n){
        cin >> a.at(i);
        sum += a.at(i);
    }

    int ans = m - sum;
    

    if(ans >= 0){
        cout << ans << endl;
        } else 
        cout << "-1" << endl;

}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
string s;
int a[26];
signed main() {
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		a[(int)(s[i] - 'a')]++;
	}
	int ans = 1;
	for (int i = 0; i < 26; i++) {
		ans *= a[i] + 1;
		ans %= Mod;
	}
	cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
// long long -> lint
using lint = long long;
// fast cin and cout from hitonanode-san's code
// w/o 71 ms -> w/ 18 ms (tested on ABC148-D with C++14(GCC 5.4.1))
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

int main(){
    // input
    int K;
    cin >> K;

    // calc
    lint ans = 0;
    for ( int a = 1 ; a<K+1; a++){
        for ( int b = 1 ; b<K+1; b++){
            for ( int c = 1 ; c<K+1; c++){
                ans += __gcd( a, __gcd(b,c) );
            }
        }        
    }

    // out
    cout << ans << endl;
} 

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string s;
    cin >> s;
    // char x = s[0];
    int res = 0;
    rep(i, 1, s.size())
    {
        if (s[i] != s[i-1])
            res++;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 512
import numpy as np

N = int(input())
b = [int(s) for s in input().split(' ')]

A = [0] * N
B = [0] * N

for i in range(len(b)):
    B[i] = b[i]

A[0] = B[0]
A[-1] = B[-2]

for i in range(1, N-1):
    num = min(B[i-1], B[i])
    A[i] = num

print(sum(A))

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli num1 , num2 , num3 ;
    cin >> num1 >> num2 >> num3 ;
    (num1 + num2 >= num3 ? Yes : No) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int h, a;
  cin >> h >> a;
  cout << (h + a - 1) / a << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int N;
  cin >> N;
  int s[N];
  rep(i, N)
    cin >> s[i];
  //入力終了

  //大きい順に
  sort(s, s+N);

  //s[]の総和
  int sum = 0;
  rep(i, N)
    sum += s[i];

  //既に10の倍数でなければ終了
  if(sum%10 != 0){
    cout << sum << endl;
    return 0;
  }

  //小さい数字から順に引いていく
  rep(i, N){
    sum -= s[i];
    //10の倍数でなければ終了
    if(sum%10 != 0){
      cout << sum <<endl;
      return 0;
    }
    //元に戻す
    sum += s[i];
  }

  //上で終わらなければ元々が10の倍数だった
  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

ll a[200002];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	if (a[0] != 0) {
		cout << -1 << endl;
		return 0;
	}
	ll ans = 0, cur = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (a[i] == cur) {
			cur = max(0LL, a[i] - 1);
			continue;
		}
		if (a[i] < cur) {
			cout << -1 << endl;
			return 0;
		}
		if (i - a[i] < 0) {
			cout << -1 << endl;
			return 0;
		}

		ans += a[i];
		cur = max(0LL, a[i] - 1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
s = input()
for _ in range(int(input())):
    o = input().split()
    a, b = map(int, o[1:3])
    b += 1
    c = o[0][2]
    if c == 'p':
        s = s[:a]+o[3]+s[b:]
    elif c == 'i':
        print(s[a:b])
    elif c == 'v':
        s = s[:a]+s[a:b][::-1]+s[b:]



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

int main(int argc, char const *argv[])
{
    pair<int, int> A[3][3];
    for (size_t i = 0; i < 3; i++)
    {
        for (size_t j = 0; j < 3; j++)
        {
            cin >> A[i][j].first;
        }
    }

    int N;
    cin >> N;
    vector<int> b(N);
    for (size_t x = 0; x < N; x++)
    {
        cin >> b[x];

        for (size_t i = 0; i < 3; i++)
        {
            for (size_t j = 0; j < 3; j++)
            {
                if (A[i][j].first == b[x])
                {
                    A[i][j].second++;
                }
            }
        }
    }

    string yes = "Yes";
    string no = "No";
    string ans = no;
    for (size_t i = 0; i < 3; i++)
    {
        if (A[i][0].second != 0 && A[i][1].second != 0 && A[i][2].second != 0)
        {
            ans = yes;
        }
    }

    for (size_t j = 0; j < 3; j++)
    {
        if (A[0][j].second != 0 && A[1][j].second != 0 && A[2][j].second != 0)
        {
            ans = yes;
        }
    }

    if (A[0][0].second != 0 && A[1][1].second != 0 && A[2][2].second != 0)
    {
        ans = yes;
    }

    if (A[0][2].second != 0 && A[1][1].second != 0 && A[2][0].second != 0)
    {
        ans = yes;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int count=0;
      float n,m;
      cin>>n>>m;
      float sum=0;
      vector<int> v;
      for(int i=0;i<n;i++)
      {
        int x;cin>>x;v.push_back(x);
        sum+=x;
      }
      sum=sum/(4*m);
      for(int i=0;i<n;i++)
      {
        if(v[i]>=sum)
        {
          count++;
        }
      }
      if(count>=m)
      {cout<<"Yes";}else{cout<<"No";}
    }  

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>
#include<math.h>


using namespace std;

int main(){




	string p,q,r;
	while(1){
		cin>>p;if(p=="0")break;
		cin>>q>>r;
	char ch[4][4]={};

	for(int i=0;i<3;i++)
	{
		ch[0][i]=p[i];
		ch[1][i]=q[i];
		ch[2][i]=r[i];
	}
	char win='N';

	for(int i=0;i<3;i++)
	{
		if(ch[i][0]==ch[i][1]&&ch[i][0]==ch[i][2]&&ch[i][0]!='+'){
			win=ch[i][0];
		}
		
		if(ch[0][i]==ch[1][i]&&ch[0][i]==ch[2][i]&&ch[0][i]!='+'){
			win=ch[0][i];
		}
	}
	if(ch[0][0]==ch[1][1]&&ch[0][0]==ch[2][2]&&ch[0][0]!='+'){
			win=ch[0][0];
		}
	if(ch[0][2]==ch[1][1]&&ch[0][2]==ch[2][0]&&ch[0][2]!='+'){
			win=ch[0][2];
		}

if(win!='N')cout<<win<<endl;
else cout<<"NA"<<endl;
	}

	return 0;
}

Measured memory_bytes: 1176
s = input()
n = len(s)

ans = [1 for i in range(n)]
for i,a in enumerate(s):
    if a =="R":
        nxta = s[i+1]
        if nxta =="R":
            ans[i+2] += ans[i]
            ans[i] = 0

for i in range(n-1,-1,-1):
    a = s[i]
    if a =="L":
        nxta = s[i-1]
        if nxta =="L":
            ans[i-2] += ans[i]
            ans[i] = 0
print(*ans)


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        int change = 0;
        
        while(true){
        	if(A%2!=0||B%2!=0||C%2!=0)break;
        	int nextA = (B+C)/2;
        	int nextB = (C+A)/2;
        	int nextC = (A+B)/2;
        	change++;
        	if(nextA%2!=0 || nextB%2!=0 || nextC%2!=0) break;
        	int minimum = Math.min(Math.min(nextA,nextB),nextC);
        	A = nextA;
        	B = nextB;
        	C = nextC;
        	if(nextA==nextB&&nextA==nextC){
        		change=-1;
        		break;
        	}
        }
        System.out.println(change);
    }
}

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

using namespace std;

#define int long long
#define nl "\n"
#define sp " "

const int mod = 1e9 + 7;

signed main(){
	double d, t, s; cin >> d >> t >> s;
	if (d/s <= t){
		cout << "Yes";
	}
	else cout << "No";
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long

using namespace std;

int main()
{
	ll n, m;
	while(cin >> n >> m, n > 0){
		ll ans=0;
		vector<pair<int, int>> pd;
		rep(i, n){
			int p, d;
			cin >> d >> p;
			pd.push_back(make_pair(p, d));
		}
		sort(pd.rbegin(), pd.rend());
		for(auto itr=pd.begin(); itr!=pd.end(); itr++){
			if (m >= itr->second){
				m -= itr->second;
			}else{
				ans += itr->first*(itr->second-m);
				m = 0;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3156
N = int(input())
A = [int(x) for x in input().split()]
s = min(A)
d = [x % s for x in A]
while max(d) > 0 and s > 1:
  d = [e for e in d if e > 0] + [s]
  s = min(d)
  d = [x % s for x in d]
print(s)


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<pair<int64_t, int64_t>> xd(n);
    for (auto&& t : xd) {
        cin >> t.first >> t.second;
    }

    sort(xd.begin(), xd.end());

    constexpr auto M = 998244353;
    constexpr auto K = 1L << 40;
    map<int64_t, int64_t> m;
    m[-K] = 1;
    m[K] = 0;
    for (const auto& t : xd) {
        {
            auto b = m.begin();
            ++b;
            auto e = m.upper_bound(t.first);
            m.erase(b, e);
        }

        {
            auto tmp = m.begin()->second;
            auto b = m.begin();
            ++b;
            tmp -= b->second;
            tmp = (tmp + M) % M;
            auto e = m.upper_bound(t.first + t.second);

            m.erase(b, e);
            m[t.first + t.second] = m.begin()->second;
            m.begin()->second += tmp;
            m.begin()->second %= M;
        }
    }

    cout << m.begin()->second << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 55;
const double eps = (double) 1e-9;

struct point {
  int x, y;
};

int n;
point arr[N];

double dist(double x, double y) {
  double mx = 0;
  for (int i = 0; i < n; i++) {
    mx = max(mx, sqrt((x - arr[i].x) * (x - arr[i].x) + (y - arr[i].y) * (y - arr[i].y)));
  }
  return mx;
}

double f(double x) {
  double l = 0, r = 1000;
  while (fabs(r - l) > eps) {
    double m1 = l + (r - l) / 3;
    double m2 = r - (r - l) / 3;
    if (dist(x, m1) < dist(x, m2)) {
      r = m2;
    } else {
      l = m1;
    }
  }
  return dist(x, l);
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i].x >> arr[i].y;
  }
  double l = 0, r = 1000;
  while (fabs(r - l) > eps) {
    double m1 = l + (r - l) / 3;
    double m2 = r - (r - l) / 3;
    if (f(m1) < f(m2)) {
      r = m2;
    } else {
      l = m1;
    }
  }
  cout << fixed << setprecision(12) << f(l) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,t,a[500010];
LL ans;
int main(){
	cin>>n;
	FOR(i,1,n) getint(a[i]),a[i]-=i;
	sort(a+1,a+n+1);
	if (n&1) t=a[n/2+1]; else t=a[n/2];
	FOR(i,1,n) ans+=abs(t-a[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
   ll n,w;
   cin>>n>>w;
   ll a[n+1],b[n+1];
   for(ll k=1;k<=n;k++){
   	   cin>>a[k]>>b[k];
   }
   ll d[n+1][w+1];
   for(ll j=1;j<=w;j++){
       if(j<a[1])d[1][j]=0;
       else d[1][j]=b[1];  	
    }
    
    for(ll i=2;i<=n;i++){
    	for(ll j=2;j<=w;j++){
    		if(j>a[i])d[i][j]=max(d[i-1][j],d[i-1][j-a[i]]+b[i]);
    		else d[i][j]=d[i-1][j];
		}
	}
	cout<<d[n][w];
   return 0;
}

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

int main(){
    int a,b;
    vector<int> path[4];
    for(int i=0;i<3;i++){
    cin >> a>>b;
    path[a-1].push_back(b-1);
    path[b-1].push_back(a-1);
    }
    int one=0;
    int two =0;
    for (int i = 0; i < 4; i++)
    {   
       // cout <<path[i].size()<<endl;
        if(path[i].size()==1){
            one++;
        }else if(path[i].size()==2){
            two++;
        }else{
            one=-35;
            two=-46;
        }
    }
    if(one==two and one==2){
        cout <<"YES";
    }else{
    cout << "NO";
}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long t,n,m,x,i,j,kt,a[200002],b[200002],c,d;
double r,pi=3.14;
int main()
{
    cin>>n;
    t=0;
    for(i=1;i<n;i++)
    {
        cin>>a[i];
        b[a[i]]++;
    }
    for(i=1;i<=n;i++) cout<<b[i]<<endl;
}



Measured memory_bytes: 6760
import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input


class HeavyLightDecomposition:
    def __init__(self, g, root=0):
        self.g = g
        self.vid, self.head, self.heavy, self.parent = [0] * len(g), [-1] * len(g), [-1] * len(g), [-1] * len(g)
        self.dfs(root)
        self.bfs(root)

    def dfs(self, root):
        stack = [(root, -1)]
        sub, max_sub = [1] * len(self.g), [(0, -1)] * len(self.g)
        used = [False] * len(self.g)
        while stack:
            v, par = stack.pop()
            if not used[v]:
                self.parent[v] = par
                used[v] = True
                stack.append((v, par))
                stack.extend((c, v) for c in self.g[v] if c != par)
            else:
                if par != -1:
                    sub[par] += sub[v]
                    if sub[v] > max_sub[par][0]:
                        max_sub[par] = max(max_sub[par], (sub[v], v))
                self.heavy[v] = max_sub[v][1]

    def bfs(self, root=0):
        from collections import deque
        k, que = 0, deque([root])
        while que:
            r = v = que.popleft()
            while v != -1:
                self.vid[v], self.head[v] = k, r
                for c in self.g[v]:
                    if c != self.parent[v] and c != self.heavy[v]:
                        que.append(c)
                k += 1
                v = self.heavy[v]

    def lca(self, u, v):
        while self.head[u] != self.head[v]:
            if self.vid[u] > self.vid[v]:
                u, v = v, u
            v = self.parent[self.head[v]]
        else:
            if self.vid[u] > self.vid[v]:
                u, v = v, u
        return u

N = int(input())
g = [[] for _ in range(N)]
for i in range(N):
    for c in map(int, input().split()[1:]):
        g[i].append(c)
        g[c].append(i)
hld = HeavyLightDecomposition(g)
Q = int(input())
for _ in range(Q):
    u, v = map(int, input().split())
    print(hld.lca(u, v))

Measured memory_bytes: 38684
from sys import stdin
nii=lambda:map(int,stdin.readline().split())

n,m=map(int,input().split())
a=sorted(list(nii()))
l=[list(nii()) for i in range(m)]
l=sorted(l,key=lambda x:x[1],reverse=True)

man=[]
num=0
for b,c in l:
  man+=[c]*b
  num+=b
  if num>n:
    break

ans=0
for i in range(n):
  if i<num:
    ans+=max(a[i],man[i])
  else:
    ans+=a[i]
print(ans)

Measured memory_bytes: 35176
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
long long i[3000000];
bool o;
bool ans[5];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=inf,e=0,f=0,g=0,h=0,j=0;
  string s;
  cin >>s;
  b=s.size();
  for(lol n=0;n<b-1;n++){
    if(s[n]!=s[n+1]){
      a=max(n+1,b-n-1);
      d=min(d,a);
    }
  }
  if(d==inf) d=b;
  cout <<d<<'\n';
  return (0);
}


Measured memory_bytes: 512
#include<stdio.h>

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

  if(a < b){
    printf("a < b\n");
  }
  else if(a > b){
    printf("a > b\n");
  }
  else{
    printf("a == b\n");
  }

  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
string s;
int n;

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


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

vector<int> G[100100];

int main()
{
    int n;
    cin >> n;
    vector<int> ans(n);
    rep(i, n - 1)
    {
        int a;
        cin >> a;
        ans[a - 1]++;
    }
    for(int x : ans) {
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 6396
import sys
import heapq

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().rstrip().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    
    return divisors

def main():
    if len(A) <= 2:
        print(max(A))
        exit()
    else:
        a0, a1 = heapq.nsmallest(2, A)
        all_divisors = list(set(make_divisors(a0) + make_divisors(a1)))

    ans = 1
    for divisor in all_divisors:
        cnt = 0
        for a in A:
            if a % divisor != 0:
                cnt += 1
            if cnt == 2:
                break
        if cnt < 2:
            ans = max(ans, divisor)

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14588
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
void solve(){
    ll h,w;
    cin>>h>>w;
    string s[60];
    rep(i,h) cin>>s[i];
    char ans[60][60];
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                ans[i][j]='#';
                continue;
            }
            ll cnt=0;
            rep(k,8){
                ll nx=i+dx[k],ny=j+dy[k];
                if(nx<0||nx>=h||ny<0||ny>=w) continue;
                if(s[nx][ny]=='#') cnt++;
            }
            ans[i][j]=(char)('0'+cnt);
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<ans[i][j];
        }
        cout<<endl;
    }
 
}
 
 
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){
 
        solve();
 
    }
   
 
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  vector<ll>p(n);
  rep(i,n) cin >> p[i];
  int ans=0;
  rep(i,n){
    if((i+1)==p[i]){
      ans++;
      i++;
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 1024
inputs = readlines
# inputs = "4\n1 2 3 4\n".split("\n")

n = inputs[0].to_i
hs = inputs[1].split(' ').map(&:to_i)

def solve(n, hs)
  answer = 0
  counter = 0
  (0..n - 2).each do |i|
    if hs[i + 1] <= hs[i]
      counter += 1
    else
      answer = counter if counter > answer
      counter = 0
    end
  end
  answer = counter if counter > answer
  answer
end

puts solve(n, hs)



Measured memory_bytes: 8580
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = 0, z = 0;
		char[] s = sc.next().toCharArray();
		for(int i = 0; i < s.length; i++) {
			if(s[i] == 'A') {
				a = i;
				break;
			}
		}
		for(int i = s.length - 1; i >= 0; i--) {
			if(s[i] == 'Z') {
				z = i;
				break;
			}
		}
		System.out.println(z - a + 1);
	}
}

Measured memory_bytes: 26276
#include <stdio.h>

int main(void) {
    int i, j, sum, d;
    while (scanf("%d", &i) != EOF) {
        scanf("%d", &j);
        d = 1;
        sum = i+j;
        while ((sum = sum / 10) != 0) {
            d++;
        }
        printf("%d\n", d);
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=2e3+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,k,ans,cnt;
vector<int> E[N];
void dfs(int u,int fa,int dep) {
    if(dep>k/2) cnt++;
    for(int v:E[u]) if(v!=fa) dfs(v,u,dep+1);
}
int main() {
    cin>>n>>k;ans=n;
    for(int i=1,u,v;i<n;i++) u=gi(),v=gi(),E[u].pb(v),E[v].pb(u);
    if(k&1) for(int u=1;u<=n;u++) for(int v:E[u]) cnt=0,dfs(u,v,0),dfs(v,u,0),ans=min(ans,cnt);
    else for(int u=1;u<=n;u++) cnt=0,dfs(u,0,0),ans=min(ans,cnt);
    printf("%d\n",ans);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
string s[5000];
signed main() {
  int n;cin>>n;
  rep(i,0,n-1) cin>>s[i];
  rep(i,1,n-1) if(s[i-1][s[i-1].length()-1] != s[i][0])
  {
    cout << "No" << endl;
    return 0;
  }

  sort(s,s+n);

  rep(i,1,n-1) if(s[i-1] == s[i])
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  
}


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

using namespace std;

int main()
{
   int n,m;
   cin>>n>>m;
   long long s=0;
   for(int i=0;i<m;i++){
     long long a;
     cin>>a;
     s+=a;
   }
   if((n-s)<0)cout<<"-1"<<endl;
   else       cout<<(n-s)<<endl;
}


Measured memory_bytes: 3636
a = input()
s = [int(i) for i in a]
count = 0
ans = 0
while True:
    if (len(s) == count+1) or len(s) == 0:
        break
    if (s[count] == 0 and s[count+1] == 1) or (s[count] == 1 and s[count+1] == 0):
        ans += 1
        s.pop(count)
        s.pop(count)
        if count != 0:
            count -= 1
    else:
        count += 1
print(ans*2)


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

int main(){
    int A, P, N;
    string S;
    
    cin >> S;
    int i=0;
    while(S[i]!='\0'){
	if(S[i]=='1')
	    S[i]='9';
	else
	    S[i]='1';
	i++;
    }

    cout << S<<endl;
    
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  
  int ans=1e9+7;
  for(int i=0;i<=2*max(x,y);i+=2){
    int sum=i*c+max(x-i/2,0)*a+max(y-i/2,0)*b;
    ans=min(ans,sum);
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3580