akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 
const int N = 1e5 + 11;

void solve(){
  cout << fixed;
  cout << setprecision(10);
  int n;
  cin >> n;
  double x[N], y[N];
  for(int i = 0; i < n; i++) cin >> x[i];
  for(int i = 0; i < n; i++) cin >> y[i];
  double val1 = 0.0, val2 = 0.0, val3 = 0.0, val4 = 0.0;
  for(int i = 0; i < n; i++){
	  val1 += fabs(x[i] - y[i]);
	  val2 += fabs(x[i] - y[i]) * fabs(x[i] - y[i]);
	  val3 += fabs(x[i] - y[i]) * fabs(x[i] - y[i]) * fabs(x[i] - y[i]);
	  val4 = max(val4, fabs(x[i] - y[i]));
	}
	cout << val1 << endl;
	cout << sqrt(val2) << endl;
	cout << cbrt(val3) << endl;
	cout << val4 << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



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

int main(){
    map <string, string> data;
    data["A"] = "T";
    data["T"] = "A";
    data["G"] = "C";
    data["C"] = "G";
    
    string temp;
    
    cin >> temp;
    cout << data[temp] << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair



using namespace std;
typedef unsigned long long ull;
typedef vector<int>vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef set<int> si;

const int  N = 1e5+5;
int arr[N],pos[N];
bool win[N];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int a,b,c;
	cin >> a;
	if(a == 1){
		cout << "Hello World" << endl;
	}else{
		cin >> b >> c;
		cout << b + c << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys

for stdin in sys.stdin:
    inlist = stdin.split()

    a = int(inlist[0])
    b = int(inlist[2])
    op = inlist[1]
    
    if op == "?":
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "/":
        print(a // b)
    elif op == "*":
        print(a * b)

Measured memory_bytes: 7672
ans=0
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
C.append(0)
for i in A:
    ans+=B[i-1]
for i in range(N-1):
    if A[i]+1==A[i+1]:
        ans+=C[A[i]-1]
print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
  string s;cin >> s;
  vector<int>x((s.size()+1),0);
  rep(i,s.size()){
    if(s[i]=='<'){
      x[i+1]=max(x[i+1],x[i]+1);
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='>'){
      x[i]=max(x[i+1]+1,x[i]);
    }
  }
  ll ans = 0;
  rep(i,s.size()+1){
    ans +=x[i];
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 2820
#include <iostream>

//int moto(int y, int x)
//{
//	int p;
//	double a = y * 100;
//	a /= (100 + x);
//	
//	if ( a - int(a) > 1.0e-20 ) p = int(a) + 1;
//	else p = int(a);
//
//	return a;
//}

int saki(int p, int x)
{
	return p * (100 + x) / 100.;
}

int main()
{
	while(true){
		int x, y, s;

		std::cin >> x >> y >> s;

		if ( x == 0 && y == 0 && s == 0 ) break;

		int max = 0;
//		for ( int i = 1; i < s; ++i ) {
//			int j = s - i;
//
//			int moto_j = moto(j, x);
//			int moto_i = moto(i, x);
//
//			if ( moto_j == 13 ) {
//				std::cout << j << " " << i << std::endl;
//				std::cout << moto_j << " " << moto_i << " " << saki(moto_j, y) << " " << saki(moto_i, y) << std::endl;
//			}
//			int a = saki(moto_i, y) + saki(moto_j, y);
//			if ( max < a ) max = a;
//		}
//
	
		for ( int i = 1; i <= 1000; ++i ) {
			for ( int j = 1; j <= 1000; ++j ) {
				if ( i < j ) continue;
				if ( saki(i, x) + saki(j, x) == s ) {
					int a = saki(i, y) + saki(j, y);
					if ( max < a ) max = a;
				}
			}
		}

		std::cout << max << std::endl;
	}
	return 0;
}

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

const int N = 5e5 + 1000;

int n;
double max_volume;
double temp[N], volume[N];

void init() {
	std::cin >> n;
	std::cin >> max_volume;
	for (int i = 1; i <= n; i++) {
		scanf("%lf%lf", &temp[i], &volume[i]);
	}
}

void printAnswer(double x0, double y0, double x1, double y1, double x_target) {
	double lambda = (x_target - x0) / (x1 - x0);
	printf("%.20f\n", (y0 + lambda * (y1 - y0)) / x_target);
}

void work() {
	std::deque<std::pair<double, double>> deque;

	double sum_x = 0, sum_y = 0;
	for (int i = 1; i <= n; i++) {
		deque.push_front({volume[i], temp[i] * volume[i]});
		sum_x += volume[i];
		sum_y += temp[i] * volume[i];

		while (sum_x - deque.back().first > max_volume) {
			sum_x -= deque.back().first;
			sum_y -= deque.back().second;
			deque.pop_back();
		}
		printAnswer(sum_x - deque.back().first, sum_y - deque.back().second, sum_x, sum_y, max_volume);

		if (sum_x > max_volume) {
			auto back = deque.back();
			sum_x -= back.first;
			sum_y -= back.second;
			deque.pop_back();
			double t = (max_volume - sum_x) / back.first;
			back.first *= t;
			back.second *= t;
			sum_x += back.first;
			sum_y += back.second;
			deque.push_back(back);
		}
		while (deque.size() >= 2) {
			std::pair<double, double> front[2];
			front[0] = deque.front();
			deque.pop_front();
			front[1] = deque.front();
			deque.pop_front();
			if (front[0].second * front[1].first <= front[1].second * front[0].first) {
				std::pair<double, double> t = {front[0].first + front[1].first, front[0].second + front[1].second};
				deque.push_front(t);
			} else {
				deque.push_front(front[1]);
				deque.push_front(front[0]);
				break;
			}
		}
	}
}

int main() {
	init();
	work();

	return 0;
}


Measured memory_bytes: 31380
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str1 = br.readLine();
        String[] str_1 = str1.split(" ");
        String str2 = br.readLine();
        String[] str_2 = str2.split(" ");
        int[] HW = new int[2];
        int[] hw = new int[2];
        for (int i=0;i<2;i++){
            HW[i] = Integer.parseInt(str_1[i]);
            hw[i] = Integer.parseInt(str_2[i]);
        }
        System.out.println((HW[0]-hw[0])*(HW[1]-hw[1]));
    }
}

Measured memory_bytes: 22996
def chk(s,x,y):
    cnt = 0
    if s[y][x]!='#':
        for i in [-1,0,1]:
            for j in [-1,0,1]:
                if 0<=x+i<w and 0<=y+j<h:
                    if s[y+j][x+i]=='#':
                        cnt += 1
        return str(cnt)
    else:
        return '#'

h,w = map(int,input().split())
gazo = []
for i in range(h):
    gazo.append(str(input()))

#for i in range(h):
#    print(gazo[i])

for i in range(h):
    for j in range(w):
        print(chk(gazo,j,i),end='')
    print('')



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

int main () {
    int N;
    while(cin >> N, N) {
        vector<set<int>> v(N);
        for(int i=0; i<N; ++i) {
            int M;
            cin >> M;
            for(int j=0; j<M; ++j) {
                int p;
                cin >> p;
                v[i].insert(p);
            }
        }
        int K;
        cin >> K;
        set<int> s;
        for(int i=0; i<K; ++i) {
            int l;
            cin >> l;
            s.insert(l);
        }

        vector<int> ret;
        for(int i=0; i<N; ++i) {
            if(includes(v[i].begin(), v[i].end(), s.begin(), s.end())) {
                ret.push_back(i+1);
            }
        }

        if(ret.size() == 1) {
            cout << ret[0] << endl;
        } else {
            cout << -1 << endl;
        }
    }
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    ll N, A, B;
    cin >> N >> A >> B;
    cout << max(0LL, A + (B * (N - 1)) - A * (N - 1) - B + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;
    
    if(m == 0) {
        if(n == 1) {
            out(0);
        }
        else if(n == 2) {
            out(10);
        }
        else {
            out(100);
        }
        re0;
    }
    
    vl v(n, -1);
    rep(i, m) {
        ll s, c;
        cin >> s >> c;
        s--;
        if(v[s] == -1) {
            v[s] = c;
        }
        else if(v[s] != c) {
            out(-1);
            re0;
        }
    }
    
    if(n == 1 && v[0] == -1) {
        out(0);
        re0;
    }
    
    if(n > 1 && v[0] == 0) {
        out(-1);
        re0;
    }
    
    rep(i, n) {
        if(v[i] == -1) {
            if(i == 0) {
                v[i] = 1;
            }
            else {
                v[i] = 0;
            }
        }
    }
    
    rep(i, n) {
        cout << v[i];
    }
    
    cout << endl;
    re0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Card Game is Fun
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt();
		int[] a = new int[A], b = new int[B];
		for(int i=0;i<A;i++)a[i]=sc.nextInt();
		for(int i=0;i<B;i++)b[i]=sc.nextInt();
		int res = 0;
		for(int i=0;i<B;i++){
			int v = i, p = 0, k = 0;
			while(v<B&&p<A){
				if(b[v]==a[p]){
					res = Math.max(res, ++k);
					v++;
				}
				p++;
			}
		}
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
// 2011/05/30 Tazoe

#include <iostream>
using namespace std;

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

	for(int i=0; i<N; i++){
		int a, b, c;
		cin >> a >> b >> c;

		if(b>a&&b>c){
			int tmp = a;
			a = b;
			b = tmp;
		}
		if(c>a&&c>b){
			int tmp = a;
			a = c;
			c = tmp;
		}

		if(a*a==b*b+c*c)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  int hand=(n-m)*100;
  int nine=pow(2,m);
  int ans=hand+(1900*m);
  cout << ans*nine << endl;
  return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    int n;
    cin>>n;
    ll a[11000]={};
    ll b[11000]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long int sa=0;
    long long int saa=0;
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            sa+=a[i]-b[i];
        }else if(a[i]<b[i]){
            saa+=(b[i]-a[i])/2;
        }
    }
    if(sa>saa){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    
}


Measured memory_bytes: 384
#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 = N / 10;
	}
	cout << "No" << endl;
}

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

int main (){
  int N;
  int a = 0, b = 0, c = 0, d = 0;
  int j = 0;
  
  cin >> N;
  
  rep (i, N){
    string x;
    cin >> x;
    
    if (x == "P") a++;
    if (x == "W") b++;
    if (x == "G") c++;
    if (x == "Y") d++;
  }
  if (a != 0) j++;
  if (b != 0) j++;
  if (c != 0) j++;
  if (d != 0) j++;
  
  if (j == 3){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
}

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

int main(){
    string S; cin >> S;
    int t = 0;
    vector<int> ans(S.length(), 0);
    for(int i=0; i < S.length(); i++){
        if(S[i] =='R'){
            t += 1;
        } else if(t != 0){
            ans[i-1] += t / 2 + t % 2;
            ans[i] += t / 2;
            t = 0;
        }
    }
    t = 0;
    for(int i=S.length()-1; i > -1; i--){
        if(S[i] =='L'){
            t += 1;
        } else if(t != 0){
            ans[i+1] += t / 2 + t % 2;
            ans[i] += t / 2;
            t = 0;
        }
    }
    for(int a:ans){
        cout << a << ' ';
    }
}

Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
    int a,b,c,d,e;

    scanf("%d%d",&a,&b);

    c=a+b;

    d=a-b;

    e=a*b;

    if(c>=d && c>=e){

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

    else if(d>=c && d>=e){

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

    else if(e>=c && e>=d){

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

    return 0;

}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
  int i,j,n,m;
  scanf("%d",&n);
  int ara[n],arr[n];
  for(i=0;i<n;i++)
    scanf("%d",&ara[i]);
    for(j=n-1,i=0;j>=0,i<n;j--,i++){
      arr[j]=ara[i];}
   for(j=0;j<n-1;j++)
   { printf("%d ",arr[j]);}
   printf("%d\n",arr[n-1]);

    return 0;
}


Measured memory_bytes: 2076
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {
    static class FastReader
        {
            BufferedReader br;
            StringTokenizer st;

            public FastReader()
            {
                br = new BufferedReader(new
                        InputStreamReader(System.in));
            }

            String next()
            {
                while (st == null || !st.hasMoreElements())
                {
                    try
                    {
                        st = new StringTokenizer(br.readLine());
                    }
                    catch (IOException e)
                    {
                        e.printStackTrace();
                    }
                }
                return st.nextToken();
            }

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

            long nextLong()
            {
                return Long.parseLong(next());
            }

            double nextDouble()
            {
                return Double.parseDouble(next());
            }

            String nextLine()
            {
                String str = "";
                try
                {
                    str = br.readLine();
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
                return str;
            }
        }
    public static void main(String[] args) {
        FastReader ob = new FastReader();
        long x = ob.nextLong();
        long ans = (x/500)*1000+((x%500)/5)*5;
        System.out.println(ans);

    }
}

Measured memory_bytes: 20692
// https://atcoder.jp/contests/abc152/tasks/abc152_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VL ps(N);
  rep(i, N) cin >> ps[i];

  ll cur_min = INF;
  ll res = 0;

  rep(i, N) {
    if (ps[i] <= cur_min) res++;
    chmin(cur_min, ps[i]);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+100;
int gi() {
	char ch='!'; int res=0, f=0;
	while(ch<'0' || ch>'9') { ch=getchar(); if(ch == '-') f=1; }
	while(ch>='0' && ch<='9') res=res*10+ch-'0', ch=getchar();
	return f?-res:res;
}
int n,a[N],c[3],o[3];
int main() {
	n=gi(); memset(c,-1,sizeof(c));
	for(int i=1;i<=n;++i) {
		a[i]=gi();
		for(int j=0;j<4;++j) {
			if(j == 3) { puts("No"); return 0; }
			if(a[i] == c[j]) { ++o[j]; break; }
			if(c[j] == -1) { c[j]=a[i], o[j]=1; break; }
		}
	}
	if(c[0] == 0 && o[0] == n) puts("Yes"), exit(0);
	if(c[2] == -1) {
		if(c[1] == -1) puts("No"), exit(0);
		if(c[0] == 0) swap(c[0],c[1]), swap(o[0],o[1]);
		if(c[1]) puts("No"), exit(0);
		if(c[1] == 0) {
			if(o[0] == o[1]*2) puts("Yes"), exit(0);
			puts("No"); exit(0);
		}
	}
	else {
		if(c[0]^c[1]^c[2]) puts("No"), exit(0);
		if(o[0] != o[1] || o[0] != o[2]) puts("No"), exit(0);
		puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(4);
  for(int i=0;i<4;i++){
    A.at(i) = n%10;
    n /= 10;
  }
  bool ans1 = true,ans2 = true;
  for(int i=0;i<2;i++){
    if(A.at(i)!=A.at(i+1)){
      ans1 = false;
    }
  }
    for(int i=1;i<3;i++){
    if(A.at(i)!=A.at(i+1)){
      ans2 = false;
    }
  }
  if(ans1||ans2) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const int MX = (int)2e+5;
const int MOD = (int)1e+9 + 7;
 
int powmod(int n, int k) {
	int res = 1;
	while(k > 0) {
		if(k & 1) res = (res * n) % MOD;
		n = (n * n) % MOD;
		k /= 2;
	}
	return res;
}
int invmod(int n) {
	return powmod(n, MOD - 2);
}
 
int fact[MX], invfact[MX];
 
int comb(int n, int m) {
	if(n < m) return 0;
	return (fact[n] * invfact[m] % MOD) * invfact[n - m] % MOD;
}

signed main(){
	fact[0] = invfact[0] = 1;
	for(int i = 1; i < MX; ++i) {
		fact[i] = (fact[i-1] * i) % MOD;
		invfact[i] = invmod(fact[i]);
	}
	int n;
	cin >> n;
	n++;
	vector<int> a(n);
	map<int, int> mp;
	int l = -1, r = -1;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		if(mp.find(a[i]) != mp.end()) {
			l = mp[a[i]];
			r = i;
		} else {
			mp[a[i]] = i;
		}
	}
	if(l < 0 || r < 0) {
		return 1;
	}
	cout << n - 1 << endl;
	for(int i = 2; i <= n; ++i) {
		int res = 0;
		// without l,r
		if(i <= n - 2) {
			res = (res + comb(n - 2, i)) % MOD;
			// cerr << "<" <<  n - 2 << "," << i << endl;
		}
		// both of l and r
		res = (res + comb(n - 2, i - 2)) % MOD;
		// cerr << "<" << n - 1 << "," <<  i - 1 << endl;
		// either l or r
		if (i <= n - 1) {
			res = (res + comb(n - 2, i - 1) * 2) % MOD;
			res = (res - comb(l + (n - r - 1), i - 1) + MOD) % MOD;
			// cerr << "<" << n - 2 << "," <<  i - 1 << "," << l + n - r - 1 << "," << i - 1 << endl;
		}
		cout << res << endl;
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    vector<set<ll>> alph(26);
    ll n; cin >> n;
    string s; cin >> s;
    rep(i, s.size()) {
        alph[s[i]-'a'].insert(i);
    }
    ll q; cin >> q;
    rep(Q, q) {
        int t; cin >> t;
        if(t == 1) {
            ll i; cin >> i; i--;
            char c; cin >> c;
            alph[s[i]-'a'].erase(i);
            s[i] = c;
            alph[c-'a'].insert(i);
        } else {
            ll l,r; cin >> l >> r; l--; r--;
            int ans = 0;
            rep(i, 26) {
                auto it = alph[i].lower_bound(l);
                if (it != alph[i].end() && *it <= r) ans++;
            }
            cout << ans << endl;
        }
    }

    return 0;
}


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

int main(){
    int H,W;
    
    while(1){
        cin >> H >> W;
        if(H==0 and W==0) break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout <<"#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
   int n,m,x;
   cin>>n>>m>>x;

   vector<int> c(n,0);
   vector<vector<int>> a(n,vector<int>(m,0));
   rep(i,n){
      cin>>c[i];
      rep(j,m){
         
         cin>>a[i][j];
      }
   }
   bool check=false;
   ll sum=100000000000;

   for(int bit=0;bit<(1<<n);bit++){
      ll kari=0;
      vector<int> p(m,0);

      for(int i=0;i<n;i++){
         if(bit & (1<<i)){
            rep(j,m){
               p[j]+=a[i][j];
            }
            kari+=c[i];
         }
      }
      bool f=true;
      rep(i,m){
         if(p[i]<x) f=false;
      }
      if(f==true) {
         sum=min(sum,kari);
         check=true;
      }
   }
   if(check==true) cout<<sum;
   else cout<<"-1";

return 0;
}



Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int a,b;
	cin >> a >> b;
	cout << max({a+b,a-b,a*b}) << endl;
	return 0;
}


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

using Graph = vector<vector<int>>;

vector<vector<vector<int>>> reachable(auto G) {
  vector<vector<vector<int>>> ok(2, vector<vector<int>>(G.size(), vector<int>(G.size(), -1)));

  function<void(int, int, int)> dfs = [&](auto b, auto root, auto u) {
    for(auto v: G[u]) if(ok[b][root][v] == -1) {
      ok[b][root][v] = ok[b][root][u];
      dfs(b, root, v);
    }
  };

  for(auto v=0; v<G.size(); ++v) ok[0][v][v] = ok[1][v][v] = 0;
  for(auto root=0; root<G.size(); ++root) for(auto i=0; i<G[root].size(); ++i) for(auto b: {0, 1}) {
    auto x = (b==0) ? i : G[root].size()-1-i;
    auto v = G[root][x];
    if(ok[b][root][v] == -1) {
      ok[b][root][v] = x;
      dfs(b, root, v);
    }
  }
  return ok;
}

int main() {
  int N, M;
  cin >> N >> M;
  Graph G(N);
  vector<int> a(M), b(M);
  for(auto i=0; i<M; ++i) {
    cin >> a[i] >> b[i];
    --a[i]; --b[i];
    G[a[i]].push_back(b[i]);
  }

  auto ok = reachable(G);

  for(auto i=0; i<M; ++i) {
    auto u = a[i], v = b[i];
    auto ab = ok[0][u][v]!=ok[1][u][v];
    auto ba = ok[0][v][u]!=-1;
    if(ab==ba) cout << "same" << endl;
    else       cout << "diff" << endl;
  }
}


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

using namespace std;
int n,a[100005],sum;
int main()
{
    cin>>n;
    for(int i=1;i<=2*n;i++)
    cin>>a[i];
  sort(a+1,a+2*n+1);
    for(int i=1;i<=2*n;i+=2)
    sum+=a[i];
    cout<<sum<<endl;
    return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using P = pair<i64,i64>;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
int M;
vector<int> p;
vector<int> x,y;

int main(){
    cin >> N >> M;
    p.resize(N + 1);
    x.resize(M);
    y.resize(M);
    rep(i,1,N) cin >> p[i];
    rep(i,0,M - 1) cin >> x[i] >> y[i];
    vector<vector<int>> es(N + 1);
    rep(i,0,M - 1){
        es[x[i]].push_back(y[i]);
        es[y[i]].push_back(x[i]);
    }
    vector<int> vis(N + 1,0);
    int cou = 1;
    int ans = 0;
    rep(i,1,N){
        if(!vis[i]){
            queue<int> que;
            vector<int> g;
            que.push(i);
            vis[i] = 1;
            while(!que.empty()){
                int v = que.front();
                que.pop();
                g.push_back(v);
                for(int to : es[v]){
                    if(vis[to]) continue;
                    vis[to] = 1;
                    que.push(to);
                }
            }

            map<int,int> mp;

            for(int v : g){
                mp[v]++;
                mp[p[v]]++;
            }
            for(auto p : mp){
                if(p.second == 2){
                    ans++;
                }
            }
            cou++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 12408
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
	int R[MAX], n;
	
	cin >> n;
	for (int i = 0; i < n; i++ ) cin >> R[i];
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for (int i = 1; i < n; i++ ){
		maxv = max(maxv, R[i] - minv );
		minv = min(minv, R[i]);
	}
	
	cout << maxv << endl;
	
	return 0;
}


Measured memory_bytes: 3848
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String n = in.next();
		int b = in.nextInt();
		BigInteger bi = new BigInteger(n);
		String x = bi.toString(b);
		System.out.println(x.length());
	}
}

Measured memory_bytes: 23764
import logging
logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s')
#logging.debug("デバッグスタート")  #

n = int(input())
a = []
b = 1
while n % 2**b == 0:
    a.append(2**b)
    n /= 2**b
#    logging.debug("n = {},b = {}".format(n,2 ** b))  #
    b += 1

while n % 2 == 0:
    n /= 2

f = 3
b = 1
while f * f <= n:
    if n % f**b == 0:
        a.append(f**b)
        n /= f**b
        b += 1
    else:
        while n % f == 0:
            n /= f
        f += 2
        b = 1
#    logging.debug("n = {},f = {},f**b = {}".format(n, f, f**b))  #
if n != 1:
    a.append(n)

#print(a)
print(len(set(a)))
#logging.debug("デバッグ終了")#

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

int main() {
string s;
int d;
map<string,int> m;
while(getline(cin,s)){
	//cout<<s<<endl;
	//cout<<s.find("O")<<endl;
	if(s.find("AB")!= std::string::npos){++m["AB"];
	}else if(s.find("O")!= std::string::npos){++m["O"];
	}else if(s.find("B")!= std::string::npos){++m["B"];
	}else{++m["A"];}
}

cout<<m["A"]<<endl;
cout<<m["B"]<<endl;
cout<<m["AB"]<<endl;
cout<<m["O"]<<endl;
}

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int sum = 0;
		int index = 0;
		int tmpIndex = 0;
		int[] a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
		}
		while(true) {
			tmpIndex = index;
			index = a[index] - 1;
			a[tmpIndex] = 0;
			sum++;
			if(index == -1) {
				sum = -1;
				break;
			} else if(index == 1) {
				break;
			}
		}
		System.out.println(sum);
		scan.close();
	}

}


Measured memory_bytes: 50308
A, B = map(int, input().split())

i = 0
check = 0
while(B - A*i >= 0):
    if B - A*i == 0:
        check = 1
        break
    else:
        i += 1

if check == 1:
    print(A+B)
else:
    print(B-A)


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

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> a(H, vector<char>(W));
  vector<bool> flag_w(W,false);
  vector<bool> flag_h(H,false);
  
  for (int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++){
      cin >> a.at(i).at(j);
      if(a.at(i).at(j) == '#'){
        flag_h.at(i) = true;
        flag_w.at(j) = true;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    if(flag_h.at(i)){
      for(int j = 0; j < W; j++){
        if(flag_w.at(j)){
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
return 0;
}


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

void solve(){
    ll h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll minute = 0;
    if(m1 <= m2){
        minute += m2 - m1;
    }else{
        minute += m2 - m1;
    }
    minute += (h2 - h1) * 60;
    ll ans = minute - k;
    print(ans);
    

}

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

Measured memory_bytes: 3640
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}


const ll N =1e3+6;


void solve(){
	long double aa;
	cin>>aa;
	aa=aa*aa*aa;
	aa=aa/27;
	cout<<setprecision(10)<<fixed;
	cout<<aa<<'\n';
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	// #ifndef ONLINE_JUDGE
	// 	cin.tie(NULL);
	// 	freopen ("INPUT.txt" , "r" , stdin);
	// 	freopen ("OUTPUT.txt", "w" , stdout);
	// #endif	
    ll t=1;
   // cin>>t;
    for (ll i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

bool check(vector<int> &v1, vector<int> &v2){
    for(int i = 0; i < v1.size(); i++){
        if( v1[i] != v2[i] ) return false;
    }
    return true;
}

int main(){

    int N;
    cin >> N;

    vector<int> p(N);
    vector<int> q(N);
    for(int i = 0; i < N; i++) cin >> p[i];
    for(int i = 0; i < N; i++) cin >> q[i];
    int pid = 0;
    int qid = 0;

    vector<int> v(N);
    iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
    int cnt = 0;
    do {
        if( check(v, p) ) pid = cnt;
        if( check(v, q) ) qid = cnt;
        cnt ++;

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

    cout << abs(pid - qid) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[2000],s1=0,s2=0,n,b[2000],c[2000],max=0,s=0;
    cin>>n;
    for(int i = 0;i < n;i++)
    {
        cin>>a[i];
        s1 += a[i];
    }
    for(int i = 0;i < n;i++)
    {
        cin>>b[i];
        s2 += b[i];
        c[i] = s2;

    }
    max = s1;
    //cout<<max<<endl;
    //cout<<c[-1]<<endl;
    for(int i = 0;i < n;i++)
    {
        s += a[i];
        if(s+(s2-c[i-1]) > max)
        {
            max = s+(s2-c[i-1]);
        }
    }
    cout<<max<<endl;


}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, X: "List[int]"):
    result = 10 ** 9
    for p in range(1, 100 + 1):
        cost = 0
        for i in range(N):
            cost += (X[i] - p) ** 2

        result = min(result, cost)
    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define N 2001
const int MOD = 1e9+7;
 
typedef long long int ll;
 
int dp[N][N];
 
int C(int n, int r) {
	if (r == 0 || r == n)return 1;
	if (r == 1) return n; 
	if (dp[n][r] != -1) return dp[n][r];
 
	return dp[n][r] = ((ll)C(n-1, r-1) + (ll)C(n-1, r)) % MOD;
}
 
int H(int r, int n) {
	return C(n+r-1,n);
}
 
int main() {
	IOS
	int n;
	cin >> n;
	int maxp = n/3;
	int c = 0;
	memset(dp, -1, sizeof(dp));
 
	for (int i = 1; i <= maxp; i++) {
		int left = n-3*i;
 
		if (left < 0)
			continue;
 
		c = ((ll)c + (ll)H(i, left)) % MOD;
	}
	cout << c;
	return 0;
}

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

signed main() {
	int y, m, d;
	char a, b;
	cin >> y >> a >> m >> b >> d;

	if (m < 5) cout << "Heisei" << endl;
	else cout << "TBD" << endl;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
from heapq import heappop, heappush
#from collections import OrderedDict, defaultdict
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
#import numba

def run():
    N, K = list(map(int, input().split()))
    A = list(map(int, sysread().split()))
    mod = 10 ** 9 + 7

    plus = [a for a in A if a >= 0]
    minus = [-a for a in A if a < 0]

    plus = sorted(plus, reverse=True)
    minus = sorted(minus, reverse=True)

    P, M  = [1], [1]
    for p in plus:
        P.append((P[-1] * p) % mod)
    for m in minus:
        M.append(((M[-1] * (-m)) % mod))
    #print(P, M)
    max_ans = -1

    for i in range(K, -1, -2):
        if len(plus) < i:continue
        if len(minus) < K - i:continue
        if max_ans == -1:
            max_ans = P[i] * M[K-i] % mod
        else:
            if not plus[i] or not plus[i + 1]:
                max_ans = P[i] * M[K-i] % mod
                continue
            if plus[i+1] * plus[i] <  minus[K-i-2] * minus[K-i-1]:
                max_ans = P[i] * M[K-i] % mod

    if max_ans == -1:
        plus = plus[::-1]
        minus = minus[::-1]
        P, M = [1], [1]
        for p in plus:
            P.append((P[-1] * p) % mod)
        for m in minus:
            M.append(((M[-1] * (-m)) % mod))

        for i in range(K-1, -1, -2):
            if len(plus) < i: continue
            if len(minus) < K - i: continue
            if max_ans == -1:
                max_ans = P[i] * M[K - i] % mod
            else:
                if not plus[i] or not plus[i+1]:
                    max_ans = 0
                    break
                if plus[i+1] * plus[i] >  minus[K-i-2] * minus[K-i-1]:
                    max_ans = P[i] * M[K - i] % mod

    print(max_ans)

if __name__ == "__main__":
    run()

Measured memory_bytes: 33344
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define INF 1e9
#define int long long
using namespace std;
signed main()
{
	int n,d;
	scanf("%lld%lld",&n,&d);
	d=d*d;
	int cnt=0;
	int p,q;
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&p,&q);
		int D=p*p+q*q;
	//	printf("%lld %lld\n",D,d);
		if(D<=d)cnt++;
	}
	printf("%lld",cnt);
	return 0;
}


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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

int N;

signed main() {
    cin >> N;
    int keta = 0;
    int ncopy = N;
    int highestDigid;
    while (ncopy) {
        keta++;
        highestDigid = ncopy % 10;
        ncopy /= 10;
    }
    int n999 = 0;
    rep(i, keta - 1) {
        n999 *= 10;
        n999 += 9;
    }
    int ans;
    if (N - (n999 + 1) * highestDigid == n999)ans = 9 * (keta - 1) + highestDigid;
    else ans = 9 * (keta - 1) + highestDigid - 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
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")
}

fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<char>>();
    let mut ans = 0;
    for i in 0..n {
        let mut sum = 0;
        'inner_loop: for j in 0..i {
            for k in 0..j {
                if s[j] == s[k] {
                    continue 'inner_loop;
                }
            }
            for k in i..n {
                if s[j] == s[k] {
                    sum += 1;
                    break;
                }
            }
        }
        ans = std::cmp::max(ans, sum);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
### subroutines

def valid?(str)
  pars = []

  for i in (0...str.length)
    case str[i]
    when '('
      pars << '('
    when '['
      pars << '['
    when ')'
      ch = pars.pop
      return false if ch != '('
    when ']'
      ch = pars.pop
      return false if ch != '['
    end
  end

  pars.empty?
end

### main

loop do
  str = gets.rstrip
  break if str == '.'

  puts valid?(str) ? 'yes' : 'no'
end

Measured memory_bytes: 6120
n, m = map(int, input().split())
if m > 0:
    p, s = zip(* [input().split() for _ in range(m)])
else:
    p = []
    s = []

ac_dict = {str(i): False for i in range(1, n + 1)}
wa_dict = {str(i): 0 for i in range(1, n + 1)}
ac_num = 0
wa_num = 0
for p_i, s_i in zip(p, s):
    if ac_dict[p_i] == False:
        if s_i == 'AC':
            ac_num += 1
            wa_num += wa_dict[p_i]
            ac_dict[p_i] = True
        elif s_i == 'WA':
            wa_dict[p_i] += 1
print('{} {}'.format(ac_num, wa_num))


Measured memory_bytes: 54384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 30

typedef struct node{
 int id;
 int pareid;
 int sibid;
 int degree;/*子供の数*/
 int depth;
 int height;
 char type[20];
 struct node *left;
 struct node *right;
}node;









int depthcheck(node N[],int i){

 if(N[i].pareid==-1)return 0;
 else{return depthcheck(N,N[i].pareid)+1;}

}


void heightcheck(node N[],int id){
 if(N[id].pareid==-1){return;}
 else if(N[N[id].pareid].height <= N[id].height+1){
    N[N[id].pareid].height=N[id].height+1;
    heightcheck(N,N[id].pareid);}


}



int main(){
int i,n;
int x,y,z;
node N[MAX];



scanf("%d",&n);

for(i=0;i<n;i++){
 N[i].id=-1;
 N[i].pareid=-1;
 N[i].sibid=-1;
 N[i].degree=-1;
 N[i].depth=-1;
 N[i].height=-1;
 N[i].left=NULL;
 N[i].right=NULL;

}


for(i=0;i<n;i++){

 scanf("%d",&x);
 N[x].id=x;

 scanf("%d %d",&y,&z);
 if(y!=-1&&z!=-1){
   N[y].pareid=x;
   N[y].sibid=z;
   N[z].pareid=x;
   N[z].sibid=y;
   N[x].degree=2;
   N[x].left=&N[y];
   N[x].right=&N[z];
  }
 else if(y==-1&&z==-1){
   N[x].degree=0;
   N[x].height=0;
   strncpy(N[x].type,"leaf",4);N[x].type[4]='\0';
 }
 else{
    if(z==-1){
     N[y].pareid=x;
     N[y].sibid=-1;
     N[x].left=&N[y];
    }
    else{
     N[z].pareid=x;
     N[z].sibid=-1;
     N[x].right=&N[z];
    }
  N[x].degree=1;
 }

}

/*root探索*/
for(i=0;i<n;i++){
 if(N[i].pareid==-1){strncpy(N[i].type,"root",4);N[x].type[4]='\0';break;}
}
/*-----------*/


for(i=0;i<n;i++){
 
if(N[i].degree==0){heightcheck(N,i);}


}

for(i=0;i<n;i++){
 N[i].depth=depthcheck(N,i);
 if(N[i].type[0]!='r'&&N[i].type[0]!='l'){strncpy(N[i].type,"internal node",13);N[i].type[13]='\0';}
 printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",i,N[i].pareid,N[i].sibid,N[i].degree,N[i].depth,N[i].height,N[i].type);
}


return 0;
}

/*あってるのにちがうって出る*/


Measured memory_bytes: 2108
# coding: utf-8


def main():
    n, m, x, y = list(map(int, input().split()))
    x_arr = list(map(int, input().split()))
    y_arr = list(map(int, input().split()))

    war_happen = False

    for z in range(x + 1, y + 1):
        # print(z)
        if z > max(x_arr) and z <= min(y_arr):
            print('No War')
            return

    print('War')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
//In The Name of Beauty
//...So here I go is my shot
//Feet fail me not 'cause maybe the only opportunity that I got...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define IB std::ios::sync_with_stdio(0);
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define pll pair<ll,ll>
#define F first
#define S second
ll const MAXN = 1e5 + 8;
ll const INF  = 1e9 + 8;
ll const delta = 1000000007;

int main()
{
    IB;
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    reverse(a,a + n);
    if(a[0] != 2)return cout << -1,0;
    ll ans = 2 , mmax = 3;
    for(ll i = 1;i < n;i++)
    {
        ans = (ll)ceil((double)ans / (double)a[i]) * a[i];
        mmax = (mmax / a[i]) * a[i];
        mmax = mmax + a[i] - 1;
        if(mmax < ans)return cout << -1,0;
    }
    cout << ans << " " << mmax;
    return 0;
}
//Written by M_H_H_7


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

class Dice {
public:
    int face[6];
    Dice() {}
    void dir(char ch) {
        if (ch == 'E') rot(0, 2, 5, 3);
        if (ch == 'W') rot(0, 3, 5, 2);
        if (ch == 'S') rot(0, 1, 5, 4);
        if (ch == 'N') rot(0, 4, 5, 1);
    }

    void rot(int a, int b, int c, int d) {
        int t[4] = {};

        t[0] = face[a];
        t[1] = face[b];
        t[2] = face[c];
        t[3] = face[d];
        face[a] = t[3];
        face[b] = t[0];
        face[c] = t[1];
        face[d] = t[2];

    }
};

int main() {
    Dice dice1;
    string D;

    for (int i = 0; i < 6; i++) {
        cin >> dice1.face[i];
    }
    cin >> D;
    for (int j = 0; j < D.size(); j++) {
        dice1.dir(D[j]);
    }
    cout << dice1.face[0] << endl;
    return 0;
}

Measured memory_bytes: 1204
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
match = [2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (n + 1)

dp[0] = 0
for i in range(1, n + 1):
    for j in a:
        if i < match[j - 1]:
            continue
        else:
            dp[i] = max(dp[i], dp[i - match[j - 1]] + 1)

num = []
k = n
for i in range(dp[n]):
    for j in a:
        if k >= match[j - 1]:
            if dp[k - match[j - 1]] == dp[k] - 1:
                num.append(j)
                k -= match[j - 1]
                break
print("".join(map(str, num)))

Measured memory_bytes: 40688
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
#define mo 1000000007
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
ll n,k,ans,gs1,gs;
int a[2005];
int main()
{
    n=read();k=read();reg int i,j;
    for(i=1;i<=n;++i)a[i]=read();
    for(i=1;i<=n;++i)
    {
        gs=gs1=0;
        for(j=i+1;j<=n;++j)
            if(a[i]>a[j])gs++;
        for(j=1;j<=n;++j)
            if(a[i]>a[j])gs1++;
        ans=(ans+gs*k%mo+gs1*(1ll*k*(k-1)/2%mo))%mo;
    }
    cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256