akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define pai 3.14159265358979323846264338327950238
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	ld a,b,c,d;
	cin>>a>>b>>c>>d;
	ld C=c*30+d*0.5;
	ld D=d*6;
	ld ds=abs(C-D);
	if(ds>180)ds=360-ds; 
	cout<<fixed<<setprecision(20)<<sqrt(a*a+b*b-2*a*b*cos(ds*pai/180));
	return 0;
}



Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
long long int m,n,min1;
unsigned long long int f[100010]={0,1};
int main()
{
	cin>>n>>m;
	min1=m/n;
	for(long long int i=min1;i>=1;i--)
	{
		if(m%i!=0) continue;
		if(m/i>=n)
		{
			cout<<i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define INF 1000000000

int main(){
    int n;
    string s;
    cin>>n>>s;
    map<pair<string,string>,ll> ms;
    rep(i,1<<n){
        int ii=i;
        string s0,s1;
        rep(j,n){
            if(ii&1) s0+=s[j];
            else s1+=s[j];
            ii>>=1;
        }
        reverse(s1.begin(),s1.end());
        ms[make_pair(s0,s1)]++;
    }
    ll ans=0;
    rep(i,1<<n){
        int ii=i;
        string s0,s1;
        rep(j,n){
            if(ii&1) s0+=s[j+n];
            else s1+=s[j+n];
            ii>>=1;
        }
        reverse(s1.begin(),s1.end());
        if(ms.count(make_pair(s1,s0))){
            ans+=ms[make_pair(s1,s0)];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 32240
A, B = map(int, input().split())

grid = [['#' if i < 50 else '.'] * 100 for i in range(100)]


def gen(X):
    cnt = 0
    for i in range(1, 50, 2):
        for j in range(1, 100, 2):
            if cnt < X:
                yield i, j
                cnt += 1


for i, j in gen(A - 1):
    grid[i][j] = '.'
for i, j in gen(B - 1):
    grid[i + 50][j] = '#'

print(100, 100)
for row in grid:
    print(''.join(row))


Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
typedef pair<mp,ll> mmp;

int main(){
    while(1){
	int n;
	cin>>n;
	if(n==0)break;
	vector<mmp> cir(n);
	vector<ll> c(n);
	for(int i=0;i<n;i++){
	    int x,y,r;
	    cin>>x>>y>>r>>c[i];
	    cir[i] = mmp(mp(x,y),r );
	}
	vector<vector<int>> g(n);
	for(int i=0;i<n;i++){
	    for(int j=i-1;j>=0;j--){
		int dis = (cir[i].first.first-cir[j].first.first)*(cir[i].first.first-cir[j].first.first) + (cir[i].first.second-cir[j].first.second)*(cir[i].first.second-cir[j].first.second);
		int rM = ( cir[i].second + cir[j].second);
		rM = rM * rM;
		int rm = (cir[i].second-cir[j].second);
		rm = rm*rm;
		//if( rm < dis && dis < rM){
		if( dis < rM ){
		    g[i].push_back(j);
		    //break;
		}
	    }
	}
	int res = 0;
	vector<bool> dp(1<<n,false);
	dp[(1<<n)-1] = true;
	//for(int i=0;i<g.size();i++)cout<<g[i]<<endl;
	for(int i= (1<<n)-1 ;i>=0;i--){
	    if(dp[i]){
		//cout<<i<<':'<<endl;
		int cnt = 0;
		for(int j=0;j<n;j++)if( ((i>>j) & 1) == 0 ) cnt++; 
		res = max(res,cnt);
		vector<int> use;
		for(int j=0;j<n;j++){
		    if( ((i>>j) & 1) == 0) continue;
		    
		    int now = j;
		    bool flag = true;
		    for(int k=0;k<g[j].size();k++){
			if( ( (i>>g[j][k] ) & 1 )==1 ){
			    flag = false;
			    //cout<<g[now]<<endl;
			    break;
			}
		    }
		    if(flag)use.push_back(j);
		}
		//for(int j=0;j<use.size();j++) cout<<use[j]<<endl;
		//for(int j=0;j<use.size();j++) if(  ((i>>use[j])&1) == 0 ) cout<<"ERROR"<<endl;
		for(int j=0;j<use.size();j++){
		    for(int k=j+1;k<use.size();k++){
			if( c[use[j]] == c[ use[k] ] ){
			    dp[ i ^ (1<<use[j] ) ^(1<<use[k]) ] = true;
			}
		    }
		}
	    }
	}
	cout<<res<<endl;

    }
    return 0;
}



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

using namespace std;

typedef long long int ll;

ll inf = 1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k, d;
    cin >> n;
    vector<int> a(26,0);

    char c;
    for(int i = 0; i < n; i++)
    {
        cin >> c;
        a.at(c-'a')++;
    }

    ll sum = 1;
    for(int i = 0; i < 26; i++)
    {
        sum *= (ll)(a.at(i)+1);
        sum %= inf;
    }

    cout << (sum-1);




    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
double radians(double radius)
{
	return radius/180.0*3.141592653589;
}
int main(void)
{
	double a,b,c,S,L,h;
	scanf("%lf %lf %lf",&a,&b,&c);
	S=0.5*a*b*sin(radians(c));
	L=a+b+sqrt(a*a+b*b-2*a*b*cos(radians(c)));
	h=b*sin(radians(c));
	printf("%lf\n%lf\n%lf\n",S,L,h);
	return 0;
}

Measured memory_bytes: 672
#include<stdio.h>

int main(void){
  int n,m;
  int i,j,k;
  int tmp[200001];
  int req[100001],fin[200001];
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d",&req[i]);
  }
 
  for(i=0;i<n;i++){
    tmp[i]=i+1;
  }

  // putchar('\n');

     for(k=0;k<m;k++){
       if(tmp[req[m-k-1]-1] && (m-k-1)>=0){
	 fin[k]=req[m-k-1];
	 printf("%d\n",fin[k]);
	 tmp[fin[k]-1]=0;
       }
     }

  for(k=0;k<n;k++){
    if(tmp[k]){
      printf("%d\n",tmp[k]);
    }
  }
  return 0;
}

Measured memory_bytes: 1764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<30;
const ll LLINF = 1LL<<62;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >> a >> b >> c;
  int mx = max(max(a,b),c);
  int sm = a+b+c;
  if ((sm+mx)%2==1){
      mx++;
  }
  cout << (3*mx-sm)/2 << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n = in();
	array<array<char, 8>, 8>g;
	REP(i, n) {
		REP(j, 8)REP(k, 8) g[j][k] = in<char>();
		ll X = in() - 1, Y = in() - 1; queue<pair<ll, ll>>bombs; bombs.push(make_pair(X, Y));
		while (!bombs.empty()) {
			ll x = bombs.front().first, y = bombs.front().second; bombs.pop(); g[y][x] = '0';
			REP1(j, 3) {
				if (x + j >= 8)break;
				if (g[y][x + j] == '1')bombs.push(make_pair(x + j, y));
				g[y][x + j] = '0';
			}
			REP1(j, 3) {
				if (y - j < 0)break;
				if (g[y - j][x] == '1')bombs.push(make_pair(x, y - j));
				g[y - j][x] = '0';
			}
			REP1(j, 3) {
				if (x - j < 0)break;
				if (g[y][x - j] == '1')bombs.push(make_pair(x - j, y));
				g[y][x - j] = '0';
			}
			REP1(j, 3) {
				if (y + j >= 8)break;
				if (g[y + j][x] == '1')bombs.push(make_pair(x, y + j));
				g[y + j][x] = '0';
			}
		}
		cout << "Data " << i + 1 << ':' << endl;
		REP(j, 8) {
			REP(k, 8) {
				cout << g[j][k];
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3096
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#define int long long
const int inf=1145141919810893;
const int mod=1000000007;
using namespace std;
template<class T>bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<class T>bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
int p[50],N;
signed main(){
	int i,j;
	cin>>N;
	for(i=0;i<N;i++)
		cin>>p[i];
	int q[13]={};
	for(i=0;i<N;i++)
		q[p[i]]++;
	if(q[0]!=0){
		cout<<0<<endl;
		return 0;
	}
	for(i=1;i<13;i++)
		if(q[i]>2){
			cout<<0<<endl;
			return 0;
		}
	int u=0;
	for(i=0;i<13;i++)
		if(q[i]==1)
			u++;
	int ans=0;
	for(i=0;i<(1<<u);i++){
		int r[24]={};
		int k=0;
		for(j=1;j<13;j++){
			if(q[j]==2){
				r[j]++;
				r[24-j]++;
			}
			else if(q[j]==1){
				if(i&(1<<k))
					r[j]++;
				else
					r[24-j]++;
				k++;
			}
		}
		int min=inf;
		for(j=0;j<24;j++)
			if(r[j]>=2)
				min=0;
		if(min!=0){
			for(j=0;j<24;j++)
				for(k=j+1;k<24;k++)
					if(r[j]&&r[k])
						chmin(min,k-j);
		}
		for(j=0;j<24;j++)
			if(r[j]){
				chmin(min,j);
				chmin(min,24-j);
			}
		chmax(ans,min);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  if (s.size() < 26) {
    int used[26] = {};
    for (auto&& ch : s) {
      used[ch - 'a']++;
    }
    cout << s;
    for (int i = 0; i < 26; i++) {
      if (used[i]) continue;
      cout << char(i + 'a') << endl;
      return 0;
    }
  }
  if (s == "zyxwvutsrqponmlkjihgfedcba") {
    cout << -1 << endl;
    return 0;
  }
  int pos = 25;
  while (pos && s[pos - 1] > s[pos]) pos--;
  int used[26] = {};
  for (int i = 0; i < pos; i++) {
    used[s[i] - 'a']++;
  }
  cout << s.substr(0, pos - 1);
  for (int i = 0; i < 26; i++) {
    if (used[i] || i <= s[pos - 1] - 'a') continue;
    cout << char(i + 'a') << endl;
    break;
  }

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		try {
			
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			long N =Long.parseLong(br.readLine());
			long A = Long.parseLong(br.readLine());
			long B = Long.parseLong(br.readLine());
			long C = Long.parseLong(br.readLine());
			long D = Long.parseLong(br.readLine());
			long E = Long.parseLong(br.readLine());
			
			long [] ninzu = {A,B,C,D,E};
			long min=Long.parseLong("999999999999999");
			for(int i=0;i<5;i++) {
				if (ninzu[i]<=min) {
					min=ninzu[i];
				}
			}

			if (min!=1) {
				System.out.println(	N/min+ 5);
			} else {
				System.out.println(	N/min+ 5-1);
			}
			
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	private static void init() {
		
	}
}


Measured memory_bytes: 22484
#include <iostream>
using namespace std;
int main(){
int k,s,z;
cin>>k>>s;
int c=0;
for(int i=0;i<=k;i++){
for(int j=0;j<=k;j++){
	z=s-i-j; 
	if(s==(i+j+z))
if(z>=0&&z<=k)
c+=1;
}}
cout<<c;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long N,ans;
int main(){
    cin>>N;
    vector<long long>F(N+1,0LL);
    for(int i=1;i<=N;i++)for(int j=i;j<=N;j+=i)F[j]++;
    for(int i=1;i<=N;i++)ans+=i*F[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 81416
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Majk
 */

#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first
#define y second
constexpr int MOD = 1000000007;

typedef std::pair<int,int> pii;
typedef long long ll;

template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

namespace std {
    template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

// #include "../l/mod.h"

class C {
public:
	void solve(istream& cin, ostream& cout) {
		int N; cin >> N;
		int B; cin >> B;
		ll A[3] = {B, -1000000000000000LL, -1000000000000000LL};
		for (int i = 0; i < N-1; ++i) {
			char c; cin >> c;
			cin >> B;

			if (c == '+') {
				A[0] = max(A[0], A[1]) + B;
				A[1] = A[1] - B;
				A[2] = A[2] + B;
			} else {
				A[2] = max(A[1], A[2]) + B;
				A[1] = max(A[1], A[0]) - B;
				A[0] = A[0] - B;
			}
		}

		cout << max(A[0], max(A[1], A[2])) << endl;
	}
};


int main() {
	ios_base::sync_with_stdio(false);
	C solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

vector<vector<int> >G;
vector<int>vec;
int a[100003];
int n,m;

int main(){
    
    string str;
    cin>>str;
    for(int i=1;i<str.length();i++){
        if(str[i]==str[i-1]){
            cout<<i<<" "<<i+1<<endl;
            return 0;
        }
        if(i>1&&str[i]==str[i-2]){
            cout<<i-1<<" "<<i+1<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int A,B,C,X,ans=0;
	cin >> A >> B >> C >> X;
	rep(i, A+1) {
		rep(j, B + 1) {
			rep(k, C + 1) {
				if (i * 500 + j * 100 + 50 * k == X)
					ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int h, w;
	cin >> h >> w;

	vector<string> grid(h);
	for (int i = 0; i < h; ++i) {
		cin >> grid[i];
	}

	vector<vector<int> > dp(h, vector<int> (w, 1e9));
	dp[0][0] = (grid[0][0] == '#');
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (i) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + (grid[i][j] != grid[i - 1][j]));
			}

			if (j) {
				dp[i][j] = min(dp[i][j], dp[i][j - 1] + (grid[i][j] != grid[i][j - 1]));
			}	
		}
	}

	cout << (dp[h - 1][w - 1] + 1) / 2 << "\n";

	return 0;

}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    private const long INF = 1000000007;
    private struct Pair { public long x, y; public Pair(long xx, long yy) { x = xx; y = yy; } }
    public static void Main()
    {
        int N = NextInt();
        int M = NextInt();
        List<int>[] list = new List<int>[M];
        for (int i = 0; i < M; i++)
        {
            list[i] = new List<int>();
            int k = NextInt();
            for (int j = 0; j < k; j++) list[i].Add(NextInt());
        }
        int[] p_ans = LineInt();

        //bit??
        int ans = 0;
        int R = (int)Math.Pow(2, N);
        for (int bit = 0; bit < R; bit++)
        {
            int[] push = new int[M];
            for (int shift = 0; shift < N; shift++)
            {
                if ((1 & bit >> shift) == 1)
                {
                    //それぞれのボタンを押してつくかつかないか
                    for (int i = 0; i < M; i++) {
                        if (list[i].Contains(shift + 1)) push[i]++;
                    }
                }
            }

            bool ok = true;
            for (int i = 0; i < M; i++) {
                if (push[i] % 2 != p_ans[i]) ok = false;
            }
            if (ok) ans++;
        }
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13408
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long int idx[100001];
long long int power(long long int x,long long int y,long long int z)
{
    long long int res=1;
    x%=z;
    while(y>0)
    {
        if(y&1)
        res=(res*x)%z;
        x=(x*x)%z;
        y/=2;
    }
    return res;
}

long long int power1(long long int x,long long int y)
{
    long long int res=1;
    while(y>0)
    {
        if(y&1)
        res=(res*x);
        x=(x*x);
        y/=2;
    }
    return res;
}

long int root(long int x)
{
    while(idx[x]!=x)
    x=idx[x];
    return x;
}

void union1(long int x,long int y)
{
    idx[root(x)]=root(y);
}
int main() {
	
	
int n,k;
cin>>n>>k;
long int a[n],b[n];
for(long int i=0;i<n;i++)
b[i]=INT_MAX;
for(long int i=0;i<n;i++)
cin>>a[i];
b[0]=0;
b[1]=abs(a[1]-a[0]);
for(long int i=1;i<n;i++)
{
    for(long int j=i-1;j>=0&&j>=i-k;j--)
    {
        b[i]=min(b[i],b[j]+abs(a[i]-a[j]));
    }
}
cout<<b[n-1];
	
	
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9+7;
#define PI 3.1415926535
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
const int siz = 2*(1e5 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int has[siz];
int ifact[siz];
int bit[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}

bool ispalin(string s)
{
	string k = s;
	reverse(k.begin(),k.end());
	if(k == s)
	{
		return true;
	}

	return false;
}


signed main()
{
   
	speedrap
	int t;
	//cin>>t;
	t = 1;
	while(t--)
	{
		string s;
		cin>>s;
		if(s[2] == s[3] and s[4] == s[5])
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
using namespace std;
using lli = long long int; 

int main(){
	lli n;
	string s,t;
	cin >> n;
	cin >> s;
	cin >> t;
	string ans;
	for(int i=0; i<n; i++){
		cout << s[i];
		cout << t[i];
	}
}

Measured memory_bytes: 256
s = gets.chomp.chars
acgt = ["A", "C", "G", "T"]
# gets.split.map(&:to_i)

ans = 0
tmp = 0
s.each do |c|
  if acgt.include?(c)
    tmp += 1 
  else
    ans = [ans, tmp].max
    tmp = 0
  end
end

ans = [ans, tmp].max

puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, x, y; cin >> h >> w >> x >> y;
    if(h * w % 2 and (x + y) % 2) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}




Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll INF = 1e18;

struct ST {
  ll a, b;
};
bool operator==(const ST& x, const ST& y){
  return (x.a == y.a && x.b == y.b);
}

int N, M;
vector<pair<ll,ll>> G[100005];
vector<ST> states[100005];


int main(){
  cin >> N >> M;
  rep(i,M){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    G[a].emplace_back(b,c);
    G[b].emplace_back(a,c);
  }

  queue<pair<int,ST>> que;
  que.push(make_pair(0,(ST){1,0}));
  while(!que.empty()){
    pair<int,ST> p = que.front(); que.pop();

    bool flg = false;
    rep(i,states[p.first].size()){
      if(states[p.first][i] == p.second) flg = true;
    }
    if(flg) continue;
    states[p.first].push_back(p.second);

    if(states[p.first].size() > 2){
      cout << 0 << endl;
      return 0;
    }

    rep(i,G[p.first].size()){
      pair<ll,ll> j = G[p.first][i];
      que.push(make_pair(j.first,(ST){-p.second.a,j.second-(p.second.b)}));
    }
  }

  ll lb = 0, ub = INF;
  rep(i,N){
    if(states[i].size() == 1){
      if(states[i][0].a > 0){
        //x+b>0
        lb = max(lb, -states[i][0].b);
      }else{
        //-x+b>0
        ub = min(ub, states[i][0].b);
      }
    }else{
      if(states[i][0].a > 0 && states[i][1].a < 0){
        lb = max(lb, -states[i][0].b);
        ub = min(ub, states[i][1].b);

        //x+a == -x+b <=> x = (b-a)/2 > 0
        if(llabs(states[i][1].b - states[i][0].b)%2 == 0){
          ll x = llabs(states[i][1].b - states[i][0].b) / 2;
          if(states[i][1].b - states[i][0].b < 0) x *= -1;
          lb = max(lb, x-1);
          ub = min(ub, x+1);
        }
      }
      else if(states[i][0].a < 0 && states[i][1].a > 0){
        ub = min(ub, states[i][0].b);
        lb = max(lb, -states[i][1].b);

        //-x+a == x+b <=> x = (a-b)/2 > 0
        if(llabs(states[i][0].b - states[i][1].b)%2 == 0){
          ll x = llabs(states[i][0].b - states[i][1].b) / 2;
          if(states[i][0].b - states[i][1].b < 0) x *= -1;
          lb = max(lb, x-1);
          ub = min(ub, x+1);
        }
      }
      else{
        cout << 0 << endl;
        return 0;
      }
    }
  }

  lb++;
  if(ub-lb <= 0) cout << 0 << endl;
  else cout << ub - lb << endl;

  return 0;
}


Measured memory_bytes: 18192
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,a,b;
  bool chk = false;
  cin>>k;
  cin>>a>>b;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0) chk=true;
  }
    if(chk){
      cout<<"OK"<<endl;
    }
    else cout<<"NG"<<endl;

  return 0;
}


Measured memory_bytes: 3620
using System;

namespace AGC011
{
    class A
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int N = int.Parse(input[0]);
            int C = int.Parse(input[1]);
            int K = int.Parse(input[2]);

            int[] T = new int[N];

            for (int i = 0; i < T.Length; i++)
            {
                T[i] = int.Parse(Console.ReadLine());
            }

            Array.Sort(T);

            int busCount = 0;
            int passengerCount = 0;
            int index = 0;

            for (int i = 0; i < N; i++)
            {
                passengerCount++;

                if (i == N - 1 || passengerCount == C || T[index] + K < T[i + 1])
                {
                    busCount++;
                    index = i + 1;
                    passengerCount = 0;
                }
            }
            Console.WriteLine(busCount);
        }
    }
}


Measured memory_bytes: 15452
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int n;scanf("%d",&n);
	map<int,int>cnt;
	rep(i,n){
		int a;scanf("%d",&a);
		cnt[a]++;
	}
	int ans=0;
	for(auto p:cnt){
		if(p.first>p.second)ans+=p.second;
		else ans+=p.second-p.first;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793

int main() {
  double a,b,x;
  cin >> a >> b >> x;
  if(a*a*b<=2*x){
    double v=a*a*b-x;
    double z=a*a*a;
    double w=2*v/z;
    
    cout << fixed << setprecision(6)<<atan(w)*180/PI << endl;
  }
  else{
    double v=x;
    double z=a*b*b;
    double w=z/2/x;
    cout << fixed << setprecision(6)<<atan(w)*180/PI<< endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a;
  cin >> a;
  if (a=='a'||a=='i'||a=='u'||a=='e'||a=='o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

ll res[11];
void Sequence() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;

	cout << (min(n, k) * x + max(n - k, 0) * y) << endl;

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    vstr s(n);
    rep(i,n)cin>>s[i];
    set<string> t;
    rep(i,n)t.insert(s[i]);
    vector<pair<int,string>> p(n);
    map<string,int> m;
    int l=0;
    for(auto u:t){
        p[l]=make_pair(0,u);
        m[u]=l;
        l++;
    }
    rep(i,n){
        p[m[s[i]]].first--;
    }
    sort(all(p));
    for(auto q:p){
        if(q.first==p[0].first)cout<<q.second<<endl;
        else break;
    }
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 500'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  cin >> n >> m >> k;
  cout << (n + m - 1) / m * k << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 3632
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n,a,b = map(int, input().split())

def func(s):
    rtn = 0
    for i in s:
        rtn += int(i)
    return rtn

ans = [0]
for i in range(1,n+1):
    temp = func(str(i))
    if (temp >= a and temp <= b):
        ans.append(i)

print(sum(ans))






Measured memory_bytes: 9424
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,k;
ll a[200000];
ll b[200000];
int main(){
	cin >> n >> k;
	REP(i,n){
		cin >> a[i + 1];
		b[i + 1] = max(0ll,a[i + 1]);
	}

	REP(i,n) {
		a[i + 1] += a[i];
		b[i + 1] += b[i];
	}

	ll ans = 0;

	REP(i,n - k + 1) {
		ll sum = max(a[i + k] - a[i],0ll);
		sum += b[i] - b[0];
		sum += b[n] - b[i + k];
		ans = max(ans,sum);
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
    int a,b,c;
    string op;

    while (1){
        cin >> a >> op >> b ;
        if (op == "?") {
            break;
        } 
        if(op == "+"){
            c = a + b;
            cout << c << endl;
        }else if(op == "-"){
            c = a - b;
            cout << c << endl;
        }else if(op == "*"){
            c = a * b;
            cout << c << endl;
        }else{
            c = a / b;
            cout << c << endl;
        }
    }

    return 0;

}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define N 2003
#define LL long long
#define mod 998244353

int n,ans;
int a[N],b[N],c[N],f[1<<23];

inline int read(){
	int X=0,w=0;
	char ch=0;
	while (ch<'0' || ch>'9')
	  w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9')
	  X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w ? -X : X;
}

int main(){
	n=read();
	for (int i=1;i<=n;i++)
	  a[i]=read();
	for (int i=1;i<=n;i++)
	  b[i]=read();
	for (int i=1;i<n;i++)
	  c[i]=read();
	for (int i=1;i<=n;i++){
	  	ans+=b[a[i]];
		if (i>1 && a[i]==a[i-1]+1) ans+=c[a[i-1]];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[ten52];
//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
vector<ll> vll[2003];

/*void dfs(ll n,ll t)
{
    for(int i=1;i<vll[n].size();i++)
}*/

int main(void)
{
    double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1,a2,a3,sum;
    string s,s1,s2;
    char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>n;
    sum=(1+n)*n/2;
    a=(3+(n/3)*3)*(n/3)/2;
    a1=(5+(n/5)*5)*(n/5)/2;
    a2=(15+(n/15)*15)*(n/15)/2;
    cout<<sum-a-a1+a2;
    return 0;
}





Measured memory_bytes: 3640
# coding: utf-8

def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    a_sum = sum(a_list)
    ans = 0 
    for i in range(n-1):
        a_head = a_list[i]
        a_sum -=  a_head
        ans += a_head * a_sum
    
    print(ans % (10**9 + 7))
        

main()

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

int solve();
int check(int i, int j);
int heiho(int dist);
int N, D;
int counter =0;

vector<vector<int>> xx;


int main(){
  cin >> N >> D;
  xx = vector<vector<int>>(N, vector<int>(D));
  for(int i = 0; i< N; i++){
    for (int j = 0; j<D; j ++){
      cin >> xx.at(i).at(j);
    }
  }
  solve();
}

int solve(){
  for(int i =0; i< N; i++){
    for(int j=i+1; j<N; j++){
      check(i, j);
      // cout << i << j<<endl;
    }
  }
  cout << counter << endl;
  return 0;

}

int check(int i, int j){
  int dist  = 0, buf;
  for(int k= 0; k <D; k++){
    buf = (xx.at(i).at(k)-xx.at(j).at(k));
    dist += buf * buf;
  }
  if(heiho(dist) == 1){
    // cout << i << j << "www" <<endl;
  }
  return 0;
}

int heiho(int dist){
  for(int k = 0; k< dist+1; k++){
    if(k * k == dist){
      counter++;
      return 1;
    }else if(k * k > dist){
      break;
    }
  }
  return 0;
}


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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;

int main() {

	IO; 
	
	string s;
	cin >> s;
	
	ll num = 0;
	int sum = 0;
	
	for (int i = 0; i < (int) s.size(); ++i) {
		sum += s[i]-'0';
		num += s[i] - '0';
		num*= 10;
	}
	num/=10;
	
	cout << (num%sum==0? "Yes" : "No");
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N, K);
  ll current = 1ll;
  ll x = 1ll;
  REP(i, N) {
    if (current < K) {
      current *= 2;
    } else {
      current += K;
    }
  }

  cout << current  << endl;

  return 0;
}



Measured memory_bytes: 256
import itertools

A, B, C, D = [int(s) for s  in list(input())]

opsgen = itertools.product((1, -1), repeat=3)

for op1, op2, op3 in opsgen:
    res = A + op1 * B + op2 * C + op3 * D
    if res == 7:
        print(
            '{A}{op1}{B}{op2}{C}{op3}{D}=7'.format(
                A=A, B=B, C=C, D=D,
                op1= '+' if op1 == 1 else '-',
                op2= '+' if op2 == 1 else '-',
                op3= '+' if op3 == 1 else '-',
            )
        )
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int dp[2000][2000];
signed main(){
  int n;cin >> n;
  rep(i,n){
    string s1, s2;cin >> s1 >> s2;
    s1 = " " + s1;s2 = " " + s2;
    int ans = 0;
    rep(j,2000)rep(k,2000)dp[j][k] = 0;
    rrep(j,s1.size()-1)rrep(k,s2.size()-1){
      if(s1[j] == s2[k])dp[j][k] = dp[j-1][k-1] + 1;
      else dp[j][k] = max(dp[j-1][k], dp[j][k-1]);
      // if(j == 5 and k == 5)cout << dp[j][k] << endl;
      ans = max(ans, dp[j][k]);
    }
    cout << ans << endl;
  }
  return 0;
}







Measured memory_bytes: 34404
#include <cstdio>
#include <algorithm>
#define f1(i,n) for(int i=0;i<(int)n;i++)
const int inf = 1000000000;
using namespace std;
int main(){
	int n;scanf("%d",&n);
	int arr[n];
	f1(i,n){
			scanf("%d",&arr[i]);
		}
	int ans = inf;
	for(int i=1;i<=100;i++){
			int cost = 0;
			f1(j,n)cost += (arr[j]-i)*(arr[j]-i);
			ans = min(ans,cost);
		}
	printf("%d",ans);		
	return 0;
	}




Measured memory_bytes: 1736
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

int tl(char c) {
    if (c == 'A') {
        return 1;
    } else if (c == 'C') {
        return 2;
    } else if (c == 'G') {
        return 3;
    } else if (c == 'T') {
        return 4;
    }
}

long int hash(std::string s) {
    long int ret = 0;
    for (int i=0; i<s.size(); i++) {
        ret += tl(s[i]) * std::pow(5,i);
    }
    return ret;
}

int main() {
    int n;
    std::cin >> n;
    static bool dict[1<<28] = {};
    for (int i=0; i<n; i++) {
        std::string operation, operand;
        std::cin >> operation >> operand;
        if (operation == std::string("insert")) {
            dict[hash(operand)]=true;
        } else {
            if (dict[hash(operand)]) {
                std::cout << "yes" << std::endl;
            } else {
                std::cout << "no" << std::endl;
            }
        }
    }

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int N;
string s[55];
ll dp[55][55][23][30];
const char e='a'-1;

ll dfs(int l,int r,int i,int c){
  if(l>=r)return 1;
  if(i==20)return l+1==r?1:0;
  if(dp[l][r][i][c]!=-1)return dp[l][r][i][c];

  ll res=0;
  if(c==26){
    bool ok=true;
    repl(j,l,r){
      if(s[j][i]!='?'&&s[j][i]!=e+c)ok=false;
    }
    if(ok)res=dfs(l,r,i+1,0);
  }else if(c!=0){
    res=dfs(l,r,i,c+1);
    repl(j,l,r){
      if(s[j][i]!='?'&&s[j][i]!=e+c)break;
      ll vl=dfs(l,j+1,i+1,0);
      ll vr=dfs(j+1,r,i,c+1);
      (res+=vl*vr%mod)%=mod;
    }
  }else{
    res=dfs(l,r,i,c+1);
    repl(j,l,r){
      if(s[j][i]!=e+c)break;
      ll vl=dfs(l,j+1,i+1,0);
      ll vr=dfs(j+1,r,i,c+1);
      (res+=vl*vr%mod)%=mod;
    }
  }
  return dp[l][r][i][c]=res;
}

int main(){
  cin>>N;
  rep(i,N){
    cin>>s[i];
    while(s[i].size()<21)s[i]+=e;
  }
  memset(dp,-1,sizeof(dp));
  cout<<dfs(0,N,0,0)<<endl;
  return 0;
}



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

int main() {
  int n, count;
  cin >> n;
  count = 0;
  
  for (int i=1; i<=n; i++) {
  	if (to_string(i).size()%2==1) {
    	count++;
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
n=gets.chomp.to_i
x=gets.chomp.split(" ").map { |e| e.to_i }

median = n/2 - 1
a = Marshal.load(Marshal.dump(x)).sort

def binary_search(a,n,x)
  ub = n
  lb = -1

  while ub-lb > 1
    m = (lb+ub)/2
    if a[m] >= x
        ub = m
    else
      lb = m
    end
  end

return ub

end


for i in 0..n-1 do
  temp = binary_search(a,n,x[i])
  if median >= temp
      puts a[median+1]
  else
    puts a[median]
  end
end

Measured memory_bytes: 26724
#!/usr/bin/python3
# coding: utf-8

# 整数 > 整数型
def I(): return int(input())

# 整数列 '1 2 3 4' > 整数型リスト
def IsIl(): return list(map(lambda x: int(x), input().split()))

# 改行挟む整数列　'1/n 2/n 3/n' > 整数型りすと
def InIl(n): return [input() for i in range(n)]

# 整数列 '1 2' > 整数型タプル
def IsIt(): return map(lambda x: int(x), input().split())

# 改行挟む整数列　'1\n 2\n 3\n' > 整数型たぷる
def InIl(n): return map(input() for i in range(n))

# 文字列 'abcd' > 文字型リスト
def SsSl(): return list(map(lambda x: x, input()))

# 整数 '1234' > 整数型リスト

# 文字列 'aba' > 辞書（文字型:個数）{'a':2,'b':1}
def SSd():
    from collections import defaultdict
    A = input() # [int(i) for i in input().split()]
    dd=defaultdict(int)
    for a in A:
        dd[a]+=1
    return dd

import math

n = I()
lis = []
for i in range(n):
    tup = IsIl()
    lis.append(tup)

sum = 0.0
for i in range(n):
    [x1,y1] = lis[i]
    for j in range(n):
        [x2,y2] = lis[j]
        sum += ((x1-x2)**2 + (y1-y2)**2)**0.5
print(sum/n)

        
    


Measured memory_bytes: 3064