akhauriyash/Code-Regression huggingface dataset:
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n;
	cin >> n;
	int t[150],tt[150];
	rep(i, n) cin >> t[i];
	int m;
	cin >> m;
	int p[150], x[150];
	rep(i, m) cin >> p[i] >> x[i];

	rep(i, m) {
		int sum = 0;
		rep(j, n) {
			if (j+1 == p[i]) sum += x[i];
			else sum += t[j];
			
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll mypow(ll x,ll n){
  ll res = 1;
  while(n>0){
      if(n&1) res = res * x;
      x = x*x;
      n >>= 1;
  }
  return res;
}

int main(){
    ll x;
    cin >> x;
    vector<ll> a(10001),b(10001);
    for(int i=0;i<=1000;i++){
        ll c = mypow(i,5);
        a[i] = c;
        b[i] = c;
    }

    for(int i=0;i<=1000;i++){
        for(int j=0;j<=1000;j++){
            if(a[i]-b[j]==x){
                cout << i << ' ' << j << endl;
                return 0;
            }
            if(a[i]+b[j]==x){
                cout << i << ' ' << -j << endl;
                return 0;
            }
        }
    }

}

Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <math.h>
#include <cmath>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 987654319 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define PI 3.14159265
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main()
{
	double a, b, x;
	cin >> a >> b >> x;
	if(2 * x <= a * a * b)
	{
		auto check = [&] (double mid)
		{ 
			if(0.5 * a * b * b / tan(mid * PI / 180.0) > x)
				return false;
			else
				return true;
		};
		double lo = atan(b / a) * 180.0 / PI, hi = 90, ans = -1;
		while(hi - lo > 1e-12)
		{
			double mid = (lo + hi) / 2;
			if(check(mid))
			{
				ans = mid;
				hi = mid;
			}
			else
			{
				lo = mid;
			}
		}
		printf("%.10lf", ans);
	}
	else
	{
		auto check = [&] (double mid)
		{
			if(a * a * b - 0.5 * a * a * a * tan(mid * PI / 180.0) > x)
				return false;
			else
				return true;
		};
		double lo = 0, hi = atan(b / a) * 180.0 / PI, ans = -1;
		while(hi - lo > 1e-12)
		{
			double mid = (lo + hi) / 2;
			if(check(mid))
			{
				ans = mid;
				hi = mid;
			}
			else
			{
				lo = mid;
			}
		}
		printf("%.10lf", ans);
	}
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int H, W;
vector<string> s;
queue<pair<int, int>> det;
map<pair<int, int>, int> mv;

void bfs(int x, int y, int d){
  if(x < 0 || x >= H){
    return;
  }
  if(y < 0 || y >= W){
    return;
  }
  if(s.at(x).at(y) == '#'){
    return;
  }
  pair<int, int> p = make_pair(x, y);
  if(mv.count(p)){
    return;
  }
  mv[p] = d + 1;
  det.push(p);
}

int main(){
  cin >> H >> W;
  s.resize(H);
  rep(i, H){
    cin >> s.at(i);
  }
  pair<int, int> g = make_pair(H-1, W-1);
  int numw = 0;
  rep(i, H){
    rep(j, W){
      if(s.at(i).at(j) == '.'){
        numw++;
      }
    }
  }
  bfs(0, 0, -1);
  while(!mv.count(g) && !det.empty()){
    pair<int, int> q = make_pair(det.front().first, det.front().second);
    det.pop();
    bfs(q.first+1, q.second, mv.at(q));
    bfs(q.first-1, q.second, mv.at(q));
    bfs(q.first, q.second+1, mv.at(q));
    bfs(q.first, q.second-1, mv.at(q));
  }
  if(!mv.count(g)){
    cout << -1 << endl;
  }
  else{
    cout << numw-mv.at(g)-1 << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int n, a, b;
	cin >> n >> a >> b;

	int ans = 0;
	while (n)
	{
		int cs = 0;
		int x = n;
		while (x)
		{
			cs += x % 10;
			x /= 10;
		}
		if (cs >= a && cs <= b)
			ans += n;
		n--;
	}
	cout << ans << endl;
}

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

	solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}


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

int main()
{
  int n, m;

  while (cin >> n >> m, n || m){
    int ps[1010], me[1010];
    for (int i = 0; i < n; i++){
      cin >> ps[i];
    }
    for (int i = 0; i < m; i++){
      cin >> me[i];
    }
    int i = 0, pos = 1;
    while (i < m){
      pos += ps[pos - 1];
      if (pos >= n) break;
      pos += me[i];
      i++;
    }
    cout << i << endl;
  }
}

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

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

    long long int ans;
    rep(i, B) {
        ans = A * (i + 1);
        if (ans % B == 0) {
            break;
        }
    }
    cout << ans << endl;
}

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

int main() {
    int cnt = 0;
    string w, t;
    cin >> w;
    while (true) {
        cin >> t;
        if (t == "END_OF_TEXT") break;
        for (int i=0;i<t.size();++i) {
            if ('A' <= t[i] && t[i] <= 'Z') t[i] = char(t[i] - 'A' + 'a');
        }
        if (t == w) cnt++;
    }
    cout << cnt << endl;
    return 0;
}



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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;

int main(){

	int N;
	cin >> N;
	std::vector<ll> A(N);
	ll ans = 0;
	for(int i= 0; i< N; i++ ){
		cin >> A[i];
	}

	vector<ll>flag(60,0); // bit[i] = Aのi番目のbitの１の個数
	for(int i = 0; i< 60 ; i++){
		//cout << "flag" << i << ":" ;
		for (int j = 0; j < N ; j++){
			flag[i] += (A[j]>>i) & 1; 
			//cout << flag[i] ;
		}
		//cout << endl;
	}
	//cout << endl;
	

	for (int i = 0; i < 60 ; i++){
		ans += ((flag[i] * (N - flag[i])) % MOD ) * ((1LL << i)%MOD) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int isprime(int x)
{  int count=0;
	 if(x==1)return 1;
	 for(int i=1;i<=x;i++)
	 {
	 	 if(x%i==0)count++;
	 }
	 return count;
}
int main()
{
	int n,co=0;
	cin>>n;
	for(int i=1;i<=n;i+=2)
	{
		 if(isprime(i)==8)co++;
	}
	cout<<co<<endl;
}

Measured memory_bytes: 256
from itertools import product

h, w, k = map(int, input().split())
mod = 10 ** 9 + 7

dp = [[0] * w for _ in range(h + 1)]
dp[0][0] = 1

pats = [pat for pat in product([1, 0], repeat=w-1)]

for i in range(h):
	for j in range(w):
		for pat in pats:
			valid = True
			for e1, e2 in zip(pat, pat[1:]):
				if e1 and e2:
					valid = False

			if not valid:
				continue

			if j - 1 >= 0 and pat[j-1]:
				dp[i+1][j-1] += dp[i][j]
				dp[i+1][j-1] %= mod

			elif j <= w - 2 and pat[j]:
				dp[i+1][j+1] += dp[i][j]
				dp[i+1][j+1] %= mod

			else:
				dp[i+1][j] += dp[i][j]
				dp[i+1][j] %= mod

ans = dp[h][k-1]
print(ans)
#print(*dp, sep="\n")


Measured memory_bytes: 3064
#define _USE_NATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<iomanip>
#include<tuple>
#include<stack>
#include<random>
#include<chrono>
#include<map>
#include<cmath>
#include<sstream>
using namespace std;

const int INF = 1e9;
const double MINF = -1e9;


int main() {
	
	long long x;
	cin >> x;
	long long cnt = 0;

	cnt = x/11 * 2;
	long long tmp = x % 11;
	if (tmp) {
		if (tmp > 6) cnt += 2;
		else cnt += 1;
	}
	

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{
 ll a,b;
  cin>>a>>b;
  if(b&1)
    cout<<"No"<<"\n";
  else if(b > a*4 || b < a*2)
    cout<<"No"<<"\n";
  else if(a*4==b || a*2==b)
    cout<<"Yes"<<"\n";
  else
  {
      int flag = 0;
    while(b>0)
    {
      
      b = b - 6;
      a = a-2;
      if(b==a*2 || b==a*4)
      {
        flag = 1;
        break;
      }
    }
    if(flag==1)
      cout<<"Yes"<<"\n";
    else
      cout<<"No"<<"\n";
  }

 
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define eps 1e-6
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=(n-1);i!=-1;i--)
#define snc(a,b,c) ((a)?(b):(c))
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define ins insert
#define pi acos(-1.0)
#define pb push_back
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    bool ari[100001]={};
    int ball[100001];
    rep(i,n+1) ball[i]=1;
    ari[1] = true;
    for (int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        if (ball[a]>1)
            ari[b]+=ari[a];
        else{
            ari[b]+=ari[a];
            ari[a]=false;
        }
        ball[b]++,ball[a]--;
    }
    int count=0;
    rep(i,n+1)
        if(ari[i])
            count++;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int p){
	for(int i=2;i<=sqrt(p);i++){
		if(!p%i)return false;
	}
	return true;
}
int n,m,Q,l,r,a,b,ans[510][510];
signed main(){
	cin>>n>>m>>Q;
	rep(i,m){
		cin>>l>>r;
		ans[l][r]++;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			ans[i][j]+=ans[i][j-1];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			ans[j][i]+=ans[j-1][i];
		}
	}
	rep(i,Q){
		cin>>a>>b;
		cout<<ans[b][b]-ans[a-1][b]-ans[b][a-1]+ans[a-1][a-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>

#define MP make_pair
#define DUMP(x) cout << "DEBUG: " << #x << " = " << x << endl; 

using namespace std;

typedef pair<int, int> PII;
typedef pair<int, PII> PIII;
typedef vector<int> VI;
typedef vector<PIII> VIII;
typedef vector<VIII> VVIII;


int dijkstra(const VVIII& g, int N, int M) {
  int res = 0;

  priority_queue<PIII, VIII, greater<PIII> > que;   
  que.push(MP(0, MP(0, 0)));  // (d, v, c)

  set<int> used;
  VI ds;
  while (!que.empty()) {
    PIII piii = que.top(); que.pop();
    int d = piii.first;
    int v = piii.second.first;
    int c = piii.second.second;

    if (used.find(v) != used.end()) {
      // used
      continue;
    }
    used.insert(v);

    res += c;

    for (const auto &e : g[v]) {
      int v2 = e.first;
      int d2 = e.second.first;
      int c2 = e.second.second;

      que.push(MP(d + d2, MP(v2, c2)));
    }
  }

  return res;
}


int main(int argc, char const* argv[])
{
  ios::sync_with_stdio(false);

  while (1) {
    int N, M;
    VVIII g;
    cin >> N >> M;
    if (N == 0 && M == 0) {
      break;
    }
    for (int i = 0; i < N; i++) {
      g.push_back(VIII());
    }
    int u, v, d, c;
    for (int i = 0; i < M; i++) {
      cin >> u >> v >> d >> c;
      u--; v--;
      g[u].push_back(MP(v, MP(d, c)));
      g[v].push_back(MP(u, MP(d, c)));
    }

    int res = dijkstra(g, N, M);
    cout << res << '\n';
  }

  return 0;
}

Measured memory_bytes: 4552
#include<iostream>
#include<string>
int main()
{
	int ans = 0;
	for (std::string str; std::getline(std::cin, str);)
	{
		int sum = 0;
		for (auto i : str)
		{
			if ('0' <= i && i <= '9')
			{
				sum *= 10;
				sum += static_cast<int>(i - '0');
			}
			else
			{
				ans += sum;
				sum = 0;
			}
		}
		ans += sum;
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 2960
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define reprev(i,n) for(ll i=n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

const int mod = 998244353;
const long double pi = acos(-1);

bool sortby(const pii &a, const pii &b){
	if(a.ss == b.ss) return a.ff <= b.ff;
	return a.ss <= b.ss;
}

ll power(ll x, ll y){
	x %= mod;
	if(y == 0) return 1;
	if(y == 1) return x;
	ll num = power(x,y/2) % mod;
	if(y%2 == 0) return (num*num)%mod;
	else return (((num*num)%mod)*x)%mod;
}

bool isEq(string a, string b){
	rep0(i,a.size()){
		if(a[i]!=b[i]) return false;
	}
	return true;
}

bool isRev(string a, string b){
	rep0(i,a.size()){
		if(a[i]!=b[a.size()-1-i]) return false;
	}
	return true;
}

bool isComp(string a, string b){
	int cnt = 0;
	rep0(i,a.size()){
		if((a[i]=='0' && b[i]=='1') || (a[i]=='1' && b[i]=='0')) cnt++;
	}
	if(cnt==a.size()) return true;
	return false;
}

bool isRevComp(string a, string b){
	int cnt = 0;
	rep0(i,a.size()){
		if((a[i]=='0' && b[a.size()-1-i]=='1') || (a[i]=='1' && b[a.size()-1-i]=='0')) cnt++;
	}
	if(cnt==a.size()) return true;
	return false;
}

void solve(){

	ll n,k;
	cin >> n >> k;
	cout << min(n%k, ((n/k)+1)*k-n);

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(101010)

N,M = map(int,input().split())
es = [[] for i in range(N)]
for i in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    es[a].append(b)
    es[b].append(a)
Q = int(input())
qs = [tuple(map(int,input().split())) for i in range(Q)]

mem = [[0,-1] for i in range(N)] # [color,depth] for v
def paint(v,d,c):
    mc,md = mem[v]
    if d <= md: return
    mem[v] = [mc if mc else c, d]
    if d == 0: return
    for to in es[v]:
        paint(to,d-1,c)

for v,d,c in reversed(qs):
    paint(v-1,d,c)
for c,d in mem:
    print(c)


Measured memory_bytes: 45992
#import <stdio.h>

int main(){
  int i,x,n,diff,maxv,minv;

  scanf("%d",&n); //length
    
  scanf("%d",&x);
  minv = x;
  
  for(i=1;i<n;i++){
    scanf("%d",&x);

    diff = x - minv;
    if(i==1){ //first
      maxv = diff;
    }
    if(diff>maxv) maxv = diff;

    if(minv>x) minv = x;
  }

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

  return 0;
}

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

int main(){
    unsigned long Q;
    cin >> Q;
    for(unsigned long iter = 0; iter < Q; ++iter){
        unsigned long N;
        cin >> N;
        unsigned long cnt{0};
        while(N > 9){
            unsigned long mx{0};
            for(unsigned long i = 10; i <= N; i *= 10)mx = max(mx, (N / i) * (N % i));
            ++cnt;
            N = mx;
        }
        cout << cnt << endl;
    }
}


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

/**
       return NO_PAIN ? NO_GAIN : GAIN;
*/

using namespace std;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) (x.size())
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define pow(n, m) (ll)powl(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define clr(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007
#define EPS 1e-7


typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin);
    //freopen("test cases\\in.txt", "w", stdout);
    int n = 5;
    for(int i = 0; i<n; i++){
        int a; cin>>a;
        if(!a) return cout<<i+1, 0;
    }
    return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String n = sc.next();
		
		if(n.length() == 1) {
			if(n.equals("3")) {
				System.out.println("bon");
			} else if(n.equals("0") || n.equals("1")||n.equals("6")||n.equals("8")) {
				System.out.println("pon");
			} else {
				System.out.println("hon");
			}	
		}
		
		if(n.length() == 2) {
			String num = n.substring(1);
			if(num.equals("3")) {
				System.out.println("bon");
			} else if(num.equals("0") || num.equals("1")||num.equals("6")||num.equals("8")) {
				System.out.println("pon");
			} else {
				System.out.println("hon");
			}	
		}
		
		if(n.length() == 3) {
			String num = n.substring(2);
			if(num.equals("3")) {
				System.out.println("bon");
			} else if(num.equals("0") || num.equals("1")||num.equals("6")||num.equals("8")) {
				System.out.println("pon");
			} else {
				System.out.println("hon");
			}	
		}

	}
}


Measured memory_bytes: 35688
parseLine :: IO [Int]
parseLine = map read . words <$> getLine

main = do
  [n, m, x, y] <- parseLine
  xs <- parseLine
  ys <- parseLine

  if (maximum (x:xs)) < (minimum (y:ys))
    then putStrLn "No War"
    else putStrLn "War"


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  int n;
  while (cin >> n) {
    int a[n];
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    lli mn = 1LL << 60;
    for (int target = -100; target <= 100; ++target) {
      lli sum = 0;
      for (int i = 0; i < n; ++i) {
        sum += (target - a[i]) * (target - a[i]);
      }
      mn = min(mn, sum);
    }
    cout << mn << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[101];
double d;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		d+=1.0/a[i];
	}
	cout<<1.0/d;
	return 0;
}


Measured memory_bytes: 256
#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++)
typedef long long ll;
typedef pair<int,int> pii;


int main(){
    int n,k,s;
    cin>>n>>k>>s;
    int maxs=1e9;

    if(n==k){
        rep(i,n) cout<<s<<" ";
        cout << endl;
        return 0;
    }
    if(s==1){
        rep(i,k)cout<<s<<" ";
        rep(i,n-k)cout<<maxs<<" ";
        cout<<endl;
        return 0;
    }
    if(s==maxs) maxs--;

    if(s%2==0){
        rep(i,k+1) cout<< s/2<<" ";
        rep(i,n-k-1) cout<< maxs<<" ";
    }else{
        rep(i,k+1){
            if(i%2==0) cout<< (s+1)/2 << " ";
            else cout<< s/2<<" ";
        }
        rep(i,n-k-1) cout<< maxs <<" ";
    }
    cout << endl;
    return 0;
}

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

int main(){
	int a,b,c,d,i;
	i=0;
	cin >> a >> b >> c;
	while(a<=b){
		d=c%a;
		if(d!=0){
		}
		else{
			i++;
		}
		a++;
	}
	cout << i << endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> L;
    ll ans = 0;
    rep(i, N){int a; cin >> a; L.push_back(a);}
    sort(L.begin(), L.end());
    for (ll i=0; i<(ll)(N); i++){
        for (ll j=i+1; j<(ll)(N); j++){
            // 大きい方から2つpick-upしたので(x1, x2)，x3の満たす条件は abs(x1 - x2) < x3 < min(x1, x2), これを二部探索
            int d = abs(L.at(i) - L.at(j));
            auto it = upper_bound(L.begin(), L.end(), d);
            int dd = distance(L.begin(), it);
            if(i > dd) ans += i - dd;
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
const int N=5e3+50,mo=1e9+7;
int i,j,n,x,y,s1,s2,ans;
int siz[N],f[N][N],tmp[N],g[N];
int to[N<<1],nxt[N<<1],lst[N<<1],l;
inline void add(int x,int y) {
	to[++l]=y,nxt[l]=lst[x],lst[x]=l;
	to[++l]=x,nxt[l]=lst[y],lst[y]=l;
}
void dfs(int x,int fa) {
	siz[x]=f[x][1]=1;
	for (int i=lst[x],j;i;i=nxt[i]) {
		j=to[i];
		if (j==fa) continue;
		dfs(j,x);
		for (s1=1;s1<=siz[x]+siz[j];s1++) tmp[s1]=0;
		for (s1=1;s1<=siz[x];s1++)
			for (s2=1;s2<=siz[j];s2++) {
				tmp[s1+s2]=(tmp[s1+s2]+(ll)f[x][s1]*f[j][s2]%mo)%mo;
				if (!(s2&1)) tmp[s1]=((tmp[s1]-(ll)f[x][s1]*f[j][s2]%mo*g[s2]%mo)+mo)%mo;
			}
		siz[x]=siz[x]+siz[j];
		for (s1=1;s1<=siz[x];s1++) f[x][s1]=tmp[s1];
	}
}
int main() {
	// freopen("ARC101E.in","r",stdin);
	// freopen("ARC101E.out","w",stdout);
	scanf("%d",&n);
	for (i=1;i<n;i++) scanf("%d%d",&x,&y),add(x,y);
	g[2]=1;
	for (i=4;i<=n;i+=2) g[i]=(ll)g[i-2]*(i-1)%mo;
	dfs(1,0);
	for (i=2;i<=n;i+=2) ans=(ans+(ll)f[1][i]*g[i]%mo)%mo;
	printf("%d\n",ans); 
	return 0;
}


Measured memory_bytes: 98432
S = input()
S1 = int(S[:2])
S2 = int(S[2:])
if (S1==0 or 13<=S1) and (S2==0 or 13<=S2):
    print("NA")
    exit()
if 1 <= S1 <=12 and 1<=S2<=12:
    print("AMBIGUOUS")
    exit()
if 1 <= S1 <=12:
    print("MMYY")
    exit()
else:
    print("YYMM")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

long double dp[301][301][301];
long double N;

long double solve(int ones, int twos, int threes){
	if(dp[ones][twos][threes] >= 0) return dp[ones][twos][threes];
	long double cur = 1;
	if(threes > 0) cur += (threes/N) * (solve(ones,twos+1,threes-1));
	if(twos > 0) cur += (twos/N) * (solve(ones+1,twos-1,threes));
	if(ones > 0) cur += (ones/N) * (solve(ones-1,twos,threes));
	cur *= N / (ones+twos+threes);
	return dp[ones][twos][threes] = cur;
}


void solution(){

	int n; cin >> n;
	N = (long double)n;
	vector<int> a(n); for(auto& x : a) cin >> x;
	int ones = 0, twos = 0, threes = 0;
	for(int x : a){
		if(x == 1) ones++;
		else if(x == 2) twos++;
		else threes++;
	}
	memset(dp,-1,sizeof(dp));
	dp[0][0][0] = 0;
	// dp[a][b][c] = dp[a][b+1][c-1]*(c/n) + 
	// 				 dp[a+1][b-1][c]*(b/n) + 
	// 				 dp[a-1][b][c]*(a/n);
	printf("%0.14Lf\n", solve(ones,twos,threes));


	
}	


int main(){ 

	fio; // fast input output
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// GOOGLE //
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}


Measured memory_bytes: 429936
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}

int main()
{
    int n;
    scanf("%i",&n);
    map<int,int> cnt;
    vector<int> numbers;
    for(int i=0;i<n;i++){
        int a;
        scanf("%i",&a);
        if(cnt[a]==0)
            numbers.pb(a);
        cnt[a]++;
    }
    sort(all(numbers));
    reverse(all(numbers));
    map<int,bool> powers;
    for(ll i=1;i<INT_MAX;i*=2)
        powers[i]=true;
    /*for(auto p:powers)
    {
        printf("%i\n",p.first);
    }*/
    int res=0;
    for(auto p:numbers)
    {
        int tr=p;
        int ct=cnt[p];
        //printf("%i %i\n",tr,ct);
        if(powers[tr])
        {
            res+=ct/2;
            ct%=2;
            continue;
        }
        ll c=2;
        while(c<INT_MAX)
        {
            if(tr<=c)
            {
                int kol=cnt[c-tr];
                int uzimam=min(ct,kol);
                cnt[c-tr]-=uzimam;
                ct-=uzimam;
                res+=uzimam;
                break;
            }
            c*=(ll)2;
        }

    }
    printf("%i\n",res);
    return 0;
}


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

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r;
    while (y > 0) {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main() {
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
}


Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N= sc.nextInt();
		double sum=0;
		for(int i=0;i<N;i++) {
			double x=sc.nextDouble();
			String u=sc.next();
			if(u.equals("JPY")) {
				sum+=x;
			}else {
				sum+=x*380000.;
			}
		}
		// 出力
		System.out.println(sum);
	}
}

Measured memory_bytes: 24532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a=n;
  int b=0;
  while(a>0){
    b+=a%10;
    a/=10;
  }
  if(n%b==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	string s,ans="yes";
	set<string> a;
	cin >> s;
	for (int i = 1;i < s.size();i++) {
		for (int j = 0;j < i;j++) {
			if (s[i] == s[j]) {
				ans = "no";
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int r,D;
   int x[15];

   cin >> r >> D >> x[0];
   for(int i=0;i<10;++i)
   {
      x[i+1]=r*x[i]-D;
      cout << x[i+1] << endl;
   }

   return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
char s[N];
int n;
int main() {
	scanf("%s",s+1);
	n = strlen(s+1);
	string v;
	REP(i,1,n) {
		if (v.size()&&v.back()=='S'&&s[i]=='T') v.pop_back();
		else v.pb(s[i]);
	}
	cout<<v.size()<<endl;
}








Measured memory_bytes: 772
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
15 6
1 2 7 8 12 50

output:
2
"""

import sys


def solve():
    rec[0] = 0
    for coin in coins:
        for current_cost in range(coin, total_cost + 1):
            rec[current_cost] = min(rec[current_cost], rec[current_cost - coin] + 1)

    return rec


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    total_cost, c_num = map(int, _input[0].split())
    coins = list(map(int, _input[1].split()))
    # assert len(coins) == c_num
    rec = [float('inf')] * (total_cost + 1)
    ans = solve()
    print(ans.pop())

Measured memory_bytes: 9520
#include <stdio.h>
#include <string.h>

#define N (1000 + 10)

#define max(a, b) (a < b ? b : a) 



int dp[N][N];
char a[N], b[N];

int LCS(void)
{
  const int a_size = strlen(a) - 1;
  const int b_size = strlen(b) - 1;
  int i,j,mx;

  memset(dp,0,sizeof(dp));

  for(i=1;i<a_size+1;++i){
    for(j=1;j<b_size+1;++j){
      mx = max(dp[i][j - 1],dp[i - 1][j]);
      if(a[i - 1] == b[j - 1]){
	mx = max(mx,dp[i - 1][j - 1]+1);
      }
      
      dp[i][j] = mx;
    }
  }

  return dp[a_size][b_size];

}

int main(){
  
  int i,n;
  
  scanf("%d\n",&n);
  
  for(i=0;i<n;i++){
    
    fgets(a,N,stdin);
    fgets(b,N,stdin);
    printf("%d\n",LCS());
  }
  
  return 0;

}



Measured memory_bytes: 5840
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;
    cin>>n;
    vector<int> a(n-1);
    vector<int> each(n,0);
    rep(i,n-1){
        cin>>a.at(i);
        each.at(a.at(i)-1)++;
    }
    rep(i,n) cout<<each.at(i)<<endl;
}


Measured memory_bytes: 4840
#include <cstdio>
using namespace std;

int pos[7][4] = {{0, 1, 10, 11}, {0, 10, 20, 30}, {0, 1, 2, 3},
{1, 10, 11, 20}, {0, 1, 11, 12}, {0, 10, 11, 21}, {1, 2, 10, 11}};
char s[110] = {0};

int main()
{
	int i, j, k;
	
	while( scanf("%s", s + 1) != -1 ){
		for( i = 1; i < 8; i++ )
			scanf("%s", s + 10 * i + 1);
		
		for( i = 0; i < 7; i++ ){
			for( j = 0; j < 100; j++ ){
				for( k = 0; k < 4; k++ ){
					if( pos[i][k] + j >= 110 || s[pos[i][k] + j] != '1' )
						break;
				}
				if( k == 4 )	//??????????????´????????¨??¨'1'?????£?????´???????????????
					break;
			}
			if( j < 100 )	//?????§???????????´???????????????
				break;
		}
		printf("%c\n", 'A' + i );
	}
	return 0;
}

Measured memory_bytes: 968
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>
 
using namespace std;
 
int main(){
 long N;
 cin >> N;
 long long int ans;
 ans = ((N-1)*N)/2;
 cout << ans << endl;
 return 0;
}


Measured memory_bytes: 256
def selectionSort(A):
    N = len(A)
    cnt = 0
    for i in range(N):
        min_i = i
        for j in range(i,N):
            if A[j] < A[min_i]:
                min_i = j
        if min_i != i:
            A[i], A[min_i] = A[min_i], A[i]
            cnt += 1
    print(*A)
    print(cnt)

N=int(input())
A=list(map(int, input().split()))
selectionSort(A)

Measured memory_bytes: 7780
#include <stdio.h>
typedef long long ll;
int main() {
	int x, y;
	scanf("%d%d", &x, &y);
	if (x % y == 0) {
		printf("-1\n");
	} else {
		printf("%lld\n", (ll)x * (y - 1));
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){

  int n,m;
  cin >> n >> m;
  vector<string> res(m,"");
  vector<vector<Pl>> v(n+1);
  rep(i,m){
    int p,y;cin >> p >> y;
    v[p].push_back(make_pair(y,i));
  }
  rep(i,n+1)sort(ALL(v[i]));
  rep(i,n+1){
    int ss = 0;
    int kk = i;
    while(kk)ss++,kk/=10;
    string k = "";
    rep(l,6-ss)k += '0';
    k += to_string(i);
    for(int j = 0;j < v[i].size();j++){
      res[v[i][j].second] += k;
      kk = j+1;
      ss = 0;
      while(kk)ss++,kk/= 10;
      rep(l,6-ss)res[v[i][j].second] += '0';
      res[v[i][j].second] += to_string(j+1);
    }
  }
  rep(i,m)cout << res[i] << endl;

  

  return 0;
}

Measured memory_bytes: 12416
#include <stdio.h>
#define NMAX 500

int a[NMAX+1][NMAX+1];

int main(void) {
    int i, j;
    int N, M, Q;
    scanf("%d %d %d", &N, &M, &Q);
    for (i = 1; i <= M; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        a[l][r] += 1;
    }
    for (i = 1; i <= N; i++) {
        int s = 0;
        for (j = 1; j <= N; j++) {
            s += a[i][j];
            a[i][j] = s;
        }
    }
    for (i = 1; i <= N; i++) {
        int s = 0;
        for (j = 1; j <= N; j++) {
            s += a[j][i];
            a[j][i] = s;
        }
    }
    for (i = 1; i <= Q; i++) {
        int p, q;
        scanf("%d %d", &p, &q);
        printf("%d\n", a[q][q] - a[p-1][q] - a[q][p-1] + a[p-1][p-1]);
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;

int main() {
  int x,a,b; cin>>x>>a>>b;
  if (a - b >= 0) {
    cout << "delicious";
  } else if (b - a <= x) {
    cout << "safe";
  } else {
    cout << "dangerous";
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> f;
    map<int, int> e;
    for(int i=0; i<M; i++) {
        int ai, bi;
        cin >> ai >> bi;
        if(ai==1) {
            f.push_back(bi);
        }
        if(bi==N) {
            e[ai]=1;
        }
    }
    bool flag = false;
    for(auto fi:f) {
        // O(M)
        if(e[fi]==1) {
            flag = true;
            break;
        }
    }
    if(flag) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 9976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N;
    ll ans = 1;
    cin >> N;
    map<int, int, greater<int>> mp;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        mp[a]++;
    }

    int cnt = 0;
    for(auto p : mp) {
        while(p.second >= 2 && cnt < 2) {
            ans *= p.first;
            p.second -= 2;
            cnt++;
        }
        if(cnt >= 2)
            break;
    }
    cout << (cnt < 2 ? 0 : ans) << endl;
    return 0;
}


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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll L, R;
	cin >> L >> R;
	ll n = L / 2019;
	ll m = R / 2019;
	ll ans = 2020;
	if(n<m) ans = 0;
	else {
		for (int i = L; i < R; i++)
		{
			for (int j = i+1; j < R+1; j++)
			{
				ll tmp = (i%2019)*(j%2019)%2019;
				ans = min(ans, tmp);
				if (ans == 0) break;
			}
			if(ans == 0) break;
		}
	}
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOR(i,n,m) for (int i=n; i<(int)(m); ++i)
#define ALL(x) x.begin(), x.end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define in(i, n) (0 <= (i) && (i) < (n))
#define on(bit, i) (((bit >> i) & 1) == 1)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int INF = 1e9+7;

const int mod = 1e9+7;
struct Mod {
  int num;
  Mod () : num(0) {;}
  Mod (int n) : num(n) {;}
  operator int() { return num; }
};
Mod operator+(Mod a, Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator-(Mod a, Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator*(Mod a, Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator^(Mod a, int n) {
  if (n == 0) return Mod(1);
  Mod res = (a * a) ^ (n / 2);
  if (n % 2) res = res * a;
  return res;
}
Mod inv(Mod a) { return a ^ (mod - 2); }
Mod operator/(Mod a, Mod b) { return a * inv(b); }
Mod operator+=(Mod &a, Mod b) { return a = a + b; }
Mod operator-=(Mod &a, Mod b) { return a = a - b; }
Mod operator*=(Mod &a, Mod b) { return a = a * b; }
Mod operator/=(Mod &a, Mod b) { return a = a / b; }

int N, M;
Mod dp[305][305][305];

int main(void) {
  cin >> N >> M;
  dp[1][1][0] = 1;
  for (int i = 1; i <= M + 1; i++) {
    REP(j, N + 1) REP(k, N + 1) {
      //if (dp[i][j][k]) cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
      // nobasu
      if (j + k < N) dp[i + 1][j][k + 1] += dp[i][j][k] * Mod(N - j - k);
      // tsunagu
      dp[i + 1][j + k][0] += dp[i][j][k] * Mod(j);
      // iminakunobasu
      if (k > 0) dp[i + 1][j][k] += dp[i][j][k] * Mod(k);
    }
  }
  cout << dp[M + 1][N][0] << endl;
  return 0;
}


Measured memory_bytes: 111104
#include<stdio.h>
int main(void){
int a,b,c;
int count=0;
int i;
scanf("%d %d %d",&a,&b,&c);
for(i=a;i<=b;i++){
if(c%i==0)
count++;
}
printf("%d\n",count);
return 0;
}

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

int main(){
    int ans,sum,i,j;
    int a[21][21];
    int b[21];
    int c,m,n;

    cin >>n>>m>>c;

    for (i = 0; i < m; i++){
        cin >> b[i];
    }
    for (i = 0; i < n; i++){
        for (j = 0; j < m; j++){
            cin >> a[i][j];
        }
        
    }
    
    

    for ( i = 0; i < n; i++){
        sum=0;
        for (size_t j = 0; j < m; j++){
            sum += a[i][j]*b[j];
        }
        sum += c;
        if(sum>0)ans++;
        
    }
    

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n,k;
    cin>>n>>k;
    
    n=n%k;
    cout<<min(n,abs(k-n))<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int n;
int dp[10][1 << 10][331];
int rec(int now, int used, int sum)
{
    if (sum < 0)
        return 0;
    if (now == n)
        return sum == 0;

    if (~dp[now][used][sum])
        return dp[now][used][sum];

    int ret = 0;
    for (int i = 0; i < 10; ++i)
    {
        if ((used >> i) & 1)
            ret += rec(now + 1, used & ~(1 << i), sum - (now + 1) * i);
    }
    return dp[now][used][sum] = ret;
}
int main()
{
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //cout << fixed << setprecision(7);
    int s;
    while (cin >> n >> s)
    {
        //cout << n << " " << s << endl;
        fill_n(**dp, 10 * (1 << 10) * 331, -1);
        cout << rec(0, (1 << 10) - 1, s) << endl;
    }

    return 0;
}


Measured memory_bytes: 16276
#include <stdio.h>

int main(){
  long i,j,k,l,n;
  char a[12];
  while(scanf("%ld",&n),n!=0){
    sprintf(a,"%lo",n);
    for(i=0;i<11;i++){
      if(a[i]>='4') a[i]++;
      if(a[i]>='6') a[i]++;
    }
    printf("%s\n",a);
  }
  return 0;
}

Measured memory_bytes: 620
# AC
# 入力
n = int(input())
org_nums = list(map(int, input().split()))
# ソートは一回だけして、取り去る順番を明確にしてから１つずつ取り去り計算を行いたい
sorted_nums = sorted(org_nums) # 入力数列のソート
sorted_index = sorted(range(len(org_nums)), key=lambda k: org_nums[k]) #ソートされたリストから取り去る順番がわかる
extract_index = sorted(range(len(sorted_index)), key=lambda k: sorted_index[k]) #ソートされたリストから取り出すインデックスを取り出す順に並べる
#print(extract_index)
for i in extract_index:
    if i+1 <= n // 2:
        print(sorted_nums[n//2])
    else:
        print(sorted_nums[n//2-1])

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


int main() {
    int S;
    cin >> S;
    int h = S / 3600;
    S %= 3600;
    int m = S / 60;
    int s = S % 60;
    
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3100
# 深さ優先探索
def dfs(sy, sx, visited, C):
    cango = [[1, 1], [1, 0], [1, -1], [0, 1], [0, -1], [-1, 1], [-1, 0], [-1, -1]]
    stack = [[sy, sx]]
    if visited[sy][sx] == 1:#きたことあるならスルー
      return 0
    visited[sy][sx] = 1
    if C[sy][sx] == 0:#もし海ならスルー
      return 0
    while stack:
      y, x = stack[-1]
      stack.pop()
      for i, j in cango:
        if (0 <= y + i < H) and (0 <= x + j < W):
          if (visited[y + i][x + j] == 0) and (C[y + i][x + j] == 1):
            visited[y + i][x + j] = 1
            stack.append([y + i, x + j])
    return 1

def dfs2(W, H, C1):
  ans = 0  
  visited = [[0] * W for i in range(H)]
  C = C1
  for i in range(H):
    for j in range(W):
      ans += dfs(i, j, visited, C)
    
  print(ans)

p = 0
while (p == 0):
#from collecitons import deque
  W, H = map(int, input().split())
  if (W, H) == (0, 0):
    p == 1
    quit()
  C1 = [0] * H
  for i in range(H):
    C1[i] = list(map(int, input().split()))
  dfs2(W, H, C1)


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define f(i,j,k) for(long long i=j;i*i<=k;i++)
using namespace std;
int main(){
    long long n;
    int ans=2;
    vector <long long> a;
    cin>>n;
    if(n==2){
        cout<<1<<endl;
        return 0;
    }
    f(i,2,n){
        if(n%i==0){
            a.push_back(i);
        }
    }
    f(i,2,n-1){
        if(i*i==(n-1)){
            ans++;
        }
        else if((n-1)%i==0){
            ans+=2;
        }
    }
    for(int i=0;i<a.size();i++){
        long long nn=n;
        while(nn%a[i]==0){
            nn=nn/a[i];
        }
        if(nn%a[i]==1){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	long long int a_i, x, sum[N];
	priority_queue<long long int> A;
	for (int i = 0; i < N; ++i) {
    	cin >> a_i;
    	A.push(a_i);
    }
	for (int i = 0; i < M; ++i) {
    	x = A.top();
    	A.pop();
    	x /= 2;
    	A.push(x);
    }
	for (int i = 0; i < N; ++i) {
    	sum[i] = A.top();
    	A.pop();
    }
	cout << accumulate(sum, sum+N, (long long int)0) << endl;
}

Measured memory_bytes: 1908
// Problem : D - Sum of Divisors
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_d
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 1e7+5;
int sv[N];		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		for(int i=1;i<=n;++i)
		sv[i] = 1;
		//sv[1] = 1;
		for(int i=1;i<=n;++i)
		{
			for(int j=2*i;j<=n;j+=i)
			{
				sv[j]++;
			}
		}
		int sum = 0;
		for(int i=1;i<=n;++i)
		sum+=(i*sv[i]);
		cout<<sum;
    }
    return 0;
}


Measured memory_bytes: 81668
#include<stdio.h>
int main(void)
{
	int t,n,s,f,sum,i;
	while(1){
		scanf("%d",&t);
		if(t==0){
			break;
		}
		scanf("%d",&n);
		sum=0;
		for(i=1;i<=n;i++){
			scanf("%d %d",&s,&f);
			sum+=f-s;
		}
		if(sum>=t){
			printf("OK\n");
		}
		else{
			printf("%d\n",t-sum);
		}
	}
	return 0;
}


Measured memory_bytes: 2032
#include <iostream>

using namespace std;

int main()
{
	long long n, L[87], i, j;

	cin >> n;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}

	L[0] = 2;	L[1] = 1;

	for (i = 2; i <= n; i++) {
		L[i] = L[i - 1] + L[i - 2];
	}

	cout << L[i-1] << endl;

	return 0;
}

Measured memory_bytes: 256