akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *max_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	using data=tuple<ll,ll,ll>;
	vector<data> v;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		v.emplace_back(i,a,b);
	}
	vector<vector<pll>> edge(n);
	sort(all(v),[](data a,data b){return get<1>(a)<get<1>(b);});
	rep(i,n-1){
		edge[get<0>(v[i])].emplace_back(get<0>(v[i+1]),get<1>(v[i+1])-get<1>(v[i]));
		edge[get<0>(v[i+1])].emplace_back(get<0>(v[i]),get<1>(v[i+1])-get<1>(v[i]));
	}
	sort(all(v),[](data a,data b){return get<2>(a)<get<2>(b);});
	rep(i,n-1){
		edge[get<0>(v[i])].emplace_back(get<0>(v[i+1]),get<2>(v[i+1])-get<2>(v[i]));
		edge[get<0>(v[i+1])].emplace_back(get<0>(v[i]),get<2>(v[i+1])-get<2>(v[i]));
	}
	priority_queue<data> q;
	set<ll> s;
	q.emplace(0,0,0);
	ll ans=0;
	while(!q.empty()){
		ll c,from,to;
		tie(c,from,to)=q.top();
		q.pop();
		if(s.find(to)!=s.end())continue;
		s.insert(to);
		ans-=c;
		//puta(c,from,to);
		for(auto&e:edge[to]){
			ll nxt,cost;
			tie(nxt,cost)=e;
			if(s.find(nxt)!=s.end())continue;
			q.emplace(-cost,to,nxt);
		}
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 21104
/*GRATITUDE*/
/*1916057*/
//Arise Awake and Stop Not Till the Goal is reached. 
//Break through all barriers..
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define endl            "\n"
#define PI                 acos(-1)
#define w(t)              int t; cin>>t; while(t--)
#define for_f(a,b,c)      for(int i=a;i<=b;i=i+c)
#define for_r(a,b,c)      for(int i=a;i>=b;i=i-c) 
#define trace1(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
void ash_god()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}

/*************************************************************************************************/
//Write your functions here..............................

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

void solve() {
/*Write your code here*/
 int x; cin>>x;
 if(x>=30) cout<<"Yes";
 else cout<<"No";
}
int32_t main()
{
ash_god();
bool tc=0;
if(tc)  {
    w(t) solve();
}
else solve();

return 0;
} 

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>

using namespace std;

using ll = long long;
const ll INF = 1e18L + 5;
const int mod = 1e9 + 7;

int n;
vector<ll> dp;
vector<ll> pre;
//pre[mask] score of group mask
void rec(int i, const vector<int>& notTaken, ll scoreSoFar, int mask, int group){
    if(i == (int) notTaken.size()){
        dp[mask] = max(dp[mask], scoreSoFar + pre[group]);
        return;
    }
    rec(i + 1, notTaken, scoreSoFar, mask, group);
    rec(i + 1, notTaken, scoreSoFar, mask ^ (1 << notTaken[i]), group ^ (1 << notTaken[i]));
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    cin >> n;
    vector<vector<ll>> in(n, vector<ll>(n));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> in[i][j];
        }
    }
    pre.resize(1 << n);
    for(int mask = 0; mask < (1 << n); mask++){
        for(int i = 0; i < n; i++){
            if(mask & (1 << i)){
                for(int j = i + 1; j < n; j++){
                    if(mask & (1 << j)){
                        pre[mask] += in[i][j];
                    }
                }
            }
        }
    }
    //dp[maks] best total score if we grouped rabbits from mask already
    dp.resize(1 << n, -INF);
    dp[0] = 0;
    
    for(int mask = 0; mask < (1 << n); mask++){
        vector<int> notTaken;
        for(int i = 0; i < n; i++){
            if(!(mask & (1 << i))){
                notTaken.push_back(i);
            }
        }
        rec(0, notTaken, dp[mask], mask, 0);
    }
    
    cout << dp[(1 << n) - 1];
}



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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll K;
  cin >> K;

  ll a[] = { 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 };

  cout << a[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]
print('AC' +  ' x ' + str(S.count('AC')))
print('WA' +  ' x ' + str(S.count('WA')))
print('TLE' + ' x ' + str(S.count('TLE')))
print('RE' +  ' x ' + str(S.count('RE')))

Measured memory_bytes: 16276
#include <iostream>
#include <queue>
#define x first
#define y second

using namespace std;

int n,m,nrs,nrp;
char c;
pair<int,int>ai[60][60],ac;
queue<pair<int,int>> q;
bool a[60][60];
int dl[]={0, -1,0,1,0};
int dc[]={0, 0,1,0,-1};
bool inside(int lin,int col){
  return (lin>=1&&lin<=n&&col>=1&&col<=m);
}

int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
      cin>>c;
      if(c=='#')a[i][j]=1,nrs++;
    }
    q.push(make_pair(1,1));a[1][1]=1;
    while(not q.empty()){
      ac=q.front(),q.pop();
      a[ac.x][ac.y]=1;
      for(int d=1;d<=4;d++)
        if(a[ac.x+dl[d]][ac.y+dc[d]]==0&&inside(ac.x+dl[d],ac.y+dc[d])){
          a[ac.x+dl[d]][ac.y+dc[d]]=1;
          ai[ac.x+dl[d]][ac.y+dc[d]]=ac;
          q.push(make_pair(ac.x+dl[d],ac.y+dc[d]));
        }
    }
    if(ai[n][m]==make_pair(0,0)){
      cout<<-1;
      return 0;
    }
    for(int lin=n,col=m;lin!=0&&col!=0;){
      nrp++;
      ac=ai[lin][col];
      lin=ac.x;
      col=ac.y;
    }
    cout<<n*m-nrs-nrp;
    return 0;
}


Measured memory_bytes: 256
'''
左端から条件を満たすようにしていく
Image :
[success] + [Failure]
[success] + [success] + [failure]
'''
N = int(input())
para = [int(i) for i in input().split()]
#logの数で判断
log = [para[0]]
p = 1 
flag_a = False
flag_b = False 
cnt = 1
while p <= N -1:
    if not flag_a and not flag_b :
        if para[p] > log[0]: 
            flag_a = True
            log.append(para[p])
            p += 1
        elif para[p] < log[0] : 
            flag_b = True
            log.append(para[p]) 
            p += 1
        else :
            log.append(para[p])
            p += 1
            continue
        
    else :
        if flag_a:
            if para[p] >= log[-1] :
                log.append(para[p])
                p += 1
            else :
                log = [para[p]]
                flag_a = False
                cnt += 1 
        if flag_b :
            if para[p] <= log[-1] :
                log.append(para[p])
                p += 1
            else :
                log = [para[p]]
                flag_b = False
                cnt += 1
print(cnt)


Measured memory_bytes: 14480
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
#include <utility>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*///map < string, ll> s;

/*i++ずつずらす
a[0] a[1] a[2]//a[1] a[2] a[3]
a[0] a[2] a[4]//a[1] a[3] a[5]
/*if (N % 2 != 0)a = N / 2;
else a = N / 2 - 1;
for (int i = 1;i <= a;i++) {
	for (int j = 0;j < N - (i * 2);j++) {
		if (S[j] != S[j + i] && S[j + i * 2] != S[j] && S[j + i] != S[j + i * 2]) sum--;
		if (sum == 0)break;
	}
}*/

//mapの使い方
/*map<int, int> mp;
for (int i = 0; i < N; i++)
	mp[a[i]]++;

int ans = 0;
for (auto p : mp) {
	int x = p.first;
	int n = p.second;
	if (n < x) ans += n;
	else ans += n - x;
}*/
//cout << std::fixed << std::setprecision(12) <<<< endl;

int main() {
	ll A,B;
	cin>>A>>B;
	cout<<(A*B)<<endl;
}

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  bool TakahashiWin = false;
  
  while(A>0){
    C-=B;
    if(C<=0){
      TakahashiWin = true;
      break;
    }
    A-=D;
  }
  if(TakahashiWin){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
      
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
int p,t,pp;
string s;
bool a[100000];
int main(){
  cin>>s;
  vector<P>v;
  while(s.size()>p){
    int res=0,ret,o=0,f=0;
    if(s[p]=='+')p++;
    if(s[p]=='-')f++,p++;
    a[pp++]=f;
    while(isdigit(s[p])){
      res=res*10+(s[p++]-'0');
    }
    if(s[p]=='x'){
      p++;o++;
      if(s[p]=='^'){
        ret=(s[++p]-'0');
        p++;
      }
      else ret=1;
    }
    if(!res)res=1;
    if(f&&!o)res*=(-1);
    if(o)v.push_back(P(res,ret));
    else t=res;
  }
  for(int i=abs(t);i>=-abs(t);i--){
    int res=t;
    for(int j=0;j<v.size();j++){
      if(a[j])res-=v[j].first*pow(i,v[j].second);
      else res+=v[j].first*pow(i,v[j].second);
    }
    if(!res){
      if(i>0)cout<<"(x"<<(-i)<<')';
      else cout<<"(x+"<<(-i)<<')';
    }
  }
  cout<<endl;
}

Measured memory_bytes: 3376
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,A,B;
    cin>>N>>A>>B;
    cout <<min(A,B)<<" "<<max(A+B-N,0)<<"\n";
}

Measured memory_bytes: 892
#include<stdio.h>
main(){
  int h,w,n,hishi=0,tyou=0;
  while(scanf("%d,%d,%d",&h,&w,&n)!=EOF){
    if(h==w && h*h+w*w!=n*n){
      hishi++;
    }
    else if(h!=w && h*h+w*w==n*n){
      tyou++;
    }
  }
  printf("%d\n%d\n",tyou,hishi);
  return 0;
}

Measured memory_bytes: 596
from heapq import heapify, heappop, heappush


def dijkstra(n, train, start):
    d = []
    queue = []
    INF = 10 ** 16
    for i in range(n):
        d.append(INF)
    d[start] = 0
    heapify(queue)
    heappush(queue, (0, start))
    # 都市kに行く時の円またはスヌークのの最小値
    while len(queue) != 0:
        distance, v = heappop(queue)
        if d[v] < distance:
            continue
        for u in range(len(train[v])):
            if d[train[v][u][0]] > d[v] + train[v][u][1]:
                d[train[v][u][0]] = d[v] + train[v][u][1]
                heappush(queue, (d[train[v][u][0]], train[v][u][0]))
    return d


def main():
    n, m, s, t = map(int, input().split())
    s -= 1
    t -= 1
    money = 10 ** 15
    train_en = []
    train_snuuk = []

    for i in range(n):
        train_en.append([])
        train_snuuk.append([])
    for i in range(m):
        fro, to, a, b = map(int, input().split())
        fro -= 1
        to -= 1
        train_en[fro].append((to, a))
        train_en[to].append((fro, a))
        train_snuuk[fro].append((to, b))
        train_snuuk[to].append((fro, b))

    a = dijkstra(n, train_en, s)
    b = dijkstra(n, train_snuuk, t)

    cost_sum = []
    for i in range(n):
        cost_sum.append((a[i] + b[i], i + 1))
    heapify(cost_sum)
    m, y = heappop(cost_sum)
    for i in range(n):
        while y <= i:
            m, y = heappop(cost_sum)
        print(money - m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 112484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define FOR(i, a, b) for(ll i = (a); i < (b); i++)
#define FORD(i, a, b) for(ll i = (b)-1; i >= (a); i--)

typedef vector<int> VI;
typedef vector<VI> VVI;
const ll INF = 1000000000000000000LL;

#define VEI(w,e) ((E[e].u == w) ? E[e].v : E[e].u)
#define CAP(w,e) ((E[e].u == w) ? E[e].cap[0] - E[e].flow : E[e].cap[1] + E[e].flow)
#define ADD(w,e,f) E[e].flow += ((E[e].u == w) ? (f) : (-(f)))

struct Edge { int u, v; ll cap[2], flow; };

VI d, act;

bool bfs(int s, int t, VVI& adj, vector<Edge>& E, ll lim) {
  queue<int> Q;
  d = VI(adj.size(), -1);
  d[t] = 0;
  Q.push(t);
  while (not Q.empty() and d[s] == -1) {
    int u = Q.front(); Q.pop();
    for (int i = 0; i < int(adj[u].size()); ++i) {
      int e = adj[u][i], v = VEI(u, e);
      if (CAP(v, e) >= lim and d[v] == -1) {
        d[v] = d[u] + 1;
        Q.push(v);
      }
    }
  }
  return d[s] >= 0;
}

bool dfs(int u,int t,ll bot,VVI& adj,vector<Edge>& E, ll lim) {
  if (bot == 0) return false;
  if (u == t) return true;
  for (; act[u] < int(adj[u].size()); ++act[u]) {
    int e = adj[u][act[u]];
    if (CAP(u, e) >= lim and d[u] == d[VEI(u, e)] + 1) {
      ll inc=dfs(VEI(u,e),t,min(bot,CAP(u,e)),adj,E,lim);
      if (inc) {
        ADD(u, e, lim);
        return true;
      }
    }
  }
  return false;
}

ll maxflow(int s, int t, VVI& adj, vector<Edge>& E) {
  for (int i=0; i<int(E.size()); ++i) E[i].flow = 0;
  ll flow = 0;
  for(int lim = (1<<30); lim >= 1;) {
    if(!bfs(s,t,adj,E, lim)) {
      lim >>= 1;
      continue;
    }
    act = VI(adj.size(), 0);
    while (dfs(s,t,INF, adj, E, lim)) flow += lim;
  }
  return flow;
}

void addEdge(int u, int v, VVI& adj, vector<Edge>& E, ll cap){
	Edge e;
	e.u = u;
	e.v = v;
	e.cap[0] = cap;
	e.cap[1] = 0;
	e.flow = 0;
	adj[u].push_back(E.size());
	adj[v].push_back(E.size());
	E.push_back(e);
}
int main() {
	int n;
	cin >> n;
	vector<int> v(n+1);
	long long ans = 0;
	for(int i = 1; i <= n; ++i) {
		cin >> v[i];
		if(v[i] > 0) ans += v[i];
	}
	vector<vector<int>> adj(n+2);
	vector<Edge> E;
	int S = 0, T = n+1;
	for(int i = 1; i < n+1; ++i) {
		if(v[i] <= 0) addEdge(S, i, adj, E, -v[i]);
		else addEdge(i, T, adj, E, v[i]);
		for(int j = 2; i*j < n+1; ++j) {
			addEdge(i, i*j, adj, E, INF);
		}
	}
	cout << ans - maxflow(S,T,adj,E) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<string> str;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        str.push_back(s);
    }
    sort(str.begin(), str.end());
    for(int i = 0; i < str.size(); i++)
    {
        cout << str[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int count=0;
  cin>>s;
  if(s.at(0)=='1') count++;
  if(s.at(1)=='1') count++;
  if(s.at(2)=='1') count++;
  cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,i=0,j,c=0,s,w;
    cin >> s >> w;
    if(s<=w)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }

    return 0;

}


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

print(' '.join(map(str, A)))
for i in range(1, N):
    j = i
    while j >= 1 and A[j] < A[j-1]:
        A[j-1], A[j] = A[j], A[j-1]
        j -= 1
    print(' '.join(map(str, A)))


Measured memory_bytes: 5604
import java.util.*
 
fun main(args:Array<String>){
  val list = readLine()!!.split(" ").map(String::toInt)
  var five = 0
  var seven = 0
  for(i in 0..list.size - 1){
    when{
      list[i] == 5 -> five++
      list[i] == 7 -> seven++
    }
  }
  if((five == 2) &&(seven == 1)){
    println("YES")
  }
  else{
    println("NO")
  }
}


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

int toIdx(char s){
    if(s == 'S') return 0;
    if(s == 'H') return 1;
    if(s == 'C') return 2;
    if(s == 'D') return 3;
}

char toSuit(int i){
    if(i == 0) return 'S';
    if(i == 1) return 'H';
    if(i == 2) return 'C';
    if(i == 3) return 'D';
}

int main(){
    int n;
    cin >> n;
    int card[4][13] = {0};
    for(int i =0;i<n;++i){
        char s;
        int c;
        cin >> s >> c;
        card[toIdx(s)][c-1] = 1;
    }

    for(int i=0;i<4;++i){
        for(int j=0;j<13;++j){
            if(card[i][j] == 0){
                cout << toSuit(i) << " " << j+1 << endl;
            }
        }
    }
    return 0;
}



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

using namespace std;

#define OnlineJudge1

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
#define debug(x) cerr << #x << " = " << (x) << '\n'
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("input.in","r",stdin);
    freopen("output.in","w",stdout);
#endif
}

const int N = 1e4 + 9, M = 105, OO = 0x3f3f3f3f;
const ll llOO = 1e18;


int main(){
    init();

    string s, t, u; cin >> s >> t;
    int a, b;   cin >> a >> b >> u;

    cout << (s == u ? a - 1 : a) << " " << (t == u ? b - 1 : b);


}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,j;
	cin>>n;

	int h[n];

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

	int arr[n];
	arr[0] = 0;
	int v1,v2= 1000000;
	for(i = 1; i<n ; i++){
		v1 = abs(h[i] - h[i-1]) + arr[i-1];
		if(i>1)
			v2 = abs(h[i] - h[i-2]) + arr[i-2];
		arr[i] = min(v1,v2);
	}

	cout<<arr[n-1];


}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <bitset>
#include <fstream>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair <int, int>
#define pll pair <long long, long long>
#define vi vector <int>
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

const ll inf = 1e18;

const int N = 55;
ll n, ans, a[N];

bool simple_check(ll x)
{
	ll need = 0;
	for(int i = 0; i < n; i++)
	{
		ll b = a[i] + x;
		need += b / (n + 1);
		if(b % (n + 1) == n)
			need++;
	}
	return need <= x;
}

bool check(ll x)
{
	for(ll i = x; i >= 0 && i >= x - 100; i--)
		if(simple_check(i)) return true;
	return false;
}

ll bs(ll l, ll r)
{
	if(l == r)
		return l;
	if(r == l + 1)
		if(check(l)) return l; else return r;
	ll m = (l + r) / 2;
	if(check(m)) return bs(l, m); else return bs(m, r);
}

int main()
{
	ios:: sync_with_stdio(false);
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	ans = bs(0, inf);
	//cout << "Kek" << endl;
	//for(int i = 0; i < 10; i++)
	//	cout << i << ": " << check(i) << endl;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;


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

	// long long?
	string S;
	cin >> S;

	bool easy = true;

	for (int i = 0; i != S.length(); ++i) {
		if (i % 2 == 1) {
			if (!((S[i] == 'L') || (S[i] == 'U') || (S[i] == 'D'))) {
				easy = false;
			}
		}
		else {
			if (!((S[i] == 'R') || (S[i] == 'U') || (S[i] == 'D'))) {
				easy = false;
			}
		}
	}

	if (easy) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;

}

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

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long num;
    cin>>num;
    bool flag = false;
    int n1, n2;
    for(int i=9;i>=1;i--){
        if(num%i==0){
            n1 = i;
            n2 = num/i;
            if(n1<=9 && n2<=9){
                flag = true;
                break;
            }
        }
    }
    if(flag){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 256
number = int(input())
list_number = input().split()

ok = 0
for i in list_number:
    if int(i) % 2 == 0:
        if int(i) % 3 == 0 or int(i) % 5 == 0:
            pass
        else:
            ok = 1
            print("DENIED")
            break

if ok == 0:
    print("APPROVED")


Measured memory_bytes: 2940
from itertools import accumulate

N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A1 = list(accumulate(A1))
A2 = list(accumulate(A2[::-1]))[::-1]
print(max(A1[i] + A2[i] for i in range(N)))

Measured memory_bytes: 38384
from itertools import accumulate

n, k = map(int, input().split())
MOD = 10 ** 9 + 7
f_acc = [0] + list(accumulate(list(range(n + 1))))
b_acc = [0] + list(accumulate(reversed(list(range(n + 1)))))
ans = 0
for i in range(k, n + 2):
    min_ = f_acc[i]
    max_ = b_acc[i]
    ans = (ans + max_ - min_ + 1) % MOD
print(ans)


Measured memory_bytes: 37956
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;

#define INF 987654321
#define ll long long

string s;

int main()
{
	cin >> s;
	if (s == "AKIHABARA" || s == "AKIHABAR" || s == "AKIHABRA" ||
		s == "AKIHABR" || s == "AKIHBARA" || s == "AKIHBAR" ||
		s == "AKIHBRA" || s == "AKIHBR" || s == "KIHABARA" ||
		s == "KIHABAR" || s == "KIHABRA" || s == "KIHABR" ||
		s == "KIHBARA" || s == "KIHBAR" || s == "KIHBRA" ||
		s == "KIHBR") cout << "YES";
	else cout << "NO";

	return 0;
}

Measured memory_bytes: 256
public class Main {

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                sb.append(i);
                sb.append("x");
                sb.append(j);
                sb.append("=");
                sb.append(i * j);
                System.out.println(sb.toString());
                sb.setLength(0);
            }
        }
    }
}

Measured memory_bytes: 24104
from collections import Counter
X,M = map(int, input().split())

A = list(map(int, input().split()))
C = Counter(A)
P = [0] * M # mod iの数
Q = [0] * M # mod iの同一数字のペアの数

for k,v in C.items():
  P[k % M] += v
  Q[k % M] += v//2

#print(P)
#print(Q)
ans = 0
for i in range(1,(M+1)//2):
  p1, p2 = P[i], P[M-i]
  q1, q2 = Q[i], Q[M-i]
  if p1 > p2:
    p1,p2 = p2,p1
    q1,q2 = q2,q1
  #print(ans, p1,p2,q1,q2)
  ans += p1
  ans += min((p2-p1)//2, q2)
ans += P[0] // 2
if M%2 == 0:
  ans += P[M//2] // 2
  
print(ans)

Measured memory_bytes: 100504
#include <bits/stdc++.h>
using namespace std;
#define int long long
long long gcd(long long a,long long b)
{
    if (a%b==0) return(b);
    else return(gcd(b,a%b));
}
 long long lcm(long long a,long long b){
 long long g = gcd(a,b);
 return a / g * b; 
 }
signed main(void){
    int a,b,c,d; cin>>a>>b>>c>>d;
    //aいか
    int x = (a-1)/c, y = (a-1)/d, z = (a-1)/lcm(c,d);
    int la = a-1-(x+y-z);
    //cout<<la<<endl;
    //bいか
    int s = (b)/c, t = b/d, st = b/lcm(c,d);
    
    int lb = b-(s+t-st);
    //cout<<lb<<endl;
    cout<<lb-la<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N,a,b,i,cnt=0;
    scanf("%d%d%d",&N,&a,&b);
    for(i=1;i<=N;i++){
        int sum=0,m=i;
        while(m>0){
            sum+=m%10;
            m/=10;
        }
        if(sum>=a && sum<=b) cnt+=i;
    }
    printf("%d",cnt);
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    rep(i,s.size()){
        if (s[i]=='1') cout<<'9';
        else if(s[i]=='9') cout<<'1';
        else cout<<s[i];
    }cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power_mod(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define outaa(a, m, n) rep(i, m) {rep(j, n) cout << a[i][j] << " "; cout << endl;} cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl

//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always
//product of minimum 9 prime numbers is above 1e9


int main() {
    
    
    
    
    int N, W; cin >> N >> W;
    ll dp[100007] = {0};
    
    rep(i, N) {
        int w, v; cin >> w >> v;
        for (int j = W; j >= w; --j) {
            chmax(dp[j], dp[j - w] + v);
        }
    }
    
    out(dp[W]);
    
    
}


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

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

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

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

  if (stoi(s.substr(5, 2)) <= 4) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}


Measured memory_bytes: 256
N=int(input())

csflist=[]
for i in range(N-1):
  c,s,f=map(int,input().split())
  csflist.append((c,s,f))
#print(csflist)

for i in range(N):
  sec=0
  for j in range(i,N-1):
    c,s,f=csflist[j]
    if sec<s:
      sec=s
    elif sec%f>0:
      sec+=f-(sec%f)
    sec+=c
    #print(i,j,sec)
  print(sec)


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

int main(){
    int n;
    cin >> n;
    vll v(n);
    rep(i,n) cin>>v[i];
    if(v[0]!=0){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=1;i<n;i++){
        if(v[i]>v[i-1]+1){
            cout << -1 << endl;
            return 0;
        }
    }
    //ans by tourist
    ll ans = 0;
    ll delta = 0;
    set<ll> s;
    for(int i=n-1;i>=0;--i){
        delta--;
        s.insert(v[i]-delta);
        if(!s.empty() && *s.begin() + delta == 0) s.erase(s.begin());
        ans += s.size();
        /*cout<<s.size()<<" ";
        cout<<endl;
        for(auto p:s) cout << p << " ";
        cout<<endl;*/
    }
    //puts("");
    //ans by yutaka1999(this is easier than tourist!)
    /*
    rep(i,n-1){
        if(v[i] == v[i-1]+1) ans++;
        else ans += v[i];
    }
    */
    cout << ans << endl;
}
/*
test case
9
0 1 1 0 1 2 2 1 2
*/

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int main(void)
{
	int a,b,h,r;
	cin>>h>>r;
	if(h<0&&abs(h)>r) cout<<"-1"<<endl;
	else if(h<0&&abs(h)==r) cout<<"0"<<endl;
	else cout<<"1"<<endl;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef unsigned int INT;
typedef unsigned long long LONG;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define FW freopen("data2.txt", "w", stdout);
//快速读入输出，只适用于整数，使用时流同步打开，C语言不准关流
// getchar()<<cin(关流)<<scanf()<<cin
template <class T>
inline bool Read(T& ret)
{
    char c;
    int sgn;
    if (static_cast<void>(c = getchar()), c == EOF)
        return 0;
    while (c != '-' && (c < '0' || c > '9'))
        c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (static_cast<void>(c = getchar()), c >= '0' && c <= '9')
        ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}
//输出只能用于整数
template <class T>
inline void Write(T x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        Write(x / 10);
    putchar(x % 10 + '0');
}

void slove(int question_num)
{
    LL x, y, k;
    cin >> x >> y >> k;
    cout << (k * y + k) / (x - 1) + k << endl;
}

void slove1(int quetion_num)
{
    string s, t;
    int ans = 999999;
    cin >> s >> t;
    for (int i = 0; i < s.size() - t.size(); ++i) {
        int cur = 0;
        for (int j = 0; j < t.size(); ++j) {
            if (t[j] != s[i + j])
                cur++;
        }
        ans = min(ans, cur);
    }
    if (s.size() == t.size()) {
        int cur = 0;
        for (int i = 0; i < s.size(); ++i)
            if (s[i] != t[i])
                cur++;
        ans = min(ans, cur);
    }
    cout << ans << endl;
}
int main()
{
    int num = 1;
    // cin >> num;
    for (int i = 1; i <= num; ++i) {
        slove1(i);
    }
    // system("pause");
    return 0;
}

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e9;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert


int main(){
    //#ifndef ONLINE_JUDGE
    //freopen("input00.txt","r",stdin);
    //#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    ll T = 1;
    //cin>>T;
    while(T--){
        vector<ll> a = {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};
        ll n;
        cin>>n;
        n--;
        cout << a[n];
        
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(a: int, b: int):
    a = str(a)
    b = str(b)

    r = a * int(b)
    r2 = b * int(a)

    result = sorted([r, r2])[0]
    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
#define def make_pair(0,0)
template<class V, int NV> struct SegTree { //[l,r)
    V comp(V& l, V& r) { return max(l, r); };

    vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
    V get(int x, int y, int l = 0, int r = NV, int k = 1) {
        if (r <= x || y <= l)return def; if (x <= l && r <= y)return val[k];
        auto a = get(x, y, l, (l + r) / 2, k * 2);
        auto b = get(x, y, (l + r) / 2, r, k * 2 + 1);
        return comp(a, b);
    }
    void update(int i, V v) {
        i += NV; val[i] = v;
        while (i > 1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
    }
    void add(int i, V v) { update(i, val[i + NV] + v); }
    V operator[](int x) { return get(x, x + 1); }
};

/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, A[101010];
SegTree<pair<int,ll>, 1 << 17> st;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    rep(i, 0, N) {
        auto p = st.get(0, A[i]);

        p.first++;
        p.second += A[i];

        chmax(p, st[A[i]]);
        st.update(A[i], p);
    }

    cout << st.get(0, 1 << 17).second << endl;
}


Measured memory_bytes: 7356
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(auto i=0;i<n;i++)
#define s(c) static_cast<int>((c).size())

struct Node{
	int key;
	Node *l;
	Node *r;
	Node *p;
};
Node *nil = new Node{INT_MAX};

void insert(Node *T, int key){
	Node *z = new Node{key, nil, nil, nil};
	if(T->key == INT_MAX){
		*T = *z;
		return;
	}
	Node *x = T;
	Node *y = x->p;
	while(x != nil){
		y = x;
		x = (key < x->key) ? x->l : x->r;
	}
	z->p = y;
	if(key < y->key){
		y->l = z;
	}else{
		y->r = z;
	}
}

bool find(Node *node, int key){
	if(node == nil) return false;
	int cmp = node->key;
	if(key == cmp) return true;

	return find( (key<cmp) ? node->l : node->r , key);
}

vector<int> pre, in;
void preorder(Node *node){
	pre.push_back(node->key);
	if(node->l != nil) preorder(node->l);
	if(node->r != nil) preorder(node->r);
}

void inorder(Node *node){
	if(node->l != nil) inorder(node->l);
	in.push_back(node->key);
	if(node->r != nil) inorder(node->r);
}

void print(vector<int> v){
	r(i, s(v))
		cout << ' ' << v[i];
	cout << endl;
}

void printPreorder(Node *node){
	preorder(node);
	print(pre);
	pre.clear();
}

void printInorder(Node *node){
	inorder(node);
	print(in);
	in.clear();
}

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

	Node *root = new Node{INT_MAX};
	string cmd;
	int arg;
	r(i, m){
		cin >> cmd;
		if(cmd[0] == 'i'){
			cin >> arg;
			insert(root, arg);
		}else if(cmd[0] == 'f'){
			cin >> arg;
			cout << (find(root, arg) ? "yes" : "no") << endl;
		}else{
			printInorder(root);
			printPreorder(root);
		}
	}

	return 0;
}



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

#define MAX_N 10000
#define MAX_M 9
typedef long long int ll;

int cost[10] = {MAX_N + 1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int dp[MAX_N + 1];

int main() {
  int n, m, a[MAX_M];

  std::cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    std::cin >> a[i];
  }
  std::sort(a, a + m);

  for(int i = 1; i <= n; ++i) {
    dp[i] = - 10000;
    for(int j = 0; j < m; ++j){
      if(i - cost[a[j]] < 0) {
        continue;
      }
      dp[i] = std::max(dp[i], dp[i - cost[a[j]]] + 1);
    }
  }

  while(n > 0) {
    for(int i = m - 1; m >= 0; --i) {
      if(n >= cost[a[i]] && dp[n] == dp[n - cost[a[i]]] + 1) {
        std::cout << a[i];
        n -= cost[a[i]];
        break;
      }
    }
  }
  std::cout << std::endl;
}

Measured memory_bytes: 256
s = input()
t = input()
dp = []
for i in range(len(s)+1):
  L = [0]*(len(t)+1)
  dp.append(L)
for i in range(len(s)):
  for j in range(len(t)):
    if s[i] == t[j]:
      dp[i+1][j+1] = dp[i][j]+1
    else:
      dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
n = len(s)
m = len(t)
ans = ''
while n > 0 and m > 0:
  if dp[n][m] == dp[n-1][m]:
    n -= 1
  elif dp[n][m] == dp[n][m-1]:
    m -= 1
  else:
    n -= 1
    m -= 1
    ans = s[n]+ans
print(ans)

Measured memory_bytes: 112348
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main
{
	public static void main (String[] arg)throws IOException
	{
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String ln[];
		double x = 0;
		double y = 0;
		double angle=Math.toRadians(90);
		String s="";
		while((s = input.readLine()) != null && !s.isEmpty()){
			ln=s.split(",");
			x += Integer.parseInt(ln[0])*Math.cos(angle);
			y += Integer.parseInt(ln[0])*Math.sin(angle);
			angle += Math.toRadians(-1*Integer.parseInt(ln[1]));	
			
		}
		System.out.println((int)x);
		System.out.println((int)y);
	}
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 101;
const int maxV = 1e5 + 1;

int n;
ll W;
ll w[maxN];
int v[maxN];
ll dp[maxN][maxV];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> W;
    for1(i, n)
    {
        cin >> w[i] >> v[i];
    }
    memset(dp, 0x3f, sizeof(dp));
    fore(i, 0, n)
    {
        dp[i][0] = 0;
    }
    for1(i, n)
    {
        for1(j, 1e5)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= v[i])
            {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
            }
        }
    }
    for (int j = 1e5; j >= 0; --j)
    {
        if (dp[n][j] <= W)
        {
            cout << j;
            return 0;
        }
    }
    return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
ll MOD = ll(1e8) + 9;

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll N, K;
    cin >> N >> K;
    vector<int> teleport(N);
    for (int i = 0; i < N; i++) {
        cin >> teleport[i];
        teleport[i]--;
    }

    vector<vector<ll>> x(N);
    ll next = 0;
    ll cnt = 0;
    do {
        x[next].push_back(cnt++);
        next = teleport[next];
        if (cnt == K) {
            cout << next + 1 << endl;
            return;
        }
    } while (x[next].size() == 0);
    x[next].push_back(cnt);

    K -= x[next][0];
    K %= x[next][1] - x[next][0];

    while (K > 0) {
        K--;
        next = teleport[next];
    }

    cout << next + 1 << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}



Measured memory_bytes: 13788
#include<stdio.h>
int main(){
	int W=0,H,x,y,r;
	while(x<-100 || 100<y || W<1 || 100<r){
		scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	}
	if(x >= r){
		if(x + r <= W){
			if(y >= r){
				if(y + r <= H) printf("Yes\n");
				else printf("No\n");
			}
			else printf("No\n");
		}
		else printf("No\n");
	}
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 580