akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

// std::cmp::Reverse doesn't have Clone.
#[derive(Eq, PartialEq, Clone)]
struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let n: usize = util::get();
    let a: Vec<usize> = util::gets();

    let total = (0..n).map(|_| 3).fold(1, |a, b| a * b);
    let odd = a.iter().map(|x| if x % 2 == 0 { 2 } else { 1 }).fold(
        1,
        |a, b| a * b,
    );

    println!("{}", total - odd);
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
ll sub(ll a){
    if(a%4==0)return a;
    else if(a%4==1)return a^(a-1);
    else if(a%4==2)return a^(a-1)^(a-2);
    else return 0LL;
}
int main(void){
    ll a,b;
    cin>>a>>b;
    a=max(--a,0LL);
    cout<<(sub(a)^sub(b));
}


Measured memory_bytes: 3684
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
vector<int> G[100000];
int ar[100000];
int buffer[100000];
int N;
bool check(int B){
	stack<pair<int,int>> sp;
	sp.push({0,-1});
	while(!sp.empty()){
		int v = sp.top().first;
		int f = sp.top().second;
		sp.pop();
		if(v >= N){
			v -= N;
			int p = 0;
			for(int i=0;i<G[v].size();i++){
				int t = G[v][i];
				if(t != f){
					buffer[p++] = ar[t]+1;
				}
			}
			if(v == 0){
				if(p % 2 == 1){
					buffer[p++] = 0;
				}
				sort(buffer,buffer+p);
				int l = 0;
				int r = p-1;
				while(l < r){
					if(buffer[l] + buffer[r] > B){
						return false;
					}
					l++;
					r--;
				}
			}
			else{
				if(p % 2 == 0){
					buffer[p++] = 0;
				}
				sort(buffer,buffer+p);
				int bf = 0;
				int bl = p;
				while(bf != bl){
					int bc = (bf+bl)/2;
					bool OK = true;
					if(bc != p){
						int l = 0;
						int r = p-1;
						while(l < r){
							if(l == bc){
								l++;
							}
							if(r == bc){
								r--;
							}
							if(buffer[l] + buffer[r] > B){
								OK = false;
								break;
							}
							l++;
							r--;
						}
					}
					if(OK){
						bl = bc;
					}
					else{
						bf = bc+1;
					}
				}
				if(bf == p){
					return false;
				}
				ar[v] = buffer[bf];
			}
		}
		else{
			sp.push({v+N,f});
			for(int i=0;i<G[v].size();i++){
				int t = G[v][i];
				if(t != f){
					sp.push({t,v});
				}
			}
		}
	}
	return true;
}
void Calc(){
	N = rei();
	for(int i=0;i<N-1;i++){
		int a = rei()-1;
		int b = rei()-1;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int A = 0;
	stack<pair<int,int>> sp;
	sp.push({0,-1});
	while(!sp.empty()){
		int v = sp.top().first;
		int f = sp.top().second;
		sp.pop();
		int b = 0;
		for(int i=0;i<G[v].size();i++){
			int t = G[v][i];
			if(t != f){
				b++;
				sp.push({t,v});
			}
		}
		A -= b / 2;
		if(b % 2 == 0 && f != -1){
			A++;
		}
	}
	int bf = 1;
	int bl = N-1;
	while(bf != bl){
		int bc = (bf+bl)/2;
		if(check(bc)){
			bl = bc;
		}
		else{
			bf = bc+1;
		}
	}
	cout << A << " " << bf << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	char c;
	cin >> c;
	cout << (char)(c - (toupper(c) - 'A')) << endl;
	return 0;
}



Measured memory_bytes: 3660
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
#define yi first
#define er second
typedef pair<ll,ll> pll;
typedef vector<ll> vlt;
const ll inf=1e18;
const int yuzu=1e5;
int n=read(),m=read(),s=read(),t=read();
 
struct edge{int to;ll cost;};
vector<edge> lj[2][yuzu|10];
 
vlt pao(int s,int id){
priority_queue<pll,vector<pll>,greater<pll> > q;
vlt d(n+2,inf);
d[s]=0,q.push(pll(0,s));
for (;!q.empty();){
  pll p=q.top();q.pop();
  int v=p.er;
  if (d[v]>=p.yi){
    for (edge e:lj[id][v]){
      if (d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        q.push(pll(d[e.to],e.to));
	    } 
	  }
    }
  }return d;
}
 
int main(){
int i;
for (i=1;i<=m;++i){
  int u=read(),v=read();ll a=read(),b=read();
  lj[0][u].push_back(edge{v,a});
  lj[0][v].push_back(edge{u,a});
  lj[1][u].push_back(edge{v,b});
  lj[1][v].push_back(edge{u,b});
  }
vlt gmy=pao(s,0),xhk=pao(t,1),ans(n+2,inf);
for (i=n;i;--i) ans[i]=min(gmy[i]+xhk[i],ans[i+1]);
ll llx=1e15;
for (i=1;i<=n;++i) write(llx-ans[i]),pl;
}

Measured memory_bytes: 19140
input_lines = readlines.map(&:chomp)
N = input_lines.shift.to_i
XI = input_lines.shift.split(' ').map(&:to_i)

def strength(p)
  XI.map do |x|
    (x - p)**2
  end.inject(:+)
end

stringths = (1..100).map do |x|
  strength(x)
end
result = stringths.min

puts result

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
const double eps=1e-16;
int main(){
	int n,t,A;
	cin>>n>>t>>A;
	int h[100005];
	double T[100005];
	int ans=1;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		T[i]=t-h[i]*0.006;
		if(fabs(T[i]-A)<fabs(T[ans]-A)){
			ans=i;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
int main(void) {
	long long int N;
	cin >> N;
	vector<string> S(N);
	map<string, int> fre;
	int max = -1;
	for (int i = 0; i < N; ++i) {
		string s;
		cin >> s;
		if (fre[s] == NULL) {
			fre[s] = 1;
		}
		else {
			fre[s]++;
		}
		if (max < fre[s]) max = fre[s];
	}

	for (auto i : fre) {
		if (i.second == max) {
			S.push_back(i.first);
		}
	}

	sort(S.begin(), S.end());
	for (int i = 0; i < S.size(); ++i) {
		cout << S[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 28516
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

//#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



int main() {
	string s;
	cin >> s;
	if ((s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0') <= 2019 && (s[5] - '0') * 10 + (s[6] - '0') < 5) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int X;
  cin>>X;
  
  int ans=0;
  bool flag=true;
  int num=X;
  
  while(flag){
    int root=sqrt(num);
    
    ans=num;
    for(int i=2;i<=root;++i){
      if(num%i==0){
        ans=0;
        break;
      }
    }
    
    if(ans>0){
      flag=false;
    }
    else
      ++num;
    
  }
  
  cout<<ans<<endl;
}


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

   if (isupper(a))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }

   return 0;
}


Measured memory_bytes: 3644
import math
a, b = map(str, input().split())
if(b[0] == "0"):
  if b[2] == "0":
    b_m = b[3]
  else:
    b_m = b[2:]
else:
  b_m = b.replace('.', '')

res = int(a) * int(b_m)

if res >= 100:
  res_int = int(str(res)[:-2])
else:
  res_int = 0
print(res_int)

Measured memory_bytes: 61976
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int 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 pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    ll max_val = 0;
    FOR(i, 0, 100000){
        ll a = i*i;
        if(a <= N){
            max_val = a;
        }else{
            break;
        }
    }

    p(max_val);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    vector<int> a(5);
    REP(i,5) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll ans = LINF;
    do {
        ll tmp = 0;
        REP(i,5) {
            tmp+=a[i];
            if (tmp%10 != 0 && i != 4) {
                tmp = tmp+(10-tmp%10);
            } 
        }
        ans = min(ans, tmp);
    } while (next_permutation(a.begin(), a.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

using namespace std;

int main ( void )
{
	int n, t, e;
	
	while (cin >> n >> t >> e)
	{
		int ans = -1;
		
		for (int i = 1; i <= n; i += 1)
		{
			int in, a, b;
			cin >> in;
			a = abs((t / in) * in - t);
			b = abs((t / in + 1) * in - t);
			
			if (a <= e || b <= e)	ans = i;
		}
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <cassert>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <cstdalign>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <exception>
#include <initializer_list>
#include <limits>
#include <new>
#include <stdexcept>
#include <string>
#include <system_error>
#include <typeinfo>

#if __has_include(<string_view>)
#include <string_view>
#endif

#include <algorithm>
#include <array>
#include <cfenv>
#include <cmath>
#include <deque>
#include <forward_list>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#if __has_include(<filesystem>)
#include <filesystem>
#endif

#include <cinttypes>
#include <cstdio>

#include <atomic>
#include <condition_variable>
#include <future>
#include <mutex>
#include <regex>
#include <shared_mutex>
#include <thread>

using namespace std;
using namespace std::literals;
int main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, M, C, r int
	fmt.Scan(&N, &M, &C)
	B := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&B[i])
	}
	for i := 0; i < N; i++ {
		var tmp, h int
		for j := 0; j < M; j++ {
			fmt.Scan(&h)
			tmp += h * B[j]
		}
		if tmp+C > 0 {
			r++
		}
	}
	fmt.Println(r)
}

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

int calc(vector<int>&a,vector<vector<int>>&aa,int q){
  int res=0;
  for(int i=0;i<q;i++){
    if(a.at(aa.at(i).at(1)-1)-a.at(aa.at(i).at(0)-1)==aa.at(i).at(2))res+=aa.at(i).at(3);
  }
  return res;
}

int retu(vector<int>&a,int n,int m,int q,vector<vector<int>>&aa){
  if(a.size()==n){
    return calc(a,aa,q);
  }
  int prev=(a.empty() ? 1:a.back());
  int ans=0;
  for(int i=prev;i<=m;i++){
    a.push_back(i);
    ans=max(ans,retu(a,n,m,q,aa));
    a.pop_back();
  }
  return ans;
}

int main(){
  int n,m,q;
  cin >>n>>m>>q;
  vector<vector<int>>aa(q,vector<int>(4,0));
  for(int i=0;i<q;i++){
    for(int j=0;j<4;j++){
      cin >>aa.at(i).at(j);
    }
  }
  vector<int>a;
  cout <<retu(a,n,m,q,aa)<<endl;
  return 0;
}

Measured memory_bytes: 3564
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
  string s; cin >> s;
  int q; cin >> q;
  string left, right;
  bool rev = false;
  for (int i = 0; i < q; ++i) {
    int type; cin >> type;
    if (type == 1) { 
      rev = !rev;
    }
    else {
      int f;
      char c;
      cin >> f >> c;
      bool l = f == 1;
      if (rev) l = !l;
      if (l) left += c;
      else right += c;
    }
  }
  string ans;
  if (rev) {
    reverse(right.begin(), right.end());
    reverse(s.begin(), s.end());
    ans = right + s + left;
  }
  else {
    reverse(left.begin(), left.end());
    ans = left + s + right;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1348
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

pii operator-(pii l, pii r){ return pii(l.first - r.first, l.second - r.second); }
ll operator/(pii l, pii r){ return (ll)l.first * r.second - (ll)l.second * r.first; }
ll operator*(pii l, pii r){ return (ll)l.first * r.first + (ll)l.second * r.second; }

const int MX = 1005;

char ans[MX][MX];
int N, M, A, B;

void fillA(int x, int y){
	if(A <= 0 ) return;
	A--;
	ans[x][y] = '<';
	ans[x][y+1] = '>';
}
void fillB(int x, int y){
	if(B <= 0 ) return;
	B--;
	ans[x][y] = '^';
	ans[x+1][y] = 'v';
}

int main()
{
	scanf("%d%d%d%d", &N, &M, &A, &B);
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= M; j++) ans[i][j] = '.';
	}
	if(N%2 == 1 && M%2 == 1 && N >= 3 && M >= 3){
		for(int i = 1; i+1 <= M; i += 2) fillA(N, i);
		for(int i = 2; i+1 <= N; i += 2) fillB(i, M);
	
		int ch = 0;
		if(A%2 == 1) fillA(1, M-1), fillB(1, M-2), ch = 1;
		for(int i = 1; i+1 <= N; i += 2){
			for(int j = 1; j+1 <= M; j += 2){
				if(i == 1 && j == M-2 && ch ) continue;
				if(A >= 1){
					fillA(i, j);
					fillA(i+1, j);
				}
				else if(B >= 1){
					fillB(i, j);
					fillB(i, j+1);
				}
			}
		}
	}
	else{
		if(N%2 == 1) for(int i = 1; i+1 <= M; i += 2) fillA(N, i);
		if(M%2 == 1) for(int i = 1; i+1 <= N; i += 2) fillB(i, M);

		for(int i = 1; i+1 <= N; i += 2){
			for(int j = 1; j+1 <= M; j += 2){
				if(A >= 1) fillA(i, j), fillA(i+1, j);
				else if( B >= 1 ) fillB(i, j), fillB(i, j+1);
			}
		}
	}

	if(A > 0 || B > 0) return !printf("NO\n");
	printf("YES\n");
	for(int i = 1; i <= N; i++) printf("%s\n", ans[i]+1);
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
P x[100000],y[100000];
int mypow(int a,int b,int c){
	if(b==0)return 1;
	else if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int n;
	cin>>n;
	cout<<n*n<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int main()
{
	int n,a[111];cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	cout<<a[n-1]-a[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353
class UnionFind:
    def __init__(self, size=None, nodes=None):
        """
        size か nodes どっちか指定。
        nodes は set、size は list を使う。
        set の最悪計算量は O(N) なので size 指定のほうが若干速い
        :param int size:
        :param collections.Iterable nodes:
        """
        assert size is not None or nodes is not None
        if size is not None:
            self._parents = [i for i in range(size)]
            self._ranks = [0 for _ in range(size)]
            self._sizes = [1 for _ in range(size)]
        else:
            self._parents = {k: k for k in nodes}
            self._ranks = {k: 0 for k in nodes}
            self._sizes = {k: 1 for k in nodes}

    def unite(self, x, y):
        """
        x が属する木と y が属する木を併合
        :param x:
        :param y:
        :return:
        """
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        # rank が小さい方が下
        if self._ranks[x] > self._ranks[y]:
            # x が root
            self._parents[y] = x
            self._sizes[x] += self._sizes[y]
        else:
            # y が root
            self._parents[x] = y
            self._sizes[y] += self._sizes[x]
            if self._ranks[x] == self._ranks[y]:
                self._ranks[y] += 1

    def root(self, x):
        """
        x が属する木の root
        :param x:
        :return:
        """
        if self._parents[x] == x:
            return x
        self._parents[x] = self.root(self._parents[x])
        return self._parents[x]

    def size(self, x):
        """
        x が属する木のノード数
        :param x:
        :return:
        """
        return self._sizes[self.root(x)]


N, M = list(map(int, sys.stdin.buffer.readline().split()))
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

AB.reverse()
uf = UnionFind(size=N)
ans = (N - 1) * N // 2
hist = []
for a, b in AB:
    a -= 1
    b -= 1
    hist.append(ans)

    if uf.root(a) != uf.root(b):
        ans -= uf.size(a) * uf.size(b)
        uf.unite(a, b)
hist.reverse()

print(*hist, sep='\n')


Measured memory_bytes: 50088
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function PriorityQueue(){
  this.heap = [];
}
PriorityQueue.prototype = {
  push : function(x){
    var i = this.heap.length++;
    while(i){
      var j = i - 1 >> 1;
      if(this.heap[j] <= x)break;
      this.heap[i] = this.heap[j];
      i = j;
    }
    this.heap[i] = x;
  },
  pop : function(){
    var r = this.heap[0];
    var x = this.heap.pop();
    var i = 0;
    var k = this.heap.length >> 1;
    while (i < k) {
      var j = (i << 1) + 1;
      if(this.heap[j+1] < this.heap[j])++j;
      if(x <= this.heap[j])break;
      this.heap[i] = this.heap[j];
      i = j;
    }
    if(this.heap.length)this.heap[i] = x;
    return r;
  },
  size : function(){return this.heap.length;},
  top : function(){return this.heap[0];},
};
var b = 0;
var low = new PriorityQueue();
var hi = new PriorityQueue();
var cnt = 0;

console.log(main());
function main(){
  var q = o.a();
  var ans = [];
  for(var i = 0; i < q; i++){
    var t = o.l();
    if(t[0] === 2)ans.push((-low.top())+" "+b);
    else solve(t[1],t[2]);
  }
  return ans.join("\n");
}
function solve(u,v){
  b += v;
  var h = hi.top();
  var l = -low.top();
  if(cnt === 0){
    low.push(-u);
  }else if(cnt&1){
    if(l <= u){
      hi.push(u);
    }else{
      hi.push(-low.pop());
      low.push(-u);
    }
    b += Math.abs(u-l);
  }else{
    if(h < u){
      low.push(-hi.pop());
      hi.push(u);
    }else{
      low.push(-u);
    }
    if(u < l)b += l-u;
    else if(h < u)b += u-h;
  }
  cnt++;
}

Measured memory_bytes: 92772
from collections import deque


def solve():
    H, W = map(int, input().split())
    m = [[-1]*W for _ in range(H)]
    l = [list(input()) for _ in range(H)]
    dx = [-1, 1, 0, 0]
    dy = [0, 0, -1, 1]
    q = deque([])

    for i in range(H):
        for j in range(W):
            if l[i][j]=="#":
                q.append((i, j))
                m[i][j] = 0
    
    while q:
        y, x = q.popleft()

        for px, py in zip(dx, dy):
            x1, y1 = x + px, y + py
            if not (0<=x1<W and 0<=y1<H):
                continue
            if m[y1][x1] == -1:
                q.append((y1, x1))
                m[y1][x1] = m[y][x] + 1

    print(max(map(max, m)))


if __name__ == "__main__":
    solve()


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

int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = A * X + B * Y;
    for (int i = 1; i <= max(X, Y); i++)
    {
        if (i <= min(X, Y))
        {
            ans = min(ans, ans - A - B + 2 * C);
        }
        else
        {
            if (X > Y)
            {
                ans = min(ans, ans - A + 2 * C);
            }
            else
            {
                ans = min(ans, ans - B + 2 * C);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 764
import numpy as np
N, M = map(int, input().split(" "))
ab = np.array([[int(i) for i in input().split(" ")] for _ in range(M)])

ab_sort = ab[np.argsort(ab[:,1])]
ans = 0
nb = -1
for a, b in ab_sort:
    if a >= nb:
        ans += 1
        nb = b
print(ans)

Measured memory_bytes: 31672
#include <iostream>
#include <algorithm>

using namespace std;

int n,a[110],s1,s2;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=n;i>=1;i--)
      if((n-i+1)%2==1)s1+=a[i];
      else s2+=a[i];
    cout<<s1-s2;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let mut ans = (n / k) * (n / k) * (n / k);
    if k % 2 == 0 {
        let cnt = (n + k / 2) / k;
        ans += cnt * cnt * cnt;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import queue
N = int(input())
G = [[] for _ in range(N)]

for i in range(N-1):
    a, b = map(lambda n: int(n) - 1, input().split())
    G[a].append(b)
    G[b].append(a)

def dfs(Graph, N, start):
    q = queue.Queue()
    dist = [-1] * N
    dist[start] = 0
    q.put(start)

    while not q.empty():
        v = q.get()
        for u in G[v]:
            if dist[u] != -1:
                continue
            dist[u] = dist[v] + 1
            q.put(u)

    return dist

FE = dfs(G, N, 0)
SN = dfs(G, N, N-1)

get_count = sum(FE[i] <= SN[i] for i in range(N))
print('Fennec' if get_count > N-get_count else 'Snuke')

Measured memory_bytes: 29936
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n,k,x,y;
    cin >>n>>k>>x>>y;
  int ans=0;
 for(int i=1; i<=n; i++){
    if(n<=k)ans=n*x;
    else ans=k*x+(n-k)*y;
 }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



ll GCD(ll m, ll n) {
  if (m == 0) {
    return n;
  } 
  if (n == 0) {
    return m;
  }

  if (m >= n) {
    return GCD(m%n, n);
  } else {
    return GCD(m, n%m);
  }
}

ll A, B;

int main () {
  cin >> A >> B;

  ll ans = A * B / GCD(A, B);
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b;
    
    scanf("%d %d", &a, &b);
 
    if(a == b){
        printf("%d\n", a);
    }else if(a <= b){
        printf("%d\n", a);
    }else if(a >= b){
        printf("%d\n", a - 1);
    }

    return 0;
}
  

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {

        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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


    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }
    let nums: Vec<i32> = s.chars().map(|c| c.to_digit(10).unwrap() as i32).collect();
    for d in 0..1 << 4 {
        let sum = nums.iter().enumerate().fold(0, |a, b| {
            if b.0 == 0 || d & (1 << b.0) == 0 {
                a + b.1
            } else {
                a - b.1
            }
        });
        if sum == 7 {
            print!("{}", nums[0]);
            for i in 1..4 {
                print!("{}", if d & (1 << i) == 0 { "+" } else { "-" });
                print!("{}", nums[i])
            }
            println!("{}", "=7");
            return;
        }
    }
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys
import math

def solve(N: int):
    ans = 100000000000000000
    amax = math.floor(math.sqrt(N))
    for i in range(1,amax+1):
        if N % i == 0:
            ans = min(ans, i+(N/i)-2)
    print(math.floor(ans))
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
s = input()
t = input()

s_c = []
t_c = []
for c in 'abcdefghijklmnopqrstuvwxyz':
    s_c.append(s.count(c))
    t_c.append(t.count(c))
s_c.sort()
t_c.sort()
if s_c == t_c:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define N 200005
using namespace std;
int n,a[N];
//int mx;
vector<int> go[N];
int dfs(int node,int ata) {
    vector<int> cost;
    int ret=0;
    for(int i=0;i<go[node].size();i++) {
        if(go[node][i]!=ata)
            cost.push_back(dfs(go[node][i],node)+1);
    }
    sort(cost.begin(),cost.end(),greater<int>());
    int dep=0;
    for(int i=0;i<cost.size();i++) {
        ret=max(ret,cost[i]+dep);
        dep++;
    }
    return ret;
}
int main() {
    cin>>n;
    for(int i=2;i<=n;i++) {
        cin>>a[i];
        go[a[i]].push_back(i);
    }
    cout<<dfs(1,0);
}


Measured memory_bytes: 17792
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
ZIP = lambda: zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    S = INPUT()
    N = len(S)

    for i in range(N//2):
        if S[i] != S[N-1-i]:
            print("No")
            sys.exit()

    for i in range(N//2//2):
        if S[i] != S[(N-1)//2-1-i] or S[(N+3)//2-1+i] != S[N-1-i]:
            print("No")
            sys.exit()

    print("Yes")
            

if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include<stdio.h>

int main(void){
  int a,b;
  int d,r;
  double f;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/b;
  printf("%d %d %lf\n",d,r,f);
  return 0;
}



Measured memory_bytes: 2028
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    w,a,b=parseMap(split(readline()))
    if a<=b
        println(max(0,b-(a+w)))
    else
        println(max(0,a-(b+w)))
    end
end
main()

Measured memory_bytes: 171768
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int k, a, b;
    cin >> k >> a >> b;
    int ans = 1;
    if (a > k + 1)
    {
        cout << k << endl;
        return 0;
    }
    ans = a;
    k -= (a - 1);
    int d = b - a;
    if (d > 2)
    {
        if (k % 2 == 1)
            ans++;
        ans += d * (k / 2);
    }
    else
        ans += k;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Map<String, Integer> blueMap = new HashMap<>();
			IntStream.range(0, n).forEach(i -> {
				String s = scanner.next();
				blueMap.put(s, blueMap.getOrDefault(s, 0) + 1);
			});
			int m = scanner.nextInt();
			Map<String, Integer> redMap = new HashMap<>();
			IntStream.range(0, m).forEach(i -> {
				String t = scanner.next();
				redMap.put(t, redMap.getOrDefault(t, 0) + 1);
			});
			System.out.println(Math.max(blueMap.entrySet().stream()
					.mapToInt(entry -> entry.getValue() - redMap.getOrDefault(entry.getKey(), 0)).max().getAsInt(), 0));
		}
	}
}


Measured memory_bytes: 29268
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   	ll n,x,i,flag=1;
   	cin >> n;
   	while(n--) {
   		cin >> x;
   		if((x%2==0) &&(x%3!=0&&x%5!=0)) {
   			flag=0;
   		}
   	}
   	if(flag) cout << "APPROVED";
   	else cout << "DENIED";
   	cout << "\n";
    return 0;
}



Measured memory_bytes: 256
# Problem https://atcoder.jp/contests/abc068/tasks/abc068_b
# Python 1st Try


def solver(givenNum):

    answer = 1
    counter = 0
    rangeNum = range(0, givenNum)
    eachCount = [0] * givenNum
    for j in rangeNum:
        oneCount = 0
        nowNumber = j + 1
        while True:
            if nowNumber % 2 == 0:
                oneCount = oneCount + 1
                nowNumber = nowNumber / 2
            else:
                break
        eachCount[j] = oneCount
#    print(eachCount)
    for j in rangeNum:
        if counter <= eachCount[j]:
            counter = eachCount[j]
            answer = j + 1
    return answer


if __name__ == "__main__":
    print(solver(int(input())))


Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int a = in.nextInt(), b = in.nextInt(),
            c = in.nextInt(), d = in.nextInt();
        
        if((c > b && d > b) || (a > d && b > d)){
            System.out.println(0);
            return;
        }
        int ans = 0;
        if(a > c){
            ans = d - a - Math.max(0, d - b);
        }else{
            ans = b - c - Math.max(0, b - d);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24148
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>
#include <random>
#include <string>
#include<vector>
 
using namespace std;
 
int main(){
	float n;
	float pi = 3.1415926;
	float ans;
	string str;
 
	cin >> n;
 
	ans = n * 2 * pi;
 
	cout << ans;
 
	return 0;
}

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

namespace ARC080
{
    class A
    {
        static void Main(string[] args)
        {

            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = input[0];
            int W = input[1];

            int N = int.Parse(Console.ReadLine());

            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int count = H * W;
            int[,] HW = new int[H, W];

            int index = 1;
            int j = 0;
            for (int i = 0; i < H; i++)
            {
                if (i % 2 == 0)
                {
                    j = 0;
                    while (j < W)
                    {
                        //Console.WriteLine(a[index]);
                        HW[i, j] = index;
                        a[index - 1]--;
                        if (a[index - 1] == 0) index++;
                        j++;
                    }
                }
                else
                {
                    j = W - 1;
                    while (0 <= j)
                    {
                        HW[i, j] = index;
                        a[index - 1]--;
                        if (a[index - 1] == 0) index++;
                        j--;
                    }
                }
            }

            for (int i = 0; i < H; i++)
            {
                for (int k = 0; k < W; k++)
                {
                    Console.Write(HW[i, k]);
                    Console.Write(" ");

                }
                Console.WriteLine();
            }
        }
    }
}


Measured memory_bytes: 13408
#include <iostream>
using namespace std;
int main(){
  int N,T;
  int c,t, min_cost = 10000;
  cin >> N >> T;
  for(int i = 0; i < N; i++){
    cin >> c >> t;
    if(t <= T && c < min_cost) min_cost = c;
  }
  if(min_cost > 1000) cout << "TLE" << endl;
  else cout << min_cost << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"regexp"
)

func main() {
	var s string
	fmt.Scan(&s)
	
	r := regexp.MustCompile(`^A?KIHA?BA?RA?$`)
	
	if r.MatchString(s) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
	
}

Measured memory_bytes: 640
import sys

sys.setrecursionlimit(100000)

n=int(input())

ans={}
inp_list=[]
G=[0 for i in range(n+1)]
T=[[] for i in range(n+1)]
for i in range(n-1):
    #print(G)
    a,b=map(int,input().split())
    inp_list.append((a,b))
    T[a].append(b)
    T[b].append(a)

L=[len(ppp) for ppp in T]
mod=max(L)

def addd(x,mod):
    x+=1
    if x==mod+1:
        x=1
    return x

def tansa(now,color):
    #print(T)
    now_col=color
    for i in T[now]:
        if G[i]==0:
            if now_col==color:
                now_col=addd(now_col,mod)
            G[i]==now_col
            ans[(now,i)]=now_col
            T[i].remove(now)
            tansa(i,now_col)
            now_col=addd(now_col,mod)


tansa(1,0)

print(mod)

for i in range(n-1):
    print(ans[inp_list[i]])

Measured memory_bytes: 77668
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	int n;
	int k;
	char d[9]={};
	cin >> n>>k;
	rep(i,k){
		cin >> d[i];
	}
	int ans;
	bool flag = 0;
	FOR(i,n,88889){
		flag = 0;
		//かぶるものがあればloopにとどまるcontinue;
		//なければbreakできる！
		string s = to_string(i);
		int len = s.size();
		rep(j,len){
			rep(m,k){
			if (s[j] == d[m]){
				flag = 1;
				break;
			}
			}
			if (flag){
				break;
			}
		}
		if (flag) continue;
		else {
			ans = i;
			break;
		}
	}
				
	cout << ans << endl;
	return 0;
}


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

int main(void){
    int h1 ,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int h3=0;
    int ans1 = h1 * 60 + m1;
    int ans2 = h2 * 60 + m2;
    int ans = 0; 
    if(ans1 < ans2){
        ans = ans2 - ans1;
    }else{
        ans = ans1 - ans2;
    }
    // if(h2 - h1 > 0){
    //     h3 = h2 - h1;
    // }else{
    //     h3 = h1 - h2;
    // }
    // int m3; 
    // if(m1 >= m2){
    //     m3 = m1 - m2;
    // }else{    //10 30 12 10 2h 
    //     m3 = m2 - m1;
    // }

    // int ans = h3*60 + m3;
    // ans = ans -k;
    // if (ans < 0){
    //     ans = 0;
    // }
    
    cout << ans-k << endl;
}

    

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int maxsec, minsec;
    if(a < c){
        maxsec = c;
    }else{
        maxsec = a;
    }

    if(b < d){
        minsec = b;
    }else{
        minsec = d;
    }

    cout << max(minsec - maxsec, 0) << endl;
}


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

int main()
{
  i64 N;
  cin >> N;
  vector<i64> a(N);
  for (i64 i = 0; i < N; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  if (a[N - 1] == 0)
    cout << "Yes" << endl;
  else if (N % 3 == 0)
  {
    if (a[0] == 0 && a[N / 3 - 1] == 0 && a[N / 3] == a[N - 1])
      cout << "Yes" << endl;
    else if (a[0] == a[N / 3 - 1] && a[N / 3] == a[2 * N / 3 - 1] && a[2 * N / 3] == a[N - 1] && (a[0] ^ a[N / 3] ^ a[2 * N / 3]) == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  else
    cout << "No" << endl;
  return 0;
}


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

int main(){
    string a, b;
    cin >> a >> b;
    for(int i = 0; i < (int)a.size(); i++)
    {
        if(i == b.size()) cout << a[i];
        else cout << a[i] << b[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<'='<<x<<' '
#define f first
#define s second
typedef long long ll;
typedef pair<int,int> pi;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int N,X; cin >> N >> X;
	if (N*500 >= X) cout << "Yes";
	else cout << "No";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.nextLine();
		long n = scanner.nextLong();

		if (n <= s.length()) {
			for (int i = 0; i < n; i++) {
				if (s.charAt(i) == '1') {
					continue;
				} else {
					System.out.println(s.charAt(i));
					return;
				}
			}

			System.out.println(1);
			return;
		}
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '1') {
				continue;
			} else {
				System.out.println(s.charAt(i));
				return;
			}
		}

		System.out.println(1);
	}
}


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

using namespace std;

const int N=2e5+5,OO=0x3f3f3f3f,M=1e9+7;
int t,n,m,k;
string s;
vector<char>v;

int main() {
    cin>>s;
    for(int i=0;s[i];++i){
        if(s[i]=='0')
            v.push_back(s[i]);
        else if(s[i]=='1')
            v.push_back(s[i]);
        else if(v.size())
            v.pop_back();
    }
    for(int i=0;i<v.size();++i)
        cout<<v[i];
    return 0;
}


Measured memory_bytes: 256