akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n,p;
	cin >> n >> p;
	map<ll,ll> m;
	// ll maxi = -1;
	ll res = p;
	for(ll i = 2; i*i <= p ; i++){
		m[i] = 0;
		while(res%i==0){
			res/=i;
			m[i]++;
		}
	}
	if (res != 1)
	{
		m[res] = 1;
	}
	ll ans = 1;
	for(map<ll,ll>::iterator itr = m.begin(); itr != m.end(); ++itr){
		//cout << itr->first << " " << itr->second/n << endl;
		ans *= pow(itr->first,itr->second/n);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 62720
import sys
from collections import deque
import heapq
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

num = 0
for i in a:
  num +=  1/i

print(1/num)

Measured memory_bytes: 3444
/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

 */

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define int long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector< vector<int> > vvi;
typedef vector< pair<int, int> > vpi;
#define MAXN 300005
#define MOD 1000000007
#define INF 1000000000000000007


signed main(){
	fast
	int k, x;
	cin>>k>>x;
	For(i, x-k+1, k+x){
		cout<<i<<" ";
	}
	cout<<endl;
    return 0;
}
    



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[101][100001];
int main(){
	fill(dp[0],dp[101],1000000001);
	dp[0][0]=0;
	int n,W,w[100],u[100];
	cin>>n>>W;
	for(int i=0;i<n;i++)
		cin>>w[i]>>u[i];
	for(int i=1;i<=n;i++)
		for(int j=0;j<=100000;j++)
			if(j>=u[i-1])
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-u[i-1]]+w[i-1]);
			else
				dp[i][j]=min(dp[i-1][j],w[i-1]);
	int ans=0;
	for(int i=0;i<=100000;i++)
		if(dp[n][i]<=W)
			ans=i;
	cout<<ans<<endl;
}


Measured memory_bytes: 39680
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  long n,k;
  cin>>n>>k;

  vector<pair<int,int>> v(n);
  rep(i,n) cin>>v[i].second>>v[i].first;
  rep(i,n) v[i].second--;

  sort(all(v));
  reverse(all(v));

  long cur = 0;
  priority_queue<int, vector<int>, greater<int>> pq;
  int num_groups = 0;
  vector<bool> use_group(n,false);

  rep(i,k){
    if(use_group[v[i].second]){
      pq.push(v[i].first);
    }
    use_group[v[i].second] = true;
    cur += v[i].first;
  }

  rep(i,n) if(use_group[i]) num_groups++;

  long ans = cur + (long)num_groups * num_groups;

  rep(i,k,n){
    if(!use_group[v[i].second] && !pq.empty()){
      num_groups++;
      cur -= pq.top();
      pq.pop();
      cur += v[i].first;
      ans = max(ans, cur + (long)num_groups * num_groups);
      use_group[v[i].second] = true;
    }
  }  

  cout << ans << endl;

  return 0;
}


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

int main()
{
 bool prime[10000000];

 prime[0]=prime[1]=false;
 for(int i=2;i<10000000;i++){
	prime[i]=true;
 }
 for(int i=2;i*i<10000000;i++){
	if(prime[i]){
		for(int j=i*i;j<10000000;j+=i){
			prime[j]=false;
		}
	}
 }
//???????????§?´???°??¨
 int n;
 while(1){
	cin>>n;
  if(n==0)break;
	for(int i=n;i>0;i--){
		if(prime[i-8]&&prime[i-6]&&prime[i-2]&&prime[i]){
			cout<<i<<endl;
			break;
		}
	}
 }
 return 0;
}
	

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

int main(){
    long long n,k;
    cin>>n>>k;
    int a[n],b[n];
    long long sum=0;
    map<long long,long long> mp;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        mp[a[i]]+=b[i];
    }
    for(auto m : mp){
        sum+=m.second;
        if(sum>=k){
            cout<<m.first<<endl;
            return 0;
        }
    }
}

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,M=0;
    string s;
    cin>>n;
    map<string,int>mp;
    rep(i,0,n){
        cin>>s;
        mp[s]++;
        M=max(M,mp[s]);
    }
    for(auto i:mp){
        if(i.second==M){cout<<i.first<<endl;}
    }
}

Measured memory_bytes: 23808
#include <iostream>
#include <algorithm>
int main(){
  int N,T,ans=1001;
  std::cin >> N >> T;
  int c[N],t[N];
  for(int i=0; i<N; i++) std::cin >> c[i] >> t[i];
  for(int i=0; i<N; i++) if(T>=t[i]) ans = std::min(ans, c[i]);
  if(ans>1000) std::cout << "TLE" << std::endl;
  else std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void sort(int a[]);
void swap(int *x, int *y);

int main(void)
{
	int a[5];
	int i;
	
	for (i = 0; i < 5; i++){
		scanf("%d", &a[i]);
	}
	
	sort(a);
	
	for (i = 0; i < 4; i++){
		printf("%d ", a[i]);
	}
	printf("%d\n", a[4]);
	
	return (0);
}
void sort(int a[])
{
	int i, j;
	
	for (i = 0; i < 5; i++){
		for (j = i + 1; j < 5; j++){
			if (a[i] < a[j]){
				swap(&a[i], &a[j]);
			}
		}
	}
}
void swap(int *x, int *y)
{
	int tmp;
	
	tmp = *x;
	*x = *y;
	*y = tmp;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll i = 1; i <= k; ++i) {
        r *= n--;
        r /= i;
    }
    return r;
}

int main()
{
    int n,a,b;
    ll ansc = 0;
    double ansn = 0;
    cin >> n >> a >> b;
    vector<ll> v(n);
    map<ll, ll> m;
    rep0(i, n){
        cin >> v[i];
        ++m[v[i]];
    }
    sort(all(v),greater<>());
    ll min = v[a - 1],cnt = 0;
    rep0(i, a){
        ansn += v[i];
    }
    ansn /= (double)a;
    
    rep0(i, n){
        if(min == v[i])break;
        ++cnt;
    }
    nfor(k, a - 1, b){
        ansc += combinations(m[min], k - cnt + 1);
        if(v[k] != min || v[0] != min)break;
    }
    printf("%.9f\n",ansn);
    pf(ansc)
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef pair < int, int> P;
/****Union-Ford-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//int a[100] = { 4,2,3,1,5 }, m[100] ={3,2,2};
//int n = 0;
//const ll mod = 1000000007;


//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

/************************************************************************************
//*無向グラフのBELL_MAN_FORD;*//*
struct edge { int from, to, cost; };
edge es[10000];
int d[10000];
void shortest_path(int s) {
	for (int i = 0; i < V; i++)d[i] = INF;
	d[s] = 0;
	while (true) {
		bool update = false;
		for (int i = 0; i < E*2; i++) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if (!update)break;
	}

}
int main() {
	cin >> V >> E;
	for (int i = 0; i < E*2; i = i+2) {
		edge e;
		cin >> e.from >> e.to >> e.cost;
		es[i] = e;
		swap(e.to, e.from);
		es[i + 1] = e;

	}
	shortest_path(0);
	cout << d[6] << endl;
}
*////////////////////////////////////////*
int gcd(int a, int b) {//最大公約数を求める
	if (b == 0) return a;
	return gcd(b, a%b);
}
/*****************************************************************************/
//int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1};
//vector<int> G[10000];


//struct edge { int to, cost; };
//vector<edge>G[100000];


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


/****
//priority_queue<int> //大きいものから順番に出てくる
//priority_queue<int,vector<int>,greater<int>>//小さいものから出てくる（順位キュー）
.top();
.pop();
.empty();
**/
//void solve();
//int V, E;
//void shortest_path(int);
typedef long double ld;
typedef unsigned long long ull;
const int MX = 3007;


int N, A[100000];
int main()
{
	cin >> N;
	ll sum = 0;
	int res = 0;
	for (int i=0; i < N; i++) cin >> A[i];
	int counter = 0;
	for (int i=0; i < N; i++) {
		if (A[i] < 0) {
			//res = max(res, A[i]);
			A[i] = abs(A[i]);
			counter++;
		}
		sum += A[i];
	}
	//cout << counter << endl;
	sort(A, A + N);
	res = A[0];
	//cout << A[0] << endl;
	if (counter % 2 == 0) {
		cout << sum << endl;
	}
	else {
		cout << sum - res*2 << endl;
	}

	
	
	
}


Measured memory_bytes: 640
N, W = map(int, input().split())
w0 = 0
Items = []
for _ in range(N):
    w, v = map(int, input().split())
    if _ == 0:
        w0 = w
        w = 0
    else:
        w -= w0
    Items.append((w, v))
# i個目までを見たときに、重さはk, j個使用
DP = [[[0] * (N * 4) for _ in range(N * 4)] for __ in range(N+1)]

for i, (w, v) in enumerate(Items, 1):
    for j in range(1, N * 4):
        if i < j:
            break
        for k in range(N * 4):
            if k < w:
                DP[i][j][k] = DP[i-1][j][k]
            else:
                DP[i][j][k] = max(DP[i-1][j][k], DP[i-1][j-1][k-w] + v)

ans = 0
for j, value in enumerate(DP[N]):
    for k, v in enumerate(value):
        if j * w0 + k <= W:
            ans = max(ans, v)
print(ans)



Measured memory_bytes: 204212
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD = 1000000000+7;
ll checkbit(ll n , ll k)
{
    return (n&(1LL<<k));
}
bool comp(string a, string b)
{
  if(a.size()>=b.size())return false;
  else return true;
}
ll BIGMOD(ll x, ll y) {
    if(y == 0)
        return 1;
    ll tmp = BIGMOD(x, y/2);
    if(y%2 == 0)
        return (tmp*tmp)%MOD;
    else
        return (((tmp*tmp)%MOD)*x)%MOD;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
      string a;
      cin>>a;
      int cnt=0,ans=0;
      for(int i=0;i<a.size();i++)
      {
          if(a[i]=='R'){cnt++;}
          else
          {ans=max(cnt,ans);cnt=0;}
          if(i==a.size()-1)ans=max(cnt,ans);

      }
      cout<<ans;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if (n%2 == 1)
    {
        cout << n/2+1 << endl;
    }
    else
    {
        cout << n/2 << endl;
    }
    return 0;
}

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

int main() {
  int n,max_2=-1,ans;
  cin>>n;
  for(int i=1; i<=n; i++){
    int j=i,now_2=0;
    while(j%2==0){
      j /= 2;
      now_2++;
    }
    if(now_2>max_2){
      max_2=now_2;
      ans=i;
    }
  }
  cout<<ans<<endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  const ll q = Q;
  const ll h = min(H, 2 * Q);
  const ll s = min(S, 2 * h);
  const ll d = min(D, 2 * s);

  ll answer = 0;
  for (; N > 0; N -= 2) {
    answer += (N >= 2) ? d : s;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}


int main() {
  int n, m;
  cin >> n >> m;
  if (n % 2 == 1 || n >= 4 * m) {
    int l = m;
    int r = m + 1;
    for (int i = 0; i < m; i++) {
      cout << l << ' ' << r<<endl;
      l--;
      r++;
    }
  }
  else {
    vector<int> sa(m);
    vector<bool> f(2 * n, 1);
    for (int i = 0; i < m; i++) {
      if (f[n - 2 * i - 1] && (2 * i + 1 != n - 2 * i - 1)) {
        sa[i] = 2 * i + 1;
        f[2 * i + 1] = 0;
      }
      else {
        sa[i] = 2 * (i + 1);
        f[2 * i + 2];
      }
    }
    int l = m;
    for (int i = 0; i < m; i++) {
      cout << l << ' ' << l + sa[i] << endl;
      l--;
    }
  }
}

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

public class Main {
	public static void main(String[] args) { new Main(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);

	int N;	
	
	Main() {
		N = in.nextInt();
		boolean ugh = true;
		for (int i = 1; i <= 9 && ugh; i++)
			if (N %i == 0 && N / i <= 9) {
				out.println("Yes");
				ugh = false;
			}
		if (ugh)
			out.println("No");
		out.close();
	}

	
	
	int abs(int x) { if (x < 0) return -x; return x; }
	long abs(long x) { if (x < 0) return -x; return x; }
	int max(int x, int y) { if (x < y) return y; return x; }
	int min(int x, int y) { if (x > y) return y; return x; }
	long max(long x, long y) { if (x < y) return y; return x; }
	long min(long x, long y) { if (x > y) return y; return x; }

	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }

		void intArr(int sz, int[] x) { for (int i = 0; i < sz; i++) x[i] = nextInt(); }
		void longArr(int sz, long[] x) { for (int i = 0; i < sz; i++) x[i] = nextLong(); }
		void doubleArr(int sz, double[] x) { for (int i = 0; i < sz; i++) x[i] = nextDouble(); }
	}
}



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

#define REP(i, n) for (int i = 0; i < n; ++i)

int field[11][5][4];

int dfs(int d) {
  static const int dy[] = {0, 1, 1, 1};
  static const int dx[] = {1, -1, 0, 1};

  if (d == 10) { return 0; }
  int ret = 20 - 2*d;
  REP(y, 5) REP(x, 4) {
    if (field[d][y][x] == -1) { break; }
    REP(k, 4) {
      int ny = y + dy[k], nx = x + dx[k];
      if (nx < 0 || nx >= 4 || ny >= 5) { continue; }
      if (field[d][y][x] == field[d][ny][nx]) {
        int yyy = 0, xxx = 0;
        REP(yy, 5) REP(xx, 4) {
          if (yy == y && xx == x) { continue; }
          if (yy == ny && xx == nx) { continue; }
          field[d+1][yyy][xxx] = field[d][yy][xx];
          ++xxx;
          if (xxx == 4) { ++yyy; xxx = 0; }
        }
        ret = min(ret, dfs(d+1));
      }
    }
  }
  return ret;
}

int main() {
  int T; scanf("%d", &T);
  while (T--) {
    memset(field, -1, sizeof(field));
    REP(y, 5) REP(x, 4) {
      scanf("%d", &field[0][y][x]);
    }
    int ans = dfs(0);
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 760
package main

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

func search(n int, as []int, q int, bs []int) {
	count := 0
	for _, b := range bs {
		l := 0
		r := n
		flag := true
		for l < r && flag {
			m := (r + l) / 2
			v := as[m]
			if v == b {
				count++
				flag = false
			} else if v > b {
				r = m
			} else {
				l = m + 1
			}
		}
	}
	fmt.Println(count)
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	var as []int
	for i := 0; i < n; i++ {
		as = append(as, nextInt(sc))
	}
	q := nextInt(sc)
	var bs []int
	for i := 0; i < q; i++ {
		bs = append(bs, nextInt(sc))
	}
	search(n, as, q, bs)
}



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

#define ll long long

int n;
string s;

void solve(){
    int cnt=0;
    bool used[1000]; memset(used, 0, sizeof used);
    cin>>n;
    cin>>s;
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            for(int k=0; k<10; k++){
                char a='0'+i;
                char b='0'+j;
                char c='0'+k;
                bool f1=false, f2=false;
                for(int ii=0; ii<s.size(); ii++){
                    if(!f1 && s[ii]==a){
                        f1=true;
                    }
                    else if(f1 && !f2 && s[ii]==b){
                        f2=true;
                    }
                    else if(f2 && s[ii]==c){
                        //cout<<a<<b<<c<<endl;
                        cnt++;
                        break;
                    }
                }
            }
        }
    }
    cout<<cnt<<endl;
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
S = input()

kaibun = True
for i in range(len(S)//2):
  if S[i] != S[-1-i]:
    kaibun = False
N = (len(S)-1)//2
for i in range(N):
  if S[i] != S[N-1-i]:
    kaibun = False
N = (len(S)+3)//2
for i in range(N):
  if S[i] != S[-1-i]:
    kaibun = False

if kaibun == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int N, M; cin >> N >> M;
  map<int, vector<int>> mp;
  for (int i = 0; i < M; ++i) {
    int a, b; cin >> a >> b;
    mp[a].push_back(b);
  }

  string ans = "IMPOSSIBLE";
  for (auto v : mp[1]) {
    if (find(ALL(mp[v]), N) != mp[v].end()) {
      ans = "POSSIBLE";
      break;
    }
  }

  cout << ans << endl;
}

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

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

    int n, r;
    cin >> n >> r;

    cout << r + 100 * max(0, 10 - n) << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define H 10000
#define NIL -1

typedef struct{
  int k;
  int pk;
  int lk;
  int rk;
}id;

int main()
{
  int n,i;
  id A[H];

  scanf("%d",&n);

  for(i = 1;i <= n;i++)
    {
      A[i].k = NIL;
      A[i].pk = NIL;
      A[i].lk = NIL;
      A[i].rk = NIL;
    }

  for(i = 1;i <= n;i++)
    {
      scanf("%d",&A[i].k);
    }

  for(i = 1;i <= n;i++)
    {
      A[i].pk = A[i/2].k;
      A[i].lk = A[2*i].k;
      A[i].rk = A[2*i +1].k;
    }

 
  for(i = 1;i <= n;i++)
    {
      if(i == 1)
	{
	  printf("node %d: key = %d, left key = %d, right key = %d, \n",i,A[i].k,A[i].lk,A[i].rk);
	}
      else if(A[i].lk == 0)
	{
	  printf("node %d: key = %d, parent key = %d, \n",i,A[i].k,A[i].pk);
	}
      else if(A[i].rk == 0)
	{
	  printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,A[i].k,A[i].pk,A[i].lk);
	}
      else
	{
	  printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,A[i].k,A[i].pk,A[i].lk,A[i].rk);
	}
    }
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t a, b;
    cin >> a >> b;

    for (auto i : {1, 2, 3}) {
        if (i != a && i != b) {
            cout << i << endl;
            return 0;
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    int num[n];
    for(int i=0; i<n; i++){
        cin >> num[i];
    }

    int min,max;
    long sum;
    for(int i=0; i<n; i++){
        if(i==0){
            sum=num[i];
            min=num[i];
            max=num[i];
        }
        else{
            if(num[i]<min){
                min=num[i];
            }
            if(num[i]>max){
                max=num[i];
            }
            sum+=num[i];
        }
    }
    cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3120
import sys
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
nsum=0
for i in range(1,N+1):
    if((i%3)!=0 and (i%5)!=0):
        nsum+=i

print(nsum)

Measured memory_bytes: 9196
s=[]
while True:
    l=list(map(int,input().split()))
    if l==[0,0]:
        break
    s.append(l)
#print(s)
for i in range(len(s)):
    cnt=0
    for j in range(1,s[i][0]+1):
        #l_2=list(range(1,s[i][0]+1))
        #print(l_2)
        for k in range(1,s[i][0]+1):
            for m in range(1,s[i][0]+1):
                if j<k and k<m:
                    if k+m+j==s[i][1]:
                        cnt+=1
    print(cnt)
            
            


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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> v(n);
	for (auto &i : v) cin >> i.first >> i.second;
	for (int i = 0; i < n; i++) {
		if (i < n && i + 1 < n && i + 2 < n) {
			if (v[i].first == v[i].second && v[i + 1].first == v[i + 1].second && v[i + 2].first == v[i + 2].second) {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n; cin >> n;
    ll ans = 0;
    for (int i=1; i<=n; ++i) {
        for (int j=i; j<=n; j+=i) {
            ans += j;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3556
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	vector<int>a(3), b(3), c(3);
	bool ans = false;
	rep(i, 3)cin >> a[i];
	rep(i, 3)cin >> b[i];
	rep(i, 3)cin >> c[i];
	int sum = accumulate(all(a), 0) + accumulate(all(b), 0) + accumulate(all(c), 0);
	if (sum == (a[0] + b[1] + c[2]) * 3)ans = true;
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3564
rule = {"A" => ["B", "D"], "B" => ["A", "C", "E"], "C" => ["B", "F"], "D" => ["A", "E", "G"], "E" => ["B", "D", "F", "H"], "F" => ["C", "E", "I"], "G" => ["D", "H"], "H" => ["E", "G", "I"], "I" => ["F", "H"]}
1000.times{
    line = gets.chomp
    candidate = true
    c = line[0]
    1.upto(line.length - 1){|i|
        unless rule[c].include?(line[i])
            candidate = false
            break
        end
        c = line[i]
    }
    puts line if candidate
}


Measured memory_bytes: 6876
import sys
import math

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    in_tax = int(inputs[0])
    not_tax = in_tax / 1.08
    kirisute = math.floor(not_tax)

    ks = [kirisute - 2, kirisute - 1, kirisute, kirisute + 1, kirisute + 2]
    for k in ks:
        c = math.floor(k * 1.08)
        if c == in_tax:
            return k
    return ':('


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 38448
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

//つねに10億7などの剰余をとる構造体
//参考: https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//参考: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod  = MODA;
struct modint {
	ll x;
	modint (ll x):x(x%mod){}
	modint& operator+=(const modint a){
		(x += a.x ) %= mod;
		return *this;
	}
	modint& operator-=(const modint a){
		(x -= a.x ) %= mod;
		if (x < 0) x += mod;
		return *this;
	}
	modint& operator*=(const modint a){
		(x *= a.x ) %= mod;
		return *this;
	}
	modint& operator/=(modint a){
		ll exp = mod - 2;
		while(exp > 0){
			if(exp & 1) *this *= a.x;
			a *= a.x;
			exp >>= 1;
		}
		return *this;
	}
	modint operator+(const modint a) const{
		modint res(*this);
		return res+=a;
	}
	modint operator-(const modint a) const{
		modint res(*this);
		return res-=a;
	}
	modint operator*(const modint a) const{
		modint res(*this);
		return res*=a;
	}
	modint operator/(const modint a) const{
		modint res(*this);
		return res/=a;
	}
};
modint modpow(modint x, ll n){
	modint res=1;
	while(n > 0){
		if(n & 1) res = res * x.x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

int main() {
	modint ans = 0;
	int tmp;
	int n, k;
	cin >> n >> k;
	
	vector<modint> now, wri, nk1, k1;
	REP(i, 2002){now.push_back(0); wri.push_back(0); nk1.push_back(0); k1.push_back(0);}
	now[0] = (ll)1;
	REP(i, 2001){
		if(i == n - k + 1) REP(j, i+1) nk1[j] = now[j];
		if(i == k - 1) REP(j, i+1) k1[j] = now[j];
		REP(j, 2001) wri[j] = 0; 
		REP(j, i+1){
			//cout << i << "C" << j << " = " << now[j].x << endl;
			wri[j] += now[j];
			wri[j+1] += now[j];
		}
		REP(j, 2001) now[j] = wri[j]; 
	}
	//cout << "ok" << endl;
	REP1(i, k){
		ans = 1;
		ans *= nk1[i];
		ans *= k1[k-i];
		cout << ans.x << endl;
	}
}

Measured memory_bytes: 384
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll A,B;
	cin >>A>>B;
	
	// 解法
	if (A>=13) cout<<B<<endl;
	else if (A>=6) cout<<B/2<<endl;
	else cout<<0<<endl;}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(void){
	int R[MAX],n;
	
	cin >> n;
	for(int i=0;i<n;i++) cin >> R[i];
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for(int i=1;i<n;i++){
		maxv = max(maxv,R[i]-minv);
		minv = min(minv,R[i]);
	}
	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 3860
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC124B
{
    class MainClass
    {

        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            n = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);

            int maxh = n[0];
            int ans = 1;
            for(int i = 1; i < s[0]; i++)
            {
                if (n[i] >= maxh)
                {
                    maxh = n[i];
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>

int main(void){
	int n;
	std::cin >> n;
	
	int seq[n];
	
	for (int i =0; i <n; i++){
		std::cin >> seq[i];
	}
	
	for (int i = 0; i < n; i ++){
		if (i < n-1) std::cout << seq[(n-1) - i] << " ";
	  else std::cout << seq[ (n-1)-i] << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main() {
  int n;
  cin >> n;
  int a, b;
  int counter = 0;
  bool flag = false;
  REP(i, n) {
    cin >> a >> b;
    if (a == b) {
      counter++;
    } else {
      counter = 0;
    }
    if (counter > 2) {
      flag = true;
    }
  }
  if (flag == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 510200;

int n;
string s;
vector<int> v;
int cnt = 0;

void run()
{
    vector<int> r;
    cnt++;
    for (int i = 0; i + 1 < v.size(); i++)
    {
        r.push_back(abs(v[i] - v[i + 1]));
    }
    v = r;
    if (v.size() == 1)
    {
        cout << v[0];
    }
}

signed main()
{
    srand(time(NULL));
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    cin >> n;
    cin >> s;
    n = s.size();
    int multiply = 2;
    for (int i = 0; i + 1 < n; i++)
    {
        v.push_back(abs(s[i] - s[i + 1]));
    }

    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] == 1) multiply = 1;
    }
    if (multiply == 2)
    {
        for (int i = 0; i < v.size(); i++)
        {
            v[i] /= 2;
        }
    }

    int res = 0;
    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] == 1)
        {
            int t = (i & (v.size() - i - 1));
            if (t == 0) res ^= 1;
        }
    }
    cout << res * multiply << "\n";
    //cout << "Show : ";
    //for (int i = 0; i < n - 2; i++) run();
}


Measured memory_bytes: 11512
import sys
r,g,b=map(int,input().split())
k=int(input())

for i in range(k+1):
    if r<g<b:
        print("Yes")
        sys.exit()
    else:
        if r<=b<=g:
            b*=2
        elif b<=r<=g:
            b*=2
        elif b<=g<=r:
            b*=2
        elif g<=r<=b:
            g*=2
        elif g<=b<=r:
            b*=2
print("No")



Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    string s;
    cin >> s;

    int n = s.size();
    int ans = 0;

    stack<char> st;
    rep (i, n) {
        if (st.size() && st.top() != s[i]) {
            st.pop();
        }
        else st.push(s[i]);
    }

    cout << n - st.size() << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <climits>
#include <sstream>
#include <bitset>
using namespace std;
 
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair
 
static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;
 
template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
    v.assign(a,vector<T>(b,t));
}
 
//v.erase(unique(v.begin(),v.end()),v.end());
vint v(10,0);
ll dp[10+5][331+10][(1<<10)+10]={0};
ll foo(int n,int s,int a){
	// cout<<n<<" "<<s<<" "<< static_cast<std::bitset<10> >(a)<<endl;
	if(s>330) return 0;
	if(s<0) return 0;
	if(dp[n][s][a]) return dp[n][s][a];
	if(n==1){
		if(s<10&&a>>s&1){
			return dp[n][s][a]=1;
		}
		else{
			return dp[n][s][a]=0;
		}
	}
	if(n<=0) return dp[n][s][a]=0;
	ll ret=0;
	rep(i,10){
		// cout<<(a>>i)<<endl;
		if(a>>i&1){
			ret+=foo(n-1,s-n*i,a-(1<<i));
		}
	}
	return dp[n][s][a]=ret;
}


int main(){
	int n,s;
	while(cin>>n){
		cin>>s;
		ll ans=foo(n,s,(1<<10)-1);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 29864
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

struct info {
  int w, s, v;
  bool operator<(const info X) const  {return w+s < X.w+X.s;}
};

const int N = 1010;
const int X = 2e4+10;

//head

int n;
info iin[N];
ll dp[X];
ll ans;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, n) {
    int w, s, v;
    cin >> w >> s >> v;
    iin[i] = (info){w, s, v};
  }
  sort(iin, iin+n);
  rep(i, n) {
    int w = iin[i].w;
    int s = iin[i].s;
    int v = iin[i].v;
    for(int j = s; j >= 0; j--) {
      chmax(dp[j+w], dp[j]+v);
      chmax(ans, dp[j+w]);
    }
    //cout << w << ' ' << s << ' ' << v << endl;
  }

  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

ll n,arr[100005][5],mem[100005][5];

ll dp(int pos, int last){
    if(pos==n)return 0;
    if(mem[pos][last]!=-1)return mem[pos][last];
    ll res=0;
    for(int i=0;i<3;i++){
        if(i!=last)res=max(res,dp(pos+1,i)+arr[pos][i]);
    }
    return mem[pos][last]=res;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=0;i<(int)n;i++){
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    memset(mem,-1, sizeof(mem));
    cout<<dp(0,3);
}

Measured memory_bytes: 14336
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	ll a,b;
	cin>>a>>b;
	ll out=(a*2<b?a:b/2);
	a-=out;b-=out*2;
	cout<<out+b/4<<endl;
}











Measured memory_bytes: 256
/*created by tanishk gupta*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef vector<int> VI;
typedef long long int ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll MOD=1e9+7;
const ll mod=1e9+7;
//const llint MOD;
const int N=(int)(2*1e5+10);
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll add(ll a,ll b){return ((a%MOD)+(b%MOD))%MOD;}
ll mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
ll sub(ll a,ll b){return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll binpow(ll x, ll y){ll z = 1;while(y){if(y & 1) z = mul(z, x);x = mul(x, x);y >>= 1;}return z;}
int inv(int x){return binpow(x, MOD - 2);}
int divide(int x, int y){return mul(x, inv(y));}
//int fact[N];
//void precalc(){fact[0] = 1;for(int i = 1; i < N; i++)fact[i] = mul(fact[i - 1], i);}
//int C(int n, int k){return divide(fact[n], mul(fact[k], fact[n - k]));}
//bool prime[N];
//void sieve() {for(int i=2;i<N;i++) {prime[i]=true;}for (int p=2; p*p<=N; p++){if (prime[p] == true){for (int i=p*p; i<=N; i += p)prime[i] = false;}}}
ll legendpow(ll n, ll p){ll total = 0;while (n){n /= p;total += n;}return total;}

//head==================================================================================

int main()
{ IOS;
int n;
cin>>n;
ll a[n];
ll ans=0;
rep(i,0,n){
    cin>>a[i];
 //   if (i)  {ans+=t;}
}
sort(a,a+n);
int curr=n-2;
ans+=a[n-1];
for (int i=n-2;i>=0;i--)
{
    if (curr>1)
    {
        ans+=(2*a[i]);
        curr=curr-2;
    }
    else if (curr==1)
    {
        ans+=a[i];
        curr--;
    }
    else
    {
        break;
    }
}
cout<<ans<<endl;
}


Measured memory_bytes: 5204
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
while(a!=0 and b!=0){
for(int c=0;c<a;c++){
for(int d=0;d<b;d++){
cout<<'#';
}
cout<<endl;
}
cout<<endl;
cin>>a>>b;
}
return 0;
}


Measured memory_bytes: 3084
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;


const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}




int main() {

  ll m, n, a;

  cin >> n >> a;


  vector<ll> x(n);
  cin >> x;

  vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(n + 1, vector<ll>(2601, 0)));



  for (int j = 0; j <= n; j++) {
    for (int k = 0; k <= n; ++k) {
      for (int s = 0; s <= 2500; s++) {
        if (j == 0 && k == 0 && s == 0) {
          dp[j][k][s] = 1;
          continue;
        }
        if (j > 0) {
          if (s < x[j - 1] && j > 0) {
            dp[j][k][s] = dp[j - 1][k][s];
          }
          if (s >= x[j - 1] && k > 0 && s > 0) { //前のそのまんま  //1文字少なく選んで、和が少ないとき
            dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]];
          }
        }


      }
    }
  }

  ll ans = 0;
  // for (int i = 1; i <= n; ++i) {
  for (int k = 1; k <= n; k++) {
    ans += dp[n][k][k * a];
  }
  // }


  // for(int i=1;i<=n;i++){
  //   cerr << dp[n][i][]
  // }


  cout << ans << endl;



}




















Measured memory_bytes: 54272
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define GODSPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;
inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){return (a%mod * b%mod)%mod;}
inline int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
signed main()
{
     GODSPEED;
     string s;
     cin>>s;
     vi frequency(26,0);
     for(auto x:s)
      frequency[x-'a']++;
     for(auto x:frequency)
     {
           if(x&1)
           {
                puts("No");
                return 0;
           }
     }
     puts("Yes");
     return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll a, b;
    cin >> a >> b;
    if (a+b == 15) cout << "+\n";
    else if (a*b == 15) cout << "*\n";
    else cout << "x\n";
}

Measured memory_bytes: 256