akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define vll vector<ll>
#define G vector<vll >
#define F first
#define S second
#define pll pair<ll,ll>
#define RFOR(i,a,b) for(int i=a;i>=b;i--)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define endl '\n'
#define clr(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define rll read_ll();
#define gc getchar
#define pc putchar
typedef int ll;
template<class T> inline T lcm(T a,T b){
        return a/gcd(a,b)*b;
}

ll read_ll(){char c=gc();while((c<'0'||c>'9')&&c!='-')c=gc();ll ret=0;int neg=0;if(c=='-')neg=1,c=gc();while(c>='0'&&c<='9'){ret=10*ret+c-48;c=gc();}return neg?-ret:ret;}

const int N = (int)1e5+10;

string s;
vector<int>pos[26];
map<char,bool>isThere;

bool cmp(int a,int b)
{
    int cnt = 1;
    while(a+cnt<s.length() && b+cnt<s.length() && s[a+cnt] == s[b+cnt])
        cnt++;
    if(a+cnt>=s.length())
        return false;
    return s[a+cnt] < s[b+cnt];
        
}

void fillPos(string s)
{
    int position = 0;
    for(auto c: s)
    {
        if(position+1!=s.size())
        pos[c-'a'].pb(position++);
        isThere[c] = true;
    }
    for(int i = 0; i < 26; i++)
    {
        sort(pos[i].begin(),pos[i].end(),cmp);
    }
}



int main()
{
    clr(pos);
    int k; cin>>s>>k;
    char search[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','x','y','z'};
    set<string>st;
    fillPos(s);
    for(auto c: search)
    {
        if(st.size()== k)break;
        if(isThere[c])
        {
            st.insert(string(1,c));
            int len = 1;
            for(auto position: pos[c-'a'])
            {
                while(len <= s.length() )
                {
                    st.insert(s.substr(position,len));
                    len+=1;
                }
            }
        }
    }
    int cnt = 1;
    for(auto ele:st)
        if(cnt == k)
        {
            cout<<ele;return 0;
        } else
            cnt++;
    
}



Measured memory_bytes: 143360
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
d=Counter(a)
import math
def cmb(n,r):
    f = math.factorial
    return int(f(n) // f(r) // f(n-r))
def combination(n, r):
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        b *= (i + 1)
    return a // b
e={}
dd=0
for i,j in d.items():
    dd+=combination(j, 2)
    e[i]=combination(j-1, 1)

for i in a:
    print(dd-e[i])
  

Measured memory_bytes: 101068
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long
#define pb push_back 
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<ll>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl;
#define cno cout << "No" << endl;
#define mod 1000000007
#define mod2 998244353
#define INT_MAX1 900000000
//////////////////////////////////////////////////////////////////////////////////////////////

int n;
int dp[100001];
bool v[100001];
int h[100001];

int s1(int i)
{
    if(i==n)
        return 0;
    if(i==n-1)
        return abs(h[i]-h[i+1]);
    if(v[i])
        return dp[i];
    v[i] = 1;
    return dp[i] = min(abs(h[i]-h[i+1])+s1(i+1),abs(h[i]-h[i+2])+s1(i+2));
}

void solve()
{
    cin >> n;
    for(int i=1; i<n+1; i++){
    	cin>>h[i];
    }

    cout << s1(1) << endl;
}
 
int32_t main()
{
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}


Measured memory_bytes: 3456
#include <stdio.h>

int main(void){
  int N, i;
  scanf("%d", &N);
  int array[N];
  int MIN=1000000000, MAX=0;
  for(i=0; i<N; i++){
    scanf("%d", &array[i]);
  }
  for(i=0; i<N; i++){
    if(array[i] < MIN){
      MIN = array[i];
    }
    if(MAX < array[i]){
      MAX = array[i];
    }
  }
  printf("%d", MAX-MIN);
  return 0;
}


Measured memory_bytes: 128
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvcha;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);

  char　小文字のほうが32大　　  　大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

  int i = sqrt (n) で、ｎの平方根(9に対する3)をiに入れる

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除             */

int a = 0, b = 0, c = 0, d = 0, x = 0, y = 0
, z = 0, n = 0, sum = 0, i = 0, ans = 0, cnt = 0;
string s = "";

int main(void) {
	cin >> n;
	vint a(n);
	vcin(a, n);
	rep(i, n) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 == 0 || a[i] % 5 == 0);
			else {
				cout << "DENIED" << rt;
				return 0;
			}
		}
	}
	cout << "APPROVED" << rt;
	please AC;
}

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

int N, A, B;
char S[100000];
int pass = 0;
int pass_abroad = 0;

int main(){
    cin >> N >> A >> B;
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
        /* code */
    }

    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'a')
        {
            if(pass < A + B){
                pass++;
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
        else if (S[i] == 'b'){
            if(pass < A + B && pass_abroad < B){
                pass++;
                pass_abroad++;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else{
            cout << "No" << endl;
        }

        /* code */
    }
    
}

Measured memory_bytes: 3724
# include <bits/stdc++.h>
# define int long long
# define fi first
# define se second

using namespace std ;

const int N = 1e5+ 4;

int n, w, W[200], V[200], dp[200][N], mx ;

int32_t main() {
    //freopen("haybales.in", "r", stdin ) ;
    //freopen("haybales.out", "w", stdout ) ;
    cin >> n >> w ;
    for( int i = 1 ; i <= n ; i ++ ) {
        cin >> W[i] >> V[i] ;
    }
    for( int i = 0 ; i <= n ; i ++ )  {
        for( int j = 1 ; j < N ; j ++ ) {
            dp[i][j] = 1e12 + 1 ;
        }
    }
    for( int i = 1 ; i <= n ; i ++ ) {
        for( int j = 1 ; j < N ; j ++ ) {
            dp[i][j] = dp[i-1][j] ;
            if( V[i] <= j ) {
                dp[i][j] = min( dp[i][j], dp[i-1][j-V[i]] + W[i] ) ;
            }
        }
    }
    for( int i = 1 ; i < N ; i ++ ) {
        if( dp[n][i] <= w ) mx = i ;
    }
    cout << mx << endl;
}


Measured memory_bytes: 82516
N, M = list(map(int, input().split()))
price = []
for i in range(N):
    A, B = list(map(int, input().split()))
    price.append([A, B])
    
price.sort()

cnt = M
re = 0
for i in range(N):
    A, B = price[i]
    if B < cnt:
        re += B * A
        cnt -= B
    else:
        re += cnt * A
        cnt = 0
        break
print(re)

Measured memory_bytes: 20464
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	bool x;
	cin >> x;
	cout << !x << endl;
	return 0;
}

Measured memory_bytes: 3632
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

ans = 'No'
for i in range(n-m+1):
    for j in range(n-m+1):
        match = 1
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    match = 0
        if match:
            ans = 'Yes'
print(ans)


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

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

    set<string> se;

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

    bool flag = true;

    se.insert(s[0]);

    for(int i=1; i<n; i++){
        if(se.count(s[i])){
            flag = false;
            break;
        }

        se.insert(s[i]);

        if(s[i-1].back() != s[i].front()){
            flag = false;
            break;
        }
    }

    if(flag) cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int n, k;
int a[5001];
int sum[5010][5010] = {};

bool need(int t)
{
	// cout << a[t] << endl;
	if(a[t] >= k) return true;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= k; j++){
			sum[i][j] = 0;
		}
	}
	for(int i = 1; i <= n; i++){
		if(i != t) sum[i][min(k, a[i])]++;
	}
	for(int i = 1; i < n; i++){
		for(int j = 0; j <= k; j++){
			if(sum[i + 1][j] == 0) sum[i + 1][j] = sum[i][j];
			if(i + 1 == t) continue;
			if(sum[i][j] == 0) continue;
			sum[i + 1][(int)min((long long int)k, (long long int)j + a[i + 1])] = sum[i][j];
		}
	}
	// for(int i = 1; i <= n; i++){
	// 	for(int j = 1; j <= k; j++){
	// 		cout << sum[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	for(int i = max(0, k - a[t]); i < k; i++){
		if(sum[n][i] > 0) return true;
	}
	return false;
}

int main()
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	if(a[0] >= k){
		cout << 0 << endl;
		return 0;
	}
	int l = 0, r = n + 1;
	while(r - l > 1){
		int mid = (r + l) / 2;
		if(need(mid)) r = mid;
		else l = mid;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 98176
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	vector<int> pw(n, 0);
	for(int i = 0; i < n; i++) while(!(a[i]%(1<<pw[i]))) pw[i]++;
	sort(pw.begin(), pw.end());
	if(pw[0] != pw[n - 1]) cout << "0\n";
	else {
		for(int i = 0; i < n; i++) a[i] /= 2;
		long long lcm = 1;
		auto gcd = [](int a, int b){
			while(b) a %= b, swap(a, b);
			return a;
		};
		for(int i = 0; i < n; i++){
			lcm = lcm / gcd(lcm, a[i]) * a[i];
			if(lcm > m) break;
		}
		if(lcm > m) cout << "0\n";
		else {
			int p = m / lcm;
			cout << (p + 1) / 2 << '\n';
		}
	}
	return 0;
}


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

using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 998244353;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}

string s;
int d;

int dp[10010][3][110];

signed main() {

	cin >> s >> d;
	int n = s.size();
	int *p;
	dp[0][0][0] = 1;

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < d; j++) {
			for(int k = 0; k < 10; k++) {
				p = &dp[i+1][1][(j+k)%d];
				*p += dp[i][1][j];
				*p %= SMOD;
			}
			
			
			for(int k = 0; k < s[i]-'0'; k++) {
				p = &dp[i+1][1][(j+k)%d];
				*p += dp[i][0][j];
				*p %= SMOD;
			}
			
			dp[i+1][0][(j+s[i]-'0')%d] += dp[i][0][j];
			dp[i+1][0][(j+s[i]-'0')%d] %= SMOD;
		}
	}
	
	cout << (dp[n][0][0] + dp[n][1][0] - 1 + SMOD) % SMOD << endl;


    return 0;
}



Measured memory_bytes: 13184
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> tree[100010];
ll val[100010] = {};

void dfs(ll cur, ll par){
    ll cnt = 0;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        cnt++;
        dfs(e, cur);
    }
    if(cnt == 0){
        val[cur] = 0;
        return;
    }
    ll min_val = INF, max_val = -INF;
    vector<ll> v;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        v.push_back(val[e]);
    }
    sort(v.begin(), v.end());
    rep(i,0,v.size()){
        val[cur] = max(val[cur], v[i] + cnt-i);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll a[100010];
    rep(i,0,N-1){
        cin >> a[i];
        a[i]--;
        tree[a[i]].push_back(i+1);
    }
    dfs(0, -1);
    print(val[0]);
    

}

Measured memory_bytes: 18176
N,M=map(int,raw_input().split())
L=[input() for i in range(N)]
S=set()
cnt=0
for i in range(N):
    if L[N-i-1] not in S:
        print L[N-i-1]
        S.add(L[N-i-1])
        cnt+=1
    if cnt==M:
        break

Measured memory_bytes: 13256
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <cmath>

int main(){
  int N;
  std::cin >> N;
  std::vector<long long> H(N);
  std::copy_n(std::istream_iterator<int>(std::cin), N, H.begin());

  if(N == 1){
    printf("Yes\n");
    return 0;
  }

  for(int i = N - 1 ; i >= 1 ; i--){
    if(H[i-1] <= H[i] ){
      continue;
    }else{
      H[i-1]--;
    }
  }
  
  bool check = true;
  for(int i = 0 ; i < N - 1 ; i++){
    if(H[i] <= H[i+1]){
      continue;
    }else{
      check = false;

    }
  }

  if(check == true){
    printf("Yes\n");
    
  }else{
    printf("No\n");
  }
  return 0;
  
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.StringTokenizer;
import java.util.ArrayList;

class Point {
	double x,y;

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

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while (!(buf = br.readLine()).equals("0")) {
				int n = Integer.parseInt(buf);
				Point p[] = new Point[n];
				for (int i=0;i<n;i++) {
					buf = br.readLine();
					StringTokenizer st = new StringTokenizer(buf,",");
					p[i] = new Point(Double.parseDouble(st.nextToken()),Double.parseDouble(st.nextToken()));
				}
				quicksort(0,n-1,p);
				sorty(n,p);
				int c = convexhull(n,p);
				System.out.println(n-c);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static int convexhull(int n,Point p[]) { //逐次追加法
		ArrayList<Point> ans = new ArrayList<Point>();
		if (S(p[2],p[1],p[0])>=0) { //CCWまたは一直線
			ans.add(p[2]);
			ans.add(p[1]);
			ans.add(p[0]);
		} else { //CW
			ans.add(p[2]);
			ans.add(p[0]);
			ans.add(p[1]);
		}

		for (int i=3;i<n;i++) {
			int s = ans.size();
			Point cnt_up,cnt_down;
			int j = 0;
			int k = 1;
			while (S(p[i],ans.get(j),ans.get(k))<0) { //CW
				j = (j+1)%s;
				k = (k+1)%s;
			}
			cnt_up = ans.get(j);
			j = 0;
			k = s-1;
			while (S(p[i],ans.get(j),ans.get(k))>0) { //CCW
				j = (j+s-1)%s;
				k = (k+s-1)%s;
			}
			cnt_down = ans.get(j);

			ArrayList<Point> construct = new ArrayList<Point>();
			construct.add(p[i]);
			for (int l=ans.indexOf(cnt_up);l!=ans.indexOf(cnt_down);l=(l+1)%s) {
				construct.add(ans.get(l));
			}
			construct.add(cnt_down);

			ans.clear();
			for (int l=0;l<construct.size();l++) {
				ans.add(construct.get(l));
			}
		}
		return ans.size();
	}

	public static void quicksort(int low,int high,Point p[]) {
		if (high>low) {
			int mid = (low+high)/2;
			double x = p[mid].x;
			int i = low;
			int j = high;
			while (p[i].x<x) i++;
			while (p[j].x>x) j--;
			if (i<=j) {
				Point t =p[i];
				p[i] = p[j];
				p[j] = t;
				i++;j--;
			}
			quicksort(low,j,p);
			quicksort(i,high,p);
		}
	}

	public static void sorty(int n,Point p[]) {
		for (int i=1;i<n;i++) {
			int j = i-1;
			while (p[j].x==p[j+1].x&&p[j].y>p[j+1].y) {
				Point t = p[j+1];
				p[j+1] = p[j];
				p[j] = t;
				j--;
				if (j<0) break;
			}
		}
	}

	public static double S(Point p0,Point p1,Point p2) {
		return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
	}
}

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

int main() {
    int x=0,n,ans=0;
    cin>>n;
    string S;cin>>S;
    for(int i=0;i<n;i++) {
        if(S[i]=='I') x++;
        else if(S[i]=='D') x--;
        ans=max(ans,x);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
N = int(input())
e = dd(list)
for _ in range(N - 1):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)
c = list(map(int, input().split()))
c.sort()
sm = sum(c) - c[-1]
res = [0] * (N + 1)
def dfs(x):
  global res
  res[x] = c.pop()
  for y in e[x]:
    if res[y]: continue
    dfs(y)
dfs(1)
print(sm)
print(*res[1: ])

Measured memory_bytes: 54364
import sys
A = [list(map(int, input().split())) for i in range(3)]

n = int(input())

for j in range(n):
    b = int(input())
    for l in range(3):
        if A[l][0] == b:
            A[l][0] = 0
        if A[l][1] == b:
            A[l][1] = 0
        if A[l][2] == b:
            A[l][2] = 0
if A[0][0]==A[1][1]==A[2][2]==0:
    print("Yes")
    sys.exit()
elif A[0][2]==A[1][1]==A[2][0]==0:
    print("Yes")
    sys.exit()
elif A[0][0]==A[0][1]==A[0][2]==0:
    print("Yes")
    sys.exit()
elif A[1][0]==A[1][1]==A[1][2]==0:
    print("Yes")
    sys.exit()
elif A[2][0]==A[2][1]==A[2][2]==0:
    print("Yes")
    sys.exit()
elif A[0][0]==A[1][0]==A[2][0]==0:
    print("Yes")
    sys.exit()
elif A[0][1]==A[1][1]==A[2][1]==0:
    print("Yes")
    sys.exit()    
elif A[0][2]==A[1][2]==A[2][2]==0:
    print("Yes")
    sys.exit()   
else:
    print("No")

Measured memory_bytes: 9336
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

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

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

let main() =
    let maze = Array2D.init 3 3 (fun _ _ -> 0)
    for i in 0 .. 2 do
        let a = reada int
        for j in 0 .. 2 do
            maze.[i, j] <- a.[j]

    let N = read int
    let B = Array.zeroCreate N
    for i in 0 .. N - 1 do
        let b = read int
        B.[i] <- b

    let seen = Array2D.init 3 3 (fun _ _ -> false)
    for b in B do
        for i in 0 .. 2 do
            for j in 0 .. 2 do
                if maze.[i, j] = b then seen.[i, j] <- true

    let mutable ok = false
    for i in 0 .. 2 do
        if seen.[i, *] |> Array.forall id then ok <- true
        if seen.[*, i] |> Array.forall id then ok <- true
    if seen.[0, 0] && seen.[1, 1] && seen.[2, 2] then ok <- true
    if seen.[0, 2] && seen.[1, 1] && seen.[2, 0] then ok <- true

    if ok then "Yes" else "No"
    |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 11476
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;
    bool is_ok = false;
    rep(i, a, b+1)
    if (i%k == 0) is_ok = true;
    if (is_ok) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> firstRow = Arrays.asList(br.readLine().split(" "));
            List<String> secondRow = Arrays.asList(br.readLine().split(" "));
            String thirdRow = br.readLine();

            List<Integer> ballsCount = new ArrayList<>();
            for (String s : secondRow) {
                ballsCount.add(Integer.parseInt(s));
            }

            Map<String, Integer> ballsCountAndColor = new HashMap<>();

            for (int i = 0; i < firstRow.size(); i++) {
                ballsCountAndColor.put(firstRow.get(i), ballsCount.get(i));
            }

            ballsCountAndColor.put(thirdRow, ballsCountAndColor.get(thirdRow).intValue() - 1);

            int iterator = 1;
            String result = "";
            for (int output : ballsCountAndColor.values()) {
                if (iterator == 1) {
                    result = output + " ";
                    iterator++;
                } else {
                    result += output;
                }

            }

            System.out.print(ballsCountAndColor.get(firstRow.get(0)).intValue() + " " + ballsCountAndColor.get(firstRow.get(1)).intValue());

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 20692
# -*- coding:utf-8 -*-

import sys

t = [
{"name":"AAA","a":35.5,"b":71.0},
{"name":"AA" ,"a":37.5,"b":77.0},
{"name":"A"  ,"a":40.0,"b":83.0},
{"name":"B"  ,"a":43.0,"b":89.0},
{"name":"C"  ,"a":50.0,"b":105.0},
{"name":"D"  ,"a":55.0,"b":116.0},
{"name":"E"  ,"a":70.0,"b":148.0},
]

while True:
	s = sys.stdin.readline()
	if not s: break
	a, b = [ float(x) for x in s.split() ]
	f = [ x for x in t if x["a"] > a and x["b"] > b ]
	if len(f) == 0 :
		print "NA"
	else:
		print f[0]["name"]
	
	

Measured memory_bytes: 4268
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int H, W;
int h, w;

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

  cin >> H >> W >> h >> w;

  cout << H*W - (H*w + W*h - h*w) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N;
	string S;
	cin>>N>>S;
	static int R,B;
	for(int i=0;i<N;i++){
		if(S[i]=='R') R++;
		else		B++;
	}
	if(R>B) cout<<"Yes"<<endl;
	else	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	cin >> s;
	int q;
	cin >> q;
	char t; vector<char> T(q); vector<int> x(q); int cnt = 0;
	string L, R;
	rep(i, q)
	{
		cin >> a;
		if (a == 2)
		{
			cin >> b >> t;
			if (b == 1)
			{
				if (cnt % 2 == 1)
					R += t;
				else
					L += t;
			}
			else
			{
				if (cnt % 2 == 1)
					L += t;
				else
					R += t;
			}
		}
		else
			cnt++;

	}
	


	if (cnt % 2 == 0)
	{
		reverse(all(L));
		cout << L << s << R << endl;;
	}
	else
	{
		reverse(all(R));
		reverse(all(s));
		cout << R << s << L;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int n;
vector<ll>l, r;
ll ans, lsum, rsum;

int main() {
	cin >> n;
	l.resize(n);
	r.resize(n);
	for (int i = 0;i < n;i++) {
		cin >> l[i] >> r[i];
	}
	sort(ALLR(l));
	sort(ALL(r));
	for (int i = 0;i < n;i++) {//First left
		lsum += l[i];
		ans = max(ans, 2 * (lsum - rsum));
		rsum += r[i];
		ans = max(ans, 2 * (lsum - rsum));
	}
	lsum = 0, rsum = 0;
	for (int i = 0;i < n;i++) {//First right 
		rsum += r[i];
		ans = max(ans, 2 * (lsum - rsum));
		lsum += l[i];
		ans = max(ans, 2 * (lsum - rsum));
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
	string S,T,U;
	long A,B;
	string result;

	cin >> S>>T>>A>>B>>U;

	result = "";

	if (U == S) {
		A -= 1;
	}
	else {
		B -= 1;
	}
	
	result = to_string(A) + " " + to_string(B);
	

	cout << result<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define MAX 100
#define NIL -1

struct Node {
    int parent, left, right;
};

Node T[MAX];
int n, H[MAX], D[MAX], C[MAX];

int setH (int id) {
    int h1 = 0; int h2 = 0;
    if (T[id].left != NIL) {
        h1 = setH(T[id].left) + 1;
    }
    if (T[id].right != NIL) {
        h2 = setH(T[id].right) + 1;
    }
    return H[id] = h1 > h2 ? h1 : h2;
}

void setD(int id, int val) {
    if (id == NIL) return;
    D[id] = val;
    setD(T[id].left, val+1);
    setD(T[id].right, val+1);
}


int getsibling(int id) {
    if (T[id].parent == NIL) return NIL;
    if (T[T[id].parent].left == id) {
        return T[T[id].parent].right;
    } else if (T[T[id].parent].right == id) {
        return T[T[id].parent].left;
    }
    return NIL;
}

void print(int u) {
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getsibling(u));
    printf("degree = %d, ", C[u]);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);
    if (T[u].parent == NIL) printf("root\n");
    else if ( T[u].left == NIL && T[u].right == NIL ) printf("leaf\n");
    else printf("internal node\n");
}


int main() {
    int id, left, right;
    int root = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        T[i].parent = T[i].left = T[i].right = NIL;
        C[i] = 0;
    }
    
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &id, &left, &right);
        T[id].left = left;
        T[id].right = right;
        if (left != NIL) {
            T[left].parent = id;
            C[id] ++;
        }
        if (right != NIL) {
            T[right].parent = id;
            C[id] ++;
        }
    }
    
    // search root
    for (int i = 0; i < n; i++) {
        if (T[i].parent == NIL) root = i;
    }
    
    setD(root, 0);
    setH(root);
    
    for (int i = 0; i < n; i++) {
        print(i);
    }
    
    return 0;
}

Measured memory_bytes: 3224
L, R = map(int, input().split())
ans = float('inf')
if R-L >= 672:
  ans = 0
  print(ans)
  quit()
for i in range(L,R):
  for j in range(i+1,R+1):
    ans = min(ans, i*j%2019)
    if ans == 1:
      print(ans)
      quit()
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    rep(i, X) { cin >> A[i]; }
    rep(i, Y) { cin >> B[i]; }
    rep(i, Z) { cin >> C[i]; }
    vector<ll> tmp, ans;
    rep(i, X)
    {
        rep(j, Y)
        {
            tmp.push_back(A[i] + B[j]);
        }
    }
    sort(tmp.rbegin(), tmp.rend());
    rep(i, min(K,X*Y))
    {
        rep(j, Z)
        {
            ans.push_back(tmp[i] + C[j]);
        }
    }

    sort(ans.rbegin(), ans.rend());
    rep(i, K)
    {
        cout << ans[i] << endl;
    }
    return 0;
}


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

for _ in range(M):
  x, y = map(int, input().split())
  node[x-1].append(y-1)
  node[y-1].append(x-1)

ct = [-1]*N

i = 0
stack = []
ct[0] = 0
stack.append(0)
while len(stack) != 0:
  v = stack.pop(0)
  for e in node[v]:
    if ct[e] == -1:
      ct[e] = v
      stack.append(e)

print('Yes')
for i in range(1,N):
  print(ct[i]+1)

Measured memory_bytes: 33652
# https://atcoder.jp/contests/abc143/tasks/abc143_c
# -*- coding: utf-8 -*-

sli_len = int(input())
sli_clr = list(str(input()))

sli_cnt = 1
for i in range(1, sli_len):
    if sli_clr[i] != sli_clr[i-1]:
        sli_cnt += 1

print(sli_cnt)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll a[30000];   
int main()
{
    fastread;
     ll n,i,j,k,l,m;
     cin>>n;
     for(i=1;i<=n;i++)
     cin>>a[i];
     ll sum=0;
     for(i=1;i<=n;i++)
     sum+=a[i];
     ll avg1=sum/n;
     ll avg2=(sum+n-1)/n;
     ll cnt1=0;
     ll cnt2=0;
     for(i=1;i<=n;i++)
     cnt1+=((a[i]-avg1)*(a[i]-avg1));
     for(i=1;i<=n;i++)
     cnt2+=((a[i]-avg2)*(a[i]-avg2));
     cout<<min(cnt1,cnt2);
    return 0;
}

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

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

	int k;
	std::vector<int> p(5);
	std::cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> k;

	do {
		for (int i = 0; i < 4; ++i) {
			if (k < abs(p[i] - p[i + 1])) {
				std::cout << ":(";
				return 0;
			}
		}
	} while ( std::next_permutation(p.begin(), p.end()) );

	std::cout << "Yay!";
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var A, B, C, X, cnt int
	fmt.Scan(&A, &B, &C, &X)

	for a := 0; a <= A; a++ {
		for b := 0; b <= B; b++ {
			for c := 0; c <= C; c++ {
				if a*500+b*100+c*50 == X {
					cnt++
				}
			}
		}
	}
	fmt.Println(cnt)
}


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

using ll = long long;
using ull = unsigned long long;

template <typename T> istream &operator>>(istream &istr, vector<T> &vec) {
  for(T &x : vec) istr >> x;
  return istr;
}

template <typename T> ostream &operator<<(ostream &ostr, vector<T> &vec) {
  if(!vec.empty()) {
    ostr << vec.front();
    for(auto itr = ++vec.begin(); itr != vec.end(); itr++) ostr << " " << *itr;
  }
  return ostr;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> h(n);
  cin >> h;

  ll move_num = 0;
  ll max = 0;

  for(ll i = 0; i < n - 1; i++) {
    if(h[i + 1] <= h[i])
      move_num++;
    else
      move_num = 0;
    if(max < move_num) max = move_num;
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std; 
typedef   long long int ll;
int main () 
{
  ll k,a,b,e,f;
  cin>>k>>a>>b;
  e=a/k;f=b/k;
  if (k==1) {e=0;f=9;}
  if (f!=e||a%k==0||b%k==0) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int res = n;
    for (int i = 0; i <= n; i++)
    {
        int cnt = 0;
        int t = i;
        while (t > 0)
            cnt += t % 6, t /= 6;
        t = n - i;
        while (t > 0)
        {
            cnt += t % 9, t /= 9;
        }
        // cout << "cnt: " << cnt << endl;
        if (res > cnt)
        {
            res = cnt;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
using namespace std;

int main()
{
    int D, T, S;
    cin >> D >> T >> S;
  	assert(D >= 1 && D <= 10000);
  	assert(T >= 1 && T <= 10000);
  	assert(S >= 1 && S <= 10000);
    if (D <= S*T) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     return p.first>q.first;//descending by first
//     return p.first<q.first;//ascending by first
//     return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}

int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }
    return 0;
}
int clue() {

    string s;
    cin>>s;
    if(s=="ABC") {
        cout<<"ARC"<<endl;
    }
    else cout<<"ABC"<<endl;
    
    return 0;
}

Measured memory_bytes: 3608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] arr;
        int[][] memo;
        int n;

        int f(int i, int sum) {
            if (i == n) return sum % 10 == 0 ? 0 : sum;
            if (memo[i][sum] != -1) return memo[i][sum];
            int ans = f(i + 1, sum);
            ans = Math.max(ans, f(i + 1, (sum + arr[i])));
            return memo[i][sum] = ans;
        }

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            n = in.nextInt();
            arr = new int[n];
            memo = new int[n][10100];
            for (int[] temp : memo)
                Arrays.fill(temp, -1);
            for (int i = 0; i < n; i++) arr[i] = in.nextInt();
            out.println(f(0, 0));
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 26068
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path; vll A;
//***********//
int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	ll ans = 1000;
	for (i = 0; i < N-1; i++) {
		if (A[i] < A[i + 1]) {
			ll p = ans / A[i];
			ans -= p * A[i];
			ans += p * A[i + 1];
		}
	}
	co(ans);
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
		a[i]--;
	}
	vector<int> b(n);
	for(int i = 0; i < n; i++){
		b[a[i]] = i;
	}

	// for(int i = 0; i < n; i++){
	// 	cout << b[i]+1 << " ";
	// }printf("\n");

	int ans = 0;
	int cnt = 0;
	for(int i = 0; i < n; i++){
		// cout << b[i]+1 << " " ;
		if(i!=0&&b[i]<b[i-1]){
			ans=max(ans,cnt);
			cnt=1;
		}else cnt++;
		// cout << cnt <<endl;
	}
	// printf("\n");

	ans=max(ans,cnt);

	cout <<n-ans <<endl;

	return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	scanf("%d",&n);
	int lf=0,rf=0;

	char x[105];
	scanf("%s",&x);
	for(int i=0; i<n; i++) {
		if(x[i]=='(') {
			lf++;
		} else {
			if(lf>0){
				lf--;
			}else{
				rf++;
			}
		}
	}
	for(int i=0;i<rf;i++){
		printf("%c",'(');
	}
	printf("%s",x);
	for(int i=0;i<lf;i++){
		printf("%c",')');
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define SWAP(a,b) (a += b,b = a - b,a -= b)
int main(){
  int flag=1;
  int N;
  int i,j,b=0;;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  while(flag){
    flag=0;
    for(j=N-1;j>0;j--){
      if(A[j]<A[j-1]){
	SWAP(A[j],A[j-1]);
	b++;
	flag=1;
      }
    }
  }

  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i==N-1){
      break;
    }
    printf(" ");

  }
  printf("\n%d\n",b);

  return 0;
}



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

class SegmentTree {
public:
    vector<ll> table;
    int size;

    SegmentTree(int n) {
        size = 1;
        while (size <= n * 2) size *= 2;
        size *= 2;
        table = vector<ll>(size, 1LL << 59);
    }

    void assign(int pos, ll num) {
        return assign(pos, num, 0, 0, size/2-1);
    }

    void assign(int pos, ll num, int i, int left, int right) {
        if (left == right) {
            table[i] = num;
            return;
        }
        auto mid = (left + right) / 2;
        if (pos <= mid)
            assign(pos, num, i*2+1, left, mid);
        else
            assign(pos, num, i*2+2, mid+1, right);
        table[i] = min(table[2*i+1], table[2*i+2]);
    }

    ll query(int pl, int pr) {
        return query(pl, pr, 0, 0, size/2-1);
    }

    ll query(int pl, int pr, int i, int left, int right) {
        if (pl > right || pr < left)
            return 1LL << 59;
        else if (pl <= left && right <= pr)
            return table[i];
        else
            return
                min(query(pl, pr, i*2+1, left, (left+right)/2),
                    query(pl, pr, i*2+2, (left+right)/2+1, right));
    }
};


int N, M, s, t;
int D[101010];
vector<int> edges[101010];
ll dist[101010];


int main() {
    cin >> N >> M >> s >> t;
    s--, t--;

    REP(i, N) cin >> D[i];
    REP(i, s+1) D[i] = 0;

    REP(i, M) {
        int a, b; cin >> a >> b;
        edges[a - 1].push_back(b - 1);
    }

    SegmentTree st = SegmentTree(N);
    REP(i, N) st.assign(s, 0);

    REP(i, N) {
        ll d = st.query(i, N);
        for (auto m: edges[i])
            st.assign(m, min(st.query(m, m), d + D[m]));
    }

    ll ans = 1LL << 59;
    REP2(i, t, N) ans = min(ans, st.query(i, i));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12792