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

#define ll long long
#define ld long double

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)

#define pii pair<int, int>
#define pll pair<ll, ll>

#define fi first
#define se second

#define pb push_back
#define eb emplace_back

#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>

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

#define endl '\n'
using namespace std;
using namespace atcoder;

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

const ll MOD=10000007;//998244353
const ll INF=1e18;
const int inf=1e9;
const double PI=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=3e5+10;


int op(int a,int b){ return max(a,b);}
int e(){return 0;}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  segtree <int,op,e> dp(MAX);
  rep(i,n){
    int x = a[i];
    int now = dp.prod(max(x-k,0),min(x+k+1,MAX));
    dp.set(x,now+1);
  }
  int ans = 0;
  rep(i,MAX)chmax(ans,dp.get(i));
  
  cout << ans << endl;
                       
  return 0;
}


Measured memory_bytes: 9796
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
int D , G;
int p[11];
int q[11];
int c[11];
//dp ? i
void solve(){
  //1番多い点数から解いた場合の点数
  long res = 0;
  long score = 0;
  long minres;
  for(int i = D-1; i >= 0; i--){
    int question = p[i];
    while(true){
      score += 100*(i+1);
      question --;
      res++;
      if(question == 0) {
        score += c[i];
        break;
      }
      if(G <= score) break;
    }
    if(G <= score) break;
  }
  minres = res;
  bool cbit[10];
  //1~10 で ボーナスをもらった場合
  for(int i = 0; i < (1 << D); i++){
    res = 0;
    score = 0;
    for(int j = 0; j < D; j++) q[j] = p[j];

    int tmp = i;
    // make bit ----------------------------
    int x = 0;
    for(int j = 0; j < 10; j++) cbit[j] = false;
    while(tmp != 0){
      if(tmp % 2 == 1)cbit[x] = true;
      else cbit[x] = false;
      x++;
      tmp /= 2;
    }
    // bit フラグが立っている問題を全問解く -------------------
    for(int j = 0; j < D; j++){
      if(cbit[j]){
        res += p[j];
        score += (100 * (j+1) * p[j]) + c[j];
        q[j] = 0;
      }
    }
    // まだスコアがG以下なら貪欲法で加点していく
    if(score >= G){
      minres = min(res,minres);
      continue;
    }else{
      for(int j = D-1; j >= 0; j--){
        int question = q[j];
        if(question == 0) continue;
        while(true){
          score += 100*(j+1);
          question --;
          res++;
          if(question == 0) {
            score += c[j];
            break;
          }
          if(G <= score) break;
        }
        if(G <= score) break;
      }
      minres = min(res,minres);
    }
  }
  cout << minres << endl;
  return;
}

int main(){

  cin >> D >> G;
  for(int i = 0; i < D; i++){
    cin >> p[i] >> c[i];
  }
  solve();
  return 0;
}


Measured memory_bytes: 384
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

ans = [0] * 101010

S = ns()
dp=[[0 for i in range(101010)] for j in range(34)]

N = len(S)
for i in range(N):
    dp[0][i] = (i - 1) if S[i] == 'L' else (i + 1)

for p in range(33):
    for i in range(N):
        dp[p+1][i] = dp[p][dp[p][i]]

for i in range(N):
    ans[dp[32][i]] += 1

print(*ans[:N])

Measured memory_bytes: 43480
// atcoder/abc177/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  str s, t;
  while (cin >> s >> t) {
    int mn = 1 << 29;
    for (int i = 0; i + t.size() - 1 < s.size(); ++i) {
      int cnt = 0;
      for (int j = 0; j < t.size(); ++j) {
        cnt += (s[i + j] != t[j]);
      }
      setmin(mn, cnt);
    }
    cout << mn << endl;
  }

  return 0;
}


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

#define ll long long
#define ull long long unsigned
#define vii vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
#define ff first
#define ss second
#define pb push_back
#define read freopen("alu.txt","r",stdin);
#define write freopen("vorta.txt","w",stdout);
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
#define PI 2*acos(0.0)

const int MAX=100005, MOD=1000000007;
const ll inf=1e18;

int arr[MAX];
int main(){

    fastio;
    string s,t;
    cin>>s>>t;
    if(t.size()>s.size()) return cout<<"UNRESTORABLE\n", 0;

    bool ok=true;
    int sz=t.size();
    for(int i=s.size()-1; i-sz+1>=0 ;i--){
        int j=i-sz+1;
        ok=true;
        for(int k=0;j<=i;j++,k++){
            if(s[j]!='?' && s[j]!=t[k]){
                ok=false;
                break;
            }
        }
        if(ok){
            int j=i-sz+1;
            for(int k=0;j<=i;j++,k++){
                if(s[j]=='?') s[j]=t[k];
            }
            break;
        }
    }

    if(!ok) return cout<<"UNRESTORABLE\n", 0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='?') s[i]='a';
    }
    cout<<s<<"\n";

}

Measured memory_bytes: 256
object Main {
  import scala.io.StdIn.{ readLine }
  def main(args : Array[String]) = {
    sub()
  }
  def sub(args : Array[Int] = readLine.split(" ").map(_.toInt)) {
    if ((args(0) != 0) || (args(1) != 0)) {
      val list = sort(readLine.split(" ").toList.map(x => new Cup(x.toInt, 0, args(0))).tail ::: readLine.split(" ").toList.map(x => new Cup(x.toInt, 1, args(0))).tail ::: readLine.split(" ").toList.map(x => new Cup(x.toInt, 2, args(0))).tail)
      val minStep = list.head.Pile match {
        case 1 =>
          min(moveEnd(list, 0), moveEnd(list, 2))
        case t : Int =>
          moveEnd(list, t)
      }
      if (minStep < args(1)) {
        println(minStep)
      } else {
        println(-1)
      }
      sub()
    }
  }
  def min(a : Int, b : Int) : Int = if (a > b) b else a
  def moveEnd(list : List[Cup], target : Int) : Int = {
    list match {
      case Nil => 0
      case first :: rest =>
        first match {
          case x @ Cup(_, t, _) if (t == target) =>
            moveEnd(rest, target)
          case x @ Cup(_, 1, _) =>
            moveEnd(rest, 2 - target) + x.moveCost * 2 + 1
          case x : Cup =>
            moveEnd(rest, target) + x.moveCost * 4 + 2
        }
    }
  }
  def insertSort(factor : Cup, list : List[Cup]) : List[Cup] = {
    list match {
      case Nil => List[Cup](factor)
      case first :: rest =>
        if (first < factor) {
          first :: insertSort(factor, rest)
        } else {
          factor :: list
        }
    }
  }
  def sort(ramlist : List[Cup], re : List[Cup] = Nil) : List[Cup] = {
    ramlist match {
      case Nil => re
      case first :: rest =>
        sort(rest, insertSort(first, re))
    }
  }
}
case class Cup(val Size : Int, val Pile : Int, val whole : Int) extends Ordered[Cup] {
  def compare(other : Cup) = Size - other.Size
  def moveCost : Int = {
    def pow(e : Int, r : Int = 1) : Int = {
      e match {
        case 0 => r
        case _ => pow(e - 1, 3 * r)
      }
    }
    (pow(whole - Size) - 1) / 2
  }
  override val toString = s"--Size = ${Size}, Pile = ${Pile}--"
}

Measured memory_bytes: 43660
#include<bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
	long long a,b;
	long long ans=0;

bool hantei(long long i){
	long long j=(i-a);
	if(b-j*2>=i*2&&a+j>=i){
		return true;
	}else{
		return false;
	}
}
int main(){

	scanf("%lld%lld",&a,&b);
	
	if(a*2>b){
		ans=b/2;
	}else if(a*2==b){
		ans=a;
	}else{
		//できる個数を求める
		long long le=0;
		long long ri=b/2;
        while(ri-le>1){
			long long cent=(le+ri)/2;
			if(hantei(cent)){
				le=cent;
			}else{
				ri=cent;
			}
		}
		ans=le;

	}
	
	
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#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++)
using ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;

int main(){
    string s;
    cin >> s;
    cout << s.at(0) << s[1] << s[2] <<  endl;
}


Measured memory_bytes: 3624
/*
ID: Aman Raj
LANG: C++
TASK: subset
*/
#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
  //# define mod 1e9+7
# define INF 100000000

int main()
{    ll a,b;cin>>a>>b;
      cout<<max(a*b,max(a-b,a+b));
     
      return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    vector<int> A(N,0);
    int sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        sum += A.at(i);
    }
    int M;
    cin >> M;
    for(int i = 0; i < M; i++) {
        int P, X;
        cin >> P >> X;

        cout << sum - A.at(P - 1) + X << endl;
    }



    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007


vector<vector<int> > e;
vector<ll> p;
vector<ll> ans;
int N;

void dfs(ll d,int parent,int now){
    ans[now] = d + p[now];
    REP(i,0,e[now].size()){
        if(e[now][i]!=parent){
            dfs(ans[now], now, e[now][i]);
        }
    }
}

int main()
{
    int Q;
    cin >> N>>Q;
    e.resize(N);
    p.resize(N);
    ans.resize(N);

    REP(i, 0, N)
    {
        p[i] = 0;
        ans[i] = 0;
    }

    REP(i,0,N-1){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    REP(i,0,Q){
        int pp;
        ll x;
        cin >> pp >> x;
        pp--;
        p[pp] += x;
    }
    dfs(0, -1, 0);

    REP(i,0,N){
        cout << ans[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 25856
#include<cstdio>
#include<vector>
#include<utility>
#include<complex>
#include<cmath>
#include<algorithm>

using namespace std;

typedef double Real;
typedef pair<int,int> P;

vector<P> dirs[200*200*2+1];

int crP(int x1,int y1,int x2,int y2){
	return x1*y2-x2*y1;
}

void init_dir(){
	for(int x=-200;x<=200;x++) for(int y=-200;y<=200;y++){
		dirs[x*x+y*y].push_back(P(x,y));
	}
}

Real getHeight(Real a,Real b,Real c){
	Real y=(a + (b*b-c*c)/a)/2;
	return sqrt(b*b-y*y);
}

Real getH2(Real a,Real b,Real c){
	Real y = (a + (b*b-c*c)/a)/2;
	return a-y;
}

const Real eps = 1e-8;

int cnt=0;
Real getHeight(Real a,Real b,Real c,Real d,Real e,Real f){
//	printf("%f %f %f %f %f %f\n",a,b,c,d,e,f);
	Real h_=getHeight(a,d,f);
	Real x=getH2(a,d,f);
	Real h2=getHeight(a,b,c);
	Real y=getH2(a,b,c);
	Real p=y-x;
	Real q=h2-h_;
	Real val = -(e*e - h_*h_ - (h_+q)*(h_+q) - p*p) / (2.0 * (h_+q) * h_);
	if(abs(val) >= 1.0 - eps) return -1;
//	printf("%f %f %f %f %f %f %f %f\n",h_,x,h2,y,p,q,val,h_*sqrt(1-val*val));
//	if(++cnt>10) exit(0);
	return h_ * sqrt(1-val*val);
}

bool sameSide(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){
	int p3 = crP(x2-x1,y2-y1,x3-x2,y3-y2);
	int p4 = crP(x2-x1,y2-y1,x4-x2,y4-y2);
	return p3*p4>=0;
}

int dis2(int x1,int y1,int x2,int y2){
	return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
}

Real dis(int x1,int y1,int x2,int y2){
	return sqrt(dis2(x1,y1,x2,y2));
}

bool check(int x){
	return x>=-100&&x<=100;
}

Real solve(int x1,int y1,int x2,int y2,int x3,int y3){
	Real a=dis(x1,y1,x2,y2);
	Real b=dis(x2,y2,x3,y3);
	Real c=dis(x3,y3,x1,y1);
	Real res = -1;
	for(int x4=-100;x4<=100;x4++) for(int y4=-100;y4<=100;y4++){
		if(sameSide(x1,y1,x2,y2,x3,y3,x4,y4)) continue;
		int d2=dis2(x2,y2,x4,y4);
		Real d=sqrt(d2);
		int f2=dis2(x1,y1,x4,y4);
		Real f=sqrt(f2);
		for(int i = 0; i < dirs[d2].size(); i++){
			for(int j = 0; j < dirs[f2].size(); j++){
				int x5 = x2 + dirs[d2][i].first;
				int y5 = y2 + dirs[d2][i].second;
				int x6 = x1 + dirs[f2][j].first;
				int y6 = y1 + dirs[f2][j].second;
				if((!check(x5)) || (!check(y5)) || (!check(x6)) || (!check(y6))) continue;
				if(sameSide(x2,y2,x3,y3,x1,y1,x5,y5)) continue;
				if(sameSide(x3,y3,x1,y1,x2,y2,x6,y6)) continue;
				int e2 = dis2(x3,y3,x6,y6);
				if(e2 != dis2(x3,y3,x5,y5)) continue;
				Real e = sqrt(e2);
				Real h = getHeight(a,b,c,d,e,f);
				if(h > 0 && (res < 0 || res > h)) res = h;
	//			if(d2==5&&e2==5) printf("%d %d %d %f\n",d2,e2,f2,h);
			}
		}
	}
	return res;
}

int main(){
	init_dir();
	while(true){
		int x1,y1,x2,y2,x3,y3;
		scanf("%d%d%d%d%d%d2",&x1,&y1,&x2,&y2,&x3,&y3);
		if(x1==0&&y1==0&&x2==0&&y2==0&&x3==0&&y3==0) break;
		Real ans = solve(x1,y1,x2,y2,x3,y3);
		if(ans < 0) printf("-1\n");
		else printf("%.9f\n",ans);
//		break;
	}
	return 0;
}

Measured memory_bytes: 4440
#include <bits/stdc++.h>
 
#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(int i=x;i<y;i++)
#define foreI(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sl "\n";
#define ii pair<ll,ll>
#define mk make_pair
 
 
typedef long long ll;
typedef unsigned long long ull;
 
using namespace std;
const int MAXN = 1e5+10;
vector<vector<int>> gp(MAXN);
ll dp[MAXN];
ll solve(int u){
    if(gp[u].size()==0){dp[u]=1;return 1;}
    ll &r=dp[u];
    if(r!=-1)return r;
    for(auto e: gp[u]){
        r=max(r,solve(e)+1);
    }
    return r;
}
int main() {FIN;
    
    memset(dp,-1,sizeof(dp));
    int n,m;cin>>n>>m;
    fore(i,0,m){
        int a,b;cin>>a>>b;
        gp[a-1].pb(b-1);
    }
    ll ans=0;
    fore(i,0,n){
        if(dp[i]==-1){
            ans=max(ans,solve(i));
        }
    }cout<<ans-1<<sl;
    return 0;
}
 

Measured memory_bytes: 11540
N, A, B, C, D = map(int, input().split())
S = input()
if "##" in S[A-1:C] or "##" in S[B-1:D]:
  print("No")

elif C < D:
  print("Yes")

else:
  if "..." in S[B-2:D+1]:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 40816
#include<iostream>
#include<cstdio>
#include<cmath>
#define MN 1000000
#define mod 998244353
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int p[MN+5],inv[MN+5],ans=0,Inv[MN+5];
inline int C(int n,int m){return 1LL*p[n]*Inv[m]%mod*Inv[n-m]%mod;}
int main()
{
	p[0]=inv[0]=p[1]=inv[1]=Inv[0]=Inv[1]=1;
	for(int i=2;i<=MN;++i)
		p[i]=1LL*p[i-1]*i%mod,
		inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod,
		Inv[i]=1LL*Inv[i-1]*inv[i]%mod;
	int n=read(),m=read(),ans=0;
	for(int i=1;i<=n&&i<=m;++i) ans=(ans+1LL*C(i*2,i)*C(n+m-i-i,n-i)%mod*(mod+1)/2)%mod;
	ans=1LL*ans*Inv[n+m]%mod*p[n]%mod*p[m]%mod;
	printf("%d\n",(ans+max(n,m))%mod);
	return 0;
}



Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int H,W;
  	cin>>H>>W;
  
  	string grid[H];
  	rep(i,H) cin>>grid[i];
  	const int dx[8]={-1,-1,-1,0,0,1,1,1};
  	const int dy[8]={-1,0,1,1,-1,-1,0,1};
  	
  	
  	rep(i,H){
     	rep(j,W){
          	int count=0;
         	if(grid[i][j]=='.'){
            	rep(d,8){
                	int ni=i+dy[d];
                  	int nj=j+dx[d];
                  	if(ni<0||H<=ni) continue;
                  	if(nj<0||W<=nj) continue;
                  	if(grid[ni][nj]=='#') count++;
                }	
              	grid[i][j]=char(count+'0');
            }
        }
    }
  
  	rep(i,H) cout<<grid[i]<<endl;
  
  	
  	
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  R(K)R(A)R(B);
  P((A+K-1)/K<=B/K?"OK":"NG");
  return 0;
}


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

public class Main {

	static int n, q;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[] S = new int[n];
		for(int i = 0 ; i < n ; i++) S[i] = sc.nextInt();
		q = sc.nextInt();
		int[] T = new int[q];
		for(int i = 0 ; i < q ; i++) T[i] = sc.nextInt();
		Arrays.sort(S);

		long ans = 0;
		for(int i = 0 ; i < q ; i++) {
			if(binary_search(T[i], S)) ans++;
		}
		System.out.println(ans);
	}

	public static boolean binary_search(int x, int[] S) {
		int l = 0;
		int r = n;
		while(r > l) {
			int center = (l + r) / 2;
			if(x == S[center]) return true;
			else if(x > S[center]) l = center + 1;
			else r = center;
		}
		return false;
	}

}

Measured memory_bytes: 79128
#include <iostream>

using namespace std;

void loop(int remain, int* jiro_rule, int rule_size, int cur) {
    remain -= (remain - 1) % 5;
    cout << remain << endl;
    if (remain == 0) return;
    if (remain <= *(jiro_rule + cur)) {
        cout << 0 << endl;
        return;
    }
    remain -= *(jiro_rule + cur);
    cout << remain << endl;
    cur++;
    if (cur == rule_size) cur = 0;
    loop(remain, jiro_rule, rule_size, cur);
}

int main() {
    int i;
    while (cin >> i) {
        if (i == 0) break;
        int a[i];
        for (int p = 0; p < i; p++) {
            cin >> a[p];
        }
        loop(32, a, i, 0);
    }
    return 0;
}

Measured memory_bytes: 0
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,M,X;
    cin >> N >> M>>X;
    vecl C(N);
    vector<vector<ll>> A(N,vector<ll>(M,0));
    REP(i,N) {
        cin >> C[i];
        REP(j,M) {
            int a;
            cin >> a;
            A[i][j] = a;
        }
    }
    ll ans = 1e9;
    for (int bit = 0; bit < (1<<N); ++bit) {
        ll cost = 0;
        vecl score(M);
    for (int i = 0; i < N; ++i) {
        if (bit & (1<<i)) { 
            cost += C[i];
            REP(j,M) {
                score[j] += A[i][j];
            }
        }
        
        }
        bool ok = true;
        REP(i,M) {
            if(score[i] < X) ok = false;
        }
        if(ok) chmin(ans,cost);
    }
    cout <<(ans != 1e9 ? ans : -1) << endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<cmath>
#include<map> 
#include<string>
#define int long long
using namespace std;
int t,a,b,cnt,n;
signed main()
{
	cin>>n;
	if(n>=30)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
 } 

Measured memory_bytes: 3624
def main():
    n = int(raw_input())
    a = map(int, raw_input().split())
    if a[-1] > 2:
        print -1
        return
    lo = hi = 2
    for x in reversed(a):
        if hi < x:
            print -1
            return
        nlo = (lo + x - 1) / x * x
        nhi = hi / x * x + x - 1
        if nlo > nhi:
            print -1
            return
        lo = nlo
        hi = nhi
    print lo, hi
main()

Measured memory_bytes: 11316
C = [[int(x) for x in input().split()] for _ in range(3)]

a = [0] * 3
b = [0] * 3
for i in range(3):
    b[i] = C[0][i] - a[0]
    a[i] = C[i][0] - b[0]

ans = 'Yes'
for i in range(3):
    for j in range(3):
        if C[i][j] != a[i] + b[j]:
            ans = 'No'
            break
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

int main(){
    int n;
    int d[100];
    int height = 0;

    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &d[i]);
    }

    sort(d, d+n, greater<int>());

    for(int i=0; i<n; i++){
        if(d[i] != d[i+1]){
            height += 1;
        }
        else{
            height += 0;
        }
    }
    printf("%d\n", height);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, k;
    string s;
    cin >> n >> k >> s;
    int nn = n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'L') {
            ans += (i && s[i - 1] == 'L');
        }
        else {
            ans += (i < n - 1 && s[i + 1] == 'R');
        }
    }


    string ss;
    ss += s[0];
    int kk = k;
    for (int i = 1; i < n; i++) {
        if (s[i] != ss.back()) ss += s[i];
    }

    n = ss.size();
    int t = 0;
    kk = k;
    for (int i = 2; i < n && kk; i += 2) {
        if (i == n - 1) t += 1;
        else t += 2;
        kk--;
    }

    if (kk) t++;

    int tt = 0;
    kk = k;
    for (int i = 1; i < n && kk; i += 2) {
        if (i == n - 1) tt += 1;
        else tt += 2;
        kk--;
    }

    cout << min(nn - 1, ans + max(t, tt));

}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
const int N = 5e5+999;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int arr[N];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;
        string s,s1,s2,s3; ;
        rep(i,0,n)
        s+= (i+1+'0');
        s3 = s;
        int x;
        rep(i,0,n)
        {
            cin>>x;
            s1+= (x+'0');
        }
        rep(i,0,n)
        {
            cin>>x;
            s2+= (x+'0');
        }
        int ct = 0;
        while(1)
        {
            if(s==s1)
                break;
            else{
                ct++;
                next_permutation(all(s));
            }
        }
        int ct2 = 0;
        while(1)
        {
            if(s3==s2)
                break;
            else{
                ct2++;
                next_permutation(all(s3));
            }
        }
        cout<<abs(ct2-ct)<<el;

    }
   return 0;
}


Measured memory_bytes: 256
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
ans = as.inject(0){|sum,a|sum + a.abs}
m = 1e10
if as.include?(0)
  puts ans
elsif as.count{|a| a < 0}.even?
  puts ans
else
  as.each do |a|
    m = [m,a.abs].min
  end
  ans -= m*2
  puts ans
end

Measured memory_bytes: 12164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(long long X, long long Y){
    ll cnt = 0;
    while(X <= Y){
        cnt++;
        X *= 2;
    }
    cout << cnt << endl;
    return;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 3760
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

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

int main(){

    string s; cin >> s;
    int cnt=0,ans=0;
    rep(i,s.size()){
        if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
            cnt++;
        }else{
            cnt=0;
        }
        ans=max(ans,cnt);
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;

/////////////////////////////////////////////////////////

void Main(){
  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  int res = 1000000000;
  rep(i, 0, max(X, Y) + 1){
    int sum = 0;
    sum += C * 2 * i;
    sum += A * max(0, X - i);
    sum += B * max(0, Y - i);
    if(sum < res) res = sum;
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int n,f[1010],c[1010];
bool d[1010][5010];
struct edge
{
	int t;
	edge *next;
}*con[1010];
void ins(int x,int y)
{
	edge *p=new edge;
	p->t=y;
	p->next=con[x];
	con[x]=p;
}
void dfs(int x,int fa)
{
	int tmp=0;
	d[x][0]=1;
	for(edge *p=con[x];p!=NULL;p=p->next)
		if(p->t!=fa)
		{
			dfs(p->t,x);
			tmp+=min(f[p->t],c[p->t]);
			f[x]+=max(f[p->t],c[p->t]);
			for(int i=c[x];i>=0;i--)
				if(i-abs(f[p->t]-c[p->t])>=0) d[x][i]=(d[x][i]||d[x][i-abs(f[p->t]-c[p->t])]);
		}
	//cout<<"1:"<<x<<' '<<f[x]<<' '<<tmp<<endl;	
	if(tmp>c[x]) {puts("IMPOSSIBLE"); exit(0);}
	for(int i=c[x]-tmp;i>=0;i--)
		if(d[x][i]) {f[x]-=i;break;}
	
	//cout<<"2:"<<x<<' '<<f[x]<<endl;	
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		ins(i,x);
		ins(x,i);
	}
	for(int i=1;i<=n;i++)
		scanf("%d",&c[i]);
	dfs(1,0);	
	puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=0;i<=(int)n;i++)
int main(void){
    cout << fixed << setprecision(10);
    int n,k;cin>>n>>k;
    vector<double> p(n),q(n);//q[i]=i番目のサイコロの期待値
    rep(i,n){
        cin>>p[i];
        q[i]=(1+p[i])/2;
    }
    int left=0,right=k-1;
    double now=0,res=0;
    for(int i=0;i<k;i++) now+=q[i];
    while(right<n){
        double buf=now;
        res=max(buf,res);
        now-=q[left];
        left++;
        right++;
        now+=q[right];
        //cout<<buf<<endl;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	static String[] w = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		String s = in.next();
		for (int i = 0; i < s.length(); i++) {
			int x = s.charAt(i) - 'A';
			x += n;
			if (x >= 26)
				x -= 26;
			System.out.print((char) ('A' + x));
		}
		System.out.println();
	}
}

Measured memory_bytes: 28116
def gcd(a, b):
    while a > 0:
        if a < b:
            a, b = b, a
        a = a % b
    return b
def resolve():
    N,x=map(int,input().split())
    X=list(map(int,input().split()))
    X.append(x)
    X=list(set(X))
    X.sort()
    D=[]
    for i in range(len(X)-1):
        D.append(X[i+1]-X[i])
    ans=D[0]
    for d in D:
        if d%ans!=0:
            ans=gcd(ans,d)
    print(ans)
resolve()

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int res = 0;

    for (int i = 0; i <= 999; i++) {
        int fd = i % 10;
        int sd = (i / 10) % 10;
        int td = (i/ 100) % 10;
        int num[3] = {td, sd, fd};
        int d = 0;
        for (auto s : S) {
            int sd = s - '0';
            if (sd == num[d]) {
                if (d == 2) {
                    res++;
                    break;
                }
                d++;
            }
        }
    }

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



    return 0;
}


Measured memory_bytes: 3784
#define _USE_MATH_DEFINES
#include <math.h>
#include<iostream>
#include <cstdio>

using namespace std;

int main() {
	double r;
	cin >> r;
	double vast, circle;
	vast = r*r*M_PI;
	circle = 2 * r*M_PI;
	printf("%.6f %.6f", vast, circle);
	return 0;
}

Measured memory_bytes: 1240
x = input()
y = int(x)
if y < 100:
    print(0)
else:
    ans = 0
    c = int(x[:len(x)-2])
    for i in range(1,c+1):
        if 100*i <= y and y <= 105*i:
            ans = 1
            break
    print(ans)
    

Measured memory_bytes: 2940
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(long long int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  int cnt=0;
  while(true){
    if(k>=v[cnt]){
      k-=v[cnt];
      cnt++;
    }else{
      cout<<cnt<<endl;
      return 0;
    }
    if(cnt==n){
      if(k==0){
        cout<<cnt<<endl;
        return 0;
      }else{
        cout<<cnt-1<<endl;
        return 0;
      }
    }
  }
  
  
  
}

Measured memory_bytes: 256
#include <cassert>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<LL, LL> PII;

#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); puts("");}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.push_back(x); return v;}
void err(vector<string>::iterator it) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args) {cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}

#if (( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

#define pb push_back
#define mp make_pair
#define all(x)  (x).begin(),(x).end()
#define tr(c, it)   for(auto it=c.begin(); it!=c.end(); it++)
#define clr(a, b)   memset(a, b, sizeof(a))
#define forn(i, n)   for(int i=0; i<n; i++)

const int INF = 0x3f3f3f3f;

const int N = 200010;

int T;
int n, k;

LL a[N];
PII seg[N];

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif

    while(cin >> n >> k)
    {
        for(int i=1; i<=n; i++)
        {
            cin >> a[i];
            seg[i] = {a[i], a[i] + k};
        }

        LL ans = 0;
        PII cur = seg[1];
        for(int i=2; i<=n; i++)
        {
            if(seg[i].first > cur.second)
            {
                ans += cur.second - cur.first;
                cur = seg[i];
            }
            else
            {
                cur.second = seg[i].second;
            }
        }
        ans += cur.second - cur.first;
        cout << ans << endl;



    }



   return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

vi v;

void dfs(int x) {
	if(x > 3.3e9) {
		return;
	}
	v.pb(x);
	int cur = x % 10;
	for(int i : {cur - 1, cur, cur + 1}) {
		if(i >= 0 && i <= 9) {
			dfs(10 * x + i);
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int k;
	cin >> k;
	for(int i = 1; i <= 9; i++) {
		dfs(i);
	}
	sort(all(v));
	cout << v[k - 1];

	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int M = 1;
  rep(i,n) {
    cin >> a[i];
    if(M<a[i]) M = a[i];
  }
  int g = 0;
  rep(i,n) g = gcd(g,a[i]);
  cout << (M>=k&&k%g==0? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}

Measured memory_bytes: 3788
from itertools import product,combinations
MOD = 10**9+7

def solve(X,Y):
    DX = [a-b for a,b in zip(X[1:],X)]
    DY = [a-b for a,b in zip(Y[1:],Y)]
    a = sum((i+1)*(len(DX)-i)*dx for i,dx in enumerate(DX))
    b = sum((i+1)*(len(DY)-i)*dy for i,dy in enumerate(DY))
    return (a*b)%MOD


def naive(X,Y):
    a = 0
    for (x1,x2),(y1,y2) in product(combinations(X,2), combinations(Y,2)):
        a += (x2-x1)*(y2-y1)
        a %= MOD
    return a

from random import randrange
from itertools import accumulate

def test():
    for _ in range(10000):
        X = list(accumulate([randrange(1,8) for _ in range(3)]))
        Y = list(accumulate([randrange(1,8) for _ in range(2)]))
        a1 = solve(X,Y)
        a2 = naive(X,Y)
        if a1 != a2:
            print(X,Y)
            print(a1)
            print(a2)
            return

if __name__ == '__main__':
    # test()
    N,M = map(int,input().split())
    X = tuple(map(int,input().split()))
    Y = tuple(map(int,input().split()))
    print(solve(X,Y))
    # print(naive(X,Y))

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP				make_pair

typedef pair<int, int> P;

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

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

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

int field[21][21];
int w, h, ans;

void dfs( P pos, int cnt ) {
	if( cnt == 10 ) return;

	REP( i, 4 ) {
		int nx = pos.first + dx[i];
		int ny = pos.second + dy[i];
		if( nx >= 0 && nx < w && ny >= 0 && ny < h && field[nx][ny] != 1 ) {
			bool flag = true;
			while( field[nx][ny] != 1 ) {
				if( field[nx][ny] == 3 ) {
					chmin( ans, cnt + 1 ); 
					flag = false;
					break;
				}
				nx += dx[i];
				ny += dy[i];
				if( nx < 0 || nx >= w || ny < 0 || ny >= h ) {
					flag = false;
					break;
				}

			}
			if( flag ) {
				field[nx][ny] = 0;
//				cout << nx - dx[i] << " " << ny - dy[i]<< endl;
				dfs( MP( nx - dx[i], ny - dy[i] ), cnt + 1 );
				field[nx][ny] = 1;
			}
		}

	}

}

signed main() {
	P start;

	while( cin >> w >> h, w ) {
		REP( i, h ) {
			REP( j, w ) {
				cin >> field[j][i];
				if( field[j][i] == 2 ) {
					start.first = j;
					start.second = i;
					field[j][i] = 0;
				}

			}
		}

		ans = INF;
		dfs( start, 0 );
		if( ans == INF ) cout << -1 << endl;
		else			 cout << ans << endl;

	}
	
}



Measured memory_bytes: 3076
from itertools import combinations
import numpy as np
N,D = map(int,input().split())
X = []
for i in range(N):
    X.append(np.array(list(map(int,input().split()))))
comb = list(combinations(list(range(N)),2))
count = 0
for i in range(len(comb)):
    dist = (sum(list(np.power(X[comb[i][0]]-X[comb[i][1]],2))))**(1/2)
    if int(dist) == dist:
        count += 1
print(count)

Measured memory_bytes: 12504
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>

using Input = std::vector<std::string>;
using Num = std::vector<int>;

Input input(void) {
	Input result;
	{
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				result.push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		result.push_back(row);
	}
	return result;
}

Num replaceToInteger(Input original = {""}) {
	Num result;
	for (unsigned int i = 0; i < original.size(); i++) {
		result.push_back(atoi(original[i].c_str()));
	}
	return result;
}

int main(void) {

	Num s = replaceToInteger(input());

	int n = 0, k = 0;

	n = s[0];
	k = s[1];

	Input mid = input();
	
	if ('A' == mid[0][(k - 1)]) {
		mid[0][(k - 1)] = 'a';
	} else if ('B' == mid[0][(k - 1)]) {
		mid[0][(k - 1)] = 'b';
	} else {
		mid[0][(k - 1)] = 'c';
	}

	printf("%s\n", mid[0].c_str());

	return 0;
}


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

int main() {
  string A;
  cin >> A;
  int ans=700;
  for(int i=0;i<3;i++){
    if(A[i]=='o'){
      ans=ans+100;
    }
    else{
      continue;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x,a,b = map(int, read().split())
print('A' if abs(b-x)>abs(a-x) else 'B')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
ll ext_gxd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll q = a / b;
    ll g = ext_gxd(b, a - q * b, x, y);
    ll z = x - q * y;
    x = y;
    y = z;
    return g;
}

ll modinv(ll a, ll m) {
    ll x, y;
    ext_gxd(a, m, x, y);
    x %= m;
    if (x < 0) x += m;
    return x;
}

ll modpow(ll a, ll n, ll m) {
    ll ret = 1;
    ll now = a;
    while (n > 0) {
        if (n % 2 == 1) ret = ret * now % m;
        now = now * now % m;
        n /= 2;
    }
    return ret;
}

int main() {
    int n;
    ll p;
    cin >> n >> p;
    vector<ll> v(n);
    rep(i, n) {
        char c;
        cin >> c;
        v[i] = c - '0';
    }

    if (p == 2) {
        ll ans = 0;
        rep(i, n) {
            if (v[i] % 2 == 0) {
                ans += (ll)(i + 1);
            }
        }
        cout << ans << endl;
        return 0;
    }
    if (p == 5) {
        ll ans = 0;
        rep(i, n) {
            if (v[i] % 5 == 0) {
                ans += (ll)(i + 1);
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<ll> t(n + 1);

    rrep(i, n) {
        t[i] = (t[i + 1] + modpow(10, n - 1 - i, p) * v[i] % p);
        t[i] %= p;
    }

    map<ll, ll> cnt;
    rep(i, n + 1) {
        cnt[t[i]]++;
    }

    ll ans = 0;
    for (auto pp : cnt) {
        ans += (pp.second * (pp.second - 1) / 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3968
#include <iostream>
using namespace std;
typedef long long Int;

Int f(Int x, Int y) {
    if (x > y) return f(y, x);
    if (x == 0) {
        return -y;
    }
    return x * (y / x * 2) + f(y % x, x);
}

int main() {
    Int n, x;
    cin >> n >> x;
    cout << (n + f(n - x, x)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    double n, k;
    cin >> n >> k;
    double sum = 0;
    for(int i = 1; i <= n; ++i){
        if(i < k){
              int p = 0;
            int j = i;
            while(j < k){
                j = j * 2;
                p++;
            }
            sum = sum + (1 / n) * pow(0.5, p);
        }
        else sum += (1 / n);
    }
    printf("%.12lf\n", sum);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll a ,b; cin >> a >> b;
  cout << a * b << endl;


}


Measured memory_bytes: 3644