akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int N,a[1000];
set<int> st;
int main(){
	cin>>N;
	rep(i,N) cin>>a[i];
	rep1(K,4){
		rep(j,N+1-K){
			int x=0;
			rep(k,K) x=x*10+a[j+k];
			st.insert(x);
		}
	}
	rep(i,10000){
		if(!binary_search(all(st),i)){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3212
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
int main()
{
	string s;
	while(cin >> s)
	{
		int maxn;
		if(s.size() == 1)
		{
			stringstream ss(s);
			ss >> maxn;
		}
		else
		{
			int flag = 1;
			for(int i = 1;i < s.size();++i)
			{
				if(s.at(i) - 48 != 9)
					flag = 0;
			}
			if(flag)
				maxn = s.at(0) - 57 + 9 * s.size();
			else
				maxn = s.at(0) - 58 + 9 * s.size();
		}
		cout << maxn << endl;
	}
	return 0;
}

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

size_t maxbin = 0;
size_t maxval = 1;
size_t GetBin(size_t num) {
  size_t bin = 0;

  while(num != 0) {
    num /= 2;
    bin++;
  }

  if (maxbin < bin) {
    maxbin = bin;
    maxval = pow(2, bin);
  }

  return bin;
}

int main(void) {
  int n;

  std::cin >> n; /* 1 to 3*10^5 */

  int* A = new int[n];
  for (size_t i = 0; i < n; i++) {
    std::cin >> A[i];

    //auto bin = GetBin(A[i]);
  }

  //std::cout << maxbin << std::endl;
  //std::cout << maxval << std::endl;

  size_t count = 0;

  //size_t* lcounts = new size_t[n];
  //size_t* rcounts = new size_t[n];

#if 0
  size_t* lsums = new size_t[n];
  size_t* rsums = new size_t[n];
  lsums[0] = A[0];
  rsums[0] = A[0];
  for (size_t i = 1; i < n; i++) {
    lsums[i] = lsums[i-1] ^ A[i];
    rsums[i] = rsums[i-1] + A[i];
  }
#else
#if 0
  size_t lsums = 0;
  size_t rsums = 0;
  for (size_t i = 0; i < n; i++) {
    lsums = lsums ^ A[i];
    rsums = rsums + A[i];
  }
#endif
#endif

  size_t lsum = 0;
  size_t rsum = 0;
  size_t offset = 0;
  for (size_t i = 0; i < n; ++i) {
    size_t lcount = 0;
    for (size_t j = i + offset; j < n; ++j) {
      size_t l = lsum ^ A[j];
      size_t r = rsum + A[j];
      if (l == r) {
        lcount++;
        lsum = l;
        rsum = r;
        continue;
      }
      break;
    }
    count += lcount + offset;
    if (lcount + offset > 1) {
      offset = lcount + offset - 1;
    } else {
      offset = 0;
    }
    lsum ^= A[i];
    rsum -= A[i];
  }
#if 0
  size_t llsum = 0;
  size_t rrsum = 0;
  for (size_t i = n-1; i >= 0; --i) {
    llsum = llsum ^ A[i];
    rrsum = rrsum + A[i];

    size_t lsum = llsum;
    size_t rsum = rrsum;
    for (size_t j = n-1; j >= i; --j) {
      lsum = lsum ^ A[j];
      rsum = rsum - A[j];
      if (lsum == rsum) {
        count++;
      }
    }
  }
#endif

  std::cout << count << std::endl;;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	ll pre = 0, ans = sum;
	for(int i = 0; i < n; ++i) {
		pre += a[i];
		ans = min(ans, abs(2LL * pre - sum));
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1792
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        var T = int.Parse(Console.ReadLine().Trim());
        while (T-- > 0)
        {
            var map = new bool[10][];
            for (int i = 0; i < 10; i++)
            {
                map[i] = new bool[10];
                string[] line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < 10; j++)
                    if (line[j] == "1") map[i][j] = true;
            }
            getAns(map);
        }
    }
    static void getAns(bool[][] map)
    {
        for (int i = 0; i < 1 << 10; i++)
        {
            if (check(map, i)) break;
        }
    }
    static bool[] calcDown(bool[] w, bool[] a)
    {
        var res = new bool[10];
        for (int i = 0; i < 10; i++)
            if (a[i]) res[i] = !w[i];
            else res[i] = w[i];
        return res;
    }
    static bool[] calcSame(bool[] w, bool[] a)
    {
        var res = new bool[10];
        if (a[0]) { res[0] = !w[0]; res[1] = !w[1]; }
        else { res[0] = w[0]; res[1] = w[1]; }
        for (int i = 1; i <= 8; i++)
        {
            if (a[i])
            {
                res[i - 1] = !res[i - 1];
                res[i] = !res[i];
                res[i + 1] = !w[i + 1];
            }
            else res[i + 1] = w[i + 1];
        }
        if (a[9]) { res[8] = !res[8]; res[9] = !res[9]; }
        return res;
    }
    static bool check(bool[][] map, int a)
    {
        var work = new bool[10][];
        var ans = new bool[10][];
        for (int i = 0; i < 10; i++)
        {
            work[i] = new bool[10];
            ans[i] = new bool[10];
        }
        for (int i = 0; i < 10; i++)
            ans[0][i] = ((a >> i) & 1) == 1;
        work[0] = calcSame(map[0], ans[0]);
        work[1] = calcDown(map[1], ans[0]);
        for (int i = 1; i < 10; i++)
        {
            ans[i] = work[i - 1];
            work[i] = calcSame(work[i], ans[i]);
            if (i <= 8) work[i + 1] = calcDown(map[i + 1], ans[i]);
        }
        if (work[9].All(x => x == false)) { print(ans); return true; }
        else return false;
    }
    static void print(bool[][] ans)
    {
        for (int i = 0; i < 10; i++)
        {
            var p = new int[10];
            for (int j = 0; j < 10; j++)
                if (ans[i][j]) p[j] = 1;
            Console.WriteLine(string.Join(" ", p));
        }
    }
}


Measured memory_bytes: 20308
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Mod
{
    static const long long MOD = 7427466391LL;
    long long a;
public:
    Mod(){
        a = 0;
    }
    Mod(long long x){
        a = (x % MOD + MOD) % MOD;
    }
    const Mod operator+(const Mod& x) const{
        return Mod(a + x.a);
    }
    const Mod operator-(const Mod& x) const{
        return Mod(a - x.a);
    }
    const Mod operator*(const Mod& x) const{
        long long ret = a / 100000 * x.a % MOD * 100000;
        ret += a % 100000 * x.a;
        return Mod(ret);
    }
    const Mod operator/(const Mod& x) const{ // フェルマーの小定理、x.aがMODと互いに素な場合のみ有効
        long long b = MOD - 2;
        Mod c = x.a;
        Mod ret = 1;
        while(b > 0){
            if(b & 1)
                ret = ret * c;
            c = c * c;
            b >>= 1;
        }
        return ret * a;
    }
    long long getValue(){
        return a;
    }
};

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

    Mod x(0);
    for(int i=0; i<n; ++i){
        int o, y;
        cin >> o >> y;
        if(o == 1)
            x = x + y;
        else if(o == 2)
            x = x - y;
        else if(o == 3)
            x = x * y;
        else
            x = x / y;
    }

    long long ret = x.getValue();
    if(ret >= (1LL<<31))
        ret -= 7427466391LL;
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 852
import java.util.*;
public class Main {
	
	static List<Integer> query;

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		while(true) {
			String str=in.next();
			if(str.charAt(0)=='.')break;
			
			String key=in.next();
			int sample=solve(str,key);
			
			int cnt=0;
			for(int i=0;i<=9;i++) {
				for(int j=0;j<=9;j++) {
					for(int k=0;k<=9;k++) {
						for(int l=0;l<=9;l++) {
							String subkey=String.valueOf(i)+String.valueOf(j)+String.valueOf(k)+String.valueOf(l);
							if(solve(str,subkey)==sample)cnt++;
						}
					}
				}
			}
			
			System.out.println(sample+" "+cnt);
		}
	}
	
	static int solve(String str,String key) {
		query=new ArrayList<>();
		
		for(int i=0;i<str.length();i++) {
			query.add((int) str.charAt(i));
			char c=(char) query.get(i).intValue();
			if(c>='a' && c<='d')query.set(i, key.charAt(c-97)-48);
		}
		myHash(0);
		
		return query.get(0);
	}
	
	static void myHash(int p) {
		char ha=(char)query.get(p).intValue();
		
		if(ha!='[')return;
		
		char op=(char)query.get(p+1).intValue();
		
		if((char) query.get(p+2).intValue()=='[') {
			myHash(p+2);
			myHash(p+3);
			query.set(p, calc(op,query.get(p+2),query.get(p+3)));
		}
		else if((char) query.get(p+3).intValue()=='[') {
			myHash(p+3);
			query.set(p, calc(op,query.get(p+2),query.get(p+3)));
		}
		else {
			query.set(p, calc(op,query.get(p+2),query.get(p+3)));
		}
		cleanq(p);

	}
	
	static void cleanq(int p) {
		int i=0,l=query.indexOf(93);
		Iterator<Integer> itr=query.iterator();
		while(true) {
			int n=itr.next();
			if(i>=p+1)itr.remove();
			if(n==93)break;
			i++;
		}
	}
	
	static int calc(char op,int a,int b) {
		int res=0;
		
		switch(op) {
		case '+':
			res=a | b;
			break;
			
		case '*':
			res=a & b;
			break;
			
		case '^':
			res=a^b;
			break;
		}
		
		return res;
	}

}



Measured memory_bytes: 137812
#include<stdio.h>
int main()
{
	int a,b,c,d,min,max;
	while(scanf("%d %d %d %d",&a,&b,&c,&d)!=EOF)
	{
		max=a<c?c:a;
		min=b>d?d:b;
		
		if((min-max)<=0)
		printf("0\n");
		else
		printf("%d\n",min-max);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();

//Appropriately Changed
using edge = struct {int to;};
using G = vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph, int from, int to) {
	graph[from].push_back({to});
}

auto topological_sort(const G& graph) {
	const int n = graph.size();
	vector<int> used(n, 0), order;

	auto dfs = [&](int v) {
		auto func = [&](int v, auto func)->void{
			used[v] = true;
			for (auto &e : graph[v]) if (!used[e.to]) func(e.to, func);
			order.push_back(v);
		};
		return func(v, func);
	};

	rep(v, n)if (!used[v]) dfs(v);
	reverse(_all(order));
	return order;
}


int main(void){
	int n,m;
	cin >> n >> m;

	G graph(n);
	rep(i,m){
		int x,y;
		cin >> x >> y;
		add_edge(graph, x - 1, y - 1);
	}

	vector<int> dp(n, 0);
	vector<int> order = topological_sort(graph);
	for(auto &v: order){
		for(auto &e:graph[v]){
			chmax(dp[e.to], dp[v] + 1);
		}
	}

	int ans = 0;
	rep(v,n) chmax(ans, dp[v]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8572
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
typedef long long LL;
const int MAXN = 100005;
const LL inf = 0x3f3f3f3f;
int main(void){
    int k,v,u;
    cin>>k;
    vector<int> dp(k,46);
    dp[1] = 1;
    deque<int> deq = {1};
    while(v = deq.front()){
        deq.pop_front();
        u = (v*10)%k;
        if(dp[u] > dp[v]){
            dp[u] = dp[v];
            deq.push_front(u);
        }
        u = (v+1)%k;
        if(dp[u] > dp[v]+1){
            dp[u] = dp[v]+1;
            deq.push_back(u);
        }
    }
    cout<<dp[v]<<endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

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

int char_cnt(string s,char a){
  int cnt=0;
  for(unsigned int i=0;i<s.size();i++){
    if(s[i]==a){
      cnt++;
    }
  }
  return cnt;
}

int main() {
  int n=0;
  string s;
  cin>>n>>s;
  ll r=0, g=0, b=0;
    r=char_cnt(s,'R');
    g=char_cnt(s,'G');
    b=char_cnt(s,'B');
    ll ans = r*g*b;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int k=2 * j - i;
      if(k>=n)continue;
      if((s[k]!=s[j])&&(s[j]!=s[i])&&(s[i]!=s[k]))ans--;
    }
  }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  string s;
  cin >> s;
  
  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int i = 0;
		int[] a = new int[m];
		int[] b = new int[m];
		for(i = 0; i < m; i++) {
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();	
		}
		for(i = 0; i < n; i++) {
			int c = 0;
			for(int j = 0; j < m; j++) {
				if(i + 1 == a[j] || i + 1 == b[j]) {
					c++;
				}
			}
			System.out.println(c);
		}
	}
}

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

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();

using namespace std;
const int N=1e3+1, mod= 1e9+7;
vector<int> g[N];

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	vector<pair<int,int>> e;
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		g[u].pb(v);
		e.pb({u,v});
	}
	vector<int> res;
	for(auto x:e){
		priority_queue< pair<int,int> , vector<pair<int,int>> , greater<pair<int,int>> > pq;
		// x.yy -> x.xx
		pq.push({0,x.yy}); vector<int> dist(n+1,INF);
		dist[x.yy]=0;  unordered_map<int,int> par;
		par[x.yy]=-1;
		while(!pq.empty()){
			int u= pq.top().yy;
			pq.pop();
			for(auto v:g[u]){
				if( dist[v]>dist[u]+1 ){
					par[v]=u;
					dist[v]=dist[u]+1;
					pq.push({dist[v],v});
				}
			}
		}
		if( dist[x.xx]!=INF ){
			vector<int> v;

			int cur=x.xx;
			while(cur!=-1){
				v.pb(cur);
				cur=par[cur];
			}
			if(v.size()<res.size() || res.size()==0 )res=v;
		}
	}
	if(res.size()){
		cout<<res.size()<<"\n";
		for(auto x:res)cout<<x<<"\n";	
	}
	else cout<<"-1";
    yogeshk972();
}

 


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

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class AStrings {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        string S, T;
        in>>S>>T;
        out<<T<<S<<'\n';
    }
};


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


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

int main() {
  string str;
  int a=0;
  cin >> str;
  a=str.size();
  
  vector<char> b(a);  
  for (int i=0;i<a;i++){
  b.at(i)=str.at(i);
  }
  vector<int> c(a-2);
  vector<int> d(a-2);
  for (int i=0;i<a-2;i++){
  c.at(i)=(b.at(i)-'0')*100+(b.at(i+1)-'0')*10+(b.at(i+2)-'0');
  d.at(i)=max(753,c.at(i))-min(753,c.at(i));
  }
  sort(d.begin(),d.end());
  cout << d.at(0) << endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    mov = 0
    prev = A[0]
    for a in A[1:]:
        if mov == 0:
            if prev < a:
                mov = 1
            elif prev > a:
                mov = -1
        elif (mov == 1 and prev > a) or (mov == -1 and prev < a):
            ans += 1
            mov = 0
        prev = a
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int n;
    int a[100];
    cin >> n;
    REP(i,n) cin >> a[i];
    int cnt = 0;
    REP(i,n) {
        if (a[i] != i + 1) cnt++;
    }
    if (cnt == 0 || cnt == 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
ans = defaultdict(int)
N, X, Y = map(int, input().split())
for i in range(1, N+1):
  for j in range(1+i, N+1):
    l1 = j-i
    l2 = abs(X-i) + 1 + abs(Y-j)
    ans[min(l1, l2)] += 1
for i in range(1, N):
  print(ans[i])

Measured memory_bytes: 9672
from collections import deque
white = 0
H,W = map(int,input().split())
c = []
for i in range(H):
  s = input()
  white += s.count(".")
  c.append(s)
st = [0,0]
go = [H - 1,W - 1]

dx = [1,-1,0,0]
dy = [0,0,1,-1]
def BFS(graph,start,goal):
  que = deque()
  que.append(start)
  dist = [["Fail" for i in range(W)] for j in range(H)]
  dist[start[0]][start[1]] = 0
  while que:
    x,y = que.popleft()
    if [x,y] == goal:
      break
    else:
      for i in range(4):
        if 0 <=x+dx[i] <H and 0 <=y+dy[i] <W:
          if c[x+dx[i]][y+dy[i]] != "#" and dist[x+dx[i]][y+dy[i]] == "Fail":
            que.append([x+dx[i],y+dy[i]])
            dist[x+dx[i]][y+dy[i]] = dist[x][y]+1
  return dist[goal[0]][goal[1]]
if BFS(c,st,go) == "Fail": print(-1)
else: print(white - BFS(c,st,go) - 1)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30);
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
struct UnionFind {
    vector<int> par, siz;
    UnionFind(int n) {
        par.resize(n);
        siz.resize(n, 1);
        for(int i = 0; i < n; i++)
            par[i] = i;
    }
    int find(int x) {
        if(par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    bool unite(int u, int v) {
        u = find(u), v = find(v);
        if(u == v)
            return false;
        if(siz[u] < siz[v])
            swap(u, v);
        par[v] = u;
        siz[u] += siz[v];
        return true;
    }
    bool same(int u, int v) { return find(u) == find(v); }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++) {
        double s = 1.0 / double(n);
        int c = i;
        while(c < k) {
            c <<= 1;
            s /= 2.0;
        }
        ans += s;
    }
    printf("%.10f\n", ans);
}


Measured memory_bytes: 256
//It will be AC.I'm sure.
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,a,b;
	cin>>k>>a>>b;
	for(int t=a;t<=b;t++)
	{
		if(t%k==0)
		{
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	return 0;
} 

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  double a, b, x;
  cin >> a >> b >> x;

  double s = x/a;
  double ans = 0;
  if(s != a*b){
    if(s > b*a/2){
      double t = 2*s/a-b;
      s -= a*t;
      b -= t;
    }

    ans = atan(b/(2*s/b)) * (180.0 / M_PI);
  }

  printf("%.9f\n", ans);

  return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int students[][] = new int[n][2];
        int points[][] = new int[m][2];
        
        for (int i = 0; i < n ; i++){
            students[i][0] = sc.nextInt(); 
            students[i][1] = sc.nextInt(); 
        }
        for (int i = 0; i < m ; i++){
            points[i][0] = sc.nextInt();
            points[i][1] = sc.nextInt();
        }
        for (int i = 0; i < n ; i++){
            int min_index = 0, min_val = 1000000000;
            for (int j = 0; j < m; j++){
                if (Math.abs(points[j][0] - students[i][0]) + Math.abs(points[j][1] - students[i][1]) < min_val){
                    min_val = Math.abs(points[j][0] - students[i][0]) + Math.abs(points[j][1] - students[i][1]);
                    min_index = j;
                }
            }
            System.out.println(min_index + 1);
        }
        
    }
}


Measured memory_bytes: 22996
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
while True:
   try:
      a,b,c,d,e,f = map(float, input().split())
      x = (c*e - b*f) / (a*e - b*d)
      y = (a*f - c*d) / (a*e - b*d)
      if x==-0:
         x=int(x)
      if y==-0:
         y=int(y)
      X = Decimal(x).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP)
      Y = Decimal(y).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP)
      print(f'{X:.3f} {Y:.3f}')
   except EOFError:
      break


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    ll a , b ;
    cin >> a >> b ;

    ll ans = a / __gcd ( a , b ) ;
    ans *= b ;

    cout << ans ; line
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int arr[]={100,101,102,103,104,105};
int i,j,x,n,y;
cin>>x;
int table[x+1][6];
for(i=0;i<6;i++)
table[0][i]=1;
for(i=1;i<x+1;i++)
{
for(j=0;j<6;j++)
{
n=(i-arr[j]>=0)?table[i-arr[j]][j]:0;
y=(j>=1)?table[i][j-1]:0;
table[i][j]=n+y;
}
}
if(table[x][5]==0)
cout<<"0\n";
else
cout<<"1\n";
/*for(i=0;i<x+1;i++)
{
for(j=0;j<6;j++)
cout<<table[i][j]<<" ";
cout<<"\n";
}*/
return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int d[N];
  for (int i=0;i<N;i++){
    cin >> d[i];
  }
  long long int ans=0;
  for (int i=0;i<N;i++){
    for (int j=0;j<N;j++){
      if (i!=j) ans += d[i]*d[j];
    }
  }
  cout << ans/2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

bool prime_factorize(int x){
    if(x == 1) return false;
    for(int i = 2;i * i <= x;i++){
        if(x % i == 0) return false;
    }
    return true;
}

int main() {
    int x; cin >> x;
    while(true){
        if(prime_factorize(x)){
            cout << x << endl;
            break;
        }
        x++;
    }
}


Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    vec A(n+1);
    rep1(i,n) cin>>A[i];
    for(int i=k+1;i<=n;i++){
        if(A[i-k]<A[i]) cout<<"Yes\n";
        else cout<<"No\n";
    }
}

Measured memory_bytes: 4780
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

// (x,y)
typedef pair<int,int> P;
// (foot,(x,y)) : foot = 0 なら左足, foot = 1 なら右足
typedef pair<int,P> Node;
// (cost,Node)
typedef pair<int,Node> State;

const int MAX_H = 61;
const int MAX_W = 31;
const int INF = 1e+8;

// 入力
int w, h;
char s[MAX_H][MAX_W];

// スタートとゴールの位置
vector<P> vs, vg;

int dx[2][9] = {
	{ 1, 1, 1, 1, 1, 2, 2, 2, 3},
	{-1,-1,-1,-1,-1,-2,-2,-2,-3}
};
int dy[2][9] = {
	{-2,-1,0,1,2,-1,0,1,0},
	{-2,-1,0,1,2,-1,0,1,0}
};

// 初期化
void init(){
	vs.clear();
	vg.clear();
}

// d[foot][y][x] := 最小コスト
int d[2][MAX_H][MAX_W];

// 足がゴールについたかどうか (最小コストの更新も行う)
bool goal(int& ans, int cost, int x, int y){
	for(int i=0 ; i < vg.size() ; i++ ){
		int gx = vg[i].first;
		int gy = vg[i].second;
		if( x == gx && y == gy ){
			ans = min( ans , cost );
			return true;
		}	
	}
}

// sp : 始点, foot : 足, (foot = 0 なら左足, foot = 1 なら右足)
int solve(P sp,int foot_){
	// 初期化
	for(int y=0 ; y < MAX_H ; y++ ){
		for(int x=0 ; x < MAX_W ; x++ ){
			d[0][y][x] = INF;
			d[1][y][x] = INF;
		}
	}
	int sx = sp.first;
	int sy = sp.second;
	Node start( foot_ , sp );
	d[foot_][sy][sx] = 0;
	priority_queue< State, vector<State> , greater<State> > q;
	q.push( State(0,start) );
	
	int ans = INF;
	while( !q.empty() ){
		// 値を取り出す
		int now_cost = q.top().first;
		int foot = q.top().second.first;
		int x = q.top().second.second.first;
		int y = q.top().second.second.second;
		q.pop();
		
		// 片足がゴールについていたら
		//if( goal( ans , now_cost , x , y ) ){
		//	continue;
		//}
		
		// もう片方の足の移動
		for(int i=0 ; i < 9 ; i++ ){
			int mx = x + dx[foot][i];
			int my = y + dy[foot][i];
			if( mx < 0 || my < 0 || mx >= w || my >= h ) continue;
			
			// 足がゴールについたとき
			if( s[my][mx] == 'T' ){
				ans = min( ans , now_cost );
				break;
			}else if( s[my][mx] >= '0' && s[my][mx] <= '9' ){ // ブロックのとき
				int cost = s[my][mx] - '0';
				// より小さいコストだったら
				if( now_cost + cost < d[foot][my][mx] ){
					d[foot][my][mx] = now_cost + cost;
					
					int foot_next;
					foot_next = (foot == 0)? 1 : 0 ;
					Node next( foot_next , P(mx,my) );
					State p( now_cost + cost , next );
					q.push( p );
				}
			}
		}
	}
	return ans;
}

int main(){
	while( cin >> w >> h , w || h ){
		// 初期化
		init();
		
		// 入力
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				cin >> s[y][x];
			}
		}
		
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				if( s[y][x] == 'S' ){
					vs.push_back( P(x,y) );
				}else if( s[y][x] == 'T' ){
					vg.push_back( P(x,y) );
				}
			}
		}
		// スタート地点から探索
		int ans = INF;
		for(int i=0 ; i < vs.size() ; i++ ){
			int result = solve( vs[i] , 0 );
			ans = min( ans , result );
			result = solve( vs[i] , 1 );
			ans = min( ans , result );
		}
		
		// 辿りつけないとき
		if( ans == INF )
			ans = -1;
		
		// 出力
		cout << ans << endl;
	}
}

Measured memory_bytes: 940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int k = sc.nextInt();
    if (k % 1 == 0) {
      System.out.println(k * k / 4);
    } else {
      System.out.println((k / 2 + 1) * k / 2);
    }
  }
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

signed main() {
  const int inf = 1LL<<60;
  int n;
  cin >> n;

  vi a(n), b(n);
  for(auto& i : a) cin >> i;
  for(auto& i : b) cin >> i;

  vvi dp(1<<n, vi(55, inf));
  dp[0][0] = 0;
  rep(mask, 0, 1<<n){
    int i = __builtin_popcount(mask);
    vector<P> v;
    int cnt = i;
    rep(j, 0, n) if(!((mask>>j) & 1)) v.emplace_back(j, cnt++);
    rep(m, 0, 55){
      if(dp[mask][m] >= inf) continue;
      for(auto k : v){
        int j = k.first;
        int tmp = j%2 == i%2 ? a[j] : b[j];
        if(tmp < m) continue;
        chmin(dp[mask | (1<<j)][tmp], dp[mask][m]+abs(k.second-i));
      }
    }
  }

  int ans = inf;
  rep(i, 0, 55){
    chmin(ans, dp[(1<<n)-1][i]);
  }
  if(ans < inf) cout << ans << endl;
  else cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 121216
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  vector<int>dp(n,INT_MAX);
  dp[0]=0;

  for(int i=1;i<n;i++)
    {
    	int h=k,g=i;
    	while(g--&&h--){
    		dp[i]=min(dp[i],abs(a[i]-a[i+h-k])+dp[i+h-k]);
    	//	cout<<i+h-k <<" ";
		}
	//	cout<<endl;
	
    	
	}
	
  cout<<dp[n-1];
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1001;


void mul(ll& x, ll y) {
    if (x>=mod) x%=mod;
    if (y>=mod) y%=mod;
    x *= y;
    if (x>=mod) x%=mod;
}


int n, m;
int a[maxn], b[maxn];
int g[maxn][maxn];

int cnt[maxn*maxn];
set<int> row[maxn*maxn], col[maxn*maxn];

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

    cin>>n>>m;
    for (int i=0; i<n; i++) {
	cin>>a[i];
	row[a[i]].insert(i);
    }
    for (int i=0; i<m; i++) {
	cin>>b[i];
	col[b[i]].insert(i);	
    }
    for (int i=0; i<n; i++) {
	for (int j=0; j<m; j++) {
	    g[i][j] = min(a[i],b[j]);
	    cnt[g[i][j]]++;
	}
    }

    ll have = 0;
    ll res = 1;


    for (int i=n*m; i>=1; i--) {
	if ((int)row[i].size()>1 && (int)col[i].size()>1) {
	    out(0);
	}
	if (cnt[i]>0) {
	    if (row[i].size() && col[i].size()) {
		mul(res, 1);
	    } else {
		mul(res, cnt[i]);
	    }
	    have += cnt[i]-1;
	} else {
	    if (have == 0) {
		out(0);
	    }
	    mul(res, have);
	    have--;
	}
    }



    cout<<res<<endl;    
    return 0;
}


Measured memory_bytes: 101624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;

int n;
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<int> p;
    int tmp,count = 0;
    for(int i = 0; i < n;i++){
        cin >> tmp;
        p.push_back(tmp);
    }

    for(int i = 1; i < n-1;i++){
        if(p[i] > p[i-1] && p[i] < p[i+1]){
                count++;
        }
        if(p[i] < p[i-1] && p[i] > p[i+1]){
                count++;
        }
    }

    cout << count << endl;



    

    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s.at(i);
    bool complete = false;
    while(!complete){
        // 行を削除
        vector<string> s2;
        rep(i,s.size()){
            rep(j,s.at(0).size()){
                if(s.at(i).at(j) == '#'){
                    s2.push_back(s.at(i));
                    break;
                }
            }
        }
        // 列を削除
        vector<string> s3(s2.size());
        rep(j,s2.at(0).size()){
            rep(i,s2.size()){
                if(s2.at(i).at(j) == '#'){
                    rep(k,s2.size()){
                        s3.at(k).push_back(s2.at(k).at(j));
                    }
                    break;
                }
            }
        }
        complete = s.size()==s3.size() && s.at(0).size() == s3.at(0).size();
        s = s3;
    }
    rep(i,s.size()){
        rep(j,s.at(0).size()){
            cout << s.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;
/*
struct dice {
	int s[6];
	void roll(char c) {
		int b;
		if (c == 'E') {
			b = s[0];
			s[0] = s[3];
			s[3] = s[5];
			s[5] = s[2];
			s[2] = b;
		}
		if (c == 'N') {
			b = s[0];
			s[0] = s[1];
			s[1] = s[5];
			s[5] = s[4];
			s[4] = b;
		}
		if (c == 'S') {
			b = s[0];
			s[0] = s[4];
			s[4] = s[5];
			s[5] = s[1];
			s[1] = b;
		}
		if (c == 'W') {
			b = s[0];
			s[0] = s[2];
			s[2] = s[5];
			s[5] = s[3];
			s[3] = b;
		}
		if (c == 'R') {
			b = s[1];
			s[1] = s[3];
			s[3] = s[4];
			s[4] = s[2];
			s[2] = b;
		}
	}
	int top() {
		return s[0];
	}
	int right() {
		return s[2];
	}
	int left() {
		return s[3];
	}
	int front() {
		return s[1];
	}

};

int main() {
	dice d;
	for (int i = 0; i < 6; i++) {
		cin >> d.s[i];
	}
	int order;
	cin >> order;
	while(order--) {
		int top, front;
		cin >> top >> front;
		if (d.left() == top) {
			d.roll('E');
		}
		if (d.right() == top) {
			d.roll('W');
		}
		while (d.top() != top) {
			d.roll('N');
		}
		while (d.front() != front) {
			d.roll('R');
		}
		cout << d.right() << endl;
	}
}
*/

int main() {
	int n, m, d;
	cin >> n >> m >> d;
	string s[100] = {};
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int dotCnt = 0;
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '.') {
				dotCnt++;
			}
			else {
				dotCnt = 0;
			}
			if (dotCnt >= d) {
				ans++;
			}
		}
	}
	for (int i = 0; i < m; i++) {
		int dotCnt = 0;
		for (int j = 0; j < n; j++) {
			if (s[j][i] == '.') {
				dotCnt++;
			}
			else {
				dotCnt = 0;
			}
			if (dotCnt >= d) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3160
n = gets.to_i
$dams = gets.split.map(&:to_i)

def mountains(start)
  mountains = [start]
  $dams.each do |dam|
    next_mountain = (dam - mountains.last / 2) * 2
    # return true if next_mountain < 0
    mountains << next_mountain
  end
  return false if mountains.first < mountains.last
  return true if mountains.first > mountains.last
  mountains
end

def b_search (min, max)
  mid = (min + max) / 2
  mid += 1 if mid.odd?
  if mid == max
    res = mountains(max)
    if res == true || res == false
      return mountains(min)
    else
      return res
    end
  end
  res = mountains(mid)
  if res == false
    min = mid
  elsif res == true
    max = mid
  else
    return res
  end
  b_search(min, max)
end

res = b_search(0, $dams.first * 2)
res.pop
puts res.join(" ")


Measured memory_bytes: 22028
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint dp[20][20];
int nx[20],ny[20];
int main()
{
	int n;cin>>n;string s;cin>>s;
	memset(dp,0,sizeof(dp));
	/*rep(i,(1<<18)+5){
		for(int j=17;j>=0;j--){
			if((i&(1<<j))) la[i]=j;
		}
	}*/
	string t=s.substr(n);reverse(All(t));
	lint out=0;
	rep(i,(1<<n)){
		int x=__builtin_popcount(i),y=n-x;
		memset(dp,0,sizeof(dp));
		int i1=0,i2=0;
		rep(j,n){
			if((i&(1<<j))) nx[i1++]=j;else ny[i2++]=j;
		}
		/*if(i==1){
			rep(j,x) cout<<nx[j]<<' ';cout<<endl;
			rep(k,y) cout<<ny[k]<<' ';cout<<endl;
		}*/
		dp[0][0]=1;
		rep(j,x+1) rep(k,y+1){
			if(j<x && t[j+k]==s[nx[j]]) dp[j+1][k]+=dp[j][k];
			if(k<y && t[j+k]==s[ny[k]]) dp[j][k+1]+=dp[j][k];
		}
		out+=dp[x][y];
	}
	cout<<out<<endl;
}


Measured memory_bytes: 384
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

step = [0]*(N+1)
last = -1
for a in A:
    if a == last + 1 or a == last - 1:
        print(0)
        exit()
    step[a] = 1
    last = a

ans = [0] + [1] + [0]*N

chk = 0
for i in range(1, N+1):
    if step[i] == 0 and chk <= 0:
        ans[i+1] = ans[i] + ans[i-1]
        chk = 0
    elif step[i] == 1:
        ans[i+1] = ans[i]
        chk = 2
    elif step[i] == 0 and chk > 0:
        ans[i+1] = ans[i]
        chk -= 1
        
print(ans[-1]%(10**9 + 7))


Measured memory_bytes: 466516
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int a,b,h; cin >>a>>b>>h;

    cout << (a+b)*h/2 << endl;
    
    return 0;
}





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




using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;


#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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

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


class UnionFind{
    public:
    vector<int> par;
    vector<int> val;
    int root(int input){
        if(par[input]==input) return input;
        return par[input] = root(par[input]);
    }
    void unite(int val1, int val2){
        par[val1] = root(par[val2]);
    }
    bool same(int val1, int val2){
        return root(par[val1]) == root(par[val2]);
    }
    UnionFind(){
        return;
    }
};

int N,K;




int main() {
    
    cin >> N >> K;
    bool A[N];
    rep(i,N) A[i] = false;

    rep(i,K){
        int d;
        cin >> d;
        rep(j,d){
            int a;
            cin >> a;
            a--;
            A[a] = true;
        }
    }

    int res = 0;

    rep(i,N){
        if(A[i] == false){
            PRINT(i)
            PRINT(A[i])
            res ++;
        }
    }

    cout << res << endl;
    return 0;
}


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

l = sorted([int(i) for i in input().split()])

l2 = sorted([l[i] - l[i-1] for i in range(1,m)],reverse = True)

if len(l2) < n:
    print(0)
else:
    print(sum(l2[n-1:]))

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int gcd(int a, int b)
{
    int r = a % b;
    if (r == 0)
    {
        return b;
    }
    else
    {
        return gcd(b, r);
    }
}

int main()
{
    ll a, b;
    while (cin >> a >> b)
    {
        ll g = gcd(a, b);
        cout << g << " " << a * b / g << endl;
    }
    return 0;
}


Measured memory_bytes: 2992
#include<iostream>

int gcd(int a,int b){
	
	int tmp;
	
	while(b!=0){
		tmp=a%b;
		a=b;
		b=tmp;
	}
	
	return a;
}

int main(void){
	
	int x,y;
	
	std::cin>>x>>y;
	
	std::cout<<gcd(x,y)<<'\n';
	
	return 0;
	
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  ll h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    fin(1);
    return 0;
  } else if (h % 2 == 0 || w % 2 == 0) {
    fin((h * w) / 2);
    return 0;
  } else {
    ll ans = h * (w - 1) / 2;
    ans += (h + 1) / 2;
    fin(ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

double p[200000];

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        int pp;
        scanf("%d", &pp);
        p[i] = (pp + 1) / 2.0;
    }
    
    int max_i = 0;

    double tmp = 0;
    for (int j = 0; j < k; j++) {
        tmp += p[j];
    }
    double max_p = tmp;
    
    for (int i = 1; i < n - k + 1; i++) {
        tmp = tmp - p[i-1] + p[i+k-1];
        if (tmp > max_p) {
            max_i = i;
            max_p = tmp;
        }
    }
    printf("%lf", max_p);
    
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<ll> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	vector<ll> sum(n+1,0),sum_non_neg(n+1,0);
	for(int i = 1; i <= n; i++){
		sum[i] = sum[i-1] + a[i-1];
		sum_non_neg[i] = sum_non_neg[i-1] + max((ll)0,a[i-1]);
	}

	ll ans = 0;
	for(int i = k; i <= n; i++){
		ll res = sum_non_neg[i-k] + max((ll)0,sum[i]-sum[i-k]) + (sum_non_neg[n]-sum_non_neg[i]);
		//cout << sum_non_neg[i-k] << "    "  << sum_non_neg[n]-sum_non_neg[i] << "    "<<  res << endl;
		ans = max(ans,res);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560