akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

const long long int INF = 1LL << 50;

struct edge {
    int from,to;
    long long int cost;
};

edge es[2010];

long long int d[1010];
int n,m;

/*bool shortest_path(int s){
    for(int i=0; i<=n; i++){
        d[i] = INF;
    }
    d[1] = 0;
    for(int loop=0; loop<n-1; loop++){
        for(int i=0; i<m; i++){
            edge ed = es[i];
            if(d[ed.from] == INF){
                continue;
            }
            if(d[ed.to] > d[ed.from] + ed.cost){
                d[ed.to] = d[ed.from] + ed.cost;
            }
        }
    }
    return false;
}*/

int main(){

    int s,t;
    long long int dd;

    cin >> n >> m;

    for(int i=0; i<m; i++){
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].cost = -es[i].cost;
    }

    for(int i=0; i<=n; i++){
        d[i] = INF;
    }

    d[1] = 0;

    for(int loop=0; loop<n-1; loop++){
        for(int i=0; i<m; i++){
            //edge ed = es[i];
            edge ed;
            ed.cost = es[i].cost;
            ed.to = es[i].to;
            ed.from = es[i].from;
            if(d[ed.from] == INF){
                continue;
            }
            if(d[ed.to] > d[ed.from] + ed.cost){
                d[ed.to] = d[ed.from] + ed.cost;
            }
        }
    }

    long long int ans = d[n];

    bool negative[1010];

    for (int i = 0; i <= n; ++i) {
        negative[i] = false;
    }

    for (int loop = 0; loop < n ; loop++) {
        for (int i = 0; i < m; i++) {
            if (d[es[i].from] == INF){
                continue;
            }
            if (d[es[i].to] > d[es[i].from] + es[i].cost) {
                d[es[i].to] = d[es[i].from] + es[i].cost;
                negative[es[i].to] = true;
            }

            if (negative[es[i].from]) {
                negative[es[i].to] = true;
            }
        }
    }

    if(negative[n]){
        cout << "inf" << endl;
    }
    else{
        cout << -ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

char S2[1000000];

int main(){
  
  std::string S;
  std::cin >> S;
  
  long long int Slen = S.length();

  // copy S to S2
  long long int start = 3e5;
  long long int end = start + Slen;
  long long int flip = 1;
  for(long long int i = 0; i < Slen; i++){
    S2[start+i] = S[i];
  }

  // query
  long long int Q;
  scanf("%lld", &Q);

  long long int T, F;
  char C;
  for(long long int i = 0; i < Q; i++){
    scanf("%lld", &T);
    if(T == 1){
      flip *= -1;
    }
    else{
      scanf("%lld %c", &F, &C);
      // sentou
      if(F == 1){
        if(flip == 1){
          start--;
          S2[start] = C;
        }
        else{
          S2[end] = C;
          end++;
        }
      }
      // matsubi
      else{
        if(flip == 1){
          S2[end] = C;
          end++;
        }
        else{
          start--;
          S2[start] = C;
        }
      }
    }
  }

  std::cerr << "start:end " << start << ": " << end << std::endl;

  std::cerr << "Answer: " << std::endl;
  if(flip == 1){
    for(long long int i = start; i < end; i++){
      std::cout << S2[i];
    }std::cerr << std::endl;
  }
  else{
    for(long long int i = end-1; i >= start; i--){
      std::cout << S2[i];
    }std::cerr << std::endl;
  }

  return 0;
}


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

int main() {
  int a;
  int b;
  
  cin >> a >> b;
  
  if ((a*b)%2 == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<array>

using namespace std;
 
int main(){
    int a;
    cin >> a;
    vector<string> b(a);
    for(int i = 0; i < a;i++)
        cin >> b[i];
    for(int i = 1;i < a;i++){
        if(b[i][0] == b[i-1][b[i-1].size()-1]){
            for(int j = 0;j < a;j++){
                if(i != j && b[i] == b[j]){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r;








void sol()
{   
    cin>>a>>b>>c>>k;
    if(a>=k)cout<<k;
    else if(b>=k-a)cout<<a;
    else cout<<a-(k-a-b);
    
    
    
    //cout<<  <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3568
def check():
    H, W = map(int, input().split())
    S = [0]*(H+2)
    S[0] = '.'*(W+2)
    S[H+1] = '.'*(W+2)
    dh = [0,1,0,-1]
    dw = [1,0,-1,0]
    for h in range(1,H+1):
        S[h] = '.' + input() + '.'
    for h in range(H):
        for w in range(W):
            if S[h][w]=='#':
                for i in range(4):
                    if S[h+dh[i]][w+dw[i]]=='#':
                        break
                else:
                    return 'No'
    return 'Yes'
print(check())

Measured memory_bytes: 39280
#include <bits/stdc++.h> 
using namespace std;
typedef vector<int> int_vector;
typedef vector<long> long_vector;
typedef vector<double> double_vector;

typedef vector< vector<int> > int_matrix;
typedef vector<string> string_vector;
typedef vector< vector<string> > string_matrix;
double_vector mps;

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    long long diff = b - a;
    if (diff % 2 == 0) {
        cout << diff / 2 << endl;
    }

    else {
        long long d = min(a-1, n-b);
        if (a-1 < n-b){
            cout << d + 1 + (b - d - 2)/2 << endl;
        }
        else {
            cout << d + 1 + (n - a - d - 1)/2  << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    string S, T; cin >> S >> T;
    int ans = T.size();
    for (int i = 0; i < S.size(); i++) {
        if (i + T.size() > S.size()) continue;
        int cnt = 0;
        for (int j = 0; j < T.size(); j++) {
            if (S[i + j] != T[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#define N 500000

int n;

int left(int i){
  return i*2;
}
int right(int i){
  return i*2+1;
}

void maxHeapify(int *A,int i){
  int l,r,tmp;
  int largest;
  l = left(i);
  r = right(i);
  if(l <=n && A[l]>A[i]) largest = l;
  else largest = i;
  if(r <=n && A[r]>A[largest]) largest = r;
  if(largest != i){
    tmp = A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(A,largest);
  }
}

void buildMaxHeap(int *A){
  int i;
  for(i=n/2;i>=1;i--){
    maxHeapify(A,i);
  }
}

int main(){
  int i,A[N];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap(A);
  for(i=1;i<=n;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
# https://atcoder.jp/contests/agc017/tasks/agc017_a

from math import factorial
n, p = map(int, input().split())

nums = [int(i) for i in input().split()]

odd = 0
even = 0
for num in nums:
    if num % 2 == 0:
        even += 1
    else:
        odd += 1
ans = 0
if p == 0:
    e = 2 ** even
    o = 0
    for i in range(0, odd + 1, 2):
        o += factorial(odd) // (factorial(odd - i) * factorial(i))
    ans += e * o
elif p == 1:
    e = 2 ** even
    o = 0
    for i in range(1, odd + 1, 2):
        o += factorial(odd) // (factorial(odd - i) * factorial(i))
    ans += e * o
print(ans)

Measured memory_bytes: 38256
#include <stdio.h>

int main() {
	char w[101];
	int c[26] = {0};

	scanf("%s", w);

	for(int i = 0; w[i] != '\0'; i++) {
		c[w[i] - 'a']++;
	}

	for(int i = 0; i < 26; i++) {
		if((c[i] % 2) != 0) {
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include<set>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<iostream>

using namespace std;

typedef long long ll;
int mod=1e9+7;
const int maxn=1e5+10;
/*
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
            ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}

int a[maxn],b[maxn],c[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&b[i]);
    }
    for(int i=2;i<=n;i++)
    {
        scanf("%d",&c[i]);
    }
    int ans=0;
    set<int>s;
    for(int i=1;i<=n;i++)
    {
        ans+=b[a[i]];
        s.insert(a[i]);
        if(s.count(a[i]-1)==1)
            ans+=c[a[i]];
    }
    cout<<ans;

    return 0;
}
 */
int p[maxn],ans[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n-1;i++)
        scanf("%d",&p[i]);
    p[n]=1e9+7;
    ans[1]=p[1];
    for(int i=2;i<=n;i++)
    {
        ans[i]=min(p[i],p[i-1]);
    }
    ll sum=0;
    for(int i=1;i<=n;i++)
        sum+=ans[i];
    cout<<sum;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans = (n + 1) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>

using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;

int main() {
  double n,k;
  cin >> n >> k;
  double ans = 0;
  for(int i = 1; i <= n; i++) {
    double tmp = 1/n;
    int current = i;
    while(current < k) {
      current *= 2;
      tmp *= 0.5;
    }
    ans += tmp;
  }
  printf("%.10lf\n", ans);
  return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, m; cin >> n >> m;
	int sum{};
	vector<int> counts(n);
	for (int i{}; i < n; i++)
	{
		cin >> counts[i];
		sum += counts[i];
	}
	double threshold = static_cast<double>(sum) / (4 * m);
	sort(counts.begin(), counts.end(), greater<>());
	for (int i{}; i < n; i++)
	{
		if (counts[i] < threshold)
		{
			cout << "No";
			return 0;
		}
		if (--m == 0)
		{
			cout << "Yes";
			return 0;
		}
	}
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}
u64 dp[100010];
int main() {
  cout << setprecision(18);
  u32 N, K;
  cin >> N >> K;
  vector<i32> h(N);
  ArrayInput(h);
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (u32 i = 2; i < N && i < K; ++i) {
    u32 tmp, mini = 0xFFFFFFFF;
    for (u32 j = 0; j < i; ++j) {
      tmp = dp[j] + abs(h[i] - h[j]);
      mini = (mini < tmp) ? mini : tmp;
    }
    dp[i] = mini;
  }
  for (u32 i = K; i < N; ++i) {
    u32 tmp, mini = 0xFFFFFFFF;
    for (u32 j = 0; j < K; ++j) {
      tmp = dp[i - K + j] + abs(h[i] - h[i - K + j]);
      mini = mini < tmp ? mini : tmp;
    }
    dp[i] = mini;
  }
  cout << dp[N - 1] << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    ll n;
    cin>>n;
    const ll p = 998244353;
    ll a[n];
    map<ll,ll> mp;
    REP(i,n)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    if(mp[0]!=1)
    {
        cout<<0;
        return 0;
    }
    ll ans=1;
    for(int i=1;i<n;i++)
    {
        ans*=mp[a[i]-1];
        ans%=p;
    }
    cout<<ans;
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 7296
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int start = sc.nextInt();
		ArrayList<HashMap<Integer, Integer>> graph = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    graph.add(new HashMap<>());
		}
		for (int i = 0; i < m; i++) {
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int c = sc.nextInt();
		    graph.get(a).put(b, c);
		}
		PriorityQueue<Path> queue = new PriorityQueue<>();
		queue.add(new Path(start, 0));
		int[] costs = new int[n];
		int[] counts = new int[n];
		Arrays.fill(costs, Integer.MAX_VALUE);
		while (queue.size() > 0) {
		    Path p = queue.poll();
		    if (costs[p.idx] <= p.value) {
		        continue;
		    }
		    counts[p.idx]++;
		    if (counts[p.idx] > n + 1) {
		        System.out.println("NEGATIVE CYCLE");
		        return;
		    }
		    costs[p.idx] = p.value;
		    for (Map.Entry<Integer, Integer> entry : graph.get(p.idx).entrySet()) {
		        queue.add(new Path(entry.getKey(), p.value + entry.getValue()));
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int x : costs) {
		    if (x == Integer.MAX_VALUE) {
		        sb.append("INF");
		    } else {
		        sb.append(x);
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
	
	static class Path implements Comparable<Path> {
	    int idx;
	    int value;
	    
	    public Path(int idx, int value) {
	        this.idx = idx;
	        this.value = value;
	    }
	    
	    public int compareTo(Path another) {
	        return value - another.value;
	    }
	}
}



Measured memory_bytes: 38240
using System;

class C
{
	static void Main()
	{
		var words = new[] { "dream", "dreamer", "erase", "eraser" };
		var s = Console.ReadLine();

		while (s != "")
		{
			var ok = false;
			foreach (var w in words)
			{
				if (!s.EndsWith(w)) continue;
				s = s.Remove(s.Length - w.Length);
				ok = true;
				break;
			}
			if (ok) continue;
			Console.WriteLine("NO");
			return;
		}
		Console.WriteLine("YES");
	}
}


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

using namespace std;

vector<int> KMP(string s) {
  int n = s.size();
  vector<int> pi(n + 1, -1);
  for (int i = 0; i < n; ++i) {
    int j = pi[i];
    while (j != -1 && s[j] != s[i])
      j = pi[j];
    pi[i + 1] = j + 1;
  }
  pi.erase(pi.begin());
  return pi;
}

int main() {
  string s; cin >> s;
  auto pi = KMP(s);
  reverse(s.begin(), s.end());
  auto ip = KMP(s);
  reverse(s.begin(), s.end());
  reverse(ip.begin(), ip.end());
  int n = s.size();

  if (pi.back() == n - 1) {
    cout << n << " " << 1 << endl;
  } else if (pi[n - 1] == 0 || n % (n - pi[n - 1]) != 0) {
    cout << 1 << " " << 1 << endl;
  } else {
    int total = 0;
    bool found = false;
    for (int i = 1; i < n; ++i) {
      int n1 = i, p1 = pi[i - 1];
      int n2 = n - i, p2 = ip[i];
      if ((n1 > 1 && p1 > 0 && n1 % (n1 - p1) == 0) || 
          (n2 > 1 && p2 > 0 && n2 % (n2 - p2) == 0)) 
        continue;
      // cerr << "OK: " << string(s.begin(), s.begin() + i) << " " << string(s.begin() + i, s.end()) << endl;
      found = true;
      total += 1;
    }
    assert(found);
    cout << 2 << " " << total << endl;
  }

  return 0;
}


Measured memory_bytes: 5148
Option Strict On
Module Module1

    Sub Main()
        Dim n As Long = Convert.ToInt64(Console.ReadLine())
        Dim m(5) As Long
        m(5) = Convert.ToInt64(Console.ReadLine())
        m(4) = Convert.ToInt64(Console.ReadLine())
        m(3) = Convert.ToInt64(Console.ReadLine())
        m(2) = Convert.ToInt64(Console.ReadLine())
        m(1) = Convert.ToInt64(Console.ReadLine())
        Dim botlle As Long = m(1)
        For i As Integer = 2 To 5
            If m(i) < botlle Then
                botlle = m(i)
            End If
        Next
        Dim time As Long = 0
        time = Convert.ToInt64(Math.Ceiling(n / botlle) + 4)
        Console.WriteLine(time)
        Console.ReadLine()
    End Sub

End Module

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
#define mem(x,i) memset(x,i,sizeof(x)) 
#define eps 1e-8 
#define ull unsigned long long
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
const int maxn=1e5+100;
string s;
ll dp[maxn][13]={0};
ll pre[maxn]={0},num[maxn]; 
void init()
{
	int len=1e5;
	pre[0]=1;
	FOR(i,1,len) pre[i]=(pre[i-1]*10)%13;
}
int main()
{
	fast;cin>>s;
	init();
	reverse(all(s));
	ll sum=0,cnt=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!='?') sum=(sum+pre[i]*(s[i]-'0')%13)%13;
		else num[++cnt]=pre[i];
	}
	dp[0][sum]=1;
	for(int i=1;i<=cnt;i++)
	{
		for(int j=0;j<=12;j++)
		for(int k=0;k<=9;k++)
		{
			int base=((j-num[i]*k)%13+13)%13;
			dp[i][j]=(dp[i][j]+dp[i-1][base])%mod;
		}
	}
	ll ans=0;
	cout<<dp[cnt][5]<<endl;
}

Measured memory_bytes: 12240
n = int(input())
ans = 8
if n < 600:
  print(ans)
elif n < 800:
  ans -= 1
  print(ans)
elif n < 1000:
  ans -= 2
  print(ans)
elif n < 1200:
  ans -= 3
  print(ans)
elif n < 1400:
  ans -= 4
  print(ans)
elif n < 1600:
  ans -= 5
  print(ans)
elif n < 1800:
  ans -= 6
  print(ans)
elif n < 2000:
  ans -= 7
  print(ans)

Measured memory_bytes: 9196
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int n = scan.nextInt();
		int [] s = new int[13];
		int [] h = new int[13];
		int [] c = new int[13];
		int [] d = new int[13];

		for(int i = 0;i<n;i++){
			String t = scan.next();
			if(t.equals("S")){
				int j = scan.nextInt();
				s[j-1]++;
			}else if(t.equals("H")){
				int j = scan.nextInt();
				h[j-1]++;
			}else if(t.equals("C")){
				int j = scan.nextInt();
				c[j-1]++;
			}else if(t.equals("D")){
				int j = scan.nextInt();
				d[j-1]++;
			}
		}

		for(int i=0;i<13;i++){
			if(s[i] == 0){
				int t = i+1;
				System.out.println("S "+t);
			}
		}
		for(int i=0;i<13;i++){
			if(h[i] == 0){
				int t = i+1;
				System.out.println("H "+t);
			}
		}
		for(int i=0;i<13;i++){
			if(c[i] == 0){
				int t = i+1;
				System.out.println("C "+t);
			}
		}
		for(int i=0;i<13;i++){
			if(d[i] == 0){
				int t = i+1;
				System.out.println("D "+t);
			}
		}
	}
}

Measured memory_bytes: 26276
'use strict'

function main(s) {

  const table = s.split('\n').slice(0, -1).map(el => el.split(' ').map(x => Number(x)));

  let ans = 'Yes';

  for (let i = 0; i < 2; i++) {
    for (let j = 0; j < 2; j++) {
      const col_diff = ((table[i][j] - table[i][j + 1]) === (table[i + 1][j] - table[i + 1][j + 1]));
      const row_diff = ((table[i][j] - table[i + 1][j]) === (table[i][j + 1] - table[i + 1][j + 1]));
      if (!(col_diff && row_diff)) {
        ans = 'No';
        break;
      } 
    }
  }

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;
typedef long long LL;
LL n,m,i,j,k,a[330][330]={0},b[330][330]={0},f[330]={0},tot=0,cnt[330],nmax[330]={0},mmax=0,maxcnt=0,mmin=LONG_LONG_MAX;

int main()
{
    scanf("%lld%lld",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%lld",&a[i][j]);
        }
    }
    tot=m;
    while(tot>0){
        memset(cnt,0,sizeof(cnt));
        for(i=0;i<n;i++){
            j=0;
            while(f[a[i][j]])j++;
            cnt[a[i][j]]++;
        }
        maxcnt=0;mmax=0;
        for(i=1;i<=m;i++){
            if(mmax<cnt[i]){
                mmax=cnt[i];
                nmax[0]=i;
                maxcnt=1;
            }else if(mmax==cnt[i]){
                nmax[maxcnt++]=i;
            }
        }
        if(!mmax){
            printf("%lld",mmin);
            //system("pause");
            exit(0);
        }
        if(mmax<mmin)mmin=mmax;
        tot-=maxcnt;
        for(i=0;i<maxcnt;i++){
            f[nmax[i]]=1;
        }
    }
    printf("%lld",mmin);
    //system("pause");
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define ll long long
#define Size(v) (int)v.size()

using namespace std;
// using namespace __gnu_pbds;

int n, m;

void solve() {
	cin >> n >> m;
	vector<char> s(n + 1);

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

	vector<int> pos;

	for (int i = 0; i <= n; ++i) {
		if (s[i] == '0') pos.push_back(i);
	}

	int up = n;

	deque<int> ans;
	ans.push_front(n);

	while (up > 0) {
		auto it = lower_bound(pos.begin(), pos.end(), up - m);
		if (it == pos.end()) {
			cout << -1;
			return;
		}

		if (*it >= up) {
			cout << -1;
			return;
		}

		up = *it;
		ans.push_front(*it);
	}

	vector<int> res;
	int prev = 0;

	// for (auto &c : ans) cout << c << ' ';
	// cout << '\n';

	for (int i = 1; i < Size(ans); ++i) {
		res.push_back(ans[i] - ans[i - 1]);
	}

	for (auto &c : res) cout << c << ' ';
}

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

	int t = 1;
	while (t--) 
		solve();
	return 0;
}

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

int main(){
  int K;
  string S;
  cin>>K>>S;
  
  if((int)S.size()<=K){
    cout<<S<<endl;
  }
  else{
    for(int i=0;i<K;i++){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
  

}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int k=n/7;
    int ok=0;
    for(int i=0;i<=k;i++){
        if((n-7*(k-i))%4==0 && ok==0){
            cout << "Yes" << endl;
            ok=1;
        }
    }
    if(ok==0){
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main() {
	speed;

	int x[10];
	for (int i = 1; i <= 5; i++) cin >> x[i];
		int index = 0;
	for (int i = 1; i <= 5; i++) {
		if (x[i] == 0) index = i;
	}
	cout << index << "\n";
	return 0;
}

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

int main() {
    int a, b, c, k;
    cin>>a>>b>>c;
    cin>>k;
    int ps=a+b+c;
    int mm=max(a, max(b, c));
    ps-=mm;
    int p=1;
    for (int i=0; i<k; ++i) p*=2;
    mm*=p;
    cout<<(ps+mm)<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        var S = ReadLine();
        var ans = 0;
        for (int i = 0; i < N-1; i++)
        {
            var s = S.Substring(i);
            var n = s.Length;
            var Z = Zalgorithm(s);
            for (int j = 0; j < n; j++)
            {
                if (j < Z[j]) Z[j] = j;
            }
            ans = Max(ans, Z.Max());
        }
        WriteLine(ans);
    }

    static int[] Zalgorithm(string S)
    {
        int N = S.Length;
        int c = 0;
        var Z = new int[N];
        for (int i = 1; i < N; i++)
        {
            int l = i - c;
            if (i + Z[l] < c + Z[c])
            {
                Z[i] = Z[l];
            }
            else
            {
                int leng = Max(0, c + Z[c] - i);
                while (leng + i < N && S[i + leng] == S[leng])
                {
                    leng++;
                }
                Z[i] = leng;
                c++;
            }

        }
        Z[0] = N;
        return Z;
    }
}


Measured memory_bytes: 46736
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        String s[]=br.readLine().trim().split(" ");
        int a=Integer.parseInt(s[0]);
        int b=Integer.parseInt(s[1]);
        int c=Integer.parseInt(s[2]);

        System.out.println(c+" "+a+" "+b);
    }
}

Measured memory_bytes: 20564
#include<bits/stdc++.h>       
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
         int s,w;cin>>s>>w;
         if(w>=s)
         cout<<"unsafe";
         else
         cout<<"safe";
    
}


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

static const auto speedup = []() { 
	std::ios::sync_with_stdio(false); 
	std::cin.tie(NULL); 
	std::cout.tie(NULL);
	return 0; 
}();

#define ll long long int

void test_case(){
	int n, k;
	scanf("%d%d", &n, &k);
	int h[n], cost[n] = {0};
	for(int i=0;i<n;i++){
		scanf("%d", &h[i]);
	}
	for(int i=1;i<n;i++){
		int j = i-1, min_cost = INT_MAX;
		int l = max(i-k, 0);
		while(j>=l){
			min_cost = min(min_cost, cost[j] + abs(h[i] - h[j]));
			j--;
		}
		cost[i] = min_cost;
	}
	printf("%d\n", cost[n-1]);
}

int main(){
	int testcases = 1;
	// scanf("%d", &testcases);
	for(int testcase = 0;testcase < testcases;testcase++){
		test_case();
	}
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;

using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;

auto R(int s, int n) {
    return boost::irange(s, n);
}
auto R(int n) {
    return boost::irange(0, n);
}
void show(const auto& v){
    for(auto i:v) cout << i << " ";
    cout << endl;
}

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

    int one=0,two=0,four=0;

    for(ll i:R(n)){
        int j;
        cin >> j;
        if(j%2==0){
            if(j%4==0){
                four++;
            }else{
                two++;
            }
        }else{
            one++;
        }
    }

    if(one==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    int back=1;
    one--;
    for(ll i:R(1,n)){
        if(back==1){
            if(four==0){
                cout<<"No"<<endl;
                return 0;
            }else{
                four--;
                back=4;
            }
        }else if(back==2){
            if(two==0){
                if(four==0){
                    cout<<"No"<<endl;
                }else{
                    four--;
                    back=4;
                }
            }else{
                two--;
                back=2;
            }
        }else{
            if(one==0){
                if(two==0){
                    four--;
                    back=4;
                }else{
                    two--;
                    back=2;
                }
            }else{
                one--;
                back=1;
            }
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys

x = sys.stdin.readline()

x1 = x.rstrip()

y = []
for c in x1:
    y.append(c)

if x1[0]==x1[1] and x1[1]==x1[2]:
    print("Yes")
elif x1[1]==x1[2] and x1[2]==x1[3]:
    print("Yes")
else:
    print("No")

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


int main(){


    string s;

    cin>>s;


    int mx=0;
    for(int i=0 ; i<s.size() ; i++){

        if(s[i]=='R'){
            int ss=0;
            for(int j=i ; j<s.size() ; j++){
                if(s[j]=='S')
                break;

               ss++;
            }

            mx=max(mx,ss);
        }

    }

    cout<<mx<<endl;

















    return 0;







}


Measured memory_bytes: 3592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMaximalValue solver = new CMaximalValue();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMaximalValue {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int[] br = new int[n - 1];
            in.scanInt(br, n - 1);
            long ans = 0;
            ans += br[0];
            for (int i = 1; i < n - 1; i++) {
                ans += Math.min(br[i - 1], br[i]);
            }
            ans += br[n - 2];
            out.println(ans);


        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

        public void scanInt(int[] A, int size) {
            for (int i = 0; i < size; i++) A[i] = scanInt();
        }

    }
}



Measured memory_bytes: 23508
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int main(void){
char s[100005];
char d[10];
d[0]='a';
int flag=0;
scanf("%s",s);
for(int count2=0;count2<26;count2++){
    for(int count=0;s[count]!='\0';count++){
        if(s[count]==d[0]){flag++;}
        //alphabet check
    }
    //文章内にアルファベットは出現したか？
    if(flag==0){printf("%c",d[0]);return 0;}
    d[0]=d[0]+1;
    flag=0;
}
printf("None");
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_b

#include "algorithm"
#include "cmath"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;
  VL as(N);

  rep(i, N) cin >> as[i];

  ll sum = 0;
  for (auto a : as) sum += a;

  ll ov = -1;

  ll cur = 0;

  rep(i, N) {
    cur += as[i];
    if (sum % 2 == 0 && cur == sum / 2) drop(0);
    if (cur > sum / 2) {
      ov = i;
      break;
    }
  }

  ll leftEdge = cur - as[ov];
  ll rightEdge = sum - cur;
  ll res = min(sum - 2 * leftEdge, sum - 2 * rightEdge);

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
using namespace std;

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

const ll INFTY=1e18;

int main() {
    ll i, n, e, t, l, r, m;
    scanf("%lld%lld%lld", &n, &e, &t);
    vll x(n+2);
    for(i=1; i<=n; i++) scanf("%lld", &x[i]);
    x[n+1]=e;
    vll opt(n+2), dp(n+2);
    dp[n+1]=INFTY;
    for(i=n; i>=1; i--) {
        l=i+1; r=n+1;
        while(l<r) {
            m=(l+r)/2;
            if(2*(x[m]-x[i])<=t) l=m+1;
            else r=m;
        }
        opt[i]=min(t+x[l]-x[i]+opt[l], -3*x[i]+dp[l]);
        dp[i]=min(2*x[i]+x[i+1]+opt[i+1], dp[i+1]);
    }
    printf("%lld\n", x[1]+opt[1]);
    return 0;
}

Measured memory_bytes: 2560
<?php
ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d", $N);

$bool = true;

for ($i = 0; $i < $N; $i++) {
	fscanf(STDIN, "%s", $W);
	if (isset($dict[$W])) {
		$bool = false;
		break;
	} else {
		$dict[$W] = 1;
	}
	if (!isset($prev)) {
	} else {
		$first = substr($W, 0, 1);
		if ($first != $prev) {
			$bool = false;
			break;
		}
	}
	$prev = substr($W, -1);
}

echo $bool ? "Yes" : "No";


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

using namespace std;

#define ll long long

bool cmp(pair<int, int>& a, pair<int, int>& b){
	return a.second < b.second;
}

void solve() {
	int a, b;
	cin >> a >> b;
	map<int, int> m;
	set<int> s;
	for (int i = 0; i < a; i++) {
		int c;
		cin >> c;
		m[c]++;
		s.insert(c);
	}
	if (s.size() <= b) {
		cout << 0 << "\n";
	} else {
		int cnt = 0;
		int left = s.size() - b;
		vector<pair<int, int>> v;
		for (auto& it : m) {
			v.push_back(it);
		}
		sort(v.begin(), v.end(), cmp);
		for (int i = 0; i < left; i++) {
			cnt += v[i].second;
		}
		cout << cnt << "\n";
	}

}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



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

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	int digits=1,ans=0;
	for(int i=1;i<=n;i++){
		if(digits%2){
			ans++;
		}
		for(int j=1;j<=5;j++){
			if(i+1==pow(10,j)){
				digits++;
				break;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2020/07/28
 *      Author: 113896
 */
#include <stdio.h>

#define BSIZE 2000

int main() {

	char buffer[BSIZE];


	int count[26];
	for (int i = 0; i < 26; i++) {
		count[i] = 0;
	}


	while (fgets(buffer, BSIZE, stdin) != NULL) {
		char c;
		int i = 0;
		int index;
		while (buffer[i] != '\0') {
			c = buffer[i];
			if (c >= 'a' && c <= 'z') {
				index = c - 'a';
			} else if (c >= 'A' && c <= 'Z') {
				index = c - 'A';
			} else {
				i++;
				continue;
			}
			count[index]++;
			i++;
		}
	}

	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n", 'a'+i, count[i]);
	}

	return 0;
}




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

using namespace std;

int n, k, sol;
int A[100005];
map<int, int> M;

int main()
{
    #ifdef acm
    freopen("a.in", "r", stdin);
    #endif // acm

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

    cin >> n;

    for( int i = 1; i <= n; i ++ ){
        cin >> A[i];
        if( i % 2 ){
            if( M.find( A[i] ) == M.end() )
                M[A[i]] = 0;
            M[A[i]] = M[A[i]]+1;
        }
    }
    sort( A+1, A+1+n );

    for( int i = 1; i <= n; i ++ ){
        if( i % 2 ){
            if( M.find( A[i] ) == M.end() )
                sol ++;
            else
                if( M[A[i]] == 0 ) sol ++;
            else
                M[A[i]] = M[A[i]]-1;
        }
    }

    cout << sol;

    return 0;
}


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

int main(){
    string str;
    string ss="";
    while(cin >> str){
        for(int i=0;i<=str.length()-1;i++){
            if(str[i]=='B'){
                if(ss.length()==0){
                    continue;
                }else{
                    ss.pop_back();
                }
            }else if(str[i]=='1'){
                ss+='1';
            }else if(str[i]=='0'){
                ss+='0';
            }
        }cout << ss << endl;
    }
}

Measured memory_bytes: 3100
//
//  main.cpp
//  ABC125
//
//  Created by hiroaki on 2019/04/27.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
    s << v[i];
  }
  s << "]";
  return s;
}

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

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

  int q_count;
  cin >> q_count;
  vector<int> qs(q_count);
  for (int i = 0; i < q_count; i++) {
    cin >> qs[i];
    qs[i]--;
  }

  vector<int64> xs(n + 1);
  xs[0] = x0;
  for (int i = 0; i < n; i++) {
    xs[i + 1] = abs(xs[i] - ds[i]);
    if (xs[i + 1] > xs[i]) xs[i + 1] = xs[i];
  }

  int gi = -1;
  for (int i = 0; i <= n; i++) {
    if (xs[i] == 0) {
      gi = i;
      break;
    }
  }

  vector<int64> cs(n + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (ds[i] <= 2 * cs[i + 1] + 1) {
      cs[i] = cs[i + 1] + ds[i];
    } else {
      cs[i] = cs[i + 1];
    }
  }

  if (DEBUG) cout << "xs: " << xs << endl;
  if (DEBUG) cout << "gi: " << gi << endl;
  if (DEBUG) cout << "cs: " << cs << endl;

  auto process_q_fn = [&](int q) -> bool {
    if (gi >= 0 && q >= gi) return false;
    if (xs[q] <= cs[q + 1]) return false;
    return true;
  };

  for (int q : qs) {
    if (DEBUG) cout << "q: " << q << endl;
    if (process_q_fn(q)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}


Measured memory_bytes: 17536
from collections import defaultdict
from operator import itemgetter
import sys
input = sys.stdin.readline

n = int(input())
v = list(map(int, input().split()))

a = defaultdict(int)
b = defaultdict(int)
a[0] = 0
b[0] = 0

for i in range(n):
    if i % 2 == 0:
        a[v[i]] += 1
    else:
        b[v[i]] += 1

a_sorted = sorted(a.items(), key=itemgetter(1), reverse=True)
b_sorted = sorted(b.items(), key=itemgetter(1), reverse=True)
if a_sorted[0][0] == b_sorted[0][0]:
    c1 = n/2 - a_sorted[0][1]
    c1 += n/2 - b_sorted[1][1]
    c2 = n/2 - b_sorted[0][1]
    c2 += n/2 - a_sorted[1][1]
    c = min(c1, c2)
else:
    c = n/2 - a_sorted[0][1]
    c += n/2 - b_sorted[0][1]
print(int(c))

Measured memory_bytes: 22252
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 200000;

int main(void){
    ll N, K;
    ll A[MAX_N];
    map<ll, ll> cnt;
    vector<ll> n_ints;
    ll answer = 0;

    cin >> N >> K;
    rep(i, N){
        cin >> A[i];
        cnt[A[i]] = 0;
    }

    rep(i, N) cnt[A[i]] ++;
    ll n_types = 0;
    for(auto& kv: cnt){
        n_ints.push_back(kv.second);
        n_types ++;
    }

    sort(all(n_ints));


    rep(i, n_types - K) answer += n_ints[i];

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 16500
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s,c;
    ll i,k=0;
    cin>>s>>c;
    for(i=0;s[i]!='\0';i++)
    {
        if(s[i]==c[i])
            k++;
    }
    cout<<k<<endl;
}


Measured memory_bytes: 256
// She is Pretty pretty!
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

const int N = 310;
int a[4], x, n;
double dp[N][N][N];
double dfs(int i , int j , int k){
    if(dp[i][j][k])return dp[i][j][k];
    if(i + j + k == 0) return 0;
    double ans = 1;
    if(i) ans += dfs(i - 1, j , k) * i / n;
    if(j) ans += dfs(i + 1, j - 1, k) * j / n;
    if(k) ans += dfs(i , j+1 , k-1) * k / n;
    if(i+j+k!=n)ans*=1.0*n/(j+k+i);
    return dp[i][j][k] = ans;
}
int main()
{
    cin >> n;
    for(int i = 0; i < n ; i++){
        cin >> x;
        a[x]++;
    }
    printf("%.10f", dfs(a[1],a[2],a[3]));
    return 0;
}

Measured memory_bytes: 225536