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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

namespace detail {
template <typename Tp, size_t N>
std::vector<Tp> make_vector(
    std::vector<size_t> &sizes,
    typename std::enable_if<(N == 1), Tp const &>::type x) {
    return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector(
    std::vector<size_t> &sizes,
    typename std::enable_if<(N > 1), Tp const &>::type x) {
    size_t size = sizes[N - 1];
    sizes.pop_back();
    return std::vector<decltype(make_vector<Tp, N - 1>(sizes, x))>(
        size, make_vector<Tp, N - 1>(sizes, x));
}
} // namespace detail

template <typename Tp, size_t N>
auto make_vector(size_t const (&sizes)[N], Tp const &x = Tp()) {
    std::vector<size_t> s(N);
    for (size_t i = 0; i < N; ++i)
        s[i] = sizes[N - i - 1];
    return detail::make_vector<Tp, N>(s, x);
}

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

    int n, m, c;
    cin >> n >> m >> c;
    vi b(m);
    rep(i, m) cin >> b[i];
    auto a = make_vector<int, 2>({n, m}, 0);
    rep(i, n) rep(j, m) cin >> a[i][j];

    int ans = 0;
    rep(i, n) {
        int theta = c;
        rep(j, m) theta += a[i][j] * b[j];
        if (theta > 0) ans++;
    }

    out(ans);
}


Measured memory_bytes: 256
/* 

 */
/* ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;

// defines
#define int long long
typedef long long ll;
#define double long double
#define vec vector
#define vi vector<int>
#define vvi vector<vector<int>>
#define FZ(n) memset((n),0,sizeof())
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define mp make_pair
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define debug(x) cout << #x << " = " << (x) << endl
#define debug2(x, y) cout<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<< endl
#define debug3(x, y, z) cout<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<", "<<#z<<" = "<<(z)<<endl
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
#define max3(a, b, c) max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c) min(a, b) < min(b, c) ? min(a, b) : min(b, c)

//permanent constants
const long long INF64 = 1e18; const int INF32 = 1e9; const int BIG = (int)(1e9 + 239);
const int MOD = 998244353; //1e9 + 7;  const ll MOD2 = (ll)MOD * (ll)MOD;
const double PI = 2.0*acos(0.0); //acos(-1.0L);
const double EPS = static_cast<double>(1e-10);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0};
//const ll INF = (ll)(1e18 + 239);

//random
mt19937 rnd(239); //(chrono::high_resolution_clock::now().time_since_epoch().count());

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO()   {freopen("in.txt", "w", stdout);}
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }
void input() {   }

int cost[10][10][10][10]; // cost[s][k][x][y] = min cost to get k from s, with counter x - y 


void solve() {
	int n; cin >> n;
	vector<string> s(n); FOR(i, 0, n) {cin >> s[i]; sort(ALL(s[i]));}
	sort(ALL(s));
	int st=0L, ed=0L, ans = 0L;
	while(st<n and ed<n) {
		string s0 = s[st];
		int k = 0L;
		while(ed<n and s[ed]==s0) { k++; ed++; }
		st=ed;
		ans += k*(k-1)/2;
	}
	cout << ans << endl;
}

signed main() {
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

//	int const T=10, N = 100000;
//	cout << T << endl;
//	FOR(i, 0, T) {
//		cout << N << endl;
//		FOR(i, 0, N) cout << "0 " ;
//		cout << endl;
//	}

//  int test = 0;
//  int t; cin >> t;
//  while(t--)
  {
//	  cout << "Case " << ++test << ": ";
	  solve();
  }

//  auto endProgram = chrono::steady_clock::now();
//  cout << chrono::duration_cast<chrono::milliseconds>(endProgram - beginProgram).count() << " ms" << endl;

  return 0;
}



Measured memory_bytes: 5760
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

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

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N, K; cin >> N >> K;
    VI L(N);
    REP(i, N) cin >> L.at(i);
    RSORT(L);
    int r=0;
    FOR(i, 0, K)
    {
        r += L.at(i);
    }
    cout << r << endl;
    return 0;
}



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

int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {

    int n;
    cin >> n;

    cout << arr[n - 1] << endl;

    return 0;
}


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


ll ll_pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % 2019;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % 2019;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main() {
  string S;
  cin>>S;
  ll N=S.size();
  vector<ll> amari(N);
  reverse(S.begin(),S.end());
  rep(i,N)
  {
    ll a=S.at(i)-'0';
    /*rep(j,i)
    {
      a*=10;
      a%=2019;
    }*/
    
    a=a*ll_pow(10,i)%2019;
    amari.at(i)=a;
  }
  vector<ll> sum(N);
  rep(i,N)
  {
    if(i==0)
    {
      sum.at(0)=amari.at(0);
    }
    else
    {
      ll a=sum.at(i-1)+amari.at(i);
      sum.at(i)=a%2019;
    }
  }
  ll ans=0;
  vector<ll> num(2019);
  rep(i,N)
  {
    ll a=sum.at(i);
    num.at(a)++;
  }  
  rep(i,2019)
  {
    ll a=0;
    if(i==0)
    {
      ll b=num.at(0);
      if(b==0)
      {
        a=0;
      }
      else
      {
        a=b+b*(b-1)/2;
      }
    }
    else
    {
      ll b=num.at(i);
      if(b<=1)
      {
        a=0;
      }
      else
      {
        a=b*(b-1)/2;
      }
    }
    ans+=a;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6764
#include <stdio.h>

int i, j, c;
int number[3];

int main(){

scanf("%d %d %d", &number[0], &number[1], &number[2]);





for (i = 0; i < 3; ++i){
   for (j = i + 1; j < 3; ++j){
     if(number[i] > number[j]){
     c = number[i];
     number[i] = number[j];
     number[j] = c;


     }

   }


}


    printf("%d %d %d\n", number[0], number[1], number[2]);



return 0;

}

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

int f(int x)
{
	if(x<3)
		return 1;
		
	return(f(x-1)+f(x-2));
	
} 
int main()
{
	int x;
	std::cin>>x;
	if(x%1000==0){
		cout<<0;
	}
	else{
		double t=x/1000.0;
		int n=ceil(t);
		cout<<(n-x/1000.0)*1000;
	}

}















Measured memory_bytes: 3316
from numpy import*
n,m=map(int,input().split())
l=[]
for i in range(m):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())

ans=0
for t in range(2**n):
    tmp=array([t>>s&1 for s in range(n)])
    if p==[sum(tmp[array(i)-1])%2for i in l]:
        ans+=1
print(ans)


Measured memory_bytes: 12576
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

int n, m, ans, a[MAXN];
vector <int> adj[MAXN];

inline int Dfs(int x)
{
	int mx = 0;
	for (auto y : adj[x])
	{
		int t = Dfs(y) + 1;
		if (t == m)
			ans ++;
		else
			mx = max(mx, t);
	}
	return mx;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read();
	for (int i = 1; i <= n; i ++)
		a[i] = Read();
	if (a[1] ^ 1)
		ans ++;
	for (int i = 2; i <= n; i ++)
		adj[a[i]].pb(i);
	for (auto x : adj[1])
		Dfs(x);
	return printf("%d\n", ans), 0;
}


Measured memory_bytes: 8448
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

int main()
{
    int a[5][5]={0},i,j,n,b[105]={0},k,l=0;
    for(i=0;i<3;i++){
    	for(j=0;j<3;j++){
    		cin>>a[i][j];
		}	
	}
	cin>>n;
	for(i=0;i<n;i++){
		cin>>k;
		b[k]++;
	}
	for(i=0;i<3;i++){
		if(b[a[i][0]]&&b[a[i][1]]&&b[a[i][2]]){
			cout<<"Yes";
			return 0;
		}
		if(b[a[0][i]]&&b[a[1][i]]&&b[a[2][i]]){
			cout<<"Yes";
			return 0;
		}
	}
	if(b[a[0][0]]&&b[a[1][1]]&&b[a[2][2]]){
			cout<<"Yes";
			return 0;
	}
	if(b[a[0][2]]&&b[a[1][1]]&&b[a[2][0]]){
			cout<<"Yes";
			return 0;
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch FoodsLovedByEveryone | diff FoodsLovedByEveryone.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address FoodsLovedByEveryone.cpp && ./a.out

/*
 
 2/28/2019
 
 15:33-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N,M;

void solve() {
  int res=0;
  REP(i,M) res+=(A[i]==N);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,N) {
    int K; cin>>K;
    REP(i,K) {
      int a; cin>>a;
      A[--a]++;
    }
  }
  solve();
  
  return 0;
}


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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  unsigned int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  ll oddsum = 0;
  ll evensum = 0;
  vector<int> odd, even;
  rep(i, n) {
    if (a[i]>=0) {
      if (i%2==0) {
        even.push_back(i);
        evensum += a[i];
      } else {
        odd.push_back(i);
        oddsum += a[i];
      }
    }
  }

  vector<int> pos;
  ll ret = max(evensum, oddsum);
  if (evensum > oddsum) {
    swap(pos, even);
  } else {
    swap(pos, odd);
  }

  if (pos.empty()) {
    ll ma = INT_MIN;
    int pos = -1;
    rep(i, n) {
      if (a[i] > ma) {
        ma = a[i];
        pos = i;
      }
    }
    cout << ma << endl;
    cout << n-1 << endl;
    int len = n;
    rep(i, pos) {
      cout << 1 << '\n';
      len--;
    }
    while(len > 1) {
      cout << len << '\n';
      len--;
    }
    return 0;
  }

  cout << ret << endl;
  int len = n;
  vector<int> ans;
  rep(i, pos[0]) {
    ans.push_back(1);
    len--;
  }
  for(int i=0; i<pos.size()-1; i++) {
    int b = pos[i+1] - pos[i];
    while(b>2) {
      ans.push_back(3);
      b-=2;
      len-=2;
    }
    ans.push_back(2);
    len-=2;
  }
  while(len>1) {
    ans.push_back(len);
    len--;
  }

  cout << ans.size() << endl;
  for(auto e: ans) {
    cout << e << '\n';
  }
}

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

int main() {
  long long int N;
  cin >> N;
  long long int y=N-1;

  for (long long int i=1; i*i<=N; i++) {
    if (N%i ==0) {
      y = min(y,(N/i)+i-2);
    }
  }
  cout << y << endl;
  return 0;    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,k,a[105],g[100005];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=k;i++){
		for(int j=1;j<=n;j++){
			if(i >= a[j] && g[i-a[j]] == 0){
				g[i] = 1; break;
			}
		}
	}
	puts(g[k]?"First":"Second");
}

Measured memory_bytes: 640
/*
 * Card Game.c
 *
 *  Created on: 2015/02/13
 */

#include <stdio.h>
#include <string.h>

int main(void){
	char taro[100],hanako[100];
	int n,r,p_taro=0,p_hanako=0;

	scanf("%d",&n);

	for(;n;n--){
		scanf("%s %s",taro,hanako);

		r = strcmp(taro,hanako);

		if(!r){
			p_taro++;
			p_hanako++;
		}
		else if(r > 0){
			p_taro += 3;
		}
		else{
			p_hanako += 3;
		}

	}
	printf("%d %d\n",p_taro,p_hanako);
return 0;
}

Measured memory_bytes: 604
n = gets.to_i
a = gets.split.map(&:to_i)
sum = x = 0
a << 0

a.each do |e|
  sum += (x - e).abs
  x = e
end

def d(x, y)
  (x - y).abs
end

n.times do |i|
  puts sum - d(a[i], a[i - 1]) - d(a[i + 1], a[i]) + d(a[i - 1], a[i + 1])
end

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

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

ll s[401];
ll memo[401][401];

ll get(int l, int r)
{
  ll res = s[r];
  res -= s[l-1];
  return res;
}

ll dfs(int l, int r)
{
  if(l == r) return 0;
  if(memo[l][r] != linf) return memo[l][r];

//  cout << l << " , " << r << endl;

  ll res = linf;
  repi(i, l, r) res = min(res, dfs(l, i)+dfs(i+1, r)+get(l,r));
  return memo[l][r] = res;
}

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

  vi a(n);
  rep(i, n) cin >> a[i];

  rep(i, n+1) rep(j, n+1) memo[i][j] = linf;

  rep(i, n){
    s[i+1] = s[i] + a[i];
  }

  cout << dfs(1, n) << endl;

  return 0;
}


Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#define EPS 1e-10
using namespace std;
typedef long long llong;
bool isrectangle(int a, int b, int c) {
	if (a != b&&a*a + b*b == c*c)return true;
	else return false;
}
bool islozenge(int a, int b, int c) {
	if (a == b)return true;
	else return false;
}
int main() {
	int a, b, c;
	char x;
	int r = 0, l = 0;
	while (cin >> a >> x >> b >> x >> c) {
		if (isrectangle(a, b, c))r++;
		if (islozenge(a, b, c))l++;
	}
	cout << r << endl << l << endl;
	return 0;
}

Measured memory_bytes: 3068
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

bool acgt(char c) {
    return c == 'A' || c == 'C' || c == 'G' || c == 'T';
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string s; cin >> s;

    long long n = s.size(), ans = 0;
    vector<long long> cnt(n);

    cnt[0] = acgt(s[0]) ? 1 : 0;
    ans = cnt[0];

    for(long long i = 1; i < n; i++){
        cnt[i] = acgt(s[i]) ? cnt[i - 1] + 1 : 0;
        ans = max(ans, cnt[i]);
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int a,b;
    
    cin >> a >> b;
    
    
    if (b%a == 0){
    
    cout << a + b << endl;
    
    }else{
    
    cout << b-a << endl;
    
    }
    
    
    
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

cnt = 1
inc = False
dec = False
p = A.pop(0)

for Ai in A:
    if (not inc) and (not dec):
        if Ai < p:
            dec = True
        elif Ai > p:
            inc = True
    elif inc:
        if Ai < p:
            cnt += 1
            inc = False
    elif dec:
        if Ai > p:
            cnt += 1
            dec = False
    p = Ai
    
print(cnt)

Measured memory_bytes: 14252
n = int(input())
ans = ""
i = 0
while n!=0:
    #print("{0}%{1} = {2}あまり{3}".format(n,-2,n//-2,n%-2))
    if n%2==0:
        ans = "0" + ans
    else:
        ans = "1" + ans
        n -= 1
    #print("n={0}".format(n))
    n=n//(-2)
    #print("n={0}".format(n))
if ans == "":
    print("0")
else:
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    ll gcd_num = 0;
    rep(i, n) cin >> a[i];
    rep(i, n-1) {
        if (i == 0) {
            gcd_num = gcd(a[i], a[i+1]);
        }
        else {
            gcd_num = gcd(gcd_num, a[i+1]);
        }
    }
    cout << gcd_num << endl;
    return 0;
}

Measured memory_bytes: 4060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
signed main(){
    int a,p;cin>>a>>p;
    cout<<(a*3+p)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)
const int MOD = 998244353;

template<typename T>
struct Fenwick {
    std::vector<T> data;
    Fenwick(int sz=1e5): data(sz+1, 0) {}

    void add(int idx, T x){
        idx++;
        while(idx<data.size()){
            data[idx] += x;
			data[idx] %= MOD;
            idx += idx & -idx;
        }
    }

    T __sum(int r){
        T ret = 0;
        while(r>0){
            ret += data[r];
			ret %= MOD;
            r -= r & -r;
        }
        return ret;
    }

    T sum(int l, int r){
		if(l>r) return 0;
        return (__sum(r+1) - __sum(l) + MOD) % MOD;
    }

};

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	int l[k], r[k];
	REP(i, 0, k) scanf("%d %d", &l[i], &r[i]);

	Fenwick<ll> dp(n+1);
	dp.add(1, 1);
	REP(i, 2, n+1){
		ll a = 0;
		REP(j, 0, k){
			int L = l[j], R = r[j];
			if(i<=l[j]) L = i;
			if(i<=r[j]) R = i;
			a += dp.sum(i-R, i-L);
		}
		dp.add(i, a);
	}
	printf("%ld\n", dp.sum(n, n));
}



Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define MAXC 100000
int dp[100005],a[100005],n,k=2;
int max(int a, int b, int c){
	return (max(a, max(b,c)));
}
int main()
{
	int n;cin>>n;
	int a[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++)
		cin>>a[i][j];
	}
	int dp[n][3];
	for(int i=0;i<n;i++){
	    dp[i][0] = dp[i][1] = dp[i][2] = 0;
	}
	for(int i=0;i<3;i++) dp[0][i] = a[0][i];
	for(int i=1;i<n;i++){
		dp[i][0] = max(dp[i-1][0], dp[i-1][1]+a[i][0], dp[i-1][2]+a[i][0]);
		dp[i][1] = max(dp[i-1][1], dp[i-1][2]+a[i][1], dp[i-1][0]+a[i][1]);
		dp[i][2] = max(dp[i-1][2], dp[i-1][0]+a[i][2], dp[i-1][1]+a[i][2]);
	}
// 	for(int i=0;i<n;i++){
// 	    cout<<endl;
// 	    for(int j=0;j<3;j++) cout<<dp[i][j]<<" ";
// 	}
	cout<<max(dp[n-1][0], dp[n-1][1], dp[n-1][2]);
}

Measured memory_bytes: 2560
#include <iostream>
#include <set>
#include <string>

int main() {
  const uint32_t p10k = 10000, p5k = 5000, p1k = 1000;
  uint32_t N = 0, Y = 0;
  std::cin >> N >> Y;

  if (Y > N * p10k || Y < N * p1k) {
    std::cout << "-1 -1 -1" << std::endl;
    return 0;
  }

  uint32_t minus_1kto10k = p10k / p1k - 1;
  uint32_t minus_1kto5k = p5k / p1k - 1;
  uint32_t todecrese = Y / p1k - N;
  std::set<uint32_t> s = {1, 2, 3, 5, 6, 7, 10, 11, 14, 15, 19, 23};
  bool flag = (s.find(todecrese) != s.end());

  if (flag) {
    std::cout << "-1 -1 -1" << std::endl;
  } else {
    uint32_t num10k = 0, num5k = 0;
    for (size_t i = 0; i < minus_1kto10k; i++) {
      if ((todecrese - i * minus_1kto5k) % minus_1kto10k == 0) {
        num10k = (todecrese - i * minus_1kto5k) / minus_1kto10k;
        num5k = i;
        break;
      }
    }

    if (N < num10k + num5k) {
      std::cout << "-1 -1 -1" << std::endl;
    } else {
      std::cout << num10k << " " << num5k << " " << N - num10k - num5k
                << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */



  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9;


  int main()
  {
    fast_cin();
    int N;
    cin>>N;
    cout<<setprecision(8);
    cout<<fixed;
    float total=0;
    float num;
    string curr;
    for(int i=0;i<N;i++){
      cin>>num>>curr;
      if(curr[0]=='J')
        total+=num;
      else
        total+=(num*380000.0);
    }
    cout<<total;
    return 0;
  }


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

using namespace std;

class Dijkstra {
  using QItem = pair<int, int>;

 public:
  vector<int> minDistance(vector<array<int, 3>> &edges, int n, int src) {
    vector<int> costs(n, -1);
    costs[src] = 0;

    // 各ノードの隣接ノードとその距離を初期化
    vector<vector<pair<int, int>>> distances(n);
    for (auto &edge : edges) {
      int n1 = edge[0], n2 = edge[1], d = edge[2];
      distances[n1].push_back({n2, d});
    }

    vector<bool> used(n, false);
    priority_queue<QItem, vector<QItem>, greater<QItem>> q;
    q.push({0, src});

    while (!q.empty()) {
      // 未確定で，コストの一番低いノードを選択する
      auto [min_cost, min_idx] = q.top();
      q.pop();

      // 選択したノードは確定とする
      used[min_idx] = true;

      // 選択したノードの隣接ノードについて，そのコストを再計算する
      for (auto &p : distances[min_idx]) {
        int new_cost = min_cost + p.second;
        if (costs[p.first] < 0 || costs[p.first] > new_cost) {
          costs[p.first] = new_cost;
          q.push({new_cost, p.first});
        }
      }
    }

    return costs;
  }
};

int main(int argc, const char *argv[]) {
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--, cw--, dh--, dw--;
  vector<string> maze(h);
  for (int i = 0; i < h; ++i) {
    cin >> maze[i];
  }

  vector<array<int, 3>> edges;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (maze[i][j] == '#') {
        continue;
      }

      int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
      int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
      for (int i2 = min_y; i2 <= max_y; ++i2) {
        for (int j2 = min_x; j2 <= max_x; ++j2) {
          if (i2 == i && j2 == j) {
            continue;
          }

          if (maze[i2][j2] == '#') {
            continue;
          }

          int dist = abs(i2 - i) + abs(j2 - j);
          int cost = dist <= 1 ? 0 : 1;
          // cout << i << ' ' << j << ' ' << i2 << ' ' << j2 << ' ' << cost
          // << '\n';
          edges.push_back({i * w + j, i2 * w + j2, cost});
          edges.push_back({i2 * w + j2, i * w + j, cost});
        }
      }
    }
  }

  Dijkstra d;
  vector<int> min_dists = d.minDistance(edges, h * w, ch * w + cw);
  int ans = min_dists[dh * w + dw];
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 304644
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math

sets = [
    set([1,3,5,7,8,10,12]),
    set([4,6,9,11]),
    set([2])
]

def find_group(i):
    for index, group in enumerate(sets):
        if i in group:
            return index


H,W = map(int, sys.stdin.readline().rstrip().split())

targets = []

# H -> W
for h in (H//3, H//3 + 1):
    res = H-h
    targets.append([h*W, (W//2)*res, (W-W//2)*res])
    targets.append([h*W, (res//2)*W, (res-res//2)*W])
for w in (W//3, W//3 + 1):
    res = W-w
    targets.append([w*H, (H//2)*res, (H-H//2)*res])
    targets.append([w*H, (res//2)*H, (res-res//2)*H])

print(min([
    max(target) - min(target)
    for target in targets
]))

exit(0)


Measured memory_bytes: 3064
N, M = map(int, input().split())
a = set([int(input()) for _ in range(M)])

MOD = 1000000007

dp = [0] * (N + 1)
dp[0] = 1

if 1 not in a:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2, N + 1):
    if i in a:
        continue
    dp[i] = dp[i - 1] + dp[i - 2]
    dp[i] %= MOD

print(dp[N])


Measured memory_bytes: 56664
#include <iostream>
using namespace std;
int main(){
  int m = 0,s;
  for(int i = 0 ; i < 4 ; i++)
    {
      cin >> s;
      m+=s;
    }
  s = m%60;
  m = m/60;
  cout << m << endl;
  cout << s << endl;
}

Measured memory_bytes: 1160
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int monsterCount = sc.nextInt();
		int extraAttackCount = sc.nextInt();
		long answer = 0;

		int[] monsterArray = new int[monsterCount];
		for(int i = 0; i < monsterCount; i++) {
			monsterArray[i] = sc.nextInt();
		}
		Arrays.sort(monsterArray);

		for(int i =0; i < monsterCount -extraAttackCount; i++) {
			answer += monsterArray[i];
		}
		System.out.println(answer);
	}
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (b > c) swap(b, c);
    if (a > b) swap(a, b);
    cout << a << " " << b << " " << c << endl;
}


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

int main(){
  string s;
  cin >> s;
  int count = 0;
  for(int i = 0; i < s.size(); i++){
    for(int j = 0; j <= s.size() - i; j++){
      string s1 = s.substr(i, j);
      int count1 = 0;
      for(int k = 0; k < s1.size(); k++){
        if(s1.at(k) == 'A' || s1.at(k) == 'C' || s1.at(k) == 'G' || s1.at(k) == 'T'){
          count1++;
        }
        else break;
      }
      if(count < count1) count = count1;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;

	void run() {
		for (;;) {
			int n = sc2.nextInt();
			if (n == 0) {
				return;
			}
			BigInteger[][] info = new BigInteger[n][2];
			for (int i = 0; i < n; i++) {
				info[i][0] = new BigInteger(sc2.next());
				info[i][1] = new BigInteger(sc2.next());

				BigInteger div = info[i][0].gcd(info[i][1]);
				info[i][0] = info[i][0].divide(div);
				info[i][1] = info[i][1].divide(div);
			}
			BigInteger gcd = info[0][1].gcd(info[1][1]);
			BigInteger lcm = info[0][1].multiply(info[1][1]).divide(gcd);
			for (int i = 2; i < n; i++) {
				gcd = lcm.gcd(info[i][1]);
				lcm = lcm.divide(gcd).multiply(info[i][1]);
			}
			for (int i = 0; i < n; i++) {
				info[i][0] = info[i][0].multiply(lcm).divide(info[i][1]);
				info[i][1] = lcm;
			}
			gcd = info[0][0].gcd(info[1][0]);
			lcm = info[0][0].divide(gcd).multiply(info[1][0]);
			for (int i = 2; i < n; i++) {
				gcd = lcm.gcd(info[i][0]);
				lcm = lcm.divide(gcd).multiply(info[i][0]);
			}
			for (BigInteger[] out : info) {
				System.out.println(lcm.divide(out[0]));
			}
		}
	}

	long gcd(long a, long b) {
		return a % b == 0 ? b : gcd(b, a % b);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 43508
H, N = map(int, input().split())

data = []

for i in range(N):
    a, b = map(int, input().split())
    data.append({'a': a, 'b': b})

dp = [[float('inf')] * (H+1) for _ in range(N)]


for i in range(N):
    dp[i][0] = 0

for j in range(H+1):
    dp[0][j] = -(-j // data[0]['a']) * data[0]['b']

for i in range(1, N):
    power = data[i]['a']
    magic = data[i]['b']

    for j in range(H+1):
        dp[i][j] = dp[i - 1][j]
        if j <= power:
            dp[i][j] = min(dp[i][j], dp[i-1][max(0, j - power)] + magic)
        else:
            dp[i][j] = min(dp[i][j], dp[i][j - power] + magic)

# print(dp)
print(dp[N-1][H])


Measured memory_bytes: 381976
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int min_prime(int n);
int isprime(int n);

int main()
{
	int n, p;
	while(1){
		cin >> n >> p;
		if(n == -1 && p == -1) break;
		int prime_array[1000] = {0}, sum_array[50000] = {0};
		prime_array[0] = min_prime(n);
		for(int i = 0; i < (2 * p); i++){
			prime_array[i + 1] = min_prime(prime_array[i]);
		}
		int k = 0;
		for(int i = 0; i < (2 * p) + 1; i++){
			for(int j = i; j < (2 * p) + 1; j++){
				sum_array[k] = prime_array[i] + prime_array[j];
				k++;
			}
		}
		sort(sum_array, sum_array+k);
		cout << sum_array[p - 1] << endl;
	}
	return 0;
}

int min_prime(int n)
{
	while(++n){
		if(isprime(n)) break;
	}
	return n;
}

int isprime(int n)
{
	int ans = 0;
	if(n == 0 || n == 1) ans = 0;
	else if(n == 2) ans = 1;
	else {
		for(int i = 2; i < n; i++){
			if(i * i > n){
				ans = 1;
				break;
			}
			else if(n % i == 0){
				ans = 0;
				break;
			}
		}
	}
	return ans;
}

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

using namespace std;

typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    ll x[n], y[n], z[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = 0;
    for (int u = -1; u <= 1; u += 2) {
        for (int v = -1; v <= 1; v += 2) {
            for (int w = -1; w <= 1; w += 2) {
                ll t[n];
                for (int i = 0; i < n; i++) {
                    t[i] = x[i] * u + y[i] * v + z[i] * w;
                }
                sort(t, t+n);
                reverse(t, t+n);

                ll cur = 0;
                for (int i = 0; i < m; i++) {
                    cur += t[i];
                }

                ans = max(ans, cur);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


a = input()
k = inp()
i = 0
while i < len(a) and a[i] == '1':
    i += 1

if i >= k:
    print(1)
elif len(a) == i:
    print(1)
else:
    print(a[i])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N,T; cin>>N>>T;
  vii adp(N+1,vi(T)),dp(N+1,vi(T));
  REP(i,1,N){
    int A,B; cin>>A>>B;
    rep(j,0,min(A,T))
      dp[i][j]=dp[i-1][j];
    rep(j,min(A,T),T)
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-A]+B);
    rep(j,0,min(A,T))
      adp[i][j]=max(adp[i-1][j],dp[i-1][j]+B);
    rep(j,min(A,T),T)
      adp[i][j]=max(adp[i-1][j],max(dp[i-1][j]+B,adp[i-1][j-A]+B));
    }
  cout<<adp[N][T-1]<<endl;
  }


Measured memory_bytes: 141312
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int d[10];
int n,k;

bool digit(int n){
  while(n>0){
    REP(i,k){
      if(n%10 == d[i]){
        return false;
      }
    }
  n/=10;
  //cout<<n<<endl;
  }
  return true;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  REP(i,k) cin>>d[i];
  for(int i=n;i<10*n;i++){
    if(digit(i)){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <random>
#include <cfloat>
#define norm(X) ((X) * (X))
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

const llong s = 7000000;
const double R = 1e11;
llong n;
double px[105];
double py[105];
llong cnt[105];
double x;
double y;
double r;
llong indx;

int main() {
    
    cin >> n;
    for (llong i = 0; i < n; i++) {
        cin >> px[i];
        cin >> py[i];
    }
    
    for (llong i = 1; i <= s; i++) {
        x = R * cos(i * 2.0 * M_PI / s);
        y = R * sin(i * 2.0 * M_PI / s);
        indx = 0;

        r = 1e32;

        //cout << x << ' ' << y << endl;
        for (llong j = 0; j < n; j++) {
            double d = norm(x - px[j]) + norm(y - py[j]);

            if (d < r) {
                indx = j;
                r = d;
            }
        }

        cnt[indx]++;
    }

    for (llong i = 0; i < n; i++) {
        printf("%.*lf\n", DBL_DIG, (double)cnt[i] / (double)s);
    }

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main (void) {
 
	int k, x;
    
    printf("");	scanf("%d", &k);
    printf("");	scanf("%d", &x);
    
    if(k * 500 >= x) {
    	printf("Yes");
    } else {
    	printf("No");
    }
 
return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize "O3"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define POP pop_back
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define F first
#define S second
#define X real()
#define Y imag()
#ifndef LOCAL
    #define endl "\n"
#endif

using namespace std;
using namespace chrono;
using namespace __gnu_pbds;

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef long long C;
typedef complex<C> P;

const int INF = 1e9;
const long long LLINF = 1e18;
const double PI = 3.14159265358979323;
const long long PRIME = (1ll << 31) - 1;
const long long PRIME2 = 269;
const long long MOD = 1e9 + 7;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class U> using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using hash_set = gp_hash_table<T, null_type>;
template <class T, class U> using hash_map = gp_hash_table<T, U>;
template <class T, class U> ostream& operator<< (ostream &out, pair<T, U> p) { return out << "(" << p.F << ", " << p.S << ")"; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T, class U> ostream& operator<< (ostream &out, map<T, U> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, ordered_set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T, class U> ostream& operator<< (ostream &out, ordered_map<T, U> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, hash_set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T, class U> ostream& operator<< (ostream &out, hash_map<T, U> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> int sign (T x) { return (x > 0) - (x < 0); }
inline ll mod (ll a, ll b) { return a%b + (a < 0) * b; }
inline ll mod (ll a) { return mod(a, MOD); }
C dot (P a, P b) { return a.X * b.X + a.Y * b.Y; }
C cross (P a, P b) { return a.X * b.Y - b.X * a.Y; }

double startTime;
double currTime() { return duration_cast<nanoseconds>(system_clock::now().time_since_epoch()).count() / 1e9; }
double execTime() { return currTime() - startTime; }

int main() {
#ifndef LOCAL
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    srand(time(0));
    startTime = currTime();

    ll a, b;
    cin >> a >> b;
    cout << max(0ll, a - 2 * b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll t=1;
	while(t--)
	{
		ll n;
		cin>>n;
		ll arr[n],i,ans[n],x,y;
		for(i=0;i<n;i++)
			cin>>arr[i];
		ans[0]=0;
		x=abs(arr[1]-arr[0]);
		ans[1]=ans[0]+x;
		for(i=2;i<n;i++)
			ans[i]=min((ans[i-1]+abs(arr[i-1]-arr[i])),(ans[i-2]+abs(arr[i-2]-arr[i])));
		cout<<ans[n-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1792
import heapq


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

    sum_max, sum_min = [0] * (n+1), [0] * (n+1)
    mx_pq, mn_pq = [], []

    for i in range(n):
        heapq.heappush(mx_pq, a[i])
        heapq.heappush(mn_pq, -a[3*n-i-1])

    sum_max[0], sum_min[n] = sum(mx_pq), -sum(mn_pq)

    for i in range(1, n+1):
        if mx_pq[0] < a[n+i-1]:
            sum_max[i] = sum_max[i-1] + a[n+i-1] - heapq.heappop(mx_pq)
            heapq.heappush(mx_pq, a[n+i-1])
        else:
            sum_max[i] = sum_max[i-1]

        if mn_pq[0] < -a[2*n-i]:
            sum_min[n-i] = sum_min[n-i+1] + a[2*n-i] + heapq.heappop(mn_pq)
            heapq.heappush(mn_pq, -a[2*n-i])
        else:
            sum_min[n-i] = sum_min[n-i+1]

    ans = -10 ** 16
    for i in range(n+1):
        ans = max(ans, sum_max[i]-sum_min[i])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39260
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    set<char> se;
    for(char c : s) {
        se.insert(c);
    }
    cout << (se.size() == s.size() ? "yes" : "no") << "\n";
}

Measured memory_bytes: 3620