akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N;
	char[] S;
	char[] result;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		S = in.readLine().toCharArray();
		result = new char[S.length];
	}

	void calc() {
		for (int i = 0; i < result.length; ++i) {
			result[i] = conv(S[i]);
		}
	}

	char conv(char c) {
		char result = c;
		result += (char) N;
		if ((int) result > 90) {
			result = (char) ((int) result % -90 + 64);
		}
		return result;
	}

	void showResult() {
		for (int i = 0; i < result.length; ++i) {
			System.out.print(result[i]);
		}
		System.out.println("");
	}
}

Measured memory_bytes: 22868
n = int(input())
num = 0
for k in range(1,n+1):
    #print(k)
    if k*(k+1) >=2*n:
        break
if k*(k+1) == 2*n:
    for i in range(k):
        print(i+1)
else:
    num = k*(k+1)//2-n
    #print(num,k*(k+1)//2)
    for i in range(k):
        if i+1 == num:
            continue
        else:
            print(i+1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;


int main(){
  int i,j;
  string s;
  cin>>s;
  if(s=="SUN") cout<<7<<endl;
  if(s=="MON") cout<<6<<endl;
  if(s=="TUE") cout<<5<<endl;
  if(s=="WED") cout<<4<<endl;
  if(s=="THU") cout<<3<<endl;
  if(s=="FRI") cout<<2<<endl;
  if(s=="SAT") cout<<1<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int x;
    cin >> x;
    int ans = 0;
    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                if(x == 500 * i + 100 * j + 50 * k) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3556
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	//for(int i=0;i<N;i++) {}
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int N=sc.nextInt();
		int a[]=new int[N];
		long ans=1;
		
		
		for(int i=0;i<N;i++) {
			a[sc.nextInt()]++;
		}
		
		boolean x=true;
		if(N%2!=0) {
			if(a[0]!=1)x=false;
			
			for(int i=2;i<N;i+=2) {
				if(a[i]!=2)x=false;
				ans*=2;
				ans%=mod;
			}
			
			
		}else {
			for(int i=1;i<N;i+=2) {
				if(a[i]!=2)x=false;
				ans*=2;
				ans%=mod;
			}

		}
		
		if(x)p(ans);
		else p(0);
		
		
		
	}
	

	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 50160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
using ll = long long;

int main() {

    lli N;
    cin >> N;

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

    lli answer = 0;
    lli counter = 0;
    for (lli i = N - 1; i > 0 ; --i) {

        if (H[i] <= H[i - 1]) {
            ++counter;
        } else {
            // 左の方が小さいとき
            if (counter > answer) {
                answer = counter;
            }
            counter = 0;
        }
    }

    if (counter > answer) {
        answer = counter;
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 1024
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    h = LI()
    dp = [float("inf") for i in range(n)]
    dp[0] = 0
    for i in range(n-2):
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
        dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
    dp[n-1] = min(dp[n-1],dp[n-2]+abs(h[n-1]-h[n-2]))
    print(dp[n-1])
#B
def B():
    n,k = LI()
    h = LI()
    dp = [float("inf") for i in range(n)]
    dp[0] = 0
    for i in range(n):
        for j in range(1,min(n-i,k+1)):
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
    print(dp[n-1])

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()


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

bool binary_search(vector<int> &s, int key) {
	int l = 0, r = s.size() - 1;
	while (l <= r) {
		int mid = l + (r - l) / 2;
		if (s[mid] == key) return true;
		if (s[mid] < key) l = mid + 1;
		if (s[mid] > key) r = mid - 1;
	}
	return false;
}

int main() {
	int n;
	cin >> n;
	vector<int> s(n);
	rep(i, n) cin >> s[i];
	int q;
	cin >> q;
	vector<int> t(q);
	rep(i, q) cin >> t[i];
	int ans = 0;
	rep(i, q) if (binary_search(s, t[i])) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3348
#include <iostream>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int cnt_like[30] = {0};
    for(int i = 0; i < N; i++){
        int K;
        cin >> K;
        for(int j = 0; j < K; j++){
            int A;
            cin >> A;
            cnt_like[A-1]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < M; i++){
        if(cnt_like[i] == N) ans++;
    }
    cout << ans << endl;
}

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint n;

unsigned long calc(llint a){
	return a*a*a*a*a;
}

void solve(){
	cin >> n;
	llint ansa,ansb;

	if(n==1){
		ansa=0;
		ansb=-1;
	}
	else if(n==2){
		ansa=1;
		ansb=-1;
	}
	else{
		for(int i=-200;i<=200;i++){
			llint a=calc(i);
			for(int j=-200;j<=200;j++){
				llint b=calc(j);
				if(a-b==n){
					ansa=i;
					ansb=j;
					break;
				}
			}
		}
	}

	cout << ansa << " " << ansb << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 3584
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
b = Array.new(n)
n.times do |i|
  b[i] = a[i] - i
end

h = Hash.new(0)
n.times do |i|
  h[b[i]] += 1
end

ans = 0
n.times do |i|
  target = -a[i] - i
  ans += h[target]
end

puts ans

Measured memory_bytes: 40292
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define HASH 18014398241046527
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
template <typename T>
ll SIZEOF(T a){return (ll)a.size();}
ll xlcm(ll a, ll b){return (a/__gcd(a, b))*b;}

ll dx[] = {1, 0, -1, 0};
ll dy[] = {0, 1, 0, -1};


const int N = 100005;

void SOLVE(){
    inp(n);
    ll ans = xmodpow(10, n, MOD);
    ll sub1 = xmodpow(9, n, MOD);
    ll sub2 = xmodpow(9, n, MOD);
    ll sub3 = xmodpow(8, n, MOD);
    ans = xmod(ans-sub1, MOD);
    ans = xmod(ans-sub2, MOD);
    ans = xmod(ans+sub3, MOD);
    cout << ans << '\n';
}

int main() {
	fastIO();
	// #ifndef ONLINE_JUDGE
    //     freopen("i.txt", "r", stdin);
    //     freopen("o.txt", "w", stdout);
	// #endif

    ll TC = 1;
    // cin >> TC;
    for(ll tc1=1; tc1<=TC; tc1++){
        // cout << "Case #" << tc1 << ": ";
        SOLVE();
    }
    printclock;
}

Measured memory_bytes: 3792
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for C - Attention
	var N int
	fmt.Scanf("%d", &N)

	var S string
	fmt.Scanf("%s", &S)

	Ecount := make([]int, N)
	var temp1 int
	for i := 0; i < N; i++ {
		if S[i] == 'E' {
			temp1++
		}
		Ecount[i] = temp1
	}

	Wcount := make([]int, N)
	var temp2 int
	for i := N - 1; 0 <= i; i-- {
		if S[i] == 'W' {
			temp2++
		}
		Wcount[i] = temp2
	}

	var count int
	var min int = N - Wcount[1] - 1
	for i := 1; i < N-1; i++ {
		count = N - Ecount[i-1] - Wcount[i+1] - 1
		if min > count {
			min = count
		}
	}
	min = int(math.Min(float64(min), float64(N-Ecount[N-2]-1)))
	fmt.Println(min)
}


Measured memory_bytes: 8572
/*
  C - Boxes and Candies
  <http://abc048.contest.atcoder.jp/tasks/arc064_a>
  [Tips]
  ・callocはヒープ領域からメモリの割り当てを行うため遅い<https://oshiete.goo.ne.jp/qa/1726895.html>
*/

#include <stdio.h>

typedef long int int32_t;
typedef long long int int64_t;

int main(int argc, char const *argv[]) {

  int32_t N, x, a, a_next;
  int32_t i;
  int64_t cnt;

  scanf("%ld %ld", &N, &x);

  cnt = 0;
  a = 0;
  for( i=0; i<N; i++ ){
    scanf("%ld", &a_next);
    if( (a+a_next) > x ){
      cnt += (a+a_next) - x;
      a_next = x-a;
    }
    a = a_next;
  }

  printf("%lld\n", cnt);
  return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int pw[22];
int len[22];
int getNdig(int n) {
  int d = 1, x = 1, t = 0;
  for(; t < n; (t < n ? d++, x*=10 : 0)) {
    int y = x*10-1;
    t += (y-(x-1))*d;
    pw[d] = x-1;
    len[d] = t;
  }
  return d;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, k;
  while(cin >> n >> k, n || k) {
    int d = getNdig(n);
    int lb = 1;
    for(int i = 1; i < d; i++) lb *= 10;
    int ub = lb*10;
    lb--;
    while(lb+1 < ub) {
      int mb = (lb+ub)/2;
      int l = len[d-1]+(mb-pw[d])*d;
      if(l < n) lb = mb;
      else ub = mb;
    }
    int l = len[d-1]+(ub-pw[d])*d;
    //cout<<l<<endl;
    if(l >= n) {
      string o = to_string(ub);
      cout << o.substr(o.size()-((l-n)+1), min(k, (l-n)+1));
      k -= ((l-n)+1);
    }
    for(int i = ub+1; k > 0; i++) {
      string o = to_string(i);
      cout << ((int)o.size() <= k ? o : o.substr(0, k));
      k -= o.size();
    }
    cout << endl;
  }

  return 0;
}

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

#define MAX 410000
#define MOD 1000000007

long long modpow(long long a,long long n,long long mod){
  long long res=1;
  while(n>0){
    if(n&1){       //nのbitと...00001を比較  nが2で割り切れるならtrue
      res=(res*a)%mod;
    }
    a=(a*a)%mod;
    n>>=1;
  }
  return res;
}

long long modinv(long long a,long long mod){
  return modpow(a,mod-2,mod);
}

long long fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=(fac[i-1]*i)%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

long long COM(int n,int k){
  if(n<k){
    return 0;
  }
  if(n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  COMinit();
  long long n,a,b;
  cin>>n>>a>>b;
  long long sum=modpow(2,n,MOD)-1;
  long long com=1;
  for(int i=1;i<=a;i++){
    com*=((n+1-i)*inv[i]%MOD);
    com%=MOD;
  }
  sum-=com;
  if(sum<0){
    sum+=MOD;
  }
  for(int i=a+1;i<=b;i++){
    com*=((n+1-i)*inv[i]%MOD);
    com%=MOD;
  }
  sum-=com;
  if(sum<0){
    sum+=MOD;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 9856
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>

using namespace std;


int main() {

	int n, m;
	cin >> n >> m;

	int a[100], b[100];

	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
	}

	int sum[100] = { 0 };

	for (int i = 0; i < m; i++) {
		sum[a[i]]++;
		sum[b[i]]++;
	}

	for (int i = 1; i <=n; i++) {
		cout << sum[i] << endl;
	}


	return 0;
}




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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,9)
    {
        f(j,1,9)
        {
            if(i*j==n)
            {
                cout<<"Yes\n";
                return 0;
            }
        }
    }
    cout<<"No\n";



















    return 0;

}














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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
}
return u;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

while(x!=NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
}
z->parent = y;
if(y == NIL) root = z;
else if(z->key < y->key) y->left = z;
else y->right = z;
}

void inorder(Node u){
if(u == NIL) return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(Node u){
if(u == NIL) return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "file"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    map<int, int> cnt;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        cnt[a]++;
    }
    vector<long long> rec, sq;
    for(auto k: cnt)
    {
        if(k.second >= 2)
            rec.pb(k.first);
        if(k.second >= 4)
            sq.pb(k.first);
    }
    long long ans = 0;
    if(rec.size() > 1)
        ans = rec[rec.size() - 1] * rec[rec.size() - 2];
    if(sq.size() > 1)
        ans = max(ans, sq.back() * sq.back());
    cout << ans;
    return 0;
}


Measured memory_bytes: 4992
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <boost/hana/functional/fix.hpp>
#include <boost/sort/spreadsort/spreadsort.hpp>
//#include <boost/graph/adjacency_list.hpp>
//#include <boost/graph/dijkstra_shortest_paths.hpp>
//#include <boost/graph/graph_utility.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
  
using namespace std;
//using namespace boost::multiprecision;
//using namespace boost::math;

/*
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
        boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;
*/

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define FixPoint boost::hana::fix
#define bsort boost::sort::spreadsort::spreadsort
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};

struct negrightshift {
    inline int operator() (const int &x, const unsigned offset) {
        return -(x >> offset);
    }
};
//}}}


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n, W;
    cin >> n >> W;

    vector w(n + 1, 0), v(n + 1, 0);

    reps(i,n){
        cin >> w[i] >> v[i];
    }

    vector dp(n + 1, vector(W + 1, -1LL));

    dp[0][0] = 0;

    const auto res = FixPoint([&](const auto rec, const auto r, const auto c){
        if(c < 0 || r < 0){
            return (-LINF);
        }else if(~dp[r][c]){
            return (dp[r][c]);
        }

        dp[r][c] = max({rec(r-1, c), rec(r, c-1), rec(r-1, c - w[r]) + v[r]});

        return (dp[r][c]);
    })(n, W);

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 102792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  vector<int> c(N);
  vector<int> g(N);
  int ge = 0;
  for (int i=0; i < N; i++){cin >> v.at(i);}
  for (int i=0; i < N; i++){cin >> c.at(i);}
  for (int i=0; i < N; i++){g.at(i) = v.at(i)-c.at(i);}
  for (int i=0; i < N; i++){
    if (g.at(i)>0){ge += g.at(i);}
  }
  cout << ge << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
    std::cin >> N;
    std::map<int64_t, int64_t> num;
    for (int64_t i = 0; i < N; i++)
    {
        int64_t a;
        std::cin >> a;
        num[a]++;
    }

    int64_t ans = 0;
    for (auto v : num)
    {
        if (v.first > v.second) ans += v.second;
        else ans += v.second - v.first;
    }

    std::cout << ans << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 9520
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		int[] data=new int[10];
		for(int i=0;i<10;i++){
			data[i]=sc.nextInt();
		}
		Arrays.sort(data);
		for(int i=data.length-1;i>=data.length-3;i--){
			ln(data[i]);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
N, M = list(map(int, input().split()))
height_list = list(map(int, input().split()))
road_list_1 = [list(map(int, input().split())) for i in range(M)]
road_list = [[road_list_1[j][i] - 1 for i in range(2)] for j in range(M)]
observation_deck = list(range(N))

for i in range(M):
    if height_list[road_list[i][0]] >= height_list[road_list[i][1]]:
        observation_deck[road_list[i][1]] = -1
    if height_list[road_list[i][0]] <= height_list[road_list[i][1]]:
        observation_deck[road_list[i][0]] = -1

answer = 0

for i in range(N):
    if observation_deck[i] != -1:
        answer += 1

print(answer)

Measured memory_bytes: 51844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,nn) for(int i=0;i<nn;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}



ll h,w;
char a[1010][1010];
ll dp[1010][1010]={0};
ll dx[]={0,1};
ll dy[]={1,0};
bool checked[1010][1010]={0};
 
int main(){
  cin >> h >> w;
  FOR(i,h)FOR(j,w)cin >> a[i][j];
  dp[0][0]=1;
  queue<pair<ll,ll>> v;
  v.push(make_pair(0,0));
  while(!v.empty()){
    ll x=v.front().first;
    ll y=v.front().second;
    v.pop();
    FOR(i,2){
      if(x+dx[i]<h && y+dy[i]<w && a[x+dx[i]][y+dy[i]]=='.'){
        dp[x+dx[i]][y+dy[i]]+=dp[x][y];
        dp[x+dx[i]][y+dy[i]]%=MOD;
        if(checked[x+dx[i]][y+dy[i]])continue;
        v.push(make_pair(x+dx[i],y+dy[i]));
        checked[x+dx[i]][y+dy[i]]=1;
      }
    }
  }
  cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 10112
n=int(input())
s = list(map(int,input().split()))
li=[0]*9
for i in range(n):
  if s[i]<3200:
    b=s[i]//400
    li[b]+=1
  else:
    li[8]+=1

ans=0
for j in range(8):
  if li[j]!=0:
    ans+=1

c=ans+li[8]

if ans==0:
  print(1,c)
else:
  print(ans,c)

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


int main() {
	
	string w;
	cin >> w;
	sort(w.begin(),w.end());
	bool flag = 1;
	
	if (w.size() % 2) flag = 0, cout << "No" << endl;
	
	else {
		for (int i=0; i<w.size()/2; i+=2){
			if ( w.at(i) != w.at(i+1) ){
				cout << "No" << endl;
				flag = 0;
				break;
			}
		}
	if (flag) cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import numpy as np
import math
A,B,H,M = map(int,input().split())

theta = H * 30 * math.pi/180 + M * math.pi/360
phi = M * 6 * math.pi/180

x1 = A * math.sin(theta)
y1 = A * math.cos(theta)

x2 = B * math.sin(phi)
y2 = B * math.cos(phi)

buf = abs(phi-theta)
c = A ** 2 + B ** 2 - 2 * A * B * math.cos(buf)
print(math.sqrt(c))

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

int main(){
  int N,x=1;
  cin >> N;
  vector<int> vec(N);
  for(int i=0 ; i < N ; i++) cin >> vec.at(i);
  for(int i=0 ; i < N ; i++){
    x = vec.at(x-1);
    if(x == 2) {
      cout << i + 1; break;
    }
    if(i == N-1) cout << -1;
  }
  
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int fa[N],w[N];
int Find(int x){
	return fa[x]==x?x:fa[x]=Find(fa[x]);
}
int main(){
	int n,m,u,v;scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=0;i<m;i++){
		scanf("%d%d",&u,&v);
		u=Find(u),v=Find(v);
		fa[u]=v;
	}
	for(int i=1;i<=n;i++)w[Find(i)]++;
	int ans=0;
	for(int i=1;i<=n;i++)ans=max(ans,w[i]);
	printf("%d",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  while(true){
      int n,m;cin>>n>>m;
      if(n==0 && m==0) break;
      VVI dp(n+1,vector<ll>(256,INF));
      std::vector<int> c(m),x(n+1);
      for(int i=0;i<m;i++) cin>>c[i];
      for(int i=1;i<=n;i++) cin>>x[i];
      //ll dp[n+1][256];
      for(int i=0;i<n+1;i++)for(int j=0;j<256;j++)dp[i][j]=INF;
      dp[0][128]=0;
      for(int i=0;i<n;i++)for(int j=0;j<256;j++){
          for(int k=0;k<m;k++){
              if(j+c[k]>255) dp[i+1][255]=min(dp[i+1][255],dp[i][j]+(255-x[i+1])*(255-x[i+1]));
              else if(j+c[k]<0) dp[i+1][0]=min(dp[i+1][0],dp[i][j]+(x[i+1])*(x[i+1]));
              else dp[i+1][j+c[k]]=min(dp[i+1][j+c[k]],dp[i][j]+(j+c[k]-x[i+1])*(j+c[k]-x[i+1]));
          }
      }
      ll res=INF;
      for(int i=0;i<256;i++) res=min(res,dp[n][i]);
      cout<<res<<endl;
  }
  return 0;
}

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

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;

    for (size_t i = 0; i < 3 - 1; i++)
    {
        if (S[i] != S[i + 1])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll k;
    string s;

    cin >> k >> s;

    if (s.size() <= k)
    {
        cout << s << endl;
        return 0;
    }

    for (int i = 0; i < k; i++)
    {
        cout << s[i];
    }

    cout << "..." << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
	vector <int> v;
	int n,maxi=0,m=0;          
	cin>>n;
    int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n;i++)
	{
		if(a[i]>=a[i+1])
		m=a[i];
		
		if(m>=a[i] && a[i]>=a[i+1])		
		++maxi;
		else
		{
		v.push_back(maxi); 
		maxi=0; 
	}
	if(i==n-1)
	v.push_back(--maxi);
	}
   cout<<*max_element(v.begin(),v.end());
}

Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {

    static long ans = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();

        int[] a = new int[Q];
        int[] b = new int[Q];
        int[] c = new int[Q];
        int[] d = new int[Q];

        for (int i = 0; i < Q; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }
        sc.close();

        int[] A = new int[N * N];
        A[0] = 1;

        dfs(A, 0, N, M, Q, a, b, c, d);
        System.out.println(ans);
    }

    public static void dfs(int[] A, int roopCount, int N, int M, int Q, int[] a, int[] b, int[] c, int[] d) {

        if (roopCount == N) {
            int now = 0;
            for (int i = 0; i < Q; i++) {
                if (A[b[i]] - A[a[i]] == c[i]) {
                    now += d[i];
                }
            }
            ans = Math.max(now, ans);
            return;
        } else {
            A[roopCount + 1] = A[roopCount];
            while (A[roopCount + 1] <= M) {
                dfs(A, roopCount + 1, N, M, Q, a, b, c, d);
                A[roopCount + 1] += 1;
            }
        }
    }
}

Measured memory_bytes: 37092
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    multiset<ll> color;
    color.insert(A[0]);
    for (ll i = 1; i < N; i++) {
        if (A[i] <= (*color.begin())) {
            color.insert(A[i]);
        } else {
            color.insert(A[i]);
            auto itr = color.find(A[i]);
            itr--;
            color.erase(itr);
        }
    }
    
    // for (auto itr = color.begin(); itr != color.end(); itr++) {
    //     cout << -*itr << " ";
    // }
    // cout << "\n";

    cout << color.size() << "\n";
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;
using boost::algorithm::join;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
int N;
string S;

bool check(int len) {
  unordered_map<string, si> m;

  for (auto i : irange(0,N-len+1)) {
    const string& s = S.substr(i, len);
    m[s].insert(i);
  }

  for (auto kv : m) {
    if (kv.second.size() < 2) continue;
    auto it1 = kv.second.begin();
    auto it2 = kv.second.end();
    it2--;
    if (*it1+len > *it2) continue;

//cerr << "len " << len << ": true" << endl;
    return true;
  }

//cerr << "len " << len << ": false" << endl;

  return false;
}

// [s,e)
// s should be true
int binary_search(int s, int e) {
//cerr << "["<<s<<","<<e<<")"<<endl;
  if (e<=s) return 0;

  int m = (s+e)/2;

  bool mb = check(m);
  if (s==m) {
    assert(mb);
    return s;
  }

  if (mb) {
    return binary_search(m, e);
  }

  return binary_search(s, m);
}

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

  cin >> N >> S;

  if (!check(1)) {
    cout << 0 << endl;
    return 0;
  }

  cout << binary_search(1, N/2+1) << endl;

  return 0;
}


Measured memory_bytes: 6884
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int[] arrA = new int[a];
        int[] arrB = new int[b];
        int[] arrC = new int[c];
        for(int i = 0; i < a; i++)
        	arrA[i] = sc.nextInt();
        for(int i = 0; i < b; i++)
        	arrB[i] = sc.nextInt();
    	for(int i = 0; i < c; i++)
        	arrC[i] = sc.nextInt();
        Arrays.sort(arrA); Arrays.sort(arrB); Arrays.sort(arrC);
        long sum = 0;
        List<Integer> list = new ArrayList<>();
        for(int i = a - x; i < a; i++) {
        	sum += arrA[i];
        	list.add(arrA[i]);
        }
        for(int i = b - y; i < b; i++) {
        	sum += arrB[i];
        	list.add(arrB[i]);
        }
        Collections.sort(list);

        for(int i = 0, idxC = c - 1; i < list.size() && idxC >= 0; i++) {
            if(arrC[idxC] == list.get(i)) continue;
            else if (arrC[idxC] > list.get(i)) {
                sum -= list.get(i);
        		sum += arrC[idxC--];
            } else {
                break;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 92788
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;


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

	if (N - M == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
package main

import "fmt"

func scanIntSlice(N int) []int {
	_slice := make([]int,N)
	for i:=0; i< N ; i++ {
		fmt.Scan(&_slice[i])
	}
	return _slice
}
func getMostCommonCountWithIgnore(m map[int]int,ignore int) (maxKey,maxCount int){
	for key, value := range m {
		if value>maxCount && key!=ignore {
			maxCount=value
			maxKey = key
		}
	}
	return
}

func main() {
	n :=0;
	fmt.Scan(&n)
	v := scanIntSlice(n)
	evens := make(map[int]int)
	odds := make(map[int]int)
	for i:=0 ;i<n/2;i++ {
		evens[v[2*i]]++
		odds[v[2*i+1]]++
	}
	ans := n
	evenMostKey,evenMostCount := getMostCommonCountWithIgnore(evens,-1)
	_,even2ndCount := getMostCommonCountWithIgnore(evens,evenMostKey)
	oddsMostKey,oddsMostCount := getMostCommonCountWithIgnore(odds,-1)
	_,odds2ndCount := getMostCommonCountWithIgnore(odds,oddsMostKey)
	if evenMostKey!=oddsMostKey{
		ans -= evenMostCount+oddsMostCount
	}else {
		a := evenMostCount+odds2ndCount
		b := even2ndCount + oddsMostCount
		if b>a{
			a=b
		}
		ans -= a
	}

	fmt.Println(ans)

}



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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int ans = 0;
    int mi = p[0];
    rep(i,n){
        if(p[i]<=mi){
            ans++;
            mi = p[i];
        }
    } 
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int x, a;
    cin >> x >> a;

    cout << (x < a ? 0 : 10) << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def check(z, zz, z_list):
  if len(z_list) == 0:
    if z != zz:
      return 0
    else:
      return 1
  else:
    z_n = len(z_list)
    z_hash = {}
    z_hash[0] = {}
    z_hash[0][zz] = 1
    z_hash[z_n] = {}
    z_hash[z_n][z] = 1
    for i in range(0,z_n):
      if i+1 not in z_hash:
        z_hash[i+1] = {}
        for b_z in z_hash[i]:
          a_z = b_z + z_list[i]
          z_hash[i+1][a_z] = 1
          a_z = b_z - z_list[i]
          z_hash[i+1][a_z] = 1
      else:
        for b_z in z_hash[i]:
          a_z = b_z + z_list[i]
          if a_z in z_hash[i+1]:
            return 1
          a_z = b_z - z_list[i]
          if a_z in z_hash[i+1]:
            return 1
        return 0
      if z_n-i-1 not in z_hash:
        z_hash[z_n-i-1] = {}
        for a_z in z_hash[z_n-i]:
          b_z = a_z + z_list[z_n-i-1]
          z_hash[z_n-i-1][b_z] = 1
          b_z = a_z - z_list[z_n-i-1]
          z_hash[z_n-i-1][b_z] = 1
      else:
        for a_z in z_hash[z_n-i]:
          b_z = a_z + z_list[z_n-i-1]
          if b_z in z_hash[z_n-i-1]:
            return 1
          b_z = a_z - z_list[z_n-i-1]
          if b_z in z_hash[z_n-i-1]:
            return 1
        return 0



s = input()
x, y = map(int, input().split())
data = s.split("T")
xx, yy = 0, 0
i = 0
x_list = []
y_list = []
for Fs in data:
  if len(Fs) == 0:
    i += 1
  else:
    if i == 0:
      xx = len(Fs)
    elif i % 2 == 0:
      x_list.append(len(Fs))
    else:
      y_list.append(len(Fs))
    i += 1
if check(x, xx, x_list) == 1 and check(y, yy, y_list) == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 139528
//package com.karancp;

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.InputStream;


 class Main{
    public static void main(String args[])
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader z = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        task solver =new task();
        solver.solve(z,out);
        out.close();
    }

    static class task
    {

        static long gcd(long a,long b)
        {
            if(b==0)return a;
            else return gcd(b,a%b);
        }
        static long lcm(long a,long b)
        {
            long pp=a*b;
            long bb=gcd(a,b);
            long res =pp/bb;
            return res;
        }
        static int max(int a,int b)
        {
            return Math.max(a,b);
        }
        static int min(int a,int b)
        {
            return Math.min(a,b);
        }





        public static void solve(InputReader z, PrintWriter out) {
            int n=z.nextInt();
            int ar[][]=new int[n][3];
            int i;int j;
            for(i=0;i<n;i++)
            {
                for(j=0;j<3;j++)ar[i][j]=z.nextInt();
            }
            int dp[][]=new int[n+1][4];
            dp[1][1]=ar[0][0];
            dp[1][2]=ar[0][1];
            dp[1][3]=ar[0][2];
            for(i=2;i<=n;i++)
            {
                dp[i][1]=ar[i-1][0]+max(dp[i-1][2],dp[i-1][3]);
                dp[i][2]=ar[i-1][1]+max(dp[i-1][1],dp[i-1][3]);
                dp[i][3]=ar[i-1][2]+max(dp[i-1][1],dp[i-1][2]);
                //out.println(min(dp[i][1],min(dp[i][2],dp[i][3])));
                //out.println(dp[i][1]+" "+dp[i][2]+" "+dp[i][3]);
            }
            out.print(max(dp[n][1],max(dp[n][2],dp[n][3])));
        }
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }

    }



}

Measured memory_bytes: 50016
#include <bits/stdc++.h>
#include "atcoder/all"
using namespace std;
using namespace atcoder;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
const long long int sMod = 998244353;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,m;
    cin >> n >> m;
    scc_graph graph(n);
    rp(i,m){
        ll a,b;
        cin >> a >> b;
        graph.add_edge(--a,--b);
        graph.add_edge(b,a);
    }
    vector<vi> ans = graph.scc();
    print((int)ans.size()-1);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 11112
n, k = map(int, input().split())
s = input()

aa = []
prev = None
for c in s:
    if prev != c:
        aa.append((c, 1))
        prev = c
    else:
        _, count = aa[-1]
        aa[-1] = (prev, count + 1)

kk = 0
candidate = 0
total = 0
i = 0
if aa[i][0] == '1':
    total = aa[i][1]
    candidate = total
    i += 1


while i < len(aa):
    if aa[i][0] == '0':
        if kk < k:
            kk += 1
            total += aa[i][1]
            if i < len(aa) - 1:
                i += 1
                total += aa[i][1]
            candidate = max(candidate, total)
        else:
            total -= aa[i - k * 2][1]
            if i - k * 2 - 1 >= 0:
                total -= aa[i - k * 2 - 1][1]

            total += aa[i][1]
            if i < len(aa) - 1:
                i += 1
                total += aa[i][1]
            candidate = max(candidate, total)

    i += 1

print(candidate)


Measured memory_bytes: 10364
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9



int main() {
	ll N, A, B;
	cin >> N >> A >> B;

	ll S = A * (N - 1) + B;
	ll L = A + (N - 1) * B;

	if (A > B) {
		cout << 0 << endl;
	}
	else {
		if (N == 1) {
			if (A == B) cout << 1 << endl;
			else cout << 0 << endl;
		}
		else {
			cout << L - S + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

#N, K = [ int(x) for x in input().split() ]
#V = [ int(x) for x in input().split() ]

N = int(input())

print((N-2)*180)



Measured memory_bytes: 25392