akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;

const int INF = INT_MAX / 4;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( ui i = (ui)( m ); i < (ui)( n ); i++ )
#define EACH( v, c ) for ( __typeof( c.front() ) &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int main()
{
	while ( true )
	{
		string line;
		getline( cin, line );

		if ( line == "." )
		{
			break;;
		}

		bool yes = true;
		stack<char> st;

		for ( auto &c : line )
		{
			if ( c == '(' || c == '[' )
			{
				st.push( c );
			}
			else if ( c == ')' || c == ']' )
			{
				int c2 = ( c == ')' ? '(' : '[' );

				if ( !st.empty() && st.top() == c2 )
				{
					st.pop();
				}
				else
				{
					yes = false;
				}
			}
		}

		if ( yes && st.empty() )
		{
			cout << "yes" << endl;
		}
		else
		{
			cout << "no" << endl;
		}
	}				

	return 0;
}

Measured memory_bytes: 1180
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int k = sc.nextInt();
    int[] a = new int[s.length()];
    for(int i=0;i<s.length();i++){
      a[i]=s.charAt(i)=='a'?0:'z'-s.charAt(i)+1;
    }
    for(int i=0;i<s.length();i++){
      if(a[i]<=k){
        k-=a[i];
        a[i]=0;
      }
    }
    if(k%26!=0){
      a[s.length()-1]-=(k%26);
      if(a[s.length()-1]<0){
        a[s.length()-1]+=26;
      }
    }
    StringBuilder sb = new StringBuilder();
    for(int i=0;i<s.length();i++){
      if(a[i]==0){
        sb.append('a');
      }else{
        sb.append((char)('z'-a[i]+1));
      }
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 26576
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin, s, t;
    int ans = 0;
    int n = s.size();
    REP(i, 0, n) {
        ans += s[i] != t[i];
    }
    print(ans);

    return 0;
}


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  string s;
  cin >> s;
  cout << (s.length() % 2 != 0 ^ s[0] == s[s.length() - 1] ? "First" : "Second") << endl;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	

	int b = 0;
	int f = 0;
	int r = 0;
	int v = 0;
	int roomMem[4][3][10] = { 0 };

	char sh[21] ="####################";

	// 0 = スペードが'S'、 1 = ハートが'H'、2 =クラブが'C'、3 = ダイヤが'D'
	int n;
	scanf("%d", &n);

	int i = 0;
	for (; i < n; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		roomMem[b - 1][f - 1][r - 1] += v;
	}

	int b_i = 0;
	for (; b_i < 4; b_i++) {
		int f_i = 0;
		for (f_i = 0; f_i < 3; f_i++) {
			int r_i = 0;
			for (r_i = 0; r_i < 10; r_i++) {
				printf(" %d", roomMem[b_i][f_i][r_i]);
				//if (r_i != 9) {
				//	printf(" ");
				//}
			}
			//if (b_i == 3 && f_i == 2) {
				
			//}else { 
				printf("\n");
			//}
		}
		if (b_i != 3) {
			printf("%s\n", sh);
		}
		
	}


	return 0;
}


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

int n, cnt = 1;
string s;

int main() {
  cin >> n >> s;
  for(int i = 1; i < n; ++i) {
    if(s[i] == 'x' && s[i - 1] == 'x') break;
    ++cnt;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3336
import numpy as np
S = [int(s) for s in input()]
p1 = [1 if i % 2 == 0 else 0 for i in range(len(S))]
p2 = [0 if i % 2 == 0 else 1 for i in range(len(S))]
print(min(np.count_nonzero(np.logical_xor(p1, S)), np.count_nonzero(np.logical_xor(p2, S))))

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

bool c[200][200];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        c[b][a] = true;
    }

    vector<pair<int, int> > v;

    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        v.push_back({b, a});
    }
    sort(v.begin(), v.end());

    int ans = 0;
    for (int i = 0; i < n; i++) {
        pair<int, int> p = v[i];

        int x = -1, y = -1;

        for (int i = 0; i < p.second; i++) {
            for (int j = 0; j < p.first; j++) {
                if (c[j][i]) x = i, y = j;
            }
        }

        if (x != -1) {
            c[y][x] = false;
            ans++;
        }
    }

    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
ll f(ll x) {
  ll num = 0;
  // if (x == 0 || x == 1) return 1;
  if (((x + 1) / 2) % 2 == 1) {
    num += 1;
  }
  if (x % 2 == 0) {
    num += x;
  } else {
  }
  return num;
}
int main() {
  ll A, B;
  cin >> A >> B;
  if (A == B) {
    cout << A << endl;
    return 0;
  }
  cout << (f(A - 1) ^ f(B)) << endl;
}

Measured memory_bytes: 3616
// https://atcoder.jp/contests/abc146/tasks/abc146_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    for (auto &x : s) {
        int a = ((x - 'A') + n) % 26;
        char c = 'A' + a;
        cout << c;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;
const ll MOD = 1e9 + 7; 

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int a,b,c;
  cin>>a>>b>>c;
  int q=b/a;
  if(a>b){
  	cout<<"0"<<endl;
  }
  else if(q>=c){
  	cout<<c<<endl;
  }
  else{
  	cout<<q<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

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

  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  int count = 0;
  for (int i = 0; i < n; i++) {
    while (v[i] / 2 + v[i] / 2 == v[i]) {
      count++;
      v[i] /= 2;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
package main

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

type shop struct {
	price int
	stock int
}

type shops []shop

func (s shops) Len() int {
	return len(s)
}

func (s shops) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s shops) Less(i, j int) bool {
	return s[i].price < s[j].price
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var s shops = make([]shop, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		s[i].price, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		s[i].stock, _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(s)

	count := 0
	sum := 0
	for i := 0; i < n; i++ {
		if v := count + s[i].stock; v >= m {
			sum += s[i].price * (m - count)
			break
		} else {
			count = v
			sum += s[i].price * s[i].stock
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 3840
//ABC145_B
#include <stdio.h>
int main(int argc, char const *argv[]) {
    int n;
    char s[101];
    int flag = 1;
    scanf("%d\n%s",&n,&s);

    if(n%2==0){
        for(int i=0;i<=(n-2)/2;i++){
            if(s[i]!=s[i+(n/2)]) flag = 0;
        }
    }else{
        flag = 0;
    }

    if(flag==1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main()
{
    ll N; cin >> N;
    vector<ll> a(N);
    vector<ll> b(N);
    for(int i = 0 ; i < N ; i++)
    {
        ll x,y;
        cin >> x >> y;
        a[i] = x+y;
        b[i] = x-y;
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    cout << max(a[N-1] - a[0] , b[N-1] - b[0]);

}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define ll long long
#define fastio cin.sync_with_stdio(false); cin.tie(NULL)
#define all(x) x.begin(),x.end()
using namespace std;
int h,w,n;
ll ans[10]={0};
int main(){
  cin>>h>>w>>n;
  ans[0]=(ll)(h-2)*(w-2);
  vector <pair<int,int>> a(n);
  for (int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
    a[i].first--;a[i].second--;
  }
  map <pair<int,int>,int> m;
  for (int i=0;i<n;i++){
    for (int j=-2;j<=0;j++){
      for (int k=-2;k<=0;k++){
        int x=a[i].first+j;
        int y=a[i].second+k;
        if (x<0||x>h-3||y<0||y>w-3) continue;

        m[{x,y}]++;
      }
    }
  }
  for (auto it:m){
    ans[0]--;
    ans[it.second]++;
  }
  for (int i=0;i<10;i++)cout<<ans[i]<<'\n';
  return 0;
}


Measured memory_bytes: 60116
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    stack <int> st;
    while(cin>>n){
            if(n==0){
                if(st.empty()){
                    continue;
                }
                cout<<st.top()<<endl;
                st.pop();
            }
            else{
                st.push(n);

            }

    }


    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  map<ll,ll> mp;
  repr(i, n, 0) {
    cin >> a[i];
    sum += a[i];
    mp[a[i]] ++;
  }
  ll q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    ll b,c;
    cin >> b >> c;
    ll cnt = mp[b];
    sum -= cnt * b;
    sum += cnt * c;
    mp[b] = 0;
    mp[c] += cnt;
    cout << sum << endl;
  }

}

Measured memory_bytes: 10084
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
	int n;
	
	cin>>n;vl v(n);
	rep(i,n){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	double ans;
	ans=v[0];
	rep(i,n){
		ans=(ans+v[i])/2;
	}
	cout<<ans<<endl;
	return 0;
}













Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	
	int N,x,k;
	scanf("%d",&N);
	
	k = N / 100;
	if( N <= 100*k + 10*k + k){
		x = 100*k + 10*k + k;
	}else{
		k++;
		x = 100*k + 10*k + k;
	}
	
	printf("%d",x);

}

Measured memory_bytes: 128
from collections import Counter

N=int(input())
a_lst = [int(_) for _ in input().split()]

c = Counter(a_lst)
mi = min(a_lst)
ma = max(a_lst)

ans = 0
for i in range(mi, ma + 1):
    score = c[i] + c[i+1]+c[i+2]
    ans = max(ans, score)
print(ans)

Measured memory_bytes: 14564
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = [S() for _ in range(3)]
    r = ''.join([a[i][i] for i in range(3)])

    return r


print(main())




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

using namespace std;

using ll = long long;
const ll mod = 998244353;

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

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

    vector<vector<ll>> dp(n + 1, vector<ll>(s + 1));
    dp[0][0] = 1;
    rep(i, n) {
        rep(j, s + 1) {
            dp[i + 1][j] += ((dp[i][j] * 2) % mod);
            dp[i + 1][j] %= mod;
            if (j + a[i] <= s) {
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= mod;
            }
        }
    }
    cout << dp[n][s] << '\n';
    return 0;
}


Measured memory_bytes: 73728
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
struct node{
	//char name [15];
	string name;
	int fen;
	int xu;
}book[105];
int camp( const node &c1,const node &c2){
	if(c1.name==c2.name)  return c1.fen<c2.fen;
	else return c1.name>c2.name;
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>book[i].name;
		scanf("%d",&book[i].fen);
    	book[i].xu=i;
	}
    sort(book+1,book+1+n,camp);
    //cout<<book[2].name;
    for(int i=n;i>=1;i--)
    {
    //cout<<book[i].name;
		printf("%d\n",book[i].xu);
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string s;
  cin >> s;
  int n = s.size() - 2;
  
  cout << s[0]+to_string(n)+s[s.size()-1];
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define MP make_pair
#define all(s) (s).begin(), (s).end()
#define rev(s) (s).rbegin(), (s).rend()
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

void test(){freopen("test.txt", "r", stdin);}

int main(){
	int n, m;
	cin >> n >> m;
	vector<P> pr;
	rep(i, m){
		int l, r;
		cin >> l >> r;
		pr.push_back(MP(r, l));
	}
	sort(rev(pr));

	int right = 1;
	int ans = 0;
	while(n != right-1){
		rep(i, m){
			if(pr[i].second <= right && right <= pr[i].first){
				right = pr[i].first+1;
				ans++;
				goto next;
			}
		}
		cout << "Impossible" << endl;
		return 0;
next:
		;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define maxn 310
#define mod 1000000007
#define P pair<int,int>
int dp[2][3][maxn][maxn];
void add(int &x,int y)
{
    x+=y;
    if(x>=mod) x-=mod;
}
vector<P>lim[maxn];
int n,m;
void mem(int cur)
{
    for(int k=0;k<3;++k)
        for(int i=0;i<=n;++i)
            for(int j=0;j<=n;++j)
                dp[cur][k][i][j]=0;
}
bool judge(int pos,int x1,int x2,int x3)
{
    int r,g,b;
    if(x1==0)
    {
        r=pos;
        g=x2;
        b=x3;
    }
    else if(x1==1)
    {
        r=x2;
        g=pos;
        b=x3;
    }
    else
    {
        r=x2;
        g=x3;
        b=pos;
    }
    for(int i=0;i<(int)lim[pos].size();++i)
    {
        P tmp=lim[pos][i];
        int l=tmp.first,cnt=tmp.second;
        if(r>0&&r>=l) --cnt;
        if(g>0&&g>=l) --cnt;
        if(b>0&&b>=l) --cnt;
        if(cnt!=0) return false;
    }
    return true;
}
int main()
{
    while(~scanf("%d%d",&n,&m))
    {
        for(int i=1;i<=n;++i) lim[i].clear();
        while(m--)
        {
            int l,r,x;
            scanf("%d%d%d",&l,&r,&x);
            lim[r].push_back(P(l,x));
        }
        int cur=0,nex=1;
        mem(cur);
        dp[cur][0][0][0]=1;
        dp[cur][1][0][0]=1;
        dp[cur][2][0][0]=1;
        for(int i=1;i<n;++i)
        {
            //cur^=1; nex^=1;
            mem(nex);
            for(int j=0;j<3;++j)
            {
                for(int k=0;k<=n;++k)
                {
                    for(int l=0;l<=n;++l)
                    {
                        int tmp=dp[cur][j][k][l];
                        if(tmp==0||!judge(i,j,k,l)) continue;
                        if(j==0)
                        {
                            //R=i,G=k,B=l
                            //paint R
                            add(dp[nex][0][k][l],tmp);
                            //paint G
                            add(dp[nex][1][i][l],tmp);
                            //paint B
                            add(dp[nex][2][i][k],tmp);
                        }
                        else if(j==1)
                        {
                            //R=k,G=i,B=l
                            //paint R
                            add(dp[nex][0][i][l],tmp);
                            //paint G
                            add(dp[nex][1][k][l],tmp);
                            //paint B
                            add(dp[nex][2][k][i],tmp);
                        }
                        else
                        {
                            //R=k,G=l,B=i
                            //paint R
                            add(dp[nex][0][l][i],tmp);
                            add(dp[nex][1][k][i],tmp);
                            add(dp[nex][2][k][l],tmp);
                        }
                    }
                }
            }
            cur^=1; nex^=1;
        }
        int ans=0;
        for(int i=0;i<3;++i)
            for(int j=0;j<=n;++j)
                for(int k=0;k<=n;++k)
                    if(judge(n,i,j,k))
                        add(ans,dp[cur][i][j][k]);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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


struct unionfind {
	ll N;
	vector<ll> par;
	vector<ll> sz;//根の場合、その木のサイズ

	unionfind(ll N0) {
		N = N0;
		par.assign(N + 1, -1);
		sz.assign(N + 1, 1);

	}

	ll root(ll x) {
		if (par[x] == -1) { return x; }
		par[x] = root(par[x]);
		return par[x];
	}

	bool same(ll x, ll y) {
		return root(x) == root(y);
	}

	void unite(ll x, ll y) {
		ll a = root(x);
		ll b = root(y);
		if (a != b) { par[a] = b; }
		sz[b] += sz[a];
	}

	ll size(ll x) {
		ll r = root(x);
		return sz[r];
	}
};


int main() {

	ll N, K, L;
	cin >> N >> K >> L;

	unionfind road(N), train(N);

	repn(i, K) {
		ll p, q;
		cin >> p >> q;
		road.unite(p, q);
	}

	repn(i, L) {
		ll r, s;
		cin >> r>> s;
		train.unite(r, s);
	}

	map<pair<ll, ll>,ll> mp;

	repn(i, N) {
		mp[{road.root(i), train.root(i)}]++;
	}

	repn(i, N) {
		cout << mp[{road.root(i), train.root(i)}] <<" ";
	}
	

	

	system("PAUSE");
}

Measured memory_bytes: 18296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const ll N = 105, INF = 1e18;
int n, source, sink;
ll a[N], par[N];
ll cap[N][N];
vector<int> adj[N];
 
void bfs(int source, int sink) {
	memset(par, -1, sizeof par);
	queue<int> q;
	q.push(source);
	while(!q.empty()) {
		int u = q.front(); q.pop();
		if(u == sink) return;
		for(auto& v : adj[u]) {
			if(par[v] == -1 && cap[u][v] > 0) {
				par[v] = u;
				q.push(v);
			}
		}
	}
}
 
ll augment(int u, ll bottleneck) {
	if(u == source) return bottleneck;
	if(par[u] != -1) {
		ll flow = augment(par[u], min(bottleneck, cap[par[u]][u]));
		cap[par[u]][u] -= flow;
		cap[u][par[u]] += flow;
		return flow;
	}
	return 0;
}
 
ll maxflow(int source, int sink) {
	ll flow = 0;
	ll newFlow;
	while(1) {
		bfs(source, sink);
		newFlow = augment(sink, INF);
		if(newFlow == 0) break;
		flow += newFlow;
	}
	return flow;
}
 
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	source = n+1; sink = n+2;
	ll ideal = 0;
	for(int i = 1; i <= n; i++)
		cin >> a[i], ideal += (a[i]>0)?a[i]:0;
	memset(cap, 0, sizeof cap);
	for(int i = 1; i <= n; i++) {
		if(a[i] < 0) adj[source].push_back(i), adj[i].push_back(source), cap[source][i] = -a[i];
		else adj[i].push_back(sink), adj[sink].push_back(i), cap[i][sink] = a[i];
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 2*i; j <= n; j+=i)
			adj[i].push_back(j), adj[j].push_back(i), cap[i][j] = INF;
	}
	ll mf = maxflow(source, sink);
	ll ans = ideal - mf;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3760
#include "bits/stdc++.h"
#include <unordered_set>

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979323846

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;

//==============================================

vi pre, in, post;
int pos = 0;

int rec(int l, int r) {
	if (l >= r) return 0;

	int root = pre[pos++];
	int mid = distance(in.begin(), find(ALL(in), root));

	rec(l, mid);
	rec(mid + 1, r);

	post.push_back(root);
}

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

	int n;
	cin >> n;

	pre.resize(n);
	in.resize(n);

	int tmpN;
	REP(i, n) cin >> tmpN, pre[i] = tmpN;
	REP(i, n) cin >> tmpN, in[i] = tmpN;

	rec(0, pre.size());

	REP(i, n) {
		if (i) cout << " ";
		cout << post[i];
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 3232
import sys
input = sys.stdin.readline
import heapq
n = int(input())
a = [int(i) for i in input().split()]
a_l = [];a_r = []
sum_a_l = 0;sum_a_r = 0
a = tuple(a)
heapq.heapify(a_l);heapq.heapify(a_r)

for i in range(n):
  heapq.heappush(a_l,a[i])
  heapq.heappush(a_r,-a[3*n-1-i])
  sum_a_l += a[i]
  sum_a_r += a[3*n-1-i]
chk_1 = [sum_a_l]
chk_2 = [sum_a_r]
import collections
chk_1 = collections.deque(chk_1)
chk_2 = collections.deque(chk_2)
ans = -float('inf')
for i in range(n):
  heapq.heappush(a_l,a[n+i])
  heapq.heappush(a_r,-a[2*n-1-i])
  x = heapq.heappop(a_l)
  y = heapq.heappop(a_r)
  chk_1_append=chk_1.append
  chk_2_append=chk_2.append
  sum_a_l += a[n+i]-x
  sum_a_r += y+a[2*n-1-i]
  chk_1_append(sum_a_l)
  chk_2_append(sum_a_r)

for i in range(n+1):
  ans = max(chk_1.pop()-chk_2.popleft(),ans)
print(ans)

Measured memory_bytes: 128528
#include<stdio.h>
int main(void){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int n=a*100+b*10+c;
	if(n==0||n==10||n==100)printf("Close\n");
	else printf("Open\n");
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 505



int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("in.txt","r",stdin);
//   freopen("out.txt","w",stdout);
    int n,m;
    cin>>n;
    double ar=2.0*n*pai;
    cout<<fixed<<setprecision(15)<<ar<<endl;
    return 0;
}



Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll modpow(ll a, ll b, ll m)
{
    if (b == 0) return 1%m;
    ll u = modpow(a, b / 2, m);
    u = ((u%m) * (u%m)) % m;
    if (b%2) u = ((a%m) * (u%m))%m;
    return u;
}

const int mod = (int) 1e9 + 7;

ll ncr(ll n, ll r)
{
    if (n - r < r) r = n - r;
    ll ans = 1;
    ll fr = 1;
    for (int i = 1, j = n; i <= r; i++, j--) {
        ans = ((ans%mod) *( j%mod))%mod;
        fr = ((fr%mod)  * (i%mod)) % mod;
    }
    return ((ans%mod) * modpow(fr, mod - 2, mod)) % mod;
}

void solve()
{
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = modpow(2, n, mod) - 1;
    ans = ans - ncr(n, a) - ncr(n, b);
    cout << (ans%mod + mod)%mod << "\n";
}

int main()
{

    int t = 1;
    while (t--) 
    {
        solve();
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector


bool check(int x)
{
    int a = x%10 ;
    x/=10;
    if(a>1 and x>1)return 1;
    return 0;
}

void solve()
{
    int m,d;
    cin>>m>>d;
    int ans = 0;
    forn(i,22,d)
    {
        int a = i%10 , b= i/10;
        if(check(i) and a*b<=m){
            ans++;
           // cout<<i<<"\n";
        }
    }
    cout<<ans;
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }



    return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 256
#include <cstdio>

typedef long long ll;
ll n,p,tot=0,pr[40],t[40],ans=1;

int main()
{
    scanf("%lld%lld",&n,&p);
    for(ll i=2;i*i<=p;i++)
    {
        if(p%i==0)
        {
            t[tot]=0;
            pr[tot]=i;
            while(p%i==0)
            {
                t[tot]++;
                p/=i;
            }
            tot++;
        }
    }
    if(p!=1) {t[tot]=1;pr[tot++]=p;}
    for(int i=0;i<tot;i++)
        for(int j=0;j<t[i]/n;j++)
            ans*=pr[i];
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 128
class Factorial:
    def __init__(self, max_fact, mod):
        #mod should be prime number
        #using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
        f = [1] * 2 + [None] * (max_fact - 1)
        for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx % mod
        fi = [None] * max_fact + [pow(f[-1], mod - 2, mod)]
        for idx in range(max_fact, 0, -1):
            fi[idx - 1] = fi[idx] * idx % mod
        self.mod = mod
        self.f = f
        self.fi = fi

    def factorial(self, n):
        return self.f[n]

    def factorial_inverse(self, n):
        return self.fi[n]

    def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

    def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

    def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod


max_fact = 5 * 10**5
mod = 10**9 + 7
fact_instance = Factorial(max_fact, mod)
comb = fact_instance.combination
perm = fact_instance.permutation

N, M = [int(_) for _ in input().split()]
ans = 0
for p in range(N + 1):
    ans += (-1)**p * comb(N, p) * perm(M - p, N - p)
    ans %= mod
ans *= perm(M, N)
ans %= mod
print(ans)


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

using namespace std;

const int N = 5e5 + 5;
const int BLOCK_SIZE = 705;

struct Query {
    int l, r, idx;
    bool operator<(Query other) const
    {
        return make_pair(l / BLOCK_SIZE, r) <
               make_pair(other.l / BLOCK_SIZE, other.r);
    }
};


int n, q, arr[N], ans[N], cnt[N], hey;
vector<Query> queries;

bool cmp(pair<int, int> p, pair<int, int> q) {
    if (p.first / BLOCK_SIZE != q.first / BLOCK_SIZE)
        return p < q;
    return (p.first / BLOCK_SIZE & 1) ? (p.second < q.second) : (p.second > q.second);
}

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

    cin >> n >> q;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
    }
    for(int i = 1; i <= q; i++){
        int a, b;
        cin >> a >> b;
        Query test;
        test.idx = i;
        test.l = a;
        test.r = b;
        queries.push_back(test);
    }

    sort(queries.begin(), queries.end());

    int cur_l = 0;
    int cur_r = -1;
    hey = 0;
    for(Query q : queries){
        while (cur_l > q.l) {
            cur_l--;
            int num = arr[cur_l];
            if(cnt[num] == 0){
                hey++;
            }
            cnt[num]++;
        }
        while (cur_r < q.r) {
            cur_r++;
            int num = arr[cur_r];
            if(cnt[num] == 0){
                hey++;
            }
            cnt[num]++;
        }
        while (cur_l < q.l) {
            int num = arr[cur_l];
            if(cnt[num] == 1){
                hey--;
            }
            cnt[num]--;
            cur_l++;
        }
        while (cur_r > q.r) {
            int num = arr[cur_r];
            if(cnt[num] == 1){
                hey--;
            }
            cnt[num]--;
            cur_r--;
        }
        ans[q.idx] = hey;
    }

    for(int i = 1; i <= q; i++){
        cout << ans[i] << '\n';
    }
    return 0;
}

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


int main(){
    string s1,s2;
    cin>>s1>>s2;
    ll n1,n2;
    n1=s1.size();
    n2=s2.size();
    vector<vector<ll> >dp(n1+1,vector<ll>(n2+1,0));
    for(ll i = 1 ; i < n1+1 ; i++ ){
        for(ll j = 1 ; j < n2+1 ; j++ ){
            if(s1[i-1]==s2[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string ans="";
    ll i = n1;
    ll j  = n2;
   
    while(i>0 && j >0 ){
               if( s1[i-1]==s2[j-1]){
                   ans+=s1[i-1];
                   i--;
                   j--;
               }
               else if(dp[i-1][j]>dp[i][j-1]){
                   i--;
               }
               else{
                   j--;
           }
       }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}


Measured memory_bytes: 73584
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> to(n,false),from(n,false);
  vi a(m); vi b(m);
  rep(i,m) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    if(a[i]==0) to[b[i]] = true;
    if(b[i]==n-1) from[a[i]] = true;
  }
  rep(i,n) if(to[i]&&from[i]) {
    cout << "POSSIBLE" << endl;
    return 0;
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int N, M;
string U[257];

int main() {
  char s[11];
  scanf("%d", &N);
  for (int i=0;i<N;i++) {
    scanf("%s", s);
    U[i] = s;
  }
  scanf("%d", &M);
  bool opened = false;
  for (int i=0;i<M;i++) {
    scanf("%s", s);
    const string* p = find(U, U+N, (string)s);
    if (!p->empty()) {
      opened = !opened;
      printf("%s by %s\n", (opened ? "Opened" : "Closed"), s);
    } else {
      printf("Unknown %s\n", s);
    }
  }
  return 0;
}

Measured memory_bytes: 2836
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt(), b = scan.nextInt();
		String[] S = new String[a];
		String output = "";
		for (int i = 0;  i < a; i++ ) S[i] = scan.next();
		Arrays.sort(S);
		for (int i = 0;  i < a; i++ ) System.out.print(S[i]);
	}
}

Measured memory_bytes: 21972
#include<stdio.h>
int main()
{
    int h,w,i,j,flag=1;
    char a[55][55];
    scanf("%d %d",&h,&w);
    getchar();
    for(i=0; i<h; i++)
    {
        for(j=0; j<w; j++)
            scanf("%c",&a[i][j]);
        getchar();
    }
    for(i=0; i<h; i++)
    {
        for(j=0; j<w; j++)
        {
            if(a[i][j]=='#')
            {
                if(i==0)
                {
                    if(j==0)
                    {
                        if(a[i+1][j]!=a[i][j]&&a[i][j+1]!=a[i][j])
                        {
                            flag=0;
                            break;
                        }
                    }
                    else if(j==w-1)
                    {
                        if(a[i+1][j]!=a[i][j]&&a[i][j-1]!=a[i][j])
                        {
                            flag=0;
                            break;
                        }
                    }
                    else
                    {
                        if(a[i+1][j]!=a[i][j]&&a[i][j-1]!=a[i][j]&&a[i][j+1]!='#')
                        {
                            flag=0;
                            break;
                        }
                    }
                }
                else if(i==h-1)
                {
                    if(j==0)
                    {
                        if(a[i-1][j]!=a[i][j]&&a[i][j+1]!=a[i][j])
                        {
                            flag=0;
                            break;
                        }
                    }
                    else if(j==w-1)
                    {
                        if(a[i-1][j]!=a[i][j]&&a[i][j-1]!=a[i][j])
                        {
                            flag=0;
                            break;
                        }
                    }
                    else
                    {
                        if(a[i-1][j]!=a[i][j]&&a[i][j-1]!=a[i][j]&&a[i][j+1]!='#')
                        {
                            flag=0;
                            break;
                        }
                    }
                }
                else
                {
                    if(j==0)
                    {
                        if(a[i-1][j]!=a[i][j]&&a[i][j+1]!='#'&&a[i+1][j]!='#')
                        {
                            flag=0;
                            break;
                        }
                    }
                    else if(j==w-1)
                    {
                        if(a[i-1][j]!=a[i][j]&&a[i+1][j]!=a[i][j]&&a[i][j-1]!='#')
                        {
                            flag=0;
                            break;
                        }
                    }
                    else
                    {
                        if(a[i-1][j]!=a[i][j]&&a[i+1][j]!='#'&&a[i][j-1]!=a[i][j]&&a[i][j+1]!='#')
                        {
                            flag=0;
                            break;
                        }
                    }
                }
            }

        }
        if(flag==0)
            break;
    }
    if(flag==0)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val k = inputs.head.toInt

  println(solve(k))

  def solve(k: Int): Int = {
    val set = scala.collection.mutable.Set.empty[Int]
    var mod = 7 % k
    var count = 1

    (0 until k).foreach { i =>
      if(set.contains(mod)) {
        return -1
      }


      if(mod == 0) {
        return count
      }

      mod = (mod * 10 + 7) % k
      count = count + 1
    }

    -1
  }
}

Measured memory_bytes: 56304
import java.util.*;
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){
            System.out.println("a < b");
        }else if(a > b){
            System.out.println("a > b");
        }else {
            System.out.println("a == b");
        }
        sc.close();
    }
}


Measured memory_bytes: 26336
#include <stdio.h>

int array[44] = {};

int fibo(int n){
    if(n <= 1){ return 1; }
    if(array[n-2]){
        return array[n-2] + fibo(n-1);
    }else{
        array[n-2] = fibo(n-2);
        return array[n-2] + fibo(n-1);
    }
}

int main(){
    int n;

    scanf("%d", &n);
    printf("%d\n", fibo(n));
    return 0;
}

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

"""
input:
5 8

output:
390625
"""

import sys


def mod_pow(x, n, _mod):
    res = 1
    while n > 0:
        # check n is odd number
        if n % 2:
            res = res * x % _mod
        x = pow(x, 2) % _mod
        n //= 2
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    M = 1000000007
    # print(pow(n1, n2, M))
    print(mod_pow(n1, n2, M))

Measured memory_bytes: 7720
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  map<int, int> mp;
  for (int i = 0; i < n - 1; ++i) {
    int cnt = 0;
    mp.clear();
    for (int j = 0; j <= i; ++j) mp[s[j]]++;
    for (int j = i + 1; j < n; ++j) {
      if (mp[s[j]]) {
        ++cnt;
        mp[s[j]] = 0;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}





Measured memory_bytes: 256
#include <stdio.h>
 
int main(int argc, const char * argv[]) {
    int tr[4][14];
    int n,i,j,c;
    char m;
    for(i = 0 ; i < 4 ; i++){
        for(j = 0 ; j < 14 ; j++){
            tr[i][j] = 0;
        }
    }
    scanf("%d",&c);
    for(i = 0 ; i < c ; i++){
        scanf("\n");
        scanf("%c %d",&m,&n);
        if(m == 'S'){
            tr[0][n] = 1;
        }else if(m == 'H'){
            tr[1][n] = 1;
        }else if(m == 'C'){
            tr[2][n] = 1;
        }else if(m == 'D'){
            tr[3][n] = 1;
        }
    }
    for(j = 1 ; j < 14 ; j++){
        if(tr[0][j] != 1){
            printf("S %d\n",j);
        }
    }
    for(j = 1 ; j < 14 ; j++){
        if(tr[1][j] != 1){
            printf("H %d\n",j);
        }
    }
    for(j = 1 ; j < 14 ; j++){
        if(tr[2][j] != 1){
            printf("C %d\n",j);
        }
    }
    for(j = 1 ; j < 14 ; j++){
        if(tr[3][j] != 1){
            printf("D %d\n",j);
        }
    }
    return 0;
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
int a[200];
int main() {
    int x,n;
    cin>>x>>n;
    for(int x1,i=1; i<=n; i++) {
        cin>>x1;
        a[x1]=1;
    }
    int ans=201,result=0;
    for(int i=0; i<=201; i++) {
        if(a[i]!=1) {
            int  r=abs(x-i);
            if(r<ans) {
                ans=min(ans,r);
                result=i;
            }
        }
    }
    cout<<result;
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef struct{
  int t;
  int x;
  int y;
}Travel;
int main(){
  int n;
  scanf("%d",&n);
  Travel plan[100001];
  for(int i=0;i<n;i++) scanf("%d %d %d",&plan[i].t,&plan[i].x,&plan[i].y);
  int time=plan[n-1].t;
  int count=0;
  for(int i=0;i<n;i++){
    if(plan[i].x==0 && plan[i].y==0){
      if(plan[i].t%2==0){
        count++;
      }
    }else if(plan[i].t<plan[i].x+plan[i].y){
      count--;
    }else if(plan[i].t%2==(plan[i].x+plan[i].y)%2){
      count++;
    }
  }
  if(count==n) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static bool[,] graph = new bool[8, 8];
        static void Main(string[] args)
        {
            var S = ReadLine();
            var T = ReadLine();
            var ans = 0;
            for(var i=0;i<S.Length;i++)
            {
                if (S[i] != T[i]) ans++;
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 18240
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        int n = sc.nextInt();

        int[] arr = new int[n];

        for (int i=0; i<n-1; i++) {
            int tmp = sc.nextInt();
            arr[tmp-1]++;
        }

        for (int i=0; i<n; i++) {
            System.out.println(arr[i]);
        }
    }
}


Measured memory_bytes: 62204
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

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

    int A, B;
    A=B=0;

    int cnt=0;
    for(int i=0; i<N; i++){
        if(S[i]=='A'){
            A=1;
            B=0;
        }else if(A==1 && S[i]=='B'){
            A=0;
            B=1;
        }else if(B==1 && S[i]=='C'){
            cnt++;
            A=0;
            B=0;
        }else{
            A=0;
            B=0;
        }
    }

    cout << cnt << endl;
}

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++)
typedef long long ll;

int main() {
    string S; cin >> S;
    if(S[0] == S[1] && S[1] == S[2] && S[2] == S[0]) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 764
n, m = map(int, input().split())
votes = list(map(int, input().split()))
vote_total = sum(votes)
base_4m = vote_total / (4 * m)
over4m_count = 0

for i in votes:
    if i >= base_4m:
        over4m_count += 1

if over4m_count >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <cstdio>

int main()
{
        const int MAX = 10;
        char str[MAX+1];
        int num[MAX];

        while (scanf("%s", str) != EOF) {
                for (int i = 0; i < MAX; i++) {
                        num[i] = str[i] - '0';
                }
                for (int j = MAX - 1; j > 0; j--) {
                        for (int i = 0; i < j; i++) {
                                num[i] = (num[i] + num[i+1]) % 10;
                        }
                }
                printf("%d\n", num[0]);
        }
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a(100000, 0);
vector<int> col(3, 0);
long long mod = 1e9+7;
int main() {
    cin >> n;
    long long ans = 1;
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }

    for(int i = 0; i < n; ++i) {
        long long cnt = 0;
        long long c = 0;
        if(a.at(i) == col.at(0)) {
            cnt++;
            c = 0;
        }
        if(a.at(i) == col.at(1)) {
            cnt++;
            c = 1;
        }
        if(a.at(i) == col.at(2)) {
            cnt++;
            c = 2;
        }
        ans *= cnt;
        col.at(c)++;
        ans %= mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640