akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, ar[N], t[N], ans = 1;
bool fl;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> t[i];
	t[n + 1] = 135781354;

	int ind = 0;
	for(int i = 1; i <= n; i++) {
		if(t[i] == t[i + 1])
			continue;
		else
			ar[++ind] = t[i];
	}
	n = ind;
	fl = ar[1] < ar[2];
	for(int i = 2; i <= n; i++) {
		if(fl) {
			if(ar[i - 1] > ar[i]) {
				ans++;
				fl = ar[i] < ar[i + 1];
			}
		}
		else {
			if(ar[i - 1] < ar[i]) {
				ans++;
				fl = ar[i] < ar[i + 1];
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 4736
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
grid = []
for _ in range(3):
    array = list(map(int, input().strip().split()))
    grid.append(array)

def judge():
    for i in range(3):
        if grid[i][0] == 0 and grid[i][1] == 0 and grid[i][2] == 0:
            return True
        if grid[0][i] == 0 and grid[1][i] == 0 and grid[2][i] == 0:
            return True
    if grid[0][0] == 0 and grid[1][1] == 0 and grid[2][2] == 0:
        return True
    if grid[0][2] == 0 and grid[1][1] == 0 and grid[2][0] == 0:
        return True
    return False

n = int(input())
ans = "No"
for _ in range(n):
    b = int(input())
    for i in range(3):
        if b in grid[i]:
            grid[i][grid[i].index(b)] = 0
    if judge():
        ans = "Yes"
#    print (grid)

print (ans)

Measured memory_bytes: 3064
#include <stdio.h>

using namespace std;

int main(){
    int n;
    int a[212345];
    int b[212345];

    scanf("%d", &n);

    for(int i=1; i <= n; i++){
        scanf("%d", a + i);
    }

    int m = 0;
    for(int i=n; i >=1; i--){
        b[i] = a[i];
        for(int j=i*2; j <= n; j+=i){
            b[i] += b[j];
        }
        b[i] = b[i] % 2;
        if(b[i] == 1){
            m++;
        }
    }
    printf("%d\n", m);
    int spaced = false;
    for(int i=1; i <= n; i++){
        if(b[i] == 1){
            if(spaced==false){
                spaced=true;
            }else{
                printf(" ");
            }
            printf("%d", i);
        }
    }
    printf("\n");
    return 0;
}

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

int main(){
    int n; cin >> n;
    int a[n];
    int j = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int pre = a[0];
    for(int i = 1; i < n; i++){
        if(j == 0){
            if(pre < a[i]){
                j = 1;
            }else if(pre > a[i]){
                j = 2;
            }
        }else if(j == 1){
            if(pre == a[i]){
                j = 1;
            }else if(pre < a[i]){
                j = 1;
            }else if(pre > a[i]){
                j = 0;
                ans++;
            }
        }else if(j == 2){
            if(pre == a[i]){
                j = 2;
            }else if(pre < a[i]){
                j = 0;
                ans++;
            }else if(pre > a[i]){
                j = 2;
            }
        }
        pre = a[i];
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

ll dp[100001];
int s[200];
ll mod_inverse(ll x) {
	ll ret = 1; ll n = mod - 2;
	while (n) {
		if (n & 1)ret = ret * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return ret;
}
ll p[201];
void init() {
	p[0] = 1;
	rep1(i, 200) {
		p[i] = p[i - 1] * i%mod;
	}
}
void solve() {
	init();
	int n, x; cin >> n >> x;
	dp[x] = 1;
	rep(i, n) {
		cin >> s[i];
	}
	sort(s, s + n, greater<int>());
	rep(i, n) {
		ll pe = mod_inverse(n - i);
		ll els = pe * (n - i - 1) % mod;
		
		rep(j, 100001) {
			int nex = j % s[i];
			ll memo = dp[j]; dp[j] = 0;
			(dp[nex] += memo*pe%mod) %= mod;
			(dp[j] += memo * els%mod) %= mod;
		}
		/*rep(j, 100) {
			cout << j << " " << dp[j] * p[n] % mod << endl;
		}*/
	}
	ll ans = 0;
	rep(i, 100001) {
		/*if (i < 100) {
			cout << i << " " << dp[i]*p[n]%mod << endl;
		}*/
		ans += dp[i] * i;
		ans %= mod;
	}
	ans = ans * p[n] % mod;
	cout << ans << endl;
}
int main() {
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<vector<int>> adj;
vector<int> deg;
vector<bool> vis;
int ans = 0;

int dfs(int nd) {
    if (adj[nd].empty()) {
        deg[nd] = max(deg[nd], 1);
        return 1;
    }

    int ret = 0;
    for (auto e : adj[nd]) {
        if (!vis[e]) {
            vis[e] = 1;
            ret = max(ret, dfs(e));
        } else {
            ret = max(ret, deg[e]);
        }
    }
    deg[nd] = max(deg[nd], ret + 1);

    return deg[nd];
}

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

    adj.resize(n);
    deg.resize(n, 0);
    vis.resize(n, 0);

    int x, y;
    for (int i=0; i<m; ++i) {
        cin >> x >> y;
        x--, y--;
        adj[x].push_back(y);
    }

    for (int i=0; i<n; ++i) {
        if (!vis[i]) {
            vis[i] = 1;
            ans = max(ans, dfs(i));
        }
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 8832
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    seika s;
    int q;
    cin >> s >> q;
    deque<char> pre, lat;
    int cur = 0;
    while (q--)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            cur ^= 1;
            continue;
        }
        int f;
        char c;
        cin >> f >> c;
        if (f == 1)
        {
            if (cur)
            {
                lat.push_back(c);
            }
            else
            {
                pre.push_front(c);
            }
        }
        else
        {
            if (!cur)
            {
                lat.push_back(c);
            }
            else
            {
                pre.push_front(c);
            }
        }
    }
    seika ans;
    if (cur)
    {
        while (!lat.empty())
        {
            ans += lat.back();
            lat.pop_back();
        }
        reverse(s.begin(), s.end());
        ans += s;
        while (!pre.empty())
        {
            ans += pre.back();
            pre.pop_back();
        }
    }
    else
    {
        while (!pre.empty())
        {
            ans += pre.front();
            pre.pop_front();
        }
        ans += s;
        while (!lat.empty())
        {
            ans += lat.front();
            lat.pop_front();
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

int main(){
	ios_base::sync_with_stdio(false);

	int n, m;

	cin >> n >> m;

	int run = (n - m) * 100 + m * 1900;

	cout << run * (1 << m);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>


using namespace std;


constexpr int MAXELEMS = 10001;

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

  // prime numbers less than `MAXELEMS'
  vector<int> primes;

  // eratosthenes sieve
  vector<bool> sieve(MAXELEMS, true);

  sieve[0] = sieve[1] = false;

  int sqrtelm = sqrt(MAXELEMS);
  for (int i = 2; i < sqrtelm; i++) {
    if (sieve[i] == true) {
      for (int j = i * 2; j < MAXELEMS; j += i) {
        sieve[j] = false;
      }
    }
  }

  for (int i = 0; i < MAXELEMS; i++) {
    if (sieve[i] == true) {
      primes.push_back(i);
//      cout << "# " << i << endl;
    }
  }

  int count = n;
  for (int i = 0; i < n; i++) {
    int input;
    cin >> input;

    for (int p : primes) {
      if (p * p > input) {
        break;
      }
      if (input % p == 0) {
        count--;
        break;
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

signed main(){
  long long N;

  cin >> N;
  int _min = 1 << 10;
  
  for(int i = 1 ; i <= sqrt(N) ; i++){
    if(N%i == 0){
      _min = min(_min, (int)max(to_string(i).length(), to_string(N/i).length()));
    }
  }
  
  cout << _min << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <unordered_map>
#define MOD (1000000007l)

using namespace std;

int main(void) {
  char S[100010] = { 0 };
  long N;
  cin >> N;
  cin >> S;

/*
  cout << N << endl;
  cout << S << endl;
*/

  unordered_map<long, long> um;
  for (long i = 0; i < N; i++) {
    um[S[i]] += 1;
  }

  long ret = 1;
  for (auto it: um) {
    // cout << it.first << ": " << it.second << endl;
    ret = (ret * (it.second + 1)) % MOD;
  }

  ret -= 1;
  if (ret < 0) ret += MOD;

  cout << ret << endl;

  return 0;
}


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

int a,b;

int main(){
    scanf("%d%d",&a,&b);
    if(a>0)puts("Positive");
    else if(b>=0)puts("Zero");
    else if((a&1)^(b&1))puts("Positive");
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <cstdint>
#include <iostream>
#include <string>

void CallNaiveStringSearch(std::istream &input_stream);

void NaiveStringSearch(const std::string &text_1, const std::string &text_2);

void CallNaiveStringSearch(std::istream &input_stream) {
  input_stream.tie(0);
  std::ios::sync_with_stdio(false);
  try {
    std::string text_1, text_2;
    input_stream >> text_1 >> text_2;
    NaiveStringSearch(text_1, text_2);
  } catch (...) {
    std::cerr << "ERROR: CallNaiveStringSearch()" << std::endl;
    throw;
  }
}

void NaiveStringSearch(const std::string &text_1, const std::string &text_2) {
  try {
    int32_t length_text_1 = static_cast<int32_t>(text_1.size());
    int32_t length_text_2 = static_cast<int32_t>(text_2.size());
    for (int32_t start_text_1 = 0; start_text_1 < length_text_1; ++start_text_1) {
      const int32_t length_substr = length_text_1 - start_text_1;
      if (length_substr < length_text_2) {
        break;
      }
      bool match = true;
      for (int32_t offset = 0; offset < length_text_2; ++offset) {
        if (text_1.substr()[start_text_1 + offset] != text_2.substr()[offset]) {
          match = false;
          break;
        }
      }
      if (match) {
        std::cout << start_text_1 << std::endl;
      }
    }
  } catch (...) {
    std::cerr << "ERROR: NaiveStringSearch()" << std::endl;
    throw;
  }
}

int main(int argc, char *argv[]) {
  try {
    CallNaiveStringSearch(std::cin);
  } catch (...) {
    std::cerr << "ERROR: main()" << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int main() {
  int X,Y;
  cin >> X >> Y;
  cout << X + (Y/2) << endl;
  return 0;
}

Measured memory_bytes: 3552
#include <math.h>
#include <stdio.h>

#define N 8

int main() {
	static int xx[N], yy[N];
	int n, i, j;
	double x;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d%d", &xx[i], &yy[i]);
	x = 0;
	for (i = 0; i < n; i++)
		for (j = i + 1; j < n; j++)
			x += hypot(xx[i] - xx[j], yy[i] - yy[j]);
	printf("%.10f\n", x / (n * (n - 1) / 2) * (n - 1));
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sum = 0
for i in range(len(A)):
    sum += B[i]
    if i > 0 and A[i-1] + 1 == A[i]:
        sum += C[A[i-1]-1]
print(sum)


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

using namespace std;

using ll = long long;

ll five(ll t) {
    ll ret = t;
    for (int i = 1; i < 5; i++) ret *= t;
    return ret;
}

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

    int a = 0;

    while (true) {
        ll af = five(a);
        for (int b = 0; b < a; b++) {
            ll bf = five(b);
            if (af - bf == x) {
                cout << a << ' ' << b << endl;
                return 0;
            }
            if (af + bf == x) {
                cout << a << ' ' << -b << endl;
                return 0;
            }
        }
        a++;
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  for(int i = a; i <= b; i++){
    if(a+k > i || i > b-k) cout << i << endl;
  }
}



Measured memory_bytes: 256
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

#include <cstdint>
#include <iostream>

template <std::uint_fast64_t Modulus = 1000000007ULL> class Modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr Modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr Modint operator+(const Modint rhs) const noexcept {
    return Modint(*this) += rhs;
  }
  constexpr Modint operator-(const Modint rhs) const noexcept {
    return Modint(*this) -= rhs;
  }
  constexpr Modint operator*(const Modint rhs) const noexcept {
    return Modint(*this) *= rhs;
  }
  constexpr Modint operator/(const Modint rhs) const noexcept {
    return Modint(*this) /= rhs;
  }
  constexpr Modint &operator+=(const Modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr Modint &operator-=(const Modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr Modint &operator*=(const Modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr Modint &operator/=(Modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

Modint<> modpow(const Modint<> a, int exp) {
    Modint<> k = 1;
    Modint<> x = a;
    while(exp > 0) {
        if (exp & 1) {
            k *= x;
        }
        x *= x;
        exp >>= 1;
    }
    return k;
}

template <std::uint_fast64_t Modulus = 1000000007ULL>
std::ostream& operator<<(std::ostream& os, const Modint<Modulus>& obj)
{
    os << obj.value();
    return os;
}

#include<string>
using namespace std;
int n;
string s;
vector<int> hist(26, 0);
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> s;
    REP(i, (int)s.size()) {
        hist[s[i] - 'a'] += 1;
    }
    Modint<> ans = 1;
    REP(i, (int)hist.size()) {
        if (hist[i] > 0) {
            ans *= hist[i] + 1;
        }
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

ll a[3010][3010], dp[2][3010][4];

int main() {
    ios_base::sync_with_stdio(0);
    int n, m, t; cin >> n >> m >> t;
    for (int i=0;i<t;i++) {
        int x, y, v; cin >> y >> x >> v;
        a[y-1][x-1] = v;
    }

    for (int i=0;i<2;i++) for (int j=0;j<m;j++) {
        for (int k=0;k<4;k++) dp[i][j][k] = -1e18;
    }
    dp[0][0][0] = 0;
    if (a[0][0]) dp[0][0][1] = a[0][0];
    int p = 0, q = 1;

    for (int i=0;i<n;i++) {
        for (int j=0;j<m;j++) {
            if (i==0&&j==0) continue;
            if (j) {
                for (int k=0;k<4;k++) dp[p][j][k] = max(dp[p][j][k], dp[p][j-1][k]);
                if (a[i][j]) for (int k=1;k<4;k++) dp[p][j][k] = max(dp[p][j][k], dp[p][j-1][k-1]+a[i][j]);
            }
            if (i) {
                for (int k=0;k<4;k++) dp[p][j][0] = max(dp[p][j][0], dp[q][j][k]);
                if (a[i][j]) for (int k=0;k<4;k++) dp[p][j][1] = max(dp[p][j][1], dp[q][j][k]+a[i][j]);
            }
        }
        for (int j=0;j<m;j++) for (int k=0;k<4;k++) dp[(i+1)%2][j][k] = -1e18;
        swap(p, q);
    }

    cout << max(dp[q][m-1][0], max(dp[q][m-1][1], max(dp[q][m-1][2], dp[q][m-1][3]))) << endl;
}


Measured memory_bytes: 74236
#include<stdio.h>
int main(){
    int h,w;
    int i,j;

    while(1){
        scanf("%d %d",&h,&w);

        if(h==0 && w==0) break; //終了条件

        for(i=0;i<h;i++){       //縦のfor文
            for(j=0;j<w;j++){   //横のfor文
                if(i==0||i==h-1){//一番上と下なら#
                    printf("#");
                    continue;
                }
                if(j==0||j==w-1) //左端と右端なら#
                    printf("#");
                else printf(".");//真ん中は.
            }printf("\n");       //その行の終了
      } printf("\n");             //空行
    }
    return 0;
}



Measured memory_bytes: 2076
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val p1 :: ps = List.fill(sc.nextInt())(sc.nextInt())
  val (_, count) = ps.foldLeft(p1 -> 1) {
    case ((min, count), p) =>
      if (p <= min) (p, count + 1) else (min, count)
  }
  println(count)
}


Measured memory_bytes: 66592
import math
 
def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        for j in range(1,n+1):
            tmp = math.gcd(i,j)
            for k in range(1,n+1):
                ans += math.gcd(tmp,k)
 
    print(ans)
 

main()

Measured memory_bytes: 9180
def solve():

    N, K = [int(i) for i in input().split()]
    xlist = list(map(int, input().split()))

    cost = float("inf")

    for i in range(N-K+1):
        j = i+K-1
        cost = min(
            abs(xlist[i])+abs(xlist[j]-xlist[i]),
            abs(xlist[j])+abs(xlist[i]-xlist[j]),
            cost
        )

    print(cost)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 62576
#include <iostream>
using namespace std;
int main(){
	int a,b,c,x;
	int cnt=0;
	cin >> a >> b >> c >> x;
	for(int i=0; i<=a; i++){
		for(int j=0; j<=b; j++){
			for(int k=0; k<=c; k++){
				if((i*500+j*100+k*50)==x){
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,count=1;
  int p[200005];
  int min;

  cin>>n;
  for(int i=0;i<n;i++) cin>>p[i];
  min=p[0];

  for(int i=1;i<n;i++){
    if(min>p[i]){ min=p[i]; count++; }
  }

  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>

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

ld pi = acos(-1);
ld eps = 0.0000000001;
ld a,b,x;

ld f(ld a,ld b,ld deg){
    if(deg > pi/2 - eps){
        return 0.0;
    }

    ld ret;
    if(a * tan(deg) <= b){
        ret = a * a * b - a * a * a * tan(deg) /2;
    }else{
        ret = b * b / tan(deg) * a/2;
    }
    return ret;
}

int main(){
    cin >> a >> b >> x;
    ld ok = pi/2;
    ld ng = 0;
    rep(i,100000){
        ld mid = (ok+ng)/2;
        if(f(a,b,mid) < x) ok = mid;
        else ng = mid;
    }

    cout << fixed << setprecision(10) << ok / pi * 180 << endl;
    return 0;
}

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

int main()
{
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;

    if (S == U)
    {
        A--;
    }
    if (T == U)
    {
        B--;
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1000000000;
const ll inf=LONG_LONG_MAX;
const ll ms=(1e5)+5;


int main()
{
    idfc;

    string s;
    cin>>s;

    ll a=0;
    ll n=0;

    for(char e:s)
    {
        if(e=='W')a+=n;
        else ++n;
    }
    cout<<a;

    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  ll q;std::cin >> q;
  ll a, b;
  char c;

  string fr = "", ba = "";
  bool rv = 0;

  re(i, q){
    std::cin >> a;
    if(a==1){
      if(rv) rv = false;
      else rv = true;
    }else{
      std::cin >> b >> c;
      if(!rv&&b==2) ba = ba + c;
      if(!rv&&b==1) fr = c + fr;
      if(rv&&b==1) ba = ba + c;
      if(rv&&b==2) fr = c + fr;
    }
  }
  if(rv){
    reverse(all(s));
    reverse(all(ba));
    reverse(all(fr));
    string ans = ba + s + fr;
    std::cout << ans << '\n';
  }else{
    string ans = fr + s + ba;
    std::cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 1424
species, num = [int(i) for i in input().split()]
votes = [int(i) for i in input().split()]

sum_vote = sum(votes)
min_rate = sum_vote / 4 / num
votes.sort(reverse=True)

ans = 'Yes' if votes[num - 1] >= min_rate else 'No'

print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST
{
    static void Main()
    {
        Sol mySol = new Sol();
        mySol.Solve();
    }
}

class Sol
{

    public Sol()
    {
        string str = rs();
        str = str.Substring(0, str.Length-1);
        int ori_len = str.Length;
        int evelen = 0;
        while (str.Length > 0) {
            if (str.Length % 2 == 0)
            {
                if (String.Compare(str.Substring(0, str.Length / 2), str.Substring(str.Length / 2, str.Length / 2)) == 0)
                {
                    evelen = str.Length;
                    break;
                }
                else {
                    str = str.Substring(0, str.Length - 1);
                }
            }
            else {
                str = str.Substring(0, str.Length - 1);
            }
        }

        Console.WriteLine(str.Length);
    }

    public void Solve()
    {

    }

    static String rs() { return Console.ReadLine(); }
    static int ri() { return int.Parse(Console.ReadLine()); }
    static long rl() { return long.Parse(Console.ReadLine()); }
    static double rd() { return double.Parse(Console.ReadLine()); }
    static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
    static int[] ria(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
    static long[] rla(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
    static double[] rda(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
}

Measured memory_bytes: 13280
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <stack>
#include <string>
using namespace std;
int main(){
    string s;
    while(cin>>s){
        if(s.length()==2){

        }else if(s.length()==3){
            reverse(s.begin(),s.end());
        }
        cout<<s<<endl;
    }
    
}

Measured memory_bytes: 256
from functools import lru_cache
n, m = map(int, input().split())
aa = set(list(map(int, input().split())))

@lru_cache(maxsize=4095)
def gcd(a,b):
    if a < b:
        a, b = b, a
    while  a % b != 0:
        a, b = b, a % b
    return b
@lru_cache(maxsize=4095)
def lcm(c,d):
    return c*d // gcd(c,d)
# half all the array
A = set([a//2 for a in aa])
# calc lcm of all
LCM = 1
for each in A:
    LCM = lcm(LCM, each)
    if LCM > m:
        print(0)
        break
else:
    for each in A:
        if (LCM // each) % 2 == 0:
            print(0)
            break
    else:
        print(m//LCM - m//(LCM*2))

Measured memory_bytes: 21640
S = input()
N = len(S)
result = "Yes"
for i in range((N+1)//2):
    if S[i] != S[N-1-i]:
        result = "No"
        break

if result == "Yes":
    for i in range((N+1)//4):
        if S[i] != S[(N-1)//2-1-i]:
            result = "No"
            break
    
if result == "Yes":
    for i in range((N-(N+3)//2+2)//2):
        if S[(N+3)//2-1+i] != S[N-1-i]:
            result = "No"
            break
    
print(result)


Measured memory_bytes: 3064
import sys
S = str(input())
#print (S)

flag = True

if S[0:1] != 'A':
    flag = False

S2 = S[2:-1]
x = S2.count('C')
if  x != 1:
    flag = False

a = 0
c = 0
for i in S:
    if i == 'A':
        a += 1
    if i == 'C':
        c += 1
    if a >= 2 or c >= 2:
        flag = False
    if i != 'A' and i != 'C':
        if i != i.lower():
            flag = False

if flag:
    print ('AC')
else:
    print ('WA')

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

void solve()
{
    int K;
    string S;
    cin >> K >> S;

    if (S.length() <= K)
    {
        cout << S;
    }
    else
    {
        cout << S.substr(0, K) + "...";
    }
}

signed main()
{

    solve();

    return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int cnt(int c,int a)
{
	int mx=0;
	for(int i=0;i<=min(a,c/2);i++)mx=max(mx,i+(c-2*i)/3);
	return mx;
}
void solve(int c,int a,int n)
{
	int ans=0;
	for(int i=0;i<=min(n,min(a,c));i++)ans=max(ans,i+cnt(c-i,a-i));
	printf("%d\n",ans);
	return;
}
int main()
{
	int Q;
	scanf("%d",&Q);
	for(int i=0;i<Q;i++)
	{
		int c,a,n;
		scanf("%d %d %d",&c,&a,&n);
		solve(c,a,n);
	}
	return 0;
}

Measured memory_bytes: 1188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            int w = Integer.parseInt(line);
            boolean sp = false;
            for (int i = 1; i <= 512; i <<= 1) {
                if ((w & i) == i) {
                    if (!sp) {
                        sp = true;
                    } else {
                        out.print(' ');
                    }
                    out.print(i);
                }
            }
            out.println();
        }
    }
}

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

int main(){

  int r[4] = {0},l[4] = {0};
  double a,b;

  while(cin >> a >> b){

    if(a >= 1.1) r[0]++;
    else if(a >= 0.6) r[1]++;
    else if(a >= 0.2) r[2]++;
    else r[3]++;

   if(b >= 1.1) l[0]++;
    else if(b >= 0.6) l[1]++;
    else if(b >= 0.2) l[2]++;
    else l[3]++;

  }

  for(int i=0;i<4;i++) cout << r[i] << " " << l[i] << endl;

} 

Measured memory_bytes: 1220
#include <stdio.h>
 
int main ()
{
    int a, b, c, x, i, j, k, cnt=0;
    scanf("%d%d%d%d", &a, &b, &c, &x);
    for (i=0; i <= a && 500*i<=x; i++)
    {
        for (j=0; j <= b && 100*j+500*i<=x; j++)
        {
            for (k=0; k <= c && 50*k+100*j+500*i<=x; k++)
            {
                if (500*i+100*j+50*k==x)
                {
                    cnt++;
                }
            }
        }
    }
 
    printf("%d", cnt);
 
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
#ABC136 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

a,b,c = map(int,input().split())

if a - b >= c:
    print(0)
else:
    print(c-(a-b))


Measured memory_bytes: 38384
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  ll i,j,N,D,ans;
  cin>>N>>D>>ans;
  while(N--){
    cin>>i;
    rep(j,D)if(j%i==0)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    h,w,k = map(int,ipt().split())
    nm = [1,1,2,3,5,8,13,21,34]
    dp = [0]*(w+2)
    dp[1] = 1
    for i in range(h):
        ndp = [0]*(w+2)
        for j in range(1,w+1):
            ndp[j] = dp[j]*nm[j-1]*nm[w-j]+dp[j-1]*nm[j-2]*nm[w-j]+dp[j+1]*nm[j-1]*nm[w-j-1]
            ndp[j] %= mod
        dp = ndp*1
#        print(dp)

    print(dp[k])


    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 75016
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	double n;
	cin >> n;
	cout << setprecision(15) << (double)(n/3)*(n/3)*(n/3) << endl;




}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n;
  scanf("%d", &n);

  int i;
  int l, r;
  int total=0;
  for(i=0;i<n;i++){
    fscanf(stdin, "%d %d", &l, &r);
    total += r - l + 1;
  }
  printf("%d\n", total);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main() {

    int num;
    scanf("%d", &num);

    int max;
    scanf("%d", &max);

    int cur;
    int moutains = 1;
    for (int i=2; i<=num; i++) {
        scanf("%d", &cur);
        if (max <= cur) {
            max = cur;
            moutains++;
        }
    }

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

    return 0;
}


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

using namespace std;

map<long long,long long> freq;

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

    long long prefix[n+10];
    prefix[0]=0;

    for(int i=1;i<=n;i++) cin>>prefix[i];
    for(int i=1;i<=n;i++) prefix[i]+=prefix[i-1];
    for(int i=1;i<=n;i++) freq[prefix[i]]++;

    long long ans=0;
    for(auto p : freq) {
        ans += (p.second*(p.second-1))>>1;
    }
    cout<<ans+freq[0]<<endl;

    return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define wfile freopen("output.txt", "w", stdout)
#define rfile freopen("input.txt", "r", stdin)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
void enable_io(){
    #ifdef LOCAL_PROJECT
        wfile;
        rfile;
    #endif
}

int main(int argc, char const *argv[])
{   
    fastio;
    enable_io();
    int T = 1;
    //cin >> T;
    for(int t = 0; t < T; t++){
        int s,w;
        cin >> s >> w;
        if(w >= s)
        {
            cout << "unsafe\n";
        }
        else{
            cout << "safe\n";
        }      
    }
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void)
{
  int mountain[10];
  int buf;
  int i;

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

  int flag = 0;

  do{
    flag = 0;
    for(i = 0; i < 9; i++){
      if(mountain[i] < mountain[i + 1]){
	buf = mountain[i];
	mountain[i] = mountain[i + 1];
	mountain[i + 1] = buf;
	flag = 1;
      }
    }
  }while(flag == 1);

  for(i = 0; i < 3; i++){
    printf("%d\n", mountain[i]);
  }

  return 0;
}

Measured memory_bytes: 600
n, m = map(int, input().split())
a = [ list(input()) for _ in range(n) ]
b = [ list(input()) for _ in range(m) ]

is_ok = False
for dx in range(n-m+1):
    for dy in range(n-m+1):
        f = True
        for y in range(m):
            for x in range(m):
                if a[y+dy][x+dx] != b[y][x]:
                    f = False
        if f:
            is_ok = True

print("Yes" if is_ok else "No")

Measured memory_bytes: 3064
@in1=in();
$n=$in1[0];
for($i=0;$i<$n;$i++){
@in2=in();
$x[$i]=$in2[0];}$max=-1;
for($i=0;$i<$n;$i++){
$cnt=0;
for($j=0;$j<$n;$j++){
if(substr($x[$i],$j,1)eq"#"){$cnt++;}
}
$ok=0;
for($j=0;$j<$n;$j++){
if(substr($x[$j],$i,1)eq"#"){$ok=1;last;}
}
if($ok==0){$cnt--;}
if($max<$cnt) {$max=$cnt;}
}
if($max==-1){print "-1";exit;}
$max=$n-$max;

for($i=0;$i<$n;$i++){
$cnt=0;for($j=0;$j<$n;$j++){
if(substr($x[$j],$i,1)eq"."){$cnt++;
last;}
}if($cnt>0){$max++;}
}
print "$max";
sub in {
$t=<STDIN>;
$t=~s/[¥r¥n]+//;
return split / /, $t;
}

Measured memory_bytes: 896
w,a,b = list(map(int, input().split()))
if(b <= (a + w) and (a + w) <= (b + w)):
  print(0)
elif(b <= a and a <= (b + w)):
  print(0)
else:
  if((a + w) <= b):
  	print(b - (a + w))
  else:
    print(a - (b + w))

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int a, b, c;
  int d = 0, e = 0;
  while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
    if ((a + b) <= c || (b + c) <= a || (a + c) <= b || a > c || b > c)
      continue;
    if ((a * a + b * b) == c * c)
      d++;
    else
      e++;
  }
  cout << d << endl << e << endl;
  return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int n;
  cin>>n;
  cout<<n/3<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

int n;

const int MAX = 255;
int M[MAX][MAX];

int solve()
{
	int mval = 0;
	
	for(int i=0; i<n; i++)
	{
		int c = 0;
		for(int j=0; j<n; j++)
		{
			if(M[i][j]==1)
			{
				c++;
			}
			else
			{
				if(c > mval) mval =c;
				c = 0;
			}
		}
		
		if(c > mval)
		{
			mval = c;
		}
	}
	
	for(int i=0; i<n; i++)
	{
		int c = 0;
		for(int j=0; j<n; j++)
		{
			if(M[j][i]==1)
			{
				c++;
			}
			else
			{
				if(c > mval) mval =c;
				c = 0;
			}
		}
		
		if(c > mval)
		{
			mval = c;
		}
	}
	
	for(int i=0; i<n; i++)
	{
		int c = 0;
		for(int j=0; j<=i; j++)
		{
			if(M[i-j][j]==1) c++;
			else
			{
				mval = max(c, mval);
				c = 0;
			}
		}
		mval = max(c, mval);
		
		c = 0;
		for(int j=0; j<n-i; j++)
		{
			if(M[i+j][j]==1) c++;
			else
			{
				mval = max(c, mval);
				c = 0;
			}
		}
		mval = max(c, mval);
		
		c = 0;
		for(int j=0; j<=i; j++)
		{
			if(M[i-j][n-j-1]==1) c++;
			else
			{
				mval = max(c, mval);
				c = 0;
			}
		}
		mval = max(c, mval);
		
		c = 0;
		for(int j=0; j<n-i; j++)
		{
			if(M[i+j][n-j-1]==1) c++;
			else
			{
				mval = max(c, mval);
				c = 0;
			}
		}
		mval = max(c, mval);
		
		
	}
	
	return mval;
}

int main(int argc, char** argv)
{
	string tmp;
	char c[1];
	
	while(cin >> n, n)
	{
		for(int i=0; i<n; i++)
		{
			cin >> tmp;
			for(int j=0; j<n; j++)
			{
				memcpy(c, &tmp[j], sizeof(char));
				M[i][j] = atoi(c);
			}
		}
		
		cout << solve() << endl;;
	}
}

Measured memory_bytes: 1184
n,k = [int(i) for i in input().split()]
edges = [[int(i)-1 for i in input().split()] for j in range(n-1)]

node = [[] for _ in range(n)]
for edge in edges:
    node[edge[0]].append(edge[1])
    node[edge[1]].append(edge[0])

M = 0
for i in range(n):
    count = 1
    que = []
    check = [False]*n
    if k%2==0:
        check[i] = True
        que.append(i)
    elif i!=n-1:
        check[edges[i][0]]=True
        check[edges[i][1]]=True
        que.append(edges[i][0])
        que.append(edges[i][1])
        count = 2
    for j in range(k//2):
        newque = []
        while len(que)!=0:
            q = que.pop()
            for l in node[q]:
                if check[l]:
                    continue
                newque.append(l)
                check[l] = True
                count += 1
        que = newque
    M = max(M,count)
print(n-M)

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

int main(){
  int a1, a2, a3, i, count;

  cin >> a1 >> a2 >> a3;
  i = 0;
  if(a1 < a2){
    i = a1;
    a1 = a2;
    a2 = i;
  }
  if(a1 < a3){
    i = a3;
    a3 = a1;
    a1 = i;
  }
  if(a2 < a3){
    i = a3;
    a3 = a2;
    a2 = i;
  }

  count = (a1 - a2) + (a2 - a3);
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;


 int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c)
       cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
       cout << a << " " << c << " " << b << endl;
    else if(b <= a && a <= c)
       cout << b << " " << a << " " << c << endl;
    else if(b <= c && c <= a)
       cout << b << " " << c << " " << a << endl;
     else if(c <= a && a <= b)
       cout << c << " " << a << " " << b << endl;
     else if(c <= b && b <= a)
       cout << c << " " << b << " " << a << endl;
}



Measured memory_bytes: 3088