akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
map<int,ll> mp;
int main(){
 int h,w,k;
 cin>>h>>w>>k;
 vector<string> s(h);
 for(int i=0;i<h;i++)cin>>s[i];
 vector<vector<int>> a(h,vector<int>(w,0));
 int cnt=0;
 for(int i=0;i<h;i++){
       for(int j=0;j<w;j++){
           if(s[i][j]=='#'){
               cnt++;
                   int p=i;
                     while(p>=0){
                       if(a[p][j]!=0||(p!=i&&s[p][j]=='#'))break;
                       a[p][j]=cnt;
                       p--;
                   }
                      p=i+1;
                     while(p<h){
                       if(a[p][j]!=0||(p!=i&&s[p][j]=='#')){
                           break;
                       }
                       a[p][j]=cnt;
                       p++;
                  }
              }
            }
     }
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
       if(a[i][j]!=0){
           int t=a[i][j];
          int nowy=j-1;
           while(nowy>=0){
               if(a[i][nowy]==0)a[i][nowy]=t;
               else break;
               nowy--;
           }
           nowy=j+1;
           while(nowy<w){
               if(a[i][nowy]==0)a[i][nowy]=t;
               else {
                   nowy--;
                   break;
               }
               nowy++;
           }
           j=nowy;
       }
    }
}
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        cout<<a[i][j]<<" ";
    }
    cout<<endl;
}
}



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

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

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

  int ans = floor(n / 3);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
int a[1005];
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	ll n,k;
	cin>>n>>k;
	cout<<min(n%k,abs(k-n%k));
	return 0;
}


Measured memory_bytes: 888
let input = require("fs").readFileSync("/dev/stdin", "utf8")

function main({ input, load, yesno, math_sum, log_json }) {
    let [A,B,H,M] = load(4)
    
    const hr = 2*Math.PI*(H*60+M)/12/60
    const mr = 2*Math.PI*M/60

    const hx = Math.cos(hr)*A
    const hy = Math.sin(hr)*A
    
    const mx = Math.cos(mr)*B
    const my = Math.sin(mr)*B

    const dist = Math.sqrt((hx - mx) * (hx - mx) + (hy - my) * (hy - my))
    
    return dist
}



// console.time()
let inputs = input.split(/[\s\n]/)
let result = main({
    input,
    yesno: value => value ? 'Yes' : 'No',
    math_sum: numbers => numbers.reduce((acc, cur) => acc + cur, 0),
    load(rows = 1, cols = 1, type = Number) {
        const length = rows * cols
        let result = inputs.splice(0, length)
        if(type !== String) result = result.map(type)
        if(cols > 1) {
            const arrays = new Array(cols)
            for(let col = 0; col < cols; col++) {
                arrays[col] = new Array()
                for(let row = 0; row < rows; row++) {
                    arrays[col].push(result[row * cols + col])
                }
            }
            result = arrays
        }
        return result
    },
    inifinite_loop_preventer() {
        throw new Error("Infinite loop")
    },
    log_json(value) {
        console.log(JSON.stringify(value))
    },
})

if(result === undefined) {
    console.warn("result is undefined")
} else {
    console.log(result)
}
// console.timeEnd()

function math_max(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n > result) result = n
    return result
}

function math_min(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n < result) result = n
    return result
}

// 素因数分解 { 素数: n乗 }
function math_prime_factors(n) {
    const result = {}

    for(let i = 2; i * i <= n; i++) {
        if(n % i === 0) {
            n /= i
            result[i] = 1
            
            while(n % i === 0) {
                n /= i
                result[i]++
            }
        }
    }

    if(n > 1) result[n] = 1

    return result
}


Measured memory_bytes: 29832
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int mod=10007;
int n,e[100000][2],w[100000][2];
bool v[100000];

int mx,mxn;
void rec(int c)
{
	v[c]=1;
	rep(i,2)
	{
		if(mx<w[c][i])mx=w[c][i],mxn=0;
		if(mx==w[c][i])mxn++;
		
		if(!v[e[c][i]])rec(e[c][i]);
	}
}
int main()
{
	while(scanf("%d",&n),n)
	{
		rep(i,n)rep(j,2)scanf("%d%d",e[i]+j,w[i]+j);
		int ans=1;
		rep(i,n)v[i]=0;
		rep(i,n)if(!v[i])
		{
			mx=0; mxn=1;
			rec(i);
			ans=(ans*mxn/2)%mod;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
  int x,y,d,temp,r;

  scanf("%d %d",&x,&y);
  if(x<y){
    temp=x;
    x=y;
    y=temp;
  }
  while(1){
    r=x%y;
    if(r==0) break;
    x=y;
    y=r;
  }
  printf("%d\n",y);
  return 0;
}

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

using namespace std;

int main(void)
{
	int n; cin>>n;
	int a[n]; for(int i = 0; i < n; i++) cin>>a[i];
	long long ans = 0;
	for(int i = 0; i < n-1; i++){
		ans+=a[i]/2;
		if(a[i] % 2 == 1 && a[i+1] > 0){
			a[i+1]--;
			ans++;
		}
	}
	ans+=a[n-1]/2;
	cout<<ans<<endl;
	int w = 0;
	/*
	for(int i = 0; i < 20; i++){
		w+=i/2;
		cout<<"i = "<<i<<", w = "<<w<<endl;
	}
	*/
	return 0;
}



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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string o, e;

int main() {
	cin >> o >> e;
	rep(i,o.length()+e.length()) {
		if (i%2==0) cout << o[i/2];
		else cout << e[i/2];
	}
	cout << ln;
}

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

int main(){
    char S;
    cin >> S;
    if (S=='S' or S=='s'){
        cout << "Cloudy";
    }else if (S=='C' or S=='c'){
        cout << "Rainy";
    }else{
        cout << "Sunny";
    }
}

Measured memory_bytes: 256
def calc (input)
  seet = [[nil],
          [nil,"a","b","c","d","e"],
          [nil,"f","g","h","i","j"],
          [nil,"k","l","m","n","o"],
          [nil,"p","q","r","s","t"],
          [nil,"u","v","w","x","y"],
          [nil,"z",".","?","!"," "]
         ]
  
  input.gsub!(/\n/,"")
  no = input.split("")
  no = no.map{|n| n.to_i}
  if (no.size%2!=0)
    return "NA"
  end

  output = ""
  (no.size/2).times do |i|
    begin
      output = output + seet[no.shift][no.shift]
    rescue
      return "NA"
    end
  end

  return output
end

while input = gets
puts calc(input)
end

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

const int ALP_NUM = 26;
const int INF = 1001001001;

int main() {
    int d;
    cin >> d;
    vector<int> C(ALP_NUM);
    rep(i, ALP_NUM) cin >> C[i];
    vector<vector<int>> S(d, vector<int>(ALP_NUM));
    rep(i, d) rep(j, ALP_NUM) cin >> S[i][j];
    vector<int> T;
    vector<set<int>> schedules(ALP_NUM);
    rep(i, ALP_NUM) schedules[i].insert(-1);
    

    auto get_score = [&](vector<int> A, int n) {
        int res = 0;
        vector<int> D(ALP_NUM, -1);
        n = min(d, n);
        rep(i, n) {
            int t = A[i];
            if (t >= 0) {
                res += S[i][t];
                D[t] = i;
            }
            rep(j, ALP_NUM) {
                res -= (i-D[j]) * C[j];
            }
        }
        return res;
    };

    auto change = [&](int nd, int nt) {
        int pt = T[nd];
        int res = S[nd][nt] - S[nd][pt];

        auto it_l = schedules[pt].lower_bound(nd);
        auto it_r = schedules[pt].upper_bound(nd);
        --it_l;
        int pt_ld = *it_l;
        int pt_rd;
        if (it_r != schedules[pt].end()) pt_rd = *it_r;
        else pt_rd = d;
        res -= C[pt] * (nd-pt_ld) * (pt_rd-nd);

        it_l = schedules[nt].lower_bound(nd);
        it_r = schedules[nt].upper_bound(nd);
        --it_l;
        int nt_ld = *it_l;
        int nt_rd;
        if (it_r != schedules[nt].end()) nt_rd = *it_r;
        else nt_rd = d;
        res += C[nt] * (nd-nt_ld) * (nt_rd-nd);

        return res;
    };


    vector<int> T_(d, -1);
    rep(i, d) {
        int max_score = -INF;
        int tmp = 0;
        T_[i] = 0;
        rep(j, ALP_NUM) {
            T_[i] = j;
            rep(k, 26) {
                int score = get_score(T_, i+1+k);
                if (score > max_score) {
                    max_score = score;
                    tmp = j;
                }
            }
        }
        T_[i] = tmp;
    }

    T = T_;
    

    rep(i, d) {
        cout << T[i]+1 << endl;
    }

    //cout << get_score(T, d) << endl;

    return 0;
}


Measured memory_bytes: 3684
use std::str::FromStr;
use std::fmt::Debug;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: u32 = read_as_vec()[0];
    let mut sum: u32 = 0;
    let mut max_price = 0;
    for _ in 0..n{
        let p: u32 = read_as_vec()[0];
        if max_price < p{
            max_price = p;
        }
        sum += p;
    }
    sum -= (max_price/2);
    println!("{}", sum);

    
 }

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.length(),i,c=0;
    for(i=0;i<l-1;i++)
    {
        if(s[i]!=s[i+1]) c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3732
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder {
    class Practice {
        static void Main() => CustomMain();

        static void Solve() {
            var a = ReadIntArray();

            Array.Sort(a);
            var ans = Math.Abs(a[0] - a[1]);
            ans += Math.Abs(a[2] - a[1]);
            WriteAnswer(ans);
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if (a == b)
			System.out.println(a * 2);
		else if (a < b)
			System.out.println(b + (b - 1));
		else
			System.out.println(a + (a - 1));
	}
    public static void main(String[] args) {
    	new Main().run();
    }
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> a(n), b(n);
  rep(i, n-1) cin >> a[i] >> b[i];
  vector<vector<int>> g(n+1);
  rep(i, n-1) {
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  vector<int> c(n);
  rep(i, n) cin >> c[i];
  sort(rALL(c));
  vector<int> vex(n+1, -1);
  vector<int> edge(n);

  int index;
  queue<int> q;
  auto update = [&](int now) {
    for(auto next : g[now]) {
      if(vex[next] == -1) {
        vex[next] = c[index];
        q.push(next);
        ++index;
      }
    }
  };

  q.push(1);
  vex[1] = c[0];
  index = 1;

  while(!q.empty()) {
    int now = q.front(); q.pop();
    update(now);
  }

  int ans = 0;
  rep(i, n-1) {
    ans += min(vex[a[i]], vex[b[i]]);
  }
  cout << ans << endl;
  for(int i = 1; i <= n; ++i) {
    cout << vex[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std ;

int main()
{
  int N ;
  cin>>N ;
  vector<int>p(N) ;
  for(int i=0;i<N;i++) cin>>p.at(i) ;
  sort(p.begin(),p.end()) ;
  
  int ans=0 ;
  for(int i=0;i<N;i++){
    if(i==N-1) p.at(i)/=2 ;
    ans+=p.at(i) ;
  }
  cout<<ans<<endl ;
  return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

/*ここから*/

int V;//頂点の個数
int E;//辺の個数
P e[2000010];//辺の組
int conn=0;//連結数
int t[2000010];//親情報の記録媒体

void Conn(){  
    for(int i=0;i<E;i++){
        int a,b;
        a=e[i].first;
        b=e[i].second;
        //同一連結成分か？
        while(t[a]!=t[t[a]]){
            t[a]=t[t[a]];
        }
        while(t[b]!=t[t[b]]){
            t[b]=t[t[b]];
        }
        if(t[a]!=t[b]){
            if(t[a]<t[b]){
                t[t[b]]=t[a];
                t[b]=t[a];
            }
            else{
                t[t[a]]=t[b];
                t[a]=t[b];
            }
        }
    }
    for(int i=1;i<=V;i++){
        if(t[i]==i){conn++;}
    }
}

/*ここまで*/

int main()
{ 
    int n,m,k;
    cin>>n>>m>>k;
    vector <P> f;
    vector <P> b;
    for(int i=0;i<m;i++){
        int a,c;
        cin>>a>>c;
        e[i].first=a;
        e[i].second=c;
        f.push_back(e[i]);
    }
    for(int j=0;j<k;j++){
        int a,c;
        cin>>a>>c;
        P p;
        p.first=a;
        p.second=c;
        b.push_back(p);
    }

    V=n;E=m;
    for(int i=1;i<=V;i++){
        t[i]=i;
    }
    Conn();
    Conn();

    int ans[n+1];
    for(int i=0;i<=n;i++){ans[i]=0;}

    for(int i=1;i<=n;i++){
        ans[t[i]]++;
    }
    for(int i=1;i<=n;i++){
        ans[i]=ans[t[i]];
    }
    for(int i=0;i<m;i++){
        P p;
        p=f.back();
        f.pop_back();
        ans[p.first]--;
        ans[p.second]--;
    }
    for(int i=0;i<k;i++){
        P p;
        p=b.back();
        b.pop_back();
        if(t[p.first]==t[p.second]){
            ans[p.first]--;
            ans[p.second]--;
        }
    }
    

    /*for(int i=1;i<=n;i++){cout<<t[i]<<' ';}
    cout<<endl<<endl;*/

    for(int i=1;i<n;i++){
        cout<<ans[i]-1<<' ';
    }
    cout<<ans[n]-1<<endl;
    return 0;
}

Measured memory_bytes: 7412
# -*- coding:utf-8 -*-

def solve():
    L, R = list(map(int, input().split()))
    MOD = 2019

    ans = float("inf")
    if R-L <= MOD-1:
        for i in range(L, R+1):
            for j in range(i+1, R+1):
                ans = min(ans, i*j%MOD)
    else:
        # 必ず0をかけることになるので
        ans = 0

    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
#include <iostream>
#include <string>

using namespace std;

int main() {
    int ans = 0, num;
    string s;
    while (cin >> s) {
        num = 0;
        for (int i = 0; i < s.size(); i++) {
            if ('0' <= s[i] && s[i] <= '9') {
                num = num * 10 + (s[i] - '0');
            }
            else {
                ans += num;
                num = 0;
            }
        }
        ans += num;
    }
    cout << ans << endl;

    return 0;
}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define repm(i,m,n) for(ll i=m;i<n;i++)
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define YesNo(a) (a)?cout<<"Yes"<<endl:cout<<"No"<<endl
#define YESNO(a) (a)?cout<<"YES"<<endl:cout<<"NO"<<endl
#define INF (2e9)
#define PI (acos(-1))
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

typedef long long ll;

int main(){
  string s,t; cin >> s >> t;
  int n = s.size();
  
  int ans = 0;
  rep(i,n){
    if(s[i] != t[i]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3864
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int h, w;
	while (cin >> h >> w) {
		if (h == 0)break;
		int r = h * h + w * w;
		bool f = true;
		for (int i = h + 1; i <= w; i++) {
			for (int j = i + 1; j <= w; j++) {
				if (i*i + j * j == r) {
					cout << i << " " << j << endl;
					f = false; break;
				}
			}
			if (!f)break;
		}
		r++;
		while (f) {
			for (int i = 1; i <= 1000; i++) {
				for (int j = i + 1; j <= 1000; j++) {
					if (i*i + j * j == r) {
						cout << i << " " << j << endl;
						f = false; break;
					}
				}
				if (!f)break;
			}
			r++;
		}
	}
	return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;
  map<int, char> mp;
  rep(i, 26) {
    mp[i%26]='a' + i;
  }
  mp[-1] = 'z';
  string ans = "";
  while(n>0){
    n--;
    int x = n % 26;
    n /= 26;
    //ans = mp[x] + ans;
    ans = char('a' + x) + ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <iterator>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  copy_n(istream_iterator<int>(cin), N, X.begin());
  int result;
  for (int i = 1; i <= 100; ++i) {
    int tmp = accumulate(X.begin(), X.end(), 0, [i](int acc, int n) {
      return acc + (n - i) * (n - i);
    });
    if ((tmp < result) || (i == 1)) {
      result = tmp;
    }
  }
  cout << result << endl;
  return 0;
}


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

using namespace std;

int main()
{
  int x,y;
  cin>>x>>y;
  for(int i=1;i<100;i++)
  {
    if(x==i&&y==2*i)
    {
      cout<<"Yes"<<endl;
      return 0;
    }
    else if(x==i&&y==4*i)
    {
       cout<<"Yes"<<endl;
      return 0;
    }
  }
  for(int i=1;i<=100;i++)
  {
    for(int j=1;j<=100;j++)
    {
      if(x==i+j&&y==2*i+4*j)
      {
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3628
S = input()
SL = []
for i in range(1,13):
    SL.append("0"+str(i) if len(str(i)) == 1 else str(i))
 
 
if S[2:] in SL:
    if S[:2] in SL:
        print("AMBIGUOUS")
    else:
        print("YYMM")
    
else:
    if S[:2] in SL or SL[:2] == "00":
        print("MMYY")
    else:
        print("NA")

Measured memory_bytes: 3060
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
struct Comb {
    fac: Vec<u64>,
    finv: Vec<u64>,
    inv: Vec<u64>,
    m: u64,
}

impl Comb {
    fn new(n: usize, m: u64) -> Comb {
        let mut fac = vec![0u64; n];
        let mut finv = vec![0u64; n];
        let mut inv = vec![0u64; n];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..n {
            fac[i] = fac[(i - 1) as usize] * i as u64 % m;
            inv[i] = m - inv[(m % i as u64) as usize] * (m / i as u64) % m;
            finv[i] = finv[(i - 1) as usize] * inv[i] % m;
        }
        Comb {
            fac: fac,
            finv: finv,
            inv: inv,
            m: m,
        }
    }
    fn calc(&self, n: usize, k: usize) -> u64 {
        if n < k {
            return 0;
        }

        return self.fac[n] * (self.finv[k] * self.finv[n - k] % self.m) % self.m;
    }
}

const MOD: u64 = 1_000_000_000 + 7;
fn main() {
    input! {
        h: usize, w: usize, a: usize, b: usize,
    }
    let comb = Comb::new(h + w + 10, MOD);
    let mut ans = 0;
    for w_ in b..w {
        ans += comb.calc(h - a - 1 + w_, w_) * comb.calc(a - 1 + w - 1 - w_, w - 1 - w_);
        ans %= MOD;
    }

    println!("{}", ans);
}


Measured memory_bytes: 10492
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<vector>
#define ll long long
using namespace std;
int main()
{
	ll a, b;
	cin >> a >> b;
	if (a*b % 2 == 0)
		cout << "Even" << endl;
	else
		cout << "Odd" << endl;


}

Measured memory_bytes: 256
/*
** Author: MAC45
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.tie(0);
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt","wt",stdout);
    ll N, K, d, A, treat = 0;
    cin >> N >> K;
    ll trick[N + 1] = {0};
    while (K--)
    {
        cin >> d;
        while (d--)
        {
            cin >> A;
            trick[A]++;
        }
    }
    while (N>0)
    {
        if (trick[N--] == 0)
            treat++;
    }
    cout << treat << endl;
    return 0;
}


Measured memory_bytes: 3616
package main

import (
	"fmt"
	"sort"
)

func median(vs []int) int {
	sort.Ints(vs)
	return vs[len(vs)/2]
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func score(vs []int, b int) int {
	sum := 0
	for i, v := range vs {
		sum += abs(v - (b + i + 1))
	}
	return sum
}

func main() {
	var N int
	fmt.Scan(&N)
	as := make([]int, N)
	for i := range as {
		fmt.Scan(&as[i])
	}

	bs := make([]int, N)
	for i := range bs {
		bs[i] = as[i] - i - 1
	}
	b := median(bs)

	fmt.Println(score(as, b))
}


Measured memory_bytes: 6656
import java.util.Scanner;
import java.util.ArrayList;
class Main{
    public static void main(String[] args){
        Scanner scn=new Scanner(System.in);
        String s=scn.next();
        String t=scn.next();
        String answer="Yes";
        int limit=Math.min(s.length(),t.length());
        ArrayList<Character> sList=new ArrayList<Character>();
        ArrayList<Character> tList=new ArrayList<Character>();
        for(int i=0;i<s.length();i++){
            char buf=s.charAt(i);
            for(int j=i+1;j<s.length();j++){
                char bufj=s.charAt(j);
                if(buf>bufj){
                    String front=s.substring(0,i);
                   String mid= s.substring(i,j+1);
                   StringBuffer bf=new StringBuffer(mid);
                   String end=s.substring(j+1,s.length());
                   s=front+bf.reverse()+end;
                    buf=bufj;
                }
            }
            sList.add(buf);
        }
        for(int i=0;i<t.length();i++){
            char buf=t.charAt(i);
            for(int j=i+1;j<t.length();j++){
                char bufj=t.charAt(j);
                if(buf<bufj){
                     String front=t.substring(0,i);
                    String mid= t.substring(i,j+1);
                    StringBuffer bf=new StringBuffer(mid);
                    String end=t.substring(j+1,t.length());
                    t=front+bf.reverse()+end;
                    buf=bufj;
                }
            }   
            tList.add(buf);
        }

        int i=0;
        for(;i<limit;i++){
            if(sList.get(i)<tList.get(i)){
                i=limit+1;
                break;
            }else if(sList.get(i)>tList.get(i)){
                i=limit+1;
                answer="No";
                break;
            }
        }
        if(i==limit&&t.length()<=s.length()){  
            answer="No";
        }
        System.out.println(answer);
     }
}

Measured memory_bytes: 23636
n,m=map(int,input().split())
j=[True for _ in range(n+1)]
ans=[1,1]+[0 for _ in range(n-1)]
p=10**9+7
for _ in range(m):
    j[int(input())]=False
if j[1]==False:
    ans[1]=0
    ans[2]=ans[0]
for i in range(n-1):
    if j[i+2]==True:
        ans[i+2]=ans[i+1]+ans[i]
        ans[i+2]%=p
    else:
        ans[i+2]=0
print(ans[n]%p)



Measured memory_bytes: 7800
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int N, M, K;
		cin >> N >> M >> K;

		vector<int> A( N ), B( M );
		for( int i = 0; i < N; ++i ) { cin >> A[i]; }
		for( int i = 0; i < M; ++i ) { cin >> B[i]; }

		vector<long> a2( N+1 ), b2( M+1 );
		for( int i = 0; i < N; ++i ) { a2[i+1] = a2[i] + A[i]; }
		for( int i = 0; i < M; ++i ) { b2[i+1] = b2[i] + B[i]; }

		int ans = 0;
		int j = M;
		for( int i = 0; i <= N; ++i ) {
			if( a2[i] > K ) { break; }
			while( b2[j] > K - a2[i] ) { j -= 1; }

			ans = max( ans, i+j );
		}

		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 7948
#include <stdio.h>

int main() {
    int card, rank, i, j;
    int deck[4][13] = {0};
    char ch;
    char suit[] = "SHCD";
    
    scanf("%d", &card);
    for(i = 1; i <= card; i++) {
        scanf("%c", &ch);
        scanf("%c %d", &ch, &rank);
        
        switch (ch) {
            case 'S':
                deck[0][rank - 1] = 1;
                break;
            case 'H':
                deck[1][rank - 1] = 1;
                break;
            case 'C':
                deck[2][rank - 1] = 1;
                break;
            case 'D':
                deck[3][rank - 1] = 1;
                break;
            default:
                break;
        }
    }
    
    for(i = 0; i < 4; i++) {
        for(j = 0; j < 13; j++) {
            if(deck[i][j] == 0) {
                printf("%c %d\n", suit[i], j + 1);   
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 2104
A,B,C,D = map(int, input().split())
for i in range(1, 200):
  # 高橋
  if i%2 != 0:
    C=C-B
    if C <=0:
      print('Yes')
      exit(0)
  else:
    A=A-D
    if A <=0:
      print('No')
      exit(0)


Measured memory_bytes: 9172
#include <iostream>

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

    int n;
    while (std::cin >> n) {
        int cnt = 0;
        for (int i = 0; i < 10; ++i)
            for (int j = 0; j < 10; ++j)
                for (int k = 0; k < 10; ++k)
                    for (int l = 0; l < 10; ++l)
                        if (i + j + k + l == n)
                            ++cnt;
        std::cout << cnt << std::endl;
    }
}



Measured memory_bytes: 3020
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j, k;
    	
    	while(true){
            int n = sc.nextInt();
            if(n == 0)
                break;
 
            int[] s = new int[n];
            double sum = 0;
 
            for (i = 0; i < n; i++) {
                sum += s[i] = sc.nextInt();
            }
 
            double m = sum/n;
            sum = 0;
 
            for (i = 0; i < n; i++) {
                sum += Math.pow(s[i]-m,2);
            }
            System.out.printf("%.5f\n",Math.pow((double)sum/n,0.5));
        }
    }
}


Measured memory_bytes: 31500
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int cnt = 0;
        
        for (int i = 1; i <= a; i++) {
            if (Integer.toString(i).length() % 2 == 1) {
                cnt++;
            }
        }
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 28372
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char temp='a';
		char[] s = sc.next().toCharArray();
		for (char c : s) {
			if(temp == c) {
				System.out.println("Bad");
				return;
			}
			temp = c;
		}
		System.out.println("Good");
	}
}


Measured memory_bytes: 21844
/**
 * Road to ROI
**/ 
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn for(int i=0;i<n;i++)
#define form for(int j=0;j<m;j++)
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define kek cout<<"\n"
#define all(v)        ((v).begin()), ((v).end())
#define pob pop_back()
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  string s;
  cin>>s;
  if(s=="SUN") cout<<7;
  else if(s=="MON") cout<<6;
   else if(s=="TUE") cout<<5; else if(s=="SAT") cout<<1;
    else if(s=="WED") cout<<4;
     else if(s=="THU") cout<<3;
      else if(s=="FRI") cout<<2;
      return 0;
  
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
    int N,t[101],M,p[101],x[101],sum=0;
    cin>>N;
    rep(i,N) cin>>t[i];
    cin>>M;
    rep(i,M) cin>>p[i]>>x[i];
    
    rep(i,N) sum+=t[i];

    rep(i,M) {
        p(sum+x[i]-t[p[i]-1]);
    }

}

Measured memory_bytes: 3552
from math import sqrt

N,K=map(int,input().split())
mod=10**9+7

fn=[0 for i in range(0,K+1)]
fn[0]=0
fn[1]=1
for i in range(2,K+1):
    I=int(sqrt(i))
    s=sum(fn[i//g] for g in range(1,I+1))
    t=0
    r=i//(I+1)
    for j in range(1,r+1):
        t=(t+(i//j-i//(j+1))*fn[j])%mod
    fn[i]=(pow(i,N,mod)-s-t)%mod

ans=0
for g in range(1,K+1):
    ans=(ans+g*fn[K//g])%mod

print(ans)

Measured memory_bytes: 73392
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
int main() {
    ll n,m;
    cin>>n>>m;
    ll a,b;
    vector<pair<ll,ll>>v;
    for(ll i=0;i<n;i++)
    {
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
    ll cost=0,g=0;
    for(ll i=0;i<n;i++)
    {
        if(m>v[i].second)
        {
            g=v[i].second;
            m-=g;
        }
        else
        {
            g=m;
            m=0;
        }
        cost+=g*v[i].first;
        if(m==0)
        {
            break;
        }

    }
    cout<<cost<<endl;
	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
 using namespace  std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const double pi=3.1415926535897932384626433832;
const long long mod=1e9+7;
//long long primeset[5000000]={};
typedef complex<double> cd;
typedef long long ll;
typedef double ld;
//#define For(i,0,n) for(long long i = 0 ; i<n ;i++) 
cd fast_exp(cd a, long long b)
{
	if (b == 0)
		return 1;
	
	cd res = fast_exp(a, b / 2);
		
	res = res * res;
	
	if (b % 2 == 1)
		res = res * a;
	
	return res;
}

long long fastexpon(long long a,long long b,long long mod)
{
	if(b==0)
		return 1;
	
	long long res=fastexpon(a,b/2,mod);
	
	res=(res*res)%mod;
	if(b%2==1)
		res= (res * a)%mod;

	return res;
}


//template ends here





int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	int dp[k+1]={};
	dp[0]=1;

	int a[n];
	for(int i=0 ;i<n ;i++)
	cin>>a[i];
	int prefix[k+2]={};
	for(int i=0 ;i<n ;i++)
	{
		for(int j=k ; j>=0 ;j--)
		{
			int cur=dp[j];
			int l=j+1;
			int r=min(j+a[i],k);
			//cout<<"j  = "<<j<<"  l= "<<l<<"  r=  "<<r<<'\n';
			prefix[l]= (prefix[l]+cur)%mod;
			prefix[r+1]= (prefix[r+1]-cur+mod)%mod;
			// for(int m=0 ; m<k+2 ;m++)
			// 	cout<<prefix[m]<<' ';
			// 	cout<<endl;

		}



			int sum=0;
			for(int j=0 ; j<=k ;j++)
			{
				sum+=prefix[j];
				prefix[j]=0;
				sum=sum%mod;
				dp[j]=(dp[j]+sum)%mod;
			}		
	}

	// for(int i=0 ;i<=k ;i++)
	// {
	// 	cout<<dp[i]<<'\n';
	// }
	// cout<<"\n\n\n";

	// for(int i=0 ;i<=k ;i++)
	// {
	// 	cout<<dp[i]<<'\n';
	// }
	cout<<dp[k]<<'\n';
	

	

	
	//cout<<'\n'<<"time elapsed: "<<clock()*1000.0 / CLOCKS_PER_SEC<<" ms"<<'\n';
	return 0;
}

Measured memory_bytes: 1024
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
BIG = 10**18

h,w = inm()
s = []
for i in range(h):
    s.append(ins())
d = [[0]*w for i in range(h)]
d[0][0] = 1 if s[0][0]=='#' else 0
for i in range(h):
    for j in range(w):
        if i==0 and j==0:
            continue
        vx = BIG if i==0 else \
          d[i-1][j]+(1 if s[i-1][j]=='.' and s[i][j]=='#' else 0)
        vy = BIG if j==0 else \
          d[i][j-1]+(1 if s[i][j-1]=='.' and s[i][j]=='#' else 0)
        d[i][j] = min(vx,vy)
        #ddprint(f"i {i} j {j} x {vx} y {vy} dij {d[i][j]}")
print(d[h-1][w-1])


Measured memory_bytes: 42864
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
# define ALL(x) (x).begin(), (x).end()
using namespace std;
int main()
{
    int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;




return 0;
}

Measured memory_bytes: 3636
gets
l=gets.split.map{|c|[c.to_i]}
i=0
l.sort.map{|a|a[0]=i+=1}
b=[s=0]*(1+r=l.size)
l.reverse_each{|n,|i=n;(s+=b[i];i&=i-1)while i>0;(b[n]+=1;n+=n&-n)until n>r}
p s

Measured memory_bytes: 32624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int x[n], y[n], a[n];
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> a[i];
  int rec[w][h];
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      rec[i][j] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      for (int ii = 0; ii < x[i]; ii++) {
        for (int jj = 0; jj < h; jj++) {
          rec[ii][jj] = 0;
        }
      }
    }
    if (a[i] == 2) {
      for (int ii = x[i]; ii < w; ii++) {
        for (int jj = 0; jj < h; jj++) {
          rec[ii][jj] = 0;
        }
      }
    }
    if (a[i] == 3) {
      for (int ii = 0; ii < w; ii++) {
        for (int jj = 0; jj < y[i]; jj++) {
          rec[ii][jj] = 0;
        }
      }
    }
    if (a[i] == 4) {
      for (int ii = 0; ii < w; ii++) {
        for (int jj = y[i]; jj < h; jj++) {
          rec[ii][jj] = 0;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      ans += rec[i][j];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys
input=sys.stdin.readline


class Reroot:
    def __init__(self, N, e, merge, f, g):
        self.G = defaultdict(list)
        self.parents = [-1]*(N+1)
        self.dp = defaultdict(lambda: defaultdict(int))
        self.ans = [0]*(N+1)
        self.merge = merge
        self.f = f
        self.g = g
        self.e = e

    def add_edge(self, s, t):
        self.G[s].append(t)

    def build(self):
        self.dfs1(1)
        self.dfs2(1)
        return self.ans

    def dfs1(self, s):
        l = []
        q = [1]
        while q:
            s = q.pop()
            l.append(s)
            for t in self.G[s]:
                if t == self.parents[s]:
                    continue
                self.parents[t] = s
                q.append(t)

        for s in l[::-1]:
            v = self.e
            for t in self.G[s]:
                if t == self.parents[s]:
                    continue
                v = self.merge(v, self.f(self.dp[s][t], 1))
            self.dp[self.parents[s]][s] = self.g(v, 0)

    def dfs2(self, s):
        q = [(s, self.e)]
        while q:
            s, dp_p = q.pop()
            par = self.parents[s]
            for t in self.G[s]:
                if t == par:
                    self.dp[s][t] = dp_p

            size = len(self.G[s])
            ac_l = [self.e] * (size+1)
            ac_r = [self.e] * (size+1)
            for i, t in enumerate(self.G[s]):
                ac_l[i+1] = self.merge(ac_l[i], self.f(self.dp[s][t], 1))
            for i, t in enumerate(self.G[s][::-1]):
                ac_r[size-i-1] = self.merge(ac_r[size-i], self.f(self.dp[s][t], 1))
            self.ans[s] = self.g(ac_l[size], 0)
            for i, t in enumerate(self.G[s]):
                if t == par:
                    continue
                q.append((t, self.g(self.merge(ac_l[i], ac_r[i+1]), 0)))


def solve():
    N, M = map(int, input().split())
    
    merge = lambda x,y:(x*y)%M
    f = lambda x,y:x+y
    g = lambda x,y:x+y
    e = 1
    tree = Reroot(N, e, merge, f, g)

    for _ in range(N-1):
        a, b = map(int, input().split())
        tree.add_edge(a, b)
        tree.add_edge(b, a)
    ans = tree.build()
    for i in range(1, N+1):
        print(ans[i])


if __name__ == "__main__":
    solve()


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

public class Main{
	static int ans;
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		try{
			while(true){
				int n=scan.nextInt();
				int s=scan.nextInt();
				if(n==0 && s==0)break;
				ans=0;
				func(0,n,s);
				System.out.println(ans);
			}
		}catch(NumberFormatException e){
			System.out.println(e);
		}
	}
	private static void func(int min,int n,int s){
		if(s<min*n)return;
		if(n==1){
			if(s<10)ans+=1;
		}else{
			for(int i=min;i<=s/n;i++)func(i+1,n-1,s-i);
		}
	}
}

Measured memory_bytes: 26324
#include <cstdio>
#include <cmath>

int pow100(int n){
    int ans = 1;
    for(int i=0; i<n; i++) ans *= 100;
    return ans;
}

int main(){
    int D, N;
    scanf("%d%d", &D, &N);
    printf("%d\n", (N+(N==100))*pow100(D));
    return 0;
}

Measured memory_bytes: 128
import sys

N, Y = [int(x) for x in input().split(" ")]

for x in range(0, N + 1):
    for y in range(0, N + 1):
        if ((N - x - y) * 1000 + x * 10_000 + y * 5000) == Y and (N - x - y) >= 0:
            print(x, y, N - x - y)
            sys.exit(0)
print(-1, -1, -1)

Measured memory_bytes: 65956
def ipow(x,y):
    z = 1
    for i in range(y):
        z *= x
    return z

def make_bit(value,deg):
    bit = []
    for i in range(deg):
        bit.append(value%2)
        value = value >> 1
    return bit


n,m,x = (int(i) for i in input().split())
data  = []
result = [0] * (m+1)

ra = ipow(2,n)
ans = -1

for i in range(n):
    data.append([int(x) for x in input().split()])

for i in range(ra):
    flag = True
    result = [0 for i in range(m+1)]
    bit = make_bit(i,n)
    for j in range(n):
        if(bit[j] == 1):
            result = [x+y for(x,y) in zip(result,data[j])]
    for j in range(1,m+1):
        if result[j] < x:
            flag = False
            break
    if flag == True:
        if ans == -1 or ans > result[0]:
            ans = result[0]

print(ans)






Measured memory_bytes: 9224