akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <ctype.h>

int main(int argc, const char * argv[]) {
    int i=0,kazu=0;
    char abc[]="abcdefghijklmnopqrstuvwxyz";
    char aaa;
    int sum[27]={0};
    
    while(scanf("%c",&aaa)!= EOF){
        if(isupper(aaa)){
            kazu=tolower(aaa);
        }else{
            kazu=aaa;
        }
        for(i=0;i<26;i++){
            if(kazu==abc[i]){
                sum[i]++;
            }
        }
        i++;
        
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n",abc[i],sum[i]);
    }
    return 0;
}

Measured memory_bytes: 548
#include <iostream>
using namespace std;
int n;
bool esPal1(string cad){
    int aux = cad.size();
    for(int i = 0; i < aux / 2; i++)
        if(cad[i] != cad[aux - i - 1])
            return 0;
    return 1;
}
int main(){
    string cad; cin >> cad;
    n = cad.size();
    string a = cad.substr(0, (n - 1) / 2), b = cad.substr(((n + 3) / 2) - 1, n - ((n + 3) / 2) + 1);
    if(esPal1(cad) && esPal1(a) && esPal1(b))
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


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

int Digits(long i) {
	int ans = 0;
	while (i > 0) {
		ans++;
		i /= 10;
	}
	return ans;
}

int main() {
	long n;
	cin >> n;
	long lim = sqrt(n);
	int ans = 10000;
	for (int i = 1; i <= lim; i++) {
		if (n % i) continue;
		int tmp = Digits(n / i);
		if (ans < tmp) break;
		else ans = tmp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int a,b;
    int h;
    ld m;
    cin >> a >> b >> h >> m;
    cout << fixed << setprecision(20) << sqrtl(a*a+b*b - 2*a*b*cosl(M_PI * (30*h - 11*m/2) / 180)) << endl;
}

Measured memory_bytes: 4188
n=int(input())
a=[list(map(int,input().split())) for i in range(n)] 

dp=[]
for i in range(n+1):
    dp.append([0,0,0])

for i in range(0,n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][k]=max(dp[i+1][k],dp[i][j]+a[i][k])

print(max(dp[n]))

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

#define REP(i,n)   for(int i=0;i<(n);++i)
const int INF = 1e9;

int main(){
    int d[100][100],v,e,a[1000],b[1000],c[1000],ans=0;
    scanf("%d",&v);
    REP(i,v) REP(j,v) d[i][j] = INF;
    REP(i,v) d[i][i] = 0;
    scanf("%d",&e);
    REP(i,e) scanf("%d%d%d",a+i,b+i,c+i);
    REP(i,e){
        --a[i];--b[i];
        d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
    }

    REP(k,v) REP(i,v) REP(j,v) d[i][j] = std::min(d[i][j],d[i][k] + d[k][j]);

    bool used;
    REP(i,e){
        used = true;
        REP(s,v) if(d[s][a[i]] + c[i] == d[s][b[i]]) used = false;
        if(used) ++ans;
    }

    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int x1, x2, a;
	
	scanf("%d" "%d" , &x1, &x2);
	
	if(x1 > x2){
		a = x1 - x2;
	}
	else if(x2 > x1){
		a = x2 - x1;
	}
	else{
		a = x1 - x2;
	}
	
	printf("%d\n",a);
	
	return 0;
}


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

int main()
{
    int N;
    int A[100005];
    int cnt = 0;

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

    for(int i = 0; i < N - 2; i++) {
        if(A[i] == i + 1) cnt++, i++;
    }
    if(A[N - 2] == N - 1 || A[N - 1] == N) cnt++;
    cout << cnt << endl;

    return (0);
}

Measured memory_bytes: 640
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [fetch_int_input() for _ in range(times)]


N, M = fetch_int_input()
gate_len = fetch_int_inputs(M)
# range_card = [[False] * N for _ in range(M)]
l, r = 0, N
for gl in gate_len:
    if l < gl[0]:
        l = gl[0]
    if r > gl[1]:
        r = gl[1]

# range_card = list(zip(*range_card))
# print(sum([all(r) for r in range_card]))
result = r - l + 1
if result < 0: result = 0

print(result)


Measured memory_bytes: 56284
from collections import defaultdict

class BIT():
    def __init__(self,n):
        self.size=n
        self.bit=[0]*(n+1)
    def add(self,i,x):
        while i<=self.size:
            self.bit[i]+=x
            i+=i&-i
    def sum(self,i):
        s=0
        while i>0:
            s+=self.bit[i]
            i-=i&-i
        return s

s=input()
n=len(s)
idx=defaultdict(list)
for i,c in enumerate(s):
    idx[c].append(i)
ctr=n//2
B=[0]*n
flag=False
P=[]
for c,I in idx.items():
    cnt=len(I)
    if cnt%2:
        if flag:
            print(-1)
            exit()
        flag=True
        B[I[cnt//2]]=ctr+1
    for i in range(cnt//2):
        l,r=I[i],I[-i-1]
        P.append((l,r))
P.sort()
for i,(l,r) in enumerate(P):
    B[l],B[r]=i+1,n-i
ans=0
bit=BIT(n)
for i,b in enumerate(B):
    ans+=i-bit.sum(b)
    bit.add(b,1)
print(ans)

Measured memory_bytes: 57932
n = int(input())
s = input()

sw = [1,0]
ss = [1,1]
ws = [0,1]
ww = [0,0]

def nxt(tf, last):
    if tf=='x' and last=='S':
        return ''

for idx,c in enumerate(s):
    if idx==0:
        continue
    if c == 'x':
        sw.append(sw[-1]^sw[-2])
        ss.append(ss[-1]^ss[-2])
        ws.append(ws[-1]^ws[-2])
        ww.append(ww[-1]^ww[-2])
    else:
        sw.append(1*(not(sw[-1]^sw[-2])))
        ss.append(1*(not(ss[-1]^ss[-2])))
        ws.append(1*(not(ws[-1]^ws[-2])))
        ww.append(1*(not(ww[-1]^ww[-2])))

c=s[0]
if c == 'x':
    sw.append(sw[-1]^sw[-2])
    ss.append(ss[-1]^ss[-2])
    ws.append(ws[-1]^ws[-2])
    ww.append(ww[-1]^ww[-2])
else:
    sw.append(1*(not(sw[-1]^sw[-2])))
    ss.append(1*(not(ss[-1]^ss[-2])))
    ws.append(1*(not(ws[-1]^ws[-2])))
    ww.append(1*(not(ww[-1]^ww[-2])))


def f(seq):
    # print(seq[-1],seq[0])
    return seq[-2:]==seq[:2]

def pp(seq):
    print(''.join(map(lambda x:'S' if x else 'W', seq[:-2])))

if f(sw):
    pp(sw)
elif f(ss):
    pp(ss)
elif f(ws):
    pp(ws)
elif f(ww):
    pp(ww)
else:
    print(-1)


Measured memory_bytes: 8256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
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; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   string s,t;
           cin>>s>>t;
           int n=s.size();
           int m=t.size();
           int ans=inf;
           rep(i,0,n-m+1){
             int cnt=0;
			 rep(j,0,m){
               //cout<<t[j]<<" "<<s[i+j]<<endl;
               if(t[j]!=s[i+j])cnt++;
             }
            // cout<<cnt<<endl;
             chmin(ans,cnt);
           }
           cout<<ans<<endl;
}

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

int main() {
  // cin, coutが速くなる？
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  int n;
  // cin >> n;
  scanf("%d", &n);
  vector< pair<int, int> > a(n);
  for(int i = 0; i < n; i++) {
    //cin >> a[i].first;
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  // begin(), end() : 昇順
  // rbegin(), rend() : 降順
  sort(a.rbegin(), a.rend());
  for(int i = 0; i < n; i++) {
    // 降順にしたときに最大値をとるindexのみ2番目の値を出力
    if(i == a[0].second) cout << a[1].first << endl;
    else                 cout << a[0].first << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String[] n = sc.next().split("");
        if(n[0].equals(n[1]) && n[1].equals(n[2])){
            System.out.println("No");
        }
        else{
            System.out.println("Yes");
        }

    }
}


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

#define N 11
using namespace std;
int n;
int a[3][3];
vector<int>f;

bool judge()
{
    int flag = 1;
    for(int i = 0;i < 3;i++)
    {
        if(find(f.begin(),f.end(),a[i][i]) == f.end())flag = 0;
    }
    if(flag)return true;
    flag = 1;
    for(int i = 0;i < 3;i++)
    {
        if(find(f.begin(),f.end(),a[i][3 - i - 1]) == f.end())flag = 0;
    }
    if(flag)return true;

    for(int i = 0;i < 3;i++)
    {
        flag = 1;
        for(int j = 0;j < 3;j++)
        if(find(f.begin(),f.end(),a[i][j]) == f.end())flag = 0;
        if(flag)return true;
    }
    for(int i = 0;i < 3;i++)
    {
        flag = 1;
        for(int j = 0;j < 3;j++)
        if(find(f.begin(),f.end(),a[j][i]) == f.end())flag = 0;
        if(flag)return true;
    }
    if(flag)return true;
    else return false;    
}

int main()
{
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#endif
    for(int i = 0;i < 3;i++)
        for(int j = 0;j < 3;j++)
            cin >> a[i][j];
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        int t;
        cin >> t;
        f.push_back(t);
    }
    
    if(judge())cout <<"Yes\n";
    else cout <<"No\n";

    return 0;
}

Measured memory_bytes: 256
'''input
2
3 1 2
6 1 1
'''
n = input()
arr = []
for i in range(n):
	t,x,y = map(int,raw_input().split())
	arr.append((t,x,y))
arr.sort()
cx,cy = 0,0
ct = 0
flag = False
for i in range(n):
	td = arr[i][0]-ct
	if abs(cx-arr[i][1])+abs(cy-arr[i][2]) > td or (td%2 != (abs(cx-arr[i][1])+abs(cy-arr[i][2]))%2):
		flag = True
		break
	else:
		cx,cy = arr[i][1],arr[i][2]
		ct = arr[i][0]
print "No" if flag else "Yes"

Measured memory_bytes: 47900
package main

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

func main() {
	N := ReadLineInt()[0]

	for i := 1; i <= 50000; i++ {
		if int(float64(i)*1.08) == N {
			fmt.Println(i)
			return
		}
	}

	fmt.Println(":(")
}

/////////////////////////////////////////

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var BufReader = bufio.NewReaderSize(os.Stdin, 1e6)

func ReadLine() string {
	a, _, _ := BufReader.ReadLine()
	return string(a)
}

func ReadLineInt() (result []int) {
	in := strings.Split(ReadLine(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}


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

int main(void){
  int n;
  cin >> n;
  for( int i = 0; i < n; i++){
    bool f = true;
    double xa, xb, ya, yb, ra, rb;
    long double r;

    cin >> xa >> ya >> ra >> xb >> yb >> rb;

    r = sqrt( pow(fabs(xa - xb), 2) + pow(fabs(ya - yb), 2));
    // cout << sqrt( pow(fabs(xa - xb), 2) + pow(fabs(ya - yb), 2)) << endl;
    //cout << r << endl;
    if( r > ra + rb ){
      cout << 0 << endl;
    }
    else{
    
      if(ra < rb)
	f = false;

      if(f){

	if(r + rb < ra){
	  cout << 2 << endl;
	}else{
	  cout << 1 << endl;
	}
      }

      else{
	if(r + ra < rb){
	  cout << -2 << endl;
	}else{
	  cout << 1 << endl;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1232
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

U = 10**6 + 10

def main(A, primes):
    B = np.zeros(U + 1, np.int64)
    for x in A:
        B[x] += 1
    for p in primes:
        for i in range(U // p + 1):
            B[p * i] += B[i]
    ret = 0
    for x in A:
        ret += B[x] == 1
    return ret

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i8[::1],i8[::1])')(main)
    cc.compile()
    exit()
from my_module import main

def prime_table(N):
    is_prime = np.zeros(N, np.int64)
    is_prime[2:3] = 1
    is_prime[3::2] = 1
    for p in range(3, N, 2):
        if p * p >= N:
            break
        if is_prime[p]:
            is_prime[p * p::p + p] = 0
    return is_prime, np.where(is_prime)[0]

A = np.array(read().split(), np.int64)[1:]
_, primes = prime_table(U)

print(main(A, primes))


Measured memory_bytes: 46496
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
	ll N;
	cin>>N;
	ll a=1,b=1;
	while(N--){
		ll x,y;
		cin>>x>>y;
		ll tx=a/x;
		ll ty=b/y;
		if(tx*x!=a)
			tx++;
		if(ty*y!=b)
			ty++;
		ll Max=max(tx,ty);
		a=x*Max;
		b=y*Max;
		//cout<<"a="<<a<<" b="<<b<<endl;
	}
	cout<<a+b<<endl;
	return 0;
}

Measured memory_bytes: 256
def toi(a)
	b = []
	a.each do |n|
		b << n.to_i
	end
	b	
end

a = toi(gets.split)
if a[0] > a[1]
	print("a > b\n")
elsif a[0]<a[1]
	print("a < b\n")
else 
print("a == b\n")	
end

Measured memory_bytes: 8628
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 100001
#define MCONS 1001

using namespace std;

ll prefix[NCONS];

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    ll N, Q; cin >> N >> Q;
    string str; cin >> str;
    
    for(int i = 1; i < str.size(); i++)
    {
        prefix[i] = prefix[i-1];
        if(str[i-1] == 'A' && str[i] == 'C')
            prefix[i] += 1;
    }
    
    while(Q--)
    {
        ll l, r; cin >> l >> r;
        r -= 1; l -= 1;
        if(l == 0)
            cout << prefix[r] << endl;
        else
            cout << prefix[r] - prefix[l] << endl;
    }

    
    return 0;
}




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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/*************************************************************************************/
void file(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/*************************************************************************************/

const ll maxn=2e5+1,mod=1e9+7;




int main(){

    sync
   // file();
    
    ll s;
    cin>>s;

    ll ah = sqrt(s);
    if(ah*ah!=s) ah+=1;
    ll oh = ah*ah;
    
    cout<<ah<<" "<<1<<" "<<-s+oh<<" "<<ah<<" "<<0<<" "<<0;


  return 0;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===



int gcd(int a, int b)
{
	if (b > a) swap(a, b);

	int r = a % b;
	while (r) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}




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

	Vi x(N);
	for (int i = 0; i < N; ++i) {
		cin >> x[i];
		x[i] -= X;
	}

	int ans = x[0];
	for (int i = 1; i < N; ++i) {
		ans = gcd(ans, x[i]);
	}

	cout << abs(ans) << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll uni[160005];
ll root(ll u){
    if(uni[u]<0)return u;
    return uni[u]=root(uni[u]);
}

void connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(uni[a]>uni[b]){
        a^=b;
        b^=a;
        a^=b;
    }
    uni[a]+=uni[b];
    uni[b]=a;
    return;
}
ll size(ll u){
    return -uni[root(u)];
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    memset(uni,-1,sizeof(uni));
    ll h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    ll x,y,x2,y2;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                for(int k=0;k<4;k++){
                    x=j+dx[k];
                    y=i+dy[k];
                    if(x>=0 && x<w && y>=0 && y<h && s[y][x]=='.'){
                        for(int m=0;m<4;m++){
                            x2=x+dx[m];
                            y2=y+dy[m];
                            if(x2>=0 && x2<w && y2>=0 && y2<h && s[y2][x2]=='#'){
                                connect(i*400+j,y2*400+x2);
                            }
                        }
                    }
                }
            }
        }
    }
    vector<set<pair<ll,ll> > > v(160005);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                for(int k=0;k<4;k++){
                    x=j+dx[k];
                    y=i+dy[k];
                    if(x>=0 && x<w && y>=0 && y<h && s[y][x]=='.'){
                        v[root(i*400+j)].insert(make_pair(y,x));
                    }
                }
            }
        }
    }
    ll ans=0;
    for(int i=0;i<160005;i++){
        ans+=uni[i]*(v[i].size());
    }
    cout << -ans<<endl;
    return 0;
}


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

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

    vector<int> vec(n);
    int high = 0;
    for(int i = 0; i < n; ++i)
    {
        cin >> vec[i];
        high = max(high, vec[i]);
    }

    int ans = 0;
    for(int i = 0; i < high; ++i)
    {
        int cnt = 0;
        bool flag = false;
        for(int j = 0; j < n; ++j)
        {
            if(vec[j] > 0)
            {
                --vec[j];
                if(!flag)
                {
                    ++cnt;
                    flag = true;
                }
            }
            else
            {
                flag = false;
            }
        }
        ans += cnt;
    }

    cout << ans << endl;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    if(N % 2 == 0) cout << N << endl;
    else cout << N * 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef long long ll;
const int maxn=1e5+50;
const int inf=0x3f3f3f3f;
const int MOD=10007;

int a[200];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+n);
    int ans=0;
    for(int i=1;i<=n-2;i++)
    {
        for(int j=i+1;j<=n-1;j++)
        {
            for(int k=j+1;k<=n;k++)
            {
                if(a[i]<a[j]&&a[j]<a[k])
                {
                    if(a[i]+a[j]>a[k])
                        ans++;
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3816
#include<iostream>
#include<cstring>
#include<string>
#include<queue>
#include<map>
using namespace std;

map<string,int> dp;
int x[4] = {1,-1,4,-4};  //分别对应右移，左移，下移，上移 

void bfs()
{
	string s = "01234567";
	dp["01234567"] = 0;
	queue<string> q;
	q.push(s);
	while(!q.empty())
	{
		string now = q.front();
		q.pop();
		int m,n;
		m = now.find('0');         //m表示0的位置 
		for(int i = 0;i < 4;i++)
		{
			n = m + x[i];
			if(n >= 0&&n <= 7&& !(m == 3&&i == 0) && !(m == 4&&i == 1) )    //0可以向这个方向移动 
			{
				string New = now;
				char temp = New.at(m);
				New.at(m) = New.at(n);
				New.at(n) = temp;
				if(dp.find(New) == dp.end())                                //尚未出现过这种状况 
				{
					dp[New] = dp[now] + 1;
					q.push(New); 
				}
			}
			
	    }
	}
} 

int main()
{
	bfs();
	string s;s.clear();
	char c;
	int l = 0;
	while(cin>>c)
	{
		if(c >= '0'&&c <= '9')
		{
		    s.push_back(c);
		    l++;
	    }
		if(l == 8)
		{
			cout<<dp[s]<<endl;
			s.clear();
			l = 0;
		}
	}
}


Measured memory_bytes: 5296
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "Yes" << endl
#define no cout << "No" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = ~(1 << 31);

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

    int n, a;
    cin >> n;
    cin >> a;
    int n2 = n % 500;
    if(n2 <= a){
        yes;
    }else{
        no;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a , b;
  	cin >> a >> b;
  	if((a*b)%2|| (a*b*2)%2 ||(a*b*3)%2)
      cout << "Yes" << endl;
  	else
      cout << "No" << endl;
 	return 0; 
}

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

int main(void){
    int n, x, y;
    cin >> n >> x >> y;
    x--,y--;
    map<int,int> cnt;
    rep(r,n)rep(l,r){
        cnt[min(abs(x-l)+1+abs(y-r), r-l)]++;
    }
    rep1(i,n-1){
        cout << cnt[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 384
def partition(A,p,r):
    x = A[r]
    i = p-1
    for j in range(p,r):
        if A[j] <= x:
            i = i + 1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i+1

n = int(input())
A = [int(x) for x in input().split()]

p = partition(A,0,n-1)

for i in range(n):
    if i:
        print(" ",end="")
    if i == p:
        print("[",end="")
    print(A[i],end="")
    if i == p:
        print("]",end="")
print()


Measured memory_bytes: 16364
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    ll ans = 1;
    for (ll i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            if (m / i >= n) chmax(ans, i);
            if (m / (m / i) >= n) chmax(ans, m / i);
        }
    }
    cout << ans << '\n';
    return 0;
}


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

struct edge {
        int to, cap, rev;
};
bool used[101010];
vector<edge> g[101010];
static const int INF = 0x3f3f3f3f;
void add_edge(int from, int to, int cap) {
        g[from].push_back((edge) { to, cap, (int)g[to].size() });
        g[to].push_back((edge) { from, 0, (int)g[from].size() - 1 });
}
int dfs(int v, int t, int f) {
        if (v == t) return f;
        used[v] = true;
        for (int i = 0; i < g[v].size(); i ++) {
                edge& e = g[v][i];
                if (!used[e.to] && e.cap > 0) {
                        int d = dfs(e.to, t, min(f, e.cap));
                        if (d > 0) {
                                e.cap -= d;
                                g[e.to][e.rev].cap += d;
                                return  d;
                        }
                }
        }
        return 0;
}
int MaxFlow(int s, int t) {
        int flow = 0;
        while (true) {
                memset(used, false, sizeof(used));
                int f = dfs(s, t, INF);
                if (f == 0) return flow;
                flow += f;
        }
}

int main() {
        int n, m;
        cin >> n >> m;
        for (int i = 0; i < m; i ++) {
                int u, v, c;
                cin >> u >> v >> c;
                add_edge(u, v, c);
        }
        cout << MaxFlow(0, n - 1) << endl;
        return 0;
}

Measured memory_bytes: 5624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(i , L , R) for( i = L ; i < R ; i++)
#define per(i,L,R) for( i = L; i >= R; i--)
#define all(con) (con).begin(),(con).end()
#define fi first
#define se second
#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] << (i==R?'\n':' ')
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}

int main()
{
   SPEED
//   ll q,i,l,r;
//   string s;
//   cin>>s;
//   ll n = s.length();
//   ll a[n+1]={0};
//   rep(i,0,n-1)
//   {
//       if(s[i]==s[i+1])
//        a[i+1]=1;
//   }
//   printa(a,0,n+1);
//   cout<<"\n";
//   rep(i,1,n+1)
//   {
//       a[i]=a[i]+a[i-1];
//   }
//
//  // printa(a,0,n);
//   cin>>q;
//   while(q--)
//   {
//       cin>>l>>r;
//       cout<<a[r-1]-a[l-2]<<"\n";
//   }
   ll n,i;
   cin>>n;
   pair<ll,ll> a[n];
   ll b;
   rep(i,0,n)
   {
       cin>>b;
       a[i]={b,i+1};
   }
   sort(a,a+n);
   rep(i,0,n)
   cout<<a[i].se<<" ";


}












Measured memory_bytes: 2432
#include <math.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <ostream>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _lcint;
#define REP(i, n) for (_lcint i = 0; i < n; i++)
#define FOR(i, a, b) for (_lcint i = (_lcint)(a); i < (_lcint)(b); i++)
#define FORREV(i, a, b) for (_lcint i = (_lcint)(b)-1; i >= (_lcint)(a); i--)
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)  \
  cout << #v << ": "; \
  REP(i, v.size()) cout << " " << v[i] << endl;

#define ALL(a) (a).begin(), (a).end()
#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// permutation
ll mPn(ll m, ll n) {
  ll a = 1;
  REP(i, n) { a *= m - i; }
  return a;
}

// excrametion
ll exc(ll m) {
  ll a = 1;
  FOR(i, 1, m) { a *= i + 1; }
  return a;
}

// combination
ll mCn(ll m, ll n) {
  ll a = 1, b = 1;
  REP(i, n) {
    a *= m - i;
    b *= n - i;
  }
  return a / b;
}

// 最大公約数を求める 条件
ll eculidean(ll a, ll b) {
  ll tmp;
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

struct Position {
  int x, y;
};

int main() {
  int r, D, x;

  cin >> r >> D >> x;
  REP(i, 10) {
    x = r * (x)-D;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}	
char mem[114514];
char t[114514];
int a[214514];
int b[214514];
signed main(){
	ic(n)
	rep(0,i,n)cin>>a[i];
	int sum=0;
	b[0]=214514;
	rep(0,i,n){
		b[i+1]=min(a[i],b[i]);
	}
	rep(1,i,n+1){
		if(b[i]==a[i-1]){
			sum++;
		}
	}		
	c(sum)
}	


Measured memory_bytes: 3328
function main(input) {
const args = input.split('\n');
const heights = args[1].split(' ');
const N = parseInt(args[0],10);
var answer = 0;
for( var i = 0 ; i <= N ; ++i ){
var check =0
for( var k = 0 ; k<= i - 1; ++k){
if ( parseInt(heights[k - 1],10) <= parseInt(heights[i - 1],10) ){
++check;}
}
if(check === i-1){++answer;}
}
console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7488
#include <stdio.h>

int main() {
	char b;

	scanf("%c", &b);

	if (b == 'A')
		printf("T\n");
	if (b == 'C')
		printf("G\n");
	if (b == 'G')
		printf("C\n");
	if (b == 'T')
		printf("A\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if(b - a <= 0) cout << "delicious" << endl;
    else if(b - a <= x) cout << "safe" << endl;
    else           cout << "dangerous" << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i=0; i<N; i++){
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  string tmp = S[0];
  int ans = 1;
  for(int i=1; i<N; i++){
    if(tmp == S[i]) continue;
    tmp = S[i];
    ans ++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9596
#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No") {
		if (judge_exp) {
			cout << ok << endl;
		} else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right) {
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;

int main(void) {
	int a, b;

	cin >> a >> b;
	int tall_dif = b-a;
	int tall = 0;
	for (int i = 1; i < tall_dif; i++) {
		tall += i;
	}
	cout << tall - a << endl;
	return 0;
}


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

int dp[110][11000];

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> v(N + 1, 0), w(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    cin >> v[i] >> w[i];
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= W; j++) {
      if (j - w[i] >= 0) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
      }
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
    }
  }
  int ans = dp[N][W];
  cout << ans << endl;
  return 0;
}


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

int main(){
	int n;
	cin>>n;
	int m=n%10;
	if(m==2||m==4||m==5||m==7||m==9) cout<<"hon";
	else if(m==0||m==1||m==6||m==8) cout<<"pon";
	else if(m==3) cout<<"bon";
	 
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <chrono>
#include <ext/random>
#include <random>
using namespace std;
using ull = unsigned long long;

class RollingHash {
 public:
  RollingHash(const std::string& s) : s_(s) { Initialize(); }
  std::pair<ull, ull> GetHash(int left, int right);

 private:
  const std::string s_;
  static ull base0_;
  static ull base1_;
  static constexpr ull mod0_ = 2020202077;
  static constexpr ull mod1_ = 2020202111;
  std::vector<ull> hash0_;
  std::vector<ull> hash1_;
  static std::vector<ull> power0_;
  static std::vector<ull> power1_;
  static __gnu_cxx::sfmt19937_64 sfmt_;
  void Initialize();
};

void RollingHash::Initialize() {
  size_t n = s_.size();
  hash0_.assign(n + 1, 0);
  hash1_.assign(n + 1, 0);
  for (size_t i = 0; i < n; ++i) {
    hash0_[i + 1] = (hash0_[i] * base0_ + s_[i]) % mod0_;
    hash1_[i + 1] = (hash1_[i] * base1_ + s_[i]) % mod1_;
  }
  while (power0_.size() <= n) {
    power0_.emplace_back(power0_.back() * base0_ % mod0_);
    power1_.emplace_back(power1_.back() * base1_ % mod1_);
  }
}

inline std::pair<ull, ull> RollingHash::GetHash(int left, int right) {
  ull ret0 = (hash0_[right] - hash0_[left] * power0_[right - left] % mod0_ + mod0_) % mod0_;
  ull ret1 = (hash1_[right] - hash1_[left] * power1_[right - left] % mod1_ + mod1_) % mod1_;
  return {ret0, ret1};
}

__gnu_cxx::sfmt19937_64 RollingHash::sfmt_(
    std::chrono::steady_clock::now().time_since_epoch().count());
ull RollingHash::base0_ = std::uniform_int_distribution<ull>(
    2, RollingHash::mod0_)(RollingHash::sfmt_);
ull RollingHash::base1_ = std::uniform_int_distribution<ull>(
    2, RollingHash::mod1_)(RollingHash::sfmt_);
std::vector<ull> RollingHash::power0_{1};
std::vector<ull> RollingHash::power1_{1};

void ABC141_E() {
  int n; cin >> n;
  string s; cin >> s;
  RollingHash rh(s);

  auto ok = [&](int x) -> bool{
    for (int i = 0; i + 2 * x <= n; ++i) {
      for (int j = i + x; j + x <= n; ++j) {
        if (rh.GetHash(i, i + x) == rh.GetHash(j, j + x)) {
          return true;
        }
      }
    }
    return false;
  };

  int low = 0, high = n / 2 + 1;

  while (high - low > 1) {
    int mid = (low + high) >> 1;
    if (ok(mid)) {
      low = mid;
    } else {
      high = mid;
    }
  }

  cout << low << '\n';
}

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

  ABC141_E();

  return 0;
}

Measured memory_bytes: 512
A, B, C, X, Y = map(int, input().split())
# print("{},{},{},{},{}".format(A,B,C,X,Y))
cost = 0
if A+B >= 2*C:
    if X>Y:
#         print("{},{}".format(X,Y))
        cost += C*Y*2
        X -= Y
        Y -= Y
#         print("{},{}".format(X,Y))

    else:
        cost += C*X*2
        Y -= X
        X -= X
#         print("{},{}".format(X,Y))
    if X>0 and A > 2*C:
        cost += X*C*2
    elif X>0 and A <= 2*C:
        cost += X*A
    elif Y>0 and B > 2*C:
        cost += Y*C*2
    elif Y>0 and B <= 2*C:
        cost += Y*B
else:
    cost += X*A + B*Y

print(cost)

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

using namespace std;
char a[111][111];
void removeCol(int x,int n,int m)
{
    for (int i=x;i<m-1;i++)
    {
        for (int j=0;j<n;j++)
        {
            a[j][i]=a[j][i+1];
        }
    }
    return ;
}
void removeRow(int x,int n,int m)
{
    for (int i=x;i<n-1;i++)
    {
        for (int j=0;j<m;j++)
        {
            a[i][j]=a[i+1][j];
        }
    }
    return ;
}
int main()
{
    int n,m;
    cin >> n >> m;
    for (int i=0;i<n;i++)
    {     
        for(int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }  
    }
    for (int i=0;i<n;)
    {
        bool flg=1;
        for (int j=0;j<m&&flg;j++)
        {
            if (a[i][j]=='#') flg=0;
        }
        if (flg) removeRow(i,n,m),--n;
        else ++i;
    }
    for (int i=0;i<m;)
    {
        bool flg=1;
        for (int j=0;j<n&&flg;j++)
        {
            if (a[j][i]=='#') flg=0;
        }
        if (flg) removeCol(i,n,m),--m;
        else ++i;
    }
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<m;j++)
        {
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}

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


int main(void) {
  int N;
  cin >> N;
  int A[N];
  REP(i,N) cin >> A[i];

  int rv[100000] = {};
  REP(i,N) rv[A[i]]++;

  sort(rv, rv+100000, greater<int>());
  int j = 1;
  int others = 0;
  if (rv[1] == 0) {
    cout << 1 << '\n';
    return 0;
  }
  while(rv[j]>1) {
    others += rv[j] - 1;
    j++;
  }
  int all = others + rv[0] - 1;
  int del_time = max(rv[0]-1, all/2+all%2);
  cout << N - del_time * 2 << '\n';
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,m,f[1005][1005];
char a[1005][1005];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(i==1&&j==1){
				f[i][j]=1;
				continue;
			}
			if(a[i][j]=='#'){
				continue;
			}
			f[i][j]+=(f[i-1][j]+f[i][j-1])%mod;
			f[i][j]%=mod;
		}
	}
//	for(int i=1;i<=n;i++){
//		for(int j=1;j<=m;j++){
//			cout<<f[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	cout<<f[n][m];
	return 0;
}



Measured memory_bytes: 5120
n, m = map(int, input().split())
a_t = [list(map(int, input().split())) for _ in range(n)]
b_l = [int(input()) for _ in range(m)]
l = [0] * n

for i, a in enumerate(a_t):
    for j, k in enumerate(a):
        l[i] = (k * b_l[j]) + l[i]

for l in l:
    print(l)


Measured memory_bytes: 6020
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] arr = new int[N][3];
		int[][] dp = new int[N][3];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 3; j++) {
				arr[i][j] = sc.nextInt();
			}
		}
		dp[0] = Arrays.copyOf(arr[0],3);
		for(int i = 1; i < N; i++) {
			dp[i][0] = arr[i][0] + Math.max(dp[i-1][1],dp[i-1][2]);
			dp[i][1] = arr[i][1] + Math.max(dp[i-1][0],dp[i-1][2]);
			dp[i][2] = arr[i][2] + Math.max(dp[i-1][0],dp[i-1][1]);
		}
		int ans = 0;
		for(int i = 0; i < 3; i++) {
				ans = Math.max(ans,dp[N-1][i]);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 66788
#include<stdio.h>
int a,b,c,d,e[1001],f[1001],g[1001],h[1001],x[1001],y[1004],z[1001];
int main(void)
{
    while(scanf("%d%d%d",&a,&b,&c),a + b + c)
    {
        int result[320] = {0};
        scanf("%d",&d);

        for(int i = 0; i < d; i++)
        {
            scanf("%d%d%d%d",&e[i],&f[i],&g[i],&h[i]);
            if(h[i] == 1)//ok!
            {
                result[e[i]-1] = 1;x[i] = e[i];
                result[f[i]-1] = 1;y[i] = f[i];
                result[g[i]-1] = 1;z[i] = g[i];
            }
        }

        for(int i = 0; i < d; i++)
        {
            if(h[i] == 0)
            {
                if(result[f[i]-1] == 1 && result[g[i]-1] == 1)result[e[i]-1] = 2;
            }
            if(h[i] == 0)
            {
                if(result[e[i]-1] == 1 && result[g[i]-1] == 1)result[f[i]-1] = 2;
            }
            if(h[i] == 0)
            {
                if(result[f[i]-1] == 1 && result[e[i]-1] == 1)result[g[i]-1] = 2;
            }
        }
        for(int i = 0; i < a+b+c; i++)
        {
            if(result[i] == 2)result[i] = 0;
            else if(result[i] == 0)result[i] = 2;
            printf("%d\n",result[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 2616
from itertools import accumulate
N = 100000
prime = [True for _ in range(N+1)]
prime[0] = False
prime[1] = False
i = 2
for i in range(N+1):
    if prime[i]:
        for j in range(2*i, N+1, i):
            prime[j] = False
prime2 = [0 for _ in range(N+1)]
for i in range(N+1):
    if prime[i] and prime[(i+1)//2]:
        prime2[i] = 1
acc = list(accumulate(prime2))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(acc[r] - acc[l-1])


Measured memory_bytes: 53664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a+b == 15) System.out.println("+");
        else if (a*b == 15) System.out.println("*");
        else System.out.println("x");
    }
}


Measured memory_bytes: 35728
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int k = int.Parse(Console.ReadLine());
        var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = ab[0];
        var b = ab[1];
        for (int i = a; i <= b; i++)
        {
            if (i % k == 0)
            {
                Console.WriteLine("OK");
                return;
            }
        }
        Console.WriteLine("NG");
    }
}

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

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

using namespace std;

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

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

  vector<int> res(n, 0);
  rep(i, n - 1) {
    res[a[i] - 1]++;
  }
  rep(i, n) {
    cout << res[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 4848
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int n = in.nextInt();
            int[] p = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = in.nextInt();
            }

            int count = 0;
            for (int i = 1; i < n - 1; i++) {
                if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
                    count++;
                }
                if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
const int Maxn=100005;
int n,bl[Maxn],vis[Maxn];
vector<int>a[Maxn];
pair<int,int>ans[Maxn];
namespace dinic{
	const int Maxn=2*::Maxn,Maxm=4*::Maxn;
	int S,T,cnt,h[Maxn],cur[Maxn],dis[Maxn];
	struct node{
		int to,next,v,pair;
	}e[2*Maxm];
	void AddEdge(int x,int y,int v,int pair){
		e[cnt]=(node){y,h[x],v,pair};h[x]=cnt;
	}
	void AddEdge(int x,int y,int v){
		AddEdge(x,y,v,++cnt+1);
		AddEdge(y,x,0,++cnt-1);
	}
	bool bfs(){
		memset(dis,0x3f,sizeof(dis));
		dis[S]=0;
		queue<int>Q;Q.push(S);
		while(Q.size()){
			int x=Q.front();Q.pop();
			for(int p=h[x];p;p=e[p].next){
				int y=e[p].to;
				if(dis[y]<=dis[x]+1||!e[p].v)continue;
				Q.push(y);dis[y]=dis[x]+1;
			}
		}
		return dis[T]!=0x3f3f3f3f;
	}
	int dfs(int x,int Maxflow){
		if(x==T||!Maxflow)return Maxflow;
		int flow=0;
		for(int&p=cur[x];p;p=e[p].next){
			if(!Maxflow)break;
			int y=e[p].to;
			if(dis[y]!=dis[x]+1)continue;
			int ret=dfs(y,min(e[p].v,Maxflow));
			Maxflow-=ret;flow+=ret;
			e[p].v-=ret;e[e[p].pair].v+=ret;
		}
		return flow;
	}
	int Maxflow(int s,int t){
		S=s,T=t;
		int ans=0;
		while(bfs()){
			memcpy(cur,h,sizeof(h));
			ans+=dfs(S,INT_MAX);
		}
		return ans;
	}
	void solve(){
		for(int i=1;i<n;i++)
			for(int p=h[i];p;p=e[p].next)
				if(e[p].to>=n&&!e[p].v)
					bl[i]=e[p].to;
	}
}
int main(){
	scanf("%d",&n);
	int S=0,T=2*n;
	for(int i=1;i<n;i++)dinic::AddEdge(S,i,1);
	for(int i=1;i<=n;i++)dinic::AddEdge(i+n-1,T,1);
	for(int i=1;i<n;i++){
		int sz;scanf("%d",&sz);
		while(sz--){
			int x;scanf("%d",&x);
			a[x].push_back(i);
			dinic::AddEdge(i,x+n-1,1);
		}
	}
	if(dinic::Maxflow(S,T)!=n-1){
		cout<<"-1\n";
		return 0;
	}
	dinic::solve();
	for(int i=1;i<n;i++)bl[i]-=n-1;
	set<int>o;
	queue<int>Q;
	int rt=1,cnt=0;
	for(int i=1;i<n;i++)o.insert(bl[i]);
	while(o.count(rt))rt++;
	auto add=[&](int x){
		for(int f:a[x])
			if(!vis[f]){
				Q.push(f);
				vis[f]=x;
			}
	};
	add(rt);
	while(Q.size()){
		int f=Q.front();Q.pop();
		ans[f]=make_pair(bl[f],vis[f]);
		cnt++;
		add(bl[f]);
	}
	if(cnt==n-1){
		for(int i=1;i<n;i++)
			cout<<ans[i].first<<" "<<ans[i].second<<"\n";
	}else{
		cout<<"-1\n";
	}
	return 0;
}

Measured memory_bytes: 28664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    string s; cin >> s;
    ll ans = 0;
    rep(i, s.size()-1) {
        if (s[i] != s[i+1]) {
            ans += 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>

using namespace std;

long dfs(vector<vector<bool>> &graph, vector<bool> &visited, vector<long> &hs, int i, int N, long h, long cnt) {

    visited[i] = true;

    for (int j = 0; j < N; ++j) {
        if (graph[i][j] && !visited[j]) {

            if (h <= hs[j]) {
                cnt += 1;
            }

            cnt += dfs(graph, visited, hs, j, N, h, 0);
        }
    }

    return cnt;
}

int main() {

    int N, M;
    cin >> N >> M;

    vector<long> hs;
    vector<vector<long>> graph(N);

    for (int i = 0; i < N; ++i) {
        long h;
        cin >> h;
        hs.push_back(h);
    }

    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        graph[A - 1].push_back(B - 1);
        graph[B - 1].push_back(A - 1);
    }

    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        long h = hs[i];
        bool good = true;
        for (long j : graph[i]) {
            if (h <= hs[j]) {
                good = false;
                break;
            }
        }
        if (good) {
            cnt += 1;
        }
    }


    cout << cnt << endl;

    return 0;

}

Measured memory_bytes: 9816