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

const int prime[25]={
  2, 3, 5, 7, 11,
  13, 17, 19, 23, 29,
  31, 37, 41, 43, 47,
  53, 59, 61, 67, 71,
  73, 79, 83, 89, 97
};


int main(){
  int N;
  cin >> N;
  vector<int> cnt(25,0);

  for(int n=2;n<=N;++n){
    int m=n;

    for(int i=0;i<25;++i){
      while(m%prime[i]==0){
        cnt[i]++;
        m/=prime[i];
      }
    }
  }

  int ans=0;
  for(int p=0;p<25;++p){
    if(cnt[p]>=74)ans++;
  }

  for(int p=0;p<25;++p){
    for(int q=0;q<25;++q){
      if(p==q) continue;
      if(cnt[p]>=4 && cnt[q]>=14) ans++;
      if(cnt[p]>=2 && cnt[q]>=24) ans++;
    }
  }

  for(int p=0;p<25;++p){
    for(int q=0;q<25;++q){
      for(int r=q+1;r<25;++r){
        if(p==q || p==r) continue;
        if(cnt[p]>=2 && cnt[q]>=4 && cnt[r]>=4) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	
	string s, t;
	cin >> s >> t;
	cout << (s < t ? '<' : s > t ? '>' : '=')  << endl;
	
	
	
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(a == b && a != c ? "Yes" : a == c && a != b ? "Yes" : b == c && a != b ? "Yes" : "No");
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
static const int MAX = 202;
static const int INFTY = (1 << 30);
class edge {
public:
    int target, cap, rev;
    edge (int target = 0, int cap = 0, int rev = 0) : target(target), cap(cap), rev(rev) {}
};
std::vector<edge> G[MAX];
int level[MAX]; //dist from source
int iter[MAX]; //ended search num
bool can[MAX/2][MAX/2];

void bfs(int s) {
    std::memset(level, -1, sizeof(level));
    std::queue<int> q;
    q.push(s);
    level[s] = 0;
    while(!q.empty()) {
        int current = q.front(); q.pop();
        for (int i  = 0; i < G[current].size(); i++) {
            edge &e = G[current][i];
            if (e.cap > 0 && level[e.target] < 0) {
                level[e.target] = level[current] + 1;
                q.push(e.target);
            }
        }
    }
}

int dfs(int current, int sink, int f) {
    if (current == sink) return f;
    for (int &i = iter[current]; iter[current] < G[current].size(); i++) {
        edge &e = G[current][i];
        if (e.cap > 0 && level[current] < level[e.target]) {
            int d = dfs(e.target, sink, std::min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.target][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    for (; ;) {
        bfs(s);
        if (level[t] < 0) return flow;
        std::memset(iter, 0, sizeof(iter));
        int f;
        while ((f = dfs(s, t, INFTY)) > 0) {
            flow += f;
        }
    }
}

void add_edge(int source, int target, int cap) {
    G[source].push_back(edge(target, cap, G[target].size()));
    G[target].push_back(edge(source, 0, G[source].size()-1));
}

int main()
{
    int X, Y, E, xi, yi;
    std::scanf("%d %d %d", &X, &Y, &E);
    if (E==0) std::cout << 0 << std::endl;
    else {
        int s = X+Y, t = s+1;
        for (int i = 0; i <= X; i++) {
            for (int j = 0; j <= Y; j++) {
                can[i][j] = false; //2d table which represents the connection between X and Y side
            }
        }

        //xi, X+yi
        for (int i = 0; i < E; i++) {
            std::scanf("%d %d", &xi, &yi);
            can[xi][yi] = true;
        }

        for (int i = 0; i < X; i++) add_edge(s, i, 1);
        for (int i = 0; i < Y; i++) add_edge(X+i, t, 1);

        for (int i = 0; i < X; i++) {
            for (int j = 0; j < Y; j++) {
                if (can[i][j]) add_edge(i, X+j, 1);
            }
        }
        std::cout << max_flow(s, t) << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3440
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        while(H!=0 && W!=0) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (((i + j) % 2) == 0) System.out.printf("#");
                    else System.out.printf(".");
                }
                System.out.println();
            }
            System.out.println();
            H = sc.nextInt();
            W = sc.nextInt();
        }
    }
}


Measured memory_bytes: 61072
import java.util.*;
public class Main {
	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	
	int s = 0;
	if(a<b) {
		for(;a<b;a++){
			if(c % a == 0) s++;
		}
			
		
			}
	else if(a>b);{
		for(; b<a;b++){
			if(c% b == 0)s++;}
	}
	if(a==b)if(c % a == 0) s++;	
	System.out.println(s);
	}
}

Measured memory_bytes: 17348
n = int(input())
a = list(map(int,input().split()))
b ={}

for _ in a:
  if b.get(_, "NotFound") == "NotFound" :
    b[_] = 1
  else:
    b[_] += 1

for i in range(1,n+1):
  if b.get(i, "NotFound") == "NotFound" :
    print(0)
  else:
    print(b[i])




Measured memory_bytes: 33532
#include <bits/stdc++.h>
using namespace std;
 
int main() {
double r;
cin >> r;
cout << fixed << setprecision(10) << r*r*3.141592653589 <<endl;
cout << fixed << setprecision(10) << 2*r*3.141592653589 <<endl;
return 0;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;

int n, a[maxn], f[maxn], t[maxn];

int main()
{
    //freopen("a.inp","r",stdin);
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];

    for(int i=1;i<=n;i++) f[i] = __gcd(f[i-1], a[i]);
    for(int i=n;i>=1;i--) t[i] = __gcd(t[i+1], a[i]);

    int dapan = 0;
    for(int i=1;i<=n;i++) dapan = max(dapan, __gcd(f[i-1], t[i+1]));
    cout << dapan;
}


Measured memory_bytes: 1408
import java.util.*;
import java.util.stream.*;

class Main {
    static Scanner s=new Scanner(System.in);
    public static void main(String[]$){
        int n=s.nextInt(),t=s.nextInt();
        
        int r=1000000000;
        for(int i=0;i<n;++i){
            int a=s.nextInt(),b=s.nextInt();
            if(b<=t)
                r=Math.min(r,a);
        }
        System.out.println(r<1000000000?r:"TLE");
    }
}

Measured memory_bytes: 22100
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)


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

GRAPH = {i:[] for i in range(1, n + 1)}
for _ in range(n - 1):
    a, b = map(int, input().split())
    GRAPH[a].append(b)
    GRAPH[b].append(a)

def dfs(now, prev = 0):
    PARENT[now] = prev
    DEPTH[now] = DEPTH[prev] + 1
    if len(GRAPH[now]) == 1:
        LEAVES.append((DEPTH[now], now))
    
    for w in GRAPH[now]:
        if w == prev:
            continue
        next = w
        dfs(next, now)

PARENT = {}
DEPTH = {0:-1}
LEAVES = []
dfs(v)

PATH = {i:False for i in range(1, n + 1)}
now = u
while True:
    PATH[now] = True
    if now == v:
        break
    now = PARENT[now]

LEAVES.sort(reverse = True)
for leaf in LEAVES:
    now = leaf[1]
    while True:
        if PATH[now]:
            break
        now = PARENT[now]
    lca = now
    
    du, dv = DEPTH[u] - DEPTH[lca], DEPTH[lca]
    if du < dv:
        print(leaf[0] - 1)
        exit()


Measured memory_bytes: 145856
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int x[n],y[n],a[n];
  rep(i, n) cin >> x[i] >> y[i] >> a[i];

  int l=0, r=w, t=h, b=0;
  rep(i, n) {
    switch (a[i]) {
    case 1:
      l = max(l, x[i]);
      break;
    case 2:
      r = min(r, x[i]);
      break;
    case 3:
      b = max(b, y[i]);
      break;
    case 4:
      t = min(t, y[i]);
      break;
    }
  }

  if (r-l < 0 || t-b < 0) cout << 0 << endl;
  else cout << (r-l)*(t-b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,k,x,y,nc,sn,snc,tc; //nc=nights_cost,sn=subsequent nights,snc=subsequent nights cost,tc=totalcost//
    scanf("%d%d%d%d",&n,&k,&x,&y);
    if(n<k)
    {
        nc=n*x;
        printf("%d\n",nc);
    }
    else
    {
    nc=k*x;
    sn=n-k;
    snc=sn*y;
    tc=nc+snc;
    printf("%d\n",tc);
    }
    return 0;
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  bool y = false;
  rep(i, N) {
    char c;
    cin >> c;
    if (c == 'Y') y = true;
  }

  if (y) cout << "Four" << endl;
  else cout << "Three" << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

const int mod = 1000000007;
const int logR = 30;
const int R = 1<<logR;
const int Rmask = R-1;
const int R2 = (int)((ll)R*R%mod);
int modash;
int MR(ll x){
    int m = (x*modash)&Rmask;
    int t = (x+(ll)m*mod)>>logR;
    if(t>=mod)t-=mod;
    return t;
}
int get_mod(ll x){return (int)MR((ll)MR(x)*R2);}
void init(){
    // R=1ll;logR=0;modash=0;
    // while(R<mod){R<<=1;logR++;}
    // R2=R*R%mod;
    int t=0,r=R,i=1;
    while(r>1){
        if((t&1)==0){t+=mod;modash+=i;}
        t>>=1;r>>=1;i<<=1;
    }
}

vector<vl> mul(vector<vl> a, vector<vl> b){
  int n = a.size();
  vector<vl> ret(n,vl(n,0));
  REP(k,n)REP(i,n)REP(j,n){
    ret[i][j] += get_mod(a[i][k]*b[k][j]);
    if(ret[i][j]>=mod) ret[i][j] -= mod;
  }
  return ret;
}

int main(){
  int n,k,c,t;
  scanf("%d%d%d%d",&n,&k,&c,&t);
  // ????§???????
  // 0?§???????1?§????...4?§????????£??????§??\?????????????????°t?????§?????¨?????????
  vector<vl> mat(5*n,vl(5*n,0));
  // ??????????§?
  REP(i,4){
    REP(j,n) mat[i*n+j][(i+1)*n+j] += 1;
  }
  // ?????????????§?
  REP(_,k){
    int a,b,tm;
    scanf("%d%d%d",&a,&b,&tm);
    // --a; --b;
    --tm;
    REP(i,n){
      int from;
      if(i<b) from = i+a-1;
      else if(i<b+a-1) from = i-b;
      else from = i;
      int to = i;
      mat[tm*n+to][from] += 1;
    }
  }
  // REP(po,5*n){
  //   DEBUG_VEC(mat[po]);
  // }
  // cout<<endl;
  init();
  // ?´????
  vector<vl> ans(5*n,vl(5*n,0));
  REP(i,5*n) ans[i][i]=1;
  while(t){
    if(t&1) ans = mul(ans,mat);
    mat = mul(mat,mat);
    t>>=1;
  }
  // DEBUG
  // REP(po,5*n){
  //   DEBUG_VEC(ans[po]);
  // }
  cout<<ans[0][c-1]<<endl;
  return 0;
}

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

using namespace std;

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

  int N,K;
  cin>>N>>K;
  vector<int> P(N);
  for (auto& p : P) cin>>p;

  vector<int> par(N-K+1);
  iota(par.begin(), par.end(), 0);
  auto root = [f=[&](auto g, int x) {
    if (par[x] == x) {
      return x;
    }
    return par[x] = g(g, par[x]);
  }](int x) {
    return f(f, x);
  };
  auto unite = [&](int x, int y) {
    par[root(y)] = root(x);
  };

  {
    int f = 0;
    int l = 1;
    int rooti = -1;
    for (int i = 1; i < N; i++) {
      if (P[i] > P[i - 1]) {
        if (++l == K) {
          if (rooti == -1) {
            rooti = f;
          } else {
            unite(rooti, f);
          }
        }
      } else {
        f = i;
        l = 1;
      }
    }
  }

  {
    deque<int> incs;
    auto add_incs = [&](int i) {
      while (not incs.empty() and P[incs.back()] > P[i]) 
        incs.pop_back();
      incs.push_back(i);
    };
    deque<int> decs;
    auto add_decs = [&](int i) {
      while (not decs.empty() and P[decs.back()] < P[i])
        decs.pop_back();
      decs.push_back(i);
    };
    for (int i = 0; i < K; i++) {
      add_incs(i);
      add_decs(i);
    }
    for (int i = 0; i < N - K; i++) {
      add_incs(i+K);
      add_decs(i+K);
      if ((decs.front() == i+K) and
          (incs.front() == i)) {
        unite(i, i + 1);
      }
      if (incs.front() == i) {
        incs.pop_front();
      }
      if (decs.front() == i) {
        decs.pop_front();
      }
    }
  }

  unordered_set<int> graph;
  for (int i = 0; i < par.size(); i++) {
    graph.insert(root(i));
  }
  cout << graph.size() << endl;

  return 0;
}


Measured memory_bytes: 10056
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    String s = a+b;
    double n = Integer.parseInt(s);
    double m = Math.sqrt(n);
    if(n % m*m == 0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<algorithm>


using namespace std;

int main()
{
	int A,B,C,D;
	cin >> A >> B >> C >> D ; 

	if (A*B >= C * D) {
		cout << A*B << endl;
	}
	else {
		cout << C * D << endl;
	}

    
	return 0;
}

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

using namespace std;

#define make_unique(a) (a.erase(unique(a.begin(),a.end()),a.end()))
#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define readln(x) (getline(cin, x))
#define watch(x) cout << (#x) << " is " << (x) << endl;

typedef pair<int, int> pii;
typedef long long ll;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

const int MAXW = 1e5 + 5;
// const int MAXN = 105;

ll dp[MAXW];

void solve() {
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    for(int i=0; i<n; i++) cin >> w[i] >> v[i];
    for(int i=0; i<n; i++) {
        for(int j=W; j>=0; j--) {
            if(j>=w[i]) dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
        }
    }
//    for(int i=0; i<=W; i++) {
//        printf("index: %d, value: %lld\n", i, dp[i]);
//    }
    cout << dp[W] << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    int a[n+1];
    int m = 0, p = -1;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        if(abs(a[i]) >= abs(m)) {
            m = a[i];
            p = i;
        }
    }
    cout << 2*n-1 << endl;
    if(m >= 0){
        for(int i = 1; i <= n; i++) cout << p << " " << i << endl;
        for(int i = 1; i < n; i++) cout << i << " " << i+1 << endl;
    } else {
        for(int i = 1; i <= n; i++) cout << p << " " << i << endl;
        for(int i = n; i >= 2; i--) cout << i << " " << i-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]

R = {}
for a, b in ab:
  a -= 1
  b -= 1
  if a not in R:
    R[a] = [b]
  else:
    R[a].append(b)
  if b not in R:
    R[b] = [a]
  else:
    R[b].append(a)

D = [0] * N
S = [[0, 0]] 
D[0] = 1
C = {}
m = 0
while S != []:
  t, c = S.pop()
  n = 1
  if c == n:
    n += 1
  m = max(m, len(R[t]))
  for i in R[t]:
    if D[i] == 0:
      D[i] = D[t] + 1
      S.append([i, n])
      if t not in C:
        C[t] = {}
        C[t][i] = n
      else:
        C[t][i] = n
      if i not in C:
        C[i] = {}
        C[i][t] = n
      else:
        C[i][t] = n
      n += 1
      if c == n:
        n += 1

print(m)
for a, b in ab:
  a -= 1
  b -= 1
  print(C[a][b])

Measured memory_bytes: 84628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int gcd(int a, int b){
  if(a<b) return gcd(b,a);
  while(b != 0){
    int r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> city(n+1);
  city[0] = x;
  rep(i,n) cin >> city[i+1];
  sort(all(city));
  vector<int> diff(n);
  rep(i,n) diff[i] = city[i+1] - city[i];
  //for(d:diff) cout << d << endl;
  int ans = diff[0];
  rep(i,n-1) ans = gcd(ans,diff[i+1]);
  cout << ans << endl;
}



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

using namespace std;

typedef pair<string, int> P;

//????????????????????????????????????
bool judge(string str) {
	for (int i = 0; i < str.size(); ++i) {
		if (str[0] != str[i]) return false;
	}
	return true;
}

//??£?????????2?????????????????§?????????????????????
char color(char a, char b){
	if((a == 'g' && b == 'r') || (a == 'r' && b == 'g'))return 'b';
	else if((a == 'b' && b == 'r') || (a == 'r' && b == 'b')) return 'g';
	else if((a == 'g' && b == 'b') || (a == 'b' && b == 'g')) return 'r';
}

int solve(string s ){

	queue<P> q;
	map<string, int> m;
	q.push(P(s, 0));	//?????\??????????????¶????????\??????

	while (!q.empty()) {	//?????\??????????????¶?????????????????§
		P p = q.front();
		q.pop();
		if(m[p.first]) continue;	//??????????????????
		string now = p.first;
		if (judge(now)) return p.second;
		m[p.first] = p.second;
		for (int i = 0; i < now.size() - 1; ++i) {
			if (now[i] != now[i+1]){	//??£?????????2????????°????????¨???
				char tmp = color(now[i], now[i + 1]);
				string D = now;
				D[i] = tmp;
				D[i + 1] = tmp;
				q.push(P(D, p.second + 1));
			}
		}
	}
	return -1;
}

int main() {
	string worm;
	while (cin >> worm) {
		if (worm == "0") break;
		int count = solve(worm);
		if (count == -1) cout << "NA" << endl;
		else cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 4968
#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>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)



int main() {
	int N, K;
	cin >> N >> K;
	vector<int>H(N);
	rep(i, N) {
		cin >> H[i];
	}
	vector<int>dp(N,1000000000);
	dp[0] = 0;
	for (int i = 1; i < N; i++) {
		for (int j = 1; j <= K; j++) {
			if (i - j >= 0) {
				dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j]));
			}
		}
	}
	cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <numeric>

using namespace std;

using ll = long long;
using vi = vector<int>; using vi2 = vector<vi>;
#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define loopll(i, n) for (ll i = 0; i < (ll)n; i++)

int main() {
    int n; cin >> n;
    vi a(n, 0);
    loop(i, n - 1) {
        int b; cin >> b;
        a[b - 1]++;
    }
    loop(i, n) cout << a[i] << endl;
}

Measured memory_bytes: 3968
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=700 +117;
const int MM=250000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("99e.in","r",stdin);
	//freopen("99e.cpp.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
int sq[NN][NN]={};
vector<int> p[NN];
vector<int> v;
int has[2][NN]={};
int col[NN]={};
int dfs(int x,int c){
	int res=c;
	col[x]=c;
	for(int i=0;i<p[x].size();++i){
		int cur=p[x][i];
		if(col[cur]==c){
			return -2*n;
		}
		if(!col[cur]){
			int tp=dfs(cur,-c);
			if(tp<-n)return -2*n;
			res+=tp;
		}
	}
	return res;
}
int main(){
	//open();
	n=read();
	m=read();
	for(int i=1;i<=m;++i){
		int x=read(),y=read();
		sq[x][y]=1;
		sq[y][x]=1;
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(!sq[i][j]&&i!=j){
				p[i].push_back(j);
			}
		}
	}
	for(int i=1;i<=n;++i){
		if(!col[i]){
			int tp=dfs(i,1);
			if(tp<-n){
				printf("-1\n");
				return 0;
			}
			v.push_back(abs(tp));
		}
	}
	has[0][0]=1;
	int now=0;
	for(int pos=0;pos<v.size();++pos){
		now^=1;
		for(int i=n;i>=0;--i){
			if(has[now^1][i]){
				has[now][abs(i-v[pos])]=1;
				has[now][i+v[pos]]=1;
				has[now^1][i]=0;
			}
		}
	}
	int ans=n;
	for(int i=0;i<=n;++i){
		if(has[now][i])ans=min(ans,i);
	}
	int aa=(ans+n)/2;
	printf("%d\n",aa*(aa-1)/2+(n-aa)*(n-aa-1)/2);
	close();
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
struct graph{
    vi v;
};

void bfs(graph G[],int start,vl & d){
    queue<int> q;
    q.push(start);
    d[start] = 0;
   
    while(!q.empty()){
        int from = q.front();
        q.pop();
        for(int i=0;i<G[from].v.size();i++){
            int to = G[from].v[i];
          //  cout << from << "  " << to << "\n";
            if(d[to] == inf){
                d[to] = d[from]+1;
                q.push(to);
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    cin>>str;
    if(str[0] == str[1] || str[1] == str[2] || str[2] == str[3])
    cout << "Bad";
    else 
    cout << "Good";
    return 0;
}
    


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N;
ll A[100010],B[100010];
ll s[200010];
vector<ll> C;

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

  cin>>N;
  rep(i,N)cin>>A[i]>>B[i];

  ll res=INF;
  {
    ll sum=0;
    rep(i,N)sum+=A[i];
    minch(res,sum);
  }
  {
    ll sum=0;
    rep(i,N)sum+=B[i];
    minch(res,sum);
  }

  rep(i,N){
    C.push_back(A[i]);
    C.push_back(B[i]);
  }
  sort(all(C));
  rep(i,N*2)s[i+1]=s[i]+C[i];

  if(N>2){
    rep(i,N){
      if(min(A[i],B[i])<=C[N-3]){
        if(max(A[i],B[i])<=C[N-2]){
          minch(res,s[N]);
        }else{
          minch(res,s[N-1]+max(A[i],B[i]));
        }
      }else{
        minch(res,s[N-2]+A[i]+B[i]);
      }
    }
  }else{
    rep(i,N)minch(res,A[i]+B[i]);
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair< int, int > Pi;
 
const int INF = 1 << 30;
// 区間への加算, 最大値が求まればいいかんじに出来る
 
int64 seg[1 << 18], added[1 << 18];
 
inline void add( int a, int b, int64 value, int k = 0, int l = 0, int r = 1 << 17){ // [a,b)にvalueを足すやつ
  if(r <= a || b <= l) return;
  if(a <= l && r <= b) { // 完全に含んでたら足す
    added[k] += value;
  } else {
    int mid = (l + r) >> 1;
    add( a, b, value, 2 * k + 1, l, mid);
    add( a, b, value, 2 * k + 2, mid, r);
    seg[k] = max( seg[2 * k + 1] + added[2 * k + 1], seg[2 * k + 2] + added[2 * k + 2]);
  }
  return;
}
 
inline int64 query( int a, int b, int k = 0, int l = 0, int r = 1 << 17){ // [a,b)の最大値を返すやつ
  if(r <= a || b <= l) return -INF;
  if(a <= l && r <= b) return seg[k] + added[k];
  int mid = (l + r) >> 1;
  return max( query( a, b, 2 * k + 1, l, mid), query( a, b, 2 * k + 2, mid, r)) + added[k];
}
 
 
 int main()
 {
   int N, H;
   int64 life = 0; // 今の体力
   int64 ret = 0;
 
   scanf("%d %d", &N, &H);
   life = H;
   priority_queue< Pi > que; // first: 一回あたりの回復体力量, second: どこ
   for(int i = 0; i < N - 1; i++){
     add( i, i + 1, life); // 今の体力を更新
     int d, h;
     scanf("%d %d", &d, &h);
     que.push( Pi( h, i));
 
     life -= d; // 降りる
     while(life <= 0){
       Pi p = que.top(); que.pop();
       int64 lange = query( p.second, i + 1); // 回復量の最大値
       if(p.first + lange > H)  {
         que.push( Pi( H - lange, p.second));
       } else {
         int64 cnt = min((H - lange) / p.first, -life / p.first + 1LL); // 回復量の最大値 OR lifeまでの回復量
         ret += cnt;
         life += cnt * p.first;
         add( p.second, i + 1, cnt * p.first);
         que.push(p);
       }
     }
   }
   printf("%lld\n", ret);
}

Measured memory_bytes: 5348
import fractions

N,X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()

if N != 1:
    A = [0]*N
    for i in range(N):
        A[i] = x[i+1]-x[i]
    a = A[0]
    for j in range(N):
        a = fractions.gcd(a,A[j])
    print(a)
else:
    print(x[1]-x[0])

Measured memory_bytes: 16240
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] S = Console.ReadLine().Split(' ');
        int R = int.Parse(S[0]);
        int G = int.Parse(S[1]);
        int B = int.Parse(S[2]);
        int K = int.Parse(S[3]);
        int Ans = 0;
        int W;

        for (int i = 0; i <= K; i++)
        {

            W = K;

            for (int j = i; j <= K; j++)
            {
                //Console.WriteLine("{0},{1}", i, j);

                if (i % R == 0 && (j - i) % G == 0 && (W - j) % B == 0)
                {
                    Ans++;
                    //Console.WriteLine("OK");
                }
                else
                {
                    //Console.WriteLine("NO");
                }

            }

        }

        Console.WriteLine(Ans);

    }
}


Measured memory_bytes: 13140
//package beginner164.c;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Set<String> s = new HashSet<>();
            for (int i = 0; i < n; ++i) {
                s.add(in.next());
            }

            out.println(s.size());
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 66428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string a,b,c;
  cin >> a >> b >> c;
  cout << "A" << b.at(0) << "C" << endl;
}


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

int main(){
	int n;
  char s[200];
  
  cin >> n;
  
  for(int i=0; i<n; ++i){
  	cin >> s[i];
  }
  if(n%2 == 1){
  	cout << "No";
    return 0;
  }
  
  int k=n/2;
  int ans=0;
  for(int i=0; i<k; i++){
  	if(s[i] == s[k+i]) ans++;
  }
  if(ans != k) {
  cout << "No";
    return 0;
  }
  
  cout << "Yes";
}

Measured memory_bytes: 256
from collections import Counter

def solve(n, s):
    c = Counter(s)
    ret, tmp = 0, 0
    d = set()
    for l in s:
        c[l] -= 1
        if c[l] == 0:
            tmp -= 1

        if l not in d:
            tmp += 1
        d.add(l)

        if ret < tmp:
            ret = tmp
    return ret

_n = int(input())
_s = input()
print(solve(_n, _s))

Measured memory_bytes: 3316
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

ll Q, H, S, D;
ll n;
pair<ll, ll> a[4];

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> Q >> H >> S >> D;
	cin >> n;
	n *= 100ll;
	
	a[0].FI = Q * 8;
	a[0].SE = 25;
	a[1].FI = H * 4;
	a[1].SE = 50;
	a[2].FI = S * 2;
	a[2].SE = 100;
	a[3].FI = D;
	a[3].SE = 200;
	
	sort(a, a + 4);
	int pos = 0;
	ll ans = 0;
	while (pos < 4 && n) {
		int cur = a[pos].SE;
		ll v = (a[pos].FI / (200ll / cur));
//		cout << cur << " " << n / cur << " " << v << endl;
		ans += (n / cur) * v;
		n %= cur;
		pos++;
	}

	cout << ans;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100000
struct edge{int nx,t;}e[MN*2+5];
int h[MN+5],en,f[MN+5],v[1<<17];
inline void ins(int x,int y)
{
	e[++en]=(edge){h[x],y};h[x]=en;
	e[++en]=(edge){h[y],x};h[y]=en;
}
int cal(int x){for(int i=17;i;--i)if(x&(1<<i))return i;return -1;}
void dfs(int x,int fa)
{
	int mx=0;
	for(int i=h[x];i;i=e[i].nx)if(e[i].t!=fa)
	{
		dfs(e[i].t,x);
		mx=max(mx,v[f[x]&f[e[i].t]]+1);
		f[x]|=f[e[i].t];
	}
	for(int i=0;;++i)if(i>=mx&&!(f[x]&(1<<i)))
		{f[x]=(f[x]|(1<<i))&((-1)<<i);return;}
}
int main()
{
	int n=read(),i,j;
	for(i=0,j=-1;i<1<<17;v[i++]=j)if(i==(1<<j+1))++j;
	for(i=1;i<n;++i)ins(read(),read());
	dfs(1,0);
	printf("%d",v[f[1]]);
}

Measured memory_bytes: 6400
from math import gcd

class SegmentTree:
    """Segment Tree

    Attributes:
        n (int):       要素数以上の最小の2の累乗
        ide_ele (int): 単位元
            - RmQ (Range Minimum Query): inf
            - RMQ (Range Maximum Query): -1
            - RSQ (Range Sum Query):     0
            - RPQ (Range Product Query): 1
            - RGQ (Range GCD Query):     0
        seg (list):    要素の格納先
    """
    def __init__(self, a):
        """初期化 O(N)
        
        Args:
            a (list): 対象の配列
        """
        self.n = 2 ** (len(a) - 1).bit_length()
        self.ide_ele = 0
        self.seg = [self.ide_ele] * (2*self.n)

        for i, v in enumerate(a, self.n):
            self.seg[i] = v
        for i in range(self.n-1, 0, -1):
            self.seg[i] = self.st_func(self.seg[2*i], self.seg[2*i+1])

    def query(self, l, r):
        """区間クエリの計算 O(logN)

        Args:
            l (int): 区間の左端
            r (int): 区間の右端
        
        Returns:
            int: [l, r)についての区間クエリ
        """
        l += self.n
        r += self.n
        res_l = self.ide_ele
        res_r = self.ide_ele

        while l < r:
            if l % 2 == 1:
                res_l = self.st_func(res_l, self.seg[l])
                l += 1
            if r % 2 == 1:
                r -= 1
                res_r = self.st_func(self.seg[r], res_r)
            l //= 2
            r //= 2

        return self.st_func(res_l, res_r)

    def update(self, i, v):
        """値の更新 O(logN)

        Args:
            i (int): 更新対象のindex
            v (int): 更新値
        """
        i += self.n
        self.seg[i] = v
        while i > 1:
            i //= 2
            self.seg[i] = self.st_func(self.seg[i*2], self.seg[i*2+1])
    
    def st_func(self, x, y):
        """問題に応じた処理

        Returns:
            int: 問題に応じた値
                - RmQ(Range Minimum Query): min(x, y)
                - RMQ(Range Maximum Query): max(x, y)
                - RSQ(Range Sum Query):     x + y
                - RPQ(Range Product Query): x * y
                - RGQ(Range GCD Query):     gcd(x, y)
        """
        return gcd(x, y)
 
n = int(input())
a = list(map(int, input().split()))

st = SegmentTree(a)

res = 0
for i in range(n):
	res = max(res, gcd(st.query(0, i), st.query(i+1, n)))

print(res)

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

#define MAX 100000

vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX], parent[MAX], lowest[MAX], timer;

void dfs(int current, int prev){
    prenum[current] = lowest[current] = timer;
    timer++;

    visited[current] = true;

    int next;

    for(int i=0; i<G[current].size(); i++){
        next = G[current][i];
        if(!visited[next]){
            parent[next] = current;
            dfs(next, current);
            // ノード next の探索が終了した直後の処理
            lowest[current] = min(lowest[current], lowest[next]);
        }
        else if(next != prev){
            // エッジ current --> next が Back-edgeの場合の処理
            lowest[current] = min(lowest[current], prenum[next]);
        }
    }
}

void art_points(){
    for(int i=0; i<N; i++) visited[i] = false;
    timer = 1;
    dfs(0, -1); 
    
    set<int> ap;
    int np = 0;
    for(int i=1; i<N; i++){
        int p=parent[i];
        if(p==0) np++;
        else if(prenum[p] <= lowest[i]) ap.insert(p);
    }
    if(np > 1) ap.insert(0);
    for(set<int>::iterator it = ap.begin(); it != ap.end(); it++){
        cout << *it << endl;
    }
}

int main(int argc, char const *argv[])
{
    int m;
    cin >> N >> m;
    for(int i=0; i<m; i++){
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    art_points();

    return 0;
}



Measured memory_bytes: 6904
import java.util.Scanner;

// internous_atcoder_001 at 2018/02/15

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

	private void solveA080() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (N * A < B) {
			System.out.println(N * A);
		} else {
			System.out.println(B);
		}
	}

	private void solveA044() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		if (N <= K) {
			System.out.println(N * X);
		} else {
			System.out.println((K * X) + (N - K) * Y);
		}
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveE() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveF() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

}

Measured memory_bytes: 22996
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	f, p := make([][10]int, n), make([][11]int, n)
	for i := range f {
		for j := range f[i] {
			f[i][j] = nextInt()
		}
	}
	for i := range p {
		for j := range p[i] {
			p[i][j] = nextInt()
		}
	}

	ans := -100000000 * n
	open := make([]bool, 10)
	for bit := 1; bit < 1<<10; bit++ {
		// 営業するか否かを決定
		for hour := 0; hour < 10; hour++ {
			open[hour] = (bit>>uint(hour))&1 == 1
		}
		// 得られる利益を計算
		profit := 0
		for i := 0; i < n; i++ {
			// 各店舗と被っている時間帯数
			c := 0
			for j := 0; j < 10; j++ {
				if open[j] && f[i][j] == 1 {
					c++
				}
			}
			profit += p[i][c]
		}
		// 最大値更新
		ans = max(ans, profit)
	}

	puts(ans)
}


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

typedef long long ll;

ll N;
ll R;

int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    ll a, k;
    cin >> a >> k;
    ll r;
    while (true) {
      if (a % k == 0) {
        r = a / k;
        break;
      }
      ll step = a / k + 1;
      a -= ((a - a / k * k - 1) / step + 1) * step;
    }
    R ^= r;
  }
  cout << (R == 0 ? "Aoki" : "Takahashi") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
 
  int a,b;
  cin>>a>>b;
  string x;
  cin>>x;
 
  int c1=0,c2=0,c3=0;
  bool ck=true;
  for(int i=0;i<x.length();i++)
  {
 
      if(ck==true)
          if(isdigit(x[i]))
            c1++;
      if(ck==false){
        if(isdigit(x[i]))
            c2++;
      }
      if(x[i]=='-')
      {
        c3++;
        ck=false;
      }
  }
  //cout<<c1<<" "<<c2;
  if(c1==a && c2==b && c3==1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) (((1+x)*x)/2)
#define sum(x) ((n*(n-1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];

  scanf("%lld",&n);
  printf("%lld",sum(n-1));

  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;
typedef long long ll;
int a[100005];
int b[100005];
int c[100005];
ll dp[100005][3];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for (int i = 1; i < n; ++i) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    ll res = 0;
    for (int i = 0; i < 3; ++i) {
        res = max(res, dp[n - 1][i]);
    }
    cout << res << endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main(){
    fast();
 
/* you get what you work for not what you wish for */
    
    string s;
    cin >> s;
    ll cnt = 0;
    for(int i=0; i<s.size()/2; i++){
        if(s[i]!=s[s.size()-1-i]){
            cnt++;
        }
    }
    out(cnt);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 dd, nn;
	cin >> dd >> nn;
	if(nn == 100)
	{
		nn++;
	}
	cout << nn;
	if(dd == 0)
	{
		cout << endl;
	}
	else if(dd == 1)
	{
		cout << "00" << endl;
	}
	else
	{
		cout << "0000" << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
def main() -> None:
    n = int(input())
    a_tuple = tuple(map(int, input().split()))

    if 0 in a_tuple:
        print(0)
        return
    boader = 10 ** 18
    answer = 1
    for a in a_tuple:
        answer *= a
        if answer > boader:
            print(-1)
            return
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21864
my $N = <STDIN>;
my $s = <STDIN>;
chomp $s;
my @A = split(/ /,$s);
my $count=0;
my @R;
my @L;
for(0..$N){ $L[$_]=0;$R[$_]=0;}
for(my $i=0;$i<$N;$i++){
    if($i+$A[$i] <=$N){
      $R[$i + $A[$i]]++;
    }
    if( $i - $A[$i] >=0){
        $L[$i - $A[$i]]++;
    }
}
for(my $i=0;$i<$N;$i++){
    $count = $count + $R[$i]*$L[$i];
}
print "$count";

Measured memory_bytes: 39536
S = input()

while 1:

    flag = 0
    if S[-5:] == "erase":
        S = S[:-5]
        flag = 1
    if S[-6:] == "eraser":
        S = S[:-6]
        flag = 1
    if S[-5:] == "dream":
        S = S[:-5]
        flag = 1
    if S[-7:] == "dreamer":
        S = S[:-7]
        flag = 1

    if flag == 0:
        break

if S=="":
    print("YES")
else:
    print("NO")


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

typedef long long Int;

using namespace std;

int main()
{
	int n, t;
	int D[100001];

	scanf("%d %d", &n, &t);

	for (int i = 0; i < n; i++) scanf("%d", D + i);

	sort(D, D + n);

	Int ans = 1;

	for (int i = n - 1; i >= 0; i--){
		ans = (ans * (upper_bound(D, D + n, D[i] + t) - D - i)) % 1000000007;
	}

	printf("%lld\n", ans);

	return (0);
}

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

void solver() {
  int n;
  cin >> n;

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

  sort(as.begin(), as.end());
  sort(bs.begin(), bs.end());

  long long medA, medB;
  if (n % 2 == 0) {
    medA = (as[(n/2)-1] + as[(n/2)]);
    medB = (bs[(n/2)-1] + bs[(n/2)]);
  } else {
    medA = (as[(n-1)/2]);
    medB = (bs[(n-1)/2]);
  }
  cout << medB - medA + 1 << "\n";
}

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 6412