akhauriyash/Code-Regression huggingface dataset:
var main = function main(input) {
    var N = +input.split('\n')[0]
    var A = input.split('\n')[1].split(' ')
    var min = 1000000000
    var max = 1

    for (var i = 0; i < N; i++) {
        if (+A[i] > max) max = +A[i]
        if (+A[i] < min) min = +A[i]
    }
    console.log(max - min)
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


Measured memory_bytes: 7372
using System;
using System.Linq;

namespace OTW
{
    class P
    {
        private string Read()
        {
           return  Console.ReadLine();
        }

        private int[] ReadArray()
        {
            return Read().Split().Select(int.Parse).ToArray();
        }
        private void S()
        {
            var abc = Read();
            var array = abc.Split().Select(int.Parse).ToArray();
            var a = array[0];
            var b = array[1];
            var c = array[2];

            if((c < b && c < a) || (c>b && c > a))
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }

        }

        static void Main(string[] args)
        {
            new P().S();
        }
    }
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) (int)x.size()
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<ll, ll> point;

const int off = 1 << 6;

struct Tournament{
  point t[2 * off];
  ll p[2 * off];
  Tournament() { REP(i, 2 * off) { t[i] = point(0, 0); p[i] = 0; } }
  void prop(int x){
    t[x].first += p[x];
    if(x < off){
      p[x * 2] += p[x];
      p[x * 2 + 1] += p[x];
    }
    p[x] = 0;
  }
  point merge(point A, point B){
    if(A.first < B.first) swap(A, B);
    return A;
  }
  void dodaj(int x, ll val){
    x += off; t[x] = point(val, x - off);
    for( x /= 2; x > 0; x /= 2)
      t[x] = merge(t[x * 2], t[x * 2 + 1]);
  }
  void update(int x, int lo, int hi, int a, int b, ll val){
    prop(x);
    if(lo >= b || hi <= a) return;
    if(lo >= a && hi <= b) { p[x] += val; prop(x); return; }
    int mid = (lo + hi) >> 1;
    update(x * 2, lo, mid, a, b, val); update(x * 2 + 1, mid, hi, a, b, val);
    t[x] = merge(t[x * 2], t[x * 2 + 1]);
  }
  point get(){
    prop(1);
    return t[1];
  }
} T;

int n;
ll sol;

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

  cin >> n;
  REP(i, n){
    ll x; cin >> x;
    T.dodaj(i, x);
  }
  //TRACE(T.get().first);
  while(T.get().first >= n){
    point x = T.get();
    ll val = x.first;
    ll pos = x.second;
    ll add = val / n;
    sol += add;

    T.update(1, 0, off, pos, pos + 1, - add * n - add);
    T.update(1, 0, off, 0, n, add);
  }
  cout << sol;
}


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

using namespace std;

int main(void){
  char a[4], b[4];
  cin >> a >> b;
  bool ok = true;
  
  for(int i = 0;i < 3;i++){
    if(a[i] != b[2-i]) ok = false;
  }
    
  cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int n;
pi ar[100005];
int main(){
  cin>>n;
  REP(i,n){
    int a,b;scanf("%d%d",&a,&b);
    ar[i]={a+b,b};
  }
  sort(ar,ar+n,[&](pi a,pi b){
      return abs(a.fr)>abs(b.fr);
      });

  lint res=0;
  REP(i,n){
    if(i%2==0){
      res+=ar[i].fr-ar[i].sc;
    }else{
      res-=ar[i].sc;
    }
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n;
string s[55];
int t[55];
string x;
signed main(){
    cin>>n;
    rep(i,n)cin>>s[i]>>t[i];
    cin>>x;
    int ans=0;
    bool flag=false;
    rep(i,n){
        if(flag)ans+=t[i];
        if(s[i]==x)flag=true;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
#define prev prev228
#define all(x) (x).begin(), (x).end()

int n, k;
int a[500000];
int ans = 0;
vector<int> graph[500000];
int dist[500000];
int go[33][500000];
int marked[500000];

void dfs(int v, int p, int d)
{
    go[0][v] = p;
    dist[v] = d;
    for (auto u : graph[v]) dfs(u, v, d + 1);
}

int Go(int op, int v)
{
    for (int j = 30; j >= 0; j--)
    {
        if (op >= (1 << j))
        {
            op -= (1 << j);
            v = go[j][v];
        }
    }
    return v;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] != 1)
    {
        a[1] = 1;
        ans++;
    }
    for (int i = 2; i <= n; i++)
    {
        graph[a[i]].push_back(i);
    }
    dfs(1, 1, 0);
    for (int j = 1; j <= 30; j++)
    {
        for (int i = 1; i <= n; i++)
        {
            go[j][i] = go[j - 1][go[j - 1][i]];
        }
    }
    set<pair<int, int>, greater<pair<int, int> > > ss;
    for (int i = 1; i <= n; i++) ss.insert({dist[i], i});
    while (ss.size())
    {
        pair<int, int> it = *ss.begin();
        ss.erase(ss.begin());
        if (Go(k, it.second) == 1) continue;
        int g = Go(k - 1, it.second);
        ans++;
        marked[g] = 1;
        vector<int> kek = {g};
        for (int i = 0; i < kek.size(); i++)
        {
            ss.erase({dist[kek[i]], kek[i]});
            for (auto u : graph[kek[i]])
            {
                if (marked[u] == 0)
                {
                    kek.push_back(u);
                    marked[u] = 1;
                }
            }
        }
    }
    cout << ans;
}


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

int main(void) {
	string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  char a = toupper(s1[0]);
  char b = toupper(s2[0]);
  char c = toupper(s3[0]);
  cout << a << b << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;
    cin>>n;
    vector<int64_t> h(n);
    rep(i,n) cin>>h.at(i);
    bool a=true;
    reverse(h.begin(),h.end());
    rep(i,n-1){
        if(h.at(i)<h.at(i+1)){
            h.at(i+1)--;
        }
        if(h.at(i)<h.at(i+1)){
            a=false;
            break;
        }
    }
    if(a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int A, B;
	cin >> A >> B;
	cout << max({A+B,A-B,A*B}) << endl;

	return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt","r",stdin);
    //     freopen("out.txt","w",stdout);
    // #endif
    int n,m;
    cin>>n>>m;
    int l,r;
    cin>>l>>r;
    f1(i,0,m-1)
    {
        cin>>temp;
        l=max(l,temp);
        cin>>temp;
        r=min(r,temp);
    }
    int ans=r-l+1;
    if(ans<0)
        ans=0;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 
unsigned int randInt() {
	static unsigned int tx = 123456789, ty = 362436069, tz = 521288629, tw = 88675123;
	unsigned int tt = (tx ^ (tx << 11));
	tx = ty; ty = tz; tz = tw;
	return (tw = (tw ^ (tw >> 19)) ^ (tt ^ (tt >> 8)));
}


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T; cin >> T;
    int S = T;
    if (S == 1000000000000000000) {
        cout << "0 0 1000000000 0 0 1000000000" << endl;
        return 0;
    }
    int X = S / 1000000000 + 1;
    int Y = 1;
    while(X * Y <= S && Y <= 100000000) {
        Y *= 10;
    }
    int remain = X * Y - S;
    int x = remain;
    int y = 1;
    //cout << X << " " << Y << " " << X * Y - S << endl;
    cout << "0 0 " << X << " " << y << " " << x << " " << Y << endl;
    // cout << abs(X * Y - x*y) << " " << S << endl;
    // rep(i, 100000000) {
    //     int S = randInt() % 1000000000 + 1;
    //     S = S * S;
    //     int X = S / 1000000000 + 1;
    //     int Y = 1;
    //     while(X * Y <= S && Y <= 100000000) {
    //         Y *= 10;
    //     }
    //     int remain = X * Y - S;
    //     int x = remain;
    //     int y = 1;
    //     //cout << X << " " << Y << " " << X * Y - S << endl;
    //     //cout << "0 0 " << X << " " << y << " " << x << " " << Y << endl;
    //     //cout << X * Y - x*y << " " << S << endl;
    //     if (abs(X*Y -x*y) != S) cout << "error" << endl; 
    // }
    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main(void){
    int a,b;
    std::cin >> a >> b;
    int sum = a+b;
    if(sum >= 10){
        std::cout << "error";
        return 0;
    }
    std::cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  ll n; ll ans = 0;
  cin >> n;
  ans = n * (n-1) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main
 
import (
	"fmt"
)
 
func main() {
	n := 0
	fmt.Scan(&n)
	if n == 1 || n == 2 || n == 3 || n == 5 || n == 6 || n == 9 || n == 10 || n == 13 || n == 17 {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
int main (){
    int a,b,c;
    cin >> a>>b>>c;
    int d=b*10+c;
    if(d%4==0){
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	string s; cin >> s;
	int sum = 0;
	for (int i = 0; i < s.size(); i++) {
		sum += s[i] - '0';
	}
	if (sum % 9 == 0) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <climits>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
#include <numeric>
#include <random>
#include <memory>
#include <chrono>
#include <iterator>
#include <functional>
#ifdef LOCAL
#include "debug.h"
#else
#define debug(x...)
#endif
//#pragma GCC optimize("Ofast")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define mp make_pair
#define pb push_back
#define sz(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e3 + 7;
const int inf = INT_MAX / 2;
const ll INF = LLONG_MAX / 3;
const int MOD = 998244353;
const ld eps = 1e-6;
const string cars[] = {"🚗", "🚕", "🚙"};

deque < int > q[N];
short used[N];

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout << fixed << setprecision(3);
    cin.tie();
    cout.tie();

    int n, r;
    cin >> n;
    r = n * (n - 1);

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < n - 1; j++) {
            int t;
            cin >> t;

            q[i].push_back(t);
        }
    }

    set < int > now;
    for (int i = 1; i <= n; i++) {
        now.insert(now.end(), i);
    }
    for (int t = 1; ; t++) {
        debug(now);
        int flag = 0;
        set < int > later;

        for (int i : now) {
            if (q[i].empty()) {
                continue;
            }

            int j = q[i].front();
            if (q[j].front() == i && later.find(i) == later.find(j)) {
                q[i].pop_front();
                q[j].pop_front();

                later.insert(i);
                later.insert(j);
                debug(later);
                r -= 2;
                flag = 1;

                if (r == 0) {
                    return cout << t, 0;
                }
            }
        }

        if (!flag) {
            return cout << "-1", 0;
        }
        swap(now, later);
    }

    return 0;
}


Measured memory_bytes: 4736
def solve(string):
    l, r = map(int, string.split())
    if r - l >= 2019:
        return "0"
    return str(min({i * j % 2019 for i in range(l, r + 1) for j in range(i+1, r + 1)}))


if __name__ == '__main__':
    print(solve(input()))


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

typedef long long ll;
typedef int ii;
//typedef vector<ll> vi;

#define INF 1000000007

#define pi 3.141592654

#define T while(t--)
#define for2(i,a,b) for(i=a;i>=b;i--)
#define for3(i,a,b) for(i=a;i<=b;i=i+2)
#define for1(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define mp make_pair

#include<sstream>

#define si set<ll>
#define se multiset<ll>

typedef long double ld;

typedef vector<ll> vi;

#define bb(arr,nn,xx) upper_bound(arr,arr+nn,xx)-arr
#define aa(arra,nna,xxa) lower_bound(arra,arra+nna,xxa)-arra

#define all(v) sort(v.begin(),v.end())
 
#define all1(v) sort(v.rbegin(),v.rend())

ii main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    ll x; cin>>x;
    
    cout<<abs(x-1)<<"\n";
    
}


Measured memory_bytes: 3640
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
from collections import defaultdict as ddic, Counter, deque
import heapq, bisect, itertools
MOD = 10 ** 9 + 7
S=rr(); T=rr()

ans = len(T)
for i in xrange(len(S) - len(T) + 1):
    ham = sum(S[j+i] != T[j] for j in xrange(len(T)))
    ans = min(ans, ham)

print ans


Measured memory_bytes: 72328
lst = [int(input())]
count = 1
while True:
    count += 1
    if lst[-1] % 2 == 0:
        next_num = lst[-1]/2
        if next_num in set(lst):
            print(count)
            break
        lst.append(next_num)
    else:
        next_num = 3*lst[-1]+1
        if next_num in set(lst):
            print(count)
            break
        lst.append(next_num)

Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		long[] sum = new long[n];
		sum[0] = a[0];
		for (int i = 0; i < n - 1; i++) {
			sum[i + 1] = a[i + 1] + sum[i];
		}
		long mincost = 1000000000000000000L;
		for (int i = 0; i < n; i++) {
			mincost = Math.min(mincost, Math.abs(sum[n - 1] - 2 * sum[i]));
		}
		System.out.println(mincost);
	}
}



class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 25396
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int solve(string s){
	int k=0;
	for(int i=1;i<n;i++){
		int cnt=0;
		for(char j='a';j<='z';j++){
			bool x=false;
			bool y=false;
			for(int k=0;k<i;k++){
				if(s[k]==j){
					x=true;
				}
			}
			for(int k=i;k<n;k++){
				if(s[k]==j){
					y=true;
				}
			}
			if(x&&y){
				cnt++;
			}
		}
		k=max(k,cnt);
	}
	return k;
}
int main(){
	cin>>n>>s;
	int m;
	m=solve(s);
	cout<<m<<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++)

int main()
{
  int N;
  cin >> N;
  vector<int> C(N - 1), S(N - 1), F(N - 1);
  rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];
  rep(i, N)
  {
    int time = 0;
    for (int j = i; j < N - 1; j++)
    {
      time = max(time, S[j]);
      time = time + (F[j] - 1);
      time /= F[j];
      time *= F[j];
      time += C[j];
    }
    cout << time << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	int f=0,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f?-x:x;
}
#define MAXN 2000
#define INF 0x3f3f3f3f
#define Mod int(1e9+7)
int n,k,tree[MAXN+5];
inline int lowbit(int x){return x&-x;}
void Add(int i,int x){
	while(i<=MAXN)
		tree[i]+=x,i+=lowbit(i);
	return ;
}
int Sum(int i){
	int ret=0;
	while(i)
		ret+=tree[i],i-=lowbit(i);
	return ret;
}
int a[MAXN+5];
int main(){
	n=read(),k=read();
	LL rev=0,cnt=0;
	for(int i=1;i<=n;i++){
		a[i]=read();
		rev=(rev+i-1-Sum(a[i]))%Mod,Add(a[i],1);
	}
	for(int i=1;i<=n;i++)
		cnt=(cnt+n-Sum(a[i]))%Mod;
	printf("%lld\n",(rev*k%Mod+cnt*(1ll*k*(k-1)/2%Mod)%Mod)%Mod);
	return 0;
}

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

const int N = 3e2 + 6;
int n, k, m;
int dp[N][N];
int DP[N][N];
int ch[N][N];

int _sum (int a, int b) {
	int c = a + b;
	if (m <= c)
		c -= m;
	return c;
}

int _sub (int a, int b) {
	int c = a - b;
	if (c < 0)
		c += m;
	return c;
}

int _mul (int a, int b) {
	return 1LL * a * b % m;
}

void preProcess() {
	ch[0][0] = 1;
	for (int i = 1; i < N; i++) {
		ch[0][i] = 1;
		for (int j = 1; j <= i; j++)
			ch[j][i] = _sum(ch[j][i - 1], ch[j - 1][i - 1]);
	}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k >> m;
	preProcess();
	for (int i = 0; i <= k; i++) {
		dp[1][i] = 1;
		DP[1][i] = (k - i + 1) % m;
	}

	for (int i = 2; i <= n + 1; i++) 
		for (int j = k - 1; ~j; j--) {
			for (int p = 1; p <= i - 1; p++)
				dp[i][j] = _sum(dp[i][j], _mul(_mul(dp[i - p][j], ch[p - 1][i - 2]), DP[p][j + 1]));

			DP[i][j] = _sum(DP[i][j + 1], dp[i][j]);
		}
		
	cout << dp[n + 1][0] << "\n";
	return 0;
}

Measured memory_bytes: 4744
#include <iostream>
using namespace std;
long long int A[100][100];
long long int maxi=10000000001;
int w,V,E,v,e,i,j,flag=1;
void floid(){
    for(int k=0;k<100;k++){
        for(i=0;i<100;i++){
            if(A[i][k]==maxi) continue;
            for(j=0;j<100;j++){
            if(A[k][j]==maxi) continue;
            A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
            }
        }
    }
}
int main(){
    for(i=0;i<100;i++){
        for(j=0;j<100;j++){
            if(i==j) A[i][j]=0;
            else A[i][j]=maxi;
        }
    }
    cin>>V>>E;
    for(i=0;i<E;i++){
        cin>>v>>e>>w;
        A[v][e]=w;
    }
    floid();
    for(i=0;i<V;i++){
        if(A[i][i]<0) flag=0;
    }
    if(flag){
    for(i=0;i<V;i++){
        for(j=0;j<V;j++){
            if(j) cout<<" ";
            if(A[i][j]==maxi) cout<<"INF";
            else cout<<A[i][j];
        }
        cout<<endl;
    }
    }
    else cout<<"NEGATIVE CYCLE"<<endl;
}


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

using namespace std;
int main() {
	string n;
	int sum = 0;
	cin >> n;

	for (int i = 0; i < n.length(); i++) {
		sum += n[i] - '0';
	}

	if (atoi(n.c_str()) % sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;
long long x[10000010], y[10000010],z[10000010];
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n) i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9+7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int a,b,c,d,n,cnt=0,ans=0;
   string s,w;

   cin>>a>>b;

   c=a+b;
   if(a%3==0) cout<<"Possible"<<'\n';
   else if(b%3==0) cout<<"Possible"<<'\n';
   else if(c%3==0) cout<<"Possible"<<'\n';
   else cout<<"Impossible"<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))





signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	vector<int>a(n); rep(i, n)cin >> a[i];
	sort(a.rbegin(), a.rend());
	if (a[0] < k) {
		cout << "IMPOSSIBLE" << endl; return 0;
	}
	int now = a[0];
	for (int i = 1; i < n; i++) {
		now = gcd(now, a[i]);
	}
	if (k % now == 0) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

#define clear(x) memset(x, 0, sizeof(x))
#define op(x) ((x) <= n ? (x) + n : (x) - n)
#define mid ((l + r) / 2)
#define ls now * 2
#define rs now * 2 + 1

const int N = 4e4 + 10, M = N * 20;

int hd[N * 5], nxt[M], t[M], ec;
void addEdge(int u, int v) {
    t[++ec] = v;
    nxt[ec] = hd[u];
    hd[u] = ec;
}
struct Flag {
    int pos, id;
    bool operator<(const Flag& f) const { return pos < f.pos; }
    Flag(int pos = 0): pos(pos) {}
} flgs[N * 2];

int n;
int cnt;
int id[N * 5];

void build(int now, int l, int r) {
    id[now] = ++cnt;
    if (l == r) {
        addEdge(id[now], op(flgs[l].id));
        return;
    }
    build(ls, l, mid);
    build(rs, mid + 1, r);
    addEdge(id[now], id[ls]);
    addEdge(id[now], id[rs]);
}

void link(int now, int l, int r, int x, int y, int point) {
    if (y < x) return;
    if (l == x && y == r) addEdge(point, id[now]);
    else if (y <= mid) link(ls, l, mid, x, y, point);
    else if(x > mid) link(rs, mid + 1, r, x, y, point);
    else link(ls, l, mid, x, mid, point), link(rs, mid + 1, r, mid + 1, y, point);
}

#undef mid

int dfn[N * 5], low[N * 5], tim;
int stk[N * 5], tp;
int scc[N * 5], sc;
bool in[N * 5];

void dfs(int u) {
    in[u] = 1;
    dfn[u] = low[u] = ++tim;
    stk[++tp] = u;
    int v;
    for (int i = hd[u]; i; i = nxt[i]) {
        if (!dfn[v = t[i]]) dfs(v), low[u] = min(low[u], low[v]);
        else if (in[v]) low[u] = min(low[u], dfn[v]);
    }
    if (dfn[u] == low[u]) {
        ++sc;
        do {
            scc[v = stk[tp--]] = sc;
            in[v] = 0;
        } while (v != u);
    }
}

bool check(int v) {
    tp = tim = ec = 0;
    clear(hd), clear(dfn), clear(low);
    build(1, 1, cnt = 2 * n);
    int l, r;
    for (int i = 1; i <= 2 * n; i++) {
        l = upper_bound(flgs + 1, flgs + 1 + 2 * n, Flag(flgs[i].pos - v)) - flgs;
        r = upper_bound(flgs + 1, flgs + 1 + 2 * n, Flag(flgs[i].pos + v - 1)) - flgs - 1;
        link(1, 1, 2 * n, l, i - 1, flgs[i].id), link(1, 1, 2 * n, i + 1, r, flgs[i].id);
    }
    for (int i = 1; i <= 2 * n; i++) if (!dfn[i]) dfs(i);
    for (int i = 1; i <= n; i++) if(scc[i] == scc[i + n]) return 0;
    return 1;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d%d", &flgs[i].pos, &flgs[i + n].pos);
        flgs[i].id = i, flgs[i + n].id = i + n;
    }

    sort(flgs + 1, flgs + n * 2 + 1);
    
    int l = 0, r = flgs[2 * n].pos - flgs[1].pos + 1, mid, ans;
    while (l <= r) {
        mid = (l + r) / 2;
        if (check(mid)) l = mid + 1, ans = mid;
        else r = mid - 1;
    }

    printf("%d", ans);
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

vector<int> val(100005, 0);
vector<int> adj[100005];
vector<bool> vis(100005, false);
map<ii,int> edge;
vector<int> ans;

void dfs(int x, int pre){
      vis[x] = true;
      for(auto y : adj[x]){
            if(vis[y]) continue;
            dfs(y, x);
      }
      if(val[x] && pre != -1){
            val[x] = 0;
            val[pre] = 1 - val[pre];
            ans.pb(edge[{pre, x}]);
      }
}
int lower_bound(vector<ii>& arr, int x){
      int ret = arr.size();
      int l = 0, r = (int)arr.size() - 1;
      while(l <= r){
            int mid = (l + r) / 2;
            if(arr[mid].first >= x){
                  ret = mid;
                  r = mid - 1;
            }
            else l = mid + 1;
      }
      return ret;
}
int upper_bound(vector<ii>& arr, int x){
      int ret = arr.size();
      int l = 0, r = (int)arr.size() - 1;
      while(l <= r){
            int mid = (l + r) / 2;
            if(arr[mid].first > x){
                  ret = mid;
                  r = mid - 1;
            }
            else l = mid + 1;
      }
      return ret;
}

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n, m;
      cin >> n >> m;
      vector<ii> A(n);
      for(int i = 0; i < n; i++) cin >> A[i].first >> A[i].second;
      A.pb({-INF, 0});A.pb({INF, 0});
      sort(all(A));
      vector<int> D(n + 1, 0);
      for(int i = 0; i <= n; i++){
            D[i] = A[i].second ^ A[i + 1].second;
            val[i] = D[i];
      }
      for(int i = 1; i <= m; i++){
            int x, y;
            cin >> x >> y;
            x = lower_bound(A, x) - 1;
            y = upper_bound(A, y) - 1;
            edge[{x, y}] = i;
            edge[{y, x}] = i;
            adj[x].pb(y);
            adj[y].pb(x);
      }
      for(int i = 0; i <= n; i++){
            if(!vis[i]) dfs(i, -1);
            if(val[i]){
                  cout << -1;
                  return 0;
            }
      }
      sort(all(ans));
      cout << ans.size() << "\n";
      for(int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}


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

const int maxn = 600, mod = 1e9 + 7;
int n, k, a[maxn + 3], b[maxn + 3], g[maxn + 3];
int dp[maxn + 3][maxn + 3], cnt[maxn + 3][maxn + 3];
bool val[maxn + 3][maxn + 3];

bool in(int x, int l, int r) {
	return x >= l && x <= r;
}

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= k; i++) {
		scanf("%d %d", &a[i], &b[i]);
	}
	g[0] = 1;
	for (int i = 1; i <= n * 2; i++) {
		g[i] = i & 1 ? 0 : 1ll * g[i - 2] * (i - 1) % mod;
	}
	for (int i = 1; i <= n * 2; i++) {
		for (int j = i + 1; j <= n * 2; j++) {
			val[i][j] = true;
			for (int t = 1; t <= k; t++) {
				if (in(a[t], i, j) ^ in(b[t], i, j)) {
					val[i][j] = false;
					break;
				}
			}
			if (val[i][j]) {
				for (int t = 1; t <= k; t++) {
					cnt[i][j] += in(a[t], i, j) + in(b[t], i, j);
				}
			}
		}
	}
	int ans = 0;
	for (int d = 2; d <= n * 2; d += 2) {
		for (int i = 1, j = d; j <= n * 2; i++, j++) {
			if (!val[i][j]) continue;
			dp[i][j] = g[d - cnt[i][j]];
			for (int k = i + 1; k < j; k++) {
				dp[i][j] = (dp[i][j] + 1ll * (mod - dp[i][k]) * g[j - k - cnt[k + 1][j]]) % mod;
			}
			ans = (ans + 1ll * dp[i][j] * g[(n - k) * 2 - (d - cnt[i][j])]) % mod;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3456
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)


int main()
{
    double t;
    int x;
    scanf("%lf%d",&t,&x);
    t/=x;
    printf("%lf\n",t);
    return 0;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())

if b<=0 and c>=0:
  print(b*c)
  
elif a>=0 and d<=0:
  print(a*d)
  
elif d<=0 and b<=0 :
  print(c*a)
  
elif a>=0 and c>=0 :
  print(b*d)
  
else:
  print(max(a*c,b*d))

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

int main()
{
	int N;
	string A, B, C;
	cin >> N >> A >> B >> C;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] == B[i] && B[i] == C[i]) {
			;
		}
		else if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) {
			cnt += 1;
		}
		else {
			cnt += 2;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
    int c[3][3];
        for(int i=0;i<3;++i){
            for(int j=0;j<3;++j){
                cin>>c[i][j];
            }
        }
    int x[3],y[3];
    x[0]=0;

            for(int i=0;i<3;++i)y[i]=c[0][i];
                for(int i=0;i<3;++i)x[i]=c[i][0]-y[0];
    bool check=true;


    
                    for(int i=0;i<3;++i){
                        for(int j=0;j<3;++j){
                            if(x[i]+y[j]!=c[i][j]){
                                check=false;
                                break;
                            }
                        }
                    }


                        if(check){
                            cout<<"Yes";
                        }else{
                            cout<<"No";
                        }
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  int n;
  string s[100010];
  cin>>n;
  rep(i,n)cin>>s[i];

  rep(i,n)sort(s[i].begin(),s[i].end());
  sort(s,s+n);
  //  rep(i,n)cout<<s[i]<<endl;


  int start=0;
  ll ans=0;
  while(start<n){
    int plus=1;
    while(s[start]==s[start+1]){
      ans+=plus;
      plus++;
      start++;
    }
    start++;
  }


  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 6768
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Array.Sort(line);
            int A = line[0];
            int B = line[1];
            Console.WriteLine(A + B);
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll power(ll a,ll b){
    a=a%mod;
    ll res=1;
    while(b){
        if(b&1){
            res=(1LL*res%mod*a%mod)%mod;
        }
        a=(1LL*a%mod*a%mod)%mod;
        b=b>>1;
    }
    return res%mod;
}
void solve(){
    ll n;
    cin>>n;
    ll a=power(10,n);
    ll b=power(9,n);
    ll c=power(8,n);
    ll ans=(a%mod-((b%mod+b%mod)%mod-c%mod)%mod)%mod;
    if(ans<0){
        ans+=mod;
    }
    cout<<ans<<"\n";
}
int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3620
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int a,b,c;
	std::cin >> a >> b >> c;
	std::cout << a << ' ' << b << ' ' << 3*c-a-b << ENDL;
	std::cout << 4*c-2*a-b << ' ' << c << ' ' << 2*a+b-2*c << ENDL;
	std::cout << a+b-c << ' ' << 2*c-b << ' ' << 2*c-a << ENDL;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
vector<ll> dp;

int main(){
	cin >> n;
	vector<ll> a(n);
	dp.resize(n,INF);
	rep(i,n)cin >> a[i];

	rep(i,n){
		auto it = lower_bound(ALL(dp),a[i]);
		*it = a[i];
	}
	int ans = 0;
	rep(i,n){
		if(dp[i] != INF)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4412
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
bool isOK(vector<long>* ok,long n){
  for(long l: *ok){
	//cout << l << endl;
	if(n==l){
	  return true;
	}
  }
  return false;
}
int main(){
  long n,ii,jj;
  vector<long> ok;
  long cost = 0;
  for(ii=0;ii<=25;ii++){
	cost = ii*4;
	jj=0;
	while(cost<=120){
	  cost += jj*7;	  
	  ok.push_back(cost);
	  jj++;
	}

  }
  cin >> n;
  if(isOK(&ok,n)){
	cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll INF = 1ll << 60;

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N;
  while (cin >> N) {
    vector<ll> A(N);
    for (ll& x : A) cin >> x;
    vector<ll> dp(2, -INF);
    dp[0] = 0;
    for (ll x : A) {
      vector<ll> ndp(2, -INF);
      for (int p = 0; p < 2; p++) {
        if (dp[p] <= -INF) continue;
        for (int np = 0; np < 2; np++) {
          chmax(ndp[(p + np) % 2], dp[p] + x * (np ? -1 : 1));
        }
      }
      dp = ndp;
    }
    cout << dp[0] << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

static int max_size = 10001;
static int sentinel = 1000001;

int main(void) {
    int i, j, k, n, m, max, t1, t2, tl[max_size], tr[max_size], tmix[max_size*2];

    while (EOF != scanf(" %d %d", &n, &m)) {
        if (m == 0 && n == 0) {
            break;
        }

        for (i = 0; i < n; i++) {
            scanf(" %d", &tl[i]);
        }
        tl[i] = sentinel;

        for (i = 0; i < m; i++) {
            scanf(" %d", &tr[i]);
        }
        tr[i] = sentinel;

        max  = i = j = 0;
        tmix[0] = 0;
        k = 1;

        // merge
        while (tl[i] != sentinel || tr[j] != sentinel) {
            if (tl[i] == sentinel) {
                tmix[k++] = tr[j++];
            } else if (tr[j] == sentinel) {
                tmix[k++] = tl[i++];
            } else {
                tmix[k++] = (tl[i] < tr[j])?(tl[i++]):(tr[j++]);
            }
        }

        for (i = 1; i <= m + n; i++) {
            if (max < (tmix[i] - tmix[i - 1])) {
                max = tmix[i] - tmix[i - 1];
            }
        }

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

    }
    return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

struct state {
	ll v0, v1, v2;
	state() { v0 = v1 = v2 = 0; }
};

void merge_states(state &a, state &b) {
	ll tmp = (a.v2 * b.v0 + a.v1 * b.v1 + a.v0 * b.v2) % MOD;
	tmp = (tmp + a.v2 * b.v1 + a.v1 * b.v2) % MOD;
	tmp = (tmp + a.v2 * b.v2) % MOD;
	a.v2 = tmp;
	a.v1 = (a.v1 * b.v0 + a.v0 * b.v1) % MOD;
	a.v0 = (a.v0 * b.v0) % MOD;
}

void merge_states_deque(deque<state> &a, deque<state> &b) {
	if (SZ(a) < SZ(b)) {
		swap(a, b);
	}
	REP(i, 0, SZ(b)) {
		merge_states(a[i], b[i]);
	}
}

deque<state> states[MAXN];
state new_state;
int ind[MAXN];
int dis[MAXN];
ll st2[MAXN];
int cnt[MAXN];

vi g[MAXN];

void dfs(int s) {
	int d = 0;
	REP(i, 0, SZ(g[s])) {
		int to = g[s][i];
		dis[to] = dis[s] + 1;
		dfs(to);
		if (i == 0) {
			ind[s] = ind[to];
		} else {
			merge_states_deque(states[ind[s]], states[ind[to]]);
			d = max(d, SZ(states[ind[to]]));
		}
	}
	
	states[ind[s]].push_front(new_state);
	
	/*printf("%d: %d\n", s, SZ(states[ind[s]]));
	REP(i, 0, SZ(states[ind[s]])) {
		printf("%lld %lld %lld\n", states[ind[s]][i].v0, states[ind[s]][i].v1, states[ind[s]][i].v2);
	}*/
	
	REPN(i, 1, d) {
		states[ind[s]][i].v0 = (states[ind[s]][i].v0 + states[ind[s]][i].v2) % MOD;
		states[ind[s]][i].v2 = 0;
	}
	
	
}

void solve(){
	int n;
	scanf("%d", &n);
	REPN(i, 1, n) {
		int p;
		scanf("%d", &p);
		g[p].pb(i);
		ind[i] = i;
	}
	
	new_state.v0 = new_state.v1 = 1;
	new_state.v2 = 0;
	
	dfs(0);
	
	st2[0] = 1;
	REPN(i, 1, n + 1) {
		st2[i] = (st2[i - 1] * 2) % MOD;
	}
	
	REPN(i, 0, n) {
		cnt[dis[i]]++;
	}
	
	ll ans = 0ll;
	REP(i, 0, SZ(states[ind[0]])) {
		ans = (ans + states[ind[0]][i].v1 * st2[n + 1 - cnt[i]]) % MOD;
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 240884
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;


int main(void){

	for( int i = 0; i < 3; i++ ) {
		int val[2][3];
		int t[3] = { 3600, 60, 1 };
		int sum;
		for( int j = 0; j < 6; j++ ) {
			cin >> val[j/3][j%3];
		}
			
		for( int j = 0; j < 3; j++ ) {
			sum += ( val[1][j] - val[0][j] ) * t[j];
		}
		cout << sum / t[0];
		sum %= t[0];
		for( int j = 1; j < 3; j++ ) {
			cout << " " << sum / t[j];
			sum %= t[j];
		}
		cout << endl;
	}


    return 0;
}

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


def solve(S: str, T: str):
    min_change = 100000000

    S = [s for s in S]
    T = [t for t in T]

    for i, s in enumerate(S):
        for j, t in enumerate(T):
            if j == 0:
                c = 0
            if len(S) <= i + j:
                break
            if S[i+j] != t:
                c += 1
            if len(T) == j + 1:
                min_change = min(min_change, c)

    print(min_change)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9140