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

using namespace std;

#define pq priority_queue
#define MZ 1000000007


int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n==1)
    {
        if(m==1)
            printf("1\n");
        else
            printf("%d\n",m-2);
    }
    else
    {
        if(m==1)
            printf("%d",n-2);
        else
        {
            long long ans=1LL*(n-2)*(m-2);
            printf("%lld\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N=int(input())
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
m=0
for i in range(0,N):
    d=B[i]-A[i]
    if d > 0:
        if A[i+1]-d <=0:
            B[i]=A[i]+A[i+1]
            A[i]=0
            A[i+1]=0
        else:
            A[i]=0
            A[i+1]=A[i+1]-d
    else:
        A[i]=-d
print(sum(B))

Measured memory_bytes: 19228
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int main()
{
	int n,cnt = 0;cin>>n;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		if(i%2==1&&x%2==1)cnt++; 
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3616
H,W = map(int,input().split())
L = [list(input()) for _ in range(H)]
for i in range(H):
    for j in range(W):
        if L[i][j] == '#':
            if i != 0 and L[i-1][j] == '#':
                continue
            if i != H-1 and L[i+1][j] == '#':
                continue
            if j != 0 and L[i][j-1] == '#':
                continue
            if j != W-1 and L[i][j+1] == '#':
                continue
            print('No')
            exit()
print('Yes')


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

int main()
{
	long long x;
	cin >> x;
	long long p=100,step=0;
	while(p<x)
	{
		p+=p/100;
		step++;
	}
	
	cout << step << endl;
	return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>
#define abs(x) ((x)<0 ? -(x) : (x))
int main(){
  int ans = 0;
  double diff = 1000;
  int n, t, a;
  scanf("%d %d %d", &n, &t, &a);
  for(int i=1; i<=n; i++){
    int h;  scanf("%d", &h);
    double ondo = t - h * 0.006;
    if(abs(a - ondo) < diff){
      diff = abs(a - ondo);
      ans = i;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1692
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF=2e18;
const ll MOD=1e9+7;
ll X,Y;
int main(){
    cin>>X>>Y;
    if(X<=1 && Y<=1)cout<<"Brown";
    else cout<<(abs(X-Y)<=1?"Brown":"Alice")<<endl;
    return 0;
}

Measured memory_bytes: 256
X = int(input())
dp = [True] + [False] * (X)

if X < 106:
  if 100 <= X <= 105:
    print(1)
    exit()
  else:
    print(0)
    exit()


# 100~105円はyes
for i in range(100,106):
  dp[i] = True

for i in range(106,X+1):
  for j in range(100,106):
    if dp[i-j] == True:
      dp[i] = True
      break

print(1 if dp[X] == True else 0)

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

int main()
{
  string S, T;
  cin >> S >> T;

  int ans = 0;

  for (int i = 0; i < S.size(); i++)
  {
    if (S.at(i) != T.at(i))
      ans++;
  }

  cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a;
    for(int i=0; i<n; i++){
        int aa;
        cin >> aa;
        a.push_back(aa);
    }
    int m;
    cin >> m;
    vector<int> b;
    for(int i=0; i<m; i++){
        int bb;
        cin >> bb;
        b.push_back(bb);
    }

    vector<int> result;
    // aとbの積集合を作る->O(N+M)
    set_intersection(begin(a), end(a), begin(b), end(b), inserter(result, end(result)));

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


Measured memory_bytes: 5220
#include <stdio.h>
int main(){
  int a, b, c, ans;
  scanf("%d %d %d",&a, &b, &c);
  ans=c-(a-b);
  if(a-b>=c){
    printf("0");
  }
  else if(a-b<c){
    printf("%d",ans);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
    double v, y, t, f, n;
    long long int i, a;
    while(cin>>v)
    {
        t=v/9.8;
        //cout<<t<<endl;
        y=4.9*t*t;
        for(i=1;;i++)
        {
            f=i*5-5;
            if(f>=y)
            {
                a=i;
                break;
            }
        }
        cout<<a<<endl;
    }
}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

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

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 30; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline void maxch(int& a, int b) { if (a < b) a = b; }

int bfs(int n, vector<vector<int>> &edge, map<pair<int,int>,int> &ecol) {
  queue<int> q;
	q.push(0);

	int maxcol = 0;

	while(!q.empty()){
		int col = 1, parcol = 0;
	  int par = q.front();
		q.pop();
		for (int v : edge[par]) {
		  if (ecol.at({par,v}) == 0) q.push(v);
			parcol = max(parcol, ecol.at({ par,v }));
		}
		// 色を付ける
		for (int v : edge[par]) {
		  if (col == parcol) col++;
			if (ecol.at({par,v}) == 0) {
			  ecol.at({par,v}) = col;
				ecol.at({v,par}) = col;
				maxcol = max(maxcol, col);
			  col++;
			}
		}
	}

	return maxcol;
}

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

	for (int i = 1; i <= n; i++) {
		if((int) (i*1.08) == n) { cout << i << endl; return 0;}
	}

	cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5+4;
int dp[MAX][6];
int a[6][MAX];
int main()
{
	int n;	
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[1][i]>>a[2][i]>>a[3][i];
	}
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=3;j++)
		{
			for(int k=1;k<=3;k++)
			{
				if(k != j)
				{
					dp[i][j] = max(dp[i][j],dp[i-1][k] + a[j][i]);
				}	
			}
		}
	}
	
	int best = -1;
	for(int i=1;i<=3;i++)
	{
		best = max(best,dp[n][i]);
	}
	
	cout<<best;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,m,q;cin>>n>>m>>q;
	vector<vector<int>> d(n + 1,vector<int>(n + 1,0));
	for(int i = 0; i < m; i++) {
		int l,r;cin>>l>>r;
		d[l][r] += 1;
	}
	vector<vector<int>> s(n + 1,vector<int>(n + 1,0));
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			s[i][j] = s[i][j - 1] + d[i][j];
		}
	}

	for(int i = 1; i <= n; i++) {
		for(int j = n - 1; j >= 0; j--) {
			s[j][i] += s[j + 1][i];
		}
	}
	// cout << endl;

	// for(int i = 1; i <= n; i++) {
	// 	for(int j = 1; j <= n; j++) {
	// 		cout << s[j][i] << " ";
	// 	}
	// 	cout << endl;
	// }

	for(int i = 0; i < q; i++) {
		int l,r;cin>>l>>r;
		cout << s[l][r] << endl;
	}

	return 0;
}

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

if N == 1:
    print("Yes")
else:
    for i in range(N):
        if i == 0:
            H[i] -= 1
        else:
            if H[i] > H[i - 1]:
                H[i] -= 1
            elif H[i] < H[i - 1]:
                print("No")
                break
    else:
        print("Yes")

Measured memory_bytes: 20696
/***********************************************
#
#      Filename: b.cpp
#
#        Author: Comsyl - ylsong15@fudan.edu.cn
#   Description: ---
#        Create: 2017-05-06 22:20:14
***********************************************/
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N, M;
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    vector<int> count(N+1);
    int u, v;
    for (int i = 0; i < M; ++ i) {
        cin >> u >> v;
        count[u] ++;
        count[v] ++;
    }
    bool is = true;
    for (int i = 1; i <= N; ++ i) {
        if (count[i] % 2) {
            is = false;
            break;
        }
    }
    if (is) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, M; cin >> N >> M;
	int res = 1;
	for (int i = 1; i * i <= M; i++)
	{
		if(M % i == 0) {
			if(M / i >= N) res = max(res, i);
			if(i >= N) res = max(res, M / i);
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll MOD = 1e9+7;
signed main(){
    ll n; cin >> n;
    ll k; cin >> k;
    vector<ll> v;
    for(ll i=1;i*i<=n;i++){
        int x=n/i;
        v.pb(i);
        if(i!=x) v.pb(x);
    }
    sort(ALL(v));
    int sz=v.size();
    ll dp[k][sz];
    ll dpsum[k][sz];
    rep(i,sz){
        if(i==0){
            dp[0][0]=v[0];
            dpsum[0][0]=v[0];
        }
        else{
            dp[0][i]=v[i]-v[i-1];
            dp[0][i]%=MOD;
            dpsum[0][i]=dpsum[0][i-1]+dp[0][i];
            dpsum[0][i]%=MOD;
        }
    }
    rep(i,k-1){
        rep(j,sz){
            dp[i+1][j]=dpsum[i][sz-1-j]*dp[0][j];
            dp[i+1][j]%=MOD;
        }
        rep(j,sz){
            if(j==0){
                dpsum[i+1][0]=dp[i+1][0];
                dpsum[i+1][0]%=MOD;
            }
            else{
                dpsum[i+1][j]=dpsum[i+1][j-1]+dp[i+1][j];
                dpsum[i+1][j]%=MOD;
            }
        }
    }
    //rep(i,k){rep(j,sz){cout << dp[i][j] << " ";}cout << endl;}
    ll ans=0;
    rep(i,sz){
        ans+=dp[k-1][i];
        ans%=MOD;
    }
    cout << ans << endl;
}




Measured memory_bytes: 99704
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c;
  /*cin>>a>>b>>c;
  if(a>b) cout<<"NO"<<'\n';
  else if(a+b>=c) cout<<"YES"<<'\n';
  else cout<<"NO"<<'\n';*/
  string s,code="CODEFESTIVAL2016";
  cin>>s;
  int sum=0;
  for(int i=0;i<16;i++){
    if(s[i]!=code[i]) sum++;
  }
  cout<<sum<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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 LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};


int main(){
    int n,k;cin>>n>>k;
    vector<int> p(n);
    vector<double> e(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        e[i] = p[i] * (p[i] + 1) / 2. / p[i];
    }
    vector<double> ec(n+1,0);
    for (int i = 0; i < n; i++) {
        ec[i+1] = ec[i] + e[i];
    }
    double ans = 0.0;
    for (int i = 0; i <= n-k; i++) {
        chmax(ans, ec[i+k] - ec[i]);
    }
    cout << setprecision(30) << fixed << ans << endl;
    return 0;
}


Measured memory_bytes: 4096
import java.util.*;


public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] data = new int[n];
			for(int i = 0; i < n;i++){
				data[i] = sc.nextInt();
			}
			long [] acc = new long[n];
			acc[0] = data[0];
			for(int i = 1; i < n; i++){
				acc[i] = acc[i-1] + data[i];
			}
			
			HashMap<Long, Integer> map = new HashMap<>();
			map.put(0L, 1);
			for(int i = 0; i < n; i++){
				if(map.containsKey(acc[i])){
					map.put(acc[i], map.get(acc[i]) + 1);
				}
				else{
					map.put(acc[i], 1);
				}
			}
			long sum = 0;
			for(Long key: map.keySet()){
				long value = map.get(key);
				sum += value * (value-1) / 2;
			}
			System.out.println(sum);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


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

int main(){
  string a = "Sunny", b = "Cloudy", c = "Rainy" ;
  string S;
  cin >> S;
  
  if (S == a) cout << b << endl;
  else if (S == b) cout << c << endl;
  else if (S == c) cout << a << endl;
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n, k;

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

    ll ans = 0;
    for(int b = 1; b <= n; b++){
        int p = n / b, r = n % b;
        ll val = p * max(0, b - k) + max(0, r - k + 1);
        if(k == 0) ans--;
        ans += val;
    }

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

Measured memory_bytes: 256
#include <cstdio>
#define MOD 1000000007
int ok[25][25], dp[25][1000005], trans[1000005][25];
int main()
{
	// freopen("AGC017-F.in", "r", stdin);
	int n, m, q;
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < n - 1; j++)
			ok[i][j] = 3;
	}
	while (q--)
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		ok[--a][--b] = 1 << c;
	}
	for (int i = 0; i < 1 << n - 1; i++)
	{
		for (int j = 0; j < n - 1; j++)
		{
			if (i & (1 << j))
				continue;
			trans[i][j] = i ^ (1 << j);
			for (int k = j + 1; k < n - 1; k++)
			{
				if (i & (1 << k))
				{
					trans[i][j] = i ^ (1 << j) ^ (1 << k);
					break;
				}
			}
		}
	}
	auto upd = [&] (int &x, const int &y)
	{
		x += y;
		if (x >= MOD)
			x -= MOD;
	};
	dp[0][0] = 1;
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < n - 1; j++)
		{
			for (int k = 0; k < 1 << n - 1; k++)
			{
				if (!(k & (1 << j)))
				{
					if (ok[i][j] & 1)
						upd(dp[j + 1][k], dp[j][k]);
					if (ok[i][j] & 2)
						upd(dp[j + 1][trans[k][j]], dp[j][k]);
				}
				else if (ok[i][j] & 2)
					upd(dp[j + 1][k], dp[j][k]);
				dp[j][k] = 0;
			}
		}
		for (int j = 0; j < 1 << n - 1; j++)
		{
			dp[0][j] = dp[n - 1][j];
			dp[n - 1][j] = 0;
		}
	}
	int ans = 0;
	for (int i = 0; i < 1 << n - 1; i++)
		upd(ans, dp[0][i]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 131328
#include <iostream>
#include <vector>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string str;

void solve(){
  vector<string> ans;
  string tmp;
  string str1,str2;

  for(int i = 1 ; i < str.size(); i++){
    tmp = str;

    for(int reverseStr = 0; reverseStr < 4; reverseStr++){
      str1 = tmp.substr(0,i);
      str2 = tmp.substr(i);
      if(reverseStr == 1 || reverseStr == 3) reverse(str1.begin(),str1.end());
      if(reverseStr == 2 || reverseStr == 3) reverse(str2.begin(),str2.end());
      bool flag1 = true;
      bool flag2 = true;
      for(int j = 0 ; j < ans.size() ; j++){
        if(ans[j] == str1 + str2) flag1 = false;
        if(ans[j] == str2 + str1) flag2 = false;
      }
      if(flag1) ans.push_back(str1 + str2);
      if(flag2 && (str1 + str2) != (str2 + str1) ) ans.push_back(str2 + str1);
    }

  }
  int res = ans.size();
  cout << res << endl;
  ans.clear();
  return ;
}
int main(){
  int n;
  cin >> n ;
  for(int i = 0; i < n; i++){
    cin >> str;

    solve();
  }
  return 0;
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#pragma GCC target ("sse4.2")
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define time cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
vector<lli>fact;
lli mod=1e9+7;
void factorial()
{
    fact.push_back(1);
    lli prev=1,cur;
    for(lli i=1;i<=1e5+5;i++)
    {
        cur=(i%mod*prev%mod)%mod;
        fact.push_back(cur);
        prev=cur;
    }
}
/*for(lli i=0;i<10;i++)
{
    cout<<fact[i]<<" ";
}
cout<<"\n";*/
lli power(lli c,lli n)
{
    lli ans=1;
    while(n)
    {
        if(n%2!=0)
        {
            ans=(ans%mod*c%mod)%mod;
        }

        c=(c%mod*c%mod)%mod;
        n/=2;
    }
    return ans;
}
vector<lli>inv;
void invfact()
{
    for(lli i=0;i<=1e5+5;i++)
    {
        inv.push_back(power(fact[i],mod-2));


    }
}

int main()
{


    fast;
    factorial();
    invfact();
    lli n,k;
    cin>>n>>k;
    vector<lli>a(n);
    for(lli i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    lli mod=1e9+7;
    lli total=0;
    vector<lli>v;
    for(lli i=0;i<n-(k-1);i++)
    {
        lli x=(fact[n-i-1]%mod*inv[k-1]%mod*inv[n-i-k]%mod)%mod;
        //lli y=(x*(x+1)/2);
        v.push_back(x);
        total=total+(-(x%mod*a[i]%mod)%mod);
       // cout<<" "<<total<<" ";
    }
    //cout<<"\n";
    reverse(v.begin(),v.end());
    lli sv=v.size();
    for(lli i=n-1;i>=(k-1);i--)
    {
        total+=(a[i]%mod*v[sv-1]%mod)%mod;
        sv--;
        v.pop_back();
        //cout<<total<<" ";
    }
    cout<<(total%mod+mod)%mod;
    return 0;


}


Measured memory_bytes: 3572
#include <stdio.h>
#define max(p,q)((p)>(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)

int a[16][16];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)a[i][j]=-1;
	for(int i=0;i<n;i++){
		int j;
		scanf("%d",&j);
		while(j--){
			int x,y;
			scanf("%d%d",&x,&y);
			x--;
			a[i][x]=y;
		}
	}
		
	int ans=0;
	for(int b=0;b<1<<n;b++){
		int ng=0;
		for(int i=0;i<n;i++)if(bit(b,i))for(int j=0;j<n;j++){
			if(a[i][j]!=-1 && a[i][j]!=bit(b,j)){
				ng=1;
			}
		}
		if(!ng)ans=max(ans,__builtin_popcount(b));
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
# ABC163

MOD=10**9+7
n,k=map(int,input().split())

ans=0
for i in range(k,n+2):
    ans+=(n+(n-i+1)-(i-1+0))*i//2+1
    ans%=MOD
    #print((n+(n-i+1))*i//2,(i-1+0)*i//2,(n+(n-i+1)-(i-1+0))*i//2,ans)

print(ans)

Measured memory_bytes: 9180
#include<iostream>
#include<vector>
using namespace std;
int main(void){
	int n,w,h;
	while(1){
		cin>>n;
		if(n==0)break;
		cin>>w>>h;
		vector<vector<bool> > map(w,vector<bool>(h,false));
		int x,y;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			map[x-1][y-1]=true;
		}
		int s,t;
		int ans=0;
		cin>>s>>t;
		for(int i=0;i<w-s+1;i++){
			for(int j=0;j<h-t+1;j++){
				int time=0;
				for(int k=i;k<i+s;k++){
					for(int l=j;l<j+t;l++){
						if(map[k][l]){
							time++;
						}
					}
				}
				ans=max(ans,time);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main()
{
  int n;
  string s;
  cin >> n;
  cin >> s;
  if (n % 2 != 0)
  {
    cout << "No" << endl;
    return 0;
  }

  auto a = s.substr(0, n / 2);
  auto b = s.substr(n / 2);
  //cout << a << endl;
  //cout << b << endl;

  if (a == b)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef vector<int>  vi;
typedef vector<vi> vv;
int h,w,c,dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
bool visited[8][8];
void dfs2(vv& vc,int be,int to,int x,int y){
	if(visited[x][y]) return;
	visited[x][y]=true;
	if(vc[x][y]!=be) return;
	vc[x][y]=to;
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx<0 || h<=nx || ny<0 || w<=ny) continue;
		dfs2(vc,be,to,nx,ny);
	}
}
int cnt(vv &vc,int be,int x,int y){
	if(visited[x][y]) return 0;
	int ret=1;
	visited[x][y]=true;
	if(vc[x][y]!=be) return 0;
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx<0 || h<=nx || ny<0 || w<=ny) continue;
		ret+=cnt(vc,be,nx,ny);
	}
//	cout << x << " " << y << " " << ret << endl;
	return ret;
}
int dfs(vv vc,int t){
	int ret=-1;
	rep(i,6){
		if(t==4) if(i!=c-1) continue;
		vv np=vc;
		rep(j,8) rep(k,8) visited[j][k]=false;
		dfs2(np,np[0][0],i,0,0);
		np[0][0]=i;
/*		cout << t << " " << i << endl;
		rep(j,h){
			rep(k,w){
				cout << np[j][k] << " ";
			}
			cout << endl;
		}
		cout << endl;*/
		rep(j,8) rep(k,8) visited[j][k]=false;
		if(t<4){
			ret=max(ret,dfs(np,t+1));
		}else{
			int hoge=cnt(np,np[0][0],0,0);
//			cout << i << " " << hoge << endl;
			ret=max(ret,hoge);
/*			if(ret<hoge){
				ret=hoge;
				cout << t << " " << i << "  ret= " << ret << endl;
				rep(j,h){
					rep(k,w){
						cout << np[j][k] << " ";
					}
					cout << endl;
				}
				cout << endl;
			}*/
		}
	}
	return ret;
}
int main(){
	while(true){
		scanf("%d%d%d",&h,&w,&c);
		if(!h) break;
		vv pn(h,vi(w));
		rep(i,h) rep(j,w) scanf("%d",&pn[i][j]),pn[i][j]--;
		//printf("%d\n",cnt(pn,pn[0][0],0,0));
		/*dfs2(pn,pn[0][0],4,0,0);
		cout << endl;
		rep(j,h){
			rep(k,w){
				cout << pn[j][k] << " ";
			}
			cout << endl;
		}*/
		printf("%d\n",dfs(pn,0));
	}
}

Measured memory_bytes: 1220
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

const MODULO: i64 = 1_000_000_007;

fn main() {
  input! {
    n: usize,
    k: usize,
    aa: [usize; n]
  }
  let mut dp = vec![vec![0i64; k+1]; 2];
  dp[0][0] = 1;
  for (i, &a) in aa.iter().enumerate() {
    dp[(i+1)%2][0] = 1;
    for c in 0 .. k {
      dp[(i+1)%2][c+1] = (dp[(i+1)%2][c] + dp[i%2][c+1]) % MODULO;
      if c >= a {
        let d = c - a;
        dp[(i+1)%2][c+1] = (dp[(i+1)%2][c+1] - dp[i%2][d] + MODULO) % MODULO;
      }
    }
  }
  println!("{}", dp[n%2][k]);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) printf("Possible\n");
    else printf("Impossible\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  string op;
  cin >> A >> op >> B;
 
  if (op == "+") {
    cout << A + B << endl;
  }
  if (op == "-") {
    cout << A - B << endl;
  }
}


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

using namespace std;


int main()
{
	iostream::sync_with_stdio(false);
	int N, d;
	int k = 1;
	int total = 0;
	int i = 0;
	cin >> N;
	vector<int> foods(N);
	while (cin >> d)
	{
		foods[i] = d;
		++i;
	}

	for (int i = 0; i < N -1; i++)
	{
		k = i + 1;
		for (k; k < N; k++)
		{
			total += foods[i] * foods[k];
		}
	}

	cout << total;
	return 0;
}

Measured memory_bytes: 256
/***********************************************************************************
*           Falling down is an accident, Staying down is a choice.                 *
***********************************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) //Fast IO
#define _USE_MATH_DEFINES
#define PI acos(-1.0) //3.14159265358
#define EPS 1e-9 //epsilon, 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
const int inf=1e9+7; //10^9 +7
const int modc=998244353;
typedef long long int ll;
void solve();int main(){ios;solve();return 0;}
/***********************************************************************************/
void solve()
{
	int n;cin>>n;
	int d;cin>>d;
	vector<vector<int> > a(n,vector<int>(d,0));
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			ll dist=0;
			for(int k=0;k<d;k++)
			{
				dist+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			for(int l=0;l<500;l++)
			{
				if(l*l==dist)
				{
					ans++;
					break;
				}
			}

		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    readln;
    auto S = readln.chomp.to!(char[]);
    auto K = readln.chomp.to!int;
    auto c = S[K-1];
    foreach (ref s; S) if (s != c) s = '*';
    writeln(S);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int INF = 1001001001;

int main(){
    int n, k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> dp(n,INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 1; j <= k; ++j){
            if(i+j>=n) break; 
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//


        signed main() {
          int n,p,ans=0;
          cin>>n>>p;
          string s;
          cin>>s;
          if(p==2||p==5){
                  for(int i=0;i<n;i++)if((s[i]-'0')%p==0)ans+=i+1;
                  cout<<ans;
                  return 0;
          }
          int t=1,z[p]={},h=0;
          for(int i=n-1;i>=0;i--){
                  h=((s[i]-'0')*t+h)%p;
                  z[h]++;
                  t=(t*10)%p;
          }
           ans=z[0];
          for(int i=0;i<p;i++)ans+=z[i]*(z[i]-1)/2;
        
        cout<<ans;
        


      }


        


Measured memory_bytes: 644
#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>;

vector<int> count_k(string x){
    vector<int> count; 
    rep(i,x.size()){
        count.push_back(int(x[x.size()-1-i]-'0'));
    }
    //reverse(count.begin(),count.end());
    return count;
}

int choose(int n,int k){
    int res = 1;
    rep(i,k){
        res*=n;
        n--;
    }
    rep(i,k){
        res/=(k-i);
    }
    return res;
}

int main(){
    string n;
    int k;
    cin >> n >> k;
    vector<int> N;
    N = count_k(n);

    int G[N.size()][4];

    /*
    int ref=0;
    for(int i=1;i<=n;++i){
        vector<int> p;
        p = count_k(i);
        int temp=0;
        rep(i,p.size()){
            if(p[i]!=0) temp++;
        }
        if(temp==k) ref++; 
    }
    cout <<"ref" << ref << endl;;
    */
    rep(i,N.size()){
        for(int j=1; j<=3; ++j){
            if(j==1){
                if(N[i]==0){
                    if(i==0) G[i-1][j]=0;
                    G[i][j]=G[i-1][j];
                    continue;
                }
                G[i][j]=N[i]+9*i;
            }
            if(j==2){
                if(i==0){
                    G[i][j]=0;
                    continue;
                }
                if(N[i]==0){
                    G[i][j]=G[i-1][j];
                    continue;
                }
                G[i][j]=choose(i,2)*81+choose(i,1)*9*(N[i]-1)+G[i-1][1];
            }
            
            if(j==3){
                if(i==0){
                    G[i][j]=0;
                    continue;
                }
                if(N[i]==0){
                    G[i][j]=G[i-1][j];
                    continue;
                }
                G[i][j]=choose(i,3)*81*9+choose(i,2)*81*(N[i]-1)+G[i-1][2];
            }
        }
    }
    /*
    rep(i,N.size()){
        rep(j,3) cout << G[i][j+1] << " ";
        cout << endl;
    }*/

    cout << G[N.size()-1][k] << endl;


}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int last = -1;
		for(int i=0;i<N-1;i++){
			if(A[i+1] + A[i] >= L){
				last = i;
				break;
			}
		}
		if(last == -1){
			Console.WriteLine("Impossible");
			return;
		}
		
		var ans = new List<int>();
		ans.Add(last + 1);
		int l = last - 1;
		while(l >= 0){
			ans.Add(l+1);
			l--;
		}
		
		int r = last + 1;
		while(r < N-1){
			ans.Add(r+1);
			r++;
		}
		Console.WriteLine("Possible");
		ans.Reverse();
		foreach(var n in ans) Console.WriteLine(n);
	}
	int N;
	long L;
	long[] A;
	public Sol(){
		var d = ria();
		N = d[0]; L = d[1];
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 30172
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		List<String> strList = new ArrayList<String>(Arrays.asList(s.split("")));
		List<String> answerList = new ArrayList<String>();

		for (String str : strList) {
			if (answerList.size() != 0 && !answerList.get(answerList.size() - 1).equals(str)) {
				answerList.add(str);
			} else if (answerList.size() == 0) {
				answerList.add(str);
			}
		}

		System.out.println(answerList.size());
	}
}


Measured memory_bytes: 34520
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e9
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    ll N, M, R;
    cin >> N >> M >> R;
    vector<ll> r(R);
    REP(i, R) {
        cin >> r[i];
        r[i]--;
    }
    ll A, B, C;
    vector<vector<ll>> dp(N, vector<ll>(N, INF));
    REP(i, M){
        cin >> A >> B >> C;
        A--;
        B--;
        dp[A][B] = C;
        dp[B][A] = C;
    }
    REP(k, N) REP(i, N) REP(j, N){
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    }
    sort(r.begin(), r.end());
    ll ans = INF;
    do{
        ll tmp = 0;
        REP(i, R-1) tmp += dp[r[i]][r[i+1]];
        ans = min(ans, tmp);

    }while(next_permutation(r.begin(), r.end()));
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 768
N = int(input())

AB = [map(int, input().split()) for _ in range(N)]
A, B = map(list, zip(*AB))

listXmin = []
listXmax = []
maxXi = 0
minXi = 10 ** 10
for i in range(N):
    listXmin.append(A[i])
    listXmax.append(B[i])

listXmin.sort()
listXmax.sort()
if N % 2 == 0:
    centrali = int(N / 2) - 1
    centralinext = int(N / 2)
    print(((listXmax[centrali] + listXmax[centralinext]) - (listXmin[centrali] + listXmin[centralinext])) + 1)
else:
    centrali = int((N + 1) / 2) - 1
    print(listXmax[centrali] - listXmin[centrali] + 1)

Measured memory_bytes: 117284
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n>>k;
	ld ar[n+1]; ar[0]=0.0;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	for(i=1;i<=n;i++){
		l=ar[i];
		ar[i]=(l*(l+1))/2.0;
		ar[i]=ar[i]/l;
		//cout<<ar[i]<<endl;
	}

	for(i=2;i<=n;i++){
		ar[i]+=ar[i-1];
	}
	ld mx=0;
	for(i=k;i<=n;i++){
		mx=max(mx,ar[i]-ar[i-k]);
	}
	cout<<fixed<<setprecision(10)<<mx;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N,L;
  cin>> N>>L;
  int sum=(2*L+N-1)*N/2;
  int mn=L,mx=L+N-1;
  if(mn>0)cout<<sum-mn;
  else if(mx<0)cout<<sum-mx;
  else cout<<sum;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits>
const int mod = 1e9 + 7;
#define INF 1000000000000000
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<bool> vis(n, false);
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        vis[a] = true;
    }
    vector<int>dp(n+1,0);
    dp[0] = 1;
    if (vis[1]==false){
        dp[1]=1;
    }
    FOR(i, 2,n+1){
        if (vis[i]) continue;
        dp[i]=(dp[i-1] + dp[i-2])%mod;
    }
    cout<<dp[n];
}

Measured memory_bytes: 640
#include <stdio.h>

int Max(int x,int y);
int Min(int x,int y);

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

    int min;
    int up_max;
    int up;
    int x;

    scanf("%d",&min);

    scanf("%d",&x);
    up_max=x-min;
    min=Min(min,x);

    for(int i=0;i<N-2;i++){
        scanf("%d",&x);
        up=x-min;
        up_max=Max(up_max,up);
        min=Min(min,x);
    }

    printf("%d\n",up_max);
}

int Max(int x,int y){
    if(x>=y)
        return x;
    else
        return y;
}
int Min(int x,int y){
    if(x<=y)
        return x;
    else
        return y;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int N,h[MAXN];
int dp[MAXN];
void Solve() {
	read(N);
	for(int i = 1 ; i <= N ; ++i) {
		read(h[i]);
	}
	dp[1] = 0;dp[2] = abs(h[2] - h[1]);
	for(int i = 3 ; i <= N ; ++i) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	out(dp[N]);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 1024
#161_D
import heapq
que = [i for i in range(1, 10)]
cnt = 0
k = int(input())

for i in range(k):
    x = heapq.heappop(que)
    if (x % 10) > 0:
        heapq.heappush(que, x * 10 + (x % 10) - 1)
    if (x % 10) < 9:
        heapq.heappush(que, x * 10 + (x % 10) + 1)
    heapq.heappush(que, x * 10 + (x % 10))
    
print(x)

Measured memory_bytes: 11736
S = input()
T = input()

answer = float('inf')
for s in range(len(S)):
    if len(S) - s < len(T):
        break
    count = 0
    for i in range(len(T)):

        if S[s+i] != T[i]:
            count += 1

    answer = min(answer, count)

print(answer)

Measured memory_bytes: 9016
import sys
#import numpy as np
import math
from fractions import Fraction
import itertools

input=sys.stdin.readline
n=int(input())
m=math.ceil(pow(n,0.5))
for i in range(m):
    if n%(m-i)==0:
        p=m-i
        break
q=n//p
ans=q-1+p-1
print(ans)

Measured memory_bytes: 65768
#include <stdio.h>
int main(void){
	int N;
	int i;
	scanf("%d",&N);
	if(N == 1){
		printf("%d",N);
	}else if(N < 4){
		printf("2");
	}else if(N < 8){
		printf("4");
	}else if(N < 16){
		printf("8");
	}else if(N < 32){
		printf("16");
	}else if(N < 64){
		printf("32");
	}else{
		printf("64");
	} 
	return 0;
}

Measured memory_bytes: 128
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let m: usize = scan(tokens);
    let h: usize = 1 << n;
    let w: usize = 1 << m;
    let mut res: Vec<Vec<bool>> = vec![vec![false; w]; h];
    fn rec(n: usize, m: usize, i: usize, j: usize, res: &mut Vec<Vec<bool>>) {
        if n == 1 {
            for y in 1..1 << m {
                res[i + 1][j + y] = true;
            }
        } else if m == 1 {
            for x in 1..1 << n {
                res[i + x][j + 1] = true;
            }
        } else {
            let x = i + (1 << (n - 1));
            let y = j + (1 << (m - 1));
            res[x][y] = true;
            rec(n - 1, m - 1, i, j, res);
            rec(n - 1, m - 1, i, y, res);
            rec(n - 1, m - 1, x, j, res);
            rec(n - 1, m - 1, x, y, res);
        }
    }
    rec(n, m, 0, 0, &mut res);
    for i in 1..h {
        for j in 1..w {
            if res[i][j] {
                print!("1");
            } else {
                print!("0");
            }
        }
        println!("");
    }
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define vs vector<string>
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define tr1(x)                cout<<#x<<": "<<x<<endl
#define tr2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define tr4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl
#define tr3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define db1(x) cerr << #x << ": " << x <<'\n'
#define db2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define db3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<pair<string,int>, int> &a,const pair<pair<string,int>, int> &b)
{
    if(a.ff.ff == b.ff.ff) {
        return (a.ff.ss > b.ff.ss);
    }
    return (a.ff.ff<b.ff.ff);
}
int min(int a, int b){
    if(a<b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b, int c){
    return(max( max(a,b), c ));
}
int min(int a, int b, int c){
    return (min ( min(a,b) , c));
}
int poww(int a, int b)
{
    int res = 1;
    for(int i = 1; i<=b; ++i)
        res *= a;

    return res;
}
int findlcm(int arr[], int n) 
{ 
    // Initialize result 
    int ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (__gcd(arr[i], ans))); 
  
    return ans; 
}
bool prime[100001];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
  }
}

//Define mx for maximum range and MOD for large numbers
#define mx 500005
#define mod 1000000007 

// Declare all the variables and global functions here -
int n, m;
int32_t main(){
    IOS;
    int p,q,r;
    cin >> p >>  q >> r;
    vi v = {p,q,r};
    sort(all(v));
    cout << v[0] + v[1] << endl;
}   

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long LL;
#define M(a,b) memset(a,b,sizeof(a))
#define pb push_back
const int maxn = 100000+10;
const LL mod = 1000000007;
struct Node {
    int l,r;
    bool operator < (const Node &a)const  {
        return (r-l+1)<(a.r-a.l+1);
    }
}s[maxn+(maxn<<1)];
int c[maxn];
int n,m;
void add(int l,int r) {

    while(l<=m) {
        ++c[l];
        l+=l&(-l);
    }
    while(r<=m) {
        --c[r];
        r+=r&(-r);
    }
    return ;
}
int query(int i) {

    int res=0;
    while(i) {
        res+=c[i];
        i-=i&(-i);
    }
    return res;
}
int main() {

    M(c,0);
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;++i) {
        scanf("%d%d",&s[i].l,&s[i].r);
    }
    sort(s+1,s+1+n);
    int cnt=1;
    for (int i=1;i<=m;++i) {
        while(cnt<=n&&s[cnt].r-s[cnt].l+1<i) {
            add(s[cnt].l,s[cnt].r+1);
            ++cnt;
        }
        int ans=0;
        for (int j=i;j<=m;j+=i) {
            ans+=query(j);
        }
        printf("%d\n",ans+n-(cnt-1));
    }
    return 0;
}
/**
7 9
1 7
5 9
5 7
5 9
1 1
6 8
3 4
**/

Measured memory_bytes: 3712
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    vector <int> a(2), b(2);
    cin >> a >> b;
    long long ans = -1e18 - 5;
    forn (i, 0, 2)
        forn (j, 0, 2)
            chkmax(ans, 1LL * a[i] * b[j]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#define tenmillion 1000000
using namespace std;

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

    sort(l.begin(), l.end());
    for (int i = 0; i < n - 1; i++){
        sum += l[i];
    }
    if (l[n - 1] < sum){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    } 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int MAXN = 1e5+5,MAXM = 2e5+5,MOD = 20130427,INF = 0x3f3f3f3f,N=100050;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const db eps = 1e-9;
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define mid l + ((r-l)>>1)
#define rep(i,a,b) for(register int i=(a);i<=(b);i++)
#define vii vector<pair<int,int>>
#define vi vector<int>
using namespace std;

int n,k,cnt;
char s[MAXN];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    //freopen("../A.in","r",stdin);
    //freopen("../A.out","w",stdout);
    cin>>n>>k;
    cin>>(s+1);
    int j=1,ans=0;
    if(s[1]=='0')cnt++;
    for(int i=1;i<=n;i++){
        while(j+1<=n&&(cnt+(s[j+1]=='0'&&s[j]=='1') <= k)){
            j++;
            if(s[j]=='0'&&s[j-1]=='1')cnt++;
        }
        ans=max(ans,j-i+1);
        if(s[i]=='0'&&s[i+1]=='1')cnt--;
    }
    cout<<ans<<'\n';
    return 0;
}

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

int main(){
	long double A,B,H,M;
	cin >> A >> B >> H >> M;
	long double S,T;
	S=360*((60*H+M)/(12*60));
	T=360*(M/60);
	long double K=abs(S-T);
	long double ans=sqrt(A*A+B*B-2*A*B*cos(K*M_PI/180));
	cout << setprecision(20) << ans << endl;
	return 0;
}


Measured memory_bytes: 4168
n = int(raw_input())
f = []
for i in range(10):
	f.append([0 for _ in range(10)])
ans = 0

for a in range(1, n + 1):
	val = a
	first, last = 0, val % 10
	while val != 0:
		first = val % 10
		val = val / 10
	f[first][last] += 1

for a in range(1, n + 1):
	val = a
	first, last = 0, val % 10
	while val != 0:
		first = val % 10
		val = val / 10
	ans += f[last][first]

print ans

Measured memory_bytes: 32668