akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define MAX 100005
#define NIL -1
 
struct Node{ int p, l, r;};
struct Node T[MAX];
int n, H, D[MAX];
 
int getDepth(int u){
  int d = 0;
 
  while(T[u].p >= 0){
    u = T[u].p; 
    d++;
  }
 
  return d;
}
 
void print(int u){
  if(T[u].p == NIL)
    printf("node %d: parent = %d, depth = %d, root, ",u,T[u].p,D[u]);
   
  else if(T[u].l == NIL)
    printf("node %d: parent = %d, depth = %d, leaf, ",u,T[u].p,D[u]);
   
   
  else printf("node %d: parent = %d, depth = %d, internal node, ",u,T[u].p,D[u]);
   
   
  printf("[");
  int t; 
  t = u;
  if(T[t].l  != NIL){
    printf("%d",T[t].l);
    if(T[T[t].l].r == NIL)
      printf("]\n");
    else printf(",");
    t =T[t].l;
    while(T[t].r != NIL){
      printf(" %d",T[t].r);
 
      if(T[T[t].r].r == NIL)
    printf("]\n");
      else printf(",");
      t =T[t].r;
    }
  }
  else  printf("]\n");
}
 
main(){
  int i, j, d, v, c,l,r;
   
  scanf("%d",&n);
   
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = NIL;
  }
   
   for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
    for ( j = 0; j < d; j++ ){
      scanf("%d", &c);
      //make tree
      T[c].p = v;
       
      if(j == 0) T[v].l = c;
       
      else if (j >= 1)
    T[r].r = c;
      r = c;
      }
    }
   
 
  for ( i = 0; i < n; i++ ){
    D[i] = getDepth(i);
  }
 
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<int> x(m);
	for(int i = 0; i < m; ++i) {
		cin >> x[i];
	}
	
	if( n >= m ) {
		cout << 0 << endl;
		return 0;
	}
	
	sort(x.begin(), x.end());
	
	vector<int> diff(m - 1, 0);
	int ans = 0;
	for(int i = 0; i < m - 1; ++i) {
		diff[i] = abs(x[i] - x[i + 1]);
		ans += diff[i];
	}
	
	sort(diff.rbegin(), diff.rend());
	
	for(int i = 0; i < n - 1; ++i) {
		ans -= diff[i]; 
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <fstream>
#include <vector>
#include <algorithm>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define ll long long
#define pii pair<int,int>
#define add(a,b) ((int) (((ll) (a) + (b))%MOD))
#define mul(a,b) ((int) (((ll) (a) * (b))%MOD))
#define PB emplace_back
#define MP make_pair
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N;
string seg;
vector<pii> A, B, C;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    F0R(i,N) {
        cin >> seg;
        int min_bal = 2000002;
        int bal = 0;
        for (char j: seg) {
            if (j == '(') bal++;
            else bal--;
            min_bal = min(min_bal, bal);
        }
        pii te = MP(min_bal,bal);
        if (min_bal >= 0) A.PB(te);
        else if (bal >= 0) B.PB(te);
        else C.PB(MP(bal-min_bal, bal));
    }
    sort(B.begin(), B.end());
    int bal = 0;
    for (pii s: A) bal += s.S;
    RF0(i,B.size()) {
        if (bal+B[i].F < 0) {cout << "No\n"; return 0;}
        bal += B[i].S;
    }
    // cout << "bal: " << bal << '\n';
    sort(C.begin(), C.end());
    RF0(i,C.size()) {
        // cout << bal << ' ' << C[i].S - C[i].F << ' ' << C[i].S << '\n';
        if (bal + C[i].S - C[i].F < 0) {cout << "No\n"; return 0;}
        bal += C[i].S;
    }
    if (bal != 0) {cout << "No\n"; return 0;}
    cout << "Yes\n";
}

Measured memory_bytes: 11256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			String s = sc.nextLine();
			String[] str = s.split("[ ,.]");	//空白と,.でsplit
			int cnt = 0;
			for(int i=0;i<str.length;i++) {
				String a = str[i];
				if(2 < a.length()  && a.length() < 7) {
					if(cnt ==0) {
						System.out.print(a);
						cnt++;
					}
					else System.out.print(" " + a);
				}
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 26128
#include<stdio.h>
#include<string.h>

int main(void){
  char S[11], T[11], U[11];
  int A, B;

  scanf("%s %s",S, T);

  scanf("%d %d",&A, &B);

  scanf("%s",U);

  if(strcmp(U,S) == 0){
    A--;
  }
  else if(strcmp(U,T) == 0){
    B--;
  }

  printf("%d %d\n",A, B);

}


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

int main()
{
	int n, a[2][100];
	cin >> n;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	int m = 0, sum1 = 0, sum2;
	for (int i = 0; i < n; i++) {
		sum1 += a[0][i];
		sum2 = 0;
		for (int j = i; j < n; j++) {
			sum2 += a[1][j];
		}
		m = max(m, sum1 + sum2);
	}
	cout << m << endl;
	return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    cout << s;
    if(s[n-1] == 's')
    {
        cout << "es";
    }
    else {
        cout << "s";
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll mod = 1e9+7;
const int MAX = 3e5;
vector<vector<int>> g(MAX);
vector<ll> dp1(MAX,0);
vector<ll> dp2(MAX,0);
vector<ll> ans(MAX,0);
vector<ll> per(MAX,1);
int n;

void extgcd(ll a, ll b, ll &x, ll &y) {
  if(b == 0) {
    x = 1;
    y = 0;
    return;
  }
  extgcd(b, a%b, y, x);
  y -= a/b*x;
  return; 
}

ll mod_inverse(ll a, ll m = mod) {
  ll x, y;
  extgcd(a,m,x,y);
  return (m + x % m) % m;
}

ll dfs1(int u, int p) {
  ll res = 1;
  for(auto e : g[u]) {
    if(e != p) res += dfs1(e,u);
  }
  return dp1[u] = res;
}

ll dfs2(int u, int p) {
  ll res = 1;
  for(auto e : g[u]) {
    if(e != p) {
      (res *= dfs2(e,u)) %= mod;
      (res *= mod_inverse(per[dp1[e]])) %= mod;
    }
  }
  return dp2[u] = (res * per[dp1[u]-1]) % mod;
}

void dfs3(int u, int p, int q, ll r) {
  ll res = r;
  (res *= mod_inverse(per[q])) %= mod;
  for(auto e : g[u]) {
    if(e != p) {
      (res *= dp2[e]) %= mod; 
      (res *= mod_inverse(per[dp1[e]])) %= mod; 
    } 
  }
  ans[u] = (per[n-1] * res) % mod;
  for(auto e : g[u]) {
    if(e != p) {
      ll a = ans[u];
      (a *= per[dp1[e]]) %= mod;
      (a *= mod_inverse(per[n-1])) %= mod;
      (a *= per[n-1-dp1[e]]) %= mod;
      (a *= mod_inverse(dp2[e])) %= mod;
      dfs3(e,u,n-dp1[e],a);
    }
  }
}

int main(){
  cin >> n;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for(ll i = 1; i < MAX; i++) per[i] = (per[i-1] * i) % mod; 
  dfs1(0,-1);
  dfs2(0,-1);
  dfs3(0,-1,0,1);
  rep(i,n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 25588
a, b, c, k = map(int, input().split())
if k == 0:
    print(a - b)
else:
    a, b, c = b + c, a + c, a + b 
    if a - b <= 0:
        print(abs(a - b) * (-1) ** k)
    
    elif a - b > 0:
        print(abs(a - b) * (-1) ** (k - 1))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>

using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;

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


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

const ll mod = ll(1e9) + 7;
const int INF = 1<<29;
const ll lINF = 1l<<40;

int main(){
    int n,k;
    cin >> n >> k;
    ll ans;
    if (n==1) ans = k;
    else ans = k * (pow(k-1,n-1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,n,a[200010],ans,min;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	min=a[0];
	ans=a[1]-a[0];
	for(i=1;i<n;i++){
		if(a[i]<min) min=a[i];
		else if(a[i]-min>ans) ans=a[i]-min;
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 2624
#include <iostream>

using namespace std;

class AD{
public:
  int max(int a[],int n);
  int min(int a[],int n);
  long sum(int a[],int n);
};

int main(){
    int n;
    AD gh;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<gh.min(a,n)<<" "<<gh.max(a,n)<<" "<<gh.sum(a,n)<<endl;
    return 0;
}

int AD::max(int a[],int n){
    int ma=-1000000;
    for(int i=0;i<n;i++){
        if(a[i]>ma)ma=a[i];
    }
    return ma;
}

int AD::min(int a[],int n){
    int mi=1000000;
    for(int i=0;i<n;i++){
        if(a[i]<mi)mi=a[i];
    }
    return mi;
}

long AD::sum(int a[],int n){
    long su=0;
    for(int i=0;i<n;i++){
        su+=a[i];
    }
    return su;
}



Measured memory_bytes: 3132
input = readlines

n = input.shift.to_i
a = input.first.split(" ").sort_by {|point| -point.to_i}

alice = 0;
bob   = 0;

a.each_with_index do |point, index|
  if index % 2 == 0
    alice += point.to_i
  else
    bob   += point.to_i
  end
end

puts alice - bob

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint N, M;
	while (cin >> N >> M) {
		if (N == 0 && M == 0) {
			return 0;
		}
		vector<vector<lint>>A(M, vector<lint>(N));
		rep(i, M) {
			rep(j, N) {
				cin >> A[i][j];
			}
		}
		lint ans = -1;
		lint sum = 0;
		rep(i, N) {
			rep(j, M) {
				sum += A[j][i];
			}
			ans = max(ans, sum);
			sum = 0;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3392
#include<bits/stdc++.h>
using namespace std;
int main( )
{
    int a[1000];
    for(int i=0;i<5;i++)
        cin>>a[i];
    for(int i=0;i<5;i++){
        if(a[i]==0)
            cout<<i+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3596
import collections

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

v_odd = []
v_even = []

for i, v in enumerate(v):
    if i % 2:
        v_even.append(v)
    else:
        v_odd.append(v)

# Counterに入れて、valueの降順にソート
v_odd_c = collections.Counter(v_odd)
v_odd_c = sorted(v_odd_c.items(), key=lambda x: x[1], reverse=True)
v_even_c = collections.Counter(v_even)
v_even_c = sorted(v_even_c.items(), key=lambda x: x[1], reverse=True)

# counterに一つしかkeyがないと面倒なので0が0回出たことを明示的に示しておく
# 制約上、0はvとしてあり得ないので問題ない（必ず0は0回出る）
v_odd_c.append([0, 0])
v_even_c.append([0, 0])

if n != 2:
    o1 = v_odd_c[0]
    o2 = v_odd_c[1]
    e1 = v_even_c[0]
    e2 = v_even_c[1]

    # 最頻値が異なる場合
    if o1[0] != e1[0]:
        ans = n - o1[1] - e1[1]
    # 最頻値が等しい場合
    elif o1[0] == e1[0]:
        # o1,e2を採用する場合
        temp1 = n - o1[1] - e2[1]
        #o2, e1を採用する場合
        temp2 = n - o2[1] - e1[1]
        ans = min(temp1, temp2)

print(ans)


Measured memory_bytes: 25112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
	fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	
	ll n;
	cin>>n;
	ll a[n];
	scan(a, 0, n);
	ll ans = 0;
	forn(i, 1, n-1){
		vlli v;
		v.pb(a[i-1]);
		v.pb(a[i]);
		v.pb(a[i+1]);
		sort(all(v));
		if(v[1] == a[i])ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (i=a;i<n;i++)
#define per(i,a,n) for (i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE 1000001
#define ONLINE_JUDGE
#define rd
#define PI acos(-1)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
auto clk=clock(); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;

bitset<SIZE> vis;

vector<int> adj[SIZE];
vector<int> col;

ll get(ll n,ll k){
	ll mn=(k*k-k)/2;
	ll j=n-k;
	ll mx=(n*n+n)/2-(j*j+j)/2;
	return mx-mn+1;
}

int main(){
	#ifndef rd
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(20);
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif	

	

	// Write after this
	ll n,k,i,ans=0;
	cin>>n>>k;
	rep(i,k,n+2){
		//cout<<(2*n*i-i*i+i)/2<<endl;
		ans=(ans%mod+get(n,i)%mod)%mod;
	}
	cout<<ans;
	// End code here


	#ifndef ONLINE_JUDGE
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
	return 0;
}

Measured memory_bytes: 27108
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

vector<ll> v[MAXn];
ll dp[MAXn],ct[MAXn];
ll pw[MAXn];

struct tg{
  ll n0,n1,n2,t;
};
#ifdef brian
ostream& operator << (ostream &_s,const tg &_p){return _s<<"("<<_p.n0<<","<<_p.n1<<","<<_p.n2<<","<<_p.t<<")";}
#endif

map<ll,tg> mp[MAXn];// dp -> no/yes

inline void add(ll &a,ll b)
{
  a+=b;
  if(a>=MOD)a-=MOD;
}

tg mg(ll now,tg &a,tg &b)
{
  tg rt={0,0,0,now};
  if(b.t==now)swap(a,b);
  if(a.t!=now)
  {
    add(a.n0,a.n2);
    a.n2=0;
  }
  if(b.t!=now)
  {
    add(b.n0,b.n2);
    b.n2=0;
  }
  rt.n2=(a.n2*(b.n0+b.n1)+a.n1*b.n1)%MOD;
  rt.n1=(a.n1*b.n0+a.n0*b.n1)%MOD;
  rt.n0=(a.n0*b.n0)%MOD;
  return rt;
}

void dfs(ll now)
{
  mp[now][dp[now]]={1,1,0,now};
  for(ll k:v[now])
  {
    dp[k]=dp[now]+1;
    dfs(k);
    if(SZ(mp[k])>SZ(mp[now]))mp[now].swap(mp[k]);
    for(auto tmp:mp[k])
    {
      tg a=tmp.Y;
      auto it=mp[now].insert(tmp);
      tg &b=it.X->Y;
      if(!it.Y)
      {
        b=mg(now,a,b);
      }
      else if(b.t!=now)
      {
        add(b.n0,b.n2);
        b.n2=0;
        b.t=now;
      }
    }
    mp[k].clear();
    debug(now,k,mp[now]);
  }
}

int main()
{
    IOS();
    // E
    pw[0]=1;
    REP1(i,MAXn-1)pw[i]=2*pw[i-1]%MOD;
    ll n;
    cin>>n;
    REP1(i,n)
    {
      ll t;
      cin>>t;
      v[t].pb(i);
    }
    dfs(0);
    REP(i,n+1)ct[dp[i]]++;
    //ways[0]=2;tt[0]=1;
    ll ans=0;

    for(auto tmp:mp[0])
    {
      tg a=tmp.Y;
      ans=(ans+(a.n1)*pw[n+1-ct[tmp.X]])%MOD;
      debug(tmp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 84608
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        var hash = new HashSet<char>() {
            'A', 'C', 'G', 'T'
        };

        var max = 0;

        for(int i=0; i<s.Length; i++) {
            for(int j=i; j<s.Length; j++) {
                var ss = s.Substring(i, j - i + 1);
                if(ss.All(c => hash.Contains(c))) {
                    max = Math.Max(max, ss.Length);
                }
            }
        }

        return max;
    }
}


Measured memory_bytes: 13280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  
  cin >> N;
 
  int count = -1;
  rep (i, N) {
    int A = 0;
    cin >> A;
    
    int c = 0;
    while (A % 2 == 0) {
      c++;
      A /= 2;
    }
    
    if (count == -1 || c < count) {
        count = c;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3584
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int Q = sc.nextInt();
		
		TreeSet<Long> s = new TreeSet<>();
		s.add(Long.MIN_VALUE);
		s.add(Long.MAX_VALUE);
		for (int i = 0; i < A; i++) {
			s.add(sc.nextLong());
		}
		
		TreeSet<Long> t = new TreeSet<>();
		t.add(Long.MIN_VALUE);
		t.add(Long.MAX_VALUE);
		for (int i = 0; i < B; i++) {
			t.add(sc.nextLong());
		}
		
		for (int i = 0; i < Q; i++) {
			long start = sc.nextLong();
			
			long smax = s.higher(start);
			long smin = s.lower(start);
			
			long tmax = t.higher(start);
			long tmin = t.lower(start);
			
			long min = Long.MAX_VALUE;
			if (smin != Long.MIN_VALUE && tmin != Long.MIN_VALUE) {
				long tmp = start - Math.min(smin, tmin);
				min = Math.min(tmp, min);
			}
			
			if (smax != Long.MAX_VALUE && tmax != Long.MAX_VALUE) {
				long tmp = Math.max(smax, tmax) - start;
				min = Math.min(tmp, min);
			}
			
			if (smin != Long.MIN_VALUE && tmax != Long.MAX_VALUE) {
				long tmp1 = start - smin;
				long tmp2 = tmax - start;
				
				long sum = tmp1 + tmp2 + Math.min(tmp1, tmp2);
				min = Math.min(sum, min);
			}
			
			if (tmin != Long.MIN_VALUE && smax != Long.MAX_VALUE) {
				long tmp1 = start - tmin;
				long tmp2 = smax - start;
				
				long sum = tmp1 + tmp2 + Math.min(tmp1, tmp2);
				min = Math.min(sum, min);
			}
			
			System.out.println(min);
		}
	}
}


Measured memory_bytes: 108392
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;
int n;
ll a[200001];
ll fun(ll x){
	ll ret = 0;
	for(int i = 1; i <= n; i++){
	 	ret += abs(a[i]-(x+i));
 	}
 	return ret;
}
int main(){
	cin >> n;
	vector<ll> vec;
	for(int i = 1; i <= n; i++){
	 	cin >> a[i]; vec.pb(a[i]-i);
	}
	sort(vec.begin(),vec.end());
	ll res;
	if(vec.size()%2 == 0){
	 	res = fun((vec[vec.size()/2-1]+vec[vec.size()/2+1-1])/2);
	}
	else res = fun(vec[vec.size()/2+1-1]);
	cout << res << endl;
	return 0;
}                  


Measured memory_bytes: 6640
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=600600,M=10001000,oo=1000000000;
int i,j,k,n,m,w,h,nls,ch,ff,ans;
struct tree { tree *l,*r;int ma;} *rt1,*rt2,*cur,T[M];
struct cc {
	int x,y;
	bool operator < (const cc &n) const {
		return x<n.x;
	}
} A[N];
struct dd {
	int l,r,h,x;
	bool operator < (const dd &n) const {
		return r<n.r;
	}
} Up[N],Dn[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
tree *T_new() {
	cur++;
	cur->l=cur->r=T;
	cur->ma=-oo;
	return cur;
}
void T_add(int L,int R,int x,int y,tree *&k) {
	if (k==T) k=T_new();
	k->ma=max(k->ma,y);
	if (L==R) return;
	int mid=(L+R)>>1;
	if (x<=mid) T_add(L,mid,x,y,k->l);
	else T_add(mid+1,R,x,y,k->r);
}
int T_query(int L,int R,int l,int r,tree *k) {
	if (k==T) return -oo;
	if (L==l && R==r) return k->ma;
	int mid=(L+R)>>1;
	if (r<=mid) return T_query(L,mid,l,r,k->l);
	if (l>mid) return T_query(mid+1,R,l,r,k->r);
	return max(T_query(L,mid,l,mid,k->l),T_query(mid+1,R,mid+1,r,k->r));
}
void Add(dd *A,int &n,int x,int h) {
	if (n && x==A[n].x) A[n].h=min(A[n].h,h);
	else A[++n].x=x,A[n].h=h;
}
void get(dd *A,int &n,int h) {
	int i,j,k;
	A[0].h=-1;A[n+1].h=-1;
	A[0].x=0;A[n+1].x=w;
	for (i=1;i<=n;i++) {
		j=i-1;
		while (A[j].h>=A[i].h) j=A[j].l;
		A[i].l=j;
	}
	for (i=n;i;i--) {
		j=i+1;
		while (A[j].h>=A[i].h) j=A[j].r;
		A[i].r=j; 
	}
	for (i=1;i<=n;i++) A[i].l=A[A[i].l].x,A[i].r=A[A[i].r].x;
	int tmp=n;
	for (i=0;i<=tmp;i++) if (A[i].x<A[i+1].x) {
		n++;
		A[n].l=A[i].x;
		A[n].r=A[i+1].x;
		A[n].h=h;
	}
}
int Js(dd *A,int An,dd *B,int Bn) {
	cur=T;rt1=rt2=T;
	int i,j,k,ans=-oo;
	j=Bn;
	for (i=An;i;i--) {
		while (j && B[j].r>=A[i].r) {
			T_add(0,w,B[j].l,B[j].h,rt1);
			T_add(0,w,B[j].l,B[j].h-B[j].l,rt2);
			j--;
		}
		ans=max(ans,A[i].r-A[i].l+A[i].h+T_query(0,w,0,A[i].l,rt1));
		ans=max(ans,A[i].r+A[i].h+T_query(0,w,A[i].l,A[i].r,rt2));
	}
	return ans;
}
int work() {
	sort(A+1,A+n+1);
	int i,j,k,mid=h/2,up=0,dn=0;
	Dn[0].x=Up[0].x=-1;
	for (i=1;i<=n;i++) {
		if (A[i].y<=mid) Add(Dn,dn,A[i].x,mid-A[i].y);
		else Add(Up,up,A[i].x,A[i].y-mid);
	}
	get(Up,up,h-mid);
	get(Dn,dn,mid);
	sort(Dn+1,Dn+dn+1);
	sort(Up+1,Up+up+1);
	return max(Js(Dn,dn,Up,up),Js(Up,up,Dn,dn));
}
int main() {
	R(w);R(h);R(n);
	for (i=1;i<=n;i++) R(A[i].x),R(A[i].y);
	ans=work();
	swap(w,h);
	for (i=1;i<=n;i++) swap(A[i].x,A[i].y);
	ans=max(ans,work());
	printf("%d\n",ans*2);
}

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

signed main(){
	int N,A,B,C,D,E; cin>>N>>A>>B>>C>>D>>E;
	int M=min(A,min(B,min(C,min(D,E))));
	cout<<(N+M-1)/M+4<<endl;
}

Measured memory_bytes: 256
N, A, B = (int(i) for i in input().split())
V = [int(i) for i in input().split()]
V.sort()
V = V[::-1]

key = V[A-1]
cca = 0
ccb = 0
kk = 0

def combination(a, b):
    res = 1
    for i in range(a, a - b, -1):
        res = res * i
    for i in range(b):
        res = res // (i + 1)
    return res

su = 0
for i in range(A):
    su += V[i]
print(su/A)

for i in range(A):
    if V[i] == key:
        cca += 1
for i in range(N):
    if V[i] == key:
        ccb += 1

if cca == A:
    res = 0
    for i in range(A, B+1):
        res += combination(ccb, i)
else:
    res = combination(ccb, cca)
print(res)





    


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

ll n;
ll c[500],s[500],f[500];

ll fu(ll now, ll start){
    if(start == n-1 ){
        return now;
    }
    ll t = max( (ll)ceil( ( now - s[start]+0.0 )/f[start] ) , (ll)0);
    return fu(s[start] + t*f[start]+c[start],start+1);
}

int main() {
    std::cin >> n;
    for (int i = 0; i < n-1; i++) {
        std::cin >> c[i]>>s[i]>>f[i];
    }
    for (int i = 0; i < n; i++) {
        std::cout << fu(0,i) << std::endl;
    }
}


Measured memory_bytes: 256
# AtCoder Group Contest

# input process
N = int(input())
a_list = list(map(int, input().split()))

# initialization
a_list = sorted(a_list, reverse=True)
a_max = 0

# sum process
for i in range(2*N): # 2 ~ 2Nまで
    if not i%2==0:
        a_max += a_list[i]

print(a_max)


Measured memory_bytes: 37084
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
#include <iomanip> 
typedef long long LL;
const int mod = 1000000009;
using namespace std;
map<string, int>p;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, i; string s;
    while (cin >> n)
    {
        int max1 = 0; 
        for (i = 0; i < n; i++)
        {
            cin >> s;
            p[s]++;
            max1 = max(max1, p[s]);
        }
        for (auto i : p)
        {
            if (i.second == max1)
            {
                cout << i.first << '\n';
            }
        }
        
    }
}

Measured memory_bytes: 23808
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
//#define mod 1e18
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii map<int,int>
#define mll map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;
	int arr[6];
	memset(arr,0,sizeof(arr));
	for(int i = 0;i<5;i++){
		int a;
		cin>>a;
		arr[a]++;
	}
	
	for(int i = 1;i<6;i++){
		if(arr[i]==0){
			cout<<i;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 3636
def City():
  N = int(input())
  A = [int(x) for x in input().split()]
  B = [int(x) for x in input().split()]
  ans = 0
  for i in range(len(B)):
    if A[i]<=B[i]:
      ans += A[i]
      B[i] -= A[i]
      A[i] = 0
    else:
      ans += B[i]
      A[i] -= B[i]
      B[i] = 0
    if A[i+1]<=B[i]:
      ans += A[i+1]
      B[i] -= A[i+1]
      A[i+1] = 0
    else:
      ans += B[i]
      A[i+1] -= B[i]
      B[i] = 0
  print(ans)
if __name__=="__main__":
  City()


Measured memory_bytes: 19004
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
using namespace std;
int main() {
    int N; cin >> N;
    set<string> S;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;
}


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

int main(){
	int n;
	cin >> n;
	int a[n-1];
	int count[n];
	for(int i=0; i<n; ++i){
		count[i]=0;
	}
	
	for(int i=0; i<n-1; ++i){
		cin >> a[i];
		count[a[i]-1]++;
	}
	
	for(int i=0; i<n; ++i){
		cout << count[i] << " " << endl;
	}
	
}


Measured memory_bytes: 5196
import sys
input = sys.stdin.readline

O = list(input())
E = list(input())

N = len(O) + len(E) - 2

pswd = ['' for _ in range(N)]
for i in range(N):
    pswd[i] = E.pop(0) if (i+1) % 2 == 0 else O.pop(0)
print(str(pswd).replace('[','').replace(']','').replace(',','').replace("'",'').replace(' ',''))


Measured memory_bytes: 38512
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

int n,l;
string ans;
vector<string> str;

int main(){
	cin>>n>>l;
	str=vector<string>(n);
	for(int i=0;i<n;i++) cin>>str[i];
	sort(str.begin(),str.end());
	for(int i=0;i<n;i++) ans+=str[i];
	cout<<ans<<endl;
}

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

int main() {

	int h, w, k; cin >> h >> w >> k;
	vector<string> c(h);
	for (int i = 0; i < h; i++) {
		cin >> c[i];
	}
	int n = h + w;	
	int ans = 0;
	for (int bit = 0; bit < (1 << n); ++bit) {
		vector<bool> red(n, false);
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) {
				red[i] = true;
			}
		}
		int cnt = 0;
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				if (red[y] || red[h + x]) continue;
				if (c[y][x] == '#') cnt++;				
			}			
		}
		if (cnt == k) ans++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    ll ans=0;
    ll min_=1;
    for(int i=0; i<N; i++){
        ll a;
        cin >> a;

        ll tmp=(a-1)/min_;
        if(tmp==0){
            min_=max(a+1, min_);
        }else{
            ans+=tmp;
            if(i==0){
                min_=2;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace ABC123
{
    class B
    {
        static void Main(string[] args)
        {
            int res = 0;
            int max = 10;
            int ll = 0;
            int l = 0;

            for (int i = 0; i < 5; i++)
            {
                ll = int.Parse(Console.ReadLine());
                l = ll % 10;
                if (0 < l)
                {
                    max = Math.Min(max, l);
                    res += ll + (10 - l);
                }
                else
                {
                    res += ll;
                }
            }
            Console.WriteLine(res - (10 - max));
        }
    }
}

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

#define fast                     ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll                       long long 
#define mk                       make_pair
#define pb                       push_back
#define pob                      pop_back
#define pii                      pair<int,int>
#define vi                       vector<int>
#define vii                      vector<pii>
#define mi                       map<int,int>
#define mii                      map<pii,int>
#define all(a)                   (a).begin(),(a).end()
#define x                        first
#define y                        second
#define sz(x)                    (int)x.size()
#define endl                     '\n'
#define loop(i,a,b)              for(int (i)=(a);(i)<(b);(i)++)

using namespace std;

vi g[110000],dp(110000,-1);

int dfs(int n){
    if(dp[n]!=-1) return dp[n];
    int ans = 0 ;
    loop(i,0,sz(g[n])){
        ans = max(ans,dfs(g[n][i])+1);
    }
    return dp[n]=ans;
}

int main(){
    int n , m ; cin >> n >> m ;
    loop(i,0,m){
        int a , b ; cin >> a >> b;
        a--;b--;
        g[a].pb(b);
    }

    int ans =0 ; 
    loop(i,0,n){
        ans = max(ans,dfs(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

bool isprime[110];
int cnt[110];
vector<int> prime;
int n;

void init() {
  memset(isprime, true, sizeof(isprime));
  for (int i=2;i<110;i++) {
    if (isprime[i]) {
      prime.push_back(i);
      for (int j=2*i;j<110;j+=i) {
        isprime[j] = false;
      }
    }
  }
}

void solve() {
  init();
  for (int i=0;i<=n;i++) {
    int tmp = i;
    for (int j=0;j<prime.size() && tmp > 1;j++) {
      while (tmp % prime[j] == 0) {
        cnt[j]++;
        tmp /= prime[j];
      }
    }
  }

  vector<int> factor = {2, 4, 14, 24, 74};
  vector<int> factorCnt(5);
  for (int i=0;i<prime.size();i++) {
    for (int j=0;j<factor.size();j++) {
      if (cnt[i] >= factor[j]) {
        factorCnt[j]++;
      }
    }
  }



  int ans = factorCnt[4] +
            factorCnt[3] * max(0, factorCnt[0] - 1) +
            factorCnt[2] * max(0, factorCnt[1] - 1) +
            factorCnt[1] * max(0, factorCnt[1] - 1) * max(0, factorCnt[0] - 2) / 2;
  cout << ans << endl;
}

int main() {
  cin >> n;
  solve();
}


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

int main(){
	int q;
	deque<int> Q;
	cin >> q;
	while(q--){
		int a,b,c;
		cin >> a >> b;
		if(a == 0){
			cin >> c;
			if(b) Q.push_back(c);
			else Q.push_front(c); 
		}
		else if(a == 1) cout << Q[b] <<endl;
		else{
			if(b) Q.pop_back();
			else Q.pop_front();
		}
	}
	return 0;
}



Measured memory_bytes: 4564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scan = new Scanner(System.in)) {
			int width = scan.nextInt();
			int height = scan.nextInt();
			int x = scan.nextInt();
			int y = scan.nextInt();
			int radius = scan.nextInt();

			if((x + radius) <= width && (y + radius) <= height && (x - radius) >= 0 && (y - radius) >= 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}

}

Measured memory_bytes: 26300
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){
   int n;
   I(n);
   char ar[n+2];
   SC("%s", ar + 1);
   int dp[n+2];
   SET(dp);
   for(int i=1; i<=n;i++){
       dp[i] = dp[i-1] + (ar[i] == 'W');
   }
    int ans = n;
   for(int i= 1; i<= n;i++){
       int res = dp[i-1];
       int baki = dp[n] - dp[i];
       int ko = n- i;
        ans = min(ans, res + ( ko -baki));
   }
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5152
from collections import defaultdict

N, Ma, Mb = map(int, input().split())

dp = [defaultdict(lambda : float('inf')) for _ in range(2)]
zero = float('inf')

dp[0][0] = dp[1][0] = 0

for _ in range(N) :
    a, b, c = map(int, input().split())
    d = a * Mb - b * Ma
    if d == 0 :
        zero = min(zero, c)
    else :
        i = 0 if d > 0 else 1
        d = abs(d)
        item = list(dp[i].items())[::-1]
        for k, v in item :
            dp[i][k+d] = min(dp[i][k+d], dp[i][k] + c)

ret = zero       
for k, v in dp[0].items() :
    if k in dp[1] and k != 0 :
        ret = min(ret, v + dp[1][k])
        
if ret == float('inf') :
    print(-1)
else :
    print(ret)

Measured memory_bytes: 43248
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void show (int *pos, int n){
	int i;
	for(i=1;i<=n;i++){
		printf("%d\n",pos[i]);
	}
}

int main(int argc, char *argv[]){
	int n,m;
	int i;
	int num;
	int a[2019];
	int *pos;

	memset(a,0,sizeof(a));

	scanf("%d",&n);
	pos = calloc(n+1,sizeof(int));

	for(i=1;i<=n;i++){
		scanf("%d",&num);
		a[num]=i;
		pos[i]=num;
	}

	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d",&num);
		if(a[pos[num]+1]==0 && pos[num]<2019){
			pos[num]++;
			a[pos[num]]=num;
			a[pos[num]-1]=0;
		}
	}

	show(pos,n);

	exit(0);
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  //桁ごとに偶数個あるかどうかみるかんじ
  //とはいえ10^12すべてカウントは無理なので効率化
  //0 7
  //000 0
  //001 1 
  //010 2 
  //011 3
  //100 4
  //101 5
  //110 6
  //111 7
  //---
  //000 1-7
  //001 2-7
  
  //1111011=123
  
  //1%2=1 7%2=1 7/2=3 3+1=4
  //1/2=0 0%2=0, 7/2=3 3%2=1 3/2=1
  //スタートが何番目で、ゴールが何番目なのかを桁ごとに把握すればいけるかも
  ll A,B;
  cin>>A>>B;
  if(B==0){
    cout<<0<<endl;
    return 0;
  }
  //桁数知りたい
  ll k=0,b=B;
  while(b>0){
    b/=2;
    k++;
  }
  ll tmp=1,a=A;
  b=B;
  vector<ll> S(k,0), G(k,0);
  for(int i=0; i<k; i++){
    tmp*=2;
    //スタートで1を偶数個スルーしたのかどうか
    ll x=a%tmp, y=b%tmp;
    if(x<tmp/2)
      S[i]=0;
    else if(x%2==1)
      S[i]=1;
    else
      S[i]=0;
    //ゴールで、1を偶数個とったのかどうか
    if(y<tmp/2)
      G[i]=0;
    else if(y%2==0)
      G[i]=1;
    else
      G[i]=0;
  }
  //1の位だけ補正
  //0101010101....010101　みたいな感じ
  //
  ll z=B-A+1;
  if(z%4==0)
    S[0]=0, G[0]=0;
  else if(z%4==1)
    G[0]=0;
  else if(z%4==2)
    S[0]=0, G[0]=1;
  else
    G[0]=1;
  ll ans=0;
  for(int i=k-1; i>=0; i--){
    ans*=2;
    if(S[i]+G[i]==1)
      ans++;
//    cout<<"i:"<<i<<" S:"<<S[i]<<" G:"<<G[i]<<" ans:"<<ans<<endl;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int arr[3];int s=0;
  for(int i=0;i<3;i++)
  {
    cin>>arr[i];s+=arr[i];
  }
  int mid = s/2;
  int temp;
  for(int i=0;i<3;i++)
  {
    if(arr[i]<mid)
      temp+=arr[i];
    if(arr[i]>mid)
      continue;
  }
  if(temp==mid)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}
  
  

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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    string S;
    cin >> S;
    if(S[0] == S[1] && S[0] == S[2] && S[1] == S[2]){
        cout << "No" << endl;
    } else {
        cout <<  "Yes" << endl;
    }
}


Measured memory_bytes: 256
# Contest: AtCoder Beginner Contest 145 (https://atcoder.jp/contests/abc145)
# Problem: B: Echo (https://atcoder.jp/contests/abc145/tasks/abc145_b)

def rint():
    return int(input())


def rints():
    return list(map(int, input().split()))


n = rint()
s = input()
print('Yes' if n % 2 == 0 and s[:n // 2] == s[n // 2:] else 'No')


Measured memory_bytes: 38256
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
// your code goes here
int r,c;
scanf("%d %d",&r,&c);
int as[101]={0},a;
for(int i=0;i<r;i++){
	int sum=0;
	for(int j=0;j<c;j++){
		scanf("%d",&a);
		as[j]+=a;
		sum+=a;
		printf("%d ",a);
	}
	printf("%d\n",sum);
}
int sum=0;
for(int i=0;i<c;i++){
	sum+=as[i];
	printf("%d ",as[i]);
}
printf("%d\n",sum);
return 0;
}


Measured memory_bytes: 3224
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
def LILI(n): return [LI() for _ in range(n)]
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    A = LI()
    B = LI()
    C = LI()


    prev = A[0]
    manzoku = B[prev-1]
    for i in range(1,N):
        ryouri = A[i]
        manzoku += B[ryouri-1]
        if prev+1 == A[i]:
            manzoku += C[prev-1]
        prev = A[i]

    print(manzoku)


main()

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

ll D = 365;
ll C[26] = {};
ll S[365][26] = {};

ll score(const vector<ll> &ans){
  ll ret = 0;
  ll last[26] = {};
  rep(i,D){
    ret += S[i][ans[i]];
    last[ans[i]] = i+1;
    rep(j,26){
      ret -= C[j] * (i+1 - last[j]);
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  cin>>D;
  rep(i,26){
    cin>>C[i];
  }
  rep(i,D){
    rep(j,26){
      cin>>S[i][j];
    }
  }

  vector<ll> ans(D);
  rep(i,D){
    ans[i] = i%26;
  }
  cerr << "score:" << score(ans) << endl;

  rep(i,D){
    cout<<ans[i] + 1 << endl;
  }
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  long long sum = 0;
  for (auto n : s) {
    sum += (n-'0');
  }
  if (sum % 9 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3660
class uft():
    def __init__(self,n):
        #pは代表元か-1
        self.p=[ -1 for i in range(n)]
        #ランク　木の深さ
        self.r=[ 1 for i in range(n)]
        #要素数
        self.e=[ 1 for i in range(n)]
        
    def find(self,x):
        if(self.p[x]==-1):
            return x
        else:
            self.p[x]=self.find(self.p[x])
            return self.find(self.p[x])
        
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if(x==y):
            return
        
        if(self.r[x]>self.r[y]):
            tmp=x
            x=y
            y=tmp
        
        if(self.r[x]==self.r[y]):
            self.r[y]+=1
        
        self.e[y]+=self.e[x]
            
        if(x!=y):
            self.p[x]=y
        return
    
    def tsize(self,x):
        return self.e[self.find(x)]
n,m=map(int,input().split())

uf=uft(n)
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    uf.unite(x,y)
oya=0

for i in range(n):
    if(uf.p[i]==-1):
        oya+=1
print(oya-1)

Measured memory_bytes: 79520
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');
            //int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            var a = long.Parse(str[0]);
            var b = long.Parse(str[1]);
            var n = long.Parse(str[2]);

            long mae = a * n / b;
            long usiro = n / b;

            long max = mae - a * usiro;

            if (b <= n)
            {
                max = Max(max,a * (b - 1) / b);
                
            }

            /*for (long i = 1; i < n; i++)
            {
                mae = a * i / b;
                usiro = i / b;
                long temp = mae-a*usiro;
                Console.WriteLine("{0} notoki {1}", i, temp);
                max = Max(temp, max);
                if (i > b) break;
            }*/

            Console.WriteLine(max);

            //ここまで
        }

        static long Max(long a, long b)
        {
            if (a > b) return a;
            else return b;
        }


    }

}


Measured memory_bytes: 27540