akhauriyash/Code-Regression huggingface dataset:
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    string s;
    cin>>s;

    string s1="";
    lli N=s.length(),i,j;

    rep(i,0,N)
    {
        if(s[i]!='x')
        {
            s1.push_back(s[i]);
        }
    }

    string s2=s1;
    reverse(s2.begin(),s2.end());

    if(s1.length()==0)
    {
        cout<<0;
        exit(0);
    }

    if(s1!=s2)
    {
        cout<<-1;
    }
    else
    {
        vlli V;
        V.pb(-1);

        rep(i,0,N)
        {
            if(s[i]!='x')
            {
                V.pb(i);
            }
        }
        V.pb(N);

        /*rep(i,0,V.sz())
        {
            cout<<V[i]<<' ';
        }
        nl;*/

        lli Size=V.sz();

        lli Ans=0;
        rep(i,0,Size/2)
        {
            Ans+=abs(V[i+1]-V[i]-(V[Size-i-1]-V[Size-i-2]));
            //cout<<Ans<<' ';
        }
        //nl;

        cout<<Ans;
    }






 return 0;
}


Measured memory_bytes: 1736
N = int(input())
S = input()
left = 0
right = 0
cnt1 = 0
for i in S:
    if i == '(':
        left += 1
    else:
        right += 1
    cnt1 = max(cnt1, right - left)
left = 0
right = 0
cnt2 = 0
for i in S[::-1]:
    if i == ')':
        left += 1
    else:
        right += 1
    cnt2 = max(cnt2, right - left)
ans = '(' * max(0, cnt1) + S + ')' * max(0, cnt2)
print(ans)

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
  int64_t x;
  mint(int64_t x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(int64_t t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  //for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

const int N = 25;
const int X = 1<<21;

//head

int n;
int a[N][N];
mint dp[X];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, n) rep(j, n) cin >> a[i][j];

  rep(i, 1<<n) {
    int u = __builtin_popcount(i);
    if(!u) {
      dp[0] = 1;
      continue;
    }
    u--;
    rep(j, n) if(i>>j&1 and a[u][j]) dp[i] += dp[i^(1<<j)];
  }
  cout << dp[(1<<n)-1] << endl;
}

Measured memory_bytes: 20024
#include<stdio.h>
int main()
{
	int n,k,a[1000],i,j,b,c;
	scanf("%d %d",&n,&k);
	c=0;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(a[i]>=a[j]){
				b=a[i];
				a[i]=a[j];
				a[j]=b;
			}
		}
	}
	for(i=0;i<k;i++){
		c=c+a[i];
	}
	printf("%d\n",c);
	return 0;
}
	

Measured memory_bytes: 1716
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <string>
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> a;
    for(int i = 0; i<n; i++){
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(a.begin(),a.end());
    
    if(n==1){
        int ans;
        ans = floor(a[0]/pow(2,m));
        cout << ans << endl;
    }
    else{
        while(m>0){
            while(a[n-1] >= a[n-2] and m > 0){
                a[n-1] = floor(a[n-1]/2);
                m -= 1;
            }
            int temp;
            temp = a[n-1];
            a.pop_back();
            a.insert(lower_bound(a.begin(),a.end(),temp),temp);
        }
        long long ans = 0;
        for(int i = 0; i<n; i++){
            ans += a[i];
        }
        cout << ans << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<double> V(N);
  for (int i=0 ;i<N ; i++)
    cin >> V.at(i);
  for (int i=0 ; i<N ; i++)
    V.at(i)=1/V.at(i);
  double answer=0;
  for (int i=0 ; i<N ; i++)
    answer+=V.at(i);
  answer=1/answer;
  cout << answer << endl;
}


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

struct Team{
	string name;
	int score;
	bool operator>(const Team &t) const { return (score > t.score); }
};

int main(void){
	bool bFirst = true;
	while( true ){
		int n;
		vector<Team> vTeam;

		cin >> n;
		if( n == 0 )
			break;

		if( !bFirst )
			cout << '\n';
		else
			bFirst = false;

		for(int i = 0 ; i < n; ++i){
			Team tmp;
			int win, lose, draw;

			cin >> tmp.name >> win >> lose >> draw;
			tmp.score = win * 3 + lose * 0 + draw * 1;
			vTeam.push_back( tmp );
		}
		stable_sort( vTeam.begin(), vTeam.end(), greater<Team>() );
		
		for(unsigned int i = 0; i < vTeam.size(); ++i)
			cout << vTeam[i].name << ',' << vTeam[i].score << '\n';
	}
	return 0;
}

Measured memory_bytes: 0
a,b,c = map(int,input().split())
d = 0
if a == b:
    while a != b+1:
        if c%a == 0:
            d += 1
            a += 1
        else:
            a += 1
elif b == c:
    while a != b+2:
        if c%a == 0:
            d += 1
            a += 1
        else:
            a += 1        
else:
    while a != b:
        if c%a == 0:
            d += 1
            a += 1
        else:
            a += 1
print(d)


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

typedef unsigned long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

void f()
{
    ll n,a,b,p,ans=1;
    cin>>n>>a>>b;
    if(a==0)
    {
        cout<<0<<nl;
        return;
    }
    if(n<=a && n<=a+b)
    {
        cout<<n<<nl;
        return;
    }
    if(n>=a && n<=a+b)
    {
        cout<<a<<nl;
        return;
    }
    p=n/(a+b);
    n%=(a+b);
    ans=p*a;
    if(n<=a)
      ans+=n;
    else
      ans+=a;
    cout<<ans<<nl;
}

int main()
{
    su;
    ///tt
    f();
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int a[100005];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int ans = (int) 1e9;
    for (int i = 1; i <= n - k + 1; i++)
    {
        int L = a[i], R = a[i + k - 1];
        if (L < 0 && R < 0) ans = min(ans, -L);
        if (L >= 0 && R >= 0) ans = min(ans, R);
        if (L < 0 && R >= 0) ans = min(ans, min(-L * 2 + R, R * 2 - L));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 
#define MODB  998244353

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

//つねに10億7などの剰余をとる構造体
//参考: https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//参考: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod  = MODA;
struct modint {
	ll x;
	modint (ll x):x(x%mod){}
	modint& operator+=(const modint a){
		(x += a.x ) %= mod;
		return *this;
	}
	modint& operator-=(const modint a){
		(x -= a.x ) %= mod;
		if (x < 0) x += mod;
		return *this;
	}
	modint& operator*=(const modint a){
		(x *= a.x ) %= mod;
		return *this;
	}
	modint& operator/=(modint a){ //除算のみO(log mod)なので注意。割る数が小さいならnCrのinvを使うこと
		ll exp = mod - 2;
		while(exp > 0){ 
			if(exp & 1) *this *= a.x;
			a *= a.x;
			exp >>= 1;
		}
		return *this;
	}
	modint operator+(const modint a) const{
		modint res(*this);
		return res+=a;
	}
	modint operator-(const modint a) const{
		modint res(*this);
		return res-=a;
	}
	modint operator*(const modint a) const{
		modint res(*this);
		return res*=a;
	}
	modint operator/(const modint a) const{
		modint res(*this);
		return res/=a;
	}
};
modint modpow(modint x, ll n){
	modint res=1;
	while(n > 0){
		if(n & 1) res = res * x.x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

int main() {
	modint ans = 0;
	ll tmp;
	int n; cin >> n;
	vector<ll> a(n);
	cin >> a;
	modint su = 0;
	REP(i, n) su += a[i];
	modint ss = 0;
	REP(i, n){
		ss += a[i];
		ans += a[i] * (su - ss).x;
	}
	cout << ans.x << endl;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,r;
    cin >> n >> m >> r;
    vector<int>rr(r);
    
    for(int i=0;i<r;i++)cin >>rr[i];
    sort(rr.begin(),rr.end());
    vector<vector<long> >distance(n+1,vector<long>(n+1,1<<30));
    for(int i=0;i<m;i++){
        int a,b,c;
        cin >> a >> b >> c;
        distance[a][b] = c;
        distance[b][a] = c;
    }
for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            
                distance[i][j] = min(distance[i][j] , distance[i][k] + distance[k][j]);
            
        }
    }
}
    long ans = 1<<30;

    do{
        long tmp = 0;
        for(int i=0;i<r-1;i++){
            tmp += distance[rr[i]][rr[i+1]];

        }

        ans = min(ans,tmp);

    }while(next_permutation(rr.begin(),rr.end()));

    cout << ans << endl;

}

Measured memory_bytes: 3944
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    s = input()
    n = len(s)
    if s[0] == s[1]:
        print(1,2)
        exit()
    for i in range(2,n):
        if s[i] == s[i-1]:
            print(i,i+1)
            exit()
        elif s[i] == s[i-2]:
            print(i-1,i+1)
            exit()

    print(-1,-1)


    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 75068
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <unordered_map>

#define MAX_N 100

using namespace std;

int main() {
  unordered_map<string, int> B;
  unordered_map<string, int> R;
  int N, M;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    B[s] += 1;
  }
  cin >> M;
  for (int i = 0; i < M; ++i) {
    string s;
    cin >> s;
    R[s] += 1;
  }
  int res = 0;
  for (auto &b : B) {
    int r_cnt = 0;
    if (R.count(b.first)) {
      r_cnt = R[b.first];
    }
    res = max(res, (int)(b.second - r_cnt));
  }
  printf("%d\n", res);
}

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

int main() {
  int N, M;
  vector<int> A;
  cin >> N >> M;

  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }

  vector<int> group;
  int res = 0;
  int cnt = 0;

  //group.push_back(A[0]);
  do {
    for(int j = 0; j < M; j++) {
      group.push_back(A[cnt%N]);
      //cout << A[cnt%N] << endl;
      cnt++;
    }
    sort(group.begin(), group.end());
    res += group[M-1] - group[0];
    group.clear();
  } while(cnt % N != 0);
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, m;
  scanf("%d%d", &n, &m);
  while(m%n!=0){
    if(n > m/2){
      n = m;
      break;
    }
    n++;
  }
  printf("%d\n", m / n);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
    cout<<"YES";
  }else{
    cout<<"NO";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
namespace mint {
  constexpr int md = 1e9 + 7;
  inline void add (int &a, int b) {
    a += b; if (a >= md) a -= md;
  }
  inline void sub (int &a, int b) {
    a -= b; if (a < 0) a += md;
  }
  inline int sum (int a, int b) {
    add(a, b); return a;
  }
  inline int dif (int a, int b) {
    sub(a, b); return a;
  }
  template<class... A>
  inline int prod (A... args) {
    long long ret = 1;
    for (int a : initializer_list<int>{args...}) {
      assert(a >= 0);
      ret *= a;
      ret %= md;
    }
    return (int)(ret % md);
  }
  inline void mul (int &a, int b) {
    a = prod(a, b);
  }
  inline int inv (int a) {
    a %= md;
    if(a < 0) a += md;
    int b = md, u = 0, v = 1;
    while (a) {
      int t = b / a;
      b -= a * t; swap(a, b);
      u -= v * t; swap(u, v);
    }
    assert(b == 1);
    if(u < 0) u += md;
    return u;
  }
  inline int quat (int a, int b) {
    return prod(a, inv(b));
  }
  inline void div (int& a, int b) {
    a = quat(a, b);
  }
  inline int pow (int a, long long b) {
    int res = 1;
    for (; b; b >>= 1) {
      if (b & 1) mul(res, a);
      mul(a, a);
    }
    return res;
  }
}
struct factorials {
  const int sz;
  const vector<int> fct, fnv;
  factorials (int n) :
    sz(n),
    fct([&](){
        vector<int> ret(n, 1);
        for (int i = 1; i < n; i++) ret[i] = mint::prod(ret[i - 1], i);
        return ret;
      }()),
    fnv([&](){
        vector<int> ret(n); ret[n - 1] = mint::inv(fct[n - 1]);
        for (int i = n - 2; i >= 0; i--) ret[i] = mint::prod(ret[i + 1], i + 1);
        return ret;
      }())
    {
    }
  inline int binom (int n, int k) {
    assert(0 <= k && k <= n && n < sz);
    return mint::prod(fct[n], fnv[k], fnv[n - k]);
  }
};
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  factorials fct(2 * n);
  int p = mint::quat(a, a + b);
  int q = mint::quat(b, a + b);
  int ret = 0;
  for (int t = 0; t < 2; t++) {
    for (int j = 0; j < n; j++) {
      mint::add(ret, mint::prod(
          mint::pow(p, n),
          mint::pow(q, j), 
          fct.binom(n - 1 + j, j),
          mint::sum(n, j)
        ));
    }
    swap(p, q);
  }
  int x = mint::quat(a + b + c, a + b);
  mint::mul(ret, x);
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int main (void) {
    int N;

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

    int ans = 1;
    int p = 0;
    for (int i = 0; i < N; i++) {
        if (i == N - 1) {
            continue;
        }
        if (p == 0) {
            if (A[i] < A[i + 1]) {
                p = 1;
            } else if (A[i] > A[i + 1]) {
                p = -1;
            }
        } else if (p == 1) {
            if (A[i] > A[i + 1]) {
                p = 0;
                ans++;
            }
        } else {
            if (A[i] < A[i + 1]) {
                p = 0;
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
int main()
{
	SPEED
	int n, count1 = 0, count0 = 0;
	cin >> n;

	string s;
	char ch;

	for (int i = 0; i < n; ++i)
	{
		cin >> ch;
		if (ch=='W')
		{
			s += '1';
			count1++;
		}
		else
		{
			s += '0';
			count0++;
		}
	}

	if (count0==0 || count1==0)
	{
		cout << 0;
		return 0;
	}

	int cost_swap = 0;
	for (int i = 0; i < count0; ++i)
	{
		if (s[i]=='1')
		{
			cost_swap++;
		}
	}

	cout << cost_swap;

	// //convert all 1
	// int cost1 = 0;
	// for (int i = 0; i < n; ++i)
	// {
	// 	if (s[i]=='0')
	// 	{
	// 		cost1++;
	// 	}
	// }

	// //convert all 0
	// int cost2 = 0;
	// for (int i = 0; i < n; ++i)
	// {
	// 	if (s[i]=='1')
	// 	{
	// 		cost2++;
	// 	}
	// }

	// //..000111..
	// int prefix_cost_converting_0[n+1] = {0};

	// for (int i = 0; i < n; ++i)
	// {
	// 	if (s[i]=='1')
	// 	{
	// 		prefix_cost_converting_0[i+1] = 1 + prefix_cost_converting_0[i];
	// 	}
	// 	else
	// 	{
	// 		prefix_cost_converting_0[i+1] = prefix_cost_converting_0[i];
	// 	}
	// }

	// int suffix_cost_converting_1[n+2] = {0};

	// for (int i = n-1; i >= 0; --i)
	// {
	// 	if (s[i]=='0')
	// 	{
	// 		suffix_cost_converting_1[i+1] = 1 + suffix_cost_converting_1[i+2];
	// 	}
	// 	else
	// 	{
	// 		suffix_cost_converting_1[i+1] = suffix_cost_converting_1[i+2];
	// 	}
	// }

	// int cost3 = min(cost1, cost2)
	// for (int i = 0; i < n; ++i)
	// {
	// 	int cost = prefix_cost_converting_0[i+1] + suffix_cost_converting_1[i+2];
	// 	cost3 = min(cost3, cost);
	// }

	// cout << cost3;

	return 0;
}

Measured memory_bytes: 3756
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
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 print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll ue = 0, migi = 0;
    rep(i,0,N){
        if(S[i] >= 'A' && S[i] <= 'M'){
            ue++;
        }else if(S[i] >= 'N' && S[i] <= 'Z'){
            ue--;
        }else if(S[i] >= 'a' && S[i] <= 'm'){
            migi++;
        }else{
            migi--;
        }
    }
    ll sz = abs(ue) + abs(migi);
    print(sz);
    rep(i,0,abs(ue)){
        if(ue > 0){
            cout << 'A';
        }else{
            cout << 'N';
        }
    }
    rep(i,0,abs(migi)){
        if(migi > 0){
            cout << 'a';
        }else{
            cout << 'n';
        }
    }
    cout << endl;

    
}


Measured memory_bytes: 3352
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

int a, b, A, B;
int group[4] = { 4,6,9,11 };
int main(void) {
	cin >> a >> b;
	if (a == 2)A = 2;
	else {
		FOR(i, 0, 4) {
			if (a == group[i])A = 1;
		}
	}
	if (b == 2)B = 2;
	else {
		FOR(i, 0, 4) {
			if (b == group[i])B = 1;
		}
	}
	if (A == B)ct("Yes");
	else ct("No");

	return 0;
}

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

int main() {

  int d[11][101] = {0};

  for ( long long int i = 0; i < ( 1 << 10 ); i++ ) {
    long long int k = i;
    long long int cnt = 0;
    long long int sum = 0;
    long long int j = 0;
    while( k > 0 ) {
      if ( k % 2 ) {
	sum += j;
	cnt++;
      }
      j++;
      k /= 2;
    }
    d[cnt][sum]++;
  }

  long long int n, s;

  while( cin >> n >> s, n ) {
    cout << d[n][s] << endl;
  }

  return 0;

}

Measured memory_bytes: 1160
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    int N;
    cin>>N;
    vector<string> S(N);
    REP(i,N) cin>>S[i];
    int amari_L=0;
    int amari_R=0;
    vector<tuple<int,int,int>> LRI,RLI;
    REP(i,N){
        int N_S=S[i].size();
        int stack=0;
        int hidari=0;
        int migi=0;
        REP(j,N_S){
            if(S[i][j]=='(') stack++;
            else{
                if(stack!=0) stack--;
                else{
                    migi++;
                }
            }
        }
        hidari=stack;
        amari_L+=hidari;
        amari_R+=migi;
        if(hidari>=migi){
            RLI.push_back(make_tuple(migi,hidari,i));
        }else{
            LRI.push_back(make_tuple(hidari,migi,i));
        }  
    }
    if(amari_L==0&&amari_R==0){
        cout<<"Yes"<<endl;
    }else if(amari_L==amari_R){
        sort(ALL(RLI));
        sort(ALL(LRI),greater<tuple<ll,ll,ll>>());
        int l=0;
        bool ok=true;


        REP(i,RLI.size()){
            int a=get<0>(RLI[i]);
            int b=get<1>(RLI[i]);
            l-=a;
            if(l<0){ok=false;}
            l+=b;
        }

        REP(i,LRI.size()){
            int a=get<0>(LRI[i]);
            int b=get<1>(LRI[i]);
            l-=b;
            if(l<0){ok=false;}
            l+=a;
        }

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

Measured memory_bytes: 46448
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> A(M);
	int l = 0, h = 0;
	for (int i = 0;i < M;++i) {
		cin >> A[i];
		if (A[i] < X) {
			l++;
		}
		else {
			h++;
		}
	}
	cout << min(l, h) << endl;
	return 0;
}

Measured memory_bytes: 256
//2019.3.23 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define RG register
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0,w=1,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s*w;
}
inline void swap(res &x,res &y){
    x^=y^=x^=y;
}
namespace MAIN{
    char str[100000+10];
    int n,m;
    int sum[100000+10];
    inline void MAIN(){
        n=read(),m=read();
        scanf("%s",str+1);
        for(res i=1;i<=n;){
            if(str[i]!='A'){i++;continue;}
            if(str[i+1]!='C'){i++;continue;}
            sum[i+1]++,i=i+2;
        }
        for(res i=1;i<=n;i++)sum[i]+=sum[i-1];
        while(m--){
            res l=read(),r=read();
            printf("%d\n",sum[r]-sum[l]);
        }
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, a;
    while(1){
        cin >> n >> m >> a;
        if(n + m + a == 0) break;
        a--;
        vector<P> d[1010];
        rep(i, 0, m){
            int h, p, q;
            cin >> h >> p >> q;
            d[h - 1].push_back(P(p - 1, q - 1));
        }
        repb(i, 1009, 0){
            rep(j, 0, d[i].size()){
                if(d[i][j].first == a){
                    a = d[i][j].second;
                    break;
                }else if(d[i][j].second == a){
                    a = d[i][j].first;
                    break;
                }
            }
            // cout << i << ' ' << a << endl;
        }
        cout << a + 1 << endl;
    }
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int Vmax=3643;
vi DP(int a,int b){
	vi res(Vmax,0);
	res[0]=1;
	FOR(i,a,Vmax)if(res[i-a])
		res[i]=1;
	FOR(i,b,Vmax)if(res[i-b])
		res[i]=1;
	return res;
}

signed main(){
	int a=read(),b=read(),c=read(),d=read(),e=read(),f=read();
	vi dp1=DP(a,b),dp2=DP(c,d);
	int x=1,y=-1;
	REP(i,Vmax/100)if(dp1[i])REP(j,Vmax)if(dp2[j]){
		if(i*e<j)continue;
		int w=i*100+j;
		if(f<w)continue;
		if(y*w<j*x){
			y=j;
			x=w;
		}
	}
	cout<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----

/**
 * Disjoint set data structure, uses compression by height.
 */
class DisjointSet
{
public:
    DisjointSet(int _n)
    {
        n = _n;
        root.resize(n);
        height.resize(n);
        size.resize(n);

        for (int i = 0;i < n; i++) {
            root[i] = i;
            height[i] = 0;
            size[i] = 1;
        }
    }

    int getRoot(int x)
    {
        if (root[x] == x)
            return x;

        return root[x] = getRoot(root[x]);
    }

    lint merge(int x, int y)
    {
        int rx = getRoot(x), ry = getRoot(y);
        if (rx == ry)
            return 0LL;

        lint ret = size[rx] * 1LL * size[ry];
        if (height[rx] < height[ry]) {
            root[rx] = ry;
            size[ry] += size[rx];
        } else if (height[rx] > height[ry]) {
            root[ry] = rx;
            size[rx] += size[ry];
        } else {
            root[ry] = rx;
            height[rx]++;
            size[rx] += size[ry];
        }

        return ret;
    }
private:
    int n;
    vector<int> root, height, size;
};
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M;
    cin >> N >> M;
    VEC(int) A(M), B(M);
    FOR(i, 0, M) {
        cin >> A[i] >> B[i];
    }

    VEC(lint) V(M + 1);
    lint total = N * 1LL * (N - 1) / 2;
    DisjointSet dset(N);

    V[M] = total;
    FORD(i, M - 1, -1) {
        total -= dset.merge(A[i] - 1, B[i] - 1);
        V[i] = total;
    }

    FOR(i, 1, M + 1)
        cout << V[i] << endl;
    return 0;
};


Measured memory_bytes: 4096
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main()
{
	ll N, K;
	cin >> N >> K;

	ll last_N = (ll)(2e18);
	N = N % K;

	while (true)
	{
		last_N = N;
		N = abs(N - K);
		if (N >= last_N || N < 0)
		{
			N = last_N;
			break;
		}
	}

	cout << N << endl;
	return 0;
}

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

int main() {
	long long int N, A, B;
	cin >> N >> A >> B;
	if (A > B || (N == 1 && A != B)) {
		cout << 0 << endl;
		return 0;
	}
	else {
		cout << (B * (N - 1) + A) - (A * (N - 1) + B) + 1 << endl;
		return 0;
	}
}

Measured memory_bytes: 256
h,w,k=map(int,input().split())
C=[list(input()) for _ in range(h)]

cnt=0
for i in range(2**h):
    num_1=format(i,"b").zfill(h)
    for j in range(2**w):
        point=0
        B=[["*"]*w for _ in range(h)]
        num_2=format(j,"b").zfill(w)
        for v,m in enumerate(num_1):
            if m=="1":B[v]=["."]*w
        for v,m in enumerate(num_2):
            if m=="1":
                for l in range(h):
                    B[l][v]=["."]
        for j in range(h):
            for v in range(w):
                if B[j][v]=="*" and C[j][v]=="#":
                    point +=1
        if point==k:
            cnt +=1
print(cnt)

Measured memory_bytes: 69712
import collections
n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]
#values = []
combs = 0
c = collections.Counter(s)
# このfor文を削減するためにcollections.Counter()を使用
# for i in set(s):
#   if s.count(i) > 1:
#     values.append(s.count(i))
for i in c.values():
  combs+=i*(i-1)//2
print(combs)

Measured memory_bytes: 19760
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll lcm(ll a,ll b)
{
	return (a/__gcd(a,b))*b;
}
bool cmp(pair<string,ll> a,pair<string,ll> b)
{
	if(a.first<b.first)
		return 1;
	else if(a.x==b.x)
	{
		return a.y<b.y;
	}
	return 0;
}
void solve()
{
	ll n;
	cin>>n;
	ll a[n],b[n];
	ll dp1[n],dp2[n];
	rep(i,0,n)
	{
		cin>>a[i];
	}
	rep(i,0,n)
	{
		cin>>b[i];
		if(i==0)
		{
			dp1[0]=a[0];
			dp2[0]=b[0];
		}
		else
		{
			dp1[i]=dp1[i-1]+a[i];
			dp2[i]=dp2[i-1]+b[i];
		}
	}
	ll cnt=0,ans=0;
	for(ll i=0;i<n;i++)
	{
		if(i==0)
		{
			cnt=dp1[i]+dp2[n-1];
		}
		else
		{
			cnt=dp1[i]+dp2[n-1]-dp2[i-1];
		}
		ans=max(ans,cnt);
	}
	cout<<ans<<"\n";
}	

int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint solve(int n, vector<lint> &a){
    lint ret = LINF;
    lint diff;
    vector<lint> sum(n+1, 0);
    for (int i=0; i<n; ++i){
        sum[i+1] = sum[i] + a[i];
    }
    for (int i=1; i<n; ++i){
        diff = abs(sum[i] - (sum[n] - sum[i]));
        ret = min(diff, ret);
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n);
    for (int i=0; i<n; ++i){
        cin >> a[i];
    }
    cout << solve(n, a) << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 998244353;

map<string, ll> _F;

ll F(string S) {
    if (_F.count(S)) return _F[S];
    ll &res = _F[S];
    int n = S.length();
    if (!n) return res = 1;
    res = F(S.substr(1)) * (S[0] == '1' ? 2 : 1) % MOD;
    for (int i = 1; i <= n; i++) {
        string a = S.substr(0, i);
        for (int j = 2; i * j <= n; j++) {
            string b = S.substr(i * (j - 1), i);
            for (int k = 0; k < i; k++)
                a[k] = min(a[k], b[k]);
            (res += F(a) * F(S.substr(i * j))) %= MOD;
        }
    }
    return res;
}

int main() {
    string S; cin >> S;
    ll ans = F(S);
    printf("%lld\n", ans);
}


Measured memory_bytes: 5632
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main(){

    int a, b, x; cin >> a >> b >> x;
    if ( (x-a)>=0 and b >= (x-a) ) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

struct st{
    double x,y;
};

void koch(int n, st a, st b){
    if (n ==0) return;
    st s,t,u;
    double arg = M_PI*60.0/180.0;
    
    s.x = (2.0*a.x+1.0*b.x)/3.0;
    s.y = (2.0*a.y+1.0*b.y)/3.0;
    t.x = (1.0*a.x+2.0*b.x)/3.0;
    t.y = (1.0*a.y+2.0*b.y)/3.0;
    u.x = s.x+(t.x -s.x)*cos(arg)-(t.y-s.y)*sin(arg);
    u.y = s.y+(t.x-s.x)*sin(arg)+(t.y-s.y)*cos(arg);
    
    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,b);
    
}

int main(){
    st a,b;
    int n;
    cin >> n;
    a.x = 0; a.y = 0; b.x =100; b.y = 0;
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
    return 0;
}



Measured memory_bytes: 3140
#! /usr/bin/ruby -w
# encoding: utf-8

if $0 == __FILE__
  max = 1 - 10**9
  n   = gets.to_i
  min = gets.to_i
  (n - 1).times do
    r = gets.to_i
    if r - min > max
      max = r - min
    end
    min = r < min ? r : min
  end
  puts max
end

Measured memory_bytes: 8772
/// In the name of God
#include <bits/stdc++.h>
//#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define y1 def1
#define X first
#define Y second
#define endl '\n'
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
int cnt[30];
main(){
    IOS;
    string s;
    cin >> s;
    int n = s.size();
    for(int i=0; i<n; i++)
        cnt[s[i] - 'a']++;
    ll ans = 1;
    for(int i=0; i<30; i++)
        for(int j=i+1; j<30; j++)
            ans += 1LL * cnt[i] * cnt[j];
    cout << ans << endl;
}


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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif
  
  double t; cin >> t;
  double x; cin >> x;
  cout.precision(10);
  cout << (t / x) << endl;   
  
   
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

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

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  vector<int64_t> B(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    B.at(i)=0;
  }
  for(int i=0;i<N;i++){
    B.at(A.at(i)-1) += 1;
  }
  int64_t k=0;
  for(int i=0;i<N;i++){
    k += ( B.at(i) * (B.at(i) - 1) ) / 2;
  }
  int64_t a;
  for(int i=0;i<N;i++){
    a = k - B.at(A.at(i) - 1) + 1;
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 5760
S = input()
base = ['A', 'T', 'C', 'G']

n = len(S)
st = 0
ans = 0
for i in range(n):
    if S[i] in base:
        ans = max(ans, i - st + 1)
        continue
    ans = max(ans, i - st)
    st = i + 1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<climits>

using namespace std;

int main()
{
	long long int N, M, R;
	cin >> N >> M >> R;
	vector<long long int >D(R);
	for (size_t i = 0; i < R; i++)
	{
		cin >> D[i];
		D[i]--;
	}

	vector<vector<long long int>>X(N, vector<long long int>(N, LLONG_MAX / 6));
	for (size_t i = 0; i < N; i++)
	{
		X[i][i] = 0;
	}
	for (size_t i = 0; i < M; i++)
	{
		long long int A, B, C;
		cin >> A >> B >> C;
		A--; B--;
		X[A][B] = X[B][A] = C;
	}

	for (size_t k = 0; k < N; k++)
	{
		for (size_t i = 0; i < N; i++)
		{
			for (size_t j = 0; j < N; j++)
			{
				X[i][j] = min(X[i][j], X[i][k] + X[k][j]);
				X[j][i] = X[i][j];
			}
		}
	}
	sort(D.begin(), D.end());
	long long int ans = LLONG_MAX / 6;
	do {
		long long int len = 0;
		for (size_t i = 0; i < R - 1; i++)
		{
			len += X[D[i]][D[i + 1]];
		}
		ans = min(len, ans);
	} while (next_permutation(D.begin(), D.end()));
	cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define int long long int
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define umpii unordered_map<int,int>
#define mem(a,b) memset(a, b, sizeof a)
#define mii map<int,int>
#define pqh priority_queue<int>
#define pql priority_queue<int,vi,greater<int>>
#define setbits(x) __builtin_popcountll(x);
#define zerobits(x)__builtin_ctzll(x);
#define dbg(x) cerr<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int INF = 1e9;
#define mod 1000000007
void longestCommonSubsequencePUREDP(string s1, string s2)
{
	int row = s1.length() + 1;
	int col = s2.length() + 1;
	vector<vector<int>> dp(row, vector<int>(col));
	//BASE CASE
	for (int i = 0; i < col; i++)
	{
		dp[s1.length()][i] = 0;
	}
	for (int i = 0; i < row; i++)
	{
		dp[i][s2.length()] = 0;
	}
	//RECURSIVE CASE
	int result;
	for (int i = s1.length() - 1; i >= 0; i--) {
		for (int j = s2.length() - 1; j >= 0; j--) {
			if (s1[i] == s2[j])
			{
				result = dp[i + 1][j + 1] + 1;
			} else {
				int first = dp[i + 1][j];
				int second = dp[i][j + 1];
				result = max(first, second);
			}
			dp[i][j] = result;
		}
	}
	// cout<< dp[0][0];
	string res = "";
	int i = 0;
	int j = 0;
	while (i  < s1.length() and j < s2.length())
	{
		if (s1[i] == s2[j])
		{
			res += s1[i ];
			i++;
			j++;
		}
		else if (dp[i + 1][j] > dp[i][j + 1])
		{
			i++;
		}
		else {
			j++;
		}
	}
	cout << res;
}
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	//FUCK RATINGS
	//Once a CHARAS, always a CHARAS


	string s1, s2;
	cin >> s1;
	cin >> s2;
	longestCommonSubsequencePUREDP(s1, s2);

	return 0;
}

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

int main() {
    string s; cin >> s;
    if (s.size() % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    for (int i=0; i<s.size(); i+=2) {
        if (s[i] != 'h' || s[i+1] != 'i') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int x[110], y[110];

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    rep(i, N)cin >> x[i];
    rep(i, M)cin >> y[i];

    sort(x, x + N);
    sort(y, y + M);


    for (int Z = X + 1; Z <= Y; Z++) {
        if (x[N - 1] < Z&&Z <= y[0]) {
            cout << "No War" << endl;
            return 0;
        }

    }
    cout << "War" << endl;
}

Measured memory_bytes: 256