akhauriyash/Code-Regression huggingface dataset:
import java.io.File;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		//task b battle
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(); int b =sc.nextInt(); int c = sc.nextInt(); int d = sc.nextInt();
		boolean turn = true;
		while(a>0&&c>0){
			if(turn){
				c-=b;
			}else{
				a-=d;
			}
			turn= !turn;
		}
		System.out.println(a>0?"Yes":"No");

	}
}


Measured memory_bytes: 35768
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const px = lines.filter((v,i)=>i>0).map(v=>v+"\n"+v).join("\n");
    console.log(px);
});


Measured memory_bytes: 30784
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
 
using namespace std;
 
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;
 
const int MAX_N = 10005;
 
vector<int> G[MAX_N];
int kind[MAX_N];
bool used[MAX_N][MAX_N];
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int t[3];
    cin >> n >> t[0] >> t[1] >> t[2];
    int mn[3];
    vi vec[3];
    rep(i,3){
        vec[i].resize(t[i]);
    }
    rep(i,n){
        kind[i] = -1;
    }
    rep(i,3){
        mn[i] = INF;
        rep(j,t[i]){
            cin >> vec[i][j];
            vec[i][j]--;
            kind[vec[i][j]] = i;
            cmn(mn[i],vec[i][j]);
        }
    }
    int m;
    cin >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a,--b;
        if(kind[a] >= 0){
            a = mn[kind[a]];
        }
        if(kind[b] >= 0){
            b = mn[kind[b]];
        }
        if(a == b){
            continue;
        }else if(a > b){
            swap(a, b);
        }
        if(!used[a][b]){
            G[a].pb(b),G[b].pb(a);
            used[a][b] = true;
        }
    }
    vp d[3];
    rep(i,3){
        queue<int> que;
        d[i].resize(n,P(INF/10,INF/10));
        d[i][mn[i]] = P(0,mn[i]);
        que.push(mn[i]);
        while(!que.empty()){
            int p = que.front();
            que.pop();
            each(v,G[p]){
                if(d[i][p].fi+1 < d[i][v].fi){
                    d[i][v] = P(d[i][p].fi+1,min(d[i][p].se,v));
                    que.push(v);
                }else if(d[i][p].fi+1 == d[i][v].fi && d[i][v].se > d[i][p].se){
                    d[i][v].se = d[i][p].se;
                    que.push(v);
                }
            }
        }
    }
    P ans = P(INF,INF);
    rep(i,n){
        cmn(ans,P(d[0][i].fi+d[1][i].fi+d[2][i].fi,min({d[0][i].se,d[1][i].se,d[2][i].se})));
    }
    cout << ans.fi << " " << ans.se+1 << "\n";
    return 0;
}


Measured memory_bytes: 85144
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  bool bad[(int)1e5+3] = {};
  int n,m;cin>>n>>m;
  int H[(int)1e5+3] = {};
  rep(i,n){
    cin >> H[i];
  }

  rep(i,m){
    int a,b;cin>>a>>b;a--;b--;
    if(H[a] <= H[b]){
      bad[a] = true;
    }
    if(H[a] >= H[b]){
      bad[b] = true;
    }
  }
  int ans = 0;
  rep(i,n){
    if(!bad[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

# define ll long long

int fpb(int a, int b){
  return (b == 0 ? a : fpb(b, a%b));
}

int main(){
 
  int n, k;
  cin >> n >> k;
  int f = 0, largest = 0;
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    largest = max(largest, num);
    f = fpb(f, num);
  }  
  
  if (k <= largest && k % f == 0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
} 



Measured memory_bytes: 3644
let input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");
const NM = input.shift().split(' ').map(item => parseInt(item))
const N = NM[0]
const M = NM[1]
const H = input.shift().split(' ').map(item => parseInt(item))
input.pop() // lastが邪魔
const A = input.map(item => item.split(' ').map(value => parseInt(value)))
let goodPlaceList = new Array(N).fill(true)

// console.log('H: ', H)
// console.log('A: ', A)

for (i = 0; i < M; i++) {
    // console.log(i)
    // console.log(H[A[i][0]-1], H[A[i][1]-1])
    if (H[A[i][0]-1] <= H[A[i][1]-1]) {
        goodPlaceList[A[i][0]-1] = false
    }
    if (H[A[i][1]-1] <= H[A[i][0]-1]) {
        goodPlaceList[A[i][1]-1] = false
    }
}
console.log(goodPlaceList.filter((isGood => isGood == true)).length)


Measured memory_bytes: 69196
N, M = map(int, input().split())

ans = [-1] * N
if N == 1 and M == 0:
    print(0)
    exit(0)
for _ in range(M):
    sn, cn = map(int, input().split())
    if ans[sn - 1] != -1 and ans[sn - 1] != cn:
        print(-1)
        exit(0)
    if sn == 1 and cn == 0 and N > 1:
        print(-1)
        exit(0)
    ans[sn - 1] = cn
if ans[0] == -1:
    ans[0] = 1
ans = list(map(lambda x: str(0) if x == -1 else str(x), ans))
print("".join(ans))


Measured memory_bytes: 3064
DIV = 1_000_000_007
n = gets.to_i
l = n.times.map{ gets.chomp }
l.delete('-')
s = l.size
u = l.count('U')
dp = (s+1).times.map{ [0]*(s+1) }
dp[0][0] = 1
case_u = 0
case_d = 0
for i in (0...s)
  case_d += 1 if l[i] == 'U'
  for j in (0..i+1)
    dp[i+1][j] = dp[i][j-1]*(case_u - (j-1)) if j > 0 
    dp[i+1][j] += dp[i][j]*(case_d - j)
    dp[i+1][j] %= DIV
  end
  case_u += 1 if l[i] == 'U'
end
p dp[s][u]

Measured memory_bytes: 9024
N = int(input())

H = list(map(int, input().split())) + [0, 0]

dp = [10**10] * (N+3)
dp[0] = 0

for i in range(N):
  dp[i+1] = min(dp[i+1], dp[i] + abs(H[i]-H[i+1]))
  dp[i+2] = min(dp[i+2], dp[i] + abs(H[i]-H[i+2]))
 

print(dp[N-1])

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int sum = 0;
  rep(i, 3) {
    int a; std::cin >> a;
    sum += a;
  }
   std::cout << (sum < 22 ? "win" : "bust") << "\n";
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int N;
	std::cin >> N;
	N %= 10;
	if (N == 3) {
		std::cout << "bon";
	}
	else {
		if (N == 0|| N == 1|| N == 6|| N == 8) {
			std::cout << "pon";
		}
		else {
			std::cout << "hon";
		}
	}
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <map>

int main()
{
	std::map<std::string, int> count_map;
	std::string str{};
	int max_length = 0;
	std::string max_str{};
	while (std::cin >> str)
	{
		if (count_map.count(str) == 0)
		{
			count_map[str] = 1;
		}
		else
		{
			count_map[str]++;
		}
		if (max_length < str.length())
		{
			max_length = str.length();
			max_str = str;
		}
	}

	int max_count = 0;
	std::string max_string{};
	for (auto counter : count_map)
	{
		if (max_count < counter.second)
		{
			max_count = counter.second;
			max_string = counter.first;
		}
	}

	std::cout << max_string << " " << max_str << std::endl;
	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){

	while(1){
		int data[7]={22,60,6,38,24,42,20},a=0,b=0,sum=0;
		char x;
		rer(i,1,8){
			rer(j,1,8){
				cin>>x;
				if(cin.eof()) return 0;
				if(x=='1'){
					if(a==0 && b==0){
						a=i; b=j;
					}else{
						sum+=10*(i-a)+j-b;
					}
				}
				//o(sum);
			}
		}
		rep(i,0,7){
			if(sum==data[i]){
				char c;
				c='A'+i;
				o(c); break;
			}
		}
	}
}

Measured memory_bytes: 1132
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	if(nn % 2 == 0)
	{
		cout << "0.500000000000000000000" << endl;
	}
	else
	{
		long double ans = (nn / 2 + 1) / (long double)nn;
		cout << fixed << setprecision(15) << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3736
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main pc = new Main();
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		Map<Integer,List<City>> map = new HashMap<>();
		for(int i=0;i<m;i++) {
			int p = in.nextInt();
			int y = in.nextInt();
			if(map.containsKey(p)) {
				map.get(p).add(pc.new City(p,y,i));
			}else {
				List<City> list = new ArrayList<>();
				list.add(pc.new City(p,y,i));
				map.put(p, list);
			}
		}
		
		List<City> allCities = new ArrayList<>();
		
		for(int p : map.keySet()) {
			List<City> list = map.get(p);
			list.sort((c1,c2)->c1.year-c2.year);
			for(int i=0;i<list.size();i++) {
				City city = list.get(i);
				city.cityNumber = get6digit(p) + get6digit(i+1);
				allCities.add(city);
			}
		}
		
		allCities.sort((c1,c2)->c1.number-c2.number);
		
		for(City city : allCities) {
			System.out.println(city.cityNumber);
		}
		in.close();
		

	}
	
	public static String get6digit(int x) {
		String ret = "";
		for(int i=0;i<6;i++) {
			ret = x%10 + ret;
			x /= 10;
		}
		return ret;
		
	}
	
	class City {
		public int prefecture;
		public int year;
		public int number;
		public String cityNumber;
		
		public City(int p,int y,int num) {
			this.prefecture = p;
			this.year = y;
			this.number = num;
		}
	}

}




Measured memory_bytes: 117196
#include<bits/stdc++.h>
using namespace std;
int  main(){
	int k,x;//k=連続する個数　x=座標
	cin>> k>> x;
	
	int s=k-1;
	while(true){
		if(s<=0) break;
		cout<<x-s<<" ";
		s=s-1;
	}
	cout<< x <<" ";
	for(int i=1;i<k;i++){
		cout<<x+i;
		if(i!=k) cout<<" ";
		else cout <<endl;	
	}	
	return(0);
}

Measured memory_bytes: 256
from math import atan,pi

a, b, x = map(int, input().split())
if a**2*b < 2 * x:
    print(180 * atan(2 * (a ** 2 * b - x) / (a ** 3)) / pi)
else:
    print(180 * atan(a * b ** 2 / (2 * x)) / pi)


Measured memory_bytes: 3060
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}

fn main() {
    let hw = reads();
    let mut xs = vec![];
    let mut v = vec!['.'; hw[1] + 2];

    xs.push(v.clone());

    for _ in 0..hw[0] {
        let mut x: Vec<char> = get_line().chars().collect();
        x.push('.');

        let mut i  = vec!['.'; 1];
        i.append(&mut x);
        xs.push(i);
    }
    xs.push(v.clone());

    for i in 1..(hw[0] + 1) {
        for j in 1..(hw[1] + 1) {
            if xs[i][j] == '.' {
                let mut c = 0;

                let r = vec![-1, 0, 1];
                for &dx in &r {
                    for &dy in &r {
                        if xs[(i as i64 + dx) as usize][(j as i64 + dy) as usize] == '#' {
                            c += 1;
                        }
                    }
                }

                print!("{}", c);
            }
            else {
                print!("#");
            }
        }
        println!("");
    }

}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d,e,x,y,i,j,p,ans1=0,ans2=0;
    cin>>a>>b>>c>>d>>e;
    if(a<=0){
    x=0-a;
    for(i=1;i<=x;i++){
        ans1=ans1+c;
            }
            ans1=ans1+d;
            for(j=1;j<=b;j++){
                ans1=ans1+e;
            }
            cout<<ans1<<endl;
    }
    else if(a>0){
        x=b-a;
        for(p=0;p<x;p++){
            ans2=ans2+e;
        }
        cout<<ans2<<endl;
            }
    
return 0;
    
}


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

int main() {
  int n, m;
  int ans = 0;
  
  cin >> n;
  vector<string> blue(n);
  for (int i = 0; i < n; i++) {
    cin >> blue.at(i);
  }

  cin >> m;
  vector<string> red(m);
  for (int i = 0; i < m; i++) {
    cin >> red.at(i);
  }

  for (int i = 0; i < n-1; i++) {
      int num = 1;
      for(int j = i+1; j < n; j++) {
      if (blue.at(i) == blue.at(j)) num++;
      }

      for(int j = 0; j < m; j++) {
      if (blue.at(i) == red.at(j)) num--;
      }
      ans = max(ans, num);

  }
    cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  
  if(S == "SUN"){
    cout << 7 << endl;
  }else if(S == "MON"){
    cout << 6 << endl;
  }else if(S == "TUE"){
    cout << 5 << endl;
  }else if(S == "WED"){
    cout << 4 << endl;
  }else if(S == "THU"){
    cout << 3 << endl;
  }else if(S == "FRI"){
    cout << 2 << endl;
  }else if(S == "SAT"){
    cout << 1 << endl;
  }
}


Measured memory_bytes: 3584
N, A, B = gets.chomp.split(" ").map(&:to_i)
X = gets.chomp.split(" ").map(&:to_i)

ans = 0
(1...N).each{|i|
  wk = (X[i] - X[i-1]) * A
  ans += (wk < B ? wk : B)
}

puts ans


Measured memory_bytes: 9476
import std.stdio,std.string;

int main(){
    auto input=readln.chomp;
    char[] s=input.dup;
    foreach(ss;s[1..3]){
        if(ss!=s[0]){
            writeln("Yes");
            return 0;
        }
    }   
    "No".writeln;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const ll INF = 1e+15;

ll dist1[305][305];
ll dist2[305][305];

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

    int n, m, l;
    cin >> n >> m >> l;
    fill((ll*)dist1, (ll*)(dist1 + n), INF);
    fill((ll*)dist2, (ll*)(dist2 + n), INF);
    for(int i = 0; i < n; ++i){
        dist1[i][i] = dist2[i][i] = 0;
    }
    for(int i = 0; i < m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        dist1[a][b] = c;
        dist1[b][a] = c;
    }

    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                dist1[i][j] = min(dist1[i][j], dist1[i][k] + dist1[k][j]);
            }
        }
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(dist1[i][j] <= l){
                dist2[i][j] = 1;
                dist2[j][i] = 1;
            }
        }
    }
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
            }
        }
    }

    int q;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int s, t;
        cin >> s >> t;
        --s, --t;
        if(dist2[s][t] == INF)  dist2[s][t] = 0;
        cout << --dist2[s][t] << "\n";
    }
}

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n; cin >> n;
  vector<ll> ecasdqina(n);
  ll oddsum = 0, evensum = 0;
  ll mx = - 1e10; int mi;
  for(int i = 0; i < n; i++) {
    cin >> ecasdqina[i];
    if(mx < ecasdqina[i]) {
      mx = ecasdqina[i];
      mi = i;
    }
    if(ecasdqina[i] < 0) continue;
    if(i % 2) oddsum += ecasdqina[i];
    else evensum += ecasdqina[i];
  }

  if(mx < 0) {
    cout << mx << endl;
    ecasdqina[mi] = 100;
    oddsum = evensum = -1;
    if(mi % 2) oddsum = 100; else evensum = 100;
  } else {
    cout << max(evensum, oddsum) << endl;
  }

  vector<int> ans;

  // x o x o x ...
  if(oddsum > evensum) {
    ans.emplace_back(0);
    ecasdqina.erase(begin(ecasdqina));
    n--;
  }

  // o x o x o x o x _ x _ x o
  int c = 0;
  for(int i = 0; i < n; i += 2) {
    int j = i;
    if(ecasdqina[i] < 0) {
      while(j + 2 < n && ecasdqina[j + 2] < 0) j += 2;
      int v = (j - i + 1) + 2;
      v = (v - 1) / 2;
      int noel = i - c * 2;
      for(int k = 0; k < v; k++) {
        ans.emplace_back(noel);
        int taplis = n - c * 2 - 1;
        if(taplis != 0) {
          if(noel == 0) ans.emplace_back(noel);
          else if(noel == taplis) ans.emplace_back(noel - 1);
        }
        c++;
      }
      // c += (j - i + 2) / 2;
      // cerr << "v = " << v << " , c = " << c << endl;
      i = j;
    }
  }
  n = n - c * 2;
  n = n / 2;
  for(int i = 0; i < n; i++) ans.emplace_back(1);

  cout << ans.size() << endl;
  for(int el : ans) cout << el + 1 << endl;
}


Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e6+10;
const long long Mod=924844033;
const long long G=5;

int head[maxm],tot,N;
int Father[maxm],Size[maxm],Limit=1,l;
long long Inv1[maxm],Inv2[maxm],Fac[maxm],r[maxm];
long long Cnt[maxm],A[maxm<<2],B[maxm<<2];

struct edge{
	int To;
	int Next;
	# define To(x) Edge[x].To
	# define Next(x) Edge[x].Next
}Edge[maxm<<1];

inline void Add_Edge(int From,int To){Edge[++tot]=(edge){To,head[From]},head[From]=tot;return;}
inline void Insert_Edge(int x,int y){Add_Edge(x,y),Add_Edge(y,x);return;}

void Dfs(int now){
	Size[now]=1;
	for(int i=head[now];i;i=Next(i)){
		if(To(i)==Father[now]) continue;
		Father[To(i)]=now;
		Dfs(To(i));
		Size[now]+=Size[To(i)];
		Cnt[Size[To(i)]]--;
	}
	Cnt[N-Size[now]]--;
	return;
}

inline long long power(long long x,long long y){
	long long Ans=1;
	while(y){
		if(y&1) Ans=Ans*x%Mod;
		x=x*x%Mod;
		y>>=1;
	}
	return Ans;
}

void NTT(long long *A,int n,int type){
	register int i,j,k,mid,R;
	register long long Wn,W,x,y;
	for(i=0;i<n;i++) if(i<r[i]) swap(A[i],A[r[i]]);
	for(mid=1;mid<n;mid<<=1){
		Wn=power(G,(Mod-1)/(mid<<1));
		if(type==-1) Wn=power(Wn,Mod-2);
		for(R=mid<<1,j=0;j<n;j+=R){
			W=1;
			for(k=0;k<mid;k++,W=W*Wn%Mod){
				x=A[j+k],y=W*A[j+mid+k]%Mod;
				A[j+k]=(x+y)%Mod;
				A[j+k+mid]=(x-y+Mod)%Mod;
			}
		}
	}
	if(type==-1){
		int Inv=power(n,Mod-2);
		for(i=0;i<=n;i++) A[i]=A[i]*Inv%Mod;
	}
	return;
}

inline void Mul(long long *A,long long *B,int N){
	NTT(A,N,1);NTT(B,N,1);
	for(register int i=0;i<=N;i++) A[i]=A[i]*B[i]%Mod;
	NTT(A,N,-1);
	return;
}

int main(){
	register int i;
	register long long Now;
	int x,y;
	scanf("%d",&N);
	Inv1[1]=Inv2[1]=Fac[1]=Inv1[0]=Inv2[0]=Fac[0]=1;
	for(i=2;i<=N;i++){
		scanf("%d%d",&x,&y);
		Insert_Edge(x,y);
		Fac[i]=Fac[i-1]*i%Mod;
		Inv1[i]=(Mod-Mod/i)*Inv1[Mod%i]%Mod;
		Inv2[i]=Inv1[i]*Inv2[i-1]%Mod;
	}
	Dfs(1);
	for(i=1;i<=N;i++){
        Cnt[i]=(Mod+Cnt[i])%Mod;
        A[i]=Cnt[i]*Fac[i]%Mod;
        B[i]=Inv2[N-i];
	}
	A[N]=Fac[N]*N%Mod;
	while(Limit<=(N<<1)) Limit<<=1,l++;
	for(i=0;i<Limit;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
	Mul(A,B,Limit);
	for(i=1;i<=N;i++){
		Now=A[N+i]*Inv2[i]%Mod;
		Now=(Now+Mod)%Mod;
		printf("%lld\n",A[N+i]*Inv2[i]%Mod);
	}
	return 0;
}

Measured memory_bytes: 50432
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<stdio.h>
#include<numeric>

using namespace std;

int main(){
    int A, B, ans;
    cin >> A >> B;
    if (A > B)
        ans = A * 2 - 1;
    else if (A == B)
        ans = A * 2;
    else
        ans = B * 2 - 1;
    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int Q = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) {
      nodes[i] = new Node();
    }
    for (int i = 0; i < N - 1; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      nodes[a].adjacent.add(nodes[b]);
      nodes[b].adjacent.add(nodes[a]);
    }
    for (int i = 0; i < Q; i++) {
      int p = scanner.nextInt() - 1;
      int x = scanner.nextInt();
      nodes[p].counter += x;
    }
    dfs(nodes[0], null);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < N; i++) {
      sb.append(nodes[i].counter).append(' ');
    }
    sb.setLength(sb.length() - 1);
    System.out.println(sb.toString());
  }

  private static void dfs(Node node, Node from) {
    if (from != null) node.counter += from.counter;
    for (Node a : node.adjacent) {
      if (a != from) {
        dfs(a, node);
      }
    }
  }

  private static class Node {
    List<Node> adjacent = new ArrayList<>();
    long counter = 0;
  }
}


Measured memory_bytes: 203892
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    long g, p;
    long ans;
    foreach (c; S)
    {
        if (c == 'p')
        {
            if (p < g)
            {
                p++;
            }
            else
            {
                g++;
                ans--;
            }
        }
        else if (c == 'g')
        {
            if (p < g)
            {
                p++;
                ans++;
            }
            else
            {
                g++;
            }
        }
    }
    writeln(ans);
}


Measured memory_bytes: 508
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;
int main() {
    int n;
    cin >> n;

    vector<int> inp(n);
    ll sum = 0;
    rep(i, 0, n) {
        cin >> inp[i];
        sum += inp[i];
    }

    ll ans = 100010001000;
    ll x   = 0;
    rep(i, 0, n - 1) {
        x += inp[i];
        ans = min(ans, abs(sum - 2 * x));
    }

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


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

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for (auto p: mp) {
        int d = p.second - p.first;
        if (d >= 0) {
            ans += d;
        } else {
            ans += p.second;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <complex>

#define all(n) n.begin(),b.end()
#define INF (1<<10)

using namespace std;

struct P : public complex<int> {
    P(){}
    P(int x, int y) : complex<int>(x,y) {}
    static bool comp_x(const P&a, const P& b){
        if(a.real() != b.real())
            return a.real() < b.real();
        else return a.imag() < b.imag();
    }
    static bool comp_y(const P&a, const P& b){
        if(a.imag() != b.imag())
            return a.imag() < b.imag();
        else return a.real() < b.real();
    }
};

typedef vector<P> VP;
int n;

pair<P,P> closest_pair(vector<P>::iterator begin, vector<P>::iterator end){
    int len = end - begin;
    if(len <= 1) return make_pair(P(), P(INF,INF));
    auto mid = begin + len / 2;
    int x = mid->real();
    auto L = closest_pair(begin, mid), R = closest_pair(mid, end);
    int dL = norm(L.first - L.second), dR = norm(R.first - R.second);
    pair<P,P> res = dL < dR ? L : R;

    int range = norm(res.first - res.second);
    inplace_merge(begin, mid, end, P::comp_y);
    VP b;
    for(int i = 0; i < len; i++){
        if(abs(begin[i].real() - x) >= range) continue;
        for(int j = b.size() - 1; j >= 0; j--) {
            int dx = begin[i].real() - b[j].real();
            int dy = begin[i].imag() - b[j].imag();
            if(dy >= range)
                break;
            if(dx*dx + dy*dy < range){
                range = dx*dx + dy*dy;
                res = make_pair(begin[i], b[j]);
            }
            range = min(range, dx*dx + dy*dy);
        }
        b.push_back(begin[i]);
    }
    return res;
}

int main(){
    cin >> n;
    vector<P> a(n);
    for(int i = 0; i < n; i++){
        int x,y;
        cin >> x >> y;
        a[i] = P(x,y);
    }
    sort(a.begin(), a.end(), P::comp_x);
    auto ans = closest_pair(a.begin(), a.end());
    cout << norm(ans.first - ans.second) << endl;
    return 0;
}

Measured memory_bytes: 10704
import java.util.*;
public class Main {
    public static void main(String[] args) {
    Scanner kbd = new Scanner(System.in);
 
    while(kbd.hasNext()){
        int x = kbd.nextInt();
        int y = kbd.nextInt();
     
        if(x==0 && y==0){
        ;
        }
        else{
        if(x<y){
            System.out.println(x+" "+y);
        }
        else{
            System.out.println(y+" "+x);
        }
        }
    }
    }
}

Measured memory_bytes: 26396
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;

int main() {
	int N, K, T, U, V, L;
	vector<int> D;
	cin >> N >> K >> T >> U >> V >> L;
	D.resize(N);
	for(int i = 0; i < N; i++)
		cin >> D[i];
	sort(D.begin(), D.end());
	double res = 0;
	int x = 0;
	int g = 0;
	int i = 0;
	while(x < L) {
		if(g) {
			g--;
			int x_ = x;
			x += T * V;
			for(; i < D.size() && D[i] < x; i++) {
				g++;
				if(g > K) {
					g = K;
					x = D[i] + T * V;
				}
			}
			res += (double)(min(x,L) - x_) / V;
		}
		else {
			if(i < D.size()) {
				res += (D[i] - x) / (double)U;
				x = D[i];
				g++; i++;
			}
			else {
				res += (L - x) / (double)U;
				x = L;
			}
		}
	}
	printf("%.10f\n", res);
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
vector<int> parent;
vector<vector<int>> G;
vector<int> cnt;
int n, q;
void dfs(int v, int prev) {
    if (prev != -1) cnt[v] += cnt[prev];
    for (auto nxt: G[v]) {
        if (nxt == prev) continue;
        dfs(nxt, v);
    }
}
int main() {
    cin >> n >> q;
    parent.assign(n, -1);
    G.assign(n, vector<int>());
    cnt.assign(n, 0);
    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        cnt[p-1] += x;
    }
    dfs(0, -1);
    for (int i = 0; i < n; i++) {
        cout << cnt[i];
        if (i < n-1) cout << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 25108
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn dist(cur: (i64, i64), next: (i64, i64)) -> i64 {
    (cur.0 - next.0).abs() + (cur.1 - next.1).abs()
}

fn main() {
    let n = read::<usize>();
    let mut cur = (0i64, 0i64);
    let mut cur_t = 0i64;

    for i in 0..n {
        let v = read_vec::<i64>();
        let next_t = v[0];
        let next = (v[1], v[2]);

        if dist(cur, next) % 2 != (next_t - cur_t) % 2 || dist(cur, next) > (next_t - cur_t) {
            println!("No");
            return;
        }

        cur_t = next_t;
        cur = next;
    }
    println!("Yes");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

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

  int ws[n];
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> ws[i];
    sum += ws[i];
  }
  
  int sum2 = 0;
  int min_diff;
  for (int i = 0; i < n; i++) {
    sum2 += ws[i];
    if (i == 0) {
      min_diff = abs(sum - 2 * sum2);
    } else {
      min_diff = min(min_diff, abs(sum - 2 * sum2));
    }
  }
    
  cout << min_diff << endl;
  
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] ans = new int[n];

    // 部下の人数を数える
    for(int i=0; i<n-1; ++i) {
      ans[sc.nextInt()-1]++;
    }

    // 出力
    for(int p : ans) {
      System.out.println(p);
    }
  }
}

Measured memory_bytes: 60476
#include<iostream>
#include<queue>
using namespace std;
int a[1000][1000];
int dx[]={1,0,-1,-1,0,1},dy[]={0,-1,-1,0,1,1};
main()
{
	int n,t;
	while(cin>>t>>n,t)
	{
		for(int i=0;i<1000;i++)for(int j=0;j<1000;j++)a[i][j]=0;
		for(int i=0;i<n;i++)
		{
			int x,y;cin>>x>>y;a[x+500][y+500]=-1;
		}
		int x,y;cin>>x>>y;
		queue<pair<pair<int,int>,int> >P;
		P.push(make_pair(make_pair(x+500,y+500),t));
		a[x+500][y+500]=1;
		while(!P.empty())
		{
			int x=P.front().first.first,y=P.front().first.second,T=P.front().second;
			P.pop();
			if(T<=0)continue;
			for(int r=0;r<6;r++)
			{
				int tx=x+dx[r],ty=y+dy[r];
				if(a[tx][ty]==0)
				{
					a[tx][ty]=1;
					P.push(make_pair(make_pair(tx,ty),T-1));
				}
			}
		}
		int cnt=0;
		for(int i=0;i<1000;i++)for(int j=0;j<1000;j++)cnt+=a[i][j]==1;
		cout<<cnt<<endl;
	}
}



Measured memory_bytes: 6968
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    int even, odd;
    even = (n*(n-1))/2;
    odd = (m*(m-1))/2;
    printf("%d\n", odd+even);

    return 0;
}


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

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

  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];

  int answer = 0;
  int tmp_answer = 0;

  for (int i = 0; i < N; i++) {
    if (i == N - 1) {
      answer = max(answer, tmp_answer);
      break;
    }

    if (H[i] >= H[i + 1]) {
      tmp_answer++;
    } else {
      answer = max(answer, tmp_answer);
      tmp_answer = 0;
    }
  }

  cout << answer << endl;
}

Measured memory_bytes: 640
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int a,b,c;
    int g=0;
    cin>>a>>b>>c;
    if(a==b)g++;
    if(a==c)g++;
    if(b==c)g++;
    if(g==1)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_traits::Pow;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use superslice::*;

pub 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")
}

//abc166-E
// #[fastout]
fn main() {
    input![n: usize, a: [i64; n]];

    let mut l = HashMap::new();
    let mut r = HashMap::new();

    for i in 0..n {
        let la = a[i] + (i + 1) as i64;
        if let Some(v) = l.get_mut(&la) {
            *v += 1;
        } else {
            l.insert(la, 1 as u64);
        }

        let ra = (i + 1) as i64 - a[i];
        if let Some(v) = r.get_mut(&ra) {
            *v += 1;
        } else {
            r.insert(ra, 1 as u64);
        }
    }

    let mut ans = 0;
    for (la, num) in l.iter() {
        if let Some(num_r) = r.get(la) {
            ans += num * num_r;
        } else {
        }
    }

    println!("{}", ans);
    eprintln!("{}", log10(std::u64::MAX as f64));
}

// use lazy_static::lazy_static;
// use std::sync::Mutex;

// lazy_static! {
//     static ref VALUES: Mutex<Vec<i32>> = Mutex::default();
// }

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);

// -100000000
//  1000000000


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

bool dp[50][50];
vector<int> sche[31];

int main(){
	int n;
	while(cin >> n && n != 0){
		for(int i = 0; i < 50; i++){
			for(int j = 0; j < 50; j++){
					dp[i][j] = false;
			}
		}
		for(int i = 0; i < n ; i++){
			int m;
			cin >> m;
			dp[i][i] = true;
			for(int j = 0; j < m; j++){
				int d;
				cin >> d;
				sche[d].push_back(i);
			}
		}
		int i = 1;
		for(; i <= 30; i++){
			bool sch[50];
			fill(sch, sch + 50, false);
			for(vector<int>::iterator iter = sche[i].begin();
				iter != sche[i].end(); iter++)
			{
				for(int j = 0; j < n; j++){
					if(dp[*iter][j]){
						sch[j] = dp[*iter][j];
					}
				}
			}
			for(vector<int>::iterator iter = sche[i].begin();
				iter != sche[i].end(); iter++)
			{
				for(int j = 0; j < n; j++){
					if(sch[j]) dp[*iter][j] = sch[j];
				}
			}
			int count = 0;
			for(int j = 0; j < n; j++){
				if(sch[j]) count++;
			}
			if(count == n) break;
		}
		if(i == 31) cout << -1 << endl;
		else cout << i << endl;
		for(int i = 0; i <= 30; i++){
			sche[i].clear();
		}
	}
	return 0;
}

Measured memory_bytes: 920
s = input()
n = len(s) - 1
bit = 0
total = 0
while bit < (1 << n):
    siki = s[0]
    for i in range(n):
        if bit & 1 << i:
            siki += '+'
        siki += s[i + 1]
    total += eval(siki)
    bit += 1
print(total)

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

int main()
{
    int x, a, b, c;
    cin >> x; 
    a = x / 500;
    b = x % 500;
    c = b / 5;
    
    cout << a * 1000 + c * 5 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 1e6 + 5;
const int MAXN = 1e5 + 5;
const int M = 5e5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int arr[N];

class f
{
public:
	int l;
	int r;
	int idx;
	f(int a, int b, int c)
	{
		l = a;
		r = b;
		idx = c;
	}
};

void solve() 
{
	int w, s;
	cin >> w >> s;
	swap(s, w);
	if(w >= s)
	{
		cout << "unsafe";
	}
	else
	{
		cout << "safe" ;
	}
}

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

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}


Measured memory_bytes: 3664
void main() {
	if(readAs!(int[]).sum >= 22) writeln("bust");
	else writeln("win");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

ll count(ll x)
{
    int num = 0;
    while (x > 0)
    {
        x /= 10;
        num++;
    }
    return num;
}

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

    ll n, ans = LONG_LONG_MAX;
    cin >> n;
    for (ll i = 1; i <= sqrtl(n); i++)
    {
        if (n % i == 0)
        {
            ans = min(ans, count(n / i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
i1, i2, i3 = 0, 0, 0
m1, m2, m3, p = 0, 0, 0, 0
while i1 <= a:
  m1 = 500 * i1
  while i2 <= b:
    m2 = m1 + 100 * i2
    while i3 <= c:
      m3 = m2 + 50 * i3
      if m3 < x:
        i3 += 1
        continue
      elif m3 > x:
        break
      else:
        p += 1
        break
    i3 = 0
    i2 += 1
  i2 = 0
  i1 += 1
print(p)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int L[110]={};
	int X;

	cin >> N;
	cin >> X;
	for(int i=1;i<=N;i++)
		cin >> L[i];
	
	int ans=1;
	int D[110]={};
	D[1]=0;
	for(int i=2;i<=N+1;i++)
	{
		D[i]=D[i-1]+L[i-1];
		if(D[i]<=X)
			ans++;
	}

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



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

typedef long long int ll;

int main()
{
    string s, t;
    cin >> s >> t;
    for(ll i = 0;i < s.size();i++){
        if(s[i] != t[i]){
            cout << "No";

            return 0;
        }
    }

    cout << "Yes";
    
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <memory>

template<class T> class Dlist {
  public:
    void insert(T value) {
      #ifdef debug
        showAll();
      #endif
      auto new_node = std::make_shared<Node>(value, dummy_head, dummy_head->next);
      if (dummy_head->prev == nullptr) dummy_head->prev = new_node;
      if (dummy_head->next) dummy_head->next->prev = new_node;
      dummy_head->next = new_node;
    }
    void deleteFirst(void) {
      #ifdef debug
        showAll();
      #endif
      dummy_head->next = dummy_head->next->next;
      if (dummy_head->next) dummy_head->next->prev = dummy_head;
      else dummy_head->prev = nullptr;
    }
    void deleteLast(void) {
      #ifdef debug
        showAll();
      #endif
      dummy_head->prev = dummy_head->prev->prev;
      if (dummy_head->prev == dummy_head) dummy_head->next = nullptr;
      else dummy_head->prev->next = nullptr;
    }
    void delete_(T target) {
      #ifdef debug
        showAll();
      #endif
      auto cur = dummy_head->next;
      while (cur) {
        if (cur->value == target) {
          cur->prev->next = cur->next;
          if (dummy_head->prev == cur) dummy_head->prev = cur->prev;
          if (cur->next) cur->next->prev = cur->prev;
          break;
        }
        cur = cur->next;
      }
    }
    void showAll(void) {
      auto cur = dummy_head->next;
      while (cur) {
        std::cout << cur->value;
        if (cur->next) std::cout << " ";
        cur = cur->next;
      }
      std::cout << std::endl;
    }
  private:
    struct Node {
      Node(int val, std::shared_ptr<Node> prev, std::shared_ptr<Node> next) : value(val), prev(prev), next(next) {}
      T value;
      std::shared_ptr<Node> prev;
      std::shared_ptr<Node> next;
    };
    std::shared_ptr<Node> dummy_head = std::make_shared<Node>(0, nullptr, nullptr);
};

int main() {
  Dlist<int> list;
  int n;
  std::cin >> n;
  
  std::string input;
  std::string op;
  int num;
  
  for (auto i=0; i<n; ++i) {
    std::cin >> op;
    
    if (op == "deleteFirst") {
      list.deleteFirst();
    } else if (op == "deleteLast") {
      list.deleteLast();
    } else {
      std::cin >> num;
      if (op == "insert") {
        list.insert(num);
      } else {
        list.delete_(num);
      }
    }
  }
  list.showAll();
}


Measured memory_bytes: 65616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] ch = sc.next().toCharArray();
		sc.close();

		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < ch.length;i++) {
			if(sb.length()==0&&ch[i]=='B') {
				continue;
			}else if(sb.length() > 0&&ch[i]=='B') {
				sb.deleteCharAt(sb.length()-1);
			}else {
				sb.append(ch[i]);
			}
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));

    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            int dist = 0;
            for(int k = 0; k < D; k++){
                int temp = X[i][k] - X[j][k];
                dist += temp * temp;
            }

            for(int k = 0; k <= 1000; k++){
                if(k * k == dist){
                    ans++;
                    break;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int res=1<<30;
  int n,T;cin>>n>>T;
  while(n--){
    int c,t;cin>>c>>t;
    if(t<=T){
      res=min(res,c);
    }
  }
  if(res==1<<30)
    cout<<"TLE"<<endl;
  else
    cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256