akhauriyash/Code-Regression huggingface dataset:
// ABC172-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る

vector<ll> ruia(200010,0);
vector<ll> ruib(200010,0);
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        ruia[i]=ruia[i-1]+a;
    }
    for(int i=1;i<=m;i++){
        int b;
        cin>>b;
        ruib[i]=ruib[i-1]+b;
    }
    int ans=0;
    int j=m;
    for(int i=0;i<=n;i++){
        ll time=ruia[i]+ruib[j];
        while(j>=0 && time>k){
            j--;
            time=ruia[i]+ruib[j];
        }
        if(time>k) break;
        //cout<<time<<" "<<i<<" "<<j<<endl;
        ans=max(ans,i+j);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6288
#include <iostream>
#include <map>
#include <string>

using namespace std;
using ll = long long;

void solve() {
    string s, result = "";
    cin >> s;
    auto n = s.length();
    result += s[0];
    result += to_string(n-2);
    result += s[n-1];
    cout << result << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
 
using namespace std;
 
struct Node {
    int key;
    Node *right, *left, *parent;
};
 
Node *root, *NIL;
 
Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}
 
void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
     
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
     
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
     
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}
 
void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
     
int main(void) {
    int n, i, x;
    string com;
    scanf("%d",&n);
     
    for(i=0;i<n;i++) {
        cin >> com;
        if(com[0] == 'f') {
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        } else if(com == "insert") {
            scanf("%d",&x);
            insert(x);
        } else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
 
    return 0;
}


Measured memory_bytes: 21928
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KyouProg
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int i;
            for (i = 0; i < S.Length; i++)
            {
                if (i % 2 == 0 && S.Substring(i, 1) == "L")
                {
                    Console.WriteLine("No");
                    break;
                }
                else if (i % 2 == 1 && S.Substring(i, 1) == "R")
                {
                    Console.WriteLine("No");
                    break;
                }
            }
            if (i == S.Length) Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define m 1000000007
using namespace std;
long long int helper(int s, vector<long long int>& dp)
{
    if(dp[s]!=-1)
        return dp[s];
    long long int res=0;
    for(int i=3;s-i>=0;i++)
    {
        res+=helper(s-i,dp);
        res%=m;
    }
    dp[s]=res;
    return res;
}
int main()
{
    int s;
    cin>>s;
    if(s<3)
        cout<<"0\n";
    else
    {
        vector<long long int> dp(s+1,-1);
        dp[0]=1;
        dp[1]=0;
        dp[2]=0;
        dp[3]=1;
        cout<<(helper(s,dp)+m)%m<<endl;
        //for(int i=0;i<=s;i++)
        //    cout<<i<<" "<<dp[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3652
a,b,m = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))


ans = min(A) + min(B)
for i in range(m):
    x,y,c = list(map(int,input().split()))
    ans = min(A[x-1]+B[y-1]-c,ans)

print(ans)

Measured memory_bytes: 18736
use std::fmt::Debug;
use std::str::FromStr;

fn read_line<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()
}

fn main() {
    let _: i64 = read_line()[0];
    let a: Vec<i64> = read_line();
    for a_n in &a {
        if *a_n == 0 {
            println!("0");
            return;
        }
    }
    let mut result: i64 = 1;
    for a_n in &a {
        if *a_n > 1_000_000_000_000_000_000i64 / result {
            println!("-1");
            return;
        }
        result *= a_n;
    }
    println!("{}", result);
}


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

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

  if((B - A) % 2){
    cout << min((A + B - 1) / 2, N - (A + B - 1) / 2) << endl;
  }else{
    cout << (B - A) / 2 << endl;
  }
}


Measured memory_bytes: 888
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()
p = set(list(map(int, input().split())))

for i in range(200):
    for sgn in [-1, 1]:
        cand = X + sgn * i
        if cand not in p:
            print(cand)
            exit()


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  vector<int>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};
  int K;
  cin>>K;
  cout<<a[K-1]<<endl;
  return 0;
}


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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int N, M;
vector<int> X;

signed main()
{

    cin >> N >> M;
    X.resize(M);

    rep(i, M)
    {
        cin >> X[i];
    }

    if (N >= M)
    {
        cout << "0" << endl;
        return 0;
    }

    sort(all(X));

    vector<int> Y(M - 1);
    int sum = 0;

    rep(i, M - 1)
    {
        Y[i] = X[i + 1] - X[i];
        sum += Y[i];
    }

    sort(all(Y), greater<>());

    rep(i, N - 1)
    {
        sum -= Y[i];
    }

    cout << sum << endl;

    return 0;
}


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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

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

struct UnionFind {
	vector< int > data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return (false);
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return (true);
	}

	int find(int k) {
		if (data[k] < 0) return (k);
		return (data[k] = find(data[k]));
	}

	int size(int k) {
		return (-data[find(k)]);
	}
};

signed main(){

	int N, M;
	cin >> N >> M;
	UnionFind u(N);

	vector<int> v[123456];
	for (int i = 0; i < N; i++){
		int K; cin >> K;
		for (int k = 0; k < K; k++){
			int l; cin >> l;
			v[l].push_back(i);
		}
	}
	for (int l = 0; l < 123456; l++){
		if (v[l].size() >= 2){
			for (int i = 1; i < v[l].size(); i++){
				u.unite(v[l][0], v[l][i]);
			}
		}
	}

	for (int i = 1; i < N; i++){
		if (u.unite(0, i)){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;



	return 0;
}

Measured memory_bytes: 5628
#Aiについて取りうる値の範囲を考える
#すべての組み合わせから、すべて奇数のものを除く

n = int(input())
a_inputs = list(map(int,input().split()))

all_pair = 1
odd_pair = 1

for i in range(n):
    if a_inputs[i]%2==0:
        odd_pair*=2
    else:
        odd_pair*=1
    all_pair*=3

print(all_pair-odd_pair)




Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  llong K;
  cin >> S;
  cin >> K;
  for(llong i=0;i<K;i++){
    if(S[i] != '1'){
      cout << S[i] << endl;
      return 0;
    }
  }
  cout << '1' << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>

using namespace std;

bool solve(int n, string *says)
{
    stack<string> c_stack;

    for (int i = 0; i < n; ++i) {
        if (says[i] == "A") {
            c_stack.push(says[i]);
        } else {
            if (c_stack.empty()) {
                return false;
            }
            c_stack.pop();
        }
    }

    return c_stack.empty();
}

int main()
{
    int n;
    string says[100];
    while(cin>>n) {
        for (int i = 0; i < n; ++i) {
            cin >> says[i];
        }
        if (solve(n, says)) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3168
import itertools
s = input()
n = len(s) - 1

ans = 0
op = [x for x in itertools.product(["+", ""], repeat=n)]
for i in range(2 ** n):
  f = s[0]
  for j, k in zip(op[i], s[1:]):
    f += (j+k)
  ans += eval(f)
print(ans)

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 105;

vector <int> adj[N], seq[N];
int n, dep[N], par[N];
LL ans, f[N], g[N];

inline void DFS(int x, int p) {
  par[x] = p, dep[x] = dep[p] + 1;
  for (auto y : adj[x]) {
    if (y != p) {
      DFS(y, x);
    }
  }
}

inline LL Solve(int x) {
  DFS(x, 0);
  int maxdep = 0;
  for (int i = 1; i <= n; ++i) {
    CheckMax(maxdep, dep[i]);
  }
  for (int i = 1; i <= maxdep; ++i) {
    seq[i].clear();
  }
  for (int i = 1; i <= n; ++i) {
    seq[dep[i]].pb(i);
  }
  LL ret = 1;
  for (int i = maxdep - 1; i; --i) {
    int maxson = 0;
    for (auto x : seq[i]) {
      int cnt = 0;
      for (auto y : adj[x]) {
        if (dep[y] == i + 1) {
          ++cnt;
        }
      }
      CheckMax(maxson, cnt);
    }
    ret *= maxson;
  }
  return ret;
}

inline LL Solve(int x, int y) {
  dep[y] = 0, DFS(x, y), dep[x] = 0, DFS(y, x), dep[x] = 1;
  int maxdep = 0;
  for (int i = 1; i <= n; ++i) {
    CheckMax(maxdep, dep[i]);
  }
  for (int i = 1; i <= maxdep; ++i) {
    seq[i].clear();
  }
  for (int i = 1; i <= n; ++i) {
    seq[dep[i]].pb(i);
  }
  LL ret = 1;
  for (int i = maxdep - 1; i; --i) {
    int maxson = 0;
    for (auto x : seq[i]) {
      int cnt = 0;
      for (auto y : adj[x]) {
        if (dep[y] == i + 1) {
          ++cnt;
        }
      }
      CheckMax(maxson, cnt);
    }
    ret *= maxson;
  }
  return ret << 1;
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n);
  for (int i = 1, x, y; i < n; ++i) {
    Read(x), Read(y);
    adj[x].pb(y), adj[y].pb(x);
  }
  DFS(1, 0);
  int s = 0;
  for (int i = 1; i <= n; ++i) {
    if (dep[i] > dep[s]) {
      s = i;
    }
  }
  DFS(s, 0);
  int t = 0;
  for (int i = 1; i <= n; ++i) {
    if (dep[i] > dep[t]) {
      t = i;
    }
  }
  if (!(dep[s] + dep[t] & 1)) {
    int mid = dep[s] + dep[t] >> 1, r;
    for (r = t; dep[r] != mid; r = par[r]);
    ans = Solve(r);
    for (auto x : adj[r]) {
      CheckMin(ans, Solve(r, x));
    }
    printf("%d %lld\n", mid, ans);
  } else {
    int mid1 = dep[s] + dep[t] >> 1, mid2 = dep[s] + dep[t] + 1 >> 1, r1, r2;
    for (r1 = t; dep[r1] != mid1; r1 = par[r1]);
    for (r2 = t; dep[r2] != mid2; r2 = par[r2]);
    printf("%d %lld\n", mid1, Solve(r1, r2));
  }
}

Measured memory_bytes: 256
n, m, x, y = map(int, input().split())
x_n = list(map(int, input().split()))
y_m = list(map(int, input().split()))
x_n.append(x)
y_m.append(y)
if min(y_m) - max(x_n) < 1:
    print("War")
    exit()
print("No War")

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];

    sort(A.begin(), A.end());
    sort(C.begin(), C.end());

    ll ans = 0;
    rep(i, N) {
        ll a = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        ll c = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        ans += a * c;
    }
    cout << ans << endl;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
typedef pair<li, li> PI;

li yon = 0;
li ni = 0;
li ichi = 0;

int main(void)
{
	li h, w;
	cin >> h >> w;
	li cnt[26] = {0};

	rep(i, h) {
		string s;
		cin >> s;
		for (auto c : s) {
			cnt[c - 'a']++;
		}
	}
	rep(i, 26) {
		//cout << cnt[i] << " ";
		yon += cnt[i] / 4;
		cnt[i] = cnt[i] % 4;


		ni += cnt[i] / 2;
		cnt[i] = cnt[i] % 2;

		ichi += cnt[i];
	}

	li need_ichi = 0;
	li need_ni = 0;
	if (h % 2 == 0) {
		if (w % 2 == 0) {
			need_ichi = 0;
			need_ni = 0;
		} else {
			need_ni = h;
		}
	} else {
		if (w % 2 == 0) {
			need_ni = w;
		} else {
			need_ichi = 1;
			need_ni = w + h - 1;
		}
	}
	//cout << need_ichi << ", " << need_ni << endl;
	//cout << ichi << ", " << ni << endl;
	if (ichi != need_ichi) {
		puts("No");
		return 0;
	}
	if (need_ni < ni * 2) {
		puts("No");
		return 0;
	}
	puts("Yes");


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <queue>
#include <functional>
#include <numeric>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ll ans = 0;
    ll N, M;
    cin >> N >> M;

    vector<ll > A(N, 0);

    vector<pair <ll, ll> > act;
    map<ll, ll> B;
    vector<ll > C;
    
    priority_queue<ll, vector<ll>, greater<ll > > que;

    for(ll i = 0; i < N; i++){
        cin >> A[i];
        que.push(A[i]);
        ans += A[i];
    }


    for(ll i = 0; i < M; i++){
        ll b, c;
        cin >> b >> c;
        /* 
        if(B.count(c) == 0){
            C.push_back(c);
        }
        B[c] += b;
        */
        act.push_back(make_pair(c, b));
    }
    //cout << B.size() << " " << C.size() << endl;
    //大きいものから優先して使っていく
    sort(act.rbegin(), act.rend());
    //sort(C.rbegin(), C.rend());

    for(ll i = 0; i < M; i++){
        ll count = 0;
        //cout << C[i] << endl;
        if(que.top() >= act[i].first){
            break;
        }
        for(ll j = 0; j < act[i].second; j++){
            
            if(que.top() >= act[i].first){
                break;
            }
            //cout << que.top() << endl;
            ans -= que.top();
            count++;
            que.pop();

        }
        for(ll j = 0; j < count; j++){
            ans += act[i].first;
            que.push(act[i].first);
        }         
    }

    cout << ans << endl;

}

Measured memory_bytes: 4980
x, k, d = map(int, input().split())
x = abs(x)
p = k * d
if x - p < 0:
    k -= x // d
    x -= (x // d) * d
    if k % 2 == 0:
        print(x)
    else:
        print(abs(x - d))
else:
    print(x - p)


Measured memory_bytes: 9100
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<ll>> dp(n + 1, vector<ll>(13));
  dp[0][0] = 1;
  rep(i, n){
    int a;
    if(s[i] == '?') a = -1;
    else a = s[i] - '0';
    if(a == -1){
      rep(j, 10){
        rep(k, 13){
          (dp[i + 1][(k * 10 + j) % 13] += dp[i][k]) %= mod;
        }
      }
    }else{
      rep(k, 13){
        (dp[i + 1][(k * 10 + a) % 13] += dp[i][k]) %= mod;
      }
    }
  }
  cout << dp[n][5] << endl;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll INF=1e18L+5;

void solve(){
    int n,W;
    cin>>n>>W;
    vector<ll>weight(n),value(n);
    for(int i=0;i<n;i++){
        cin>>weight[i]>>value[i];
    }
    int sum_value=0;
    for(int x:value){
        sum_value+=x;
    }
    vector<ll>dp(sum_value+1,INF);
    dp[0]=0;
    for(int item=0;item<n;item++){
        for(int value_already=sum_value-value[item];value_already>=0;value_already--){
            dp[value_already+value[item]]=min(dp[value_already+value[item]],dp[value_already]+weight[item]);
        }
    }
    ll answer=0;
    for(int i=0;i<=sum_value;i++){
        if(dp[i]<=W)
            answer=max(answer,(ll)i);
    }
    cout<<answer<<endl;
}

int main(){
    // int t;
    // cin>>t;
    // while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String ans[] = {"AC", "WA", "TLE", "RE"};
		int num[] = new int[4];
		for(int i = 0; i < n; ++i){
			String s = sc.next();
			for(int j = 0; j < 4; ++j){
				if(s.equals(ans[j])){
					num[j]++;
					break;
				}
			}
		}
		sc.close();
		for(int i = 0; i < 4; ++i){
			System.out.println(ans[i] + " " + "x " + num[i]);
		}
	}
}


Measured memory_bytes: 58912
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

vector<pll> part(ll N)
{
  vector<pll> res;
  ll temp = N;
  for (ll i = 2; i * i <= temp; ++i) {
    if (N % i == 0) {
      ll cnt = 0;
      while (N % i == 0) {
        N /= i;
        cnt += 1;
      }
      res.push_back({i, cnt});
    }
  }
  if (N != 1) {
    res.push_back({N, 1});
  }
  return res;
}

ll num_part(ll N)
{
  ll res = -1;
  for (ll i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res += 2;
    }
    if (i * i == N) {
      res -= 1;
    }
  }
  return res;
}

int main()
{
  ll N;
  cin >> N;
  ll ans = num_part(N - 1) + 1;
  // cout << ans << endl;
  for (ll i = 2; i * i <= N; ++i) {
    if (N % i != 0) {
      continue;
    }
    ll temp = N;
    while (temp % i == 0) {
      temp /= i;
    }
    if (temp % i == 1) {
      ans += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  random_device rnd;
  mt19937 mt(rnd());
  int D;
  cin >> D;
  vector<int> c(26);
  for (int i = 0; i < 26; i++){
    cin >> c[i];
  }
  vector<vector<int>> s(D, vector<int>(26));
  for (int i = 0; i < D; i++){
    for (int j = 0; j < 26; j++){
      cin >> s[i][j];
    }
  }
  vector<int> last(26, -1);
  for (int i = 0; i < D; i++){
    int t = min(10, D - i);
    vector<vector<int>> L(t, vector<int>(26, 0));
    for (int j = 0; j < t; j++){
      for (int k = 0; k < 26; k++){
        L[j][k] = c[k] * (i + j - last[k]);
      }
    }
    int mx = 0;
    int a = 0;
    vector<int> best(t);
    for (int j = 0; j < 10000; j++){
      vector<int> next(t, 0);
      if (j < 1000){
        for (int k = 0; k < t; k++){
          next[k] = mt() % 26;
        }
      } else if (j < 6000){
        next = best;
        for (int k = 0; k < 3; k++){
          int pos = mt() % t;
          int upd = mt() % 26;
          next[pos] = upd;
        }
      } else {
        next = best;
        for (int k = 0; k < 2; k++){
          int pos = mt() % t;
          int upd = mt() % 26;
          next[pos] = upd;
        }
      }
      //calculate diff
      int diff = 0;
      for (int k = 0; k < t; k++){
        diff += s[i + k][next[k]];
        for (int l = k; l < t; l++){
          diff += L[l][next[k]] - (l - k) * c[next[k]];
          L[l][next[k]] = (l - k) * c[next[k]];
        }
      }
      if (diff > mx){
        mx = diff;
        best = next;
        /*
        cout << "best: " << endl;
        for (int k = 0; k < t; k++){
          cout << best[k] << ' ';
        }
        cout << endl;
        cout << "mx = " << mx << endl;
        */
      }
    }
    cout << best[0] + 1 << endl;
    last[best[0]] = i;
  }
}

Measured memory_bytes: 3692
#include<stdio.h>
int main(void){
  struct as{
    int n;
    char C;
  }A[36],B[36],t;

  int i,j,len,mini;
  char c;
  scanf("%d",&len);
  for(i=0;i<len;i++){
    scanf("%c%c%d",&c,&A[i].C,&A[i].n);
  }
  for(i=0;i<len;i++){
    B[i]=A[i];
  }
  for(i=0;i<len;i++){
    for(j=len-1;j>i;j--){
      if(A[j].n<A[j-1].n){
	t=A[j];
	A[j]=A[j-1];
	A[j-1]=t;
      }
    }
  }
  for(i=0;i<len;i++){
    if(i!=0){
      printf(" ");
    }
    printf("%c%d",A[i].C,A[i].n);
  }
  printf("\n");
  printf("Stable\n"); 
  for(i=0;i<len;i++){
    mini=i;
     for(j=i;j<len;j++){
       if(B[j].n<B[mini].n){
	 mini=j;
       }
     }
     if(i!=mini){
       t.n=B[i].n;
       B[i].n=B[mini].n;
       B[mini].n=t.n;
       t.C=B[i].C;
       B[i].C=B[mini].C;
       B[mini].C=t.C;

     }
  }
  for(i=0;i<len;i++){
    if(i!=0){
      printf(" ");
    }
    printf("%c%d",B[i].C,B[i].n);
  }
  printf("\n");
  
   
  for(i=0;i<len;i++){
    if(B[i].C!=A[i].C){
	printf("Not stable\n");
	break;
      }
  } 
    if(i==len)printf("Stable\n");
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

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

	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


S, T = input().split()
A, B = read_ints()
U = input()

if U == S:
    print(A - 1, B)
else:
    print(A, B - 1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[maxn];
typedef long long ll;
void init(){
	scanf("%d",&n);
	a[0]=-1;//用来判第一个是否合法 
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=0;i<n;i++){
		if(a[i]<a[i+1]-1){
			printf("-1");return;
		}
	}
	
	ll ans=0;
	for(int i=n;i>=1;i--){
		if(a[i]!=a[i+1]-1) ans+=a[i];
	}
	printf("%lld",ans);
}
int main(){
	init();
	
	return 0;
}

Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		Map<String, Integer> dic = new HashMap<>();
		int count = stdIn.nextInt();
		
		for(int i = 0; i < count; i++){
			int command = stdIn.nextInt();
			switch(command){
				case 0:
					dic.put(stdIn.next(), stdIn.nextInt());
					break;
					
				case 1:
					System.out.println(dic.get(stdIn.next())); 
			}
	
			
		}
		stdIn.close();
	}

}



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

signed main() {
  int A, B;
  cin >> A >> B;
  
  for( int i = 1; i <= 3; i++ ){
    if( i != A && i != B ){
      cout << i << endl;
    }
  }
 
}


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

int main() {
  ll N, T; cin>>N>>T;
  ll sum=0;
  vector<ll> t(N);
  for(ll i=0; i<N; i++){
    ll x; cin>>x;
    t[i]=x;
  }
  for(ll i=0; i<N-1; i++){
    if(t[i+1]-t[i]<T) sum+=t[i+1]-t[i];
    else sum+=T;
  }
  cout<<sum+T<<endl;
}


Measured memory_bytes: 1792
import math
import itertools
import statistics
#n = int(input())
#n, d = list(input().split())
s = input()
m = 1000
for i in range(len(s)-2):
    a = int(s[i])
    b = int(s[i+1])
    c = int(s[i+2])
    if abs(753-(a*100+b*10+c)) < m:
        m = abs(753-(a*100+b*10+c))

print(m)
    

Measured memory_bytes: 5148
// https://atcoder.jp/contests/abc166/tasks/abc166_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N, M;
  cin >> N >> M;

  VL hs(N);
  rep(i, N) cin >> hs[i];

  VVL edge_list(N, VL(0));

  rep(i, M) {
    ll a, b;
    cin >> a >> b;
    --a, --b;

    edge_list[a].push_back(b);
    edge_list[b].push_back(a);
  }

  ll res = 0;

  rep(u, N) {
    bool ok = all_of(all(edge_list[u]), [&](ll v) { return hs[u] > hs[v]; });
    if (ok) res++;
  }

  cout << res << "\n";
}


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

using namespace std;
using ll = long long int;

const ll MOD = 1e9 + 7;

ll pow_fast(ll n, ll k) {
  if (k == 0) {
    return 1LL;
  }
  if (k == 1) {
    return n;
  }

  if (k % 2 == 0) {
    ll tmp = pow_fast(n, k / 2);
    return tmp * tmp % MOD;
  } else {
    ll tmp = pow_fast(n, (k - 1) / 2);
    tmp *= tmp;
    tmp %= MOD;
    return tmp * n % MOD;
  }
}

template <typename T>
class stack {
 private:
  vector<T> _vec;

 public:
  stack(){};

  void push(T n) {
    _vec.push_back(n);
    return;
  }

  void pop() {
    if (this->empty()) {
      return;
    }
    _vec.erase(_vec.end() - 1);
    _vec.shrink_to_fit();
    return;
  }

  size_t size() { return _vec.size(); }

  T top() { return _vec[this->size() - 1]; }
  bool empty() { return _vec.empty(); }
};

int main() {
  ll N;
  cin >> N;
  vector<ll> T(N);
  ll sum = 0;
  for (ll i = 0; i < N; i++)
  {
    cin >> T[i];
    sum += T[i];
  }
  
  ll M;
  cin >> M;
  vector<pair<ll, ll>> drink(M);
  for (ll i = 0; i < M; i++)
  {
    ll p, x;
    cin >> p >> x;
    drink[i] = {p, x};
  }
  
  for (ll i = 0; i < M; i++)
  {
    cout << (sum + drink[i].second - T[drink[i].first - 1]) << endl;
  }
  
}

Measured memory_bytes: 3604
object Main extends App {
	val N = scala.io.StdIn.readInt
	val x = scala.io.StdIn.readLine

	var a: Array[Int] = new Array(N)

	for(i <- 0 until N){
		a(i) = x.split(" ")(i).toInt
	}


	for(i<- 0 until N){
		for(j <- N-1 until i by -1){
			if(a(j-1) > a(j)){
				val t = a(j-1)
				a(j-1) = a(j)
				a(j) = t
			}

		}
	}

	val sum = a(N-1) - a(0)

	println(sum)


}

Measured memory_bytes: 27328
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>

using namespace std;
//#define int long
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main() 
{
	int N;
	cin >> N;
	vector<int>v(N);
	for (int i = 0; i < N; i++)cin >> v[i];
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		if (v[i] == cnt + 1)cnt++;
	}
	if (cnt == 0)cout << "-1";
	else cout << N - cnt;
}

Measured memory_bytes: 1024
//#undef DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll llinf = (1ll<<61)-1;
const char lf = '\n', splf[] = " \n";
#define sz(a) int(a.size())
#define all(x) begin(x), end(x)
#define TCC template<class C
#define OSO ostream &operator<<(ostream &os, const
#ifdef DEBUG
const int DEBUG_END = 26;
#define DOS cout
#include <debug.h>
#else
#define bug(args...) void()
#define cbug(a, args...)
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define fi first
#define se second
const int inf = 1000000007;
int TC=1, CN;

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    //cin >> TC;// inputAll + resetAll -> solution
    auto kase = [&]()->void {
        int K;
        cin>>K;
        for(int i=0;i<K;++i)cout<<"ACL";
        cout<<lf;
    };
    while (CN++!=TC) kase();
}


Measured memory_bytes: 3636
#include <cstdio>
#define MAXN 100007
#include <cstring>

char mayRed[MAXN];
int numOfBall[MAXN];

int main(void)
{
    mayRed[1]=1;
    int i,N,M;
    int x,y;
    scanf("%d%d",&N,&M);
    for(i=1;i<=N;i++)
    {
        numOfBall[i]=1;
        mayRed[i]=0;
    }
    mayRed[1]=1;

    for(i = 0;i<M;i++)
    {
        scanf("%d%d",&x,&y);
        if(mayRed[x])
        {
            mayRed[y]=1;
        }
        numOfBall[y]+=1;
        numOfBall[x]-=1;
        if(numOfBall[x]==0)
        {
            mayRed[x]=0;
        }
    }
    int r = 0;
    for(i=1;i<=N;i++)
    {
        r+=mayRed[i];
    }
    printf("%d\n",r);

    return 0;
}


Measured memory_bytes: 640
using System;

class Program
{
    static void Main(string[] args)
    {
        var nx = Console.ReadLine().Split();
        var n = int.Parse(nx[0]);
        var x = int.Parse(nx[1]);
        var L = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        var sum = 0;
        var ans = 1;
        for (int i = 0; i < n; i++)
        {
            sum += L[i];
            if (sum <= x)
            {
                ans++;
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  ll N; cin >> N;
  ll T[N], A[N]; rep(i, N) cin >> T[i] >> A[i];

  ll nt = 1, na = 1; 
  rep(i, N) {
    ll p = max((nt+T[i]-1)/T[i], (na+A[i]-1)/A[i]);
    nt = T[i]*p; na = A[i]*p;
    // cout << nt << " " << na << endl;
  }

  ll result = nt + na;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

vector<int> G[MAX_N];
int d[MAX_N];
int color[MAX_N];

struct data
{
    int v,d,c;
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        G[a-1].pb(b-1),G[b-1].pb(a-1);
    }
    rep(i,n){
        d[i] = -1;
    }
    int q;
    cin >> q;
    vector<data> vec(q);
    rep(i,q){
        int a,b,c;
        cin >> a >> b >> c;
        --a;
        vec[i] = (data){a,b,c};
    }
    rrep(i,q){
        queue<P> que;
        int u = vec[i].v;
        if(d[u] < 0){
            d[u] = vec[i].d;
            color[u] = vec[i].c;
        }else if(d[u] < vec[i].d){
            d[u] = vec[i].d;
        }else{
            continue;
        }
        que.push(P(u,vec[i].c));
        while(!que.empty()){
            P p = que.front();
            que.pop();
            if(d[p.fi] == 0) continue;
            each(v,G[p.fi]){
                if(d[v] < 0){
                    color[v] = p.se;
                    d[v] = d[p.fi]-1;
                }else if(d[v] < d[p.fi]-1){
                    d[v] = d[p.fi]-1;
                }else{
                    continue;
                }
                que.push(P(v,p.se));
            }
        }
    }
    rep(i,n){
        cout << color[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 8952
# Aizu Problem 00119: Taro's Obsession
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

class DirectedGraph():
    def __init__(self):
        self.edges = {}

    def AddNode(self, node):
        if node not in self.edges:
            self.edges[node] = []

    def GetNodes(self):
        return list(self.edges.keys())

    def GetEdges(self):
        return self.edges

    def AddEdge(self, node1, node2):
        if node1 not in self.GetNodes():
            self.AddNode(node1)
        if node2 not in self.edges[node1]:
            self.edges[node1].append(node2)

    def RemoveEdge(self, node1, node2):
        if node1 not in self.edges or node2 not in self.edges[node1]:
            print("ERROR: can't remove edge", node1, "->", node2)
            print(self.edges)
            return
        self.edges[node1].remove(node2)

    def OutDegree(self, node):
        return len(self.edges[node])

    def InDegree(self, node):
        deg = 0
        for node2 in self.GetNodes():
            if node in self.GetNeighbors(node2):
                deg += 1
        return deg

    def GetNeighbors(self, node):
        return self.edges.get(node, [])
            
    def GetPath(self, source, target):
        # find path by BFS:
        predecessor = {node: -1 for node in self.GetNodes()}
        predecessor[source] = 0
        visited = {node: False for node in self.GetNodes()}
        queue = [source]
        while len(queue) > 0:
            current = queue.pop(0)
            visited[current] = True
            for neighbor in self.GetNeighbors(current):
                if not visited[neighbor] and neighbor not in queue:
                    queue.append(neighbor)
                    predecessor[neighbor] = current
                if neighbor == target:
                    queue = []
                    break
        # build path from predecessor info:
        if predecessor[target] == -1:
            return []
        path = [target]
        while path[0] != source:
            path = [predecessor[path[0]]] + path[:]
        return path

    def TopologicalSort(self):
        # determine topological sorting of graph by Kahn's algorithm;
        # edges are removed by this algorithm
        L = []
        S = [node for node in self.GetNodes() if self.InDegree(node) == 0]
        while len(S) > 0:
            n = S.pop(0)
            L.append(n)
            for m in self.GetNeighbors(n)[:]:
                self.RemoveEdge(n, m)
                if self.InDegree(m) == 0:
                    S.append(m)
        for node in self.GetNodes():
            if self.edges[node] != []:
                print("ERROR: graph has cycle!", self.edges)
                return
        return L


m = int(input())
n = int(input())
G = DirectedGraph()
for __ in range(n):
    a, b = [int(_) for _ in input().split()]
    G.AddEdge(a, b)
tsort = G.TopologicalSort()
for k in tsort:
    print(k)

Measured memory_bytes: 8016
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n;
    cin >> n;
    vll a(n);
    forn(i, n) cin >> a[i];
    vll dp(n);
    dp[0] = 1000;
    forn1(i, n){
        forn(j, i){
            ll minn = 300;
            for2(z, j, i) minn = min(minn, a[z]);
            if (minn < 300){
                ll num = dp[j] / minn, r = dp[j] - num * minn;
                dp[i] = max(dp[i], r + num * a[i]);
            }
        }
    }
    cout << *max_element(all(dp)) << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3648
n,a,b = map(int,input().split())
c,cb = 0,0
for i in input():
  if i == 'a':
    if c < a+b:
      print('Yes')
      c += 1
    else:
      print('No')
  elif i == 'b':
    if c < a+b and cb < b:
      print('Yes')
      c += 1
      cb += 1
    else:
      print('No')
  else:
    print('No')

Measured memory_bytes: 53080
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> p;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    std::vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }

    int index = 0;
    for (int i = 0; i < h; i++) {
        std::vector<int> out;
        for (int j = 0; j < w; j++) {
            out.pb(index + 1);
            a[index]--;
            if (a[index] == 0) {
                index++;
            }
        }
        if (i % 2 == 0) {
            for (int k = 0; k < w; k++) {
                cout << out[k] << " ";
            }
            cout << endl;
        } else {
            for (int k = w - 1; k >= 0; k--) {
                cout << out[k] << " ";
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

struct coin {
    ll A, B, C, idx;
    coin(ll A, ll B, ll C, ll idx) : A(A), B(B), C(C) , idx(idx) {}
};

const long long INF = 1e18;
//const ll mod = 1000000007;

bool IsC[301000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    vector<coin> coins;
    for(int i = 0; i < X + Y + Z; i++) {
        ll A, B, C;
        cin >> A >> B >> C;
        coins.emplace_back(A, B, C, i);
    }
    sort(coins.begin(), coins.end(), [](coin a, coin b) {
        return a.A - a.C > b.A - b.C;
    });
    for(int i = 0; i < coins.size(); i++) {
        //cerr << coins[i].A << " " << coins[i].B << " " << coins[i].C << endl;
        coins[i].idx = i;
    }
    ll tmp = 0;
    priority_queue<ll> Left;
    for(int i = 0; i < X; i++) {
        tmp += coins[i].A;
        Left.push(coins[i].B - coins[i].A);
    }
    priority_queue<l_l> Right;
    for(int i = X; i < X + Y + Z; i++) {
        tmp += coins[i].B;
        Right.push({coins[i].C - coins[i].B, i});
    }
    for(int i = 0; i < Z; i++) {
        auto now = Right.top();
        Right.pop();
        IsC[now.second] = true;
        tmp += now.first;
    }
    ll ans = tmp;
    //cerr << X - 1 << " " << tmp << endl;
    for(int i = X; i < X + Y; i++) {
        if(IsC[i]) {
            tmp -= coins[i].C;
            while(true) {
                auto now = Right.top();
                Right.pop();
                if(now.second <= i) continue;
                //cerr << "B to C: " << now.second << endl;
                tmp += now.first;
                IsC[now.second] = true;
                break;
            }
        } else {
            tmp -= coins[i].B;
        }
        tmp += coins[i].A;
        Left.push(coins[i].B - coins[i].A);
        auto now = Left.top();
        Left.pop();
        tmp += now;
        chmax(ans, tmp);
        //cerr << i << " " << tmp << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7660