akhauriyash/Code-Regression huggingface dataset:
(let ((s (nreverse (read-line))))
  (labels ((f (str)
             (cond ((string= "" str) t)
                   ((and (>= (length str) 7)
                         (string= "remaerd" str :end2 7)) (f (subseq str 7)))
                   ((and (>= (length str) 6) 
                         (string= "resare" str :end2 6)) (f (subseq str 6)))
                   ((and (>= (length str) 5)
                         (string= "maerd" str :end2 5)) (f (subseq str 5)))
                   ((and (>= (length str) 5)
                         (string= "esare" str :end2 5)) (f (subseq str 5)))
                   (t nil))))
    (format t "~A~%" (if (f s) 'yes 'no))))

Measured memory_bytes: 86184
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int main(){
    int h, w;
    while(cin >> h >> w && h > 0){
        auto p = make_pair(h * h + w * w, h);
        auto min_p = make_pair(INT_MAX, INT_MAX);
        int ans_x = -1, ans_y = -1;
        for(int y = 1; y <= 200; y++) {
            for(int x = y + 1; x <= 200; x++) {
                auto q = make_pair(y * y + x * x, y);
                if(q > p && q < min_p) {
                    min_p = q;
                    ans_x = x;
                    ans_y = y;
                }
            }
        }
        cout << ans_y << " " << ans_x << endl;
    }
    return 0;
}

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

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    std::cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

const ll M = 1e9+7;
const ll INF = 1e9+7;

ll n, k, sum[220000], ans;
map<ll, ll> mp;

int main() {
  cin >> n >> k;
  
  for (ll i = 0; i < n; i++) {
    if (i >= k) {
      mp[sum[i-k]]--;
    }
    ll a;
    cin >> a;
    if (i == 0) sum[i] = (a - 1 + k) % k;
    else sum[i] = (sum[i-1] + a - 1 + k) % k;
    if (i < k-1 and sum[i] == 0) ans++;
    ans += mp[sum[i]];
    mp[sum[i]]++;
  }

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

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

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define int ll

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;


void solve() {
	int n;
	cin >> n;

	int a[n];
	set<int> s;
	F0R(i,n) cin >> a[i], s.insert(a[i]);

	int cnt = 0;
	sort(ALLn(a,n));
	
	F0R(i,n-2) {
		FOR(j,i+1,n-1) {
			FOR(k,j+1,n) {
				if(a[i] == a[j] || a[i] == a[k] || a[k] == a[j]) continue;
				if(a[i] + a[j] > a[k] && a[k] - a[j] < a[i]) {
					cnt++;
					// cerr << a[i] << ' ' <</ a[j] << ' ' << a[k] << '\n';
				}
			}
		}
	}

	cout << cnt;
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}

Measured memory_bytes: 3872
#include<stdio.h>
#include<string.h>
#define N 1000010
#define M 14
char H[N][M];
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
int h1(int key){ return key%N; }
int h2(int key){ return (1+key)%(N-1); }
int find(char str[]){
  long long ooh;
  int i = 0;
  long long sum = getKey(str);
  while(1){
    ooh = (h1(sum)+ i * h2(sum)) % N;
    if(strcmp(H[ooh], str) == 0) return 1;
    if(H[ooh][0] == '\0') return 0;
    i++;
  }
  return 0;
}
int insert(char str[]){
  int i = 0;
  long long tin;
  long long sum = getKey(str);
  while(1){
    tin = (h1(sum)+ i * h2(sum)) % N;
    if(H[tin][0] == '\0' || strcmp(H[tin],str) == 0){
      strcpy(H[tin], str);
      break;
    }
    i++;
  }
}
int main(){
  int i, total, h;
    char str[M], com[9];
    for ( i = 0; i < N; i++ ) H[i][0] = '\0';
    scanf("%d", &total);
    for ( i = 0; i < total; i++ ){
      scanf("%s %s", com, str);
      if ( com[0] == 'i' ){
        insert(str);
      } else {
        if (find(str)){
          printf("yes\n");
        } else {
          printf("no\n");
        }
 }
    }
    return 0;
}



Measured memory_bytes: 15468
#include<bits/stdc++.h>
using namespace std;
int K,N,C;
bool flag=false;
int main()
{
  cin>>N;
  for(int i=0;i<3;i++){
    if(N%10==7){
      flag=true;
      break;
    }
    N=N/10;
  }
  if(flag){
    cout<<"Yes";
  }else{
    cout<<"No";
  }

  return 0;
}




Measured memory_bytes: 3636
#include <stdio.h>

long		ft_sqrt(long nb)
{
	long i;
	long count;

	i = 1;
	count = 0;
	while (i <= nb)
	{
		if (i % 2)
		{
			nb -= i;
			count++;
		}
		i++;
	}
	return(count);
}

long		is_prime(long nb)
{
	long i;

	i = 2;
	if (nb < 2)
		return (0);
	while (i <= ft_sqrt(nb))
	{
		if (nb % i == 0)
			return (0);
		i++;
	}
	return (1);
}

long		next_prime(long nb)
{
	while(1)
	{
		if (!is_prime(nb))
			nb++;
		if (is_prime(nb))
			break ;
	}
	return (nb);
}

int	main(void)
{
	long x;
	scanf("%ld", &x);
	printf("%ld", next_prime(x));
	return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N;
    cin >> N;
    vector<Pll> P(N);
    for(int i=0; i<N; i++){
        cin >> P[i].first;
        P[i].second = i;
    }
    sort(P.begin(), P.end(), greater<Pll>());

    Vvec<ll> dp(N+1, vector<ll>(N+1));
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            int k = i+j;
            if(k>=N) break;
            dp[i+1][j] = max(dp[i][j] + P[k].first * abs(P[k].second - i), dp[i+1][j]);
            dp[i][j+1] = max(dp[i][j] + P[k].first * abs(P[k].second - (N-j-1)), dp[i][j+1]);
        }
    }

    ll ans = 0;
    for(int i=0; i<N; i++){
        int j = N-i;
        ans = max(dp[i][j], ans);
    }
    cout << ans << endl;
    // for(auto& v: dp) debug(v);
}

Measured memory_bytes: 34672
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,i,a;
  cin >> n;
  vector<long long> s(n+1,0);
  for(i=1;i<=n;i++){
    cin >> a;
    s[i] = s[i-1] + a;
  }
  sort(s.begin(),s.end());
  long long ans=0,t=1;
  for(i=1;i<=n;i++){
    if(s[i]==s[i-1]) t++;
    else{
      ans += t*(t-1)/2;
      t=1;
    }
  }
  ans += t*(t-1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int w, h; /* 部屋の幅と高さ */
int t[400]; /* タイルの配置 */
int RED = 1, BLACK = 0;

/* 与えられた座標のタイルを始点としたときに到達できるタイルの数を返す */
int search(int x, int y) {
	int n = 0;
	if (t[w * y + x] != BLACK) return n;
	t[w * y + x] = RED;
	n++;
	if (x > 0)     n += search(x - 1, y);
	if (x < w - 1) n += search(x + 1, y);
	if (y > 0)     n += search(x, y - 1);
	if (y < h - 1) n += search(x, y + 1);
	return n;
}

int main(void) {
	int sx, sy; /* 人の初期座標 */
	int i, j;

	/* データセット毎の処理 */
	while (scanf("%d%d", &w, &h) == 2) {
		if (w < 1 || w > 20 || h < 1 || h > 20) break;
		/* タイルの配置を読み込む */
		for (i = 0; i < h; i++) {
			scanf("%*[^.#@]"); /* 改行などを無視する */
			for (j = 0; j < w; j++) {
				char c;
				scanf("%c", &c);
				switch (c) {
				case '@': /* 黒いタイルの上の人 (一つのデータセットに1度だけ出現) */
					sx = j;
					sy = i;
				case '.': /* 黒いタイル */
					t[w * i + j] = BLACK;
					break;
				case '#': /* 赤いタイル */
				default:
					t[w * i + j] = RED;
					break;
				}
			}
		}

		printf("%d\n", search(sx, sy));
	}

    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


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

    map<pair<ll, ll>, ll> count;
    REP(i, n){
        double ai;
        cin >> ai;
        ll bi = static_cast<ll>((ai * 1000000000) + 0.5);
        ll n2 = 0;
        while(bi % 2 == 0){
            n2++;
            bi /= 2;
        }
        ll n5 = 0;
        while(bi % 5 == 0){
            n5++;
            bi /= 5;
        }
        count[make_pair(n2, n5)]++;
    }

    ll ans = 0;
    for(auto it = count.begin(); it != count.end(); ++it){
        for(auto jt = count.begin(); jt != count.end(); ++jt){
            if(it->first.first + jt->first.first >= 18 &&
               it->first.second + jt->first.second >= 18){
                if(it != jt){
                    ans += it->second * jt->second;
                }else{
                    ans += it->second * (it->second - 1);
                }
            }
        }
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n;cin>>n;
  vector<ll> a(n),b(n+1);
  b[0]=0LL;
  rep(i,n){
    cin>>a[i];
    b[i+1]=a[i]+b[i];
  }
  ll c=1e17;
  reps(i,1,n){
    chmin(c,abs(b[n]-2*b[i]));
  }
  cout<<c;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define PB push_back
#define MP make_pair
#define F first
#define S second

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

const int MOD = 1e9+7;
const int INF = 1e9;
const int MAX_HW = 300;

int H, W, D, Q, L, R;
int dist[MAX_HW*MAX_HW];
pii A[MAX_HW * MAX_HW];

int main() {
  cin >> H >> W >> D;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int tmp;
      cin >> tmp; tmp--;
      A[tmp] = MP(i, j);
    }
  }
  for (int i = 0; i < D; i++) {
    int p = i;
    while (p + D < H * W) {
      int np = p + D;
      dist[np] = dist[p] + abs(A[np].F - A[p].F) + abs(A[np].S - A[p].S);
      p = np;
    }
  }

  int ans = 0;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> L >> R; L--; R--;
    ans = dist[R] - dist[L];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
  string s;cin >> s;
  int rem[2020];
  rep(i,2020){
    rem[i]=0;
  }
  rem[0]=1;
  ll cur=0;
  ll pow10[s.size()+1];
  pow10[0]=1;
  rep(i,s.size()){
    pow10[i+1]=(pow10[i]*10)%2019;
  }
  for(int i=s.size()-1;i>=0;i--){
    cur+=pow10[s.size()-i-1]*(s[i]-'0');
    cur%=2019;
    rem[cur]++;
  }
  ll ans=0;
  rep(i,2019){
    ans+=rem[i]*(rem[i]-1)/2;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n; cin>>n;
  map<int, int> a{};
  rep(i, n) {
    int x; cin>>x;
    a[x]++;
  }
  if (a.size()==n) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 9600
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 


/*****************************************************************************/
int C[51][51];

void c(int n) {
	f(i,0, n + 1) {
		f(j, 0, i + 1) {
			if (j == 0 || j == i) {
				C[i][j] = 1LL;
			}
			else {
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
			}
		}
	}
}

signed main(void) {
	int n, a, b;
	cin >> n >> a >> b;
	vi v(n);
	f_vI(v, n);
	c(n);
	sort(all(v), greater<int>());
	double ans1 = 0.0;
	f(i, 0, a) {
		ans1 += v[i];
	}
	ans1 /= a;

	int num = 0, pos = 0;
	f(i, 0, n) {
		if (v[i] == v[a - 1]) {
			num++;
			if (i < a) {
				pos++;
			}
		}
	}
	
	int cnt = 0LL;
	if (pos == a) {
		f(pos,a, b + 1) {
			cnt += C[num][pos];
		}
	}
	else {
		cnt += C[num][pos];
	}
	cout << fixed << setprecision(10) << ans1 << endl << cnt;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    
    map<char, char> ms;
    map<char, char> mt;
    
    for (int i = 0; i < s.size(); ++i)
    {
        if (mt.count(t[i]) == 0)
        {
            mt[t[i]] = s[i];
        }
        if (ms.count(s[i]) == 0)
        {
            ms[s[i]] = t[i];
        }
        
        if (mt[t[i]] == s[i] && ms[s[i]] == t[i])
        {
            continue;
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    string s;
    string t;
    cin >> s;
    cin >> t;
    if(s == t) {
        cout << N << endl;
        return 0;
    }
    int res = 0;
    REP(i, N) {
        int cnt = 0;
        REP(j, N) {
            if(j + i >= N) {
                res = max(res, cnt);
                break;
            }
            if(s[j + i] == t[j]) {
                cnt++;
            } else {
                res = max(res, cnt);
                break;
            }
        }
    }
    cout << 2 * N - res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=1;i<=(n);i++)
using namespace std;
int main(){
  int N,a,ans=1; bool start=false, up;
  cin >>N >>a;
  rep(i,N){
    int b; cin>>b;
    if(start==false){
      if(a<b) up=true, start=true;
      else if(a>b) up=false, start=true;
      a=b;
    }
    else{
      if(a<b && up==false) ans++, up=true, start=false;
      else if(a>b && up==true) ans++, up=false, start=false;
      a=b;
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

int main()
{
    string s;
    cin >> s;
    bool flg = true;

    reverse(s.begin(), s.end());

    while (flg) {
        if (s.find("maerd") == 0) {
            s.erase(0,5);
        }
        else if (s.find("remaerd") == 0) {
            s.erase(0,7);
        }
        else if (s.find("esare") == 0) {
            s.erase(0,5);
        }
        else if (s.find("resare") == 0) {
            s.erase(0,6);
        }
        else {
            flg = false;
        }
    }

    if (s.empty()) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

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

  int count = 0;
  int maxH = H[0];
  for(int i = 0; i < N; i++){
    if(maxH <= H[i]) count++;
    maxH = max(maxH, H[i]);
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
vector<vector<int> > v;
int L = 0, id = 0;
void dfs(int now, int count = 0, int p = -1){
	if(v[now].size() == 1){
		if(L < count) id = now, L = count;
	}
	for(auto& to: v[now]){
		if(to == p) continue;
		dfs(to, count + 1, now);
	}
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n;
    v.resize(n);
    for(int i=1;i<n;i++){
    	cin >> a >> b; 
    	a--,b--;
    	v[a].pb(b);
    	v[b].pb(a);
    }
    dfs(0); dfs(id);
    cout << ((L % 3 == 1)? "Second": "First") << endl;
    return 0;
}


Measured memory_bytes: 20608
def input_from_console():
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    return n, a_list, b_list


def solve(n, a_list, b_list):
    sum_of_a = sum(a_list)
    for i in range(n):
        if a_list[i] - b_list[i] <= 0:
            b_list[i] -= a_list[i]
            a_list[i] = 0
            a_list[i + 1] -= min(b_list[i], a_list[i + 1])
        else:
            a_list[i] -= b_list[i]
    return sum_of_a - sum(a_list)


def main():
    n, a_list, b_list = input_from_console()
    print(solve(n, a_list, b_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Measured memory_bytes: 19004
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,a,b,c;
  cin>>A>>B>>C;
  a=max(max(A,B),C);
  if(a==A){
  b=max(B,C);
  c=min(B,C);
  }
  else if(a==B){
  b=max(A,C);
    c=min(A,C);
  }
  else{
  b=max(A,B);
    c=min(A,B);
  
  }
cout<<a*10+b+c<<endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
ans = 1
i = 1
while i*i <= M:
    if M%i == 0 and M//N >= i:
        ans = max(ans,i)
        if M //i *N <= M:
            ans = max(ans,M//i)
    i += 1
print(ans)


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

namespace ABC142
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);

            int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(h.Count(x => K <= x));
        }
    }
}


Measured memory_bytes: 19296
def print0():
    print(0)
    exit()

n = int(input())
d = list(map(int, input().split()))
mod = 998244353
ans = 1
maxd = max(d)
numcnt = [0] * (maxd + 1)
for i in d:
    numcnt[i] += 1
if not d[0] == 0 or not numcnt[0] == 1:
    print0()
for i in range(1, maxd + 1):
    if numcnt[i] == 0:
        print0()
    ans *= pow(numcnt[i - 1], numcnt[i], mod)
    ans %= mod
print(ans)

Measured memory_bytes: 20756
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  int a, b, c;
  cin >> a >> b >> c;
  int ex = 0;
  if (a==b and b==c and c==a){
    if (a%2==0 && b%2==0 && c%2==0){
      cout << "-1";
    } else {
      cout << ex;
    }
  } else {
    int t_a, t_b, t_c;
    while (true){
      if (a%2==0 && b%2==0 && c%2==0){
        ex++;
        t_a = (b + c)/2;
        t_b = (a + c)/2;
        t_c = (a + b)/2;
        a = t_a;
        b = t_b;
        c = t_c;
      }else{
        cout << ex;
        break;
      }
    }
  }
  return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;

    double teika;
    teika = 10*B;
    int a, d;
    while(1){
        a = (int)teika*0.08;
        d = (int)teika*0.1;
        if( a==A and d == B){
            cout << teika << endl;
            break;
        }

        if(d != B){
            cout << -1 << endl;
            break;
        }
        teika++;
    }

}

Measured memory_bytes: 256
from operator import itemgetter
from collections import deque
n,m=map(int,input().split())
d=dict()
edge=[[] for i in range(n)]
for i in range(m):
  x,y,z=map(int,input().split())
  edge[x-1].append(y-1)
  edge[y-1].append(x-1)
  if x-1 not in d:
    d[x-1]=1
  else:
    d[x-1]+=1
  if y-1 not in d:
    d[y-1]=1
  else:
    d[y-1]+=1
d=sorted(list(d.items()),key=itemgetter(1),reverse=True)
visited=[0]*n
def bfs(edge,visited,s):
  q=deque([s])
  visited[s]=1
  while q:
    x=q.popleft()
    for i in edge[x]:
      newx=i
      if newx<n:
        if visited[newx]!=1:
          visited[newx]=1
          q.append(newx)
  return visited
ans=0
for i in range(len(d)):
  if visited[d[i][0]]==0:
    visited=bfs(edge,visited,d[i][0])
    ans+=1
print(ans+n-sum(visited))

Measured memory_bytes: 40532
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let line = read_as_vec::<usize>();
    let (x, n) = (line[0], line[1]);
    let p = read_as_vec::<usize>();
    if !p.contains(&x) {
        println!("{}", x);
        return;
    }
    let mut ans = 0;
    for i in 0..=101 {
        if !p.contains(&i) && (i as i64 - x as i64).abs() < (ans - x as i64).abs() {
            ans = i as i64;
        }
    }
    println!("{}", ans);
    // let mut are_included: Vec<bool> = vec![false; 250];
    // for elem in p {
    //     are_included[elem + 125] = true;
    // }
    // let mut ans: i64 = 0;
    // for i in 0..250 {
    //     if are_included[i] {
    //         continue;
    //     }
    //     let i = i as i64 - 125;
    //     let x = x as i64;
    //     if (i - x as i64).abs() <= (x - ans).abs() && x < ans {
    //         ans = i;
    //     }
    // }
    //println!("{}", ans);
}


Measured memory_bytes: 2124
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	# = int(input())
	n, y = tin()
	#s = input()
	for ii in range(n+1):
		for ji in range(n+1-ii):
			ty = 10000 * ii + 5000 * ji + 1000*(n-ii-ji)
			if ty == y:
				print(*[ii, ji, n-ii-ji])
				return 
	else:
		print(*[-1, -1, -1])
		return 
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 9168
package main

import "fmt"

func main() {
	// Code for B - Choose Integers
	var A, B, C int
	fmt.Scanf("%d %d %d", &A, &B, &C)

	var flag int = 0
	for i := 1; i <= A*B; i++ {
		temp := (i * A) % B
		if temp == C {
			flag = 1
		}
	}
	if flag == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1832
import numpy as np
import math


x1, y1, x2, y2 = map(int, input().split())

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)

x4 = x3 - (y3 - y2)
y4 = y3 + (x3 - x2)

print(x3, y3, x4, y4)


Measured memory_bytes: 20768
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long int ll;
int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < A.size(); i++) {
    cin >> A[i];
  }
  sort(A.rbegin(), A.rend());
  ll a = 0;
  ll b = 0;
  for (int i = 0; i < A.size() - 1; i++) {
    if (A[i] == A[i + 1]) {
      if (a == 0) {
        a = A[i];
        i++;
        continue;
      } else if (b == 0) {
        b = A[i];
        break;
      }
    }
  }
  cout << a * b << endl;

  return 0;
}


Measured memory_bytes: 1024
n,k=map(int,input().split())
d=[0]*(10**5+1)
for i in range(n):
  a,b=map(int,input().split())
  d[a]+=b
for i in range(10**5+1):
  if d[i]>=k:
    print(i)
    break
  else:k-=d[i]


Measured memory_bytes: 46680
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int A,B;
  cin >> A >> B;
  cout << ((A+B)>=24?A+B-24:A+B) << endl;
  return 0;
}

Measured memory_bytes: 256
N,C = list(map(int,input().split()))
D = []

for i in range(C):
    D.append(list(map(int,input().split())))

c = []

for i in range(N):
    c.append(list(map(int,input().split())))

color_list = [[0 for i in range(C)] for j in range(3)]

for i in range(N):
    for j in range(N):
        color_list[(i+j)%3][c[i][j]-1]+=1
score_list = [[] for i in range(3)]
for i in range(3):
    for j in range(C):
        score=0
        for k in range(C):
            score+=D[k][j]*color_list[i][k]
        score_list[i].append([score,j])
        
for i in range(3):
    score_list[i]=sorted(score_list[i],key=lambda x: x[0])

min_score=10**28
for i in range(3):
    for j in range(3):
        for k in range(3):
          
            if score_list[0][i][1]!=score_list[1][j][1] and score_list[1][j][1]!=score_list[2][k][1] and score_list[2][k][1]!=score_list[0][i][1]:
                min_score=min(score_list[0][i][0]+score_list[1][j][0]+score_list[2][k][0],min_score)

print(min_score)

Measured memory_bytes: 5620
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 200010
#define LL long long
char s[MAXN];
int cnt[MAXN];
LL ans;
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=n;i;i--)
		if(s[i]=='C'&&s[i-1]=='B')
			cnt[i-1]=1+cnt[i+1];
		else if(s[i]=='A')
			ans+=cnt[i+1],cnt[i]=cnt[i+1];
	printf("%lld\n",ans);
}

Measured memory_bytes: 1152
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [9999999999]*n
dp[0] = 0
for i in range(1,n):
    for j in range(1,k+1):
        if(i >= j):
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[-1])


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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

class Stack{
private:
int m[1000];
int tp;
public:
    Stack(){
    tp=0;
    }
    void push(int x){
        tp++;
        m[tp]=x;
    }
    int pop(){
        tp--;
        return m[tp+1];
    }
}; 
class Queue{
private:
pair<string,int> m[60000];
int head,tail;
public:
    Queue(){
        head=0;
        tail=0;
    }
    bool isEmpty(){
        return head==tail;
    }
    void enqueue(pair<string,int> x){
        m[tail]=x;
        if(tail +1 ==60000)tail=0;
        else tail++;
    }
    pair<string,int> deque(){
        pair<string,int> x=m[head];
        if(head+1==60000)head=0;
        else head++;
        return x;
    } 
};
int linersearch(ll key,ll *A,int n){
int j=0;
int a=0;
int b=1;
A[n]=key;
while(A[j]!=key){
j++;
if (j==n)return a;
}
return b;
}

int main(){
int n;
int count=0;
cin>>n;
ll A[n+1];
REP(i,n)cin>>A[i];
int q;
cin>>q;
ll B[q];
REP(i,q)cin>>B[i];
REP(i,q){
    count+=linersearch(B[i],A,n);
}
cout<<count<<endl;
}


Measured memory_bytes: 3156
# -*- coding: utf-8 -*-
N,x = input().split()
N = int(N)
x = int(x)

a = map(int, input().split())

a = sorted(a)

xnum = 0
total = 0
for ax in a:
    total = total + ax
    if (total <= x):
        xnum = xnum + 1

if (total < x):
    xnum = xnum - 1
print(xnum)


Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))
count = 0
for i in range(N):
    if A[i] < 0:
        count += 1
    A[i] = abs(A[i])

ans = sum(A)
if count % 2 == 0:
    print(ans)
else:
    print(ans - 2*min(A))

Measured memory_bytes: 14332
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main(){
  int n,k,q;
  cin >> n >> k>> q;
  vector<int> a(n,k);
  
  
  rep(i,q){
    int wi=0;
    cin >> wi;
    a[wi-1]++;
  }
  rep(i,n){
    if(a[i] - q > 0) cout <<"Yes" <<endl;
    else cout << "No" << endl;
  }
}



Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	int x=0;
	x=N*800;
	int y;
	y=200;
 if(N>=15){
	y=y*(N/15);
	cout<<x-y;
		}
	else if(N<15){
	cout<<x;	}
	return 0;
}

Measured memory_bytes: 256
#define CIN(a,b) cin >> a >> b
#define rep(i, n) for (int i = 0; i < n; i++)

#include <iostream>
using namespace std;

int main(){
    int a,b;
    CIN(a,b);
    if((a + b) % 2 == 0){
        cout << (a + b) / 2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N,T;
    cin>>N >> T;
    vl Time(N);
    REP(i, 0, N){
        cin >> Time[i];
    }
    long sum = 0;
    REP(i, 0, N-1){
        if(Time[i+1] - Time[i] < T) sum += Time[i+1] - Time[i];
        else sum += T;
    }
    sum += T;
    cout << sum << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <algorithm>   //sort,二分探索,など
#include <bitset>      //固定長bit集合
#include <chrono>      //実行時間計測
#include <cmath>       //pow,logなど
#include <complex>     //複素数
#include <deque>       //両端アクセスのキュー
#include <functional>  //sortのgreater
#include <iomanip>     //setprecision(浮動小数点の出力の誤差)
#include <iostream>    //入出力
#include <iterator>    //集合演算(積集合,和集合,差集合など)
#include <map>         //map(辞書)
#include <numeric>     //iota(整数列の生成),gcdとlcm,accumulate
#include <queue>       //キュー
#include <set>         //集合（順序保持）
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility> //pair
#include <vector>  //可変長配列
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, n) for (int i = 0; i < ll(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < ll(b); i++)
#define FORD(i, a, b) for (int i = a; i > ll(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size()) // sizeをsize_tからllに直しておく
const long long INF = 1e12;
const int MOD = 1e9 + 7;
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define Umap unordered_map
#define Uset unordered_set
#define int long long
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed#c%E3%81%A7%E3%81%AE%E5%AE%9F%E8%A3%85
void print() { cout << endl; }

template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T> void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}

template <class T> void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

signed main() {

    int a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    long double dis = abs(b - a);
    long double speed = abs(v - w);
    if (v <= w) {
        print("NO");
    } else if (dis / speed <= t) {
        print("YES");
    } else {
        print("NO");
    }
}


Measured memory_bytes: 3612
#include<stdio.h>

/* 線形探索 */
int search(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main(){
    int i, n, A[10000 + 1], q, key, sum = 0;

    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &A[i]);

    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d", &key);
        if(search(A, n, key)) sum++;
    }
    printf("%d\n", sum);

    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long ll;
typedef struct data {
    ll x,y;
    bool operator<(const data& a) const
    {
        return x < a.x;
    }
} stu;



ll n,m,k,w;
int a[101];
int b[101];
ll dp[101][100002];

void solve(){
     ll x = 0;
     for (int i = 0; i < 101; ++i)
     {
        for (int j = 0; j < 100002; ++j)
        {
        dp[i][j]=x;
        }
     }

    cin >> n >> w  ;
    b[0]=0;
    a[0]=0;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i] >> b[i];
    }

    for (int i = 1; i <= n; ++i)
    {
        for(int j = 0 ; j <= w ; j++){
            if(a[i]<=j){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i]]+b[i]);
            }else{
            dp[i][j]=dp[i-1][j];   
            }
        }
    }
    ll ma=0;
    for (int i = 0; i <= w; ++i)
    {
        ma=max(ma,dp[n][i]);
    }
    cout << ma ;


}




int main() {

    

        //clock_t startTime = clock();

    solve();
    //cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<<  endl;    
    return 0;
}

Measured memory_bytes: 79232
n,t = map(int,input().split())
x = list(map(int,input().split()))
m = 0

for i in range(1,n):
    if x[i] - t <= x[i - 1]:
        m += x[i] - x[i - 1]
    else:
        m += t
    

print(m + t)

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

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

ll get_rem(ll x, ll base){
    ll x_original = x;
    ll count = 0;
    while (x >= base){
        count++;
        x /= base;
    }
    ll div{1};
    for (auto &&i: irange(0LL, count)){
        div *= base;
    }
    return x_original - div;
}

int main() {
    ll N;
    cin >> N;
//    DPを行う
//    状態遷移は，6の最大乗を下ろす，9の最大乗を下ろすのどちらか
    array<ll, 100001> dp;
    for (auto &&i: irange(0LL, 6LL)){
        dp.at(i) = i;
    }
    dp.at(6) = 1;
    dp.at(7) = 2;
    dp.at(8) = 3;
    for (auto &&i: irange(9LL, 100001LL)){
//        cout << "i: " << i << " get_rem(i, 6): " << get_rem(i, 6LL) << " dp[get_rem(i, 6)]: " << dp.at(get_rem(i, 6LL)) << " get_rem(i, 9): " << get_rem(i, 9LL) << " dp[get_rem(i, 6)]: " << dp.at(get_rem(i, 9LL)) << endl;
        dp.at(i) = min(dp.at(get_rem(i, 6LL))+ 1, dp.at(get_rem(i, 9LL)) + 1);
    }
    cout << dp.at(N);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
long a,b,c,n;
main()
{
	cin>>n;
	for(a=1;a<=3500;a++)for(b=a;b<=3500;b++)
	{
		long u=n*a*b,p=4*a*b-n*a-n*b;
		if(p>0&&u%p==0)
		{
			cout<<a<<" "<<b<<" "<<u/p<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define fi first
#define se second
using namespace std;

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

priority_queue<pll> pq;
vector<pll> vec;
vector<ll> dt;
vector<ll> za(1);

bool d[100005];


int main ()
{
    ll ans = 0;
    ll n, k;
    pll a;

    cin >> n >> k;
    for (ll i = 0; i < n; i++) {
        cin >> a.se >> a.fi;

        vec.push_back(a);
    }

    sort(vec.begin(), vec.end(), greater<pll>());

    for (ll i = 0; i < vec.size(); i++) {
        a = vec[i];

        if (!d[a.se]) {
            d[a.se] = true;

            dt.push_back(a.fi);
        } else {
            za.push_back(a.fi);
        }
    }
    
    for (ll i = 1; i < dt.size(); i++) {
        dt[i] += dt[i - 1];
    }
    
    for (ll i = 2; i < za.size(); i++ ) {
        za[i] += za[i - 1];
    }
    za.resize(k, 0);
    
    for (ll i = 0; i < k && i < dt.size(); i++) {
        ans = max(ans,
                  dt[i] + za[(k - (i + 1))]
                  + (i + 1) * (i + 1));
    }

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


Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
 
const int INF = 1145141919;
const long long INFL = 1LL<<60;
 
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
 
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
 
int main()
{
	int N, W;
	cin >> N >> W;
	int w[110], v[110];
	long long int dp[110000] = {};
	for (int i = 0; i < N; ++i)
	{
		cin >> w[i] >> v[i];
	}
	for (int i = 0; i < N; ++i)
	{
		for (int j = W; j >= 0; --j)
		{
			if((dp[j] != 0 || j == 0) && j + w[i] <= W)
			{
				chmax(dp[j+w[i]], dp[j] + v[i]);
			}
		}
	}
	long long int ans = 0;
	for (int i = 0; i <= W; ++i)
	{
		chmax(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

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

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

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

struct EdgeEx{
  int to, cap, rev;
  EdgeEx(int to_=0, int cap_ = 0, int rev_ = 0)
	:to(to_), cap(cap_), rev(rev_){}
};


// Ford-Fulkerson
// O(FE) where F := max flow of graph
vector< vector<EdgeEx> > G; // (V, E)
vector<bool> used; // sizeof V

// add edge with (from -> to, capacity)
void add_edge(int from, int to, int cap){
  G[from].push_back(EdgeEx(to, cap, G[to].size()));
  G[to].push_back(EdgeEx(from, 0, G[from].size()-1));
}

// find increase path
int max_flow_dfs(int v, int t, int f){
  if(v == t) return f;
  used[v] = true;
  for(int i=0;i<G[v].size();++i){
	EdgeEx& e = G[v][i];
	if(!used[e.to] && e.cap > 0){
	  int d = max_flow_dfs(e.to, t, min(f, e.cap));
	  if(d > 0){
		e.cap -= d;
		G[e.to][e.rev].cap += d;
		return d;
	  }
	}
  }
  return 0;
}

int max_flow(int s, int t){
  const int V = G.size();
  int flow = 0;
  used.assign(V, false);
  while(true){
	fill(used.begin(), used.end(), false);
	int f = max_flow_dfs(s, t, INF);
	if(f == 0) return flow;
	flow += f;
  }
}


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

  int N, M; cin >> N >> M;
  G.assign(N, vector<EdgeEx>());
  vector<PII> es(M);
  int tab[310][310];
  fill((int*)tab, (int*)tab+310*310, 0);
  REP(i,M){
	int a, b; cin >> a >> b;
	--a, --b;
	es[i].first = a, es[i].second = b;
	add_edge(a, b, 1);
	tab[a][b] = i+1;
	add_edge(b, a, 1);
	tab[b][a] = -i-1;
  }
  int S, T; cin >> S >> T;
  --S, --T;
  int ans = max_flow(S,T);
  VI xs;
  REP(i,N){
	REP(j, SZ(G[i])){
	  int to = G[i][j].to;
	  if(G[i][j].cap == 0 && tab[i][to] < 0)
		xs.PB(-tab[i][to]);
	}
  }

  SORT(xs);
  xs.erase(unique(ALL(xs)), xs.end());
  cout << ans << endl << SZ(xs) << endl;
  for(int x: xs) cout << x << endl;
  
  return 0;
}

Measured memory_bytes: 1728
# coding : UTF-8

from sys import stdin

n = stdin.readline().rstrip()

def main():
    ans = ""
    
    for _ in range(len(n)):
        if n[_] == '1':
            ans = ans + '9'
        else:
            ans = ans + '1'
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <iostream>
#include <queue>

#define INF -1

using namespace std;

int sx, sy, gx, gy;
vector<vector<int>> ans(21, vector<int>(21));
vector<vector<int>> ans2(21, vector<int>(21));
char maze[21][21];
int h, w;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
queue<pair<int, int>> q;

void bfs() {

    while (q.size()) {
        pair<int, int> p = q.front();
        q.pop();

        for (int i = 0; i < 4; i++) {
            int nx = p.second + dx[i];
            int ny = p.first + dy[i];


            if (nx >= 0 && nx < w && ny >= 0 && ny < h && maze[ny][nx] != '#' && ans[ny][nx] == INF) {
                q.push(make_pair(ny, nx));
                ans[ny][nx] = ans[p.first][p.second] + 1;
            }
        }
    }
}

int main()
{
    int prev = 0;

    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        cin >> maze[i];
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            ans2[i][j] = INF;
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (maze[i][j] == '#') continue;
            sx = j;
            sy = i;
            ans.swap(ans2);
            q.push(make_pair(sy, sx));
            ans[sy][sx] = 0;
            bfs();
            int far = 0;
            for (int a = 0; a < h; a++) {
                for (int b = 0; b < w; b++) {
                    ans2[a][b] = INF;
                    if (far < ans[a][b]) far = ans[a][b];
                }
            }
            if (prev < far) prev = far;
        }
    }

    cout << prev << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n, t, m, mt=0;
    scanf("%d %d", &n, &m);
    while(m--){
        scanf("%d", &t);
        mt += t;
    }
    if(mt>=n) printf("Yes\n");
    else printf("No\n");

    return 0;
}



Measured memory_bytes: 128