akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e ,n, k, x,l,r;
    string s;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> re;
    vector<ll> de;

    ll t[5];
    ll _all = 0;

    rep(i,5) {
        cin  >> t[i];
        _all += ((t[i]+9)/10) * 10;
    }

    ans = INF;

    rep(i,5){
        ll tmp = _all - (((t[i]+9)/10)*10) + t[i];
        ans = min(ans, tmp); 
    }

    
    std::cout << ans << endl; 

    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

double dp[301][301][301];

double solve(ll x, ll y, ll z, ll& n){
    if(x<0 || y<0 || z<0) return 0;
    if(x==0&&y==0&&z==0) return 0;
    if(dp[x][y][z]>-1.0) return dp[x][y][z];
    double exp = n+x*solve(x-1, y, z, n)+y*solve(x+1, y-1, z, n)+z*solve(x, y+1, z-1, n);
    return dp[x][y][z] = exp/(x+y+z);
}

int main(){
    cpp();
    memset(dp, -1, sizeof dp);
    ll n;
    cin>>n;
    ll one=0, two=0, three=0;
    for(ll i=0; i<n; i++){
        ll x;
        cin>>x;
        if(x==1) one++;
        else if(x==2) two++;
        else three++;
    }
    cout<<ps(solve(one, two, three, n), 9)<<endl;
    return 0;
}






Measured memory_bytes: 216900
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N, M = MI()
    A = LI()
    minA = min(A)
    BC = LLIN(M)
    BC.sort(reverse=True, key=lambda x: x[1])
    bc = []
    cnt = 0
    for b, c in BC:
        if cnt >= N or minA >= c:
            break
        bc += [c] * b
        cnt += b

    l = A + bc
    l.sort(reverse=True)
    ans = sum(l[:N])
    print(ans)

    """
    from bisect import bisect_left
    N, M = MI()
    A = LI()
    A.sort()
    BC = LLIN(M)
    BC.sort(key=lambda x: x[1])
    now = 0  # 要検討
    ans = 0
    for b, c in BC:
        bis = bisect_left(A, c)
        print(bis, b, c)
        if bis - now < 0:
            continue
        else:
            if bis - now > b:
                ans += b*c
                now += b
            else:
                ans += (bis - now) * c
                now = bis
                print(bis, now)
        print(ans)
    # nowまでは想いのままに

    for i in range(now, N):
        ans += A[i]
    print(ans)
"""


if __name__ == '__main__':
    main()


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  cout << (1<<(int)(log2(N))) << endl;

  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
//#define int long long
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
constexpr int inf = 1e9;
constexpr int mod = 998244353;
string s[305];
int dp[305][305];
int dp1[305][305], dp2[305][305];
int h, w;

int DP(int now) {
	rep(i, h + 1)rep(j, h + 1)dp1[i][j] = dp2[i][j] = 0;
	rep(i, h + 1)rep(j, h + 1)dp[i][j] = inf;
	dp[0][0] = 0;

	rep(i, h) {
		rep(j, h - i) {
			//i,i-j;
			if (s[i + j][now] == s[j][now + 1])dp1[i][i + j]++;
			if (s[j][now] == s[i + j][now + 1])dp2[i][i + j]++;
		}
		rep(j, h) {
			dp1[i][j + 1] += dp1[i][j];
			dp2[i][j + 1] += dp2[i][j];
		}
	}

	rep(i, h + 1) {
		rep(j, h + 1) {
			int cst;
			if (i < j&&i!=h) {
				cst = dp1[j - i][h - i - 1];
			}
			else if(i>=j&&j!=h){
				cst = dp2[i - j][h - j - 1];
			}
			if (i != h)dp[i + 1][j] = min(dp[i][j] + cst, dp[i + 1][j]);
			if (j != h)dp[i][j + 1] = min(dp[i][j] + cst, dp[i][j + 1]);
		}
	}
	return dp[h][h];
}

signed main() {
	cin >> h >> w;
	rep(i, h)cin >> s[i];
	int ans = 0;
	rep(i, w - 1) {
		ans += DP(i);
	}
	cout << ans << endl;
}

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


def main():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())

    if v <= w:
        print('NO')
        exit()

    if a <= b:
        if 0 <= (b - a) <= t * (v - w):
            print('YES')
        else:
            print('NO')
    else:
        if 0 <= (a - b) <= t * (v - w):
            print('YES')
        else:
            print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
from collections import deque
 
n, q = map(int,(input().split()))
queue = deque()
 
for i in range(n):
    name, time = input().split()
    queue.append( [name, int(time)]  )
     
t = 0
while queue:
    p = queue.popleft()
    t += min(q, p[1])
    if q < p[1]:
        queue.append([p[0], p[1] - q])
    else:
        print(f"{p[0]} {t}")


Measured memory_bytes: 13284
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    cin >> N;
    vector<int> v( N );
    for( auto &x : v )
    {
        cin >> x;
    }
    cout << abs( *min_element( ALL( v ) ) - *max_element( ALL( v ) ) ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
const int N = 2e5+87;
int a[N];
int main()
{
	RI(n);
	RP(i,n) RD(a[i]);
	PT(a[n-1]);
	for (int k = n-3; k >= 0; k -= 2)
		PT(' '), PT(a[k]);
	for (int k = n&1; k < n; k += 2)
		PT(' '), PT(a[k]);
	PL();
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

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

int N,M;
ll L[128];
int se[128];

ll dfs(int n, int bit){
  if(n==N) return 0;
  ll res = 0;
  if(!(se[n] & bit)) res = max(res, dfs(n+1, bit | se[n])+L[n]);
  res = max(res, dfs(n+1, bit));
  return res;
}

int main(){
  while(cin >> N && N){
    memset(se,0,sizeof(se));
    rep(i,N){
      cin >> M >> L[i];
      rep(j,M){
	int S,E;
	cin >> S >> E; S-=6; E-=6;
	for(int k=S;k<E;k++) se[i] |= (1<<k);
      }
    }

    cout << dfs(0, 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = 0;
	bool flag;
	for (int i = 0;i < n;i++) {
		flag = true;
		if (i > 0) {
			if (a[i] == a[i - 1]) {
				continue;
			}
		}
		if (i < n - 1) {
			if (a[i] == a[i + 1]) {
				continue;
			}
		}
		if (a[i] == 1) {
			ans++;
			continue;
		}
		int level = (int)sqrt(a[i]);
		for (int j = 1;j <= level;j++) {
			if (a[i] % j == 0) {
				int index = lower_bound(a, a + n, j) - a;
				if (a[index] == j) {
					flag = false;
					break;
				}
				if (j != 1) {
					index = lower_bound(a, a + n, a[i] / j) - a;
					if (a[index] == a[i] / j) {
						flag = false;
						break;
					}
				}
			}
		}
		if (flag){
			ans++;
		}

			
		
	}
	cout << ans << endl;
}

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

l.sort(reverse = True)
ans = l[-1]
for i in range(n-1):
    ans *= l[i]
    if ans > 10**18:
      ans = -1
      break
    elif ans == 0:
      ans = 0
      break

print(ans)

Measured memory_bytes: 21644
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

template<class T = ll>
struct Edge {
  int to;
  T cost;
  Edge() {}
  Edge(int to, T cost) : to(to), cost(cost) {}
  bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T = ll>
vector<T> Dijkstra(vector<vector<Edge<T>>> &edges, int st) {

  int V = (int)edges.size();
  vector<T> dist(V, INF);
  dist[st] = 0;

  priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;
  p_que.emplace(st, dist[st]);

  while (!p_que.empty()) {

    Edge<T> now(p_que.top().to, p_que.top().cost);
    p_que.pop();

    if (dist[now.to] < now.cost) continue;
    for (const Edge<T> &e : edges[now.to]) {
      T tmp_cost = now.cost + e.cost;
      if (dist[e.to] > tmp_cost) {
        dist[e.to] = tmp_cost;
        p_que.emplace(e.to, dist[e.to]);
      }
    }
  }

  return dist;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M,S,T;
  cin>>N>>M;
  vector<vector<Edge<int> > > edges(3*N);
  for(int i=0;i<M;i++){
    int u,v;
    cin>>u>>v;u--;v--;
    edges[u].emplace_back(v+N,1);
    edges[u+N].emplace_back(v+2*N,1);
    edges[u+2*N].emplace_back(v,1);
  }
  cin>>S>>T;S--;T--;

  auto ans = Dijkstra<int>(edges,S);
  if(ans[T]==INF){
    cout<<-1<<endl;
  }else{
    cout<<ans[T]/3<<endl;
  }
}


Measured memory_bytes: 17792
N = int(input())
A = list(map(int, input().split()))
s = sum(A)
e = 1

ans = 1
flag = 1

if N == 0:
    if s >= 2:
        flag = 0
    else:
        ans = 1
else:
    for i in range(N):
        e = (e - A[i]) * 2
        if e < A[i+1]:
            flag = 0
            break
        tmp = min(e, s)
        s -= A[i+1]
        ans += tmp
if flag == 0:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 83404
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using ll = long long int;
using ld = long double;
using str = string;

int main(){
  kyopro;
  str S;
  cin >> S;
  str saisho = S.substr(0,2);
  str saigo = S.substr(2,2);
  int l = stoi(saisho);
  int r = stoi(saigo);
  bool lisnotMM{};
  bool risnotMM{};
  if(l < 1 || l > 12) lisnotMM = 1;
  if(r < 1 || r > 12) risnotMM = 1;
  if(lisnotMM && risnotMM) cout << "NA" << rt;
  if(lisnotMM && !risnotMM) cout << "YYMM" << rt;
  if(!lisnotMM && risnotMM) cout << "MMYY" << rt;
  if(!lisnotMM && !risnotMM) cout << "AMBIGUOUS" << rt; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
    #define debug(...) printf(__VA_ARGS__)
#else
    #define debug(...) (void)0
#endif
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<int,int>
#define PII pair<long long, long long>
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
const int inf = 0x7fffffff; //beware overflow
const LL INF = 0x7fffffffffffffff; //beware overflow
#define mem(x, y) memset(x, (y), sizeof(x) );
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) {
     return s<<"("<<p.first<<","<<p.second<<")";
}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c) {
    s << "[ ";
    for (auto it : c) s << it << " ";
    s << "]";
    return s;
}
template<typename T>
ostream& operator << (ostream &o, const set<T> &st) {
    o << "{";
    for (auto it=st.begin(); it!=st.end(); it++) o << (it==st.begin() ? "" : ", ") << *it;
    return o << "}";
}
template<typename T1, typename T2>
ostream& operator << (ostream &o, const map<T1, T2> &mp) {
    o << "{";
    for (auto it=mp.begin(); it!=mp.end(); it++) {
        o << (it==mp.begin()?"":", ") << it->fi << ":" << it->se;
    }
    o << "}";
    return o;
}
#define maxn 505
char t[maxn][maxn];
int h, w;
int main() {
    cin>>h>>w;
    for(int i = 0;i < h; i++) scanf("%s", t[i]);

//  debug("finish input\n");
    for(int i = 0; i < h; i++) {
        if( i&1 ) for(int j = 0; j < w; j++) putchar((j==w-1)?'.':'#');
        else
            for(int j = 0; j < w;j ++)
                if( !j ) putchar('#');
                else if( j == w-1) putchar('.');
                else putchar(t[i][j]);
        cout<<endl;
    }
    cout<<endl;
    for(int i = 0; i < h; i++) {
        if( !(i&1) ) for(int j = 0; j < w; j++) putchar((!j)?'.':'#');
        else
            for(int j = 0; j < w;j ++)
                if( j==w-1) putchar('#');
                else if(!j) putchar('.');
                else putchar(t[i][j]);
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("inputh.txt", "r", stdin);
    freopen("outputh.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
   // cin>>test;
    while(test--)
    {

            ll n,w;
            cin>>n>>w;
            vector <pair<ll,ll>>  v(n);
            fo(i,n)
                cin>>v[i].fst>>v[i].sec;
            ll m[n+1][w+1];
            for(int i=0;i<=n;i++)
                m[i][0]=0;
            for(int j=0;j<=w;j++)
                m[0][j]=0;
            for(int i=1;i<=n;i++)
            {
                for(int j=1;j<=w;j++)
                {
                    if(v[i-1].first<=j)
                        m[i][j]=max(m[i-1][j],v[i-1].sec+m[i-1][j-v[i-1].fst]);
                    else
                        m[i][j]=m[i-1][j];
                }
            }
            cout<<m[n][w];

//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not





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

const long MOD = 1000000007;

int main() {
    int n, m, nm;
    cin >> n >> m;
    nm = n * m;
    unordered_set<int> a, b;
    int count_a[nm + 1], count_b[nm + 1];
    fill(count_a, count_a + nm + 1, 0);
    fill(count_b, count_b + nm + 1, 0);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.insert(x);
        count_a[x] = 1;
    }
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        b.insert(x);
        count_b[x] = 1;
    }

    for (int i = nm; i > 0; i--) {
        count_a[i - 1] += count_a[i];
        count_b[i - 1] += count_b[i];
    }

    long ans = 1;
    for (int i = nm; i > 0; i--) {
        bool a_find = (a.find(i) != a.end()), b_find = (b.find(i) != b.end());
        long mul = 1;
        if (a_find) {
            if (!b_find) {
                mul *= count_b[i];
            }
        } else {
            mul *= count_a[i];
            if (!b_find) {
                mul *= count_b[i];
                mul -= nm - i;
            }
        }
        ans *= mul;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int H, W;

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};
bool inside(int x, int y){
    return x>=0 && x<H && y>=0 && y<W;
}


int main(){
    cin >> H >> W;
    string A[1000];
    for(int i=0; i<H; i++) cin >> A[i];

    const int INF = 1e9;
    static int dist[1000][1000] = {0};
    typedef pair<int, int> P;
    queue<P> que;
    for(int i=0; i<H; i++) for(int j=0; j<W; j++){
        if(A[i][j] == '.'){
            dist[i][j] = INF;
        }else{
            que.push({i, j});
        }
    }

    int ans = 0;
    while(que.size()){
        auto p = que.front(); que.pop();
        int i = p.first, j = p.second;
        for(int k=0; k<4; k++){
            int x = i+dx[k], y = j+dy[k];
            if(inside(x, y) && dist[x][y] == INF){
                dist[x][y] = dist[i][j] + 1;
                ans = max(ans, dist[x][y]);
                que.push({x, y});
            }
        }
    }

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


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

using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    i64 n;
    cin >> n;
    vector<i64> a(n);
    rep(i, n) { cin >> a.at(i); }
    vector<i64> sum(n + 1, 0);
    rep(i, n) { sum[i + 1] += sum[i] + a[i]; }

    i64 ans = 1e15;

    // 真ん中を決める
    for (int i = 2; i < n - 1; ++i) {
        // i:
        // a0  a1 | a2 | a3 | a4  a5
        //        2    3    4
        // 左側は[0, i)
        // 右側は[i, n)
        vector<i64> pqrs;
        {
            // 左側
            double half = sum[i] / 2.0;
            int index = lower_bound(sum.begin(), sum.end(), half) - sum.begin();
            if (index == i || abs(sum[i] - 2 * sum[index]) >
                                  abs(sum[i] - 2 * sum[index - 1])) {
                --index;
            }
            pqrs.push_back(sum[i] - sum[index]);
            pqrs.push_back(sum[index]);
        }
        {
            // 右側
            double half = (sum[n] + sum[i]) / 2.0;
            int index = lower_bound(sum.begin(), sum.end(), half) - sum.begin();
            if (index == n || abs(sum[n] + sum[i] - 2 * sum[index]) >
                                  abs(sum[n] + sum[i] - 2 * sum[index - 1])) {
                --index;
            }
            pqrs.push_back(sum[n] - sum[index]);
            pqrs.push_back(sum[index] - sum[i]);
        }
        sort(pqrs.begin(), pqrs.end());
        ans = min(ans, pqrs[3] - pqrs[0]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
// https://atcoder.jp/contests/abc127/tasks/abc127_c

#include <bits/stdc++.h>
#define maxn 100005

using namespace std;

int psa[maxn];
int main() {
    int N, M;
    cin >> N >> M;

    for(int i = 1; i <= M; i++) {
        int l, r;
        cin >> l >> r;

        psa[l]++;
        psa[r+1]--;
    }

    for(int i = 1; i < maxn; i++) {
        psa[i] += psa[i-1];
    }

    int ans = 0;
    for(int i = 1; i <= N; i++) {
  //      cout << psa[i] << endl;
        if(psa[i] == M) ans++;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 640
t = {}
for i = 1, 7 do
  t[i] = io.read("*n")
end
r = t[2]
r1 = 2 * (t[1] // 2 + t[4] // 2 + t[5] // 2)
if 0 < t[1] and 0 < t[4] and 0 < t[5] then
  r2 = 3 + 2 * ((t[1] - 1) // 2 + (t[4] - 1) // 2 + (t[5] - 1) // 2)
  if r1 < r2 then r1 = r2 end
end
print(r + r1)


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ll n,m,w,x;
  while(cin >> m >> n >> w >> x && n) {
    ll e[n][m],f[n][m];
    for(int i=0; i<m; i++) {
      for(int j=0; j<n; j++) cin >> e[j][i];
    }
    for(int i=0; i<m; i++) {
      for(int j=0; j<n; j++) cin >> f[j][i];
    }
    ll dp[n+1][w+1][x+1],ans=0;
    for(int i=0;i<=n;i++)for(int j=0;j<=w;j++)for(int k=0;k<=x;k++)dp[i][j][k]=-1;
    dp[0][0][0]=0;
    for(int t=0; t<n; t++) {
      for(int l=0; l<=w; l++) {
        for(int k=0; k<=x; k++) {
          if(dp[t][l][k]==-1) continue;
          dp[t+1][l][k]=max(dp[t+1][l][k],dp[t][l][k]);
          for(int i=0; i<m; i++) {
            ll z=0,y=0,xx=0;
            for(int j=i; j<m; j++) {
              if(!e[t][j]) break;
              if(j!=i) y=1;
              xx+=e[t][j];
              z+=f[t][j];
              if(z+l<=w&&k+y<=x) dp[t+1][z+l][k+y]=max(dp[t+1][z+l][k+y],dp[t][l][k]+xx);
            }
          }
        }
      }
    }
    for(int l=0;l<=w;l++)for(int k=0;k<=x;k++)ans=max(ans,dp[n][l][k]);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1232
#include <atcoder/all>
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;
using namespace atcoder;

int main(void) {
  lld n;
  cin >> n;
  for (lld i = 0; i < n; i++) {
    cout << "ACL";
  }
  cout << "\n";
}

Measured memory_bytes: 3628
{-# LANGUAGE FlexibleContexts, BangPatterns #-}

module Main where

import Data.Char
import Data.List
import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import Data.Array.Unboxed
import Control.Applicative
import Text.Printf


readInt :: IO Double
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-' || c == '.'
                then (c :) <$> input
                else return []

prints :: Show a => [a] -> IO ()
prints as = putStrLn $ concat $ intersperse " " $ map show as

main = putStrLn . printf "%.7f" . f =<< replicateM 4 readInt

f [x1,y1,x2,y2] = sqrt $ (x1 - x2) ^ 2 + (y1 - y2) ^ 2


Measured memory_bytes: 4064
sun_dic = {}
sun_dic['SAT'] = 1
sun_dic['FRI'] = 2
sun_dic['THU'] = 3
sun_dic['WED'] = 4
sun_dic['TUE'] = 5
sun_dic['MON'] = 6
sun_dic['SUN'] = 7

s = input()
print(sun_dic[s])

Measured memory_bytes: 38452
use std::io::*;
use std::str::*;
use std::collections::*;

pub fn read_from<T: FromStr, R: Read>(s: &mut R) -> T {
    let s = s.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if !s.is_empty() {
        if let Ok(s) = s.parse::<T>() {
            s
        } else {
            panic!("faild to parse {}", s);
        }
    } else {
        if cfg!(local) {
            // eprintln!("reached to EOF");
        }
        std::process::exit(0)
    }
}

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    read_from(&mut stdin)
}

pub fn chars() -> Vec<char> {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    let s: String = read_from(&mut stdin);
    s.chars().collect()
}

pub fn readn<T: FromStr>(n: usize) -> Vec<T> {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    (0..n).map(|_| read_from(&mut stdin)).collect()
}

fn calc(c: char) -> usize {
    if c == '1' {
        1
    } else {
        2e18 as usize
    }
}

fn main() {
    loop {
        let n: usize = read();
        let m: usize = read();
        let q: usize = read();

        let mut to_l: Vec<_> = vec![BTreeSet::new(); n + 1];
        let mut to_r: Vec<_> = vec![BTreeSet::new(); n + 1];
        let mut rails: Vec<(usize, usize, usize)> = (0..m).map(|i| (read(), read(), i)).collect();
        rails.sort();
        let mut rails: VecDeque<_> = rails.iter().cloned().collect();
        for &(l, r, i)in rails.iter() {
            to_l[r].insert((l, i));
            to_r[l].insert((r, i));
        }
        let mut qs: Vec<_> = (0..q).map(|i| {
            let l: usize = read();
            let r: usize = read();
            (l, r, i)
        }).collect();
        qs.sort();

        let mut ans = vec![0; q];
        for &(ql, qr, i) in qs.iter() {
            while rails.len() > 0 && rails.front().unwrap().0 < ql {
                let (l, r, i) = rails.pop_front().unwrap();
                to_l[r].remove(&(l, i));
                to_r[l].remove(&(r, i));
            }
            let mut cnt = 0;
            for r in ql..qr + 1 {
                cnt += to_l[r].len();
            }
            ans[i] = cnt;
        }

        for e in ans.iter() {
            println!("{}", e);
        }
    }
}


Measured memory_bytes: 35648
from collections import deque, defaultdict
import sys
sys.setrecursionlimit(1000000)

class Node:
    def __init__(self, id):
        self.id = id
        self.parent = self.id

N, M = [int(i) for i in input().split()]
P = [Node(i) for i in range(N)]

def root(a):
    if a.id == a.parent:
        return a.id
    else:
        id = root(P[a.parent])
        a.parent = id
        return id

def union(a, b):
    p = root(a)
    q = root(b)
    if p == q:
        return
    else:
        P[q].parent = p

for i in range(M):
    A, B = [int(i)-1 for i in input().split()]
    union(P[A], P[B])

c = defaultdict(int)
for i in range(N):
    c[root(P[i])] += 1
    maxc = 0
for key in c.keys():
    if maxc < c[key]:
        maxc = c[key]
print(maxc)

Measured memory_bytes: 121080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}


const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
ll rev(ll x) {
	return bin_pow(x, MOD - 2);
}

const int N = 5005;
int p2[N];
int dp[N][N][2];
int a[2 * N];
int ans;
int n, A, B;

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	p2[0] = 1;
	for (int i = 1; i < N; i++)
		p2[i] = add(p2[i - 1], p2[i - 1]);
	ans = 0;

	scanf("%d%d%d", &n, &A, &B);
	if (A > B) swap(A, B);
	if (A == 1) {
		printf("%d\n", p2[n]);
		return 0;
	}
	dp[0][0][1] = 1;
	for (int pref = 0; pref <= n; pref++) {
		if (pref > 0) a[pref] = add(a[pref], a[pref - 1]);
		dp[pref][1][1] = add(dp[pref][1][1], a[pref]);
		ans = add(ans, mult(p2[n - pref], add(dp[pref][B][0], dp[pref][B][1])));
		if (pref == n) break;
		for (int g = 0; g < B; g++) {
			dp[pref + 1][g + 1][0] = add(dp[pref + 1][g + 1][0], dp[pref][g][0]);
			dp[pref + 1][g + 1][1] = add(dp[pref + 1][g + 1][1], dp[pref][g][0]);
			if (pref + A <= n)
				dp[pref + A][min(B, g + A)][0] = add(dp[pref + A][min(B, g + A)][0], dp[pref][g][1]);
			dp[pref + 1][g + 1][1] = add(dp[pref + 1][g + 1][1], dp[pref][g][1]);
			a[pref + 2] = add(a[pref + 2], dp[pref][g][1]);
			if (pref + A + 1 <= n)
				a[pref + A + 1] = sub(a[pref + A + 1], dp[pref][g][1]);
		}
	}
	printf("%d\n", ans);

	return 0;
}


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

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(int.Parse).GroupBy(x => x).Select(g => g.Count()).OrderBy(x => -x).ToArray();

		var f = new int[n + 1];
		for (int i = a.Length, c = 1; c <= n; c++)
		{
			while (i > 0 && a[i - 1] < c) i--;
			f[c] = f[c - 1] + i;
		}
		f[0] = int.MaxValue;
		for (int c = 1; c <= n; c++) f[c] /= c;

		var r = new int[n + 1];
		for (int c = n, i = 1; i <= n; i++)
		{
			while (f[c] < i) c--;
			r[i] = c;
		}
		Console.WriteLine(string.Join("\n", r.Skip(1)));
	}
}


Measured memory_bytes: 78480
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    int aNum, bNum, mNum;
    cin >> aNum >> bNum >> mNum;
    int a[101000], b[101000], m[101000];

    int aMin = INT32_MAX, bMin = INT32_MAX;
    for(int i = 0; i < aNum; i++){
        cin >> a[i];
        aMin = min(aMin, a[i]);
    }
    for(int i = 0; i < bNum; i++){
        cin >> b[i];
        bMin = min(bMin, b[i]);
    }

    int res = aMin + bMin;
    for(int i = 0; i < mNum; i++){
        int x, y, c;    cin >> x >> y >> c;
        x--; y--;
        res = min(res, a[x] + b[y] - c);
    }

    cout << res << endl;



    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int H, W;
	int i; int j;
	scanf("%d %d", &H, &W);
	while( 0 != H || 0 != W)
	{
		for(i=0; i<H; i++)
		{
			for(j=0; j<W; j++)
				printf("#");
			printf("\n");
		}
		printf("\n");
		scanf("%d %d", &H, &W);
	}

	return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define INF 1234567890
#define MIN -1

int N, Z, W;
vector<int> v;
int dp[2005][2005];

int main(){
  cin >> N >> Z >> W;
  v.push_back(Z);
  v.push_back(W);
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }
  
  N += 2;

  for(int i=N-1; i>=0; i--){
    for(int j=N-1; j>=0; j--){
      if(i == j) continue; //あり得ないパターンなので無視
      if(i == N-1 || j == N-1){ //最後のカードを取った場合
        dp[i][j] = abs(v[i]-v[j]);
      }
      else{
        int ret = (i<j)?MIN:INF;
        if(i<j){//Xさんの手番
          if(i == j-1){
            REP(k,j+1,N){
              ret = max(ret, dp[k][j]);
            }
          }else{
            ret = dp[j-1][j];
          }
        }else{//Yさんの手番
          if(j == i-1){
            REP(k,i+1,N){
              ret = min(ret, dp[i][k]);
            }
          }else{
            ret = dp[i][i-1];
          }
        }
        dp[i][j] = ret;
      }
    }
  }

  cout << dp[0][1] << endl;
  
  return 0;
}



Measured memory_bytes: 16000
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=b;i>=a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int n;
ll W;
ll w[111];
ll v[111];
ll dp[100100];
int main()
{
	cin>>n>>W;
	REP(i,n)
		cin>>w[i]>>v[i];
	REP(i,100100)
		dp[i]=INF;
	dp[0]=0; 
	REP(i,n)
		for(int j=100000;j>=v[i];j--)
		{
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
		}
	//REP(i,100000)
	//	cout<<dp[i]<<" ";
	for(int i=100000;i>=0;i--)
		if(dp[i]<=W){
		cout<<i<<endl;
		break;} 
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

const int maxn = 10;
int c[maxn][maxn];

void solve()
{
    char x, y;
    cin >> x >> y;
    if(x < y)   cout << "<";
    else if(x > y)  cout << ">";
    else    cout << "=";
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN 100001


ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

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

    string l;
    cin>>l;
    ll n = l.len();
    ll cnt = 0, ans = 0;
    loop(i,0,n+1){
        if(i == n){
            ans = (ans%mod + modexp(2, cnt, mod))%mod;
            continue;
        }
        if(l[i] == '0') continue;
        else if(l[i] == '1'){
            ans = (ans%mod + (modexp(2, cnt, mod) * modexp(3 ,n-i-1, mod))%mod)%mod;
            cnt++;
        }
    }
    print(ans);
        
    
}



Measured memory_bytes: 512
import java.util.Scanner;

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

		int n = scanner.nextInt();

		int a = scanner.nextInt();

		for(int i=1; i<=3;i++) {


		if(i != n && i != a) {
			System.out.println(i);
			return;
		}
		}
	}

}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;


void func()
{
	string S, T;
	cin >> S;
	cin >> T;

	if (1 > S.length() || S.length() > 10)
	{
		cout << "No\n";
		return;
	}

	if(S.length() + 1 != T.length())
	{
		cout << "No\n";
		return;
	}

	for (int i = 0; i < S.length(); ++i)
	{
		if(!islower(S[i]) || S[i] != T[i])
		{
			cout << "No\n";
			return;
		}
	}

	if (!islower(*T.rbegin()))
	{
		cout << "No\n";
		return;
	}

	cout << "Yes\n";
	return;
}

int main() {

//	while (1)
		func();
	return 0;
}


Measured memory_bytes: 3112
using System;

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

			if (n % 2 == 1)
			{
				Console.WriteLine("No");
				return;
			}

			string first = s.Substring(0, n / 2);
			string second = s.Substring(n / 2, n / 2);

			if (first.Equals(second))
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  char S;
  cin >> S;
  if(S == 'a' || S == 'i' || S == 'u' || S == 'e' || S == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
  return 0;
}

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

int main(){
 int k, a, b;
 cin>>k>>a>>b;
 for(int i = b; i >= a; i--){
     if(i % k == 0){
       cout<<"OK";
       break;
     }
     if(i == a)cout<<"NG";
   }

}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int c[N];

void add(int x, int y, int n) {
  for (; x <= n; x += x & -x) {
    c[x] += y;
  }
}

int query(int x) {
  int ret = 0;
  for (; x; x -= x & -x) {
    ret += c[x];
  }
  return ret;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<ii> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i].first, &a[i].second);
  }
  sort(a.begin(), a.end(), [](const ii& a, const ii& b) {
      return a.second - a.first < b.second - b.first;
    });
  int k = 0;
  for (int i = 1; i <= m; ++i) {
    while (k < n && a[k].second - a[k].first + 1 < i) {
      add(a[k].first, 1, m);
      add(a[k].second + 1, -1, m);
      ++k;
    }
    int cur = n - k;
    for (int j = i; j <= m; j += i) {
      cur += query(j);
    }
    printf("%d\n", cur);
  }
  return 0;
}


Measured memory_bytes: 3712
from itertools import product as pro
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
ans = [["#"] * len(s[0]) for i in range(len(s))]
visited = []

def dfs(p):
    if p in visited or s[p[0]][p[1]] == "#":
        return None

    temp = [1 if s[y+p[0]][x+p[1]] == '#' else 0 for (y, x) in pro([-1, 0, 1], [-1, 0, 1]) if 0 <= x+p[1] < len(s[0]) and 0 <= y+p[0] < len(s)]
    s[p[0]][p[1]] = sum(temp)


for i in range(len(s)):
    for j in range(len(s[0])):
        dfs([i, j])


for i in s:
    print(''.join(map(str, i)))


Measured memory_bytes: 9188