akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> b(n);

  for (int i = 0; i < n; i++) {
    if (n - i * 2 - 1 >= 0) b[i] = a[n - i * 2 - 1];
  }
  for (int i = 0; i < n; i++) {
    if (i * 2 - n % 2 < n && i * 2 - n % 2 >= 0)
      b[i + n / 2] = a[i * 2 - n % 2];
  }
  rep(i, n) cout << b[i] << endl;

  return 0;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
#define int long long

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

    int n;
    cin >> n;
    vector<int> as(n), ans(n);
    for (int i = 0; i < n; i++) cin >> as[i];
    long long sum = 0;
    long long hoge = 0;
    for (int i = 0; i < n; i++) {
        sum += as[i];
        if (i % 2 == 0 && i != n - 1) hoge += as[i];
    }
    sum /= 2;
    ans.back() = sum - hoge;
    for (int i = -1; i < n - 1; i++) {
        int idx = i;
        if (idx < 0) idx += n;
        int A = as[idx] - ans[idx];
        ans[i + 1] = A;
    }
    for (int i = 0; i < n; i++) {
        cout << 2 * ans[i] << ' ';
    }
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 5;

int ar[N][N];

bool cek[102];

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

    for (int i=1;i<=3;i++){
        for (int j=1;j<=3;j++){
            cin >> ar[i][j];
        }
    }

    int n;
    cin >> n;
    while (n--){
        int a;
        cin >> a;
        cek[a] = 1;
    }

    bool yes = 0;
    for (int i=1;i<=3;i++){
        int cnt1 = 0, cnt2 = 0;
        for (int j=1;j<=3;j++){
            if (cek[ar[i][j]]) cnt1++;
            if (cek[ar[j][i]]) cnt2++;
        }
        if (cnt1 >= 3 || cnt2 >= 3) yes = 1;
    }
    if (yes){
        cout << "Yes" << el;
        return 0;
    }
    yes = 1;
    for (int i=1;i<=3;i++){
        if (!cek[ar[i][i]]) yes = 0;
    }
    if (yes){
        cout << "Yes" << el;
        return 0;
    }
    yes = 1;
    for (int i=1;i<=3;i++){
        if (!cek[ar[i][4 - i]]) yes = 0;
    }
    if (yes){
        cout << "Yes" << el;
        return 0;
    }
    cout << "No" << el;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String str = reader.readLine();
			String number = reader.readLine();
			int q = Integer.parseInt(number);

			String mth;
			String[] method;
			int a = 0;
			int b = 0;
			String reverse;
			String prt;
			for (int i = 0; i < q; i++) {
				mth = reader.readLine();
				method = mth.split(" ");
				a = Integer.parseInt(method[1]);
				b = Integer.parseInt(method[2]);
				if (method[0].equals("print")) {
					prt = str.substring(a, b + 1);
					System.out.println(prt);
				} else if (method[0].equals("reverse")) {
					reverse = new StringBuffer(str.substring(a, b + 1)).reverse().toString();
					str = new StringBuilder(str).replace(a, b + 1, reverse).toString();
				} else {
					str = new StringBuilder(str).replace(a, b + 1, method[3]).toString();
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 25056
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

bool dp[2][9][7*7*7*7];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  while(cin>>N,N){
	int crt = 0, nxt = 1;
	dp[crt][4][0] = true;
	FOR(i,1,N+1){
	  REP(j,9) REP(k,7*7*7*7) dp[nxt][j][k] = false;
	  
	  VI vi(16);
	  REP(j,16) cin >> vi[j];

	  for(int idx=0;idx<9;++idx){
		for(int c=0;c<7*7*7*7;++c){
		  if(!dp[crt][idx][c]) continue;
		  set<int> p;
		  for(int x=idx/3*3;x<=idx/3*3+2;++x) p.insert(x);
		  for(int y=idx%3;y<9;y+=3) p.insert(y);
		  VI ps_(4);
		  int tmp = c;
		  REP(j,4){
			ps_[j] = tmp % 7;
			tmp /= 7;
		  }
		
		  for(int idx_: p){
			if(i == 1 && idx_ != 4) continue;
			int orig;
			if(idx_ < 3)
			  orig = idx_;
			else if(idx_ < 6)
			  orig = 1 + idx_;
			else
			  orig = 2 + idx_;
			if(vi[orig] || vi[orig+1] || vi[orig+4] || vi[orig+5]) continue;
			VI ps = ps_;

			if(idx_ != 0) ++ps[0];
			else ps[0] = 0;
			if(idx_ != 2) ++ps[1];
			else ps[1] = 0;
			if(idx_ != 6) ++ps[2];
			else ps[2] = 0;
			if(idx_ != 8) ++ps[3];
			else ps[3] = 0;
		  
			if(ps[0] >= 7 || ps[1] >= 7 || ps[2] >= 7 || ps[3] >= 7) continue;
			tmp = 0;
			REP(j,4) tmp = tmp*7 + ps[3-j];
			dp[nxt][idx_][tmp] = true;
		  }
		}
	  }
	  swap(crt, nxt);
	}
	bool ok = false;
	for(int idx=0;idx<9;++idx)
	  for(int c=0;c<7*7*7*7;++c)
		ok = ok || dp[crt][idx][c];

	cout << (ok? 1: 0) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String[] inputList = br.readLine().split(" ");
		int r = Integer.parseInt(inputList[0]);
		int c = Integer.parseInt(inputList[1]);
		int[][] list = new int[r + 1][c + 1];
		int i, j, num, sum;
		for (i = 0; i < r; i++) {
			sum = 0;
			String[] hoge = br.readLine().split(" ");
			for (j = 0; j < c; j++) {
				num = Integer.parseInt(hoge[j]);
				list[i][j] = Integer.parseInt(hoge[j]);
				sum = sum + num;
			}
			list[i][c] = sum;
		}

		for (i = 0; i < c + 1; i++) {
			sum = 0;
			for (j = 0; j < r + 1; j++) {
				sum = sum + list[j][i];
			}
			list[r][i] = sum;
		}

		String output;
		for (i = 0; i < r + 1; i++) {
			output = "";
			for (j = 0; j < c + 1; j++) {
				output = output + list[i][j] + " ";
			}
			System.out.println(output.substring(0, output.length() - 1));
		}
	}
}

Measured memory_bytes: 41028
#include <cstdio>
const int maxn = 1e5+5;
int n,m,fa[maxn<<4],vis[maxn<<1];
inline int getfa(int x){return fa[x] == x ? x : fa[x] = getfa(fa[x]);}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=3*n;++i)fa[i] = i;
	int cnt = 0;
	for(int i=1,x,y,z;i<=m;++i){
		char c[2];
		scanf("%d %d %d",&x,&y,&z);
		if(z%2==0){
			int fx = getfa(x+n),fy = getfa(y+n);
			if(fx != fy)fa[fx] = fy;
			fx = getfa(x+n+n),fy = getfa(y+n+n);
			if(fx != fy)fa[fx] = fy;
		}
		else{
			int fx = getfa(x+n+n),fy = getfa(y+n);
			if(fx != fy)fa[fx] = fy;
			fx = getfa(x+n),fy = getfa(y+n+n);
			if(fx != fy)fa[fx] = fy;
		}
		int fx = getfa(x),fy = getfa(y);
		if(fx != fy)fa[fx] = fy;
	}
	for(int i=1;i<=n;++i){
		int fx = getfa(i);
		if(!vis[fx])vis[fx] = 1,++cnt;
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 3792
def main():
    sx, sy, tx, ty = map(int, input().split())
    path = []
    path.append(''.join('U' * (ty - sy)))
    path.append(''.join('R' * (tx - sx)))
    path.append(''.join('D' * (ty - sy)))
    path.append(''.join('L' * (tx - sx)))

    path.append('L')
    path.append(''.join('U' * (ty - sy + 1)))
    path.append(''.join('R' * (tx - sx + 1)))
    path.append('D')
    path.append('R')
    path.append(''.join('D' * (ty - sy + 1)))
    path.append(''.join('L' * (tx - sx + 1)))
    path.append('U')

    ans = ''.join(path)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define rap(i, a, n) for(int i=a; i<=n; i++)
#define rep(i, a, n) for(int i=a; i<n; i++)
#define lap(i, a, n) for(int i=n; i>=a; i--)
#define lep(i, a, n) for(int i=n; i>a; i--)
#define rd(a) scanf("%d", &a)
#define rlld(a) scanf("%lld", &a)
#define rc(a) scanf("%c", &a)
#define rs(a) scanf("%s", a)
#define rb(a) scanf("%lf", &a)
#define rf(a) scanf("%f", &a)
#define pd(a) printf("%d\n", a)
#define plld(a) printf("%lld\n", a)
#define pc(a) printf("%c\n", a)
#define ps(a) printf("%s\n", a)
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _  ios_base::sync_with_stdio(0),cin.tie(0)
using namespace std;
const int maxn = 1100000, INF = 0x7fffffff, MOD = 1e9 + 7;

LL D[maxn], U[maxn];
LL q_pow(LL a, LL b)
{
    LL ret = 1;
    while(b)
    {
        if(b & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ret;
}

void init()
{
    U[0] = D[0] = 1;
    for(int i = 1; i < maxn; i++)
    {
        U[i] = U[i - 1] * i % MOD;
        D[i] = q_pow(U[i], MOD - 2);
    }
}

LL C(LL n, LL m)
{
    return U[n] * D[m] % MOD * D[n - m] % MOD;
}

int main()
{
    init();

    LL h, w, a, b, ret = 0;
    cin >> h >> w >> a >> b;
    for(int i = b + 1; i <= w; i++)
    {
        ret = (ret + C(h - a + i - 2, i - 1) * C(a - 1 + w - i, a - 1)) % MOD;
    \
    }
   ret = (ret % MOD + MOD) % MOD;
   cout << ret << endl;




    return 0;
}
 

Measured memory_bytes: 17536
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b&&b==c) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
  int main()
{	
    ll n,k;
    cin>>n>>k;
    ll a[n],b[n+1],c[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    b[0]=0;
    b[1]=abs(a[0]-a[1]);
    for(ll i=2;i<n;i++) 
    {
        b[i]=100000000000000000;
        for(ll j = max(i-k,0LL);j<i;j++)
        {
            b[i]=min(b[i],abs(a[j]-a[i])+b[j]);
        }
    }   
    cout<<b[n-1];
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>

using namespace std;

#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
int main(){
    string s;
    cin>>s;

    int a=-1,z=-1,i;

    REP(i,0,s.size()){
        if(s[i]=='A'){
            a=i;
            break;
        }
    }
    RREP(i,s.size(),0){
        if(s[i]=='Z'){
            z=i;
            break;
        }
    }

    cout<<z-a+1<<endl;
}


Measured memory_bytes: 832
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,point[200007],pat[200007] = { 0 };
	int sum = 0,i = 1;
	scanf("%d",&n);
	for (i = 1; (i <= n && sum < n); ++i)
	{
		sum += i;
		point[i] = i;
		pat[i] = 1;
	}
	if(sum == n){
		for (int k = 1; k < i; ++k)
		{
			if(pat[k])	printf("%d\n",point[k]);
		}
	}
	else{
		pat[abs(sum - n)] = 0;
		for (int k = 1; k < i; ++k)
		{
			if(pat[k])	printf("%d\n",point[k]);
		}
	}
	return 0;
}


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

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

	int n;
	cin>>n;
	int a[10001];
	for(int i=0;i<n;++i)
		cin>>a[i];
	int cnt=0;
	for(int i=0;i<n;++i)
		while(a[i]%2==0)
		{
			cnt++;
			a[i]/=2;
		}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define dump(x) cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else
const bool test = false;
#endif

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

void solve();

signed main()
{
    cout << fixed << setprecision(20);
    solve();
    while (true)
    {
        char s[MAX];
        if (scanf("%s", s) == EOF)
            break;
        int n = strlen(s);
        for (int i = n - 1; i > -1; i--)
        {
            ungetc(s[i], stdin);
        }
        solve();
    }
    return 0;
}

int n;
string s[50];
int a[30][50];
 
void solve() {
    cin >> n;
    rep(i, n) cin >> s[i];

    rep(i, n) {
        rep(j, (int)s[i].size()) {
            a[s[i][j] - 'a'][i]++;
        }
    }
    rep(i, 30) {
        int min_v = *min_element(a[i], a[i] + n);
        rep(j, min_v) cout << (char)('a' + i);
    }
    cout << endl;
}


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

int main() {  
  vector<string> c(3);
  for(int i = 0; i < 3; i++) {
    cin >> c.at(i);
  }
  
  cout << c.at(0).at(0) << c.at(1).at(1) << c.at(2).at(2) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

string A,B,C;

int main(void) {
	cin >> A >> B >> C;
	if (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0])ct("YES");
	else ct("NO");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint N;
	cin >> N;
	lint X = N * 800;
	lint Y = (N / 15) * 200;
	cout << X - Y << endl;
}

Measured memory_bytes: 3616
//              *           ***********    *********         *         **           *
//            *   *         *         *       ***          *   *       *  *         *
//          *       *       *         *       ***         *     *      *    *       *
//         ***********      ***********       ***        *********     *      *     *
//        *           *     *  *              ***       *         *    *        *   *
//       *             *    *     *           ***      *           *   *          * *
//       *             *    *        **    *********   *           *   *           **

//       **********                *                ***********       ***********
//       *        *              *   *              *                 *
//       *      *              *       *            *                 *
//       * * *                ***********           ***********       ***********
//       * * *               *           *                    *                 *
//       *      *           *             *                   *                 *
//       *        *        *               *                  *                 *
//       **********        *               *        ***********       ***********

#include <iostream>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <float.h>
#include <stdio.h>
#include <chrono>
#include <cmath>
#include <vector>
#include <deque>
#include <queue>
#include <stack>

#define ll long long
#define dou double
#define Turbo std::ios::sync_with_stdio(false)

using namespace std ;

// Until 256 ;)

const int N = 1e5 + 20 ;
ll a [N] , b [N] , c [N] , ans = 0 ;

int main () {
    Turbo ;
    ll n ;
    cin >> n ;
    for (ll i = 0 ; i < n ; i ++) {
        cin >> a [i] >> b [i] ;
        ans -= b [i] ;
        c [i] = a [i] + b [i] ;
    }
    sort (c , c + n , greater <int> ()) ;
    for (ll i = 0 ; i < n ; i += 2) {
        ans += c [i] ;
    }
    cout << ans << '\n' ;
    return 0 ;
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>

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

int main() {
	int N;
	cin >> N;
	int B[100];
	int i;
	rep(i, N-1)
		cin >> B[i];
	int ans = 0;

	ans += B[0] + B[N - 2];
	for (i = 1; i <= N-2; i++) {
		ans += (B[i - 1] < B[i] ? B[i - 1] : B[i]);
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};

ll a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n;cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    __int128 ans=1;
    for(int i=1;i<=n;i++){
        ans*=a[i];
        if(ans>1000000000000000000){
            cout<<-1;
            return 0;
        }
    }
    ll now=ans;
    cout<<now;
    return 0;
}


Measured memory_bytes: 4428
#include<iostream>

using namespace std;

const int N_MAX = 1000;
const int INT_MAX = 99999;

int main()
{
    int N, T;
    int c[N_MAX], t[N_MAX];
    bool checkTime[N_MAX];
    for (int i = 0; i<N_MAX; i++)
    {
        checkTime[i] = false;
    }
    cin >> N >> T;
    for (int i = 0; i<N; i++)
    {
        cin >> c[i] >> t[i];
        if (t[i] <= T) checkTime[i] = true;
    }
    
    int minCost = INT_MAX;
    bool updateFlg = false;
    for (int i = 0; i<N; i++)
    {
        if ( checkTime[i] && c[i] < minCost )
        {
            minCost = c[i];
            updateFlg = true;
        }
    }

    if (updateFlg) cout << minCost << endl;
    else cout << "TLE" << endl;
    
    return 0;
}

Measured memory_bytes: 256
def examB():
    N = I(); K = I()
    cur = 1
    for i in range(N):
        cur = min(cur*2,cur +K)
    print(cur)

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3520
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
using namespace std;
template<class _T>inline void read(_T &_a)
{
	bool f=0; char _c=getchar(); _a=0;
	while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
	while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
	if(f) _a=-_a;
}

int n,k,beg;
long long ans1,ans2,ans,lst,sum[200001];
const long long begi=226732710;

int main()
{
	read(n); read(k);
	for (int i=1;i<=n;++i) sum[i]=sum[i-1]+i;
	while(k<=n+1)
	{
		ans1=ans2=0;
		ans2=sum[n]-sum[n-k];
		ans1=sum[k-1];
		ans+=ans2-ans1+1;
		ans%=1000000007;
		++k;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  string S;
  cin >> S;
  int N = S.size();
  reverse(S.begin(), S.end());
  string T[4];
  T[0] = "maerd";
  T[1] = "remaerd";
  T[2] = "esare";
  T[3] = "resare";
  int i=0;
  bool ok = true;
  while(true){
    if(i == N) break;
    if(S.substr(i,5) == T[0]){
      i += 5;
      continue;
    }
    if(S.substr(i,5) == T[2]){
      i += 5;
      continue;
    }
    if(S.substr(i,6) == T[3]){
      i += 6;
      continue;
    }
    if(S.substr(i,7) == T[1]){
      i += 7;
      continue;
    }
    ok = false;
    break;
  }
  cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>

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

int main() {
	int H[100000];
	int A[100000] = { 0 };
	int N;
	cin >> N;
	int i;
	rep(i, N) {
		cin >> H[i];
	}
	int Max = 0;
	for (i = N - 2; i >= 0; i--) {
		if (H[i] >= H[i+1]) {
			A[i] = A[i + 1] + 1;
		}
		if (Max < A[i])Max = A[i];
	}

	cout << Max;
	return 0;

}



Measured memory_bytes: 1024
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String op  = sc.next();
        String B = sc.next();
        int a = Integer.parseInt(A);
        int b = Integer.parseInt(B);
        
        if(op.equals("+")){
            System.out.println(a+b);
        }else{
            System.out.println(a-b);
        }
	}
}

Measured memory_bytes: 35604
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,s=0;
    scanf("%d%d%d",&a,&b,&c);
    int d=max(a,b);
    d=max(c,d);
    int k=min(a,b);
    k=min(k,c);
    int mid=a+b+c-d-k;
    s+=d-mid;
    if((mid-k)%2==0)
    s+=(mid-k)/2;
    else
    s+=(mid-k)/2+2;
    printf("%d\n",s);
    //printf("%d %d %d",d,mid,k);
    return 0;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/agc033/tasks/agc033_b

HWN = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
S = list(str(input()))
T = list(str(input()))

Rn = HWN[1] - s[1] + 1
Ln = HWN[1] - Rn + 1
Dn = HWN[0] - s[0] + 1
Un = HWN[0] - Dn + 1



l = 0
r = 0
u = 0
d = 0
stat = 0
for i in range(HWN[2]):
    if S[i] == 'L':
        l += 1
    if S[i] == 'R':
        r += 1
    if S[i] == 'U':
        u += 1
    if S[i] == 'D':
        d += 1

    #print(l,r,u,d)

    if l >= Ln or r >= Rn or u >= Un or d >= Dn:
        stat = 1
        break
    
    if T[i] == 'L':
        r -= 1
    if T[i] == 'R':
        l -= 1
    if T[i] == 'U':
        d -= 1
    if T[i] == 'D':
        u -= 1
    
    if -l >= Rn:
        l = -Rn + 1
    if -r >= Ln:
        r = -Ln + 1
    if -u >= Dn:
        u = -Dn + 1
    if -d >= Un:
        d = -Un + 1

    #print(l,r,u,d)

    if l >= Ln or r >= Rn or u >= Un or d >= Dn:
        stat = 1
        break
    

if stat == 1:
    print('NO')
else:
    print('YES')

    

Measured memory_bytes: 6832
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    
    long long int n,k,s,i,x;
    cin>>n>>k>>s;
     x=s+1;
     if(s==1000000000)
        x=s-1;
        for(i=1;i<=n;i++)
        {
            if(i<=k)
             cout<<s<<" ";
            else
             cout<<x<<" ";
        }
   
}


Measured memory_bytes: 1280
#include<cstdio>
int a,b,c,x,ans;
int main() {
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(500*i+100*j+50*k==x)
					ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    ll t, a, n; cin >> t >> a >> n;
    
    if(t - n > 0) t -= n;
    else if(a + t - n > 0){
        a -= n - t;
        t = 0;
    }else{
        t = 0;
        a = 0;
    }

    cout << t << " " << a << endl;
}

Measured memory_bytes: 256
program abc
	implicit none
	integer(8) :: n
    integer :: a,b,c,d

	read(*,*) n
	
	a = n / 500
    b = n - a * 500
    c = b / 5
    d = 1000 * a + 5 * c
    
	write(*,*) d
    
end program abc

Measured memory_bytes: 768
N = int(input())
ab = [list(map(int,input().split())) for _ in range(N-1)]

connect = [[] for _ in range(N)]
for a,b in ab:
    connect[a-1].append(b-1)
    connect[b-1].append(a-1)

q = [0]
k = 0
d = [-1] * N
d[0] = 1
while k < len(q):
    i = q[k]
    di = d[i]
    for j in connect[i]:
        if d[j] == -1:
            d[j] = di + 1
            q.append(j)
    k += 1
q = [d.index(max(d))]
k = 0
d = [-1] * N
d[q[0]] = 1
while k < len(q):
    i = q[k]
    di = d[i]
    for j in connect[i]:
        if d[j] == -1:
            d[j] = di + 1
            q.append(j)
    k += 1

size = max(d)
if size == 1:
    print("First")
elif size == 2:
    print("Second")
elif size%3 == 2:
    print("Second")
else:
    print("First")

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

int main()
{
    int n;
    cin >> n;
    vector<int> A(n + 2, 0);
    rep(i, n) cin >> A.at(i + 1);

    int all_length = 0;
    for (int i = 0; i <= n; i++)
    {
        all_length += abs(A.at(i) - A.at(i + 1));
    }

    for (int i = 1; i <= n; i++)
    {
        cout << all_length + abs(A.at(i - 1) - A.at(i + 1)) - (abs(A.at(i - 1) - A.at(i)) + abs(A.at(i) - A.at(i + 1))) << endl;
    }
}

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

using namespace std;

int main(void)
{
    int n;
    int min = 10000,max = -1;

    cin>>n;
    for(int i = 0;i < n;i++)
    {
	int a;
	cin>>a;

	min = min < a ? min : a;
	max = max > a ? max : a;
    }

    cout<<max-min<<endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int> H(N);
  for (int i=0 ; i < N; i++){
  cin >> H.at(i);
  }
  
  vector<int> count(N,0);
  
  for(int i = 1; i< N; i++){
    if(H.at(i) <= H.at(i-1)){
      count.at(i) = count.at(i-1) + 1;
    }
    else{
      count.at(i) = 0;
    }
    
  }
  sort(count.rbegin(), count.rend());

  cout << count.at(0)<< endl;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.TreeMap;

public class Main{
	public static void main(String[] args) {
		FastScanner stdIn = new FastScanner();
		
		int n = stdIn.nextInt();
		Map<String,Integer> map = new TreeMap<>();
		int max = 0;
		for(int i = 0; i < n; i++) {
			String s = stdIn.next();
			int val = map.containsKey(s)?map.get(s)+1:1;
			map.put(s,val);
			max = Math.max(max, val);
			
		}
		for(String s:map.keySet()) {
			if(map.get(s)==max) {
				System.out.println(s);
			}
		}
	
	}

}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 66912
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <stdio.h>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
ull gcd(ull a, ull b){return b? gcd(b, a%b):a;}
using namespace std;

int a[100001];
bool check[100001] = {false};

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

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

	int index = a[0] - 1;
	int count = 1;
	while(check[index] != true){
		check[index] = true;
		if(index == 1){
			cout << count << endl;
			return 0;
		}
		index = a[index] - 1;
		count++;
	}
	cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 768
N, M = map(int, input().split())
dic = {}
for i in range(N):
    A, B = map(int, input().split())
    if A in dic:
        dic[A] += B
    else:
        dic[A] = B
dic = sorted(dic.items())


sum = 0
for A, B in dic:
    if B < M:
        sum += A * B
        M -= B
    else:
        sum += A * M
        break

print(sum)


Measured memory_bytes: 22996
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

std::vector<std::pair<int, int>> queue;

int main()
{
    int n;
    std::cin >> n;

    std::vector<std::vector<int>> p(n, std::vector<int>(n - 1));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            std::cin >> p[i][j];
            p[i][j]--;
        }
        reverse(p[i].begin(), p[i].end());
    }

    auto check = [&](int player) {
        if (!p[player].size()) {
            return;
        }

        int opponent = p[player].back();

        if (!p[opponent].size()) {
            return;
        }

        if (p[opponent].back() != player) {
            return;
        }

        std::pair<int, int> p(player, opponent);
        if (p.first > p.second) {
            std::swap(p.first, p.second);
        }
        queue.push_back(p);
    };

    for (int i = 0; i < n; i++) {
        check(i);
    }

    long long day = 0;

    while (queue.size()) {
        day++;
        std::sort(queue.begin(), queue.end());
        queue.erase(std::unique(queue.begin(), queue.end()), queue.end());
        std::vector<std::pair<int, int>> past_queue;
        swap(past_queue, queue);

        for (auto t : past_queue) {
            int first = t.first;
            int second = t.second;

            p[first].pop_back();
            p[second].pop_back();

            check(first);
            check(second);
        }
    }

    for (auto t : p) {
        if (t.size()) {
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    std::cout << day << std::endl;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int input[100] = {0};
    vector <int> output;
    int num;
    
    while (cin >> num) 
        input[num - 1]++;

    int max = 0;
    for (int i = 0; i < 100; i++) 
        if (input[i] > max)
            max = input[i];

    for (int i = 0; i < 100; i++)
        if (input[i] == max)
            output.push_back(i + 1);

    sort(output.begin(), output.end());
    for (int i = 0; i < output.size(); i++)
        cout << output[i] << endl;
    
    return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>

int main() {
    int a,b,c;

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

    if (a < b) {
        if ( b < c) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    } else {
        printf("No\n");
    }

    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    ll N; cin >> N;
    string name;
    while(N > 0){
        N--;
        name.push_back(N%26+'a');
        N/=26;
    }
    reverse(all(name));
    cout << name << endl;
    return 0;
}

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

int main()
{
   int animal,leg;cin>>animal>>leg;

   for(int i=0;i<=animal;i++)
   {
       int x=2*i;
       int y=(animal-i)*4;

       if(x+y==leg)
       {
           cout<<"Yes"<<endl;return 0;
       }
   }

   cout<<"No"<<endl;


}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

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

    return gcd(b, a % b);
}

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N);
    REP(i, N)
    {
        cin >> a[i];
        a[i] /= 2;
    }

    ll lcm = a[0];
    bool flag = true;
    REP(i, N - 1) 
    {
        lcm = lcm * a[i + 1] / gcd(lcm, a[i + 1]);
        if (lcm > M)
        {
            flag = false;
            break;
        }
        if ((lcm / a[i + 1]) % 2 == 0) 
        {
            flag = false;
            break;
        }
    }

    ll ans;
    if (!flag)
    {
        ans = 0;
    }
    else
    {
        ll num = (M / lcm);
        if (num % 2 == 0)
        {
            ans = num / 2;
        }
        else
        {
            ans = num / 2 + 1;
        }
        
    }
    cout << ans << endl;
}


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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<int,int> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

int h[N];
double v[N];
int main(){
	int n; cin>> n;
	int t , a; cin>> t >> a;
	rep(i,1,n){
		cin>> h[i];
	}
	rep(i,1,n){
		v[i] = t*1.0 - (h[i]*0.006);
	}
	
	//~ rep(i,1,n){
		//~ cout<<v[i]<<" ";
	//~ }
	
	//~ cout<<endl;
	double d = inf;
	int ans = 0;
	rep(i,1,n){
		double x = abs(a*1.0 - v[i]);
		//~ cout<< x << " ";
		if(x < d){
			d = x;
			ans = i;
		}
	}
	//~ cout<<endl;
	cout<< ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int n,m,a[N],b[N],f[N];
#define ll long long 
ll size[N];
ll ans,sum,res[N]; 
int find(int x)     //并查集 
{
	if(f[x]==x) return x;
	else return f[x]=find(f[x]);
}
int main(){
	cin>>n>>m;
	sum=(ll)n*(n-1)/2;
	for(int i=1;i<=m;i++)cin>>a[i]>>b[i];
	for(int i=1;i<=n;i++) f[i]=i,size[i]=1;
	for(int i=m;i>=1;--i){
		res[i]=sum-ans;
		int x=find(a[i]),y=find(b[i]);
		if(x!=y){
			ans+=size[x]*size[y];
			size[x]+=size[y];
			f[y]=x;
		}
	} 
	for(int i=1;i<=m;++i) printf("%lld\n",res[i]);
} 

Measured memory_bytes: 4096
//Code By: pratibha_899 (Pratibha Shrivastav)
 
/********   All Required Header Files ********/
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
 
using namespace std;
 
//All the Loops and defines required
typedef long long int ll;
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define ff first
#define ss second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
// #define INFI 100000000000000
 
//All the declarations using typedef
typedef pair<ll, ll> PII;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<ll, ll> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int l;
typedef unsigned long int ul;
typedef unsigned long long int  ull;
 
const ll INFI = 1e18 + 7;


ll knapsack(ll n,ll w, ll weights[], ll values[],ll sum_values){
	
    ll dp[n+1][sum_values+1];
	
    for(ll i=0;i<=n;i++){
		for(ll j=0;j<=sum_values;j++)
			dp[i][j]=INFI;
	}
	
  for(ll i=0;i<n+1;i++)
		dp[i][0]=0;
	
    for(ll i=1;i<n+1;i++){
		for(ll j=sum_values;j>=0;j--){
                if(values[i]<=j)
                    dp[i][j]=min(dp[i-1][j],dp[i-1][j-values[i]]+weights[i]);
                else
                    dp[i][j] = dp[i-1][j];
        }
	}
  
	ll max_value;
	for(ll i=0;i<=sum_values;i++){
        if(dp[n][i]<=w)
            max_value=i;
	}
	return max_value;
}
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,w;
	cin>>n>>w;
	ll weights[n+1];
	ll values[n+1];
	for(ll i=1;i<=n;i++)
		cin>>weights[i]>>values[i];
	ll sum_values=0;
	for(ll i=1;i<=n;i++)
		sum_values+=values[i];
	ll res = knapsack(n,w,weights,values,sum_values);
	cout<<res;
	return 0;
}

Measured memory_bytes: 79232
from math import atan, degrees

a, b, x = map(int, input().split())
v = a ** 2 * b

if x < v / 2:
    theta = atan(a * b ** 2 / (2 * x))
else:
    theta = atan(2 * (v - x) / a ** 3)

print(degrees(theta))

Measured memory_bytes: 3060
S = input()
def kaibun(S):
  for i in range(len(S)//2):
    if S[i] != S[-i-1]:
      return False
      break
  else:
    return True

if kaibun(S) and kaibun(S[:len(S)//2]) and kaibun(S[(len(S)+3)//2-1:]):
  print ("Yes")
else:
  print ("No")

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

type Puzzle struct {
	numbers     []int
	iZero       int
	pathHistory string
}

func (p Puzzle) toString() string {
	s := ""
	for i := 0; i < len(p.numbers); i++ {
		s += strconv.Itoa(p.numbers[i])
	}
	return s
}

func newPuzzle(size int) Puzzle {
	puzzle := Puzzle{}
	puzzle.numbers = make([]int, size)
	return puzzle
}

func (p *Puzzle) isSolved() bool {
	for i := 0; i <= 7; i++ {
		if p.numbers[i] != i+1 {
			return false
		}
	}
	return true
}

func (p *Puzzle) swap(i, j int) {
	p.numbers[i], p.numbers[j] = p.numbers[j], p.numbers[i]
}

func copy(p1, p2 *Puzzle) {
	p1.numbers = append([]int{}, p2.numbers...)
	p1.iZero = p2.iZero
	p1.pathHistory = p2.pathHistory
}

var d = []int{1, -3, -1, 3}

func newQueue() Queue {
	queue := Queue{}
	queue.array = []Puzzle{}
	return queue
}

type Queue struct {
	array []Puzzle
}

func (q *Queue) push(p Puzzle) {
	q.array = append(q.array, p)
}

func (q *Queue) pop() Puzzle {
	p := q.array[0]
	q.array = q.array[1:len(q.array)]
	return p
}

func (q *Queue) isEmpty() bool {
	return len(q.array) == 0
}

func bfs(start Puzzle) string {
	queue := newQueue()
	queue.push(start)

	history := map[string]bool{}
	history[start.toString()] = true

	for !queue.isEmpty() {
		u := queue.pop()
		if u.isSolved() {
			return u.pathHistory
		}

		for i := 0; i < 4; i++ {
			di := d[i]

			iZeroOld := u.iZero
			iZeroNew := u.iZero + di

			if iZeroNew < 0 || iZeroNew >= 9 || (di == -1 && iZeroOld%3 == 0) || (di == 1 && iZeroOld%3 == 2) {
				continue
			}

			v := Puzzle{}
			copy(&v, &u)
			v.swap(iZeroOld, iZeroNew)

			if !history[v.toString()] {
				history[v.toString()] = true
				v.iZero = iZeroNew
				v.pathHistory += strconv.Itoa(iZeroOld)
				// fmt.Println(v.toString())
				queue.push(v)
			}
		}
	}

	return "failed"
}

func main() {
	scanner.Split(bufio.ScanWords)

	puzzle := newPuzzle(9)
	for j := 0; j < 9; j++ {
		puzzle.numbers[j] = nextInt()
		if puzzle.numbers[j] == 0 {
			puzzle.iZero = j
		}
	}

	nUpdates := bfs(puzzle)

	fmt.Println(len(nUpdates))
}



Measured memory_bytes: 33260
#include<bits/stdc++.h>
#define ll long long
#define MAX 200005
using namespace std;

const int mod = 998244353;

ll fact[MAX], finv[MAX];

ll modpow(ll a, ll b)
{
    if (b == 0) return 1;
    ll u = modpow(a, b / 2);
    u = (u * u)%mod;
    if (b%2) u = (u * a)%mod;
    return u;
}

void fillup(ll n)
{
    fact[0] = 1;
    for (ll i = 1; i <= n; i++) {
        fact[i] = ((fact[i - 1]%mod) * (i%mod))%mod;
    }
    finv[n] = modpow(fact[n], mod - 2);
    for (ll i = n - 1; i >= 0; i--) {
        finv[i] = finv[i + 1] * (i + 1)%mod;
    }
}

ll ncr(ll n, ll r)
{
    ll ans = fact[n] * finv[r]%mod * finv[n - r];
    return (ans%mod + mod)%mod;
}

int main()
{
    ll n, m, k;
    cin >> n >> m >> k;
    fillup(n);
    ll ans = 0;
    for (ll i = 0; i <= k; i++) {
        ans += ncr(n - 1, i) * m%mod * modpow(m - 1, n - 1 - i)%mod;
        ans %= mod;
    }
    cout << (ans%mod + mod)%mod << "\n";
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	string s;
	cin>>s;
	deque<pair<char, int> > dq;
	for(auto ch : s){
		if(dq.empty() || dq.back().first != ch)dq.push_back({ch, 1});
		else dq.back().second++;
	}
	for(int i = 0; i < dq.size(); i += 2){
		int r = dq[i].second;
		int l = dq[i + 1].second;
		for(int j = 1; j < r; j++){
			cout<<0<<" ";
		}
		int tot = r + l;
		if(tot&1){
			if(r&1)cout<<(tot + 1)/2<<" "<<tot/2<<" ";
			else cout<<tot/2<<" "<<(tot + 1)/2<<" ";
		}else{
			cout<<tot/2<<" "<<tot/2<<" ";
		}
		for(int j = 1; j < l; j++){
			cout<<0<<" ";
		}
	}
	cout<<'\n';

	return 0;
}

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 59;
const int mod = 1e9 + 7;


int N;
int A[3000];
bool memo[3000][3000];
int64 dp[3000][3000];

int64 rec(int l, int r) {
  if(l > r) return 0;
  if(exchange(memo[l][r], true)) return dp[l][r];
  int64 ret = max(A[r] - rec(l, r - 1), A[l] - rec(l + 1, r));
  return dp[l][r] = ret;
}


int main() {
  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];
  cout << rec(0, N - 1) << endl;
}




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

int main()
{
	int n;
	int ans = 1;

	cin >> n;

	vector<int> v(n);

	for(int i=0; i<n; i++) cin >> v[i];

	sort(v.begin(), v.end(), std::greater<int>() );

	for(int i=1; i<n; i++)
		if(v[i-1] != v[i])
			ans++;

	//for(int i=0; i<n; i++) std::cout << v[i];
	std::cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
  ll n;
  cin >>n;
  ll f[n][10];
  for(ll i=0;i<n;i++){
     for(ll j=0;j<10;j++){
        cin >> f[i][j];
      }
  }
  ll p[n][11];
  for(ll i=0;i<n;i++){
    for(ll j=0;j<11;j++){
      cin >>p[i][j];
    }
  }
  ll ans=-1e10;
  ll c[n];
  for(ll i=1;i<(1<<10);i++){
    for(ll i=0;i<n;i++) c[i]=0;
    for(ll k=0;k<n;k++){
     for(ll j=0;j<10;j++){
       if(i&(1<<j)){
         if(f[k][j]==1) c[k]++;
       }
     }
    }
  ll sum=0;
  for(ll j=0;j<n;j++) {
    sum+=p[j][c[j]];
  }
  ans=max(ans,sum);
  }
cout <<ans<<endl;
}


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

int main() {
  int n, k, h;
  int cnt = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> h;
    if (h >= k) cnt++;
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256