akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 #define PI acos(-1)
 #define MOD ((int)1e9+7)
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
 
 

 
const int N=2e5+100;
ll visited[100005];
//ll a[200000];
 

#define lop(i,n) for(int i=0;i<n;++i)
//ll n,m,mod;

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

const int MAX = 200000 ;
void finis(){cout<<-1;}


ll h,w,n,m,k,l;
ll siz[MAX];

ll siz1[MAX];

ll par[MAX];
ll par1[MAX];
int find(int x){
    while(x!=par[x]){
        x=par[x];
        
    }return x;
}
void unit(int a,int b){
    ll x=find(a);
    ll y=find(b);
    if(x==y){
        return;
    }else{
        if(siz[x]<siz[y]){swap(x,y);}
        siz[x]+=siz[y];
        par[y]=x;
    }
}int find1(int x){
    while(x!=par1[x]){
        x=par1[x];
        
    }return x;
}
void unit1(int a,int b){
    ll x=find1(a);
    ll y=find1(b);
    if(x==y){
        return;
    }else{
        if(siz1[x]<siz1[y]){swap(x,y);}
        siz1[x]+=siz1[y];
        par1[y]=x;
    }
}
int main()
{  ios::sync_with_stdio(0);
cin.tie(0);

cin>>n>>k>>l;ll x,y;
//idea is to use 2 dsu
for(int i=1;i<=n;i++){
    siz[i]=1;siz1[i]=1;
    par[i]=i;
    par1[i]=i;
}
for(int i=0;i<k;i++){
   cin>>x>>y;
   unit(x,y);
}
vector<pair<ll,ll>>v;

for(int i=0;i<l;i++){
    cin>>x>>y;
    unit1(x,y);
   
} //v.push_back({par[i],par1[i]});
map<pair<int,int>,int>mp;
for(int i=1;i<=n;i++){
    v.push_back({par[i],par1[i]});
    mp[{find(i),find1(i)}]++;
}


for(int i=1;i<=n;i++){
   
    cout<<mp[{find(i),find1(i)}]<<" ";
   
}


    
}


Measured memory_bytes: 23344
n,k = map(int,input().strip().split(" "))
arr = list(map(int,input().strip().split(" ")))

dp = [0]*n
dp[0] = 0
for i in range(1,min(n,k)):
    mn = 1000000000
    for j in range(i-1,-1,-1):
        p = abs(arr[i]-arr[j])
        mn = min(mn,p+dp[j])
    dp[i] = mn

for i in range(min(n,k),n):
    mn = 1000000000
    for j in range(i-k,i,1):
        p = abs(arr[i]-arr[j])
        mn = min(mn,p+dp[j])
    dp[i] = mn
print(dp[n-1])

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

int cost(char a,char b){
	if( a <= b ){
		return b - a;
	}else{
		return 26 - (a - b);
	}
}
void solve(string s, long long K){
	for(int i = 0 ; i < s.size() ; i++){
		for(int j = 'a' ; j <= 'z' ; j++){
			if( cost(s[i],j) <= K ){
				K -= cost(s[i],j);
				s[i] = j;
				break;
			}
		}
	}
	s.back() = 'a' + (s.back()-'a'+K)%26;
	cout << s << endl;
	
}



int main(){	
	ios::sync_with_stdio(false);
	string s;
	long long K;
	cin >> s;
	cin >> K;
	solve(s, K);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
 
#define  pb     push_back
#define  all(x) (x).begin(), (x).end()
#define  rep(i,a,b) for(int i=a ; i<b ; ++i)
#define  deb(x) cout << #x << " - " << x << "\n";
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  D2(x)  { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define  ps(x,y) fixed<<setprecision(y)<<x
 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 10000000000;
const ll MAX_N = 1e6 + 2;

void solve(){
    ll l,r; cin >> l >> r;
    if(l==0 || r - l >= 2019){
        cout << "0";
        return;
    } else{
        ll mn = 2019;
        for(ll i=l;i<r;++i){
            for(ll j=i+1;j<=r;++j){
                mn = min(mn,(((i%2019)*(j%2019))%2019));
            }
        }
        cout << mn ;
        return;
    }
}

int main() {
    IOS;
    int t = 1;
    while(t--) solve();
}

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

#define debug(x) cerr << #x << ": " << x << endl

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, i;
  cin >> n >> i;
  cout << n - i + 1 << '\n'; 
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define _USE_MATH_DEFINES
#define mp       make_pair
#define pb       push_back
#define fst      first
#define snd      second
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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


int main()
{
    int K, S; cin >> K >> S;

    int ans = 0;
    rep(x, K+1) rep(y, K+1) {
        int z = S - x - y;
        if(z >= 0 && z <= K) ans++;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=s.size()-2;i>=0;i-=2){
    s=s.substr(0,i);
    if(s.substr(0,i/2)==s.substr(i/2,i)){
      cout << i;
      return 0;
    }
  }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

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

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

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

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

    return mp;
}

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

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

void solve(){
    int H, W;
    cin >> H >> W;

    char A[H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }

    queue<pair<int,int>> black;
    int check[H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == '#') {
                check[i][j] = 1;
                black.push(make_pair(i,j));
            } else {
                check[i][j] = 0;
            }
        }
    }

    // int ans = 0;
    while (black.size() != 0) {
        pair<int,int> now = black.front();
        black.pop();
        int row = now.first, col = now.second;
        if (row + 1 < H && check[row+1][col] == 0) {
            check[row+1][col] = check[row][col] + 1;
            // ans = max(ans, check[row+1][col]);
            black.push(make_pair(row+1, col));
        }
        if (row - 1 >= 0 && check[row-1][col] == 0) {
            check[row-1][col] = check[row][col] + 1;
            // ans = max(ans, check[row-1][col]);
            black.push(make_pair(row-1, col));
        }
        if (col + 1 < W && check[row][col+1] == 0) {
            check[row][col+1] = check[row][col] + 1;
            // ans = max(ans, check[row][col+1]);
            black.push(make_pair(row, col+1));
        }
        if (col - 1 >= 0 && check[row][col-1] == 0) {
            check[row][col-1] = check[row][col] + 1;
            // ans = max(ans, check[row][col-1]);
            black.push(make_pair(row, col-1));
        }
    }


    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            // cout << check[i][j];
            ans = max(ans, check[i][j]);
        }
        // cout << endl;
    }

    cout << ans-1 << endl;

    return;
}

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


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

int main() {
    ll n, x[200],p,min = -100,hoge = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> x[i];
    }
    for(int i=1;i<101;i++){
        hoge = 0;
        for(int j = 0;j < n; j++){
            hoge += ((x[j] - i) * (x[j] - i));
        }
        if(min == -100){
            min = hoge;
        }
        if(min > hoge)min = hoge;
    }
    cout << min << endl;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = new int[3][];
            for (int i = 0; i < a.Length; i++) {
                a[i] = ReadLineIntSpilit();
            }

            var n = ReadLineInt();
            var b = new int [n];
            for (int i = 0; i < n; i++) {
                b[i] = ReadLineInt();
            }

            for (int i = 0; i < n; i++) {
                for (int q = 0; q < 3; q++) {
                    for (int e = 0; e < 3; e++) {
                        if(b[i] == a[q][e]) {
                            a[q][e] = 0;
                        }
                    }
                }
            }

            var re = false;
            for (int i = 0; i < 3; i++) {
                if (a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) re = true;
                else if (a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0) re = true;
            }

            if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) re = true;
            else if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) re = true;

            Console.WriteLine((re)?"Yes":"No");
            ReadLine();
        }

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static long ReadLineLongInt() => long.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &x){
    if(x > mod){
        x %= mod;
    }
    else if(x < 0){
        x += mod*(abs(x)/mod+1);
        x %= mod;
    }
}

int main(){
    int N,M; cin >> N >> M;
    vector<ll> x(N), y(M);

    for(int i=0; i<N; ++i) cin >> x[i];
    for(int i=0; i<M; ++i) cin >> y[i];

    ll X = 0, Y = 0;
    for(int k=0; k<N; ++k){
        X += k*x[k] - (N-1-k)*x[k];
        chmod(X);
    }
    for(int k=0; k<M; ++k){
        Y += k*y[k] - (M-1-k)*y[k];
        chmod(Y);
    }

    cout << X*Y%mod << endl;
    return 0;
}

Measured memory_bytes: 1792
def f():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    x = 1
    c = 0
    for i in range(n):
        if x != 2:
            x = a[x-1]
            c += 1
            if c == n:
                return -1
        else:
            return c
print(f())

Measured memory_bytes: 12844
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  n=n%10;
  if(n==2 || n==4 || n==5 || n==7 || n==9){
  	cout<<"hon"<<endl;
  }
  if(n==0 || n==1 || n==6 || n==8){
  	cout<<"pon"<<endl;
  }
  if(n==3){
  	cout<<"bon"<<endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m;
    cin >> n >> m;
    int x[200000] = {0} , y[200000] = {0};
    for (int i = 0 ; i < m ; i++ ) {
        int a , b;
        cin >> a >> b;
        if ( a == 1 ) x[b - 1] = 1;
        if ( b == n ) y[a - 1] = 1;
    }
    for (int i = 0 ; i < n ; i++ ) {
        if ( x[i] == 1 && y[i] == 1 ) {
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
}




Measured memory_bytes: 1792
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) (*find_by_order(i))
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/

int fre[100005];
void solve(){
    int n;
    cin >> n;
    int sum = 0;
    rep(i, 0, n){
        int a;
        cin >> a;
        fre[a]++;
        sum += a;
    }
    int q;
    cin >> q;
    while(q--){
        int a, b;
        cin >> a >> b;
        sum -= a*fre[a];
        sum += b*fre[a];
        fre[b] += fre[a];
        fre[a] = 0;
        cout << sum << endl;
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 4432
let analysis (area:string) =
  let len = String.length area in
  let stack = Stack.create () in
  let rec loop acc = function
      i when i = len -> acc
    | i ->
      match area.[i] with
      | '\\' -> Stack.push i stack; loop acc (i+1)
      | '/' -> loop
                 (match Stack.length stack with
                    0 -> acc
                  | _ -> let j = Stack.pop stack in
                    (((j,i),i-j)::acc))
                 (i+1)
      | _ -> loop acc (i+1)
  in loop [] 0

let summarize lst =
  let rec loop acc cnt sum = function
      []  -> acc,cnt,sum
    | [x] -> x::acc,cnt+1,sum+(snd x)
    | ((s1,e1),v1)::((s2,e2),v2)::r when s1 < s2 && e1 > e2 ->
      loop acc cnt sum (((s1,e1), v1+v2)::r)
    | (_,v) as a::(b::r as rest) -> loop (a::acc) (cnt+1) (sum+v) rest
  in loop [] 0 0 lst

let () =
  let line = read_line () in
  let part,cnt,sum = analysis line |> summarize in
  Printf.printf "%d\n%d" sum cnt;
  List.iter (fun (_,v) -> Printf.printf " %d" v) part;
  print_newline ()

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
const int mod = 1e9 + 7;
const int N = 1e3 + 9;

int32_t main(){
 L_T_S_K;
  int k , x;
  cin >> k >> x;
  cout << (k * 500 >= x  ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
bool gray,brown,green,cyan,blue,yellow,orange,red;
int other;
int n;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	while(n--){
		int a;
		cin>>a;
		if(a<400) gray=1;
		else if(a<800) brown=1;
		else if(a<1200) green=1;
		else if(a<1600) cyan=1;
		else if(a<2000) blue=1;
		else if(a<2400) yellow=1;
		else if(a<2800) orange=1;
		else if(a<3200) red=1;
		else other++;
	}
	int ans=gray+brown+green+cyan+blue+yellow+orange+red;
	if(!ans) cout<<1<<' '<<other;
	else cout<<ans<<' '<<ans+other;
	re 0;
}


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

#define INF INT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    int a,b;
    cin >> a >> b;

    int ans = 1;
    int tp = a;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    while(tp < b){
        ans++;
        tp += a -1;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807int
#define I64_MAX2 1223372036854775807int
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//FUNCTION  
 
//solve

void solve(void)
{
  int N;
  cin>>N;
  string str;
  if(N == 0)
  {
    cout<<0<<endl;
    return;
  }
  while(N != 0)
  {

    if(N%2 == 1 || N%2 == -1)
    {
      N --;
      str.push_back('1');
    }
    else
    {
      str.push_back('0');
    }
        // DEBUG(N);
    N /=(-2);
  }
  reverse(ALL(str));
  cout<<str<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

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

  std::string t;
  for (const auto s_i: s) {
    if (s_i == 'B') {
      if (!t.empty()) t.pop_back();
    } else {
      t.push_back(s_i);
    }
  }
  std::cout << t << std::endl;
}

Measured memory_bytes: 256
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){

	fastio;
	string cad;
	cin >> cad;
	int l = 0, r = sz(cad)-1;
	while(cad[l] != 'A') l++;
	while(cad[r] != 'Z') --r;
	cout << r-l+1 << endl;

	return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>

int main (void) {
  int N = 0;
  long long x = 0;
  std::cin >> N >> x;
  
  long long A = 0;
  std::vector<long long> a;
  while(std::cin >> A) {
    a.push_back(A);
  }
  
  long long result = 0;
  std::vector<long long> cost;
  long long temp = 0;
  //magic k:0
  for(int i = 0; i < N; i++) {
    temp = temp + a[i];
    cost.push_back(a[i]);
  }
  result = temp;

  //magic k:1 ~ N-1
  for(int k = 1; k < N; k++) {
    for(int i = 0; i < N; i++) {
      cost[i] = std::min(cost[i], a[(i-k+N)%N]);
    }

    temp = k * x;    
    for(int i = 0; i < N; i++) {
      temp = temp + cost[i];
    }
    result = std::min(result, temp);
  }
  
  std::cout << result << std::endl;
  
  return 0;    
}

Measured memory_bytes: 256
if __name__ == '__main__':
    N, Y = list(map(int, input().split()))

    for a in range(N+1):
        for b in range(N+1):
            if 10000*a + 5000*b + 1000*(N-a-b) == Y and N-a-b >= 0:
                print(a, b, N-a-b)
                exit()
    print(-1, -1, -1)


Measured memory_bytes: 2940
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

const int N = 1e5 + 1;
int n;
const ll inf = 1e18;

ll dp[N][3];

int a[N];
int op[N];

// smin, smax {{{
// clang-format off
template < class T, class U > inline void smin(T &a, const U &b) { a = a < (T) b ? a : b; }
template < class T, class U > inline void smax(T &a, const U &b) { a = a < (T) b ? b : a; }
// clang-format on
// }}}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  op[0] = 1;
  for(int i = 0; i < n; i++) {
    char t_op;
    if(i) {
      cin >> t_op;
      op[i] = t_op == '-' ? -1 : 1;
    }
    cin >> a[i];
  }

  for(int i = 0; i < n; i++) for(int j = 0; j < 3; j++) dp[i][j] = -inf;

  dp[0][0] = a[0];

  for(int i = 1; i < n; i++) for(int j = 0; j < 3; j++) {
    for(int k = 0; k <= j; k++) {
      smax(dp[i][k], dp[i-1][j] + (j & 1 ? -1 : 1) * op[i] * a[i]);
    }
    if(op[i] == -1 && j <= 1) {
      smax(dp[i][j + 1], dp[i-1][j] + (j & 1 ? -1 : 1) * op[i] * a[i]);
    }
  }
  
  // -(...-(...-(x)) - y - z

  cout << dp[n-1][0] << endl;
  return 0;
}



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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) begin(n),end(n)

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	ll x,a,b;
	cin >> x >> a >> b;

	char ans = (abs(x-a) < abs(x-b)) ? 'A' : 'B';
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,(n))
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int bitcount(int n) {
	int res = 0;
	while (n > 0) {
		res += (n % 2);
		n /= 2;
	}
	return res;
}

int main() {
	int N, M;
	cin >> N >> M;

	int k, s;
	vi b(M);
	REP(i, M) {
		cin >> k;
		REP(j, k) {
			cin >> s;
			s--;
			b[i] += (1<<s);
		}
	}
	vi p(M);
	REP(i, M) {
		cin >> p[i];
	}

	int ans = 0;
	REP(i, (1<<N)) {
		bool ok = true;
		REP(j, M) {
			if (bitcount(i&b[j])%2 != p[j]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			ans++;
		}
	}

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

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

int main() {
  string O, E;
  cin >> O >> E;
  int o, e;
  o = O.size();
  e = E.size();
  for (int i = 0; i < e; i++) {
    cout << O.at(i) << E.at(i);
  }
  if (o - e == 1) {
    cout << O.at(o - 1);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	bool ans=false;
	if(n%10==9) ans=true;
	n/=10;
	if(n%10==9) ans=true;
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++) cin >> a[i];
    vector< vector<int> > b(20, vector<int>(n+1, 0));
    for(int i=1;i<=n;i++){
        for(int j=0;j<20;j++){
            b[j][i] = b[j][i-1] + ((a[i]>>j)&1);
        }
    }
    long long ans = 0;
    int r = 1;
    for(int l=1;l<=n;l++){
        bool flg = true;
        while(r <= n && flg){
            for(int j=0;j<20;j++){
                if(b[j][r]-b[j][l-1] > 1){
                    flg = false;
                    break;
                }
            }
            if(flg) r++;
        }
        ans += r-l;
    }
    cout << ans << endl;
}


Measured memory_bytes: 17536
#include <iostream>
#include <climits>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int *H = new int[N+1];
    for (int i = 0; i < N; i++) cin >> H[i];
    H[N] = INT_MAX;
    int max_n = 0;

    // O(N^2)のやりかた！
    // for (int i = 0; i < N-1; i++) {
    //     int h = H[i];
    //     int j = i+1;
    //     int cnt = 0;
    //     while (h >= H[j]) {
    //         h = H[j];
    //         j++;
    //         cnt++;
    //     }

    //     if (cnt > max_n) {
    //         max_n = cnt;
    //     }
    // }

    int cnt = 0;
    int prev = H[0];
    for (int i = 1; i < N+1; i++) {
        if (H[i] <= prev) {
            cnt++;
        } else {
            if (cnt > max_n) {
                max_n = cnt;
            }

            cnt = 0;
        }

        prev = H[i];
    }

    cout << max_n << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int C[105][10005];
struct items {
	int value, weight;
};

int main()
{
	int N, W;
	int a, b;
	items item[105];
	cin >> N >> W;

	for (int i = 1; i <= N; i++) {
		cin >> a >> b;
		item[i].value = a;
		item[i].weight = b;
	}

	for (int i = 0; i <= N; i++) {
		C[i][0] = 0;
	}

	for (int i = 0; i <= W; i++) {
		C[0][i] = 0;
	}


	for (int i = 1; i <= N; i++) {
		for (int w = 1; w <= W; w++) {
			C[i][w] = C[i - 1][w];
			if (item[i].weight > w) continue;
			C[i][w] = max(C[i - 1][w - item[i].weight] + item[i].value, C[i - 1][w]);
		}
	}

	cout << C[N][W] << endl;

}

Measured memory_bytes: 7016
#include <iostream>
#include <algorithm>
#include <ostream>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstring>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using ll = long long;

template <typename T, typename U>
std::ostream &operator<<(std::ostream &out, std::pair<T, U> p)
{
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T>
std::ostream &operator<<(std::ostream &out, std::vector<T> v)
{
  out << "[";
  for (int i = 0; i < v.size(); ++i)
  {
    out << v[i] << (i == (v.size() - 1) ? "" : ", ");
  }
  out << "]";
  return out;
}

int main()
{
  int a, b, t;

  cin >> a >> b >> t;
  cout << (t / a) * b << endl;

  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <numeric>
#define rep(i,s,n) for (int i = s; i < n; ++i)
#define drep(i,s,n) for (int i = n; i >= s; --i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a, int b)
{
   if (a%b == 0) return(b);
   else          return(gcd(b, a%b));
}
int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
void printvv(vector<vector<auto>> vv, int n)
{
  cout << '[' << endl;
  rep(q, 0, n)
  {
    cout << '[';
    rep(p, 0, n)
    {
      cout << vv.at(q).at(p) << ',';
    }
    cout << ']' << endl;
  }
  cout << ']' << endl;
}

void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

//------------------------------------------------------------
void solve() {
  int N, dt=0, dist=0;
  bool bl=true;

  cin >> N;

  vector<vector<int>> v(N, vector<int>(3));
  rep(i,0,N) cin >> v.at(i).at(0) >> v.at(i).at(1) >> v.at(i).at(2);

  if (N==1)
  {
    dt   = v.at(0).at(0);
    dist = abs(v.at(0).at(1)) + abs(v.at(0).at(2));
    if(dt<dist || dt%2!=dist%2) bl=false;
    if(bl)cout << "Yes" << endl;
    else  cout << "No" << endl;
    return;
  }

  rep(i,1,N)
  {
    dt = v.at(i).at(0) - v.at(i-1).at(0);
    dist = abs(v.at(i).at(1)-v.at(i-1).at(1)) + abs(v.at(i).at(2)-v.at(i-1).at(2));

    if(dt<dist || dt%2!=dist%2)
    {
      bl=false;
      break;
    }
  }

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


Measured memory_bytes: 5760
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void) {
    char str[1001], x[11];
    int ans;
    int i;

    scanf("%s", x);

    for (i = 0; str[i] != '\0'; i++) str[i] = tolower(str[i]);

    ans = 0;
    while (scanf("%s", str), strcmp(str, "END_OF_TEXT")) {
        for (i = 0; str[i] != '\0'; i++) str[i] = tolower(str[i]);

        if (strcmp(str, x) == 0) ans++;
    }
    printf("%d\n", ans);

    return 0;
}



Measured memory_bytes: 2044
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

///
enum EPS = 1e-10;

///
double add(double a, double b) {
    if (abs(a + b) < EPS * (abs(a) + abs(b))) return 0;
    return a + b;
}

///
struct P {
    double x, y;

    this(double x, double y) {
        this.x = x;
        this.y = y;
    }

    P opBinary(string op)(P p) {
        static if (op == "+") return P(add(x, p.x), add(y, p.y));
        else static if (op == "-") return P(add(x, -p.x), add(y, -p.y));
        else static assert(0, "Operator '"~op~"' not implemented");
    }

    P opBinary(string op)(double d) {
        static if (op == "*") return P(x * d, y * d);
        else static assert(0, "Operator '"~op~"' not implemented");
    }

    // dot product
    double dot(P p) {
        return add(x * p.x, y * p.y);
    }

    // cross product
    double det(P p) {
        return add(x * p.y, -y * p.x);
    }

    double dist(P p) {
        return sqrt((x - p.x)^^2 + (y - p.y)^^2);
    }

    P middle(P p) {
        return P((x + p.x)/2, (y + p.y)/2);
    }
}

///
P[] convex_hull(P[] ps)
{
    auto n = ps.length;
    sort!"a.y == b.y ? a.x < b.x : a.y < b.y"(ps);
    size_t k;
    auto qs = new P[](n*2);

    foreach (i; 0..n) {
        while (k > 1 && (qs[k-1] - qs[k-2]).det(ps[i] - qs[k-1]) < 0) k--;
        qs[k++] = ps[i];
    }

    auto t = k;
    foreach_reverse (i; 0..n-1) {
        while (k > t && (qs[k-1] - qs[k-2]).det(ps[i] - qs[k-1]) < 0) k--;
        qs[k++] = ps[i];
    }

    qs.length = k;
    return qs;
}

void main()
{
    auto N = readln.chomp.to!int;
    P[] ps;
    foreach (_; 0..N) {
        auto xy = readln.split.to!(double[]);
        ps ~= P(xy[0], xy[1]);
    }
    auto qs = convex_hull(ps);
    writeln(qs.length-1);
    foreach (q; qs[0..$-1]) {
        writefln("%d %d", q.x.to!int, q.y.to!int);
    }
}


Measured memory_bytes: 7820
MOD=10**9+7

N=int(input())
A=list(map(int, input().split()))
ans=0
for i in range(60):
    x=0
    for j in range(N):
        if A[j]>>i&1: # A[j]のi桁目が1である場合
            x+=1
    now=x*(N-x)%MOD
    for j in range(i):
        now=now*2%MOD
    ans=(ans+now)%MOD
print(ans)

Measured memory_bytes: 122808
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int n;
    
    cin >> n;
    
    vector<int> p(n);
    for (int i=0;i<n;i++){
        cin >> p.at(i);
    }
    int count=0;
    
    for(int i=1;i<n-1;i++){
        if(max(max(p.at(i-1),p.at(i)),p.at(i+1)) != p.at(i)){
            if(min(min(p.at(i-1),p.at(i)),p.at(i+1)) != p.at(i)){
                count += 1;
            }
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int n;
char s[222], t[222];

int main(){
	scanf("%s%s", s, t);
	n = strlen(s);
	for(int i=0;i<n;i++) t[i+n] = t[i];
	for(int i=0;i<n;i++) {
		bool x = true;
		for(int j=0;j<n;j++) if (s[j]!=t[j+i]) x = false;
		if (x) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;
void solve(int n,vll aa){
  vector<pair<ll,ll>> stack;
  vll itol(n),itor(n);
  //高さ、アドレスの順
  stack.emplace_back(0,0);
  rep(i,n){
    while(stack.size() && stack.back().first>=aa[i]) stack.pop_back();
    if(stack.size()) itol[i]=stack.back().second;
    stack.emplace_back(aa[i],i+1);
  }
  stack.clear();
  stack.emplace_back(0,n);
  for (int i=n-1;i>=0;i--){
    while(stack.size() && stack.back().first>=aa[i]) stack.pop_back();
    if(stack.size()) itor[i]=stack.back().second;
    stack.emplace_back(aa[i],i);
  }
  //rep(i,n) cout<<itol[i]<<" ";
  //cout<<endl;
  //rep(i,n) cout<<itor[i]<<" ";
  //cout<<endl;
  ll ans=0;
  rep(i,n) ans=max(ans,aa[i]*(itor[i]-itol[i]));
  cout<<ans<<endl;
}

int main() {
  int n;
  cin>>n;
  vll aa(n);
  rep(i,n) cin>>aa[i];
  solve(n,aa);  
  return 0;
}



Measured memory_bytes: 8020
a=[],m=l=n=c=0;require("fs").readFileSync("/dev/stdin","utf8").split(' ').map(function(i){a[i]?++a[i]>m?m=a[n=i]:0:a[i]=1;(t=i.length)>l?(c=i,l=t):0});console.log(n+' '+c)

Measured memory_bytes: 7640
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
   string s1,s2;
   cin>>s1>>s2;

  int n = s1.length(),m = s2.length();
  int dp[n+1][m+1];
  memset(dp,0,sizeof(dp));

  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=m;j++)
    {
      if(s1[i-1]== s2[j-1])
        dp[i][j] = dp[i-1][j-1] + 1;
      else 
      {
        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
      }
      //cout<<dp[i][j]<<" ";
    }
    //cout<<endl;
  }

  int i=n,j=m;
  string s="";
  while(i>0 && j>0)
  {
     if(s1[i-1] == s2[j-1])
     {
       s = s1[i-1] + s;
       i--;
       j--;
     }
     else if(dp[i][j-1] < dp[i-1][j])
      i--;
     else
      j--;
  }
  cout<<s<<endl;
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="77675555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    string b;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    //数列の個数が偶数の場合
    if(n%2==0){
        for(int i=0; i<n; i+=2){
            cout << a[n-1-i] << ' ';
        }
        for(int i=0; i<n; i+=2){
            cout << a[i] << ' ';
        }
        cout << endl;
        return 0;
    }
    else{
        for(int i=0; i<n; i+=2){
            cout << a[n-1-i] << ' ';
        }
        for(int i=1; i<n; i+=2){
            cout << a[i] << ' ';
        }
        cout << endl;
        return 0;
    }
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N, M;
int S[112345];

int main() {
	cin >> N >> M;
	REP(i, M) {
		int L, R;
		cin >> L >> R;
		S[L]++;
		S[R + 1]--;
	}
	
	FOR(i, 1, 112345) S[i] += S[i - 1];
	int ans = 0;
	
	REP(i, 112345) if (S[i] == M) ++ans;
	cout << ans << endl;
	
	return 0;
}


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

int main() {
  int A, B, N, count;
  cin >> A >> B;
  N = B - A + 1;
  count = 0;
  
  for (int i = 0; i < N; i++) {
    int a, b, c, d;
    a = A % 10;
    b = (A / 10) % 10;
    c = (A / 1000) % 10;
    d = A / 10000;
    if (a == d && b == c) {
      count += 1;
    }
    A += 1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

int main() {
	int n, k, sum = 0;
	scanf("%d", &n);
	k = n;
	while (k > 0) {
		sum += k - (k / 10) * 10;
		k = k / 10;
	}
	if (n%sum == 0) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

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

int main() {
	int n, m;
	int k;
	int temp;
	int ans = 0;
	cin >> n;
	cin >> m;

	int arrays[30];
	for (int i = 0; i < 30; i++) { arrays[i] = 0; 
	}

	for (int i = 0; i < n;i++) {
		cin >> k;
		for (k > 0; k--;) {
			cin >> temp;
			arrays[temp - 1]+=1;
		}
	}
	for (int i = 0; i < m; i++) {
		if (arrays[i] == n)ans++;
	}
	cout << ans;
	
}


Measured memory_bytes: 256
n,k = map(int,input().split())
d = [0] * k
ans = [0] * n
an = 0
for i in range(k):
    d[i] = int(input())
    a = [int(x) for x in input().split()]
    for j in a:
        if ans[j-1] == 0:
            ans[j-1] += 1
            an += 1
print(n-an)



Measured memory_bytes: 9160
import java.util.*;
public class Main {
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        
        final int n = sc.nextInt();
        final String str = "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";
        String[] s = str.split(",");
        sc.close();

        System.out.println(s[n - 1]);
    }
}

Measured memory_bytes: 21844
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
template<typename K, typename V> using umap = unordered_map<K, V>;
template<typename K, typename V> using uset = unordered_set<K, V>;

//func
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

template<typename V, typename H> void resize(vector<V>& v, const H h) { v.resize(h); }
template<typename V, typename H, typename ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
template<typename V, typename T> void fill(V& x, const T& val) { x = val; }
template<typename V, typename T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main(void) {
	string S;
	cin >> S;
	sort(ALL(S));
	YesNo(S=="abc");
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class test
{
static void Main(){
    int n = Int32.Parse(Console.ReadLine());
    List<int> inputs = new List<int>();
    for(int i = 0;i < n;i++)
        inputs.Add(Int32.Parse(Console.ReadLine()));

    int max_index = 0;
    for(int i = 1;i < n;i++)
        if(inputs[i] > inputs[max_index])
            max_index = i;

    int result = 0;
    for(int i = 0;i < n;i++)
        if(i != max_index) result += inputs[i];
        else result += (int)(inputs[i] / 2);
    
    Console.WriteLine(result.ToString());
}
}

Measured memory_bytes: 11092
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		
		if(a<3200) {
			System.out.println("red");
		}else {
			System.out.println(s);
		}
		
	}

}


Measured memory_bytes: 21844
n=int(input())
a=list(map(int,input().split()))
ans=[]
x=n
for i in range(n):
    for j in reversed(range(x)):
        if a[j]==j+1:
            k=a.pop(j)
            ans.append(j+1)
            x-=1
            break
if len(a)==0:
    for i in ans[::-1]:
        print(i)
else:
    print(-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int X, A, B;
    std::cin >> X >> A >> B;

    int C = B - A;
    if (C <= 0) {
        std::cout << "delicious" << std::endl;
    } else if (C <= X) {
        std::cout << "safe" << std::endl;
    } else {
        std::cout << "dangerous" << std::endl;
    }
    return 0;
}

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

using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  cout<<n*n*n<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,n,d,sum=0;
int main()
{
	cin>>n>>d;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(a>=d) sum++;
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, k;
    cin >> n >> k;
    ll res = 0;
    if(k % 2 != 0){
        for(int i = k; i <= n; i += k){
            ll ub = (n - k) / k;
            res += (ub + 1) * (ub + 1);
        }
    }
    else{
        int mid = k / 2;
        for(int i = mid; i <= n; i += mid){
            ll ub;
            if(i % k == 0)  ub = (n - k) / k;
            else    ub = (n - mid) / k;
            res += (ub + 1) * (ub + 1);
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void){
    int n,a,b;
    int ans;

    scanf("%d%d%d",&n,&a,&b);
    
    if(n*a > b){
        ans = b;
    } else {
        ans = n*a;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,N) for(ll (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;
typedef pair<int,int> P;
const int mod = 1000000007;
int dp[5005][5005];

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

  for (int i = n - 1; i >= 0; --i) {
    for (int j = n - 1; j >= 0; --j) {
      if(s[i] == s[j]) dp[i][j] = dp[i + 1][j + 1] + 1;
      else dp[i][j] = 0;
    }
  }

  int ans = 0;
  rep(i, n)rep(j, n) {
    if(i > j) continue;
    int len = min(j - i, ll(dp[i][j]));
    ans = max(ans, len);
  }
  cout << ans << endl;
}

Measured memory_bytes: 98048
// 6/22 解き直し
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using Graph = vector<vector<int>>;

int main() {
    int N, u, v;
    cin >> N >> u >> v;
    u--; v--;

    Graph G(N);
    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist1(N, -1);  // 高橋くん
    vector<int> dist2(N, -1);  // 青木くん

    queue<int> que;

    dist1[u] = 0;
    que.push(u);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int nv : G[v]) {
            if (dist1[nv] != -1) continue;
            dist1[nv] = dist1[v] + 1;
            que.push(nv);
        }
    }

    dist2[v] = 0;
    que.push(v);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int nv : G[v]) {
            if (dist2[nv] != -1) continue;
            dist2[nv] = dist2[v] + 1;
            que.push(nv);
        }
    }

    if (G[u].size()==1 && G[u][0] == v) {
        cout << 0 << endl;
        return 0;
    }


    int res = 0;

    for (int i = 0; i < N; i++) {
        if (dist1[i] < dist2[i]) {
            res = max(res, dist2[i] - 1);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(c) c.begin(),c.end()
#define INF int(1e9+7)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

int main()
{
	IO_OP;

	int a[4];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << a[0]*a[1]/2 << endl;
}


Measured memory_bytes: 256