akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
//typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) <<double値
int H = 101, W = 101;
int h,w;
vector<vector<string>> s(H,vector<string>(W));
int dx[] = {0,1};
int dy[] = {1,0};
vector<vector<int>> dp(H,vector<int>(W,inf));
void dfs(int y, int x){

    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            int ny = y + dy[i];
            int nx = x + dx[j];
            if(ny < h && nx < w && 0 < ny && 0 < nx){
                if(s[ny][nx] == "#"){
                    if(s[ny-1][nx] == "." && s[ny][nx-1] == "."){
                        dp[ny][nx] = min(dp[ny-1][nx]+1,dp[ny][nx-1]+1);
                    }else if(s[ny-1][nx] == "#" && s[ny][nx-1] == "."){
                        dp[ny][nx] = min(dp[ny-1][nx],dp[ny][nx-1]+1);
                    }else if(s[ny-1][nx] == "." && s[ny][nx-1] == "#"){
                        dp[ny][nx] = min(dp[ny-1][nx]+1,dp[ny][nx-1]);
                    }else if(s[ny-1][nx] == "#" && s[ny][nx-1] == "#"){
                        dp[ny][nx] = min(dp[ny-1][nx],dp[ny][nx-1]);
                    }

                }else{
                    dp[ny][nx] = min(dp[ny-1][nx],dp[ny][nx-1]);
                }
                //dfs(ny,nx);
            }
        }
    }
    return ;
}

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    cin >> h >> w;
    s.resize(h,vector<string>(w));
    dp.resize(h+1,vector<int>(w+1));
    rep(i,h){
        rep(j,w){
            char c;
            cin >> c;
            s[i][j] = c;
        }
    }
    
    int countj = 0, counti = 0;
    if(s[0][0] == "#"){
        countj++;
        counti++;
    }
    rep1(j,1,w){
        if(s[0][j] == "#" && s[0][j-1] == ".") countj++;

        dp[0][j] = countj;
        //cout << countj;
    }
    rep1(i,1,h){
        if(s[i][0] == "#" && s[i-1][0] == ".") counti++;

        dp[i][0] = counti;
    }

    rep(i,h){
        rep(j,w){
            dfs(i,j);
        }
    }


    cout << dp[h-1][w-1];
}

Measured memory_bytes: 896
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 b = sc.nextInt();
        int c = sc.nextInt();
        
        String flag = "No";
        
        if(c <= b && a <= c) flag = "Yes";
        
        System.out.println(flag);
    }
}

Measured memory_bytes: 21716
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    if n % 2 == 1 {
    put!(n / 2);
    } else {
        put!((n - 2) / 2);
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const int TopIndex = 1;
const int DummySize = 1;

void Exchange(vector<int>& Heap, int& InsertIndex, int& ParentIndex)
{
	swap(Heap[InsertIndex], Heap[ParentIndex]);
	InsertIndex = ParentIndex;
	ParentIndex = InsertIndex / 2;
}

void Insert(vector<int>& Heap, int k)
{
	Heap.push_back(k);
	int InsertIndex = Heap.size() - 1;
	int ParentIndex = InsertIndex / 2;
	while(InsertIndex > TopIndex && Heap[InsertIndex] > Heap[ParentIndex]){
		Exchange(Heap, InsertIndex, ParentIndex);
	}
}

void maxHeapify(vector<int>& A, int i)
{
	int H = A.size() - 1;
	int l = 2 * i;
	int r = 2 * i + 1;
	//????????????????????????????????§???????????§????????????????????¶
	int largest;
	if(l <= H && A[l] > A[i]){
		largest = l;
	}else{
		largest = i;
	}
	if(r <= H && A[r] > A[largest]){
		largest = r;
	}
	//i???????????????????????§????????´???
	if(largest != i){
		swap(A[i], A[largest]);
		//?????°??????????????????
		maxHeapify(A, largest);
	}
}

void ExtractMax(vector<int>& Heap)
{
	int TailIndex = Heap.size() - 1;
	cout << Heap[TopIndex] << endl;
	swap(Heap[TailIndex], Heap[TopIndex]);
	Heap.pop_back();
	maxHeapify(Heap, TopIndex);
}

int main()
{
	vector<int> Heap(DummySize);
	while(true){
		string Command;
		cin >> Command;
		if(Command == "insert"){
			int k;
			cin >> k;
			Insert(Heap, k);
		}else if(Command == "extract"){
			ExtractMax(Heap);
		}else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 7060
# 上からx問目を選ぶことができるか二分探索
# x <= Pであれば必ず選べる
# A_x + M < A_Pであれば必ず選べない
# それ以外の場合
# A_xには必ず投票するのでA_x + Mが基準点
# A_xがP位である必要がある
# 上位P - 1位までにはM票投票して良い
# P + 1位以下に対しては、A_x + Mまでは投票して良い
# この投票して良い数がM * Vを上回ればOK

import sys
readline = sys.stdin.readline

N,M,V,P = map(int,readline().split())
A = sorted(list(map(int,readline().split())),reverse = True)

# 最初の時点で上位P位の点数を求めておく
border = A[P - 1]

# 大きい順に並べる

ok = -1
ng = N

def isOk(x):
  # 上からx番目を選ぶことが出来るか
  if (x + 1) <= P:
    return True
  if A[x] + M < border:
    return False
  # 基準点
  base = A[x] + M
  
  # 上位P - 1には必ず投票して良い
  vote = (P - 1) * M
  # P位以下には、baseを超えないように投票して良い
  for i in range(P - 1,len(A)):
    limit = max(base - A[i], 0)
    can = min(limit, M)
    vote += can
  if vote >= M * V:
    return True
  return False

while abs(ok - ng) > 1:
  mid = abs(ok + ng)//2
  if isOk(mid):
    ok = mid
  else:
    ng = mid
    
print(ok + 1)


Measured memory_bytes: 14168
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define Pll pair<ll,ll>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}
int n,q;
hei(ll) seg, lazy;

void aaa(int k) {
	if (lazy[k] == 0)return ;
	if (k < n - 1) {
		lazy[k * 2 + 1] += lazy[k];
		lazy[k * 2 + 2] += lazy[k];
	}
	seg[k] += lazy[k];
	lazy[k] = 0;
}

void update(int a, int b, ll x,int k,int l,int r) {
	aaa(k);
	if (a<=l && b>=r) {
		lazy[k] += x;
		aaa(k);
	}
	else if(a<r&&l<b){
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		seg[k] = seg[k * 2 + 1]+seg[k * 2 + 2];
	}
}

ll query(int a,int b,int k,int l,int r){
	aaa(k);
	if (l >= b || r <= a)return 0;
	if (a <=l  && b >= r) {
		return seg[k];
	}
	ll v1 = query(a, b, k*2+1, l, (l + r) / 2);
	ll v2 = query(a, b, k*2+2, (l + r) / 2, r);
	return v1 + v2;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	string c1, c2;
	cin >> c1 >> c2;
	YES(c1[0]==c2[2]&&c1[1]==c2[1]&&c1[2]==c2[0])
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef struct point
{
	int x,y;
	bool operator < (const struct point & t)const
	{
		return x==t.x?y<t.y:x<t.x;
	}
}POINT,*PPOINT;
int w,h;
POINT arr[200002];
long long fac[200010],rev[200010],f[200002];
void init()
{
	int i;
	fac[0]=fac[1]=rev[0]=rev[1]=1;
	for(i=2;i<=h+w-2;i++)
	{
		fac[i]=fac[i-1]*i%MOD;
		rev[i]=(MOD-MOD/i)*rev[MOD%i]%MOD;	
	}
	for(i=2;i<=h+w-2;i++)
		rev[i]=rev[i-1]*rev[i]%MOD;	
}
int main()
{
	int i,j,n;
	scanf("%d %d %d",&h,&w,&n);
	for(i=0;i<n;i++)
		scanf("%d %d",&arr[i].x,&arr[i].y);
	arr[n].x=h;
	arr[n].y=w;
	sort(arr,arr+n+1);
	init();
	for(i=0;i<=n;i++)
	{
		f[i]=fac[arr[i].x+arr[i].y-2]*rev[arr[i].x-1]%MOD*rev[arr[i].y-1]%MOD;
		//printf("%d %d\n",i,f[i]);
		for(j=0;j<i;j++)
		{
			f[i]=(f[i]-f[j]*fac[arr[i].x-arr[j].x-arr[j].y+arr[i].y]%MOD*rev[arr[i].x-arr[j].x]%MOD*rev[arr[i].y-arr[j].y]%MOD);
		}
		f[i]=(f[i]+MOD)%MOD;
	}
	printf("%lld\n",(f[n]+MOD)%MOD);
	return 0;
}

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

int main() {
  int n = 0;
  cin >> n;
  int m = n % 1000;
  if (m == 0){
    cout << 0;
    return 0;
  }
  int v = 1000 - m;
  cout << v;
	return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	ll n,m;
	ll a[111];
	cin>>n>>m;
	rep(i,n)cin>>a[i];
	rep(i,n)a[i]*=4*m;
	ll cnt=0;
	rep(i,n)cnt+=a[i];
	cnt=cnt/4/m;
	//cout<<cnt<<endl;
	int res=0;
	rep(i,n)
	{
		if(a[i]>=cnt)res++;
	}
	if(res>=m)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}



Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int W,H;
	cin>>W>>H;
	vll p(W);
	vll q(H);
	rep(i,W) cin>>p[i];
	rep(i,H) cin>>q[i];
	priority_queue<pll> pq;
	rep(i,W){
		pq.push(mkp(p[i],0));
	}
	rep(i,H){
		pq.push(mkp(q[i],1));
	}
	ll ans = 0;
	ll a = 1;
	ll b = 1;
	while(pq.size()){
		pll top = pq.top();
		pq.pop();
		if(top.S){
			b++;
			ans += top.F * a;
		}
		else{
			a++;
			ans += top.F * b;
		}
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 6128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, N);
  vi a(N);
  rep(i, N) {
    cin >> a[i];
  }
  
  ll breakCount = 0;
  ll current = 1;
  rep(i, N) {
    if(a[i] == current) {
      current++;
    } else {
      breakCount++;
    }
  }
  
  if(breakCount == N) {
    fin(-1);
  } else {
    fin(breakCount);
  }
}

Measured memory_bytes: 1024
import scala.io.StdIn.readLine

object Main extends App {
  val Array(x, y) = readLine.split(" ").map(_.toInt)

  @scala.annotation.tailrec
  def gcd(x: Int, y: Int): Int = if (y == 0) x else gcd(y, x % y)

  println(gcd(x, y))
}


Measured memory_bytes: 43964
#include<cstdio>
#define min(a,b) (a<b?a:b)
#define max(a,b) (a<b?a:b)
int n,c;
const long long mod=1e9+7;
int A[405],B[405];
long long matmod(long long val,long long k){
	long long ret=1;
	for(;k;k>>=1){
		if(k&1) ret=(val*ret)%mod;
		val=(val*val)%mod;
	}
	return ret;
}
void add(long long &des,long long sor){des+=sor;des%=mod;return ;}
long long sum[405][405],f[405][405];
int main(){
	//freopen("candies.in","r",stdin);
	//freopen("candies.out","w",stdout);
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	for(int i=1;i<=n;i++) scanf("%d",&B[i]);
	for(int i=0;i<=c;i++){
		for(int j=1;j<=400;j++)
			add(sum[i][j],sum[i][j-1]+matmod(j*1ll,i*1ll));
	}
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=c;j++)
			for(int k=0;k<=j;k++)
				add(f[i][j],f[i-1][j-k]*(sum[k][B[i]]-sum[k][A[i]-1]+mod)%mod);
	}
	printf("%lld\n",f[n][c]);
	return 0;
}

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

int main(){
	int a[100],n;
	cin >> n;
	for(int i = 0;i < n;++i){
		cin >> a[i];
	}
	for(int j = 0;j < n;++j){
		if(j) cout << " ";
		cout << a[j];
	}
	cout << endl;
	for(int i = 1;i < n;++i){
		int j = i - 1,tmp = a[i];
		while(j >= 0 && a[j] > tmp){
			a[j + 1] = a[j];
			--j;
		}
		a[j + 1] = tmp;
		for(j = 0;j < n;++j){
			if(j) cout << " ";
			cout << a[j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int A, B;
int ans = -1;

int main(){
  cin >> A >> B;
  for(int i=1;i<1010;++i){
      if((int)(i * 0.08) == A and (int)(i * 0.1) == B){
        ans = i; 
        break;
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

class binomial{
    private:
    const long long MOD = 998244353;
    std::vector<long long> fac;
    std::vector<long long> facIE;
    
    long long inv(int b){
        long long r=1,e=MOD-2;
        while(e){
            if(e&1){
                r=(r*b)%MOD;
            }
            b=(b*b)%MOD;
            e >>=1;
        }
        return r;
    }
    
    public:
    void precalc(long long N){
        fac.resize(N+1);
        facIE.resize(N+1);
        fac[0]=1;
        for(long long i=0;i<N;i++){
            fac[i+1]=((i+1)*fac[i])%MOD;
        }
        
        facIE[N] = inv(fac[N]);
        for(int i=N-1;i>=0;i--){
            facIE[i]=((i+1)*facIE[i+1])%MOD;
        }
    }
    
    long long get(long long n,long long r){
        if(r<0 || n<r)return 0;
        long long R = fac[n];
        R = (R*facIE[r])%MOD;
        R = (R*facIE[n-r])%MOD;
        return R;
    }
    
};
 
 
signed main(void){
    long long N,A,B,K;
    std::cin >> N >> A >> B >> K;
    
    const long long MOD = 998244353;
    long long Ans=0;
    
    binomial binom;
    binom.precalc(N);
    
    REP(i,N+1){
        long long b=K-A*i;
        if(b>=0 && b%B==0 && b/B<=N){
            b/=B;
            Ans+=(binom.get(N,i)*binom.get(N,b))%MOD;
            Ans%=MOD;
        }
    }
    std::cout << Ans << std::endl;
    return 0;
}



Measured memory_bytes: 4992
import sys
input = sys.stdin.readline

#input
a, b, x = map(int, input().split())

#output
import math
#傾けた時一番低い部分の高さは

if x >= a**2*b/2:
    theta = math.atan((2*a**2*b-2*x)/a**3)
else:
    theta = math.atan(a*b**2/(2*x))
print(math.degrees(theta))

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long int li;
typedef unsigned long long int ull;
typedef long double ld;
#define Max 200002
#define mod 1000000007
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define mkp make_pair
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define endl "\n"
int L[Max]={0},R[Max]={0};
void bye()
{
	
	exit(0);
}
signed main()
{
	fast;
	ll t,pro=1,n,m,temp,k,l,r,mid,i,j,x,y,z,rem,ind,ans=0,mx=LONG_LONG_MIN,mn=LONG_LONG_MAX,cnt=0,curr=0,prev,sum=0,flag=0,i1=-1,i2=-1;
	cin>>n;
	int a[n+2];
	a[0]=a[n+1]=INT_MIN;
	rep(i,1,n)
	{
	    cin>>a[i];
	}
	rep(i,1,n)
	{
	    j=i-1;
	    while(a[j]>a[i])
	    {
	        j=L[j];
	    }
	    L[i]=j;
	}
	rrep(i,n,1)
	{
	    j=i+1;
	    while(a[j]>a[i])
	    {
	        j=R[j];
	    }
	    R[i]=j;
	}
	rep(i,1,n)
	{
	    ans+=a[i]*(i-L[i])*(R[i]-i);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define inf 0x7fffffff
#define mkp make_pair
#define maxn 100205
typedef unsigned int U;
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const  double eps = 1e-8;
const double pi = acos(-1);
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}
int h,w,n,m,x[100005],y[100005];
ll ans[10],sum;
map<pair<int,int>,int > mp;
map<pair<int,int>,int >vis;
void solve(int x,int y){
	if(vis[{x,y}]) return ;
	vis[{x,y}]++;
	if(x+2>h) return ;
	if(y+2>w) return ;
	if(x<1) return ;
	if(y<1) return ;
	int cnt=0;
	for(int i=x;i<=x+2;i++)
		for(int j=y;j<=y+2;j++)
			if(mp[{i,j}]) cnt++;
	ans[cnt]++;
}
int main(){
	int i,j,k;
	//freopen("a.out","r",stdin);
	//freopen("a.ans","w",stdout);
	h=read(),w=read(),n=read();
	for(i=1;i<=n;i++) {
		x[i]=read(),y[i]=read();
		mp[{x[i],y[i]}]=1;
	}
	int cnt;
	for(i=1;i<=n;i++){
		solve(x[i],y[i]);
		solve(x[i],y[i]-1);
		solve(x[i],y[i]-2);
		solve(x[i]-1,y[i]);
		solve(x[i]-1,y[i]-1);
		solve(x[i]-1,y[i]-2);
		solve(x[i]-2,y[i]);
		solve(x[i]-2,y[i]-1);
		solve(x[i]-2,y[i]-2);
	}
	for(i=1;i<=9;i++) sum+=ans[i];
	sum=(h-2ll)*(w-2ll)-sum;
	printf("%lld\n",sum);
	for(i=1;i<=9;i++) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 216864
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N,M;
    cin >> N >> M;
    
    vi a,b;
    set<int> A;
    A.insert(0);
    int aa = 1;
    int bb = N;
    reps(i,1,N+1){
        if(!A.count(abs(aa-bb)) && !A.count(N-abs(aa-bb)) && (abs(aa-bb) != N-abs(aa-bb))){
            a.pb(aa);
            b.pb(bb);
            A.insert(abs(aa-bb));
            A.insert(N-abs(aa-bb));
            aa++;
            bb--;
        }else{
            bb--;
        }
    }
   
    //set<int> aaa;
    rep(i,M){
        cout << a[i] csp b[i]<< endl;
        //cout << a[i] csp b[i] csp abs(a[i]-b[i]) csp N-abs(a[i]-b[i]) << endl;
        //aaa.insert(abs(a[i]-b[i]));
        //aaa.insert(N-abs(a[i]-b[i]));
    }
    
    //cout << aaa.size() << endl;
    
    
    

    return 0;
}


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

int N,M;
vector<vector<pair<int,int>>> Graph;
vector<int> A;
void INPUT(){
    cin>>N>>M;
    Graph.resize(N);
    A.assign(N,-1);
    rep(i,M){
        int x,y,z;
        cin>>x>>y>>z;
        x--;y--;
        z %= 2;
        Graph[x].push_back({y,z});
        Graph[y].push_back({x,z});
    }
}
int solve(){
    queue<int> Q;
    int cnt = 0;
    rep(i,N){
        if(A[i]==-1){
            Q.push(i);
            cnt++;
            while(!Q.empty()){
                auto xi = Q.front();
                Q.pop();
                A[xi] = 1;
                for(auto nx:Graph[xi]){
                    int cost = nx.second;
                    if(A[nx.first]!=-1)continue;
                    A[nx.first] =1;
                    Q.push(nx.first);
                }
            }
        }
    }
    return cnt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    INPUT();
    cout<<solve()<<endl;
}

Measured memory_bytes: 7284
#include <string>
#include <iostream>
using namespace std;
int main() {
	int N; string S;
	cin >> N >> S;
	for (int i = 0; i < S.size(); ++i) {
		if (int(S[i]) + N <= int('Z')) S[i] += N;
		else S[i] -= 26 - N;
	}
	cout << S << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    if (n % 2 == 0) cout << "0.5000000000";
    else
    {
        cout << fixed << setprecision(10) << (double)((n / 2 + 1) / (n * 1.0));
    }
    return 0;
}


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

using Lint=long long;

Lint solve(Lint X,Lint Y)
{
    if(X<0) X=-X,Y=-Y;
    if(X==0) return 1;
    else{
        if(X+Y>0) return 0;
        else{
            Lint res=(X/abs(X+Y)+1)*2-1;
            if(X%abs(X+Y)==0) res--;
            return res;
        }
    }
}

int main()
{
    Lint T1,T2,A1,A2,B1,B2; cin>>T1>>T2>>A1>>A2>>B1>>B2;
    Lint X=(A1-B1)*T1;
    Lint Y=(A2-B2)*T2;
    if(X+Y==0) cout<<"infinity"<<endl;
    else cout<<solve(X,Y)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const long long mod=1e9+7;
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; }
ll gcd(ll a,ll b){return a%b?gcd(b,a%b):b;}
ll lcm(ll c,ll d){return c*d/gcd(c,d);}
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
  ll s1=b/c-a/c,s2=b/d-a/d,s3=lcm(c,d);
  ll s4=b/s3-a/s3;
  ll k=b-a-s1-s2+s4;
  if(a%c!=0&&a%d!=0)k++;
  cout<<k<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define F first
#define S second
int const M=2e5+10,M2=1e6+10,M3=5e3+10,inf=1e18+10,mod=1e9+7;
int c[20][20],a[M3][M3];
set<pii>dij;
bool mark[M];
int ans[M],ans2[M];
main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<=9;i++)
	{
		for(int j=0;j<=9;j++)
			cin>>a[i][j];
	}
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++)
			ans[j]=inf,mark[j]=0;
		ans[i]=0;
		dij.insert(mp(1,i));
		while(dij.size())
		{
			pii now=*dij.begin();
			//cerr<<now.S<<" ";
			int v=now.S;
		//	cerr<<i<<" "<<v<<" "<<ans[v]<<endl;
			mark[v]=1;
			dij.erase(now);
			for(int l=0;l<=9;l++)
			{
				if(!mark[l])
				{
					dij.erase(mp(ans[l],l));
					ans[l]=min(ans[l],ans[v]+a[v][l]);
					dij.insert(mp(ans[l],l));
				}
			}
		}
		ans2[i]=ans[1];
	}
	//for(int i=0;i<=9;i++)
	//	cerr<<ans[i]<<" ";
	int an=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]!=-1)
				an+=ans2[a[i][j]];
		}
	}
	cout<<an;
}

Measured memory_bytes: 10496
import sys

A, B, C, K = list(map(int, input().split()))
ans = 0

if A > K:
    print(K)
    sys.exit()
ans += A
K -= A
if B > K:
    print(ans)
    sys.exit()
K -= B
if C > K:
    print(ans - K)
    sys.exit()
else:
    print(ans - C)

Measured memory_bytes: 9156
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[2000000], ans, dp[2000000], a[2000000],b[2000000];
string str,ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[1000000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> str;
	rep(i, str.size()) {
		if (str[i] == 'B') {
			if (ss.size() > 0)
				ss.erase(ss.size() - 1);
		}
		else {
			ss.push_back(str[i]);
		}
	}
	cout << ss << endl;
	return 0;
}


Measured memory_bytes: 24832
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n, k = map(int,input().split())
    A = list(map(int,input().split()))
    for i in range(k,n):
        if A[i-k] < A[i]:
            print("Yes")
        else:
            print("No")

if __name__=='__main__':
    main()

Measured memory_bytes: 105548
nb_days = int(input())
now_a, now_b, now_c = 0, 0, 0
for _ in range(nb_days):
    a, b, c = [int(x) for x in input().split()]
    next_a = a + max(now_b, now_c)
    next_b = b + max(now_a, now_c)
    next_c = c + max(now_a, now_b)
    now_a, now_b, now_c = next_a, next_b, next_c
print(max(next_a, next_b, next_c))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <cstdlib>

using namespace std;

int arr[100001];
int right[100001];
int left[100001];

int main()
{
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &arr[i]);
	}
	
	right[0] = abs(arr[0]);
	for (int i = 1; i < n; i++)
	{
		right[i] = right[i - 1] + abs(arr[i] - arr[i - 1]);
	}
	
	left[n - 1] = abs(arr[n - 1]);
	for (int i = n - 2; i >= 0; i--)
	{
		left[i] = left[i + 1] + abs(arr[i + 1] - arr[i]);
	}
	
//	for (int i = 0; i < n; i++) printf("%d ", arr[i]); puts("");
//	for (int i = 0; i < n; i++) printf("%d ", right[i]); puts("");
//	for (int i = 0; i < n; i++) printf("%d ", left[i]); puts("");
	
	printf("%d\n", abs(arr[1]) + left[1]);
	for (int i = 1; i < n - 1; i++)
	{
		printf("%d\n", right[i - 1] + left[i + 1] + abs(arr[i + 1] - arr[i - 1]));
	}
	printf("%d\n", abs(arr[n - 2]) + right[n - 2]);
	
	return 0;
}

Measured memory_bytes: 2304
no_of_routes,time_limit=map(int,input().split())
 
smallest_cost=0
for i in range (no_of_routes):
    costs,times=map(int,input().split())
    if times<=time_limit and smallest_cost==0 :
        smallest_cost=costs
    if times <= time_limit and costs<=smallest_cost:
        smallest_cost = costs
 
if smallest_cost==0:
    print("TLE")
else :
    print(smallest_cost)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;

int main() {
  int N, A, B; cin >> N >> A >> B;
   if ((B-A)%2 == 1) cout << "Borys" << endl;
   else cout << "Alice" << endl;
    
  return 0;
  
}

Measured memory_bytes: 3640
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{
    int  n,j=0;
    long long  a[100005];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    for(int i=0;i<n;)
    {
        if(a[i]!=a[i+1])
        {
            i++;
            j++;
        }
        else
            i+=2;
    }
    printf("%d\n",j);
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
using namespace std;
#define INF 10e9
static const int MAX_N=8;
int T[MAX_N];
	int N,A,B,C;

int ans(int i,int a,int b,int c,int cost){
	if(i==N){
		if(a>0 && b>0 && c>0)
			return cost+abs(A-a)+abs(B-b)+abs(C-c);
		else
			return INF;
	}
	return min(min(ans(i+1,a,b,c,cost),ans(i+1,a+T[i],b,c,cost+(a>0?10:0))),min(ans(i+1,a,b+T[i],c,cost+(b>0?10:0)),ans(i+1,a,b,c+T[i],cost+(c>0?10:0))));
}
int main(void){
		cin >> N >> A >> B >> C;
	for(int i=0;i<N;i++)
		cin >> T[i];
	
	cout << ans(0,0,0,0,0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

int n, m, k, xi, yi, xj, yj;
string s[1<<20];

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

  vector<vector<int>> dis(n+3, vector<int>(m+3, 0));
  queue<pair<int,int>> q;
  q.push(mp(xi,yi));
  dis[xi][yi] = 1;
  while (!q.empty()) {
    pair<int,int> ii = q.front();q.pop();
    if(ii == mp(xj,yj)) return dis[xj][yj]-1;
    rep(i,4) {
      int x = ii.F + dx[i], y = ii.S + dy[i], kd = 1;
      while(x >=0 && y >= 0 && x < n && y < m && ((dis[x][y] == 0) || (dis[ii.F][ii.S]+1 <= dis[x][y])) && s[x][y] == '.' && kd <= k) {
          if((dis[x][y] == 0) || (dis[ii.F][ii.S]+1 < dis[x][y])) {
            q.push(mp(x,y));
            dis[x][y]=dis[ii.F][ii.S]+1;
          }
          x += dx[i];
          y += dy[i];
          kd++;
      }
    }
  }

  return -1;
}

int main() {

 // freopen("input.in","r",stdin);
//  freopen("output.out","w",stdout);
  cin>>n>>m>>k;
  cin>>xi>>yi>>xj>>yj;
  xi--;yi--;xj--;yj--;

  rep(i,n) cin>>s[i];

  cout << bfs() << endl;

  return 0;
}


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

int main() {
	string s;
	cin>>s;
	bool f=1;
	if(s.size()%2)f=0;
	else{
		for(int i=0;i<s.size();i++){
			if(i%2&&s[i]!='i')f=0;
			if(i%2==0&&s[i]!='h')f=0;
		}
	}
	cout<<(f?"Yes":"No");
}
  

  


Measured memory_bytes: 256
def show (a,n):
  for i in range(n):
    if i > 0:
      print("",end=" ")
    print(a[i],end="")
  print("")

def bubbleSort(a,n):
  flag = 1
  count = 0
  while flag:
    flag = 0
    for j in range(n-1,0,-1):
      if a[j] < a[j-1]:
        a[j-1],a[j] = a[j],a[j-1]
        flag = 1
        count += 1
  show(a,n)
  print(count)

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

bubbleSort(a,n)


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
int main(){
  random_device rnd;
  mt19937 mt(rnd());
  int D;
  cin >> D;
  vector<int> c(26);
  for (int i = 0; i < 26; i++){
    cin >> c[i];
  }
  vector<vector<int>> s(D, vector<int>(26));
  for (int i = 0; i < D; i++){
    for (int j = 0; j < 26; j++){
      cin >> s[i][j];
    }
  }
  vector<int> last(26, -1);
  for (int i = 0; i < D; i++){
    int t = min(10, D - i);
    vector<vector<int>> L(t, vector<int>(26, 0));
    for (int j = 0; j < t; j++){
      for (int k = 0; k < 26; k++){
        L[j][k] = c[k] * (i + j - last[k]);
      }
    }
    /*
    for (int j = 0; j < t; j++){
      for (int k = 0; k < 26; k++){
        cout << L[j][k] << ' ';
      }
      cout << endl;
    }
    */
    int mx = 0;
    int a = 0;
    vector<int> best(t);
    for (int j = 0; j < 10000; j++){
      vector<vector<int>> L2 = L;
      vector<int> next(t, 0);
      if (j < 1000){
        for (int k = 0; k < t; k++){
          next[k] = mt() % 26;
        }
      } else if (j < 5000){
        next = best;
        for (int k = 0; k < 3; k++){
          int pos = mt() % t;
          int upd = mt() % 26;
          next[pos] = upd;
        }
      } else {
        next = best;
        for (int k = 0; k < 2; k++){
          int pos = mt() % t;
          int upd = mt() % 26;
          next[pos] = upd;
        }
      }
      //calculate diff
      int diff = 0;
      for (int k = 0; k < t; k++){
        diff += s[i + k][next[k]];
        for (int l = k; l < t; l++){
          diff += L2[l][next[k]] - (l - k) * c[next[k]];
          L2[l][next[k]] = (l - k) * c[next[k]];
        }
      }
      if (diff > mx){
        mx = diff;
        best = next;
        /*
        cout << "best: " << endl;
        for (int k = 0; k < t; k++){
          cout << best[k] << ' ';
        }
        cout << endl;
        cout << "mx = " << mx << endl;
        */
      }
    }
    cout << best[0] + 1 << endl;
    last[best[0]] = i;
  }
}

Measured memory_bytes: 3696
#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; 
const int MAX = 1100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
vector<bool> isprime;
vector<int> prime;

void Prime_Sequence(int n){//nまでの素数列を形成
    isprime.resize(n+1,true);
    isprime[0]=false;
    isprime[1]=false;
    int p=0;
    for(int j=2;j<=n;j++){
        if(isprime[j]){
            prime.push_back(j);
            p++;
            for(int k=2;j*k<=n;k++){
                isprime[j*k]=false;
            }
        }
    }
}

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

//ここまで

int main()
{ 
    int n;
    cin>>n;
    LL a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    Prime_Sequence(1000);
    int s=prime.size();//1000以下の素数の個数
    LL l[s];//1000以下のLの素因数の個数。
    for(int i=0;i<s;i++){l[i]=0;}
    bool flg[1000001];
    for(int i=0;i<1000001;i++){flg[i]=0;}
    vector <LL> v;
    //素因数分解
    for(int i=0;i<n;i++){ 
        int x=a[i];
        for(int j=0;j<s;j++){
            LL cnt=0;
            while(x%prime[j]==0){
                x=x/prime[j];
                cnt++;
            }
            if(l[j]<cnt){l[j]=cnt;}
        }
        if(x!=1){
            if(flg[x]==0){
                flg[x]=1;
                v.push_back(x);//1000以上の素数は有無のみ判定
            }
        }
    }

    //まずLの形成
    LL L=1;
    for(int i=0;i<s;i++){
        for(int j=0;j<l[i];j++){
            L=(L*prime[i])%MOD;
        }
    }
    int u=v.size();
    for(int i=0;i<u;i++){
        LL y=v.back();
        v.pop_back();
        L=(L*y)%MOD;
    }

    LL ans=0;
    COMinit();
    for(int i=0;i<n;i++){
        ans=(ans+(L*inv[a[i]])%MOD)%MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 27264
import sys
h,w = map(int, input().split())
mat = ["."+input()+"." for _ in range(h)]
mat = ["."*(w+2)]+mat+["."*(w+2)]
for i in range(1,h+1):
  for j in range(1,w+1):
    if mat[i][j] == "#":
      if (mat[i+1][j] == ".") and  (mat[i-1][j] == ".") and  (mat[i][j+1] == ".") and  (mat[i][j-1] == "."):
        print("No")
        sys.exit()
print("Yes")

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

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

	int n;
	cin >> n;
	vector<int> h(n);
	vector<int> dp(n, 1e9);
	dp[0] = 0;

	for(int i = 0; i < n; i++)
	{
		cin >> h[i];
		if(i >= 1) dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if(i >= 2) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[n - 1] << "\n";
}


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

int main() {
    string s;
    cin >> s;
    bool ans = true;
    for (int i = 0; i < s.length(); i += 2) {
        if (s.substr(i, 2) != "hi") ans = false;
    }
    
    cout << (ans? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int N = 100000;
const int oo = 0x3f3f3f3f;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}
 
LL fpm(LL a, LL b, LL mod) {
    LL res = 1;
    for(; b > 0; b >>= 1) {
        if(b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
 
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
 
LL exgcd(int a, int b, LL& x, LL& y) {
    if(!b) {
        x = 1;
        y = 0;
        return a;
    }
 
    LL g = exgcd(b, a % b, y, x);
    y -= (a / b) * x;
 
    return g;
}
 
int phi(int n) {
    int res = n;
    for(int i = 2; i * i <= n; ++i) if(n % i == 0) {
        res = res / i * (i - 1);
        while(n % i == 0) n /= i;
    }
    if(n > 1) res = res / n * (n - 1);
    return res;
}
 
LL solve(int a, int m) {
    if(m <= 500) {
        int x = a;
        for(int i = 1; ; i++) {
            if(x == i % m) return i;
            x = 1LL * x * a % m;
        }
    }
    
    int p = phi(m);
    int r = gcd(m, p);
    LL t = solve(a, r), a_t = fpm(a, t, m), x, y, l = m / r;
 
    exgcd(m / r, p / r, x, y);
 
    y *= ((m + a_t - t) % m) / r;
    y = (y % l + l) % l;
    LL res = y * p + t;

    assert(fpm(a, res, m) == res % m);
    return res;
}
 
int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif
 
    for(int T = read<int>(); T--; ) {
        static int a, m;
        a = read<int>();
        m = read<int>();
        LL k = solve(a, m);
        printf("%lld\n", k);
    }
 
    return 0;
}


Measured memory_bytes: 384