akhauriyash/Code-Regression huggingface dataset:
from typing import List


def alds_1_11a():
    n = int(input())
    for i in range(n):
        u, k, *v = map(int, input().split())
        a = [0] * n
        for i_v in v:
            index_v = i_v - 1
            a[index_v] = 1
        print(*a)
    return


def print_matrices_list(matrices_list):
    for index_row in range(len(matrices_list)):
        print(*matrices_list[index_row])
    return


# def depth_first_search(u, stack, color, d):
#     stack.append(u)
#     color[u] = 1
#     while len(stack) != 0:
#     pass


def accept_adjacency_list() -> List[List[int]]:
    n = int(input())
    adjancy_list = []
    for i in range(n):
        list_u = list(map(int, input().split()))
        adjancy_list.append(list_u)
    return adjancy_list


def adjacency_list2adjacency_matrices(adj_list: List[List[int]]) -> List[List[int]]:
    adjancy_matrices = []
    n = len(adj_list)
    for list_u_i in adj_list:
        id_u, degree_k, *list_v = list_u_i
        list_row = [0] * n
        for v_i in list_v:
            list_row[v_i - 1] = 1
        adjancy_matrices.append(list_row)
    return adjancy_matrices


def dfs(adj_mat):
    n = len(adj_mat)
    list_colors = [0] * n  # 0:white, 1:gray, 2:black
    time = 0
    d = [0] * n  # 最初に訪問した頂点uの発見時刻
    f = [0] * n  # uの隣接リストを調べ終えた完了時刻

    for u in range(n):
        if list_colors[u] == 0:
            list_colors, time, d, f = dfs_visit(u, list_colors, adj_mat, d, f, time)

    for u in range(n):
        print(u + 1, d[u], f[u])
    return


def dfs_visit(u: int, list_colors: list, adj_mat: list, d: list, f: list, time: int):
    list_colors[u] = 1  # uを訪問
    time += 1
    d[u] = time
    for v in range(len(list_colors)):  # v:次に探索する場所
        if adj_mat[u][v] == 0:  # uからvに行く辺がないなら次へ
            continue
        if list_colors[v] == 0:  # uからvに道があるかつ行ったことがないなら行く。
            list_colors, time, d, f = dfs_visit(
                u=v, list_colors=list_colors, adj_mat=adj_mat, d=d, f=f, time=time
            )
    list_colors[u] = 2
    time += 1
    f[u] = time
    return list_colors, time, d, f


if __name__ == "__main__":
    # init
    adjacency_list = accept_adjacency_list()
    adjacency_matirces = adjacency_list2adjacency_matrices(adj_list=adjacency_list)

    dfs(adj_mat=adjacency_matirces)



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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int K = sc.nextInt();
		
		char it = S.charAt(K-1);

		for (int i = 0; i< S.length(); i++) {
			if (it != S.charAt(i)) {
				S = S.substring(0,i)+ '*' +S.substring(i+1);
			}
		}
		System.out.println(S);
	}
}	


Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int main() {
	int n,k,m,a=0,b=0;
	cin>>n>>m>>k;
	for(int i=0; i<m; i++) {
		int f;
		cin>>f;
		((f<k)?(a++):(b++));
	}
	cout<<min(a,b);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

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

    int ans = 0;
    FOR(i, 1, k){
        FOR(j, 1, k){
            FOR(l, 1, k){
                ll ab = gcd(i, j);
                ans += gcd(ab, l);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    string S;
    cin >> S;
    if (S.length() == 2) {
        cout << S << endl;
    } else {
        reverse(S.begin(), S.end());
        cout << S << endl;
    }
    return 0;
}

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

int main(void){
	int m,n1,n2,a,b;
	int p[201];
	while(cin>>m>>n1>>n2,m||n1||n2){
		for(int i=0;i<m;i++)cin>>p[i];
		a=0;b=0;
		for(int i=n1;i<=n2;i++){
			if(a<=p[i-1]-p[i]){
				b=i;
				a=p[i-1]-p[i];
			}
		}
		cout<<b<<endl;
	}
	return 0;
}

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

ll power(ll a, int x){
    if(x == 0) return 1;
    if(x % 2) return a * power(a, x-1);
    return power(a * a, x / 2);
}

int main(){
    ll x;
    cin >> x;
    for(int a = -130; a < 130; a++){
        for(int b = -130; b < 130; b++){
            if(power(a, 5) - power(b, 5) == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    ll n,k;
    scanf("%lld %lld",&n,&k);
    vector<ll> a(n,0);
    ll ans = 0;
    for (int i = 0; i < n; i++) scanf("%lld",&a[i]);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
              ll res = k * (k + 1) / 2 % mod;
              ans = (ans + res) % mod;
            } else if (a[i] < a[j]) {
                ll res = k * (k - 1) / 2 % mod;
                ans = (ans + res) % mod;
            } 
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
		int a,b,c,s;
		scanf("%d %d %d",&a,&b,&c);
		if(a>=b){
			if(a>=c){
				s=10*a+b+c;
			}else{
				s=10*c+a+b;
			}
		}else{
			if(b>=c){
				s=10*b+a+c;
			}else{
				s=10*c+a+b;
			}
		}
		printf("%d",s);
	return 0;
}

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL M;
int V, P;
LL A[100011];
LL sums[100011];

void MAIN() {
    scanf("%d%lld%d%d", &N, &M, &V, &P);
    REP (i, N) scanf("%lld", A+i);

    sort(A, A+N);
    REP (i, N) sums[i+1] = sums[i] + A[i];

    int ans = 0;
    REP (i, N) {
	if (i + P >= N) {
	    ans++;
	} else if (A[i] + M >= A[N-P]) {
	    if (V <= P + i) {
		ans++;
	    } else {
		LL len = (N-P+1) - (i+1);
		LL x = V-P-i;
		LL y = (A[i]+M) * len - (sums[N-P+1] - sums[i+1]);
		if (y >= x * M) ans++;
	    }
	}
    }

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

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2882&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int n,l,r;
    while(cin >> n >> l >> r,n){
        vector<int> A(n); for(auto& in:A) cin >> in;
        int ans = 0;
        for(int x = l ; x <= r; x++){
            bool ok = false;
            for(int i = 0; i < n;i++){
                if(x%A[i] == 0){
                    ok = true;
                    ans += (i+1)%2 == 1;
                    break;
                }
            }
            if(!ok) ans += n%2 == 0;
        }
        cout << ans << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



Measured memory_bytes: 3168
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		List<Integer> productList = new ArrayList<>();

		int answer = 0;

		int N = scanner.nextInt();

		for(int i = 0; i < N; i++) {
			int temp = scanner.nextInt();
			productList.add(Integer.valueOf(temp));
			answer += temp;
		}

		Optional<Integer> max = productList.stream().max(Comparator.naturalOrder());

		System.out.println(answer - (max.get()/2));

	}

}


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

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

	t = N/B;
	if(t*B+(B-1) <= N)
		r = t*B+(B-1);
	else
		r = min(N, max(t*B-1, 1ll));
	
	cout << max(A*r/B-A*(r/B), max(A*(N-1)/B-A*((N-1)/B), A*N/B-A*(N/B))) << endl;
}

Measured memory_bytes: 3600
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int n = inp.nextInt();
        int k = inp.nextInt();
        int x = inp.nextInt();
        int y = inp.nextInt();
        if (n <= k) {
            System.out.println(n * x);
            return;
        }
        int ks = n - k;
        int ans = k * x + ks * y;
        System.out.println(ans);
    }
}

Measured memory_bytes: 22740
#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() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int w, a, b;
  cin >> w >> a >> b;
  if(a > b) {
    int t = a;
    a = b;
    b = t;
  }
  else if(a == b) {
    cout << 0 << endl;
    return 0;
  }
  
  if(a+w < b) {
    cout << b - (a+w) << endl;
    return 0;
  }
  else {
    cout << 0 << endl;
    return 0;
  }
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define mod ((int)1e9+7)
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

const int N = (int)2e5+5;

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

    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) {
        cout<<"Yes";
    }
    else cout<<"No";
}


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

int main() {
  int s;
  bool chk = true;
  int tmp = 0;
  int kekka = 1;
  vector<int> vec(1000000,0);
  cin >> s;
  
  int roopCnt = 0;
  tmp = s;
  while(chk == true){
    if(roopCnt == 0){
      vec.at(roopCnt) = tmp;
      roopCnt++;
      continue;
    }
    
    if(tmp % 2 == 0) tmp /= 2;
    else tmp = 3 * tmp + 1;
    
    for(int i = 0; i < roopCnt; i++){
      if(vec.at(i) == tmp){
        chk = false;
        kekka = i+1;
      }
    }
    vec.at(roopCnt) = tmp;
    roopCnt++;
  }
  
  cout << roopCnt;
}


Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

const int MOD = 998244353;


// a^n % mod
long long modpow(long long a, long long n, long long mod) {
	long long ret = 1;

	while (n > 0) {
		if (n & 1) {
			ret = ret * a % mod;
		}

		a = a * a % mod;
		n >>= 1;
	}

	return ret;
}

// aの逆元
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}


class Combination {
public:
	vector<long long> fact, ifact;
	long long mod;
public:
	Combination(int n, int mod) : fact(n+1), ifact(n+1), mod(mod) {
		fact[0] = 1;
		for (int i = 1; i <= n; i++) {
			fact[i] = fact[i-1] * i % mod;
		}
		ifact[n] = modinv(fact[n], mod);
		for (int i = n; i > 0; i--) {
			ifact[i-1] = ifact[i] * i % mod;
		}
	};

	// nCk
	long long comb(int n, int k) {
		return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
	}
};


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

	Combination comb(n, MOD);
	vector<long long> pows(n + 1, 0);
	pows[0] = 1;
	for (int i = 1; i < pows.size(); i++) {
		pows[i] = pows[i-1] * (m - 1) % MOD;
	}

	long long ans = 0;
	for (int i = 0; i <= k; i++) {
		ans += pows[n - 1 - i] * comb.comb(n-1, i);
		ans %= MOD;
	}
	ans *= m;
	ans %= MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7512
#include <bits/stdc++.h>
#define N 18
#define ll long long
#define x first
#define y second
#define all(v) v.begin(),v.end()
using namespace std;
int ar[N][2];
int n;
int dp [ 1<< N ][ 51];
int pr[ 51 ];
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            cout.tie(NULL);
            cin>>n;
            for(int i=0;i<n;i++)
                cin>>ar[i][0];
            for(int i=0;i<n;i++)
                cin>>ar[i][1];
            for(int i=0;i<=50;i++)
                for(int j=0;j<(1<<n);j++)
                dp[j][i]=1e9;
            dp[0][0]=0;
            for(int i=0;i<(1<<n);i++){

                for(int j=0;j<51;j++){
                    pr[j] = 1e9;
                    if(dp[i][j]!=1e9)pr[j]=dp[i][j];
                    if(j)pr[j]=min(pr[j],pr[j-1]);
                }
                ll tot = __builtin_popcount(i);
                ll pos = tot;
                int cur = 0;
                for(int j=0;j<n;j++){
                    int h = (i>>j);
                    if(h&1){
                            tot--;
                            continue;
                    }
                    cur = j + tot;
                    int flip =tot&1;
                    int cost= abs(cur-pos );
                    flip += cost&1;
                    flip=flip&1;
                    int next = (1<<j)|i;
                    dp[next][ar[j][flip]]= min(dp[next][ar[j][flip]], pr[ar[j][flip]]+cost);
                }
            }
            int ans= 1e9;
            for(int i=1;i<=50;i++)
                ans=min(ans,dp[(1<<n)-1][i]);
            if(ans>=1e9)ans=-1;
            cout<<ans;
                         return 0;
}


Measured memory_bytes: 52480
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long n,i,a,ans=0;
	cin>>n;
	for(i=sqrt(n);i>=1;i--)
	if(n%i==0)
	{
		a=n/i;
		break;
	}
	while(a)
	{
		ans++;
		a/=10;
	}
	cout<<ans<<endl;
}

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

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

  string s;
  cin >> s;
  bool b1 = s.at(2) == s.at(3);
  bool b2 = s.at(4) == s.at(5);
  
  if(b1 && b2) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int x;
    cin>>x;
    cout<<(1000*(x/500)+5*(x%500/5))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p[100009],n,m,in[100009],dp[100009],vis[100009];
vector<int>v[100009];
int dfs(int x)
{
    if(dp[x]!=-1)return dp[x];
    dp[x]=0;
    for(int i=0;i<v[x].size();i++)
    {
        int y=v[x][i];
        dp[x]=max(dfs(y)+1,dp[x]);
    }
    return dp[x];

}
int x,y;
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        x--;y--;
        v[x].push_back(y);
        in[y]++;
    }
    memset(dp,-1,sizeof(dp));
    int mx=0;
    for(int i=0;i<n;i++)
    {
        if(in[i])continue;
        mx=max(mx,dfs(i));
    }
    cout<<mx;
}


Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N;
    cin>>N;
    map<string,ll> m;
    map<string,bool> b;
    vector <string> S(N);
    rep(i,0,N){
        cin>>S[i];
        m[S[i]]++;
        b[S[i]] = false;
    }
    ll ans = 0;
    rep(i,0,N){
        if(!b[S[i]]){
            b[S[i]] = true;
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 40676
import math
 
x = int(input())

if x == 2:
    print(2)
    exit()
 
while True:
    f = True
    g = math.ceil(math.sqrt(x))
    for i in range(2,g+1):
        if x%i == 0:
            f = False
            break
    if f == True:
        print(x)
        exit()
    x += 1

Measured memory_bytes: 3060
N = gets.to_i
S = gets.to_i

def calc(b, n)
    n < b ? n : n%b + calc(b,n/b)
end

def calc_two_digit(b, n)
    n%b + (n/b)
end

2.upto(989898) do |b|
    if calc(b, N) == S
        p b; exit
    end
end

best = nil
1.upto(989898) do |s_high|
    # s EQ n%b + s_high
    # n EQ n%b + s_high*b
    # s EQ n-s_high*b + s_high
    # s_high*b EQ n - s + s_high
    # b EQ (n - s + s_high)/s_high
    b = (N - S + s_high)/s_high
    if b > 1 && calc(b, N) == S
        best = b if !best || b < best
    end
end

p best ? best : N == S ? S+1 : S == 1 ? N : -1


Measured memory_bytes: 1788
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
	ll x; cin >> x;
	ll res = (x / 11) * 2 + ((x % 11) <= 6 ? 1 : 2) - (int)(x % 11 == 0);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;


int main() {
 
  int64_t N,M;
  cin>>N>>M;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << N*M << endl;
}

Measured memory_bytes: 3636
def get_input():
    length = int(raw_input())
    return map(int, raw_input().split())


def insertionSort(input_array):
    print " ".join(str(each)  for each in input_array).rstrip(" ")
    for i in range(1,len(input_array)):
        key = input_array[i]
        j = i-1
        while j >= 0 and input_array[j] > key:
            input_array[j+1] = input_array[j]
            j -= 1
            input_array[j+1] = key
        print " ".join(str(each)  for each in input_array).rstrip(" ")

insertionSort(get_input())

Measured memory_bytes: 6272
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

x = ri_()
for i, xi in enumerate(x):
    if xi == 0:
        print(i + 1)
        exit()

Measured memory_bytes: 9180
#include <stdio.h>
int main()
{
	int	K;	/* 高橋君が持っている500円玉の枚数	*/
	int	X;	/* その総額がX円以上か			*/

	scanf("%d %d", &K, &X);
	
	if((500 * K) >= X)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, T;
int A[100005];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N >> T;
    REP(i, N) cin >> A[i];

    int maxd = 0;
    int mina = INF;
    map<int, int> mp;
    REP(i, N) {
        mina = min(mina, A[i]);
        mp[A[i] - mina]++;
        maxd = max(maxd, A[i] - mina);
    }
    cout << mp[maxd] << endl;

    return 0;
}


Measured memory_bytes: 7296
#include <cstdio>
using namespace std;

int main(){
	int h, w;
	while (scanf("%d %d",&h,&w), h != 0) {
		for(int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 2564
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)3e3+7;
const ll INF = (ll)-1e18+7;

int N,M,P;
vector<pi> G[MAXN];
int vis[MAXN];
ll dis[MAXN];
queue<int> qu;

ll bfs() {
    while (!qu.empty()) qu.pop();
    memset(dis,0x3f,sizeof(dis));
    dis[1] = 0;vis[1] = 1;qu.push(1);
    while (!qu.empty()) {
        int k = qu.front();qu.pop();
        if (vis[k] >= 6000) dis[k] = INF;
        if (vis[k] >= 6001) continue;

        rep(i,0,G[k].size()-1) {
            int v = G[k][i].first;
            int cost = G[k][i].second;
            if (vis[v] >= 6000) continue;
            if (dis[v] > dis[k]+cost) {
                dis[v] = dis[k]+cost;
                if (dis[k] == INF) dis[v] = INF;
                qu.push(v);
                vis[v] ++;
            }
        }
    }
    return dis[N];
}

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

    cin >> N >> M >> P;
    rep(i,1,M) {
        int u,v,c;
        cin >> u >> v >> c;
        G[u].pb(make_pair(v,P-c));
    }
    ll res = bfs();
    if (res <= -1e18) cout << -1 << endl;
    else             cout << -min(res,0LL) << endl;
}


Measured memory_bytes: 5504
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int K = sc.nextInt();
		int X = sc.nextInt();
		int min = X - K + 1;
		int max = X + K;
		for (int i = min; i < max; i++) {
			System.out.print(i + " ");
		}
	}

}

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 || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    
    int k_count = 0;
    int answer = 0;
    //NとKをnum,kに代入
    int num,k;
    cin>>num>>k;
    //count[i](i+1と書かれたボールの個数)を0で初期化
    int count[num];
    for(int i=0;i<num;i++){
        count[i]=0;
    }
    //各数字の書かれたボールの個数をcount[i]にて数える
    for(int i=0;i<num;i++){
        int a = 0;
        cin>>a;
        count[a-1]++;
    }
    //count[i]の値を調べて数字の種類数をk_countで数える
    for(int i=0;i<num;i++){
        if(count[i]>=1){
            k_count++;
        }
    }
    int current_position = -1;
    sort(count,count+num);
    while(true){
        //もし数字の種類数がKより少なければループ脱出
        if(k_count<=k){
            break;
        }
        //iと書かれたボールの個数(count[i])が少ないものから数字を書き換える
        //ここでcount[i]を小さい順に並び替えておくと良かった希ガス

        while(true){
            current_position ++;
            if(count[current_position]!=0){
                answer += count[current_position];
                k_count --;
                break;
            }
        }

    }
    //答えを出力
    cout<<answer<<endl;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define F first
#define S second
#define rf(i,a,b) for(int (i) = (a); (i) <= (b); (i)++)
#define rb(i,b,a) for(int (i) = (b); (i) >= (a); (i)--)
#define watch(x) cout << (#x) << " = " << (x) << endl
#define test(t) int(testCnt) = 0; int(t); cin >> (t); while(t -- && ++testCnt)

const int INF = 2e9 + 7;
const int MAXA = 1e5 + 10;
const ll MOD = (ll) 1e9 + 7;
const ll INFLL = 9e18 + 7;

typedef pair<int, int> ii;
typedef pair<ii, int> II;
typedef vector<int> vi;
typedef vector<ii> vii;

int n, m, dis[MAXA];
vi adj[MAXA];
int ans;

int solve(int u) {
    if(dis[u] != -1) return dis[u];
    if(adj[u].size() == 0) return 0;
    rf(i, 0, (int)adj[u].size() - 1) {
        int v = adj[u][i];
        dis[u] = max(dis[u], 1 + solve(v));
    }
    return dis[u];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
      // freopen("in.in", "r", stdin);
    #endif
    cin >> n >> m;
    while(m--) {
        int u,v;
        cin >> u >> v;
        adj[u].pb(v);
    }
    memset(dis, -1, sizeof(dis));
    rf(i, 1, n) {
        solve(i);
        ans = max(ans, dis[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
//#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long


using namespace std;
typedef pair<int, int>P;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


const int MAX = 500010;
const int MOD = 1000000007;
const ll INF = 1e17;
const double pi = acos(-1);
double EPS = 1e-10;




int cum[200010];
int N, X;
int x[200010];
vector<int>x2;
int cum2[200020];
signed main() {
	int L, N; cin >> L >> N;
	cum[0] = 0;
	REP(i, N) {
		cin >> x[i];
		cum[i + 1] = cum[i] + x[i];
	}

	ll ans = 0;
	for (int k = 1; k <= N; k++) {
		ll res = 0;
		int rem = N - k + 1;
		int cnt = rem / 2;
		res = 2 * (cum[k + cnt - 1] - cum[k - 1]);
		res += 2*L * cnt - 2*(cum[N] - cum[N - cnt]);
		if (rem % 2 == 1) {
			res += x[k + cnt-1];
		}
		else {
			res -= L - x[N - cnt];
		}
		if (res >= ans) {
			//printf("k:%lld res:%lld\n", k, res);
		}
		ans = max(ans, res);
	}
	//cout << endl;
	x2.resize(N);
	cum2[0] = 0;
	REP(i, N) {
		x2[i] = L - x[N - i-1];
		cum2[i + 1] = cum2[i] + x2[i];
	}

	for (int k = 1; k <= N; k++) {
		ll res = 0;
		int rem = N - k + 1;
		int cnt = rem / 2;
		res = 2 * (cum2[k + cnt - 1] - cum2[k - 1]);
		res += 2 * L * cnt - 2 * (cum2[N] - cum2[N - cnt]);
		if (rem % 2 == 1) {
			res += x2[k + cnt - 1];
		}
		else {
			res -= L - x2[N - cnt];
		}
		if (res >= ans) {
			//printf("k:%lld res:%lld\n", k, res);
		}
		ans = max(ans, res);
	}

	print(ans);
}

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

long long gcd(long long a,long long b){
	if(a==0 || b==0){
		return max(a,b);
	}
	else if(a%b==0 || b%a==0){
		return min(a,b);
	}
	
	long long q;
	bool pro =true;
	while(pro){
		q=a%b;
		a=b;
		b=q;
		if(a%b==0){
			return q;
			pro=false;
		}
	}
}

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

int main() {
	int N;
	cin>>N;
	vector<ll> a(N);
	ll go;
	cin>>a.at(0);
	go=a.at(0);
	for(int i=1;i<N;i++){
		cin>>a.at(i);
		go=lcm(go,a.at(i));
	}
	go--;
	// cout<<go<<endl;
	ll ans=0;
	for(int i=0;i<N;i++){
		ans+=a.at(i);
		ans--;
	}
	
	cout<<ans<<endl;
	
	return 0;
}





Measured memory_bytes: 256
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>

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

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    if(a >= k)
    {
        cout << a - k << " " << b << endl;
    }else{
        k = k - a;
        if(b >= k)
        {
            cout << 0 << " " << b - k << endl;
        }else{
            cout << 0 << " " << 0 << endl;
        }
    }
}

Measured memory_bytes: 256
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k=int(input())
print(a[k-1])

Measured memory_bytes: 38448
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

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

const int INF = 1001001001;

struct UF
{
	vi par, rank;
	UF(int n) : par(n), rank(n, 0) {
		rep(i, n) par[i] = i;
	}
	
	int find(int x) {
		return par[x]==x ? x : (par[x] = find(par[x]));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y])
			par[x] = y;
		else
			par[y] = x;
		rank[x] += rank[x] == rank[y];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

typedef complex<int> P;
int dot(P a, P b){
	return real(conj(a)*b);
}
int cross(P a, P b){
	return imag(conj(a)*b);
}
int ccw(P a, P b, P c)
{
	b -= a;
	c -= a;
	if(cross(b, c) > 0)   return +1; // 反時計回り
	if(cross(b, c) < 0)   return -1; // 時計回り
	if(dot(b, c) < 0)     return +2; // c--a--b
	if(norm(b) < norm(c)) return -2; // a--b--c
	return 0;
}

bool inner(const vector<P>& ps, P p)
{
	rep(i, 4){
		if(ccw(ps[i], ps[(i+1)%4], p) < 0)
			return false;
	}
	return true;
}
bool crossSS(P a, P b, P c, P d) {
	return ccw(a, b, c)*ccw(a, b, d) <= 0 && ccw(c, d, a)*ccw(c, d, b) <= 0;
}

bool cross(vector<P> A, vector<P> B)
{
	rep(i, 4) rep(j, 4){
		if(crossSS(A[i], A[(i+1)%4], B[j], B[(j+1)%4])){
			return true;
		}
	}
	return inner(A, B[0]) || inner(B, A[0]);
}

int main()
{
	int n;
	while(scanf("%d", &n), n){
		rep(i, n){
			int m;
			scanf("%d", &m);

			vector<P> rect[100];
			rep(j, m){
				rect[j].resize(4);
				rep(k, 4)
					scanf("%d%d", &rect[j][3-k].real(), &rect[j][3-k].imag());
			}

			UF uf(m);
			int ans = m;
			rep(j, m) reps(k, j+1, m){
				if(!uf.same(j, k) && cross(rect[j], rect[k])){
					uf.unite(j, k);
					--ans;
				}
			}
			printf("%d\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 1040
n = int(input())
a = [int(x) for x in input().split()]

status = 0
ans = 1
for i in range(1, n):
    if status == 0:
        if a[i-1] < a[i]:
            status = 1
        elif a[i-1] > a[i]:
            status = 2
    elif status == 1:
        if a[i-1] > a[i]:
            ans += 1
            status = 0
    elif status == 2:
        if a[i-1] < a[i]:
            ans += 1
            status = 0
print(ans)


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * 1ll * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

//only for variables and vi;
template <class TH>
void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; }
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a)
{
  while (*sdbg != ',')
    cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V)
{
  os << "[";
  for (auto vv : V)
    os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P)
{
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

/*...................................................*/

struct mat {
  vvi m;
  mat(vvi _m) {
    m = _m;
  }
  const vvi operator *(mat mm) {
    int n = m.size();
    vvi res(n, vi(n));
    for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
    for(int k = 0; k < n; k++) {
      res[i][k] += (m[i][j] * mm.m[j][k]) % mod; 
      if(res[i][k] > mod) res[i][k] -= mod;
    }
    return res;
  }
};

mat mod_mat_pow(mat b, ll p) {
  int n = b.m.size();
  vvi id(n, vi(n));
  for(int i = 0; i < n; i++)
  id[i][i] = 1ll;
  mat res(id);
  while(p) {
    if(p & 1)
    res = res * b;
    p >>= 1;
    b = b * b;
  }
  return res;
}
main()
{
  ll n, k, i, j;
  cin >> n >> k;
  vvi g(n, vi(n));
  for(i = 0; i < n; i++)
  for(j = 0; j < n; j++)
  cin >> g[i][j];
  mat mt(g);
  mt = mod_mat_pow(mt, k);
  ll ans = 0;
  for(i = 0; i < n; i++)
  for(j = 0; j < n; j++) {
    ans += mt.m[i][j];
    if(ans > mod) ans -= mod;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 512
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 998244353
using namespace std;
bool comp(pair<int,string> a, pair<int,string> b){
	return a.first > b.first;
}
int main(){
	FASTIO
    int n, i, j, o, c, tot = 0, k;

    cin >> n;

    string s;
    pair<int,string> p[n];

    rep(i, 0, n)
    {
        cin >> s;
        p[i].second = s;

        tot += s.size();

        for(j=o=c=0;j<s.size();++j)
        {
            if(s[j]=='(')
                ++o;
            else
                ++c;
        }

        
        if(o==0)
            p[i].first = INT_MIN;
        else if(c==0)
            p[i].first = INT_MAX;
        else if(o>c)
            p[i].first = INT_MAX-c;
        else if(o<c)
            p[i].first = INT_MIN+o;
        else
            p[i].first = 0;



    }

    sort(p,p+n,comp);

     string ans(tot,'a');



    k=0;
    for(i=0;i<n;++i)
    {
        s = p[i].second;

        for(j=0;j<s.size();++j,++k)
        {
            ans[k] = s[j];
        }
    }


    for(i=o=c=0;i<tot;++i)
    {
        if(ans[i]=='(')
            ++o;
        else
            --o;

        if(o<0)
        {
            cout<<"No";
            return 0;
        }
    }


    if(o==0)
        cout<<"Yes";
    else
        cout<<"No";


    return 0;
}

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

int main(void){
  int rate[8];
  int tmp;
  int free=0,min=0,max;
  int N;
  scanf("%d\n",&N);
  for (int i = 0; i < 8; i++) {
    rate[i]=0;
  }
for (int i = 0; i < N; i++) {
  scanf("%d\n",&tmp);
  if (tmp>=3200) {
    free++;
  }else{
    if (rate[tmp/400]==0) {
      min++;
      rate[tmp/400]=1;
    }
  }
}
if (min==0) {
  min=1;
  free-=1;
}
max=min+free;
printf("%d %d\n",min,max);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define M 1000000007
#define int long long
#define sz(c) (int)c.size()
#define first first
#define ll long long 
#define second second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define N 1000005
#define U 998244353
#define bs binary_search
#define endl '\n'
#define FILEIO     firsteopen("input.txt","r",stdin); firsteopen("output.txt","w", stdout);
using namespace std;
#define PI 3.1415926535
int po(int n, int exp){
    int prod=1;
    rep(i,0,exp)
        prod*=n;
    return prod;
}
int lcm(int a, int b){
    int g = __gcd(a,b);
    return (a/g)*b;
}
map<int,int> primeFactors(int n)  
{   
    map<int,int> ans;
    while (n % 2 == 0)  
    {  
        ans[2]++;
        n = n/2;  
    }  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {    
        while (n % i == 0)  
        {  
            ans[i]++;
            n = n/i;  
        }  
    }  
    if (n > 2)  
        ans[n]++;
    return ans;
}
int gcd(int a, int b, int &x, int &y) {
    if (a == 0) {
        x = 0; y = 1;
        return b;
    }
    int x1, y1;
    int d = gcd(b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
signed main()
{
    ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    int TESTS=1;
    // cin>>TESTS;
    int a,b;
    while(TESTS--)
    {
        int x,a;
        cin>>x>>a;
        if(x<a) cout<<0;
        else cout<<10;
    }
}   

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
//ll mod = 1000000007;
//ll mod = 998244353;

int main() {
	int n;
	cin >> n;
	vector<int> t(n), a(n);
	for (int i = 0; i < n; i++) cin >> t[i] >> a[i];
	vector<double> b(n + 1);
	b[0] = 1.0;
	for (int i = 1; i <= n; i++) {
		b[i] = b[i - 1] * (1.0 - (double)a[i - 1] * 0.1);
	}
	int q, l, r;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> l >> r;
		int lb = lower_bound(all(t), l) - t.begin();
		int rb = lower_bound(all(t), r) - t.begin();
		cout << fixed << setprecision(15) << b[rb] / b[lb] * 1000000000.0 << endl;
	}
}


Measured memory_bytes: 5220
#include<iostream>
#include<string>
#include<vector>
#include<cstdlib>
int main() {
	std::string S;
	std::vector<char> S1;
	std::vector<char> S2;
	long long s = 0;
	long long s1 = 0;
	long long s2 = 0;
	long long scale = 1;
	int count = 0;
	int count2 = 0;

		std::cin >> S;
		S1.reserve(S.size());
		S2.reserve(S.size());
		for (int i = 0; i < S.size(); i++) {
			if (i % 2 == 0) {
				S1.emplace_back('0');
			}
			else if (i % 2 == 1) {
				S1.emplace_back('1');
			}
			
			
		}

		for (int i = 0; i < S.size(); i++) {
			if (i % 2 == 0) {
				S2.emplace_back('1');
			}
			else if (i % 2 == 1) {
				S2.emplace_back('0');
			}
			

		}

		for (int i = S.size() - 1; i >= 0; i--) {
			if (S[i] - S1[i] != 0) {
				count++;
			}
			else if (S[i] - S2[i] != 0) {
				count2++;
			}
		}

		if (count >= count2) {
			std::cout << count2;
		}
		else if (count < count2) {
			std::cout << count;
		}


}

Measured memory_bytes: 512
import scala.io.StdIn.{readLine, readInt}

object Main extends App {
  val n = readInt
  var (taro, hanako) = (0, 0)

  for (_ <- 1 to n) {
    val Array(tCard, hCard) = readLine.split(" ")
    if (tCard > hCard) taro += 3
    else if (tCard == hCard) {
      taro += 1
      hanako += 1
    }
    else hanako += 3
  }

  println(taro + " "+ hanako)
}


Measured memory_bytes: 44388
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        int komoji = 0;
        if(!(Character.isUpperCase(s.charAt(1)))){
        	komoji++;
            if(!(Character.isUpperCase(s.charAt(s.length() - 1)))){
            	komoji++;
            }
        }
        for(int i = 2; i < s.length() - 1; i++){
        	if(s.charAt(i) == 'C'){
            	count++;
            }else if(!(Character.isUpperCase(s.charAt(i)))){
            	komoji++;
            }
        }
        if(s.charAt(0) == 'A' && count == 1 && komoji == s.length() - 2){
        	System.out.println("AC");
        }else{
        	System.out.println("WA");
        }
    }
}

Measured memory_bytes: 35640
K = int(input())
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(s[K-1])

Measured memory_bytes: 3060