akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    ios::sync_with_stdio(false);
    map<pair<ll,ll>,int> mp;
    int n;
    cin >> n;
    mint ans = 0;
    rep(i,n) {
        ll a,b;
        cin >> a >> b;
        if(a == 0 && b == 0) {ans+=1;continue;}
        else if(a == 0) mp[make_pair(0,1)]++;
        else if(b == 0) mp[make_pair(1,0)]++;
        else {
            ll g = __gcd(a,b);
            mp[make_pair(a/g, b/g)]++;
        }
    }
    vector<mint> pow2(n);
    pow2[0] = 1;
    rep(i,n) pow2[i+1] = pow2[i]*2;
    mint ans2 = 1;
    while(!mp.empty()) {
        auto now = begin(mp);
        mp.erase(now);
        ll a = (*now).first.first;
        ll b = (*now).first.second;
        int num = (*now).second;
        int enemy = 0;
        if(a == 0) {
            enemy += mp[make_pair(1,0)];
            mp.erase(make_pair(1,0));
        } else if(b == 0) {
            enemy += mp[make_pair(0,1)];
            mp.erase(make_pair(0,1));
        } else {
            num += mp[make_pair(-a,-b)];
            mp.erase(make_pair(-a,-b));
            enemy += mp[make_pair(-b,a)];
            mp.erase(make_pair(-b,a));
            enemy += mp[make_pair(b,-a)];
            mp.erase(make_pair(b,-a));
        }
        ans2 *= pow2[num] + pow2[enemy] - 1;
    }
    ans += ans2;
    ans-=1;
    cout << ans << endl;
}


Measured memory_bytes: 17144
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  N, K = map(int, input().split())
  counts = [0] * N

  for _ in range(K):
    input()
    for n in map(int, input().split()):
      counts[n - 1] = 1

  print(len([v for v in counts if v == 0]))


if __name__ == '__main__':
  main()


Measured memory_bytes: 67608
#include <iostream>
#include <string>


using namespace std;

int main(void)
{
    string N;
    long long ans = 0;

    cin >> N;

    for (int i = 0; i < N.size(); i++) {
        ans += (long long)(N[i] - '0');
    }

    if (ans % 9 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t;
    //cin>>t;
    //while(t--)
    {
        string s,t;
        cin>>s;
        for(int i = 0;i<s.size();i++)
        {
            cout<<"x";
        }
    }
    return 0;
}

Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int = 0, 0, 0

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	_, _ = strconv.Atoi(read())
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(read())
	}
	var big, small int = 0, 1e9
	mark := make(map[int]int)
	for i := 0; i < N; i++ {
		if big <= A[i] {
			big = A[i]
			mark[big-small]++
		}
		if A[i] < small {
			small = A[i]
			big = A[i]
		}
	}
	for key, value := range mark {
		if cnt < key {
			cnt = key
			ans = value
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; 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
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

int main() {
  int n, c, k;
  cin >> n;

  map<ll, ll> t;

  ll tmp;
  rep(i, n) {
    cin >> tmp;
    t[tmp]++;
  }
  ll ans = 0;
  for (auto x:t){
    if(x.second%2==1) ans++;
  }

  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n, x, y;
	cin >> n >> x >> y;
	x--; y--;

	auto f = [&] (ll a, ll b) {
		return min(b - a, abs(a - x) + abs(b - y) + 1);
	};

	vector<ll> ans(n, 0);
	for (ll i = 0; i < n - 1; i++) {
		for (ll j = i + 1; j < n; j++) {
			ans[f(i, j)]++;
		}
	}
	for (ll i = 1; i < n; i++) cout << ans[i] << endl;
}

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

bool f(string s)
{
  string t = s;
  reverse(t.begin(), t.end());
  return s==t;
}

int main()
{
  string s; cin >> s;
  int n = s.length();
  if (!f(s) || !f(s.substr(0, n/2)) || !f(s.substr(n/2+1, n/2))) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, i;

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

    std::cin >> N >> i;

    i -= 1;

    int res = N - i;
    std::cout << res << std::endl;
}


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

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N, M = MII()
    s = []
    for _ in range(M):
        s.append(list(map(int, input().split()))[1:])
    p = LII()

    ans = 0
    for i in range(2**N, 2**(N+1)):
        b = bin(i)[3:]
        t = [0] * M
        for j, sj in enumerate(s):
            for k, bi in enumerate(list(b)):
                if bi == '1' and k+1 in sj:
                    t[j] += 1
            if t[j] % 2 != p[j]:
                ans -= 1
                break
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
#define endl '\n'

int32_t main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    	cin>>arr[i];
  	int ans=0;
  	for(int i=1;i<n;i++)
  	{
  		if(arr[i]>=arr[i-1])
  			continue;
  		ans+=(arr[i-1]-arr[i]);
  		arr[i]=arr[i-1];
  	}
  	cout<<ans;
}   

Measured memory_bytes: 5184
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int acc = 0;
        int pc = 0;
        int[] wa = new int[n];
        boolean[] ac = new boolean[n];
        for(int i=0; i<m; i++) {
            int a = sc.nextInt() - 1;
            String res = sc.next();
            if(ac[a]) {
                continue;
            }
            if(res.equals("AC")) {
                acc++;
                pc+=wa[a];
                ac[a] = true;
            } else {
                wa[a]++;
            }
        }
        System.out.println(String.format("%d %d", acc, pc));


    }

}


Measured memory_bytes: 62008
import numpy as np

s = int(input())
s_root = int(np.ceil(np.sqrt(s)))
upper_s_square = s_root**2
lower_s_square = (s_root-1)**2

solution = [0]*6

if upper_s_square == s:
    solution[2] = s_root
    solution[5] = s_root
elif s_root * (s_root - 1) < s:
    solution[2] = s_root
    solution[3] = upper_s_square - s
    solution[4] = 1
    solution[5] = s_root
else:
    solution[2] = s_root
    solution[3] = s_root*(s_root-1) - s
    solution[4] = 1
    solution[5] = s_root-1
    
print(*solution)

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int cnt=-1;
  for(int i=0; i<N; i++){
    cin >> a.at(i);
    if(a.at(i)==1) cnt=0;
  }
  int ans=0;
  int temp=1;
  for(int i=0; i<N; i++){
    if(a.at(i)==temp) temp++;
    else ans++;
  }
  if(cnt==-1) ans=cnt;
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;


int main() {
    int a,b,c;
    cin>>a>>b>>c;
    int ma=max(max(a,b),max(b,c));
    int diff=ma*3-a-b-c;
    if(diff%2==0){
        cout<<diff/2<<endl;
    }else{
        cout<<(diff+3)/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        int[] pos = new int[26];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
        for (int i = 0; i < n; i++) {
            int[] check = new int[26];
            Arrays.fill(check, 0);
            for (int j = 0; j < s[i].length(); j++) {
                int tag = (int) s[i].charAt(j);
                check[tag - 97]++;
            }
            for (int j = 0; j < 26; j++) {
                if (i == 0) {
                    pos[j] = check[j];
                } else {
                    pos[j] = Math.min(pos[j], check[j]);
                }
            }

        }
        for (int i = 0; i < 26; i++) {
            while (pos[i] > 0) {
                System.out.print((char) (i + 97));
                pos[i]--;
            }
        }
        System.out.println();

    }
}

Measured memory_bytes: 21844
n = int(input())
x = [list(map(int, input().split())) for _ in range(n)]

d = 0
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        d += ((x[i][0] - x[j][0]) ** 2 + (x[i][1] - x[j][1]) ** 2) ** 0.5
        cnt += 1

print(d * (n - 1) / cnt)

Measured memory_bytes: 9452
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define R register
using namespace std;
namespace chu_xuan{
    void swap(int &a,int &b){R int tmp=a;a=b,b=tmp;}
    void read(int &a) {a=0;int b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b;}
    int In() {int a=0,b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*b;}
    int max(int a,int b){return a>b?a:b;}
    int min(int a,int b){return a>b?b:a;}
}using namespace chu_xuan;

int main()
{
    double a,b;
    cin>>a>>b;
    printf("%.10lf",a/b);
    return 0;
}

Measured memory_bytes: 256
import sys
X, Y = map(int, input().split())

if Y % 2 == 1:
    print("No")
    sys.exit()

turu = (4 * X - Y) / 2
kame = X - turu

if turu >= 0 and kame >= 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9176
x,y=map(int,input().split())

A=[1,3,5,7,8,10,12]
B=[4,6,9,11]

if x==2 and y==2:
  print('Yes')
elif x in A and y in A:
  print('Yes')
elif x in B and y in B:
  print('Yes')
else:
  print('No')
  

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

const int maxn = 2e5 + 42;
int memo[maxn];
int f(int x){
    if(memo[x] != -1) return memo[x];
    int &ans = memo[x];
    ans = 1 + f(x % __builtin_popcount(x));
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(memo, -1, sizeof(memo));
    memo[0] = 0;
    int n, i, j; cin >> n;
    string x;
    cin >> x;
    reverse(all(x));
    int cnt1 = count(all(x), '1');
    int mod[2] = {cnt1 + 1, cnt1 - 1};
    int sm[2] = {0,0};
    int p2[n][2]; // 2^i mod[j]
    for(i=0;i<n;i++){
        int d = x[i] - '0';
        for(j=0;j<2;j++){
            if(mod[j] <= 0) continue;
            if(i == 0){
                p2[0][j] = 1;
            }else{
                p2[i][j] = (p2[i-1][j] * 2) % mod[j];
            }
            sm[j] = (sm[j] + d * p2[i][j])%mod[j];
        }
    }
    vi ans(n);
    for(i=0;i<n;i++){
        int d = x[i] - '0';
        if(d == 0){
            int smi = (sm[0] + p2[i][0])%mod[0];
            ans[i] = 1 + f(smi);
        }else{ // d == 1
            if(cnt1 == 1){
                ans[i] = 0;
            }else{
                int smi = (sm[1] - p2[i][1])%mod[1];
                if(smi < 0) smi += mod[1];
                ans[i] = 1 + f(smi);
            }
        }
    }
    reverse(all(ans));
    for(auto r : ans) cout << r << "\n";
    return 0;
}

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;

void solve(){
    int N, K;
    scanf("%d%d", &N, &K);
    int M = (N + 1) / 2;
    printf((M >= K) ? "YES\n" : "NO\n");
    return;
}

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

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	static boolean[][] field;
	static int n;
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(true) {
			n=in.nextInt();
			if(n==0)break;
			
			int res=0;
			field=new boolean[n][n];
			
			for(int i=0;i<n;i++) {
				String str=in.next();
				char[] m=str.toCharArray();
				for(int j=0;j<n;j++) {
					field[i][j]= (m[j]=='1')? true :false;
				}
			}
			
			for(int i=0;i<n;i++) {
				for(int j=0;j<n;j++) {
					if(field[i][j]) {
						res=Math.max(res, countSystem(i,j));
					}
				}
			}
			
			System.out.println(res);
		}
	}
	
	static int countSystem(int y,int x) {
		int res=0;
		
		int dy[]= {-1,-1,0,1,1,1,1,0,-1},dx[]= {0,1,1,1,0,-1,-1,-1};
		for(int i=0;i<8;i++) {
			res=Math.max(res, 1+countOne(y,x,dy[i],dx[i]));
		}
		
		return res;
	}
	
	static int countOne(int y,int x,int dy,int dx) {
		int py=y,px=x,res=0;
		
		while(true) {
			//System.out.println(res);
			if(py+dy>=0 && py+dy<n && px+dx>=0 && px+dx<n && field[py+dy][px+dx]) {
				py+=dy;px+=dx;
			}
			else break;
			res++;
		}
		
		return res;
	}

}



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

int n, a, b;
string c, d;

int main() {
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> c >> d;
        if (c > d) a+=3;
        else if (c < d) b+=3;
        else {
            a++; b++;
        }
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 3144
from itertools import permutations
n = int(input())
s = [input() for i in range(n)]
lsa=list() #mn,end
lsd=list()
for i in range(n):
    now = 0
    mn = 0
    for c in s[i]:
        if c == '(':
            now += 1
        else:
            now -= 1
            mn = min(mn,now)
    if now >= 0:
        lsa.append([mn,now])
    else:
        lsd.append([mn-now,-now])

lsa.sort(reverse=True)
tmn = 0
tend = 0
flag=True
# ascent
for mn,end in lsa:
    tmn = mn + tend
    tend += end
    if tmn < 0 or tend < 0:
        flag = False
        break
tenda = tend

# descent
lsd.sort(reverse=True)
tmn = 0
tend = 0

for mn,end in lsd:
    tmn = mn + tend
    tend += end
    if tmn < 0 or tend < 0:
        flag=False
        break

if flag and tend == tenda:
    print("Yes")
else:
    print("No")





Measured memory_bytes: 245068
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
int n,m;
auto yebi (vector<int> & v){
    int a =0, b = 0;
    for(int i = 0; i < m; i++)
        a += v[i];
    return a;
}
signed main(){
    cin >> n >> m;
    auto data = vectors(n, 3,0LL);
    rep(i,n)rep(j,3) cin >> data[i][j];
    int ans = 0;
    rep(bit,8){
        vector<int>res;
        rep(j,n){
            int temp = 0;
            rep(k,3){
                if(bit & 1 << k) temp += -1 * data[j][k];
                else temp +=data[j][k];
            }
            res.push_back(temp);
        }
        sort(all(res),greater<int>());
        cmax(ans,yebi(res));
    }
    cout << ans;
}




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

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

Node root;

Node treeMinimum(Node x){
  while(x->left !=NIL){
    x=x->left;
  }
  return x;

}

Node treeMaximum(Node x){
  while(x->right !=NIL){
    x=x->right;
  }
  return x;

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

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  else if(x->left !=NIL ) return treeMaximum(x->left);

  y=x->parent;
  while(y!=NIL && x==y->right) {
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right == NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x= y->right;

  if(x!=NIL) x->parent=y->parent;

  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right=x;

  if(y!=z) z->key=y->key;

}

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) {
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }


}
void preorder(Node u){
  if(u!=NIL){
    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");
    } 

    
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
   
  }

  return 0;
}

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

typedef long long LL;
const int MAXN=1000000+5;
const int INF=0x3f3f3f3f;

int main()
{
    LL a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    LL d=min(x,y);
    LL sum=d*min(2*c,a+b);
    x-=d;
    y-=d;
    if(x>0)
        sum+=x*min(2*c,a);
    else if(y>0)
        sum+=y*min(2*c,b);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

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

        int DAYS = 5;
        int TIME = 2;
        int[][][] F = new int[N][DAYS][TIME];
        for (int n = 0; n < N; n++) {
            for (int d = 0; d < DAYS; d++) {
                for (int t = 0; t < TIME; t++) {
                    F[n][d][t] = sc.nextInt();
                }
            }
        }

        int TOGETHER_DAYTIME = 11;
        long[][] P = new long[N][TOGETHER_DAYTIME];
        for (int n = 0; n < N; n++) {
            for (int dt = 0; dt < TOGETHER_DAYTIME; dt++) {
                P[n][dt] = sc.nextLong();
            }
        }

        long max = Long.MIN_VALUE;
        for (int dt = 0; dt < 2 << DAYS * TIME; dt++) {
            long tmpMax = 0;
            boolean haveTogetherShop = false;
            for (int n = 0; n < N; n++) {
                int cnt = 0;
                for (int d1 = 0; d1 < DAYS; d1++) {
                    int timeBit = (dt >> d1 * TIME) & 3;
                    for (int t1 = 0; t1 < TIME; t1++) {
                        if (((timeBit >> t1) & 1) == 1 && F[n][d1][t1] == 1) {
                            cnt++;
                            haveTogetherShop = true;
                        }
                    }
                }
                tmpMax += P[n][cnt];
            }
            if (haveTogetherShop) {
                max = Math.max(max, tmpMax);
            }
        }

        out.println(max);
    }
}

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

typedef long long ll;

ll gcd(ll a, ll b) {
  if (a % b == 0) return b;

  return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
  // a * b / gcd(a, b) だとオーバーフローするので先に割って値を小さくしておく
  return a / gcd(a, b) * b;
}

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

  // ユークリッドの互除法でgcdを求めるために0ではなく、1で初期化
  ll ans = 1;

  for (int i = 0; i < N; i++) {
    ll t;
    cin >> t;

    ans = lcm(ans, t);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int asc(const int*a,const int*b){return *a-*b;}
int main()
{
  int A[200000],N=IN(),K=IN(),l,m=0,r,accum=1,sign=1;long x,y;
  rep(i,N)A[i]=IN(),m+=A[i]<0?1:0;
  std::sort(A,A+N);
  if(K&1)accum=A[N-1],sign=(A[N-1]<0?-1:1),N--,K--;
  l=0,r=N-1;
  while(K)
  {
    x=1l*A[l]*A[l+1],y=1l*A[r]*A[r-1];
    if(x*sign>y*sign)x%=MOD,accum=1l*accum*x%MOD,l+=2;
    else y%=MOD,accum=1l*accum*y%MOD,r-=2;
    K-=2;
  }
  return printf("%ld\n",(1l*accum%MOD+MOD)%MOD),0;
}

Measured memory_bytes: 2308
#include <iostream>
using namespace std;
int main(void){
    int age , fee;      //年齢、料金
    cin >> age >> fee;      //年齢、料金の格納
    
    if (age >= 13) {
        cout << fee << endl;
    } else if (age >= 6) {
        cout << fee / 2 << endl;
    } else {
        cout << "0" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        if isCLKWISE(phU) : continue
        while(True):
            del phU[-2]
            try:
                if isCLKWISE(phU) : break
            except IndexError:
                break

    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        if isCLKWISE(phL) : continue
        while(True):
            del phL[-2]
            try:
                if isCLKWISE(phL) : break
            except IndexError:
                break
                
                
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33908
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i=0; i<(int)(n); ++i)
 
template<class T> inline bool chmin(T &a, T b) { if(a>b){ a=b; return true; }  return false;}
template<class T> inline bool chmax(T &a, T b) { if(a<b){ a=b; return true; }  return false;}

ll dp[100010][3];
ll a[100010][3];


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

  REP(i, N){
    REP(j, 3){
      cin >> a[i][j];
    }
  }
  // 幸福を最大化する
  REP(i, N){
    REP(now, 3){
      REP(nex, 3){
        if(now==nex) continue; // 前日と一緒の行動はできない
        chmax(dp[i+1][nex], dp[i][now]+a[i][nex]);
      }
    }
  }
  // ans
  ll res = 0;
  REP(j, 3) chmax(res, dp[N][j]);
  cout << res << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, long long> m;
map<long long,long long>cnt;
int main(){
    long long h, w, n; cin >> h >> w >> n;
    for (int i = 0; i < n; i++){
        long long a, b; cin >> a >> b;
        a--;b--;
        for (int k = -1; k <= 1; k++){
            for (int l = -1; l <= 1; l++){
                if(a+k <= 0 || b+l <= 0 || a+k >= h-1 || b+l >= w-1)continue;
                m[make_pair(a+k,b+l)]++;
            }
        }
    }
    long long sum = (h-2)*(w-2);
    for (map<pair<long long,long long>,long long>::iterator it = m.begin(); it != m.end(); it++)
    {
        sum--;
        cnt[it->second]++;
    }
    cout << sum << endl;
    for (int i = 1; i < 10; i++){
        cout << cnt[i] << endl;
    }
}

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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n, x;
  cin >> n >> x;
  V<int> a(n);
  REP(i, n) cin >> a[i];
  sort(ALL(a));

  int ret = 0;
  REP(i, n) {
    if(x >= a[i]) {
      x -= a[i];
      ret++;
    }
  }
  if(x > 0 && ret == n) ret--;
  cout << ret << endl;

  return 0;
}


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

struct edge {
    int to;
    int cost;
};
using P = pair<int, int>;
vector<vector<edge>> G;
vector<int> d;
void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        rep(i, G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

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

    G.resize(10);
    d.resize(10);
    rep(i, 10) rep(j, 10) {
        int a;
        cin >> a;
        G[j].push_back({i, a});
    }
    dijkstra(1);
    ll ans = 0;
    rep(i, H) rep(j, W) {
        int a;
        cin >> a;

        if (a != -1)
            ans += d[a];
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int N;
int a[101];

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i ++) {
        scanf("%d", &a[i]);
    }
    int M = 0;
    int m = 1001;
    for (int i = 0; i < N; i ++) {
        M = max(M, a[i]);
        m = min(m, a[i]); 
    }
    printf("%d\n", M - m);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define task "MAXFRAME"

#define nguyen_dz the_best
#define ll long long
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define Yes cout <<"Yes"<<endl;
#define No cout<<"No" <<endl;


using namespace std;
const ll  maxn= 4e6+100;

ld x[maxn], r[maxn];
ld ans[maxn];
stack <pair<ld,ld>> st;
ld dosth (ld x, ld r )
{
    ld nw=r;
  while (!st.empty())
  {
      ld x1= st.top().ff;
      ld r1= st.top().ss;
      r=min(r,(x1-x)*(x1-x)*1.0/(4.0*r1));
      if (r>=r1) st.pop();
      else break;
  }

  st.push(make_pair(x,r));
  return r;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    if (fopen(task".INP","r"))
    {
        freopen(task".INP", "r", stdin);
        freopen(task".OUT", "w", stdout);
    }
    ll h, m, h1 ,m1, k;
    cin>> h>>m>>h1>>m1>>k;
    ll t= h*60 +m;
    ll t1= h1*60+ m1;
    t1-=t;
    cout <<max(t1-k,0ll)<<endl;



}



Measured memory_bytes: 3620
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+10;
const int MAX2=2e5+4;
const int MAAX=2e18;
const int MOD=1e9+7;
int dp[1005][1005];
int n,m;
char c[1005][1005];
int fun(int idx,int idx2)
{
    if(idx==n-1&&idx2==m-1)
    {
        return 1;
    }
    if(c[idx][idx2]=='#') return 0;
    int &ret=dp[idx][idx2];
    if(ret!=-1)
    {
        return ret;
    }
    ret=0;
    if(idx+1<=n)
    {
        ret=fun(idx+1,idx2);
    }
    ret%=MOD;
    if(idx2+1<=m)
    {
        ret+=fun(idx,idx2+1);
    }
ret%=MOD;
    return ret;
}
in main()
{
  memset(dp,-1,sizeof dp);
cin>>n>>m;
for(int i=0;i<n;i++)
{
    for(int j=0;j<m;j++)
    {
        cin>>c[i][j];
    }
}
cout<<fun(0,0)<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	string x;cin>>x;
	int k=0,ans=0;
    int n=x.size();
	int cnts=0,cntt=0;
	rep(i,n){
		if(x[i]=='T'){
			while(x[i+1]=='T'){
				i++;
			}        
			for(int j=k;j<=i;++j){
				if(x[j]=='S')cnts++;
				if(x[j]=='T')cntt++;
			}
			ans+=min(cnts,cntt);
			if(cnts>cntt){
				cnts-=cntt;
				cntt=0;
			}
			else {
				cntt=0;cnts=0;
			}
			k=i+1;
		}
	}
	cout<<n-ans*2<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>

int qsf(const void *a,const void *b){
	return *(int *)a - *(int *)b;
}
int N;
int L[200];
int main(){
	int i,sum = 0;
	scanf("%d",&N);
	for(i=0;i<2*N;i++){
		scanf("%d",L+i);
	}
	qsort(L,2*N,sizeof(int),qsf);
	
	for(i=0;i<N;i++){
		sum += L[i*2];
	}
	printf("%d",sum);
	return 0;
}


Measured memory_bytes: 128
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e6 + 10;
char s1[N], s2[N];
int fail[N];
int ans[N];
int flag[N];
int dfs(int x, int mod, int m, int s, int o = 0)
{
	x %= mod;
	if (x == 0) x = mod;
	if (x == s && o == 1) return INF;
	if (ans[x]) return ans[x];
	if (flag[x] == 0) return 0;
	return ans[x] = dfs(x + m, mod, m, s, 1) + 1;
}
void getfail(char str[], int n)
{
	fail[1] = 0;
	int j = 0;
	for (int i = 2; i <= n; i++)
	{
		while (j > 0 && str[j + 1] != str[i]) j = fail[j];
		if (str[j + 1] == str[i]) j++;
		fail[i] = j;
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%s", s1 + 1);
	scanf("%s", s2 + 1);
	int n = strlen(s1 + 1);
	int m = strlen(s2 + 1);
	int len = (m + n - 1) / n * n;
	for (int i = n + 1; i <= len * 2; i++)
	{
		s1[i] = s1[i - n];
	}
	getfail(s2, m);
	int j = 0;
	for (int i = 1; i <= len * 2; i++)
	{
		while (j > 0 && s2[j + 1] != s1[i]) j = fail[j];
		if (s2[j + 1] == s1[i]) j++;
		if (j == m)
		{
			int o = (i - m + 1) % len;
			if (o == 0) o = len;
			flag[o] = 1;
			j = fail[j];
		}
	}
	int res = 0;
	for (int i = 1; i <= len; i++)
	{
		res = max(res, dfs(i, len, m, i));
	}
	if (res >= INF) res = -1;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 27264
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define forn(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define ford(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define int long long
#define ii pair<int,int>
#define ar array
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define sz(x) ((int)(x).size())
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;

bool get(int x,int y,int z){
    if(x==y||x==z||y==z) return false ;
    return (x+y>z)&&(x+z>y)&&(y+z>x) ;
}

void solve(){
    int n ;
    cin >> n ;
    int ans = 0;
    vector<int> a(n) ;
    for(auto& x : a) cin >> x ;
    forn(i,n){
        rep(j,i+1,n){
            rep(k,j+1,n){
                if(get(a[i],a[j],a[k])) ans++ ;
            }
        }
    }
    cout << ans << endl ;
}


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


Measured memory_bytes: 3648
#include <stdio.h>

int main(void) {
	int x, y, z = 0;
	scanf("%d %d %d", &x, &y, &z);
	if ((x<y) && (y<z)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 2112
#include <cstdio>

int main(){
	int A, B, AB, O;
	int n;
	char blood[2];
	A = B = AB = O = 0;
	while(scanf("%d,%s", &n, blood) != EOF){
		switch(blood[0]){
		case 'A':
			if(blood[1] == 'B'){
				AB++;
			}else {
				A++;
			}
			break;
		case 'B':
			B++;
			break;
		case 'O':
			O++;
			break;
		}
		blood[1] = 'z';
	}
	printf("%d\n%d\n%d\n%d\n", A, B, AB, O);
	return 0;
}

Measured memory_bytes: 1024
import queue

def bfs(w, h, maze):
    dx = [-1, 0, 0, 1]
    dy = [0, 1, -1, 0]
    dist = [ [-1] * (w+1) for _ in range(h+1) ]
    q = queue.Queue()
    q.put([0, 0, 0])
    dist[0][0] = 0

    while not q.empty():
        x, y, d = q.get()
        for i in range(4):
            nx = x+dx[i]
            ny = y+dy[i]

            if maze[y][x][i] == 0: continue
            if dist[ny][nx] != -1: continue
            
            q.put( [nx, ny, d+1] )
            dist[ny][nx] = d+1

    return dist[h-1][w-1] + 1

while True:
    w, h = map(int, input().split())
    if w == 0 and h == 0: break
    maze = [ [[0] * 4 for x in range(w+1)] for _ in range(h+1) ]

    for i in range(h*2-1):
        if i & 1:
            t = [ int(x) for x in input().split() ]
            for j, tt in enumerate(t):
                if tt == 0:
                    maze[i//2][j][1] = 1
                    maze[i//2+1][j][2] = 1
        else:
            t = [ int(x) for x in input().split() ]
            for j, tt in enumerate(t):
                if tt == 0:
                    maze[i//2][j][3] = 1
                    maze[i//2][j+1][0] = 1
    print(bfs(w, h, maze))



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

int main(){
  int n, a[100], b[201], s, ans;
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> a[i];
  ans = 0;
  for(int i = 0; i < n; i++)
    ans = ans + a[i] * a[i];
  for(int i = -100; i < 101; i++){
    s = 0;
    for(int j = 0; j < n; j++){
      s = s + (a[j] - i) * (a[j] - i);
      if(s > ans) break;
    }
    ans = min(ans, s);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int LCS(char *, char *);
int max(int, int);
int main(){
  int q, i;
  char X[1000], Y[1000]; 
  int Z[150];
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf(" %s", X);
    scanf(" %s", Y);
    Z[i] = LCS(X, Y);
  }
  for(i = 0; i < q; i++){
    printf("%d\n", Z[i]);
  }
  return 0;
}


int LCS(char *x, char *y){
  int i, j, a, b;
  int lcs[1001][1001];
  a = strlen(x);
  b = strlen(y);
  for(i = 0; i < a; i++){
    lcs[i][0] = 0;
  }
  for(j = 0; j < b; j++){
    lcs[0][j] = 0;
  }

  for(i = 1; i <= a; i++){
    for(j = 1; j <= b; j++){
      if(x[i-1] == y[j-1]) lcs[i][j] = lcs[i-1][j-1]+1;
      else lcs[i][j] = max(lcs[i][j-1], lcs[i-1][j]);
    }
  }
  return lcs[a][b];
}

int max(int a, int b){
  if(a > b) return a;
  else return b;
}

Measured memory_bytes: 4520
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------

void _main() {
	int A,B;
	cin >> A >> B;
	int ans;
	if (A >= 13) {
		ans = B;
	}
	else if (A >= 6) {
		ans = B / 2;
	}
	else {
		ans = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

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

	if (a == 1){
		a+=13;
	}
	if (b == 1){
		b+=13;
	}
	if (a == b){
		cout << "Draw" << endl;
	}
	else if (a < b){
		cout << "Bob" << endl;
	}
	else{
		cout << "Alice" << endl;
	}

	return 0;
}


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

int main()
{
    int n;
    int cnt = 0;
    cin >> n;
    for (int a = 1; a <= n; a++){
        for (int b = 1; b <= (n/a); b++){
            if (n-a*b > 0) {
                cnt++;
            }
        }
    }
    cout << cnt;
}


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

using namespace std;
 
string s;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>s;
    int n = s.length();
    
    if ((s[0]==s[n-1]) - n%2) cout<<"First"; else cout<<"Second";
    
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int n;
string s[60];
map<char,int>mp;
signed main(){
    for(int i=0;i<26;i++){
        char c='a'+i;
        mp[c]=200;
    }
    cin>>n;
    rep(i,n){
        cin>>s[i];
        int l=s[i].size();
        map<char,int>mp2;
        rep(j,l){
            mp2[s[i][j]]++;
        }
        rep(j,26){
            char c='a'+j;
            mp[c]=min(mp[c],mp2[c]);
        }
    }
    rep(i,26){
        char c='a'+i;
        if(mp[c]!=200){
            rep(j,mp[c])cout<<c;
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256