akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

ll dp1[15][155];
ll n;
string s;
ll ssum, sprod;

ll fact(ll n)
{
	if (n == 0 || n == 1) return 1;
	return n*(fact(n - 1));
}

ll comb(ll n, ll m)
{
	return fact(n) / fact(n - m) / fact(m);
}

ll calc(vi& v, ll p)
{
	ll res = 1;
	ll m = p;
	REP(i, 10)
	{
		res *= comb(m, v[i]);
		m -= v[i];
	}
	return res;
}

ll calc2(vi& v, ll p)
{
	if (p == n) return 0;
	ll tmp = s[p] - '0';
	ll res = 0;
	REP(i, tmp)
	{
		if (v[i] > 0)
		{
			vi cp = v;
			cp[i]--;
			res += calc(cp, n - p - 1);
		}
	}
	if (v[tmp] > 0)
	{
		vi cp = v;
		cp[tmp]--;
		res += calc2(cp, p + 1);
	}
	return res;
}


ll count_sum(ll rem, ll sum)
{
	if (rem == 0)
	{
		if(sum == 0) return 1;
		else return 0;
	}
	if (dp1[rem][sum] >= 0) return dp1[rem][sum];
	ll res = 0;
	REP(i, 10)
	{
		if (sum >= i) res += count_sum(rem - 1, sum - i);
		else break;
	}
	return dp1[rem][sum] = res;
}

ll solve(vi cnt, ll tmp, ll rem, ll sum, ll prod)
{
	if (tmp == 10) return 0;
	if (rem == 0)
	{
		ll res;
		if (sum < 0 || sum == 0 && prod > sprod) return 0;
		else if (sum > 0 || sum == 0 && prod < sprod)
		{
			res = calc(cnt, n);
		}
		else if (sum == 0 && prod == sprod)
		{
			res = calc2(cnt, 0);
		}
		return res;
	}
	//if (sum < tmp * rem || prod > sprod) return 0;
	ll res = 0;
	vi cp = cnt;
	cp[tmp]++;
	res += solve(cp, tmp, rem - 1, sum - tmp, prod * (tmp + 1));
	res += solve(cnt, tmp + 1, rem, sum, prod);
	return res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	MS(dp1, -1);
	cin >> s;
	n = s.size();
	ssum = 0, sprod = 1;
	for (auto i : s)
	{
		ll tmp = i - '0';
		ssum += tmp;
		sprod *= tmp + 1;
	}
	vi v(10);
	cout << solve(v, 0, n, ssum, 1) << endl;
	return 0;
}

Measured memory_bytes: 3272
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;
typedef unsigned long long ull;

ull dp[21][100] = { { 0 } };
int question[100] = { 0 };

int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N; ++i){ cin >> question[i]; }
	--N;
	dp[question[0]][0] = 1;
	for(int i = 1; i < N; ++i){
		for(int j = 0; j <= 20; ++j){
			int tmp = j + question[i];
			if(0 <= tmp && tmp <= 20){ dp[tmp][i] += dp[j][i - 1]; }
			tmp = j - question[i];
			if(0 <= tmp && tmp <= 20){ dp[tmp][i] += dp[j][i - 1]; }
		}
	}
	cout << dp[question[N]][N - 1] << endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
	string s;
	string x = "abcdefghijklmnopqrstuvwxyz";
	bool flag=false;
	cin >> s;
	for(int i=0;i<x.length();i++){
		if(s.find(x[i]) == std::string::npos){
			flag = true;
			cout << x[i] << endl;
			break;
		}
	}
	if(!flag)puts("None");
	return 0;
}


Measured memory_bytes: 512
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    X, Y = map(int, input().split())
    sm = min(X, Y)
    lg = max(X, Y)
    mod = 10**9 + 7
    m = [0] * (sm + 1)
    n = [-1] * (sm + 1)
    m[0] = 1
    n[0] = pow(m[0], mod - 2, mod)

    for i in range(1, sm + 1):
        m[i] = m[i - 1] * i % mod

    ans = 0
    for i in range(sm + 1):
        if (sm - i) % 2 == 0:
            b = (sm - i) // 2
            if b + i * 2 == lg:
                if n[i] == -1:
                    n[i] = pow(m[i], mod - 2, mod)
                if n[b] == -1:
                    n[b] = pow(m[b], mod - 2, mod)
                ans = (ans + m[i + b] * n[i] * n[b]) % mod

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 54640
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,D;
  cin >> N >> D;
  vector<ll> X(N),Y(N);
  rep(i,N)  cin >> X.at(i) >> Y.at(i);

  two_sat ts(N);
  rep(i,N){
    REP(j,i+1,N){
      if(abs(X.at(i)-X.at(j)) < D)  ts.add_clause(i, false, j, false);
      if(abs(X.at(i)-Y.at(j)) < D)  ts.add_clause(i, false, j, true);
      if(abs(Y.at(i)-X.at(j)) < D)  ts.add_clause(i, true, j, false);
      if(abs(Y.at(i)-Y.at(j)) < D)  ts.add_clause(i, true, j, true);
    }
  }

  if(!ts.satisfiable()){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  vector<bool> ans = ts.answer();
  rep(i,N){
    if(ans.at(i)) cout << X.at(i) << endl;
    else  cout << Y.at(i) << endl;
  }

  return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>

int main(void){
	int h,m,s,S;
	h=0;
	m=0;
	s=0;
	scanf("%d",&S);
	while(S>=3600){
		S=S-3600;
		h++;
	}
	while(S>=60){
		S=S-60;
		m++;
	}
	s=S;
	
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}
	

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

using namespace std;
using   ll=long long;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve() 
{
	int a[3];
	
	cin >> a[0] >> a[1] >> a[2];
	
	sort(a , a+3);
	
	cout << a[0] + a[1];
}

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


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

#define ll long long

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

    if (a+b > c+d) cout << "Left" << endl;
    else if (a+b == c+d) cout << "Balanced" << endl;
    else cout << "Right" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll n,count=0;
    int a[10000];
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>a[i];
    }
    for(int i=1; i<=n; i=i+2){
        if(a[i]%2!=0)
        count++;
    }
    cout<<count<<endl;
    return 0;
}

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


void solve(long long K, std::string S){
    if (S.size() <= K) {
        cout << S << endl;
        return;
    }
    cout << S.substr(0, K) << "..." << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


Measured memory_bytes: 3700
#include<stdio.h>

int main()
{

  int Matrix[101][101],List[101],i,j,number_of_node,k,n;

  scanf("%d",&number_of_node);
  for(j =1; j <=number_of_node ; j++ )List[j] = 0;
  for(i = 1 ; i <=100 ; i++) for(j = 1; j<= 100 ; j++) Matrix[i][j] =0;
    
  for(i = 1 ; i <= number_of_node ; i++ )
    {
      scanf("%d %d",&n,&k);
      for(j = 1; j <=k ; j++)scanf("%d",&List[j]);
      for(j = 1; j<= k ; j++)
        {
          //printf("i = %d List[%d] = %d\n",i,j,List[j]);
          Matrix[i][List[j]] = 1;
        }
    }
  
  for(i = 1; i <= number_of_node ; i++)
    {
      //printf(" i = %d :  ",i);
      for(j = 1 ; j <= number_of_node ; j++)
        if( j == number_of_node)
          {
            printf("%d\n",Matrix[i][j]);
          }
        else printf("%d ",Matrix[i][j]);
    }


  
}


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

void calc_danger(int res,int i,pair<int,int> b[],int n){
  int danger=0;
  danger+=res*(-1)*b[i].first;
  for(int j=0;j<i;j++){
    danger+=b[j].first*b[j].second;
  }
  cout<<danger<<endl;
  return;
}

int main(){
  int n,m;
  int danger;
  while(cin>>n>>m){
    if(n==0&&m==0) break;
    int d[n],p[n];
    pair<int,int> b[n];
    for(int i=0;i<n;i++){
      cin>>d[i]>>p[i];
      b[i]=make_pair(p[i],d[i]);
    }
    sort(b,b+n);
    int res=m;
    for(int i=n-1;i>=0;i--){
      res=res-b[i].second;
      if(res<=0){
        calc_danger(res,i,b,n);
	break;
      }else if(i==0){
cout<<0<<endl;
}
    }
  }
  return 0;
}

    

Measured memory_bytes: 3176
N = int(input())
W_list = list(map(int, input().split()))

result_list = []

for i in range(1,N):
  s1 = sum(W_list[:i])
  s2 = sum(W_list[i:])
  result_list.append(abs(s1-s2))
  
print(min(result_list))

Measured memory_bytes: 3060
from collections import deque
S = deque([input()])
Q = int(input())
is_reverse = False

for _ in range(Q):
  inp = input().split()
  if len(inp) == 1:
    if is_reverse:
      is_reverse = False
    else:
      is_reverse = True
  else:
    _, f, c = inp
    if f == '1':
      if is_reverse:
        S.append(c)
      else:
        S.appendleft(c)
    else:
      if is_reverse:
        S.appendleft(c)
      else:
        S.append(c)
if is_reverse:
  ans = "".join(S)
  print(ans[::-1])
else:
  print("".join(S))


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  string S;
  cin >> S;
  REP(n,S.size()) {
    cout << "x";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
import collections
l=0
h=n//2+1
ans=0
while h>l+1:
    t=(h+l)//2
    d=collections.defaultdict(int)
    for i in range(n-t+1):
        c=s[i:i+t]
        if d[c]==0:
            d[c]=i+1
        else:
            if d[c]+t<=i+1:
                l=t
                break
    else:
        h=t
print(l)

Measured memory_bytes: 192648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
           
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
    const int MAX = 50;
    double p[MAX];
    p[0] = 1;
    for (int i = 1; i < MAX; ++i)
	p[i] = p[i - 1] / 2;

    static double res[1000100], dp[MAX + 3];
    dp[0] = 1;
    for (int i = 1; i <= 1000003; ++i)
    {
	double fail = 0;
	for (int j = MAX - 1; j >= 0; --j)
	{
	    dp[j + 1] = dp[j] * p[j];
	    fail += dp[j] * (1 - p[j]);
	}
	dp[0] = fail;
	res[i] = (1 - fail) + res[i - 1];
    }

    int n;
    while (scanf("%d", &n), n)
	printf("%.8f\n", res[n]);
}

Measured memory_bytes: 0
#include<stdio.h>
#define L 100000//キューの長さ

typedef struct{
  char name[11];
  int ms;
}Process;

Process A[L];
int head=0, tail=0;//head=tailで初期化出来る(空に出来る)////////////
/*
int isFull(){
  if(head == (tail+1)%L;
  return 1;
}
*/
int isEmpty(){//1なら空
  if(head==tail)return 1;
  return 0;
}


void enqueue(Process x){
  A[tail]=x;
  tail=(tail+1)%L;
}

Process dequeue(){
  Process x=A[head];
  head=(head+1)%L;
  return x;
}


int main(){
  int i;
  int p_num,q_time;
  Process A;
  int total_time=0;
  
  scanf("%d%d", &p_num, &q_time);//INPUT
  for ( i = 0; i < p_num; i++){
    scanf("%s%d", A.name,&A.ms);
    enqueue(A);
  }

  while(isEmpty()==0){
    A=dequeue();
    A.ms-=q_time;

    if(A.ms>0){
      enqueue(A);
      total_time+=q_time;
    }
    else{//OUTPUT
      total_time+=q_time+A.ms;//20 -100のとき100-80でかかった時間
      printf("%s %d\n",A.name,total_time);
    }
  }    
  return 0;
}
/*
5 100　プロセス数　クオンタイム
p1 100
p2 100


プロセス完了順にかかった終了時刻
p2 180 
*/



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

int main() {
  
  int N, K;
  cin >> N >> K;
  
  vector<int> h(N);
  for (int i = 0;i < N; i++) {
    cin >> h.at(i);
  }
  int x = 0; //乗れる人数の変数
  for (int i = 0;i < N; i++) {
    if (K <= h.at(i)) {
      x++;
    }
  }
  cout << x << endl;
      
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i = 1; i <= 9; i++)
        for (int j = 1; j <= 9; j++)
            cout << i << "x" << j << "=" << i * j << "\n";
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
    int n, a, b;
    cin>>n>>a>>b;
    if((b-a)%2==0) {
        cout << (b-a)/2 << endl;
    }else {
        cout << min(a-1,n-b)+1+(b-a-1)/2 << endl;
    }
    return 0;

}



Measured memory_bytes: 3632
S = input()

odd_yes = True
for i in range(0, len(S), 2):
    if not S[i] in "RUD":
        odd_yes = False
        break

even_yes = True
for i in range(1, len(S), 2):
    if not S[i] in "LUD":
        even_yes = False
        break

if odd_yes and even_yes:
    print("Yes")
else:
    print("No")

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

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

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

    cout << A[n - 1] - A[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int a, b, c, k; cin >> a >> b >> c >> k;
    int tmp = 0;
    while(a >= b){
        b *= 2;
        tmp++;
    }
    while(b >= c){
        c *= 2;
        tmp++;
    }
    if(tmp <= k){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
H, W = map(int, input().split())

s = []


for i in range(H):
    s.append(input())



for i in range(H):
    for j in range(W):
        if s[i][j] == '#':

            l, u, r, d = 0, 0, 0, 0

            if j > 0 and s[i][j-1] == '#':
                l = 1

            if i > 0 and s[i-1][j] == '#':
                r = 1

            if j < W-1 and s[i][j+1] == '#':
                u = 1

            if i < H-1 and s[i+1][j] == '#':
                d = 1


            if l+u+r+d == 0:
                print('No')
                exit()

print('Yes')


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <stdio.h>
#include <string>
#include <string>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if ((i * 4) + (j * 7) == n)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,i,x;
	x=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			x++;
		}
	}
	printf("%d\n",x);
	
	return 0;
}

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

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


bool func(ll mask, ll a) {
	// printf("%d %d\na", mask, a);
	for (int i = 0; i <= 20; ++i) {
		if ((a & (1<<i)) && (mask & (1<<i))) return false;
	}
	// printf("true\n");
	return true;
}


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

	ll mask = 0, ans = 0;
	for (int l = 0, r = 0; l < n, r <= n, l <= r; ++l) {
		while(r < n && func(mask, a[r])) {
			mask ^= a[r];
			r++;
		}
		// [l, r) は条件を満たす
		// printf("l %d r %d\n", l, r);
		ans += (r - l);
		mask ^= a[l];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
int main() {
	int M1, D1, M2, D2;
	cin >> M1 >> D1 >> M2 >> D2;
	if (M1 != M2) cout << 1 << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

ac = 0
wa = 0
tle = 0
re = 0
for si in s:
    if si == "AC":
        ac += 1
    elif si == "WA":
        wa += 1
    elif si == "TLE":
        tle += 1
    else:
        re += 1

print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)

Measured memory_bytes: 79176
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll n,s=0;
  cin>>n;
  cout<<(n*(n+1))/2<<endl;
  

}
return 0;
}

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

int main()
{
    int n;
    cin >> n;
    while (n)
    {
        if (n%10 == 7) {
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3584
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element

int A[100010];

int keta(ull n)
{
	ull k = 1;
	while (n >= 10)
	{
		n /= 10;
		k++;
	}
	return k;
}

signed main()
{
	int N;
	cin >> N;

	bool is_zero = false;
	REP(i, N)
	{
		cin >> A[i];
		if (A[i] == 0)
		{
			is_zero = true;
		}
	}

	if (is_zero)
	{
		cout << 0 << endl;
		return 0;
	}

	int cur = 1;
	for (int i = 0; i < N; i++)
	{
		cur *= A[i];
		if (cur <= 0 || cur > 1000000000000000000LL)
		{
			cout << -1 << endl;
			return 0;
		}
	}

	cout << cur << endl;
}




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

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> s(m);
    for(int i=0;i<m;i++){
        int k; cin>>k;
        for(int j=0;j<k;j++){
            int a; cin>>a;
            a--;
            s[i].push_back(a);
        }
    }
    vector<int> p(m);
    for(int i=0;i<m;i++) cin>>p[i];

    int ans=0;
    for(int i=0;i<(1<<n);i++){
        bool ok=true;
        for(int j=0;j<m;j++){
            int cnt=0;
            for(int k=0;k<s[j].size();k++){
                if(i&(1<<s[j][k])) cnt++;
            }
            if(cnt%2!=p[j]) ok=false;
        }
        if(ok) ans++;
    }
    cout<<ans<<endl;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (long long)1e18 + 1;

template<typename T>
class CombinationCalcurator {
public:
    CombinationCalcurator(int n_max, T mod):
        mod_(mod),
        factorial_(n_max + 1, 0),
        inv_factorial_(n_max + 1, 0),
        inv_(n_max + 1, 0) {
        std::fill(factorial_.begin(), factorial_.begin() + 2, 1);
        std::fill(inv_factorial_.begin(), inv_factorial_.begin() + 2, 1);
        std::fill(inv_.begin(), inv_.begin() + 2, 1);
        for(int i = 2; i <= n_max; i++) {
            factorial_[i]     = (factorial_[i - 1] * i) % mod_;
            inv_[i]           = mod_ - inv_[mod_ % i] * (mod_ / i) % mod_;
            inv_factorial_[i] = inv_factorial_[i - 1] * inv_[i] % mod_;
        }
    }

    T run(int n, int k) {
        return (n < k || (n < 0 || k < 0)) ? 0 :
            factorial_[n] * (inv_factorial_[k] * inv_factorial_[n - k] % mod_) % mod_;
    }

private:
    T mod_;
    std::vector<T> factorial_;
    std::vector<T> inv_factorial_;
    std::vector<T> inv_;
};

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

    int N, K;
    std::cin >> N >> K;

    CombinationCalcurator<ll> comb(N, MOD);
    for(int i = 1; i <= K; i++) {
        std::cout << comb.run(N - K + 1, i) * comb.run(K - 1, i - 1) % MOD << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vector<string> w(n);
    rep(i,n)cin>>w[i];
    set<string> set;
    rep(i,n){
        if(set.find(w[i])!=set.end()){
            cout<<"No"<<endl;
            return;
        }
        if(i&&w[i][0]!=w[i-1][w[i-1].length()-1]){
            cout<<"No"<<endl;
            return;
        }
        set.insert(w[i]);
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    vi a(3);
    rep(i,0,3) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int res = 0;
    ///ggg
    if (a[0]%2==0 && a[1]%2 == 0 && a[2]%2 ==0) {
        res = (a[2]-a[0])/2 + (a[2]-a[1])/2;
        cout << res << endl;
        return 0;
    } 

    //ggk
    if (a[0]%2==0 && a[1]%2 == 0 && a[2]%2 !=0) {
        a[1]++;
        a[0]++;
        res = (a[2]-a[0])/2 + (a[2]-a[1])/2;
        ++res;
        cout << res << endl;
        return 0;
    }

    //gkg
    if (a[0]%2==0 && a[1]%2 != 0 && a[2]%2 ==0) {
        a[2]++;
        a[0]++;
        res = (a[2]-a[0])/2 + (a[2]-a[1])/2;
        ++res;
        cout << res << endl;
        return 0;
    }

    //gkk
    if (a[0]%2==0 && a[1]%2 != 0 && a[2]%2 !=0) {
        a[2]++;
        a[1]++;
        res = (a[2]-a[0])/2 + (a[2]-a[1])/2;
        ++res;
        cout << res << endl;
        return 0;
    }

    //kgg
    if (a[0]%2!=0 && a[1]%2 == 0 && a[2]%2 ==0) {
        a[2]++;
        a[1]++;
        res = (a[2]-a[0])/2 + (a[2]-a[1])/2;
        ++res;
        cout << res << endl;
        return 0;
    }

    //kkg
    if (a[0]%2!=0 && a[1]%2 != 0 && a[2]%2 ==0) {
        a[0]++;
        a[1]++;
        res = (a[2]-a[0])/2 + (a[2]-a[1])/2;
        ++res;
        cout << res << endl;
        return 0;
    }

    //kgk
    if (a[0]%2!=0 && a[1]%2 == 0 && a[2]%2 !=0) {
        a[2]++;
        a[0]++;
        res = (a[2]-a[0])/2 + (a[2]-a[1])/2;
        ++res;
        cout << res << endl;
        return 0;
    }
    //kkk
    if (a[0]%2!=0 && a[1]%2 != 0 && a[2]%2 !=0) {
        res = (a[2]-a[0])/2 + (a[2]-a[1])/2;
        cout << res << endl;
        return 0;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;

int main(){
  int a,b;
  while(cin >> a >> b){

    cout << max(a-2*b, 0) << endl;
  }



  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
import std.typecons;
import std.ascii;

void main()
{
  readln;
  bool[int] l;
  int cnt = 0;
  int[] a = readln.chomp.split.map!(to!int).array;
  std.algorithm.sort = a;
  foreach (v; a) {
    auto b = v/400;
    if (7 in l && b >= 8) {
      ++cnt;
    }
    l[min(b, 7)]=true;
  }
  writeln(l.length, " ", l.length + cnt);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";

		ArrayList<Integer> list = new ArrayList<Integer>();
		Stack<Integer> stack = new Stack<Integer>();

		try {
			while ((s = br.readLine()) != null) {
				list.add(Integer.parseInt(s));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		for (Integer i : list) {
			if (i > 0) {
				stack.push(i);
			} else {
				System.out.println(stack.pop());
			}
		}
	}
}

Measured memory_bytes: 16904
#include<stdio.h>
#include<math.h>
 
int main(void){
     
    double x1,x2,y1,y2,dis;
     
    double tmp;
     
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
     
    if(x1>x2){
         
        tmp=x1;
        x1=x2;
        x2=tmp;
         
    }
     
    if(y1>y2){
         
        tmp=y1;
        y1=y2;
        y2=tmp;
         
    }
     
    dis=sqrt(((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
     
    printf("%f\n",dis);
     
    return 0;
}




Measured memory_bytes: 2056
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<map>
using namespace std;
typedef pair<int, pair<int, int> >PP;
typedef long long ll;
typedef pair<int, int>P;
typedef vector<int>vec;
int inf=-1;
ll mod = pow(10, 9) + 7;

int main(){
    ll n;cin>>n;
    cout<<(n-1)*n/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
    string a,b;cin >> a >> b;
    a+=b;
    int k=stoi(a);
    bool e=false;
    rep(i,1000){
        if(i*i==k){e=true;break;}
    }
    e ? printf("Yes\n") : printf("No\n");
}

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

//#include <map>
//#include <set>
//#include <queue>
//#include <string>
//#include <vector>
//#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int MAXN = 200005;
const int P = 1000000007;
const int INF = 1000000007;
const double eps = 1e-6;

inline int getint() {
    int r = 0; bool b = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
    while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
    return b ? r : -r;
}

char str[MAXN];
int n, cnt;
LL ans;

int main() {
    scanf("%s", str + 1);
    n = strlen(str + 1);
    for (int i = n; i >= 1; --i) {
        if (str[i] == 'B') ans += cnt;
        else ++cnt;
    }
    printf("%lld", ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  int n = s.size();
  
  int x = 0;
  
  if(n % 2 == 0){
    for (int i = 0;i < (n / 2);i++) {
    if(s.at(i) != s.at(n - i - 1)) {
      x++;
    }
  }
  }
  else if(n == 1) {
  }
  else{
  	for (int i = 0;i < ((n - 1) / 2);i++) {
    	if(s.at(i) != s.at(n - i - 1)) {
      x++;
    }
  }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,M,Ai,Bi,A,count=0;
 cin >> N >> M;
 vector<int> mount(N+1);
 for (int i = 0; i < N; i++)
  mount.at(i)=1;
 vector<int> higher(N+1);
 for (int i = 0; i < N; i++)
  cin >> higher.at(i);
 for(int i = 0;i < M;i++){
   cin >> Ai >> Bi;
   if(higher.at(Bi-1)<higher.at(Ai-1))
     A=Bi-1;
   if(higher.at(Bi-1)>higher.at(Ai-1))
     A=Ai-1;
   if(higher.at(Bi-1)==higher.at(Ai-1)){
     A=Ai-1;
     mount.at(Bi-1)=0;
   }
   mount.at(A)=0;
 }
 for(int i=0;i<N;i++){
   if(mount.at(i)==1)
     ++count;
 }
 cout << count << endl;
}

Measured memory_bytes: 4044
use std::collections::{HashMap, VecDeque};
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//struct Main {
//    x: i32,
//    y: i32,
//    z: i32,
//}
//impl Main {
//    fn invoke(&mut self) {
//        println!("{} {} {}", self.z, self.x, self.y);
//    }
//}

fn main() {
//    Main { x: x, y: y, z: z }.invoke()

    let n: i64 = read();
    let k: i64 = read();

    let rem = n % k;
    if rem == 0 {
        println!("{}", 0);
    } else {
        let reversed_rem = k - rem;
        if rem < reversed_rem {
            println!("{}", rem);
        } else {
            println!("{}", reversed_rem);
        }
    }
}


Measured memory_bytes: 4352
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

a = rs()
if a in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
    print('A')
else:
    print('a')

Measured memory_bytes: 9128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int c(const void*a,const void*b){
	if(*(char*)a<*(char*)b)return -1;
	if(*(char*)a>*(char*)b)return 1;
	return 0;
}
int c2(const void*a,const void*b){
	if(*(char*)a<*(char*)b)return 1;
	if(*(char*)a>*(char*)b)return -1;
	return 0;
}

char s[110],t[110];
int main(){
	scanf("%s%s",s,t);
	ll sn=strlen(s);
	ll tn=strlen(t);
	qsort(s,sn,1,c);
	qsort(t,tn,1,c2);
	puts(strcmp(s,t)<0?"Yes":"No");
}

Measured memory_bytes: 128
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        mut s: chars,
        mut t: chars,
    }
    s.sort();
    t.sort();
    t.reverse();

    let s_ = s.iter().fold(String::new(), |acc, &c| acc + &c.to_string());
    let t_ = t.iter().fold(String::new(), |acc, &c| acc + &c.to_string());

    println!("{}", if s_ < t_ { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
hand = {"r" : p, "s" : r, "p" : s}
ans = 0
for n_ in range(n):
	temp = n_ - k
	if temp >= 0 and t[n_] == t[temp]:
		t[n_] = ""
	else:
		ans += hand[t[n_]]
print(ans)

Measured memory_bytes: 4084
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

int one[10],two[10][10],three[10][10][10];

inline void solve() { 
    memset(one,0,sizeof(one));
    memset(two,0,sizeof(two));
    memset(three,0,sizeof(three));
    int n,ans=0; string  s ;  
    cin >> n >> s ; 
    for (int i=0;i<n;i++){
        int c=s[i]-'0'; 
        for (int j=0;j<10;j++){
            for (int k=0;k<10;k++){
                if (two[j][k]) three[j][k][c]=1;
            }
        }
        for (int j=0;j<10;j++){
            if (one[j]) two[j][c]++;
        }
        one[c]++;
    }
    for (int i=0;i<10;i++){
        for (int j=0;j<10;j++){
            for (int k=0;k<10;k++){
                ans += three[i][j][k];
            }
        }
    }
    cout << ans << endl;
} 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}

/*
5
23232

*/


Measured memory_bytes: 3684
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	for(int m,n;scanf("%d%d",&m,&n),m;){
		static int h[1501],w[1501];
		h[0]=w[0]=0;
		for(int i=1;i<=m;i++)	scanf("%d",h+i),h[i]+=h[i-1];
		for(int i=1;i<=n;i++)	scanf("%d",w+i),w[i]+=w[i-1];

		static int gen_w[1500001],gen_h[1500001];
		for(int i=0;i<=max(w[n],h[m]);i++)	gen_h[i]=gen_w[i]=0;
		for(int i=0;i<m;i++)for(int j=i+1;j<=m;j++)	gen_h[h[j]-h[i]]++;
		for(int i=0;i<n;i++)for(int j=i+1;j<=n;j++)	gen_w[w[j]-w[i]]++;

		long long ans=0;
		for(int i=0;i<=max(w[n],h[m]);i++)	ans+=gen_h[i]*gen_w[i];
		printf("%lld\n",ans);
	}

	return 0;
}

Measured memory_bytes: 4752
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  int S;
  cin >> S;
  vector<ll> dp(S + 1, 0);
  dp[0] = 1;
  ll mod = 1000000007;
  for (int i = 0; i < S + 1; i++) {
    for (int j = 0; j < (i - 3) + 1; j++) {
      dp[i] += dp[j];
      dp[i] %= mod;
    }
  }
  cout << dp[S] << endl;

  return 0;
}

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

int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    while(a>0 && c>0){
        c -= b;
        if(c<=0){ printf("Yes\n"); break; }
        a -= d;
        if(a<=0){ printf("No\n"); break; }
    }
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
long long a,b,n,ans,l,k;
int main()
{
	cin>>n;
	ans=1;
	for(k=1;k<=n;k++)
	{
		cin>>l;
		if(l==0)
		{
			ans=0;
			continue;
		}
		if(ans==-1)
		{
			continue;
		}
		if(ans>1000000000000000000/l)
		{
			ans=-1;
			continue;
		}
		ans=ans*l;
			
		
	}
	cout<<ans;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int max = a;
        if (max < b)
            max = b;
        if (max < c)
            max = c;
        System.out.println(a + b + c - max);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int a,b,c,sum=0;
	cin>>a>>b>>c;
	for(int i=a;i<=b;i++){
		if(i%c==0){
			sum++;
		}
	} 
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,ans;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	long long w=__gcd(c,d),z=c/w*d;
	ans=-b/z+a/z+b/c+b/d-a/c-a/d;
	if(a%d==0)ans++;
	if(a%c==0)ans++;
	if(a%z==0)ans--;
	printf("%lld\n",b-a+1-ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
int main()
{
  int K, S, sum = 0;
  cin >> K >> S;
  Rep(i,K + 1) {
    sum += max(0,(K + 1) - abs((K - S) + i));
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 384
/*input

*/
#include<bits/stdc++.h>
#define ll        	long long 
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define rrep(i,a,b) for(ll int i=a;i>=b;i--)
#define all(a)      (a).begin(),(a).end()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define tr(i, cont) for(auto i=cont.begin();i!=cont.end();i++)
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define trace(x)                 cerr << #x << ": " << x << "\n";
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << "\n";

#define endl "\n"
using namespace std;


int main(){
	ll n;
	cin>>n;
	vi a(n),b(n),c(n-1);
	rep(i,0,n){
		cin>>a[i];
	}
	rep(i,0,n){
		cin>>b[i];
	}
	rep(i,0,n-1){
		cin>>c[i];
	}
	ll ans=0;
	rep(i,0,n){
		ans+=b[a[i]-1];
		if(i==0) continue;
		if(a[i]==a[i-1]+1){
			ans+=c[a[i]-1-1];
		// trace3(i,a[i],c[a[i]-1-1]);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256