akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using plglg = pair<ll, ll>;
using tlglglg = tuple<ll, ll, ll>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;
    int cnt = 0;
    while(b <= a) {
        b *= 2;
        cnt++;
    }
    while(c <= b) {
        c *= 2;
        cnt++;
    }
    if (cnt <= k) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3648
n,l = map(int,input().split())

dat = [l+i for i in range(n)]

min_idx = 0
min_abs = abs(dat[0])
for i in range(n):
    if abs(dat[i])<min_abs:
        min_abs = abs(dat[i])
        min_idx = i

print(sum(dat) - dat[min_idx]) 


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	string s;
	cin >> s;
	if(s.find("AC") != string::npos)dier("Yes");
	die("No");

	return 0;
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
    rep(i,m) cin >> a[i];
    ll total=0;
    rep(i,m) total+=a[i];
    ll ans=-1;
    cout << (total>n?ans:n-total) << endl;

    return 0;
}

Measured memory_bytes: 3676
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

ll n, A[N], B[N], C[N], X, Y, Z, pre[N], suf[N], ind[N];

bool cmp(int x, int y){
	return A[x] - B[x] > A[y] - B[y];
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> X >> Y >> Z;
	n = X + Y + Z;
	for (int i = 1; i <= n; i++){
		ind[i] = i;
		cin >> A[i] >> B[i] >> C[i];
	}
	sort(ind + 1, ind + n + 1, cmp);
	set<pii> st;
	//for (int i = 1; i <= n; i++) cout << ind[i] << ' ';
	//cout << '\n';
	for (int i = 1; i <= n; i++){
		st.insert({A[ind[i]] - C[ind[i]], ind[i]});
		pre[i] = pre[i - 1] + A[ind[i]];
		if (st.size() > X){
			pii fir = *st.begin();
			st.erase(fir);
			pre[i] -= A[fir.S];
			pre[i] += C[fir.S];
		}
	}
	st.clear();
	for (int i = n; i >= 1; i--){
		st.insert({B[ind[i]] - C[ind[i]], ind[i]});
		suf[i] = suf[i + 1] + B[ind[i]];
		if (st.size() > Y){
			pii fir = *st.begin();
			st.erase(fir);
			suf[i] -= B[fir.S];
			suf[i] += C[fir.S];
		}
	}
	ll ans = 0;
	for (int i = X; i < n + 1 - Y; i++){
		ans = max(ans, pre[i] + suf[i + 1]);
	}
	cout << ans;









	return 0;
}


Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000010
#define N 100010
#define int long long
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,m,pos;
ll ans,s[N],tot;
struct data
{
	int x,l,r;
	bool operator <(const data&a) const
	{
		return 1ll*(m-x)*r+1ll*x*l>1ll*(m-a.x)*a.r+1ll*a.x*a.l;
	}
}a[N];
ll mxval(int i){return 1ll*(m-a[i].x)*a[i].r;}
ll val(int i,int k){if (k<a[i].x) return 1ll*(k-a[i].x)*a[i].l;else return 1ll*(k-a[i].x)*a[i].r;}
bool check(int k,ll tot)
{
	for (int i=1;i<pos;i++)
	if (tot-mxval(i)+val(i,k)>=0) return 1;
	tot-=mxval(pos);tot+=val(pos,0);
	for (int i=pos;i<=n;i++)
	if (tot-val(i,0)+val(i,k)>=0) return 1;
	return 0;
}
signed main()
{
	n=read(),m=read();
	for (int i=1;i<=n;i++) a[i].x=read(),a[i].l=read(),a[i].r=read();
	sort(a+1,a+n+1);
	for (int i=n;i>=1;i--) s[i]=s[i+1]-val(i,0);
	tot=0;pos=0;
	for (int i=1;i<=n;i++)
	{
		tot+=mxval(i);
		if (tot>=s[i+1]) {pos=i;break;}
	}
	if (pos==0) {cout<<0;return 0;}
	tot-=s[pos+1];
	int l=0,r=m;
	while (l<=r)
	{
		int mid=l+r>>1;
		if (check(mid,tot)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans+1ll*(pos-1)*m;
	return 0;
	//NOTICE LONG LONG!!!!!
}
//当权值确定后，显然优先学权值大的
//一门课学的比对方多就使重要性取max，否则取min
//既然已经点的比对方多，不如学满
//该门课学满的收益为(m-x)*r 不学的减益为x*l 总价值为(m-x)*r+x*l
//按该价值排序依次选完
//至多只有一门课是不学满(若优则设为r否则设为l)的，其他要么不学(设为l)要么学满（设为r) 
//考虑哪一门不学满 不学满后应二分答案考虑是否可行  

Measured memory_bytes: 3328
import sys
import math

x_list = []

for line in sys.stdin.readlines():
  x_list.append(int(line.strip()))

count = 0

x_list.remove(x_list[0])

for i in x_list:
  flag = 0
  for j in range(2, int(math.sqrt(i))+1):
    if i % j == 0:
      flag = 1
      break
  if flag == 0:
    count += 1

print count
    

Measured memory_bytes: 7228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	int w,h,n;
	cin>>w>>h>>n;
	int x1=0,x2=w,y1=0,y2=h;
	for(int i=1;i<=n;i++){
		int x,y,a;
		cin>>x>>y>>a;
		if(a==1)
			x1=max(x1,x);
		else if(a==2)
			x2=min(x2,x);
		else if(a==3)
			y1=max(y1,y);
		else if(a==4) 
			y2=min(y2,y);
	}
	if(x1>=x2||y1>=y2) puts("0");
	else printf("%d\n",(x2-x1)*(y2-y1));
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, M;
int A[1010];


signed main(){
    cin >> N >> M;
    rep(i, 0, N) cin >> A[i];

    int v = accumulate(A, A+N, 0LL);

    int ans = 0;
    rep(i, 0, N) if(4*M*A[i] >= v) ans++;

    if(ans >= M) Yes;
    else No;

    return 0;
}

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define S0RT(a,n) sort(a, a + n)
#define pb push_back
#define mp make_pair
#define f first
#define s second

const int MOD = 1000000007;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);

/* NOTES TO SELF:
    Int overflow? Use all ll if in doubt.
    Edge cases? (n = 1, n = 0)
*/

string s;

int main(){
    IOS;
    cin >> s;
    F0R(i,s.size()){
        cout << "x";
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b;
	int count = 0;

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

	if (a <= 0 && b >= 0)printf("Zero");
	else {
		for (int i = a; i <= b; i++) {
			if (i < 0)count++;
		}
		if (count % 2)printf("Negative");
		else printf("Positive");
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int N;
vector<bool> s, t;

void print_result()
{
    for (int i = 0; i < N; i++) {
        cout << (t[i] ? 'S' : 'W');
    }
    cout << endl;
}

bool hidden(int p)
{
    if (p == N-1) {
        if (s[p] != t[p]) {
            if (!t[p-1] == t[0]) {
                print_result();
                return true;
            } else {
                return false;
            }
        } else {
            if (t[p-1] == t[0]) {
                print_result();
                return true;
            } else {
                return false;
            }
        }
    }
    if (s[p] != t[p]) {
        if (p == N-2) {
            if (t[p+1] != !t[p-1]) return false;
        }
        t[p+1] = !t[p-1];
    } else {
        if (p == N-2) {
            if (t[p+1] != t[p-1]) return false;
        }
        t[p+1] = t[p-1];
    }
    return hidden(p+1);
}

bool check(bool f)
{
    t.resize(N);
    t[0] = f;
    if (s[0] != t[0]) {
        t[1] = true;
        t[N-1] = false;       
        if (hidden(1)) return true;
        t[1] = false;
        t[N-1] = true;
        return hidden(1);
    } else {
        t[1] = true;
        t[N-1] = true;
        if (hidden(1)) return true;
        t[1] = false;
        t[N-1] = false;
        return hidden(1);
    }
}

int main()
{
    cin >> N;
    
    string str;
    cin >> str;
    
    s.resize(N);
    for (int i = 0; i < N; i++) {
        s[i] = (str[i] == 'o');
    }
    
    if (!check(true) && !check(false)) cout << -1 << endl;
    
    return 0;   
}

Measured memory_bytes: 512
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a <= 8 && b <= 8)
			System.out.println("Yay!");
		else
			System.out.println(":(");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define repm(i,a,b) for(ll i=(ll)(a);i>(ll)(b);i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(),(x).rend()
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb =vector<bool>;
using vvb=vector<vb>;
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; }
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int main(){
  ll n;
  cin >> n;
  ll ans=0;
  repi(i,1,n+1){
    ll m=n/i;
    ans+=i*m*(m+1)/2;
  }
  cout<<ans<<endl;
}

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

const int MAXN = 1005;
int n, m;
int a[MAXN];

bool input() {
    scanf("%d %d", &n, &m);
    if ( !n && !m ) return 0;
    for (int i = 0 ; i < n ; i++ ) {
        scanf("%d", &a[i]);
    }
    return 1;
}

void solve() {
    int mx = 0;
    for (int i = 0 ; i < n ; i++ ) {
        for (int j = i + 1 ; j < n ; j++ ) {
            if ( a[i] + a[j] <= m ) {
                mx = max(mx, a[i]+a[j]);
            }
        }
    }
    if (mx == 0) puts("NONE");
    else printf("%d\n", mx);
}

int main(){
    while(input()) {
        solve();
    }
}

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
using namespace std;
int N, Q;
vector<int> G[200010];
vector<int> ans(200010);
vector<bool> used(200010);

void dfs(int u) {
    used[u] = true;
    for (int v: G[u]) {
        if (used[v] == false) { 
            ans[v] += ans[u];
            dfs(v);
        }
    }
}

int main() {
    cin >> N >> Q;
    for (int i = 0; i < N-1; i++) {
        int a, b; cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    for (int i = 0; i < Q; i++) {
        int p, x; cin >> p >> x;
        ans[p-1] += x;
    }
    dfs(0);
    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 24368
package main

import (
    "fmt"
)

func main() {
    var n, k int
    fmt.Scan(&n, &k)
    hs := make([]int, n)
    for i := 0; i < n; i++ {
        var h int
        fmt.Scan(&h)
        hs[i] = h
    }

    dp := make([]int, n)
    dp[0] = 0
    for i := 1; i < n; i++ {
        dp[i] = 1e10
    }

    for i := 1; i < n; i++ {
        for j := 1; j <= min(k, i); j++ {
            dp[i] = min(dp[i], dp[i-j]+abs(hs[i]-hs[i-j]))
        }
    }

    fmt.Println(dp[n-1])
}

func min(a, b int) int {
    if a < b {
        return a
    }
    return b
}

func abs(n int) int {
    if n < 0 {
        return -n
    }
    return n
}


Measured memory_bytes: 5504
#include<stdio.h>
int main(){
    int a,b,n;
    char op;
    while(scanf("%d %c %d",&a,&op,&b) && op !='?'){
        if(op=='+') n=a+b;
        else if(op=='-') n=a-b;
        else if(op=='*') n=a*b;
        else if(op=='/') n=a/b;
        printf("%d\n",n);
    }
    return 0;
}


Measured memory_bytes: 2104
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	f := true
	set := make(map[rune]bool)
	for _, c := range(s) {
		if set[c] {
			fmt.Println("no")
			f = false
			break
		}
		set[c] = true
	}
	if f {
		fmt.Println("yes")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;

int main(){
  ll n,m;   cin >> n ;
  ll a[n];
  deque<ll>b;
  rep(i,n){
      int a;
      cin >> a;
      if(i%2 == 1){
          b.push_back(a);
      }else{
          b.push_front(a);
      }
  }
  if(n%2 == 1){
  for(int i=0;i<n;i++){
      int a;
      a=b.front();
      b.pop_front();
      cout << a << " " ;
  }
  }else{
      for(int i=0;i<n;i++){
      int a;
      a=b.back();
      b.pop_back();
      cout << a << " " ;
    }
  }
  cout << endl;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
 
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
 
/* vector<int> A(N); 
    vector<pair<int, int> > tasks; ＃ソートした場合、１つ目でソート
　tie(b, a) = p.at(i); #pairを分割
    tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
　xの二乗:  pow(x, 2.0) 
    小さい順: sort(v.begin(), v.end());
    大きい順: reverse(v.begin(), v.end());
    int: -2,147,483,648 ～ 2,147,483,647
    ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807
    // int型の2次元配列(3×4要素の)の宣言
    vector<vector<int>> data(3, vector<int>(4));
*/
 
int main() {
  
  ll A, B, C, count=0, ans=0;
  string D, E;
  cin >> A >> B;
  C=A*B/2;
  if(A*B%2==1){C++;}
  if(A==1||B==1){C=1;}
  cout << C << endl;
}

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

int main(){
  string s;
  cin>>s;
  char p=s[0];
  int ans=0;
  for(int i=1;i<s.size();i++){
    if(s[i]!=p){
      p=s[i];
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
  int h, w;
  while(1) {
    cin >> h >> w;
    if(h == 0 && w == 0) return 0;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        if((i + j) % 2 == 0) cout << '#';
        else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3040
#include<cstdio>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	if(n<2)
	{
		printf("1\n");
		return 0;
	}
	if(n<4)
	{
		printf("2\n");
		return 0;
	}
	if(n<8)
	{
		printf("4\n");
		return 0;
	}
	if(n<16)
	{
		printf("8\n");
		return 0;
	}
	if(n<32)
	{
		printf("16\n");
		return 0;
	}
	if(n<64)
	{
		printf("32\n");
		return 0;
	}
	printf("64\n");
	return 0;
}

Measured memory_bytes: 128
import java.math.BigInteger;
import java.util.Scanner;

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

		int mod = 1000000007;
		NCR ncr = new NCR(n * 2, mod);

		if (k >= n - 1) {
			System.out.println(ncr.calc(n + n - 1, n));
		} else {
			long ans = 0;
			for (int i = 0; i <= k; i++) {
				long val0 = ncr.calc(n, i);
				long val1 = ncr.calc(n - 1, i);;
				ans += val0 * val1;
				ans %= mod;
			}
			System.out.println(ans);
		}
	}

	static class NCR {
		long[] p, pi;
		int m;

		public NCR(int n, int mod) {
			n++;
			m = mod;
			p = new long[n];
			pi = new long[n];
			p[0] = 1;
			pi[0] = 1;
			for (int i = 1; i < n; i++) {
				p[i] = p[i - 1] * i % m;
			}
			pi[n - 1] = BigInteger.valueOf(p[n - 1])
					.modInverse(BigInteger.valueOf(m)).longValue();
			for (int i = n - 1; i > 1; i--) {
				pi[i - 1] = pi[i] * i % m;
			}
		}

		public long calc(int n, int r) {
			if (n < r) return 0;
			return p[n] * pi[r] % m * pi[n - r] % m;
		}
	}
}


Measured memory_bytes: 28116
#include <bits/stdc++.h>
using namespace std;
int n,a[105],dp[105][11];
int main() {
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i];
    for (int i=0; i<=n; i++) {
        for (int j=0; j<10; j++) dp[i][j]=-0x3f3f3f3f;
    }
    dp[0][0]=0;
    for (int i=1; i<=n; i++) {
        for (int j=0; j<10; j++) {
            int x=(((j-a[i])%10)+10)%10;
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            if (dp[i-1][x]!=-0x3f3f3f3f) dp[i][j]=max(dp[i][j],dp[i-1][x]+a[i]);
        }
    }
    int ans=0;
    for (int i=1; i<10; i++) ans=max(ans,dp[n][i]);
    cout<<ans<<'\n';
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(void){
  double a,b,t,n;
  cin>>a>>b>>t;
  n=a;
  int count=0;
  while(t+0.5>n){
    count+=b;
    n+=a;
  }
  cout<<count<<endl;
  return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}


//base=9973,mod=999999937LL, 1000000007LL;
struct rolling_hash{
    int mnum;
	std::string str;
    long long int base;
	std::vector<long long int> mod;
    std::vector<vector<long long int>> hash,pow;

	rolling_hash(const std::string &str,long long int base,vector<long long int> mod):mnum(mod.size()),str(str),base(base),mod(mod){
		int size=str.size();
		hash=std::vector<std::vector<long long int>>(mnum,std::vector<long long int>(size+1));
		pow=std::vector<std::vector<long long int>>(mnum,std::vector<long long int>(size+1));

		for(int i=0; i<mnum; ++i){
            hash[i][0]=0;
            pow[i][0]=1;
        }
        for(int i=0; i<mnum; ++i){
            long long int m=mod[i];
    		for(int j=1; j<size+1; ++j){
    			pow[i][j]=pow[i][j-1]*base%m;
    			hash[i][j]=(hash[i][j-1]*base+str[j-1])%m;
    		}
        }
	}

	long long int compute_hash(int l,int r,int i){ //[l,r)
		return (hash[i][r]-hash[i][l]*pow[i][r-l]%mod[i]+mod[i])%mod[i];
	}

    bool match(int l,int r,const std::vector<long long int> &hs){
        for(int i=0; i<mnum; ++i) if(compute_hash(l,r,mod[i])!=hs[i]) return false;
        return true;
    }
};

void solve(){
    int n,m;
    string s;
    cin >> n >> m >> s;

    rolling_hash roriha(s,9973,{999999937LL, 1000000007LL});
    vector<pair<ll,ll>> v;
    int l=0,r=1;
    rep(i,0,m){
        string q;
        cin >> q;
        if(q=="R++") ++r;
        if(q=="R--") --r;
        if(q=="L++") ++l;
        if(q=="L--") --l;
        v.push_back(make_pair(roriha.compute_hash(l,r,0),roriha.compute_hash(l,r,1)));
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    cout << v.size() << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 25292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
const int INF = 1002003004005006ll;
signed main(){
    int n;cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    vector<int> dp(n+1,INF);
    dp[0] = -INF;

    rep(i,n){
        auto hoge = lower_bound(dp.begin(),dp.end(),a[i])-dp.begin();
        dp[hoge] = min(dp[hoge],a[i]);


    }
    int ans = lower_bound(dp.begin(),dp.end(),INF)- dp.begin();
    cout << ans -1<< endl;

    return 0;
}


Measured memory_bytes: 4408
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(dead_code)]
fn read<T: FromStr>(s: &mut StdinLock) -> T {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

#[allow(unused_macros)]
macro_rules! p {
    ($x:expr) 
    => (println!("{}", $x));
    ($x:expr, $y:expr)
    => (println!("{} {}", $x, $y));
    ($x:expr, $y:expr, $z:expr) 
    => (println!("{} {} {}", $x, $y, $z));
}

#[allow(unused_macros)]
macro_rules! pl {
    ($x:expr) 
    => (println!("{}", $x));
    ($x:expr, $y:expr)
    => (println!("{}\n{}", $x, $y));
    ($x:expr, $y:expr, $z:expr) 
    => (println!("{}\n{}\n{}", $x, $y, $z));
}

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let S = &mut s;

    for _ in 0..1 {
        let q: usize = read(S);
        let is_prime: Vec<_> = (0..100010u64).map(|i| {
            if i <= 1 {
                false
            } else {
                let mut p = true;
                for j in 2..i {
                    if j * j > i { break; }
                    if i % j == 0 {
                        p = false;
                        break;
                    }
                }
                p
            }
        }).collect();
        // println!("{:?}", &is_prime[0..10]);

        let mut cnt = vec![0u32; 100010];
        for i in 1..100005 {
            let ok = i % 2 != 0 && is_prime[i] && is_prime[(i+1)/2];
            cnt[i+1] = if ok {
                cnt[i] + 1
            } else {
                cnt[i]
            }
        }

        for _ in 0..q {
            let l: usize = read(S);
            let r: usize = read(S);
            p!(cnt[r+1] - cnt[l]);
        }
    }
}

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

using namespace std;

const int Max = 1e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int a[Max] = {0};
	int n, m, l, r, no_id_cards = 0, max = -1e6;
	cin >> n >> m;
	for (int i = 0; i < m; ++i){
		cin >> l >> r;
		a[l] += 1;
		a[r + 1] -= 1;
	}

	for (int i = 1; i <= n; ++i)
		a[i] += a[i - 1];
	
	for (int i = 1; i <= n; ++i)
		if (a[i] > max){
			max = a[i];
			no_id_cards = 1;
		} else if (a[i] == max)
			++no_id_cards;
	
	if (max != m)
		cout << 0;
	else
		cout << no_id_cards;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <bitset>
#include <map>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

using namespace std;

string result = "";

bool loopdfs(vector<int> & nums, int N, int sum) {
    if (N == 4) {
        if (sum != 7) return false;
        result = "=7";
        return true;
    }
    if (loopdfs(nums, N + 1, sum + nums[N])) {
        result = to_string(nums[N]) + result;
        if (N != 0) result = "+" + result;
        return true;
    }
    if (loopdfs(nums, N + 1, sum - nums[N])) {
        result = to_string(nums[N]) + result;
        if (N != 0) result = "-" + result;
        return true;
    }
    return false;
}

int main()
{
    string S;
    vector<int> nums(4);
    cin >> S;
    rep(i, 4) {
        nums[i] = (int)(S[i] - '0');
    }
    loopdfs(nums, 0, 0);
    cout << result << endl;
}

Measured memory_bytes: 3680
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  long long n;
  cin >> n;
  int ans = 0;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      long long x = i;
      long long y = n / i;
      long long nn = n;
      while (nn > 0 && x > 1 && nn % x == 0) nn /= x;
      if (nn % x == 1) ans++;
      if (x == y) continue;
      nn = n;
      while (nn > 0 && y > 1 && nn % y == 0) nn /= y;
      if (nn % y == 1) ans++;
    }
  }
  for (long long i = 1; i * i <= n - 1; i++) {
    if ((n - 1) % i == 0) {
      long long x = i;
      long long y = (n - 1) / i;
      long long nn = n;
      while (nn > 0 && x > 1 && nn % x == 0) nn /= x;
      if (nn % x == 1) ans++;
      if (x == y) continue;
      nn = n;
      while (nn > 0 && y > 1 && nn % y == 0) nn /= y;
      if (nn % y == 1) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	map<char, char> m;
	for(int i = 0; i < 26; i++) {
		char from = (char)('A' + i);
		char to = (char)(from - 3);
		if(to < 'A') {
			to += 26;
		}
		m.insert(make_pair(from, to));
	}
	char input[1024];
	scanf(" %s", input);
	const int n = strlen(input);
	for(int i = 0; i < n; i++) {
		printf("%c", m[input[i]]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
main(){
  int N;std::cin>>N;
  while(N>0){
    int v[5],b=0,f=0,d[]={0,0,0,1,0,3,2,0};
    for(;b<5;++b){v[b]=N;f|=1<<--N;std::cin>>N;}
    for(b=0;b<5;++b)std::cout<<((v[b]==d[f])?1:(d[f]?2:3))<<std::endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    int k,n;
    cin>>n>>k;
    vector <double> p(n);
    rep(i,n)
    cin>>p[i],p[i]=(p[i]+1)/2;
    vector <double> pref(n+1,0);
    for (int i=0;i<n;i++)
        pref[i+1]=pref[i]+p[i];
    double mx=0;
    for (int i=k;i<=n;i++)
        mx=max(mx,pref[i]-pref[i-k]);
    cout<<setprecision(40)<<mx;







}

Measured memory_bytes: 3328
n=int(input())
s=input()
r=0
g=0
b=0
gh=0
for i in range(n):
    if s[i]=='R':
        r=r+1
    elif s[i]=='G':
        g=g+1
    else:
        b=b+1
for j in range(n-2):
    
    for h in range((n-j-1)//2):
        
        if s[j]!=s[j+h+1] and s[j+h+1]!=s[j+2*(h+1)] and s[j]!=s[j+2*(h+1)]:
            gh=gh+1
        else:
            continue
print(r*g*b-gh)


Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, p;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> p;
	int n0 = 0, n1 = 0;
	FOR(i, n) {
		int a;
		cin >> a;
		if (a & 1) n1++;
		else n0++;
	}
	ll ans;
	if (n1 && n0) ans = (ll)pow(2, n0) * (ll)pow(2, n1-1);
	else if (n1) ans = (ll)pow(2, n1-1);
	else ans = (ll)pow(2, n0);
	
	if (p & 1) cout << (ll)pow(2, n) - ans << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n,m;
 
   cin >> n >> m;
  
   if(500*n>=m){
     cout << "Yes" << endl;
   }else{
     cout << "No" << endl;
   }
   
   
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
        import java.util.*;
        public class Main{
          public static void main(String[] args) throws IOException{
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            int a = Integer.parseInt(reader.readLine());
            int[] list = new int[a];
            String[] inp = reader.readLine().split(" ");
            int i = 0;
            for(String s: inp){
                list[i] =Integer.parseInt(s);
                i++;
            }
            Arrays.sort(list);
            int fr = Integer.MAX_VALUE;
            for(int j = list[0];j<=list[list.length-1];j++){
                int res = 0;
                for(int h=0;h<list.length;h++){
                    res=res+(list[h]-j)*(list[h]-j);
                }
                
                fr = Math.min(res,fr);
                
            }
            System.out.println(fr);
              
          }}

Measured memory_bytes: 21204
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;

int main(){
    long long N;
    cin >> N;
    int minAns=INT_MAX;
    for(long long i=1;i*i<=N;i++){
        if(N%i==0) minAns=min((int)max(log10(i),log10(N/i))+1,minAns);
    }
    cout << minAns << endl;
    return 0;
}


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

int main() {
    string o, d;
    cin >> o >> d;
    int len = (int)o.length() + (int)d.length();
    bool odd = true;
    string ans;
    for (int i = 0; i < len; i++) {
        if (odd) ans += o.at(i / 2);
        else ans += d.at((i - 1) / 2);
        odd ^= 1;
    }
    cout << ans << endl;
}   

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a:
    ans = 0
    # print(a)
else:
    a.sort(reverse=True)
    for i in a:
        ans = ans*i
        if ans>(10**18):
            ans = -1;break
print(ans)

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int n,k;
	cin>>n>>k;
	long long int s=n;
	while(n--){
		long long int x;
		cin>>x;
	}
	long long int u=(s-1);
	long long int d=(k-1);
	if(u%d==0){
		cout<<u/d;
	}
	else{
		cout<<(u/d)+1;
	}
	return 0;
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#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, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, ll W, std::vector<ll> w, std::vector<ll> v) {
  vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));

  rep(i, N) {
    FOR(j, 1, W + 1) {
      dp.at(i + 1).at(j) = dp.at(i).at(j);
      if (j - w.at(i) >= 0)
        chmax(dp.at(i + 1).at(j), dp.at(i).at(j - w.at(i)) + v.at(i));
    }
  }

  ll ans = 0;
  rep(j, W + 1) { chmax(ans, dp.at(N).at(j)); }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  ll W;
  scanf("%lld", &W);
  std::vector<ll> w(N);
  std::vector<ll> v(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &w[i]);
    scanf("%lld", &v[i]);
  }
  solve(N, W, std::move(w), std::move(v));
  return 0;
}


Measured memory_bytes: 83256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let p: Vec<usize> = vec(n, |_| scan(tokens));
    let mut ans: usize = 0;
    for i in 1..n - 1 {
        if p[i - 1] < p[i] && p[i] < p[i + 1] {
            ans += 1;
        } else if p[i - 1] > p[i] && p[i] > p[i + 1] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

int main()
{
        ll A, B, K;
        cin >> A >> B >> K;

        ll total = B - A + 1;

        for (int i = 0; i < total; ++i) {

                if (i < K || (total - K) <= i) {

                        cout << A + i << endl;
                }


        }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll, ll>
#define vi vector<ll>
#define vii vector<ii>
#define vs vector<string>
#define si set<ll>
#define endl "\n"
#define pb push_back
#define x first
#define y second
//g++ -std=c++11 -Wall -Wextra -pedantic-errors main.cpp -o main
const int ms = 1e5 + 5, base = 31, mod = 1e5 + 7;
using namespace std;


ll dp[105][ms], N, W;
vector<ii> H;

ll solve(int n, int left){
	if (n == N) return 0;
	
	if (dp[n][left] != -1) return dp[n][left];
	
	ll one = solve(n+1, left), two = 0;
	if (left-H[n].x >= 0)
		two = H[n].y + solve(n+1, left-H[n].x);
	
	return dp[n][left] = max(one, two);
	
}

int main(){
	ios::sync_with_stdio(false), cin.tie(0);
	memset(dp, -1, sizeof(dp));
	
	cin >> N >> W;

	for (int i = 0; i < N; i++){
		int a, b;  cin >> a >> b;
		H.pb({a,b});
	}
	
	sort(H.begin(), H.end());
	
	cout << solve(0,W) << endl;
	
	return 0;
}


Measured memory_bytes: 82304
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   double n,x;
   ll t;
   cin>>n>>x>>t;
   ll temp=ceil(n/x);
   cout<<temp*t;
}




Measured memory_bytes: 3736
n = int(input())
ls = []
for i in range(n):
  ls.append(int(input()))
s = sum(ls)
p = s % 10
if (p == 0):
  ls.sort()
  for i in ls:
    if (i % 10 != 0):
      s = s - i
      print(s)
      break
  else:
    print(0)
else:
  print(s)

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

int main() {
    int N,W;
    cin >> N >> W;
    vector<long long> w(N),v(N);
    for(int i=0;i<N;i++) cin >> w[i] >> v[i];
    int V=1000;
    int VN=V*N;
    vector<long long> dp(VN+1),dpp(VN+1);
    for(int i=0;i<=VN;i++) dp[i]=W+1;
    dp[0]=0;
    for(int n=0; n<N; n++) {
        dpp.swap(dp);
        for(int i=0; i<=VN; i++) dp[i]=dpp[i];
        for(int i=0; i<=VN; i++) {
            if (dpp[i]+w[n]<=W) chmin(dp[i+v[n]], dpp[i]+w[n]);
        }
    }
    int ans;
    for(int i=VN;i>=0;i--){
        if(dp[i]<=W){
            ans=i;
            break;
        }
    }
    std::cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int K,A,B;
    cin>>K;
    cin>>A>>B;

    for(int i = A;i <= B;i++) {
        if(i%K == 0) {
            cout<<"OK"<<endl;

            return 0;
        }
    }

    cout<<"NG"<<endl;

    return 0;
}





Measured memory_bytes: 3024
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n < 3 | n > 50000) break;
			int big = 2;
			int small = n + 1000;
			boolean isP = false;
			for(int i = 3; i <= n + 1000; i++){
				for(int j = 2; j < i; j++){
					if(i % j == 0){
						isP = false; break;
					}
					isP = true;
				}
				if(isP){
					if(i > big & i < n) big = i;
					else if(i < small & i > n) small = i;
				}
			}
			System.out.println(big + " " + small);
		}
	}
}

Measured memory_bytes: 27296
n = [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]
k=int(input())

print(n[k-1])

Measured memory_bytes: 3060
<?php

$sc = new Scanner();

$f = [
    '1' => false,
    '9' => false,
    '7' => false,
    '4' => false,
];

for($i = 0; $i < 4; $i++) {
    $t = $sc->nextInt();
    if ($f[$t]) {
        echo 'NO' . PHP_EOL;
        exit;
    }
    $f[$t] = true;
}
foreach($f as $v) {
    if (!$v) {
        echo 'NO' . PHP_EOL;
        exit;
    }
}
echo 'YES' . PHP_EOL;
exit;


class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}


Measured memory_bytes: 4728
n = int(input())
sp = [0] * n
for i in range(n):
    sp[i] = input().split() + [i+1]
    sp[i][1] = int(sp[i][1])
sp.sort(key=lambda x: x[1], reverse=True)
sp.sort(key=lambda x: x[0])
for i in range(n):
    print(sp[i][2])


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;

    // 処理
    ll a[n] = {};
    a[0]    = 2;
    a[1]    = 1;
    for (int i = 2; i <= n; i++) {
        a[i] = a[i - 2] + a[i - 1];
    }

    // 出力
    cout << a[n] << endl;

    return 0;
}


Measured memory_bytes: 256
//
//  9_A.cpp
//  
//
//  Created by 杵鞭俊 on 2018/07/13.
//

#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i) {return i/2;}
int left(int i){return 2 * i;}
int right(int i){return 2 * i + 1;}

int main(){
    int H,i,A[MAX + 1];
    
    cin >> H;
    for(i=1;i<=H;i++) cin >> A[i];
    
    for(i=1;i<=H;i++){
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(parent(i) >= 1)cout << "parent key = "  <<A[parent(i)] << ", ";
        if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
        if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> h(n), dp(n);
	for(int i = 0; i < n; i++) cin >> h[i];
	int a = 0, b = abs(h[1]-h[0]);
	int c = b;
	for(int i = 2; i < n; i++){
		c = min(a+abs(h[i]-h[i-2]), b+abs(h[i]-h[i-1]));
		a = b;
		b = c;
	}
	cout << c << '\n';
	return 0;
}


Measured memory_bytes: 3960
from math import gcd
from itertools import accumulate

n = int(input())
a = list(map(int, input().split()))

l = list(accumulate(a, lambda x, y: gcd(x, y)))
r = list(accumulate(a[::-1], lambda x, y: gcd(x, y)))[::-1]
ans = max(r[1], l[-2])
for i in range(1, n-1):
    ans = max(ans, gcd(l[i-1], r[i+1]))
print(ans)

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

int main() {
	long long int N, a, b;
	cin >> N >> a >> b;
	if ((N == 1 && a != b) | a > b) { cout << 0 << endl;
	}
	else {
		cout << b*(N - 2) + a*(2 - N) + 1 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
const int INF=1e9;
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int n,a,b;cin>>n>>a>>b;
  cout<<(n/(a+b))*a+min(n%(a+b),a)<<endl;
}


Measured memory_bytes: 256