akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> point;
typedef pair<char,point> P;
string ban[500];
int n,m;
vector<point> v;//このターンで消すブロックの座標
set<int> gyou;//前のターンで消した行
set<int> retsu;//前のターンで消した列
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
//座標としてban[x][y]を選んだときに消せる座標をvに追加する
void checkAndErase(int x,int y)
{
	if(ban[x][y]!='.')
		return;
	vector<P> ret;
	//4方向調べる
	for(int i=0;i<4;i++)
	{
		int nx=x;
		int ny=y;
		bool f=false;
		while(nx>=0 && nx<m && ny>=0 && ny<n)
		{
			if(ban[nx][ny]!='.')
			{
				f=true;
				break;
			}
			nx+=dx[i];
			ny+=dy[i];
		}
		if(f)
			ret.push_back(P(ban[nx][ny],point(nx,ny)));
	}
	sort(ret.begin(),ret.end());
	//同じ文字が含まれているか確認する
	for(int i=1;i<ret.size();i++)
	{
		if(ret[i].first==ret[i-1].first)
		{
			v.push_back(ret[i].second);
			v.push_back(ret[i-1].second);
		}
	}
	return;
}

int main()
{
	cin>>m>>n;
	int ans=0;
	for(int i=0;i<m;i++)
		cin>>ban[i];
	for(int i=0;i<500;i++)
		gyou.insert(i);
	do{
		v.clear();
		//全座標の点の部分を調べる
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(!(gyou.count(i)==1 || retsu.count(j)==1))
					continue;
				checkAndErase(i,j);
			}
		}
		//重複を取り除いて消す
		if(v.size()==0)
			break;
		gyou.clear();
		retsu.clear();
		sort(v.begin(),v.end());
		v.erase(unique(v.begin(),v.end()),v.end());
		for(int i=0;i<v.size();i++)
		{
			ans++;
			ban[v[i].first][v[i].second]='.';
			gyou.insert(v[i].first);
			retsu.insert(v[i].second);
		}
	}while(1);
	cout<<ans<<endl;
	return 0;
}



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

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
#define mp            make_pair
typedef long long     ll;



int main()
{


  ll a,b;
  cin>>a>>b;
  if(a==2||b==2){
    cout<<"No";
  }else{
  cout<<"Yes";
  }

   }



Measured memory_bytes: 256
from collections import Counter
from decimal import *

N = int(input())
dp = [0]*(10**5+1)
A = []
for n in input().split():
    n = int(n)
    dp[n] += 1
    A.append(n)
ans = sum(A)
Q = int(input())
for _ in range(Q):
    B, C = [int(n) for n in input().split()]
    diff = dp[B] * (C-B)
    ans += diff
    print(ans)
    dp[C] += dp[B]
    dp[B] = 0


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

int main() {
	long long n;
	cin>>n;
	long long u=n-1,i,x;
	
	for(long long i=1;i<=ceil(sqrt(n));i++)
	{
	
		if((n%i)==0)
		{
			long long x = n/i;
			if(i+x-2<u)
			{
				u=i+x-2;
			}
			
		}
	}
	cout<<u;
	return 0;
}

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

int main()
{
  	int N;
  	cin >> N;
	float sum;  	
  	for(int i=1; i<=N; i++){
      	float value;
      	string unit;
      	cin >> value;
      	cin >> unit;
      	if(unit=="BTC"){
        	value *= 380000.0;
        }
      	sum += value; 
    }
  	cout << sum;
    return 0;
}

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

int main() 
{
	int n , k;
	cin >> n >> k;
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 1 ; i < s.length() ; i++)
		if(s[i] == s[i - 1])
			ans++;
	ans = min(2 * k + ans , n -1); 
	cout << ans << "\n";
	return 0;
}

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

const int N = 1e5 + 5;

int dp [N][2];
int arr [N];
int n;

int solve (int p, bool changed) {
  if (p >= n) return true;
  int &res = dp[p][changed];
  if (~res) return res;
  res = 0;
  int ant = arr[p - 1] - changed;
  if (arr[p] < ant) return 0;
  if (arr[p] == ant) {
    res |= solve (p + 1, 0);
  } else {
    res |= solve (p + 1, 0);
    res |= solve (p + 1, 1);
  }
  return res;
}

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  memset (dp, -1, sizeof(dp));
  cout << (solve (1, false)?"Yes":"No") << '\n';
  return 0;
}


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

int n,m,an=1e9;
int d[1000];
int c[1000];
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>d[i];
    for(int i=0;i<m;i++)cin>>c[i];
    vector<vector<int> >vec(n+2,vector<int>(m+2,1e9));
    vec[0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            vec[i][j+1]=min(vec[i][j+1],vec[i][j]);
            vec[i+1][j+1]=min(vec[i+1][j+1],vec[i][j]+c[j]*d[i]);
        }
    }
    for(int i=0;i<=m;i++)
        an=min(an,vec[n][i]);
    cout<<an<<endl;
}

Measured memory_bytes: 4172
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt(); 
		
		int x = stdIn.nextInt();
		
		int[] l = new int[n];
		
		for(int i = 0; i < n; i++) {
			l[i] = stdIn.nextInt();
		}
		
		
		int cnt = 1;
		int length = 0;
		
		for(int i = 0; i < n; i++) {
			if(l[i] + length <= x) {
				cnt++;
				length += l[i];
			}else {
				break;
			}
		}
		System.out.println(cnt);
		
	}

}


Measured memory_bytes: 25172
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int n,k,q,x,y;
	cin>>n>>k>>q;
	x = k-q;
	vi d(n+1,x);
	while(q--){
		cin>>y;
		d[y]++;
		}
	for1(i,n){
		if(d[i]>0) pf("Yes\n");
		else pf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxM = 1e5+7;
const int maxV = 90010;
 
const int MOD = 1e9+7;
 
int T;
const int maxN = 1e5+8;
const ll INF = 1000000000000000010LL;
const int K = 15;
ll a[maxN];
ll b[maxN];
int n;



int main() {
	
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int f = 0;
	for(int i=n;i>=2;i--)
	{
		if(a[i]>=a[i-1])continue;
		else if(a[i] == a[i-1]-1)
		{
			a[i-1]--;
		}
		else if(a[i] < a[i-1]-1)
		{
			f = 1;
			break;
		}
		
	}
	if(f == 1)
	{
		puts("No");	
	}
	else
		puts("Yes");
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e9+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(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; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }


int main()
{
	//int ans = 0;
	int n;
	cin >> n;

	n += 1;
	vdef a(n, 0);
	for (int i = 1; i < n; ++i) cin >> a[i];

	vdef b(n, 0);
	vdef ans;

	for (int i = n - 1; i > 0; --i)
	{
		int sum = 0;
		for (int j = 2; i*j < n; ++j)
		{
			sum += b[i*j];
		}

		if (sum % 2 != a[i])
		{
			b[i] = 1;
			ans.emplace_back(i);
		}
	}

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

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

Measured memory_bytes: 3064
# coding: utf-8
from functools import reduce


def solve(*args: str) -> str:
    a_max = 1+12*10**5
    n, m = map(int, args[0].split())
    cache = {}

    for i in range(1, 1+2*m, 2):
        a, _ = map(int, args[i].split())
        c = reduce(
            lambda x, y: x | 1 << y-1,
            [0] + list(map(int, args[i+1].split()))
        )
        cache[c] = min(cache.get(c, a_max), a)

    for C in tuple(cache.items()):
        unlocked, cost = C
        for E in tuple(cache.items()):
            c, a = E
            cache[unlocked | c] = min(
                cache.get(unlocked | c, a_max),
                a + cost
            )

    return str(cache.get(2**n-1, -1))


if __name__ == "__main__":
    nm = input()
    _, m = map(int, nm.split())
    print(solve(*([nm]+[input() for _ in range(2*m)])))


Measured memory_bytes: 4584
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N, M;
long long A[100005];
long long memo[100005];


//th以上になる数
long long count_num(long long th) {
	long long num = 0;

	rep(i, N) {
		long long rest = th - A[i];

		long long start = -1;
		long long end = N;
		while(start + 1 < end) {
			long long mid = (start + end)/2;
			if(A[mid] >= rest) {
				start = mid;
			} else {
				end = mid;
			}
		}
		num += (start + 1);
	}
	return num;
}

long long cal(long long th) {
	long long num = 0;
	long long ans = 0;

	rep(i, N) {
		long long rest = th - A[i];

		long long start = -1;
		long long end = N;
		while(start + 1 < end) {
			long long mid = (start + end)/2;
			if(A[mid] >= rest) {
				start = mid;
			} else {
				end = mid;
			}
		}


		num += (start + 1);
		//A[i]を何回使う？
		ans += A[i] * (start + 1);
		ans +=  memo[start+1];
	}
	if(num > M) {
		ans -= (num-M) * th;
	}
	return ans;
}

int main(){
	cin >> N >> M;
	rep(i, N) cin >> A[i];
	sort(A, A + N, greater<long long>());
	rep(i, N) memo[i+1] = memo[i] + A[i];

	long long start = 0;
	long long end = 200005;

	//M回目に作るパワーを見つける
	while(start + 1 < end) {
		long long mid = (start + end)/2;
		if(count_num(mid) < M) {
			end = mid;
		} else {
			start = mid;
		}
	}
	cout << cal(start) << endl;
}


Measured memory_bytes: 5160
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll in;
    cin>>in;
    cout<<in*in<<endl;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var e = int.Parse(Console.ReadLine().Trim());
            if (e == 0) break;
            Console.WriteLine(getM(e));
        }
    }
    public static int getM(int e)
    {
        var ret = 999999999;
        
        for (int z = 0; z*z*z <= e; z++)
        {
            var z3 = z * z * z;
            var y = (int)Math.Sqrt(e - z3);
            var y2 = (int)Math.Pow(y, 2);
            var x = e - z3 - y2;
            ret = Math.Min(ret, x + y + z);
        }
        return ret;
    }
}

Measured memory_bytes: 9368
#include<bits/stdc++.h>
using namespace std;
#define NIL -1

int main(){
  int n, q;
  cin >> n >> q;
  int a, b, p[n];
  p[1] = NIL;
  for ( int i = 0; i < n-1; i++){
    cin >> a >> b;
    p[b] = a;
  }
  int p_i, x, c[n+1], c_root[n+1];
  // init
  for ( int i = 1; i <= n; i++ ){
    c[i] = c_root[i] = 0;
  }
  for ( int i = 0; i < q; i++){
    cin >> p_i >> x;
    c_root[p_i] += x;
  }

  for ( int i = 1; i <= n; i++){
    c[i] = c[p[i]] + c_root[i];
  }

  for ( int i = 1; i <= n; i++){
    if ( i > 1) cout << " ";
    cout << c[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 4736
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    char[][] s = new char[H][W];
    int[][] c = new int[H][W];
    for (int i = 0; i < H; i++) {
      s[i] = sc.next().toCharArray();
    }
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (s[i][j] == '#') {
          continue;
        }
        int count = 0;
        if (i >= 1 && j >= 1 && s[i - 1][j - 1] == '#') {
          count++;
        }
        if (i >= 1 && s[i - 1][j] == '#') {
          count++;
        }
        if (i >= 1 && j < W - 1 && s[i - 1][j + 1] == '#') {
          count++;
        }
        if (j >= 1 && s[i][j - 1] == '#') {
          count++;
        }
        if (j < W - 1 && s[i][j + 1] == '#') {
          count++;
        }
        if (i < H - 1 && j >= 1 && s[i + 1][j - 1] == '#') {
          count++;
        }
        if (i < H - 1 && s[i + 1][j] == '#') {
          count++;
        }
        if (i < H - 1 && j < W - 1 && s[i + 1][j + 1] == '#') {
          count++;
        }
        c[i][j] = count;
      }
    }
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (s[i][j] == '#') {
          System.out.print("#");
        } else {
          System.out.print(c[i][j]);
        }
      }
      System.out.println();
    }
  }
}

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

int main(){
    int n;
    cin >> n;
    int a[n][26] = {};
    rep(i, n){
        string s;
        cin >> s;
        rep(j, s.size()){
            a[i][s[j]-'a']++;
        }
    }
    rep(j, 26){
        int MIN=50;
        rep(i, n){
            MIN = min(MIN, a[i][j]);
        }
        rep(i, MIN){
            cout << (char)('a'+j);
        }
    }
    cout << endl;
    // printf("%d\n", N);
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int K; cin >> K;
	
	ll sum = 0;
	for (int a = 1; a <= K; a++) {
		for (int b = 1; b <= K; b++) {
			for (int c = 1; c <= K; c++) {
				sum += gcd(a, gcd(b, c));
			}
		}
	}
	cout << sum << endl;
}

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


Measured memory_bytes: 3692
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    long long L,R,min=2018;
    cin>>L>>R;
    if(R-L>=672)cout<<0<<endl;
    else {
        for(long long l=L;l<R;l++){
            for(long long r=l+1;r<=R;r++){
                if((l*r)%2019<min)min=(l*r)%2019;
            }
        }
        cout<<min<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
O=list(input())
E=list(input())
S=[]
if len(O)>len(E):
    for i in range(len(E)):
        S.append(O[i])
        S.append(E[i])
    S.append(O[-1])
else:
    for i in range(len(E)):
        S.append(O[i])
        S.append(E[i])
print(''.join(S))

Measured memory_bytes: 3060
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << "\n";
}

int main() {
    io;
    int t = 1;
    tc(t) {
        solve();
    }
}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int c[][] = new int[3][3];
		boolean b = true;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				c[i][j] = sc.nextInt();
			}
		}
		loop: for (int i = 0; i < 2; i++) {
			for (int j = i + 1; j < 3; j++) {
				if (c[i][0] - c[j][0] == c[i][1] - c[j][1] && c[i][1] - c[j][1] == c[i][2] - c[j][2]) {

				} else {
					b = false;
					break loop;
				}
			}
		}

		loop: for (int i = 0; i < 2; i++) {
			for (int j = i + 1; j < 3; j++) {
				if (c[0][i] - c[0][j] == c[1][i] - c[1][j] && c[1][i] - c[1][j] == c[2][i] - c[2][j]) {

				} else {
					b = false;
					break loop;
				}
			}
		}

		if (b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

const int MAX_N = 5001;
const int MAX_K = 5001;

bool up[MAX_N][MAX_K];
bool down[MAX_N][MAX_K];

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

  int N, K;
  cin >> N >> K;
  vector<ll> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];

  for(int i = 0; i < MAX_N; i++){
    for(int j = 0; j < MAX_K; j++){
      up[i][j] = false;
      down[i][j] = false;
    }
  }

  up[0][0]   = true;
  down[0][0] = true;

  for(int i = 0; i < N; i++){
    for(int j = 0; j < MAX_K; j++){
      
      if(up[i][j]){
        up[i+1][j] = true;
        up[i+1][min(j+a[i], 5000LL)] = true;
      }
    }
  }

  for(int i = 0; i < N; i++){
    for(int j = 0; j < MAX_K; j++){

      if(down[i][j]){
        down[i+1][j] = true;
        down[i+1][min(j+a[N-i-1], 5000LL)] = true;
      }
    }
  }

  int ans = 0;
  for(int i = 0; i < N; i++){
    vector<int> vup;
    vector<int> vdown;

    bool ok = true;
    for(int j = 0; j < MAX_K; j++){
      if(up[i][j]) vup.push_back(j);
      if(down[N-(i+1)][j]) vdown.push_back(j);
    }

    for(int j = 0; j < vup.size(); j++){
      auto itr1 = lower_bound(vdown.begin(), vdown.end(), K-a[i]-vup[j]);
      auto itr2 = lower_bound(vdown.begin(), vdown.end(), K-vup[j]);
      if(itr1 != itr2){
        ok = false;
      }
    }
    if(ok){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 49280
n, d = map(int, input().split(" "))
p = []
ans = 0
for i in range(n):
    p.append(list(map(int, input().split(" "))))

for i, [x, y] in enumerate(p):
    if(x > d or y > d):
        continue
    if(x**2 + y**2 <= d**2):
        ans += 1


print(ans)

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

int main(){

    int a,b;

    scanf("%d",&a);
    scanf("%d",&b);

    int luas  = (a -1) * (b -1);
    printf("%d",luas);



    //((1xp)+(1xl)-1x1) ((1*a)+(1*b)-1*1);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=2e5;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  string a,b;cin>>a>>b;
  int cnt=0;
  for(int i=0;i<a.size();i++)
    if(a[i]==b[i])cnt++;
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
tmp = list(map(int, (input().split())))
n = tmp[0]
q = tmp[1]

#edge = defaultdict(list)
edge = [[] for i in range(n+1)]
fixed = [False] * (n + 1)
fixed[1] = True
point = [0] * (n + 1)

for i in range(1, n):
  tmp = list(map(int, (input().split())))
  edge[tmp[0]].append(tmp[1])
  edge[tmp[1]].append(tmp[0])

for i in range(1, q+1):
  tmp = list(map(int, (input().split())))
  point[tmp[0]] += tmp[1]

que = []
que += edge[1]
frm = 1

while len(que) != 0:
  cur = que.pop()
  for i in edge[cur]:
    if fixed[i]:
      point[cur] += point[i]
    else:
      que.append(i)
  fixed[cur] = True

for i in range(1, n+1):
  print (point[i], end=" ")

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

long long N, X[1009], Y[1009], H[1009]; vector<tuple<long long, long long, long long>>vec;

int main() {
	cin >> N; tuple<long long, long long, long long>G = make_tuple(-1, -1, -1);
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i] >> H[i];
		if (H[i] >= 1) G = make_tuple(X[i], Y[i], H[i]);
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			long long V = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j); V = max(V, 0LL); bool flag = true;
			for (int k = 1; k <= N; k++) {
				long long VV = V - abs(X[k] - i) - abs(Y[k] - j); VV = max(VV, 0LL);
				if (H[k] != VV) flag = false;
			}
			if (flag == true) vec.push_back(make_tuple(i, j, V));
		}
	}
	if (vec.size() == 1) {
		cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.tk
*/
#include <bits/stdc++.h>
using namespace std;

template<class T>
inline T read(T &a)
{
    register T x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
    return a = x * flag;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

int main() {
	int x;
	read(x);
	x ^= 1;
	cout << x << endl;
}


Measured memory_bytes: 3560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,m;
int main() {
	cin>>n>>m;
	if(n%((2*m+1))==0){
		cout<<n/((2*m+1));
	}
	else cout<<n/((2*m+1))+1;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
void era_transform(int year, int month, int day);
 
int main(void)
{
    int year, month, day;
    while (scanf("%d %d %d", &year, &month, &day) != EOF) {
        era_transform(year, month, day);
    }
    return 0;
}
 
void era_transform(int year, int month, int day)
{
    int date_number = year * 10000 + month * 100 + day;
    int meiji_number = 1868 * 10000 + 9 * 100 + 8;
    int taisho_number = 1912 * 10000 + 7 * 100 + 30;
    int showa_number = 1926 * 10000 + 12 * 100 + 25;
    int heisei_number = 1989 * 10000 + 1 * 100 + 8;
    if (date_number < meiji_number) {
        printf("pre-meiji\n");
    } else if (date_number < taisho_number) {
        printf("meiji %d %d %d\n", year - 1867, month, day);
    } else if (date_number < showa_number) {
        printf("taisho %d %d %d\n", year - 1911, month, day);
    } else if (date_number < heisei_number) {
        printf("showa %d %d %d\n", year - 1925, month, day);
    } else {
        printf("heisei %d %d %d\n", year - 1988, month, day);
    }
}

Measured memory_bytes: 1036
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define mor > muu & operator << (
#define R22(r) sim > typename \
  enable_if<1 r sizeof dud<c>(0), muu&>::type operator<<(c g) {
sim > struct rge { c b, e; };
sim > rge<c> range(c h, c n) { return {h, n}; }
sim > auto dud(c* r) -> decltype(cerr << *r);
sim > char dud(...);
struct muu {
#ifdef LOCAL
stringstream a;
~muu() { cerr << a.str() << endl; }
R22(<) a << boolalpha << g; ris; }
R22(==) ris << range(begin(g), end(g)); }
sim, class b mor pair < b, c > r) { ris << "(" << r.first << ", " << r.second << ")"; }
sim mor rge<c> u) {
  a << "[";
  for (c i = u.b; i != u.e; ++i)
    *this << ", " + 2 * (i == u.b) << *i;
  ris << "]";
}
#else
sim mor const c&) { ris; }
#endif
muu & operator()() { ris; }
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")

using ld = long double;
int n;

ld dp[307][307][307];
bool jest[307][307][307];

ld licz(int a, int b, int c) {
    debug << "wywo " << a << ' ' << b << ' ' << c;
    if (jest[a][b][c]) return dp[a][b][c];
    ld p1 = (ld) a / n;
    ld p2 = (ld) b / n;
    ld p3 = (ld) c / n;
    
    ld wyn = 0.;
    if (a) wyn += p1 * (licz(a - 1, b, c) + 1.);
    if (b) wyn += p2 * (licz(a + 1, b - 1, c) + 1.);
    if (c) wyn += p3 * (licz(a, b + 1, c - 1) + 1.);
    
    wyn += 1. - p1 - p2 - p3;
    wyn /= p1 + p2 + p3;
    dp[a][b][c] = wyn;
    jest[a][b][c] = 1;
    
    debug << a << ' ' << b << ' ' << c << ' ' << wyn;
    return wyn;
}

int main() {
    cin >> n;
    int a, b, c;
    a = b = c = 0;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        if (x == 1) a++;
        else if (x == 2) b++;
        else c++;
    }
    
    jest[0][0][0] = 1;
    dp[0][0][0] = 0.;
    cout.precision(15);
    cout << fixed << licz(a, b, c) << endl;
    return 0;
}


Measured memory_bytes: 471296
n  = []
while True:
    try:
        n.append(int(raw_input()))
    except:
        break

R = max(n)+1
p = [1]*R
p[0] = p[1] = 0
i = 2
while i*i <= R:
    if p[i]:
        p[2*i::i] = [0 for x in range(2*i,R,i)]
    i += p[i+1:].index(1)+1
for i in n:
    print sum(p[:i+1])

Measured memory_bytes: 35632
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>
#include <list>

using namespace std;
#define ll long long int

#define rep(i,n) for(int i = 0;i<n;i++)
const ll mod = 1e9 + 7;


int main(void) {

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

	int a;
	cin >> a;
	cout << a * (a * (a + 1) + 1) << endl;




	return 0;
}


Measured memory_bytes: 3648
//
// Created by yoshihito.hotta on 2018/06/10.
//
#include <iostream>
#include <algorithm>

using namespace std;

bool isstable(char *c1, char *c2, int n) {
    bool flag = true;
    for (int i = 0; i < n; i++) {
        if (c1[i] != c2[i]) {
            flag = false;
            break;
        }
    }

    return flag;
}

void bubble(int *a, char *c, int n) {
    for (int i = 0; i < n; i++) {
        int j = n - 1;
        while (j > i) {
            if (a[j] < a[j - 1]) {
                swap(a[j], a[j - 1]);
                swap(c[j], c[j - 1]);
            }
            j--;
        }
    }
}

void selection(int *a, char *c, int n) {
    for (int i = 0; i < n; i++) {
        int minj = i;
        int mina = a[i];
        for (int j = i; j < n; j++) {
            if (a[j] < mina) {
                minj = j;
                mina = a[j];
            }
        }
        swap(a[i], a[minj]);
        swap(c[i], c[minj]);
    }
}

int main() {
    int n;
    int *a1, *a2;
    char *c1, *c2;

    cin >> n;
    a1 = new int[n];
    a2 = new int[n];
    c1 = new char[n];
    c2 = new char[n];

    for (int i = 0; i < n; i++) {
        cin >> c1[i] >> a1[i];
        c2[i] = c1[i];
        a2[i] = a1[i];
    }
    bubble(a1, c1, n);
    selection(a2, c2, n);
    for (int i = 0; i < n; i++) {
        if(i) cout << " ";
        cout << c1[i] << a1[i] ;
    }
    cout << endl;
    cout << "Stable" << endl;
    for (int i = 0; i < n; i++) {
        if(i) cout << " ";
        cout << c2[i] << a2[i] ;
    }
    cout << endl;

    if (isstable(c1, c2, n)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    return 0;
}




Measured memory_bytes: 3096
#include <iostream>
#include <vector>
using namespace std;
long long INF = 1e18;
struct edge{
    int from;
    int to;
    long long cost;
};
void solve(int N, int M, vector<edge> &es, int s, int t){
    vector<long long> d(N);//各頂点までの距離
    for(int i = 0; i < N; i++) d[i] = INF;
    d[s] = 0;
    long long k = 0;
    long long ans = 0;
    while(true){
        bool flag = false;
        for(int i = 0; i < M; i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                flag = true;
            }
        }
        if(!flag || k == N) break;
        k++;
    }
    ans = min(ans, d[t]);
    k = 0;
    vector<bool> judge(N, false);
    while(true){
        for(int i = 0; i < M; i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                judge[e.to] = true;
            }
            if(judge[e.from]) judge[e.to] = true;
        }
        k++;
        if(k == N) break;
    }
    if(judge[t]) cout << -1 << endl;
    else cout << -ans << endl;
}
int main(){
    int N, M;
    cin >> N >> M;
    long long P;
    cin >> P;
    vector<edge> es(M);
    for(int i = 0; i < M; i++){
        int x, y;
        long long c;
        cin >> x >> y >> c;
        x--;
        y--;
        edge e = {x, y, -c + P};
        es[i] = e;
    }
    solve(N, M, es, 0, N - 1);
}

Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n;
	while(cin >> n,n){
		int data[101][101] = {0};
		rep(i,n)rep(j,n)
			cin >> data[i][j] , data[n][n] += data[i][j];
		rep(i,n){
			int s = 0;
			rep(j,n) s+= data[i][j];
			data[i][n] = s;
		}
		rep(i,n){
			int s = 0;
			rep(j,n) s+= data[j][i];
			data[n][i] = s;
		}
		rep(i,n+1){
			rep(j,n+1)
				printf("%5d",data[i][j]);
			cout << endl;
		}
	}
}

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

int main() {
  int n,d[110],s=0; cin>>n;
  for(int i=0;i<n;i++) cin>>d[i];
  for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) s+=d[i]*d[j];
  cout<<s;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<string> A(N), B(M);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < M; ++i) {
    cin >> B[i];
  }

  bool ans = false;
  for (int i = 0; i < N; ++i) {
    if (i + M > N ) { break; }
    string::size_type col = -1;
    while ((col = A[i].find(B[0], col + 1)) != string::npos) {
      bool ok = true;
      for (int j = 1; j < M; ++j) {
        if (A[i + j].find(B[j], col) != col) {
          ok = false;
          break;
        }
      }
      if (ok) {
        ans = true;
        break;
      }
    }
    if (ans) { break; }
  }
  printf("%s\n", ans ? "Yes" : "No");
  return 0;
}


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

using namespace std;
map<string,int> M;
int main(){
    int N;
    cin >> N;
    map<string,int>::iterator ite;
    
    for(int i=0;i<N;i++){
        string s;
        cin >> s;
        ite = M.find(s);
        if(ite==M.end()){
            M.insert(make_pair(s,1));
        }else{
            M[ite->first]++;
        }
    }
    int Ma;cin >> Ma;
    for(int i=0;i<Ma;i++){
        string s;
        cin >> s;
        ite = M.find(s);
        if(ite==M.end()){
            M.insert(make_pair(s,0));
        }else{
            if(M[ite->first]==0){
                M[ite->first]=0;
            }else M[ite->first]--;
        }
    }

    int max = 0;
    for(ite=M.begin();ite!=M.end();ite++){
        if(ite->second>max){
            max = ite->second;
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
// vector<vector<int>> d(300,vector<int>(300,INF));
ll d[301][301];
ll d2[301][301];
void warshall_floyd(int V){
	for(int k = 1;k <= V;k++){
		for(int i = 1;i <= V;i++){
			for(int j = 1;j <= V;j++){
				d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
			}
		}
	}
}

void warshall_floyd2(int V){
	for(int k = 1;k <= V;k++){
		for(int i = 1;i <= V;i++){
			for(int j = 1;j <= V;j++){
				d2[i][j] = min(d2[i][j],d2[i][k] + d2[k][j]);
			}
		}
	}
}
int main(){
	int n,m;
	ll l,A,B,C;
	cin >> n >> m >> l;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			d[i][j] = INF;
			d2[i][j] = INF;
			if (i == j) {
				d[i][j] = 0;
				d2[i][j] = 0;
			}
		}
	}

	for(int i= 0;i< m;i++){
		cin >> A >> B >> C;
		if (C <= l){
			d[A][B] = C;
			d[B][A] = C;
		}	
	}
	warshall_floyd(n);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			if (d[i][j] <= l){
				d2[i][j] = 1;
			}
		}
	}
	warshall_floyd2(n);
	int q;cin>>q;
	for(int i = 0; i < q; i++) {
		int s,t;cin>>s>>t;
		if (d2[s][t] == INF){
			cout << -1 << endl;
		}
		else{
			cout << d2[s][t] - 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    long H;

    cin >> H;
    cin >> N;
    long sum_damage = 0;

    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum_damage += A[i];
    }
    
    if(sum_damage >= H){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author KY2001
 */


#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

class CMultipleGift {
public:
  int solve(std::istream &cin, std::ostream &cout) {
    int X, Y;
    cin >> X >> Y;
    int ans = 1;
    while (X < Y) {
      X *= 2;
      if (X <= Y) {
        ans += 1;
      }
    }
    cout << ans << endl;
  }
};


signed main() {
	CMultipleGift solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
// Author : Mohamed Sameh
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
typedef long long ll ;
using namespace std ;
const int M = 2e5+1 ; 
int n ;
int a[M];
int frq[M];
ll ways[M];
ll ans ; 
int main()
{
    scanf("%d" , &n );
    for (int i =0 ; i < n ;i++)
    {
        scanf("%d" ,a+i);
        frq[a[i]]++;
    }
    for (int i = 1; i <= n ;i++)
    {
        ways[i] = (1LL*frq[i] * (frq[i]-1) )/2 ; 
        ans += ways[i]; 
    }
    for (int i =0 ; i < n ;i++)
    {
        ll cur = ans ; 
        cur -= ways[ a[i] ]; 
        cur += (1LL * (frq[ a[i] ]-1) * (frq[ a[i] ]-2) )/2 ; 
        printf ("%lld\n" , cur ); 
    }


}


Measured memory_bytes: 5248
/*
#include <bits/stdc++.h>
//*/
//*
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
//*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
    const long long INF = LLONG_MAX / 10;
#else
    const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;

int H, W, d;
char grid[2020][2020];
char ansGrid[3000][3000];

signed main()
{
    cin >> H >> W >> d;
    for (int y=0; y<2020; y++) {
        for (int x=0; x<2020; x++) {
            if ((y / d) % 2 == 0) {
                if ((x / d) % 2 == 0) grid[y][x] = 'R';
                else grid[y][x] = 'Y';
            } else {
                if ((x / d) % 2 == 0) grid[y][x] = 'G';
                else grid[y][x] = 'B';
            }
        }
    }

    /*
    REP(i,10) {
        REP(j,10) {
            cout << grid[i][j];
        }
        cout << endl;
    }*/

    REP(y,2020) {
        REP(x,2020) {
            int X = (x + y) / 2;
            int Y = (x - y) / 2;
            if (0 < X && X < 3000 && 0 < Y && Y < 3000) {
                ansGrid[X][Y] =grid[x][y];
            }
        }
    }

    for (int y=W; y<W+H; y++) {
        for (int x=1; x<=W; x++) {
            cout << ansGrid[y][x];
        }
        cout << endl;
    }

/*
    REP(i,10) {
        REP(j,10) {
            cout << ansGrid[i][j];
        }
        cout << endl;
    }
    */
}


Measured memory_bytes: 11264
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main() {
    char s[15], t[15];
    scanf("%s %s", s, t);
    bool ok = 1;
    for (int i = 0; i < strlen(s); i++) {
        if (s[i] != t[i]) ok = 0;
    }
    if (ok) printf("Yes\n");
    else printf("No\n");
}

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

using namespace std;
typedef long long ll;
struct ITEM{
    ll money;
    ll delay;
    bool operator < (const ITEM &rhs) const {
        if(delay == rhs.delay) {
            return money > rhs.money;
        } else return delay < rhs.delay;
    }
}item[int(1e5+10)];

struct DATA{
    ll money, delay;
    bool operator < (const DATA &rhs) const {
        if(money == rhs.money) {
            return delay > rhs.delay;
        } else return money < rhs.money;
    }
};

priority_queue<DATA> pq;
int n, m;

int main() {
    cin >> n >> m;
    for(int i = 0; i < n; ++i) {
        cin >> item[i].delay >> item[i].money;
    }
    sort(item, item+n);
    // cout << "---" << endl;
    // for(int i = 0; i < n; ++i) {
    //     cout << item[i].delay << " " << item[i].money <<endl;
    // }
    while(!pq.empty()) pq.pop();
    int cnt = 0;
    ll ans = 0;
    // cout << "ok" << endl;
    for(int i = 1; i <= m; ++i) {
        // cout << "here" <<  i << endl;
        while(cnt < n && item[cnt].delay <= i) {
            // cout << "in " << cnt << endl; 
            pq.push({item[cnt].money, item[cnt].delay});
            cnt ++;
        }
        if(!pq.empty()) {
            DATA temo = pq.top(); pq.pop();
            // cout << "get " << temo.delay << " " << temo.money << endl;
            ans += temo.money;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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 long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b;
  cin>>a>>b;
  if(a%3==b%3&&a%3>0)cout<<"Impossible"<<endl;
  else cout<<"Possible"<<endl;
  

  return 0;

}


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

typedef long long int LL;

LL f2(LL a, LL b) {
    return (a%2==0) ? (a/2)*(a-1) : ((a-1)/2)*a;
}

int main()
{
    LL i,n,x;
    cin>>n;
    map<LL,LL> MP;
    vector<LL> arr;
    
    for(i=0;i<n;i++) {
        cin>>x;
        arr.push_back(x);
        MP[x]++;
    }
    
    LL tot = 0;
    map<LL,LL>::iterator it;
    for(it=MP.begin();it!=MP.end();it++) {
        LL freq = it->second;
        tot += f2(freq,freq-1);
    }
    
    for(i=0;i<n;i++) {
        LL freq = MP[arr[i]];
        LL ans = tot - f2(freq,freq-1);
        freq = freq - 1;
        if(freq>0) ans += f2(freq,freq-1);
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 11120
# -*- coding: utf-8 -*-

import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for k in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for k in range(c)] for k in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 998244353

class SegTree:
    """
    セグメント木
    1.update:  i番目の値をxに更新する
    2.query: 区間[l, r)の値を得る
    """

    def __init__(self, n, func, intv, A=[]):
        """
        :param n: 要素数(0-indexed)
        :param func: 値の操作に使う関数(min, max, add, gcdなど)
        :param intv: 要素の初期値(単位元)
        :param A: 初期化に使うリスト(オプション)
        """
        self.n = n
        self.func = func
        self.intv = intv
        # nより大きい2の冪数
        n2 = 1
        while n2 < n:
            n2 <<= 1
        self.n2 = n2
        self.tree = [self.intv] * (n2 << 1)
        # 初期化の値が決まっている場合
        if A:
            # 1段目(最下段)の初期化
            for i in range(n):
                self.tree[n2+i] = A[i]
            # 2段目以降の初期化
            for i in range(n2-1, -1, -1):
                self.tree[i] = self.func(self.tree[i*2], self.tree[i*2+1])

    def update(self, i, x):
        """
        i番目の値をxに更新
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.n2
        self.tree[i] = x
        while i > 0:
            i >>= 1
            self.tree[i] = self.func(self.tree[i*2], self.tree[i*2+1])

    def query(self, a, b):
        """
        [a, b)の値を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        l = a + self.n2
        r = b + self.n2
        s = self.intv
        while l < r:
            if r & 1:
                r -= 1
                s = self.func(s, self.tree[r])
            if l & 1:
                s = self.func(s, self.tree[l])
                l += 1
            l >>= 1
            r >>= 1
        return s

    def get(self, i):
        """ 一点取得 """
        return self.tree[i+self.n2]

    def all(self):
        """ 全区間[0, n)の取得 """
        return self.tree[1]

N, M = MAP()
LRC = []
for i in range(M):
    l, r, c = MAP()
    l -= 1
    r -= 1
    LRC.append((l, r, c))

LRC.sort()
st = SegTree(N, min, INF)
st.update(0, 0)
for l, r, c in LRC:
    mn = st.query(l, r+1)
    st.update(r, min(st.get(r), mn+c))

ans = st.get(N-1)
if ans != INF:
    print(st.get(N-1))
else:
    print(-1)


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

int main(){
    int X, Y;
    cin >> X >> Y;
    int mn = 2*X, mx = 4*X;
    bool ok = (mn <= Y && Y <= mx && Y%2 == 0);
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cstdlib>
using namespace std;

int main() {
  string s;
  cin >> s;
  long long ans = 0;
  int len = s.length();

  if(len == 1){
    cout << atol(s.c_str()) << endl;
    return 0;
  }

  ans = atoll(s.c_str());

  for(int i = 1; i < len; i++){
    for(int j = 0; j < i+1; j++){
      int tmp = atoll(s.substr(j,len-i).c_str());
      int left = j;
      int right = i-j;

      if(left > 1)
        tmp *= pow(2,left-1);
      if(right > 1)
        tmp *= pow(2,right-1);
      ans += tmp;
    }
  }

  cout << ans << endl;
  return 0;
}
/*
ex:12345

12345
1234  2345
123   234   345
12    23    34    45
1     2     3     4     5

*

1
1 1
2 1 2
4 2 2 4
8 4 4 4 8

*/

Measured memory_bytes: 256
import math

def solution():
    x = int(input())
    xx = math.floor(x / 500)
    if xx == 0:
        point = math.floor(x / 5) * 5
    else:
        point = xx * 1000
        xx = x - 500 * xx
        point = point + math.floor(xx / 5) * 5
    print(point)

solution()


Measured memory_bytes: 38256