akhauriyash/Code-Regression huggingface dataset:
lst = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
while True:
    m, d = map(int, input().split())
    if m == 0:
        break
    
    if m == 1 or m == 4 or m == 7:
        print(lst[(d + 2) % 7])

    elif m == 2 or m == 8:
        print(lst[(d + 5) % 7])

    elif m == 3 or m == 11:
        print(lst[(d + 6) % 7])

    elif m == 5:
        print(lst[(d + 4) % 7])

    elif m == 6:
        print(lst[d % 7])

    elif m == 9 or m == 12:
        print(lst[(d + 1) % 7])

    else:
        print(lst[(d + 3) % 7])


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int x,y,i,j,k,c=0,n,o,mx=-10;
    vector<long long int>v;
    string s;
    map<string,long long int>m;
    cin>>n;
    while(n--)
    {
        cin>>s;
        m[s]++;
    }
    cin>>o;
    while(o--)
    {
        cin>>s;
        if(m[s]>0)
        {
            m[s]--;
        }
    }
    for(auto z:m)
    {
        mx=max(mx,z.second);
    }

    cout<<mx<<endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
  ll k,x;
  cin >> k >> x;
  ll judge=500*k;
  if(judge>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
    
    int n, x, t, ans;

    cin >> n >> x >> t;

    ans =  (n + x-1) / x;
    cout << t * ans << endl;
    
    return 0;
}



Measured memory_bytes: 3608
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;
const int U = 2048, N = 4096, M = 2e5 + 10, Mod = 1e9 + 7;

inline void Read(int &x)
{
	x = 0; register char cc = '\0'; int fff = 1;
	for (; cc < '0' || cc > '9'; cc = getchar())
		if (cc == '-') fff = -1;
	for (; cc >= '0' && cc <= '9'; cc = getchar())
		x = (x << 1) + (x << 3) + (cc & 15);
	x *= fff;
}

int n, fans, minpx, minpy, maxpx, maxpy, fac[N * 2 + 10], ifac[N * 2 + 10], ptx[M], pty[M], rptx[M], rpty[M], f[N][N];

inline int Pow(int x, int y) {
	int sum = 1;
	while (y) {
		if (y & 1) sum = (LL)sum * x % Mod;
		x = (LL)x * x % Mod; y >>= 1;
	}
	return sum;
}

inline int C(int x, int y) {
	return (LL)fac[x] * ifac[y] % Mod * ifac[x - y] % Mod;
}

int main()
{
	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= N * 2; ++i) fac[i] = (LL)fac[i - 1] * i % Mod;
	ifac[N * 2] = Pow(fac[N * 2], Mod - 2);
	for (int i = N * 2 - 1; i >= 1; --i) ifac[i] = (LL)ifac[i + 1] * (i + 1) % Mod;
	
	Read(n);
	minpx = minpy = N, maxpx = maxpy = -N;
	for (int i = 1; i <= n; ++i) {
		Read(ptx[i]), Read(pty[i]);
		rptx[i] = U - ptx[i], rpty[i] = U - pty[i];
		f[rptx[i]][rpty[i]] += 1; /* += !!! */
		minpx = min(minpx, rptx[i]), minpy = min(minpy,rpty[i]);
		ptx[i] += U, pty[i] += U;
		maxpx = max(maxpx, ptx[i]), maxpy = max(maxpy, pty[i]);
	}
	
	for (int i = minpx; i <= maxpx; ++i)
		for (int j = minpy; j <= maxpy; ++j)
			f[i][j] = (f[i][j] + (LL)f[i][j - 1] + (LL)f[i - 1][j]) % Mod;
	
	for (int i = 1; i <= n; ++i) {
	//	printf("%d %d : %d\n", ptx[i] - U, pty[i] - U, f[ptx[i]][pty[i]]);
		fans = (fans + f[ptx[i]][pty[i]]) % Mod;
		fans = (fans - C(ptx[i] - rptx[i] + pty[i] - rpty[i], ptx[i] - rptx[i]) + Mod) % Mod;
	}
	
	//printf("%d\n", fans);
	fans = (LL)fans * Pow(2, Mod - 2) % Mod;
	printf("%d\n", fans);
	
	return 0;
}


Measured memory_bytes: 68224
#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() {
  string s;
  cin >> s;
  rep(i,s.size()) {
    cout << 'x';
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
vector<bool> visited;

void dfs(vector<vector<int>>& graph, int start, vector<int>& ans) {
  visited[start] = true;
  if(graph[start].size() == 0) {
    return;
  }
  for(auto node: graph[start]) {
    //cout << start << " " <<  node << endl;
    if(visited[node]) {
      continue;
    }
    ans[node] += ans[start];
    dfs(graph, node, ans);
    visited[node] = true;
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<int>>graph(n);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    graph[a-1].push_back(b-1);
    graph[b-1].push_back(a-1);
  }
  vector<vector<int>>root(n);
  rep(i, n) {
    root[i].push_back(i);
  }
  visited = vector<bool>(n, false);
  
  //cout << endl;
  //rep(i, n) {
  //  rep(j, root[i].size()) {
  //    cout << root[i][j] << " ";
  //  }
  //  cout << endl;
  //}
  vector<int>ans(n, 0);
  rep(i, q) {
    int p, x;
    cin >> p >> x;
    ans[p-1] += x;
  }
  dfs(graph, 0, ans);
  rep(i, n) {
    cout << ans[i];
    if(i == n-1) {cout << endl;}
    else {cout << " ";}
  }
  return 0;
}

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

vector<int> InsertSort(vector<int> A, int i){
	int v = A[i];
	int j = i - 1;
	while(j >= 0 && A[j] > v){
		A[j+1] = A[j];
		j--;
	}
	A[j+1] = v;
	return A;
}

void Output(vector<int> A){
	int N = A.size();
	for(int i = 0; i < N-1; i++) cout << A[i] << ' ';
	cout << A[N-1] << endl;
}

int main(){
	int N;
	cin >> N;
	vector<int> A;
	A.resize(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	for(int i = 0; i < N; i++){
		A = InsertSort(A, i);
		Output(A);
	}
	return 0;
}

Measured memory_bytes: 1220
n = int(input())
a = map(int, input().split())
a = list(a)

for k in a:
    if k == 0:
        print(0)
        exit()

maxn = 10**18
ans = 1
for k in a:
    ans *= k
    if ans > maxn:
        ans = -1
        break


print(ans)


Measured memory_bytes: 21656
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    
    int F;
    cin >> F;
    cout << (F-30)/2 << endl;
    
    return 0;
}


Measured memory_bytes: 3092
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define REPR(i, x, n) for(int i = n - 1 ; i >= x ; i--)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) REPR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans = "";
    rep(i, tx-sx){
        ans += "R";
    }
    rep(i, ty-sy){
        ans += "U";
    }
    rep(i, tx-sx){
        ans += "L";
    }
    rep(i, ty-sy+1){
        ans += "D";
    }
    rep(i, tx-sx+1){
        ans += "R";
    }
    rep(i, ty-sy+1){
        ans += "U";
    }
    ans += "LU";
    rep(i, tx-sx+1){
        ans += "L";
    }
    rep(i, ty-sy+1){
        ans += "D";
    }
    ans += "R";
    cout << ans << endl;
    return 0;
}

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

int main() {
    ll s[32]={1,1,2,1, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll n;cin>>n;
  cout<<s[n-1];
  return 0;
}

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

using namespace std;
int n,t1,a,t[1000002],m,licz;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for(int i=1;i <= m;i++)
	{
		cin >> a;
		licz += a;
	}
	if(licz > n)
		cout << -1 << endl;
	else cout << n-licz << endl;
}

Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
#define N 510000
#define md 1000000007
using namespace std;
ll ex[N],cnt,size,l[N],r[N],n,m,tmp,i,dp[N],q[N],head,tail,j,sum;
struct node {ll v,x;}a[N];
bool cmp(node x,node y){return x.x<y.x;}
void init()
{
	sort(ex+1,ex+1+cnt);size=unique(ex+1,ex+1+cnt)-ex-1;
	for (ll i=1;i<=n;i++) l[i]=upper_bound(ex+1,ex+1+size,l[i])-ex-1,r[i]=upper_bound(ex+1,ex+1+size,r[i])-ex-1;
}
int main()
{
	scanf("%lld",&n);
	for (i=1;i<=n;i++)   scanf("%lld %lld",&a[i].x,&a[i].v);
	sort(a+1,a+1+n,cmp);
	for (i=1;i<=n;i++) tmp=max(tmp,a[i].v),r[i]=tmp;
	tmp=100000000000ll;for (i=n;i>=1;i--) tmp=min(tmp,a[i].v),l[i]=tmp;
	for (i=1;i<=n;i++) ex[++cnt]=a[i].v;
	init();
	dp[0]=1;n++;l[n]=r[n]=n;
	q[++tail]=0;sum=1;
	for (i=1;i<=n;i++) 
	{
		while (head!=tail&&r[q[head+1]]<l[i]-1) sum=(sum-dp[q[head+1]]+md)%md,head++;
		dp[i]=sum;sum=(sum+dp[i])%md;
		q[++tail]=i;
	}
	printf("%lld\n",dp[n]%md);
}

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

using namespace std;

int main()
{
    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    for(int i=0;i<h;i++) cin >> a[i];
    
    for(int i=0;i<a.size();i++){
        if(a[i].find('#')==string::npos){
            a.erase(a.begin()+i);
            i--;
        }
    }

    for(int i=0;i<w;i++){
        for(int j=0;j<a.size();j++){
            if(a[j][i]=='#') break;
            if(j==a.size()-1){
                for(int k=0;k<a.size();k++){
                    a[k].erase(a[k].begin()+i);
                }
                i--;
                w--;
            }
        }
    }

    for(int i=0;i<a.size();i++){
        cout << a[i] << endl;
    }
}

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

class Program
{
    static void Main()
    {
        const long MAX = 1000000000000000000;
        int n = int.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        if (a.Any(x => x == 0))
        {
            Console.WriteLine(0);
            return;
        }
        long ans = 1;
        foreach (var x in a)
        {
            var pre = ans;
            ans *= x;
            if (ans > MAX || ans < pre)
            {
                Console.WriteLine(-1);
                return;
            }
        }
        Console.WriteLine(ans);
    }
}

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

int main() {
  int n,d;
  cin>>n>>d;
  if(n%(d*2+1)==0){
    cout<<n/(d*2+1)<<endl;
  }
  else{
    cout<<n/(d*2+1)+1<<endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
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; }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    string S;
    cin>>S;
    if(S=="SAT")cout<<"1"<<endl;
    if(S=="FRI")cout<<"2"<<endl;
    if(S=="THU")cout<<"3"<<endl;
    if(S=="WED")cout<<"4"<<endl;
    if(S=="TUE")cout<<"5"<<endl;
    if(S=="MON")cout<<"6"<<endl;
    if(S=="SUN")cout<<"7"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{char a;
scanf("%c",&a);
if(a==97||a==98||a==99||a==100||a==101||a==102||a==103||a==104||a==105||a==106||a==107||a==108||a==109||a==110||a==111||a==112||a==113||a==114||a==115||a==116||a==117||a==118||a==119||a==120||a==121||a==122){printf("a");}
else{printf("A");}
    return 0;
}

Measured memory_bytes: 1588
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);
const int MAX = 510000;

//変数
LL n;
vector<LL> x;
vector<bool> exist;
bool bigThere = false;





//サブ関数
//入力
void input()
{
	cin >> n;
	exist.resize(MAX);
}

//枝刈
int failNo() {
	static int id = 0;
	while (exist[id + 1])id++;
	return id;
}

bool isSafeFail(int now) {
	if (bigThere)return false;


	FOR(i, now + 1, MAX) {
		if (exist[i])
			return false;
	}
	return true;
}

void insert(vector<bool>& exist, LL now) {
	if (exist[now]) {
		exist[now] = false;
		insert(exist, now - 1);
	}
	else {
		exist[now] = true;
	}
}

//計算
void calc()
{
	REP(i,n){
		LL now;
		cin >> now;
		if (n < now)bigThere = true;

		if (exist[0] || (now <= failNo() && !isSafeFail(now))) {
			if (n < now)bigThere = true;
			cout << "No" << endl;
		}
		else {
			if (now <= n) {
				insert(exist, now);
			}
			cout << "Yes" << endl;
		}
	}
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	//output();
	//debug();
	
	return 0;
}




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

int main(){
    ll N,M;
    cin >> N >> M;
    string S;
    cin >> S;
    vector<ll> ans(0);
    ll now = N;
    bool possible = true;
    while(now > M){
        ll next = 0;
        for (ll i = 1; i <= M; i++){
            if (S[now - i] == '0') next = i;
        }
        if (next == 0){
            possible = false;
            break;
        }
        now -= next;
        ans.push_back(next);
    }
    if (possible) ans.push_back(now);
    if (!possible) cout << -1 << endl;
    else{
        for (ll i = ans.size() - 1; i >= 0; i--){
            cout << ans[i] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 4272
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int L, R, d;
	cin >> L >> R >> d;
	int ans = 0;
	for(int i = L; i <= R; i++){
		if(i % d == 0){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int main(){
    int n, m , x, y;cin >> n >> m >> x >> y;
    int xmax = x;
    int ymin = y;
    for(int i = 0; i < n; i++){
        int xx;cin >> xx;
        xmax = max(xmax, xx);
    }
    for(int i = 0; i < m; i++){
        int yy;cin >> yy;
        ymin = min(ymin, yy);
    }
    cout << ((ymin - xmax > 0) ? "No War": "War" ) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#pragma warning(disable:4996)

int main(void) {
	int a, b, sum;
	int count;
	while (scanf("%d %d", &a, &b) != EOF) {
		sum = a + b;
		count = 0;
		do {
			sum = sum / 10;
			count++;
		} while (sum != 0);
		printf("%d\n", count);
	}
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin>>S;
    ll a=0;
    ll ans=0;
    FOR(i,0,S.size()){
        if(S[i]=='W')ans+=a;
        else a++;
    }

    cout<<ans<<endl;

}

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

using namespace std;
typedef long long ll;
ll f(ll a){
	if(a&1){
		if(((a+1)/2)&1) return 1;
		return 0;
	}
	else{
		if((a/2)&1){
			return 1^a;
		}
		return a;
	}
}
int main(){
	ll a,b;
	cin>>a>>b;
	cout<<(f(a-1)^f(b))<<endl;
}

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

int main() {
  string s;
  cin>>s;
  for(int i=s.size()-3;i>=1;i-=2){
    if(s.substr(0,(i+1)/2)==s.substr((i+1)/2,(i+1)/2)) {
      cout<<i+1<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
N, m= gets.split(' ').map(&:to_i)
a = []
b = []
sum = 0

N.times.with_index do |i|
  key = {}
  key[:price], key[:quantity] = gets.split(' ').map(&:to_i)
  a << key
end

a.sort! {|a, b| a[:price] <=> b[:price] }

a.each do |val|
  if (m-val[:quantity]) >= 0
    sum = sum + val[:quantity] * val[:price]
    m = m - val[:quantity]
  else
    sum = sum + val[:price] * m
    break
  end
end

puts sum


Measured memory_bytes: 32376
while True:
    H, W = map(int, raw_input().split())
    if H == 0 and W == 0:
        break
    s1 = ""
    s2 = ""
    for i in range(W):
        if i % 2 == 0:
            s1 += "#"
            s2 += "."
        else:
            s1 += "."
            s2 += "#"
    count = True
    for i in range(H):
        if count:
            print(s1)
        else:
            print(s2)
        count = not count
    print("")

Measured memory_bytes: 4216
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
typedef pair<P, int> P2;

const int dx[] = {-1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2};
const int dy[] = {2, 2, 2, 1, 0, -1, -2, -2, -2, 1, 0, -1};

int sx, sy, n;

bool bfs(vector<P> cooler){
  queue<P2> que;
  que.push(P2(P(sx, sy), 0));

  while(!que.empty()){
    int x = que.front().first.first;
    int y = que.front().first.second;
    int c = que.front().second;
    que.pop();

    if(c == n) return true;
    for(int i = 0 ; i < 12 ; i++){
      int nx = x+dx[i], ny = y+dy[i];
      if(0 <= nx && nx <= 9 && 0 <= ny && ny <= 9 &&
	 abs(nx-cooler[c].first) <= 1 && abs(ny-cooler[c].second) <= 1){
	que.push(P2(P(nx, ny), c+1));
      }
    }
  }
  return false;
}

int main(){
  while(cin >> sx >> sy){
    if(sx == 0 && sy == 0) break;
    cin >> n;
    vector<P> cooler(n);
    for(int i = 0 ; i < n ; i++){
      cin >> cooler[i].first >> cooler[i].second;
    }
    
    if(bfs(cooler)) cout << "OK" << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m;
long long ans=1e18,s[MN+5],a[MN+5],b[MN+5];
inline void Add(long long*s,int l,int r,int v){s[l]+=v;s[r+1]-=v;}
int main()
{
    n=read();m=read();
    for(int i=1;i<=n;++i) b[i]=read();
    for(int i=2;i<=n;++i)
    {
        if(b[i]>b[i-1])
            Add(s,1,b[i-1],b[i]-b[i-1]),
            Add(s,b[i]+1,m,b[i]-b[i-1]),
            Add(a,b[i-1]+1,b[i],-1),
            Add(s,b[i-1]+1,b[i],b[i]+1);
        else Add(s,b[i]+1,b[i-1],m-b[i-1]+b[i]),
             Add(a,b[i-1]+1,m,-1),
             Add(s,b[i-1]+1,m,m+b[i]+1),
             Add(a,1,b[i],-1),
             Add(s,1,b[i],b[i]+1);
    }
    for(int i=1;i<=m;++i) s[i]+=s[i-1],a[i]+=a[i-1],ans=min(ans,a[i]*i+s[i]);//cout<<i<<" "<<a[i]*i+s[i]<<endl;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2560
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] strs = str.split(" ");
		int a = Integer.parseInt(strs[0]);
		int b = Integer.parseInt(strs[1]);
		int x = a * b;
		int y = (a*2)+(b*2);
		System.out.println(x + " " + y);
		br.close();
	}
}

Measured memory_bytes: 16896
#include<stdio.h>

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

	switch (d)
	{
	case 22:
		printf("%s", "Christmas Eve Eve Eve\n");
		break;
	case 23:
		printf("%s", "Christmas Eve Eve\n");
		break;
	case 24:
		printf("%s", "Christmas Eve\n");
		break;
	case 25:
		printf("%s", "Christmas\n");
		break;
	default:
		break;
	}
	return 0;
}

Measured memory_bytes: 128
n,l = map(int,input().split())
aji = 0
for i in range(1,n+1):
    aji += l+i-1
sa = 1e10
ans = 0
for i in range(1,n+1):
    ajii = 0
    for j in range(1,n+1):
        if i == j:
            continue
        ajii += l+j-1
    #print(sa,ajii,i)
    if abs(ajii-aji) < sa:
        sa = abs(ajii-aji)
        ans = ajii
print(ans)


Measured memory_bytes: 3060
import copy

n,x=map(int,input().split())

a=[int(x) for x in input().split()]
aa=copy.deepcopy(a)

ans=0
for i in range(n):
  if x<a[i]:
    a[i]=x

for i in range(n-1):
  if x<a[i]+a[i+1]:
    a[i+1]=x-a[i]

ans=sum(aa[i]-a[i] for i in range(n))
print(ans)

Measured memory_bytes: 91396
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), k = fs.nextInt();
		int ans = 0;
		while(n>0) {
			n /= k;
			ans ++;
		}
		System.out.println(ans);
		
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

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

	ll X, Y, A, B, C, N;
	cin >> X >> Y >> A >> B >> C;
	N = X + Y;
	multiset<ll> p;
	multiset<ll> q;
	multiset<ll> r;
	ll z;
	for (int i = 0; i < A; i++) { cin >> z; p.insert(z); }
	for (int i = 0; i < B; i++) { cin >> z; q.insert(z); }
	for (int i = 0; i < C; i++) { cin >> z; r.insert(z); }

	ll mp, mq, mr;
	ll maxtaste = 0;
	while (N > 0) {
		if (p.size() > 0 && X > 0) { mp = *p.rbegin(); }
		else { mp = 0; }
		if (q.size() > 0 && Y > 0) { mq = *q.rbegin(); }
		else { mq = 0; }
		if (r.size() > 0) { mr = *r.rbegin(); }
		else { mr = 0; }
//		cout << "A = " << mp << " B = " << mq << " C = " << mr << endl;
		if (mr <= mq && mp <= mq) {
			q.erase((++q.rbegin()).base());
			Y--;
			N--;
			maxtaste += mq;
//			cout << "Y " << mq << endl;
		}
		else if (mr <= mp && mq <= mp) {
			p.erase((++p.rbegin()).base());
			X--;
			N--;
			maxtaste += mp;
//			cout << "X " << mp << endl;
		}
		else {
			r.erase((++r.rbegin()).base());
			N--;
			maxtaste += mr;
//			cout << "Z " << mr << endl;
		}
	}
	cout << maxtaste << endl;
}






Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    if(N%2 == 0){
        cout<<0.5<<endl;
    }else{
        cout << fixed << setprecision(15) << (double)((N+1)/2)/(double)N << endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
vector<vector<ll> > a(3002,vector<ll> (3002,0));
vector<vector<vector<ll> > > dp(3002,vector<vector<ll> >(3002,vector<ll> (4,-1)));
ll x,y;
ll val(ll i,ll j,ll k=0){
    if(i>x || j>y)
    return 0;
    
    if(dp[i][j][k]!=-1)
    return dp[i][j][k];
    
    ll ans=0;
    if(a[i][j]==0)
    ans=max(val(i,j+1,k),val(i+1,j));
    else{
        if(k<3){
            ans=max(a[i][j]+val(i,j+1,k+1),a[i][j]+val(i+1,j));
            ans=max(ans,val(i,j+1,k));
        }
        else
        ans=max(val(i,j+1,k),val(i+1,j));
    }
    return dp[i][j][k]=ans;
}

int main() {
    fastio
	ll n,t,i,j,k;
	cin>>x>>y>>k;
	
	ll r,c,b;
	for(i=0;i<k;i++){
	    cin>>r>>c>>b;
	    a[r][c]=b;
	}
	
	cout<<val(1,1)<<endl;
	
	return 0;
}


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

int main(void)
{
	int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K;
	
	scanf("%d", &K);
	
	printf("%d", A[K-1]);
	
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

////////// 二項係数(N<=10^7) //////////

ll fac[MAX],finv[MAX],inv[MAX];
// fac[i] i!
// finv[i] i!の逆元
// inv[i] iの逆元

// テーブルを作る前処理
void COM_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(ll i=2; i<MAX; ++i){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

// 二項係数計算
ll COM(ll n,ll k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

//////////////////////////////////////////////////

int main(){
  ll N,M,K,ans=0;
  cin>>N>>M>>K;
  COM_init();
  
  ll POW3[1000001];
  POW3[0]=1;
  RREP(i,1000000) POW3[i]=POW3[i-1]*3%MOD;
  
  ll C=1,L=0,R=0;
  for(ll i=N; i<=N+M+K; ++i){
    ll cnt=POW3[N+M+K-i]*COM(i-1,N-1)%MOD,ccnt=0;
    
    if(i==N+M+1) L=1;
    if(i>N+M+1)  L=(L*2+COM(i-N-1,i-N-M-1))%MOD;
    if(i==N+K+1) R=1;
    if(i>N+K+1)  R=(R*2+COM(i-N-1,i-N-K-1))%MOD;
    
    ans+=cnt*(C-L-R)%MOD;
    ans%=MOD;
    C=C*2%MOD;
  }
  
  ans=(ans%MOD+MOD)%MOD;
  cout<<ans<<endl;
  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

template <typename T1, typename T2>
bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll D, T, S;
    cin >> D >> T >> S;
    prints()(D <= T * S ? "Yes" : "No");
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(nullptr), cout.tie(nullptr);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3608
// CODE FESTIVAL 2016 qual C
// C - 二人のアルピニスト / Two Alpinists

#include <cstdio>
#include <algorithm>
#define MAX_N 100000
#define MOD 1000000007
using namespace std;

typedef long long int ll;


int N;
int T[MAX_N + 2], A[MAX_N + 2];
bool is_clear;
ll ans;

int main() {

  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &T[i]);
  }
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
  }
  T[0] = 0;
  A[N + 1] = 0;

  ans = 1;
  for (int i = 1; i <= N; i++) {
    is_clear = false;
    if (T[i - 1] != T[i]) {
      if (T[i] > A[i]) {
        printf("%d\n", 0);
        return 0;
      }
      is_clear = true;
    }
    if (A[i] != A[i + 1]) {
      if (A[i] > T[i]) {
        printf("%d\n", 0);
        return 0;
      }
      is_clear = true;
    }
    if (!is_clear) {
      ans = ans * min(T[i], A[i]) % MOD;
    }
  }
  printf("%lld\n", ans);

  return 0;

}




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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353
const int INF = 1 << 28;



typedef ll number;
typedef vector<number> Vect; 
typedef vector<Vect> matrix;

ll L, A, B, M;

matrix identity(int n) {
    matrix A(n, Vect(n));
    for (int i = 0; i < n; ++i) A[i][i] = 1;
    return A;
}

Vect mul(const matrix &A, const Vect &x) {
    Vect y(A.size());
    for (int i = 0; i < A.size(); ++i)
        for (int j = 0; j < A[0].size(); ++j)
            y[i] = (y[i] + (A[i][j] * x[j]) % M ) % M;
    return y;
}

matrix mul(const matrix &A, const matrix &B) {
    matrix C(A.size(), Vect(B[0].size()));
    for (int i = 0; i < C.size(); ++i)
        for (int j = 0; j < C[i].size(); ++j)
            for (int k = 0; k < A[i].size(); ++k)
                C[i][j] = (C[i][j] + (A[i][k] * B[k][j]) % M ) % M;
    return C;
}


matrix pow(const matrix &A, ll e) {
    return e == 0 ? identity(A.size())  :
           e % 2 == 0 ? pow(mul(A, A), e / 2) : mul(A, pow(A, e - 1));
}


ll powten[20];
ll C[20];
void init () {
    powten[0] = 1;
    rep(i, 19) {
        powten[i + 1] = (powten[i] * 10) % M;
    }

    C[0] = 0;
    rep(i, 19) {
        ll x = (ll)pow(10, i + 1) - 1;
        ll y = (ll)pow(10, i) - 1;
        if (A + B * (L - 1) > x) {
            C[i + 1] = ( x >= A ? (x - A) / B + 1 : 0 )
                       - ( y >= A ? (y - A) / B + 1 : 0);
        }
        else {
            C[i + 1] = L - ( y >= A ? (y - A) / B + 1 : 0);
            break;
        }
    }
}



int main() {
    cin >> L >> A >> B >> M;
    init();

    Vect S{0, A % M, 1};

    vector<matrix> R(20, matrix(3, Vect(3, 0)));
    for (int d = 1; d <= 18 ; d++) {
        R[d][0][0] = powten[d];
        R[d][1][2] = B % M;
        R[d][0][1] = R[d][1][1] = R[d][2][2] = 1;
        S = mul(pow(R[d], C[d]) , S);
    }

    cout << S[0] << endl;

}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
  int n;
  bool ans = false;
  cin >> n;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (n == i * j) {
        ans = true;
        break;
      }
    }
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

bool solve();

int main()
{
	if (solve()) puts("Yes");
	else puts("No");

	return 0;
}

bool solve()
{
	int N;
	scanf("%d", &N);
	std::vector<int64_t> diff(N);	// b - a
	for (auto& e: diff)
	{
		int tmp;
		scanf("%d", &tmp);
		e -= tmp;
	}
	int64_t sum{};
	for (auto& e: diff)
	{
		int tmp;
		scanf("%d", &tmp);
		e += tmp;
		sum += e;
	}
	if (sum < 0) return false;
	int64_t two{sum}, one{sum};
	for (auto& e: diff)
	{
		if (e > 0)
		{
			int64_t tmp{(e + 1) / 2};
			if (tmp > two) return false;
			two -= tmp;
			e -= tmp * 2;
		}
		if (e < 0)
		{
			int64_t tmp{-e};
			if (tmp > one) return false;
			one -= tmp;
			e += tmp;
		}
	}

	return 2 * two == one;
}

Measured memory_bytes: 384
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN     PIC X(3).
01 a      PIC 9(1).
01 b      PIC 9(1).
01 n      PIC 9(1).
01 i      PIC 9(2).
01 ans    PIC X(9).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO a b.
  IF a < b
    MOVE b TO n
  ELSE
    MOVE a TO n
    MOVE b TO a
  END-IF.
  PERFORM VARYING i FROM 1 BY 1 UNTIL n < i
    MOVE a TO ans(i:1)
  END-PERFORM.
  DISPLAY ans(1:n).
  STOP RUN.


Measured memory_bytes: 1016
#include <stdio.h>

int main(void){
    int m;
    scanf("%d", &m);
    long long int ans = 0;
    long long int i, d, c;
    long long int sum = 0;
    for(i = 0; i < m; i++){
        scanf("%lld%lld", &d, &c);
        sum += c * d;
        ans += c;
    }
    ans--;
    
    ans += sum / 9;
    if(sum % 9 == 0){
        ans--;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1692
#include <bits/stdc++.h>
using namespace std;
int k, n;

int main()
{
    int k;
    cin>>k;
    int ans=0,x=k/500;
    k = k - x*500;
    ans+=x*1000;
    x=k/5;
    k = k - x*5;
    ans+=x*5;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace abc164_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] a = new string[n];
            for(int i = 0; i<n; i++)
            {
               a[i] = Console.ReadLine();
            }

            int keihin = 0;
            var hashset = new HashSet<string>();
            foreach (var v in a)
            {
                if (hashset.Add(v) == true)
                {
                    keihin++;
                }
            }
            Console.WriteLine(keihin);
            Console.Read();
        }
    }
}


Measured memory_bytes: 48816
def divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
div = divisors(n)

ans = 0
for d in div:
    if d-1 == 0:
        continue
    if n%(d-1) == n//(d-1):
        ans += d-1
print(ans)

Measured memory_bytes: 9128
import Control.Monad
ok (x,y) (h,w) s =
    (s !! y !! x == '.') || or [s !!(y+j)!!(x+i) == '#'|j <-[-1,0,1],i <- [-1,0,1] , abs(i-j) == 1,y+j < h,0<=y+j , x+i < w ,0<=x+i]

main = do
    [h,w] <- (map read . words) <$> getLine
    s <- replicateM h getLine
    if and [ok (i,j) (h,w) s | i <- [0..w-1],j <- [0..h-1]]
        then putStrLn "Yes"
        else putStrLn "No"
    return()

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  string t1;
  string t2;
  cin >> n >> s;
  if(n%2==1)cout <<"No";
  else{
    t1=s.substr(0,n/2);
    t2=s.substr(n/2);
    if(t1==t2)cout << "Yes";
    else cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    int X, K; cin >> X >> K;
    int r[K+1] = {0}; rep(i, K) cin >> r[i+1];
    int Q; cin >> Q;
    int t[Q+1] = {}, a[Q+1] = {}; rep(i, Q) cin >> t[i+1] >> a[i+1];

    int t1 = 0, t2 = 1;
    int A = 0, b = X, f = -1;
    int add = 0, diff = 0, c = 0, tmp = 0;

    while (t2 <= Q) {
        if (t[t2] > r[t1 + 1] && t1 < K) {
            t1++;
            add = f * (r[t1] - r[t1 - 1]);
            A += add; b += add;
            A = max(0, min(X, A));
            b = max(0, min(X, b));
            c += add;
            f *= -1;
        } else {
            diff = t[t2] - r[t1];
            tmp = max(A, min(b, a[t2] + c));
            tmp += diff * f;
            tmp = max(0, min(X, tmp));
			cout << tmp << endl;
			t2++;
        }
    }
    return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

long long int f(long long int A){
 int a;
 if(((A+1)/2)%2==0)a=1;
 else a=0;
 
 if(A%2==0)return A^a;
 else return a; 
}

int main(void){
 long long int A,B;
 cin>>A>>B;
 //cout<<f(A-1)<<endl; 
 //cout<<f(B)<<endl;
 cout<<(f(A-1)^f(B))<<endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d)cout<<"Left";
	if(a+b==c+d)cout<<"Balanced";
	if(a+b<c+d)cout<<"Right";
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;



int main()
{
	int n, m;
	cin >> n >> m;
	int k = m / n;
	while (k > 0) {
		if (m%k == 0) {
			cout << k << endl;
			return 0;
		}
		k--;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException {
        //Scanner sc = new Scanner(System.in);
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        PrintWriter out = new PrintWriter(System.out);
        String[] buf = reader.readLine().split(" ");
        int X= Integer.parseInt(buf[0]),Y =Integer.parseInt(buf[1]);
        int Z = Integer.parseInt(buf[2]), K = Integer.parseInt(buf[3]);
        long[] a = new long[X], b = new long[Y], c = new long[Z];
        buf = reader.readLine().split(" ");
        for(int i=0;i<X;i++) a[i]=Long.parseLong(buf[i]);
        buf = reader.readLine().split(" ");
        for(int i=0;i<Y;i++) b[i]=Long.parseLong(buf[i]);
        buf = reader.readLine().split(" ");
        for(int i=0;i<Z;i++) c[i]=Long.parseLong(buf[i]);
        //Arrays.sort(a); Arrays.sort(b); Arrays.sort(c);
        int idx=0;
        long[] bc = new long[Y*Z];
        for(int i=0;i<Y;i++){
            for(int j=0;j<Z;j++) bc[idx++] = b[i]+c[j];
        }
        Arrays.sort(bc);
        ArrayList<Long> dic = new ArrayList<>();
        int lower = Math.max(0,bc.length-K);
        for(long w:a){
            for(int i=bc.length-1;i>=lower;i--){
                dic.add(w+bc[i]);
            }
        }
        Collections.sort(dic,Collections.reverseOrder());
        for(int i=0;i<K;i++) out.println(dic.get(i));
        out.flush();
    }
}

Measured memory_bytes: 184336
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


const int N= 6115;
int t,n;

string s;





int32_t main()
{
	IOS;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i,j,k,l;
  int n;

  while(1){
    int a[11][11]={0};
    int b[11][11]={0};
    scanf("%d",&n);
    if(n==0)
      break;
    for(i=0;i<n;i++)
      for(j=0;j<n;j++)
	scanf("%d",&a[i][j]);

    for(i=0;i<n;i++)
      for(j=0;j<n;j++)
	a[i][n]+=a[i][j];
    for(j=0;j<n;j++)
      for(i=0;i<n;i++)
	a[n][j]+=a[i][j];
    for(i=0;i<n;i++)
      a[n][n]+=a[i][n];

    for(i=0;i<n+1;i++){
      for(j=0;j<n+1;j++)
	printf("%5d",a[i][j]);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){

    string S;
    cin >> S;
    ll K;
    cin >> K;

    int not1_index = -1;

    for(int i = 0; i < S.length(); i++){
        if(S[i]!='1'){
            not1_index = i;
            break;
        }
    }

    if(not1_index == -1){
        cout << 1 << endl;
    }else{
        if(K <= not1_index){
            cout << 1 << endl;
        }else{
            cout << S[not1_index] << endl;
        }
    }

    return 0;

}


Measured memory_bytes: 384
import sys,fractions
input = sys.stdin.readline

a,b = map(int,input().split())
g = fractions.gcd(a,b)

if g == 1:
    print(1)
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return len(arr)+1


print(factorization(g))


Measured memory_bytes: 77744
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define pb push_back
using namespace std;
const int maxn=210,inf=1e9;
int n,m,cnt=2,p[maxn],q[maxn];char s[maxn][maxn];
struct edge{int from,to,cap,flow;};
struct D{
    vector<edge> e;
    vector<int> G[maxn];
    int n,m,s,t,vis[maxn],d[maxn],cur[maxn];
    inline void add(int from,int to,int cap){
        e.pb((edge){from,to,cap,0});e.pb((edge){to,from,cap,0});
        m=e.size();G[from].pb(m-2);G[to].pb(m-1);
    }
    bool bfs(){
        memset(vis,0,sizeof(vis));memset(d,0,sizeof(d));
        queue<int> q;q.push(s);vis[s]=1;
        while(!q.empty()){
            int u=q.front();q.pop();
            rep(i,0,(int)G[u].size()-1){
                edge &E=e[G[u][i]];
                if(!vis[E.to]&&E.cap>E.flow){
                    d[E.to]=d[u]+1;
                    q.push(E.to);
                    vis[E.to]=1;
                }
            }
        }
        return vis[t];
    }
    int dfs(int u,int a){
        if(u==t||a==0) return a;
        int flow=0,f;
        for(int &i=cur[u];i<G[u].size();++i){
            edge &E=e[G[u][i]];
            if(d[E.to]==d[u]+1&&(f=dfs(E.to,min(E.cap-E.flow,a)))){
                E.flow+=f;e[G[u][i]^1].flow-=f;
                a-=f;flow+=f;
                if(!a) break;
            }
        }
        return flow;
    }
    int max_flow(int s,int t){
        this->s=s,this->t=t;
        int flow=0;
        while(bfs()){
            memset(cur,0,sizeof(cur));
            flow+=dfs(s,inf);
        }
        return flow;
    }
}D;
int main(){
    scanf("%d%d",&n,&m);int S=1,T=2;
    rep(i,1,n) rep(j,1,m){
        scanf(" %c",&s[i][j]);
        if(s[i][j]=='S'){
            if(p[i]||q[j]) return puts("-1"),0;
            p[i]=S,q[j]=S;
        }
        if(s[i][j]=='T'){
            if(p[i]||q[j]) return puts("-1"),0;
            p[i]=T,q[j]=T; 
        }
    }
    rep(i,1,n) if(!p[i]) p[i]=++cnt;
    rep(i,1,m) if(!q[i]) q[i]=++cnt;D.n=cnt;
    rep(i,1,n) rep(j,1,m) if(s[i][j]=='o') D.add(p[i],q[j],1);
    printf("%d\n",D.max_flow(S,T));
    return 0;
}

Measured memory_bytes: 892