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

int main() {
  int N, a=0;
  cin >> N;
  
  vector<int>vec(N);
  
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  for(int j=0; j<N; j++){
    if(j == 0){
      a++;
      continue;
    } 
    else if(vec.at(j)<vec.at(j-1)){
      a++;
    }
  }
  
  cout << a << endl;
}

Measured memory_bytes: 3628
x, y = map(int, input().split())
if x!=0 and y!=0:
  if x*y > 0:
    if x<y:
      ans = y-x
    else:
      ans = 2+x-y
  else:
    ans = abs(x+y)+1
else:
  if x==0:
    ans = abs(y) + int(y<0)
  else:
    ans = abs(x) + int(x>0)
print(ans)

Measured memory_bytes: 3060
#include <unistd.h>
#include <vector>

#define N 1000000
const int mod = 998244353;

int n;
int A[N+1];

char ibuf[1600100];
char *ibufe = ibuf-1;

void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');
  return x;
}

char buf[20];
char *bufe = buf;

void write_uintll(long long int x){
  int i;
  static char tmp[14];
  if(x==0){
    *bufe++ = '0';
    *bufe++ = '\n';
    return;
  }

  for(i=0; x; i++){
    tmp[i] = '0' + x % 10;
    x /= 10;
  }
  for(i--; i >= 0; i--){
    *bufe++ = tmp[i];
  }
  *bufe++ = '\n';
}

void writeall(){
  int k, t = 0;
  while((k=write(STDOUT_FILENO, buf+t, bufe-buf-t))>0) t += k;
}


/*
\sum_{i<j} lcm(Ai,Aj)
\sum_{i<j} Ai Aj / gcd(Ai,Aj)
\sum_{d} 1/d \sum_{i<j: gcd(Ai, Aj) = d} Ai Aj

f(d) = \sum_{i,j: gcd(Ai, Aj) = d} Ai Aj
F(d) = \sum_{i,j: d | gcd(Ai, Aj)} Ai Aj
F(d) = \sum_{i,j: d | Ai, d | Aj)} Ai Aj
F(d) = (\sum_{i: d | Ai} Ai)^2
\sum_{d} 1/d \sum_{n: d|n} m(n/d) F(n)
\sum_{n} F(n) \sum_{d: d|n} 1/d m(n/d)
\sum_{n} F(n)/n \sum_{d: d|n} n/d m(n/d)
\sum_{n} F(n)/n \sum_{d: d|n} d m(d)
\sum_{d: d|n} d m(d) = \sum_{d: p|d|n} d m(d) + \sum_{d: d|n/p^k} d m(d)
= \sum_{d: d|n/p^k} pd m(pd) + \sum_{d: d|n/p^k} d m(d)
= \sum_{d: d|n/p^k} d m(d) - pd m(d)
=(1-p0)(1-p1)...(1-pm)
*/

int phi[N+1];
bool sieve[N+1];

int main(){
  int r, s;

  phi[1] = 1;
  for(int i=2;i<=N;i++) phi[i] = (long long) (mod - mod/i) * phi[mod%i] % mod;
  for(int i=2;i<=N;i++){
    if(!sieve[i]){
      for(int j=i;j<=N;j+=i){
        sieve[j] = true;
        phi[j] = (long long) phi[j] * (mod+1-i) % mod;
      }
    }
  }
  
  readall();
  n = read_uint();
  s = 0;
  for(int i=0;i<n;i++){
    int x = read_uint();
    A[x]++;
    s += x;
    if(s >= mod) s -= mod;
  }

  for(int i=1;i<=N;i++){
    A[i] = (long long) i * A[i] % mod;
  }
  for(int i=1;i<=N;i++){
    for(int j=2*i;j<=N;j+=i){
      A[i] += A[j];
      if(A[i] >= mod) A[i] -= mod;
    }
  }

  r = mod-s;
  for(int i=1;i<=N;i++){
    r = (r + (long long) A[i] * A[i] % mod * phi[i]) % mod;
  }

  write_uintll(r&1?(r+mod)/2:r/2);
  writeall();

  return 0;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,m,x;
  cin >> n >> m >> x;
  vec c(n);
  mat a(n,vec(m));
  for(ll i=0;i<n;i++) {
    cin >> c[i];
    for(ll j=0;j<m;j++) {
      cin >> a[i][j];
    }
  }
  ll ans=inf;
  for(ll i=0;i<(1<<n);i++) {
    bitset<15> bit(i);
    vec s(m);
    ll tans=0;
    for(ll j=0;j<n;j++) {
      if(bit.test(j)) {
        tans+=c[j];
        for(ll k=0;k<m;k++) {
          s[k]+=a[j][k];
        }
      }
    }
    ll f=1;
    for(ll j=0;j<m;j++) {
      if(s[j]<x) f=0;
    }
    if(f) ans=min(ans,tans);
  }
  if(ans==inf) ans=-1;
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    string s,b;
    int q;
    cin >> s >> q;
    bool flag=true;
    rep(i,q) {
        int t;
        cin >> t;
        if (t==1) flag=!flag;
        else {
            int f;
            char c;
            cin >> f >> c;
            if ((f==1)^flag) s.push_back(c);
            else b.push_back(c);
        }
    }
    if (flag==1) {
        reverse(b.begin(),b.end());
        rep(i,s.size()) b.push_back(s[i]);
        cout << b << endl;
    } else {
        reverse(s.begin(),s.end());
        rep(i,b.size()) s.push_back(b[i]);
        cout << s << endl; 
    }
   
    return 0;   
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*b,c*d) << "\n";

    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  if(n % 2 == 0)cout << n << endl;
  else cout << n * 2 << endl;
}

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

int main() {
    int n, q;
    cin >> n >> q;
    priority_queue<int> que[n];
    while (q--) {
        int t;
        cin >> t;
        if (t == 0) {
            int a, b;
            cin >> a >> b;
            que[a].push(b);
        } else if (t == 1) {
            int a;
            cin >> a;
            if (que[a].size()) {
                cout << que[a].top() << endl;
            }
        } else {
            int a;
            cin >> a;
            if (que[a].size()) {
                que[a].pop();
            }
        }
    }
}


Measured memory_bytes: 4144
n = int(input())

a_tests = [[-1]*n for _ in range(n)]

for i in range(n):
    a = int(input())
    for _ in range(a):
        x,y = map(int,input().split())
        a_tests[i][x-1] = y

res = 0

for i in range(2 ** n):
    flag = False

    one_count = 0
    for bit in bin(i)[2:]:
        one_count += int(bit)

    if res >= one_count:
        continue

    for j in range(n):
        if int(bin(i >> (n - j - 1))[-1]) == 0:
            continue
        for k in range(n):
            if a_tests[j][k] != -1 and a_tests[j][k] != int(bin(i >> (n - k - 1))[-1]):
                flag = True
    if flag == False:
        res = one_count
    
print(res)

Measured memory_bytes: 45532
N = int(input())
xyss = []
for i in range(N):
    A = int(input())
    xys = []
    for j in range(A):
        x, y = map(int, input().split())
        xys.append((x-1, y))
    xyss.append(xys)
 
ans = 0
for S in range(2**N):
    numHonest = 0
    isOK = True
    for i in range(N):  # 人i
        if (S>>i)&1 == 0:
            continue
 
        numHonest += 1
        xys = xyss[i]
        A = len(xys)
        for x, y in xys:  # 証言j
            if (S>>x)&1 != y:
                isOK = False
                break
        if not isOK:
            break
 
    if isOK:
        ans = max(ans, numHonest)
 
print(ans)

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

int main()
{
    int n; cin>>n;
    int a[n]; for(e: a) cin>>e;

    long res=0;
    int c=0;
    for(int e: a) {
        if (e==0) {
            c=0;
        }
        else {
            res+=c;
            e-=c;
            res+=e/2;
            c=e%2;
        }
    }
    cout<<res<<endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

int main(){
    int N;
    long long int res,initial[5];
    char name[5] = {'M','A','R','C','H'};
    char s[11];

    scanf("%d",&N);

    res = 0;
    REPI(5)
        initial[i] = 0;
  
    REPI(N){
        scanf("%s",s);
        REPJ(5){
            if(s[0] == name[j])
                initial[j]++;
        }
    }
  
  	REPI(5){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                res += initial[i] * initial[j] * initial[k];
            }
        }
    }

    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
def main():
    N = int(input())
    C = [int(input()) for _ in range(N)]
    MOD = 10 ** 9 + 7
    color = defaultdict(int)
    dp = [0] * (N+1)
    dp[0] = 1
    color[C[0]] = 0
    for i in range(1,N):
        if color.get(C[i]) == None or C[i] == C[i-1]:
            dp[i] = dp[i-1]
        else:
            dp[i] = dp[i-1] + dp[color[C[i]]]
        color[C[i]] = i
        dp[i] %= MOD
    print(dp[N-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 120576
import java.io.*;
import java.util.*;
public class Main{
  	
	public static void main(String args[]) throws IOException{
      Scanner sc = new Scanner(System.in);
      int v = sc.nextInt();
      int e = sc.nextInt();
      List<Integer> adj[] = new LinkedList[v];
      
      for(int i=0;i<v;i++)
        adj[i]= new LinkedList<Integer>();
      
      for(int i=0; i<e; i++){
        int st=sc.nextInt();
        int ed = sc.nextInt();
        adj[st-1].add(ed-1);
      }
      
      System.out.println(maxPath(adj));
      
      /*
      String dp[][] =  new String[n.length()][m.length()];
      System.out.println(sub(n, m , 0, 0, dp));
      */
    }
  
  public static int maxPath(List<Integer> adj[]){
    int max = Integer.MIN_VALUE;
    int visited[] = new int[adj.length];
      Arrays.fill(visited, -1);
    
    for(int i=0; i<adj.length; i++){
    
      int m = maxPath(adj, i, visited);
      
      if(m > max)
        max = m;
      
    }
    return max;
  }
   public static int maxPath(List<Integer> adj[], int st, int visited[]){
     if(visited[st] != -1)
       return visited[st];
     if(adj[st].size() == 0)
       return 0;
     
     int max = 0;
     for(int v : adj[st]){
     	max = Math.max(max, 1+ maxPath(adj, v, visited) );
     }
     visited[st] = max;
     return max;
   }
  
  
  
 
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

template <class T>
struct RangeSum {
  vector<T> vec;
  RangeSum() {}
  RangeSum(vector<T> elems) : vec(elems) {
    for (int i = 1; i < vec.size(); i++) { vec[i] += vec[i - 1]; }
  }
  T sum(int l, int r) {
    if (l > r) return T(0);
    if (l == 0)
      return vec[r];
    else
      return vec[r] - vec[l - 1];
  }
};

void solve() {
  int N;
  cin >> N;
  vector<int> t, x, y;
  t.push_back(0);
  x.push_back(0);
  y.push_back(0);
  for (int i = 0; i < N; i++) {
    int tt, xx, yy;
    cin >> tt >> xx >> yy;
    t.push_back(tt);
    x.push_back(xx);
    y.push_back(yy);
  }
  for (int i = 1; i <= N; i++) {
    int dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    int tdist = t[i] - t[i - 1];
    if (tdist < dist || tdist % 2 != dist % 2) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();
  return 0;
}


Measured memory_bytes: 1644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long r){
  cout<<r*r<<endl;
}

int main(){
    long long r;
    scanf("%lld",&r);
    solve(r);
    return 0;
}


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

#define ll long long
#define pb push_back

const int maxn = 3e5 + 20;

int dp[maxn] , a[maxn];

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

	ll n;
	cin >> n;

	cout << n * (n - 1) / 2 << endl;

}










 


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {
	char S[300], T[300];
	scanf("%s%s", S, T);


	for (int i = 0; i < strlen(S); i++)
		for (int j = i + 1; j < strlen(S); j++)
			if ((int)S[i] > (int)S[j]) {
				char tmp = S[i];
				S[i] = S[j];
				S[j] = tmp;
			}

	for (int i = 0; i < strlen(T); i++)
		for (int j = i + 1; j < strlen(T); j++)
			if ((int)T[i] < (int)T[j]) {
				char tmp = T[i];
				T[i] = T[j];
				T[j] = tmp;
			}

	if (strcmp(S, T) < 0) {
		printf("Yes");
	}
	else {
		printf("No");
	}




}


void  bubbleSort(char number[]) {
	for (int i = 0; i < strlen(number); i++)
		for (int j = i + 1; j < strlen(number); j++)
			if ((int)number[i] > (int)number[j]) {
				char tmp = number[i];
				number[i] = number[j];
				number[j] = tmp;
			}
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 9223372036854775807
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n;
  cin >> n;
  
  int x[n];
  ll s[n] = {};
  REP(i,n){
    cin >> x[i];
    s[i] = s[i==0?0:i-1] + x[i];
  }
  
  //midを決め打ち
  ll ans = INF;
  int l = 0, r = 2;
  FOR(mid,1,n-2){
    ll absl = abs(s[mid]-s[l]*2);
    while(absl > abs(s[mid]-s[l+1]*2) && l+1 < mid){
      absl = abs(s[mid]-s[l+1]*2);
      l++;
    }
    
    ll absr = abs(s[n-1]-s[r]*2+s[mid]);
    while(absr > abs(s[n-1]-s[r+1]*2+s[mid]) && r+1 < n-1){
      absr = abs(s[n-1]-s[r+1]*2+s[mid]);
      r++;
    }
    
    ll a = s[l], b = s[mid]-s[l], c = s[r]-s[mid], d = s[n-1]-s[r];
    ans = min(ans,max({a,b,c,d})-min({a,b,c,d}));
   // cout << a << " "<< b << " "<< c  << " "<< d << endl;
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define F first
#define S second
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define MP make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define debug(x) cout << " > " << #x << ':' << x << endl;
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using Prior = priority_queue<T>;
template<typename T> using prior = priority_queue<T, vec<T>, greater<T>>;

const int INF = 1e9;
const ll LLINF = (ll)4*1e18;
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
const int xx[8] = {0,1,0,-1,1,1,-1,-1};
const int yy[8] = {1,0,-1,0,1,-1,-1,1};

void pmod(ll &a, ll b) {a = (a+b)%MOD;}
void mmod(ll &a, ll b) {a = (a-b+MOD)%MOD;}
void tmod(ll &a, ll b) {a = (a*b)%MOD;}
ll POW(ll a, ll b) {ll res=1; do{if(b%2)tmod(res,a);tmod(a,a);}while(b>>=1); return res;}
template<typename T> void amax(T &a, T b) {if(a < b) a = b;}
template<typename T> void amin(T &a, T b) {if(a > b) a = b;}

#define N 500010
#define sqN 1000

struct query{
    int l, r, idx;
};

bool cmp1(query a, query b){
    return (a.l/sqN < b.l/sqN) || (a.l/sqN == b.l/sqN && a.r < b.r);
}

int cnt[N], tot;

void solve(){
    int n, m;
    
    cin >> n >> m;
    vec<int> v(n);
    for(auto &i:v) cin >> i;
    
    vec<query> q(m);
    rep(i, m) {
        cin >> q[i].l >> q[i].r;
        q[i].l--; q[i].r--;
        q[i].idx = i;
    }
    
    vec<int> ans(m);
    sort(ALL(q), cmp1);
    
    int l, r;
    l = r = 0;
    for(auto i:q){
        while(r <= i.r){
            if(cnt[v[r]] == 0) tot++;
            cnt[v[r++]]++;
        }
        while(r > i.r+1){
            cnt[v[--r]]--;
            if(cnt[v[r]] == 0) tot--;
        }
        while(l < i.l){
            if(cnt[v[l]] == 1) tot--;
            cnt[v[l++]]--;
        }
        while(l > i.l){
            cnt[v[--l]]++;
            if(cnt[v[l]] == 1) tot++;
        }
        
        ans[i.idx] = tot;
    }
    
    for(auto i:ans) cout << i << endl;
}

int main(){
//    kiyohime
    int T = 1;
    
//    cin >> T;
    while(T--){
        solve();
    }
}



Measured memory_bytes: 15444
import java.util.*;
            public class Main {
                public static void main(String[] args) {
                    Scanner stdIn = new Scanner(System.in);
                    String str = stdIn.next(); 
                    int len = str.length();
                    int[] level = new int[len+1];
                    int top = 0;
                    int bottom = 0;
                    int pos = 0;
                    for (int i=0; i<len; i++) {
                        char c = str.charAt(i);
                        level[i] = pos;
                        if (c == '\\') {
                            pos--; 
                        }
                        else if(c == '/') {
                            pos++; 
                        } 
                        top = Math.max(top,pos);
                        bottom = Math.min(bottom,pos); 
                    } 
                    level[len] = pos; 
                    top = Math.max(top,pos); 
                    bottom = Math.min(bottom,pos); 
                    boolean[] water = new boolean[len]; 
                    Map<Integer,Integer> map = new HashMap<Integer,Integer>(); 
                    int sum = 0; 
                    for (int i=top; i>bottom; i--) {
                        int start = -1;
                        for (int j=0; j<len; j++) { 
                            if (!water[j]) {
                                if ((start==-1?level[j]:level[j+1]) == i) { 
                                    if (start == -1 && level[j]>level[j+1]) {
                                        start = j;
                                    } 
                                    else if(start != -1){ 
                                        int count = 0;
                                        int vol = 0; 
                                        for (int k=start; k<j+1; k++) { 
                                            vol += Math.abs(level[start] - Math.max(level[k],level[k+1])); 
                                            if(Math.abs(level[k] - level[k+1]) > 0) 
                                                count++; 
                                            water[k] = true;
                                        } 
                                        vol += count/2; 
                                        sum += vol; 
                                        map.put(start,vol); 
                                        start = -1; 
                                    } 
                                } 
                            } 
                        } 
                    } 
                    System.out.println(sum); 
                    System.out.print(map.size()); 
                    for (int i=0; map.size()!=0; i++) { 
                        if(map.containsKey(i)){ 
                            System.out.print(" "+map.get(i)); 
                            map.remove(i); 
                        } 
                    } 
                    System.out.println(); 
                } 
            }


Measured memory_bytes: 29540
w,h,n=map(int,input().split())
l=[[int(j) for j in input().split()] for i in range(n)]
b=c=0
for i in range(n):
    x,y,a=l[i][0],l[i][1],l[i][2]
    if a==1:b=max(b,x)
    if a==2:w=min(w,x)
    if a==3:c=max(c,y)
    if a==4:h=min(h,y)
print([(w-b)*(h-c),0][(w<b)|(h<c)])

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>

using namespace std;

int main(){
    vector<int> pos(5);   
    cin>>pos[0]>>pos[1]>>pos[2]>>pos[3]>>pos[4];
    int amari[5]={0};
    int syo[5]={0};
    int just=0;
    int min_amari=9;
    for(int i=0;i<5;i++){
        amari[i]=pos[i]%10;
        syo[i]=pos[i]/10;
        if(amari[i]==0) just++;
        else min_amari=min(min_amari,amari[i]);
    }
    int spend=(syo[0]+syo[1]+syo[2]+syo[3]+syo[4])*10;
    if(just!=5){
        spend+=(4-just)*10;
        spend+=min_amari;
    }
    cout<<spend<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

ll modpow(ll a, ll N, ll mod) {
  ll ans = 1;
  ll tmp = a;
  while(N > 0) {
    if(N % 2 == 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  string x; cin >> x;
  vector<ll> to(n+1);
  rep(i, n+1) {
    if(i) {
      int tmp = i;
      while(tmp) {
        to[i]++;
        tmp %= __builtin_popcount(tmp);
      }
    }
  }
  reverse(all(x));
  int cnt = 0;
  rep(i, n) if(x[i] == '1') cnt++;
  vector<ll> memo(3);
  rep(j, 3) {
    if(cnt-1+j == 0) continue;
    rep(i, n) {
      if(x[i] == '1') (memo[j] += modpow(2, i, cnt-1+j)) %= (cnt-1+j);
    }
  }
  vector<int> ans(n);
  rep(i, n) {
    if(x[i] == '1') {
      if(cnt-1 == 0) {
        ans[i] = 0;
      } else {
        int first = (memo[0]+(cnt-1)-modpow(2, i, cnt-1))%(cnt-1);
        ans[i] = to[first]+1;
      }
    } else {
      int first = (memo[2]+modpow(2, i, cnt+1))%(cnt+1);
      ans[i] = to[first]+1;
    }
  }
  reverse(all(ans));
  rep(i, n) cout << ans[i] << endk;
  return 0;
}


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

using namespace std;

typedef long long ll;
const ll MOD=1e9+7;

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

  int n;cin >>n;
  int memo[n]={0};
  for(int i=0;i<n;i++){
    int a;cin >>a;
    memo[a]++;
  }
  ll res=1;
  if(n%2){
    int m=(n-1)/2;
    if(memo[0]!=1) res=0;
    for(int i=1;i<=m;i++){
      if(memo[i*2]==2) res=(2*res)%MOD;
      else res=0;
    }
  }
  else{
    int m=n/2;
    for(int i=1;i<=m;i++){
      if(memo[i*2-1]==2) res=(2*res)%MOD;
      else res=0;
    }
  }
  cout <<res<<endl;
}

Measured memory_bytes: 640
/**
*
* Author: MARS
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl E = 2.71828182845904523536;
const ldbl pi = acos(-1);
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1LL<<30;

/** /////////// ** Code ** /////////// **/

const int N=100100;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a <=8 && b<=8) printf("Yay!");
    else printf(":(");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    int N;
    cin >> N;
    int maxi = 0;
    for(int i = 1;;i++){
        if(i*(i+1) >= 2*N){
            maxi = i;
            break;
        }
    }
    RREPS(i,maxi){
        if(N >= i){
            cout << i << "\n";
            N -= i;
        }
    }
}

Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let mut sum: i8 = 0;
    for _i in 0..3{
	let a: i8 = read();
	sum += a;
    }
    if sum > 21{
	println!("bust");
    }else{
	println!("win");
    }
}


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

using namespace std;
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x+1) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;

const int N = 100005;
vi adj[N];


int32_t main() {
	FAST_IO;

	int n, m;
	cin >> n >> m;
	int h[n];
	for (int& x: h) cin >> x;
	
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		
		adj[a].PB(b);
		adj[b].PB(a);
	}
	
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (adj[i].size() == 0) {
			cnt++;
		} else {
			bool ok = true;
			for (int to: adj[i]) {
				if (h[to-1] >= h[i-1]) {
					ok = false;
				}
			}
			if (ok) cnt++;
		}
	}
	
	cout << cnt << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 10232
MOD = 10**9 + 7
N = int(input())
C = []
for i in range(N):
    c = int(input())-1
    if not C or C[-1] != c:
        C.append(c)
N = len(C)

prev = [None]*(max(C)+1)

dp = [0]*(N+1)
dp[0] = 1

for i,c in enumerate(C):
    if prev[c] is None:
        dp[i+1] = dp[i]
    else:
        dp[i+1] = dp[i] + dp[prev[c]+1]
    dp[i+1] %= MOD

    prev[c] = i

print(dp[N])

Measured memory_bytes: 20524
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}

	s := make([]int, n+1)
	for i := 0; i < n; i++ {
		s[i+1] = s[i] + p[i]
	}

	mm, si := 0, 0
	for i := 0; i <= n-k; i++ {
		t := s[i+k] - s[i]
		if mm < t {
			mm, si = t, i
		}
	}

	ans := 0.0
	for i := si; i < si+k; i++ {
		ans += expectation(p[i])
	}

	fmt.Println(ans)
}

func expectation(p int) float64 {
	n := float64(p)
	s := 0.5 * n * (n + 1)
	return s / n
}


Measured memory_bytes: 6656
x,y = map(int,input().split())
g = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
s = 0
for i in range(3):
    if x in g[i] and y in g[i]:
        print("Yes")
        s = 1
if s == 0:
    print("No")

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

vec san(32, 1);

int bit3_t(ll a, int t){
    return (a % san[t + 1]) / san[t];
}

bool between(ll x, ll y1, ll y2){
    if(y1 > y2) swap(y1, y2);
    ++y1; --y2;
    if(!(y1 <= y2)) return false;
    while(x > 0){
        if(x%3 == 1){
            if(y2 - y1 > 3) return true;
            for(ll y = y1; y <= y2; ++y) if(y%3 == 1) return true;
        }
        x /= 3;
        y1 /= 3;
        y2 /= 3;
    }
    return false;
}

ll f(ll a, ll b, ll c, ll d){
    ll res = 0;
    Rrep(i, 31){
        /*if(bit3_t(b, i) == 1 && bit3_t(d, i) == 1){
            swap(a, b);
            swap(c, d);
        }*/
        if(bit3_t(a, i) == 1 && bit3_t(c, i) == 1 && a / san[i] == c / san[i]){
            //if(abs(d - b) >= 2 * san[i]
            //|| abs((d % (san[i + 1])) / san[i] - (b % (san[i + 1])) / san[i]) == 2){
            if(between(a / san[i], b / san[i], d / san[i])){
                ll diff1 = a % san[i], diff2 = c % san[i];
                res = max(res, min({diff1 + 1, san[i] - diff1,
                                    diff2 + 1, san[i] - diff2}) * 2);
            }
        }
    }
    return res;
}


int main() {
    cin>>Q;
    reps(i, 1, 32) san[i] = san[i-1] * 3;
    rep(i,Q){
        vec v(4);
        rep(j,4){
            cin>>v[j];
            --v[j];
        }
        ll res = abs(v[0] - v[2]) + abs(v[1] - v[3]);
        //cout<<res<<endl;
        cout<<res + max(f(v[0], v[1], v[2], v[3]), f(v[1], v[0], v[3], v[2]))<<endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <regex>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

int main() {
    string s;
    cin >> s;
    regex re("A?KIHA?BA?RA?");
    bool res=regex_match(s,re);
    cout << (res?"YES":"NO") << endl;
    return 0;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define MAX_V 1 << 10
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

double cost[MAX_V][MAX_V];
double d[MAX_V];
int prev[MAX_V];
bool used[MAX_V];
int n;

void dijkstra(int s){
  fill(d, d + n, INF);
  fill(used, used + n, false);
  fill(prev, prev + n, -1);
  d[s] = 0;

  while(true){
    int v = -1;
    rep(u, n){
      if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
    }

    if(v == -1) break;
    used[v] = true;

    rep(u, n){
      if(d[u] > d[v] + cost[v][u]){
	d[u] = d[v] + cost[v][u];
	prev[u] = v;
      }
    }
  }
}

vi get_path(int t){
  vi path;
  for(; t != -1; t = prev[t]) path.push_back(t);
  reverse(path.begin(), path.end());
  return path;
}

int main(){
  while(scanf("%d", &n) && n){
    int b;
    double x[MAX_V], y[MAX_V];
    rep(i, n){
      scanf("%d", &b); b--;
      scanf("%lf%lf", &x[b], &y[b]);
    }
    rep(i, MAX_V) rep(j, MAX_V) cost[i][j] = INF;
    rep(i, n) rep(j, n){
      if(i == j) continue;
      double dis = sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
      if(dis > 50) continue;
      cost[i][j] = dis;
    }


    int m;
    scanf("%d", &m);
    rep(i, m){
      int s, g;
      scanf("%d%d", &s, &g);s--;g--;
      dijkstra(s);
      /*      rep(i, n){
	rep(j, n) if(cost[i][j]==INF) printf("INF"); else printf("%3.0lf", cost[i][j]);
	puts("");
      }
      rep(i, n) printf("%lf ", d[i]); puts("");
      rep(i, n) printf("%d ", (int)used[i]); puts("");
      rep(i, n) printf("%d", prev[i]); puts("");*/
      if(d[g] == INF){
	puts("NA");
      }else{
	vi res = get_path(g);
	//	printf("%d\n", (int)res.size());
	rep(i, res.size()) printf(i?" %d":"%d", res[i]+1);
	puts("");
      }
    }
  }
  return 0;
}

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

int main() {
int n;
cin>>n;
string w[n];
REP(i,n){
  cin>>w[i];
}
bool ok=true;
for (int i = 0; i < n-1; i++)
{
  /* code */
  for (int j = i+1; j < n; j++)
  {
    /* code */
    if (w[i]==w[j]||w[i].at(w[i].size()-1)!=w[i+1].at(0))
    {
      /* code */
      ok=false;
    }
    
  }
  
}
if (ok)
{
  /* code */
  cout<<"Yes"<<endl;
}
else
{
  cout<<"No"<<endl;
}


}


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

int main() {
	int n, c = 0, d = 0;
	string s;
	
	cin >> n >> s;
	
	for (int i = 0; i < n; i++)
		if (s[i] == 'R') c++;
		
	for (int i = 0; i < c; i++)
		if (s[i] == 'R') d++;
		
	cout << c - d << endl;
	return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main(){
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n){
    string str;
    cin >> str;
  	vector<char> vec(10);
  	rep(i, 10) vec[i] = str[i];
  	sort(all(vec));
  	rep(i, 10) str[i] = vec[i];
  	mp[str]++;
  }
  ll sum = 0;
  for(auto p : mp){
    ll num = p.second;
    sum += num*(num-1)/2;
  }
  cout << sum << endl;
  return 0; 
}


Measured memory_bytes: 11392
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M, Q;
ll fld[510][510];
ll S[510][510];

int main()
{
  std::cin >> N >> M >> Q;

  rep( i, M )
  {
    ll L, R;
    std::cin >> L >> R;

    --L; --R;
    L = -L;

    ++fld[L+N-1][R];
  }

  rep( i, N ) rep( j, N )
    S[i+1][j+1] = S[i+1][j]+S[i][j+1]-S[i][j]+fld[i][j];

  rep( i, Q )
  {
    ll p, q;
    std::cin >> p >> q;
    --p; --q;
    p = -p;

    std::cout << S[p+N-1+1][q+1] << std::endl;
  }

  return 0;
}

Measured memory_bytes: 4864
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		if(a <= 5){
			System.out.println(0);
		} else if(a < 13){
			System.out.println(b/2);
		} else {
			System.out.println(b);
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pow2(x) (ll(1)<<x)
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,n) for(int i=0;i<n;i++)
#define scan(n) int n;scanf("%d", &n);
using namespace std;
const int mod = 1e9 + 7;
int main()
{
    int n,m;scanf("%d%d", &n, &m);
    char x[n][m];
    int ans[n][m];
    memset(ans,0,sizeof ans);
    ans[0][0] = 1;
    For(i,n)
    {
        For(j,m)
        {
            cin>>x[i][j];
            if(i && x[i][j]=='.')
                ans[i][j] += ans[i - 1][j];
            if(j && x[i][j]=='.')
                ans[i][j] += ans[i][j - 1];
            ans[i][j]%=mod;
        }
    }
    cout<<ans[n-1][m-1];
}

Measured memory_bytes: 8644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

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

    if (s.length() <= k)
    {
        cout << s << endl;
        return 0;
    }

    for (int i = 0; i < k; i++)
    {
        cout << s[i];
    }
    cout << "..." << endl;

    return 0;
}

Measured memory_bytes: 3628
n = gets.to_i
matches = []
n.times { matches << gets.split.map(&:to_i) }
queue = (1..n).to_a
delete_list = []
day = 0

catch(:break_loop) do
until queue.empty?
  until queue.empty?
    me = queue.shift
    if opponent = matches[me - 1].first
      if matches[opponent - 1].first == me
        delete_list << me
        delete_list << opponent
      end
    end
  end
  throw :break_loop if delete_list.empty?
  day += 1
  delete_list.uniq!
  until delete_list.empty?
    d = delete_list.shift
    matches[d - 1].shift
    queue << d
  end
end
end
puts matches.flatten.empty? ? day : -1


Measured memory_bytes: 19508
#include <iostream>

using namespace std;

int fib(int n);
int memo[45];
int main() {
    int n;

    //??\???
    cin >> n;

    //??????
    cout << fib(n) << endl;

    return 0;
}

int fib(int n){
  /* ??????1 */
  if(n==0||n==1)    return 1;
  else if(memo[n]!=0){
    return memo[n];
  }else{
    return memo[n]=fib(n-1)+fib(n-2);
  }
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<ll,ll>
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,ans=1e9+7;cin>>n>>k;
  lvector h(n,0);rep(i,n) cin>>h[i];
  sort(h.begin(),h.end());
  for(ll i=0;i+k-1<n;++i) if(ans>h[i+k-1]-h[i]) ans=h[i+k-1]-h[i];
  print(ans);
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




vector<vector<ll>> g;
vector<ll> dp;

ll dfs(ll now){
    ll mx = 1;
    for(auto &v : g[now]){
        if(dp[v]) mx = max(mx, dp[v] + 1);
        else mx = max(mx, dfs(v) + 1);
    }
    return dp[now] = mx;
}

int main() {
    ll n, m;
    cin >> n >> m;
    g.resize(n);
    dp.resize(n);
    REP(i, m){
        ll x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
    }
    
    ll ans = 0;
    REP(i, n){
        ans = max(ans, dfs(i) - 1);
    }
    cout << ans  << endl;
}


Measured memory_bytes: 8576
#include<stdio.h>
int main(){
  int n,i,a,c=0,s=0,b[100010]={};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    b[a]++;
  }
  for(i=0;i<100010;i++){
    if(b[i]==0)continue;
    s++;
    if(b[i]%2==0)c++;    
  }
  printf("%d\n",s-c%2);
  return 0;
}
  


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

int main(){
    int N;
    cin >> N;
    int ketawa = 0;
    int X = N;
    while(X != 0) {
        ketawa+=X%10;
        X /= 10;
    }
    if(N%ketawa == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<map>

using namespace std;

int main(){
  int n;
  cin>>n;
  long long s=0;
  map<int,long long> m;
  m[0]=0;
  while(n--){
    int x;
    cin>>x;
    s+=x;
    auto c=(--m.lower_bound(x))->second+x;
    for(auto it=m.upper_bound(x);it!=end(m)&&it->second<=c;it=m.erase(it));
    m[x]=c;
  }
  cout<<s-m.rbegin()->second<<endl;
}

Measured memory_bytes: 7444
import sys
import math
import heapq
from collections import deque
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
mp=[[] for i in range(N+1)]

for i in range(N-1):
    a,b=LI()
    mp[a].append((b, i))
    mp[b].append((a, i))

ma = 0
ma_e = 0
for i, arr in enumerate(mp):
    if len(arr) > ma:
        ma = len(arr)
        ma_e = i

CLS = [0]*(N-1)
VISITED = [0]*(N+1)
Q=deque([(ma_e, 0)])
VISITED[ma_e] = 1

while Q:
    v, c = Q.popleft()
    cnt = 0
    for next_e, i in mp[v]:
        if VISITED[next_e]: continue
        color = ((c + cnt) % ma) + 1
        CLS[i] = color
        # print("{} color{}".format(i, color))

        Q.append((next_e, color))
        VISITED[next_e] = 1
        cnt += 1

print(ma)
for i in CLS: print(i)


Measured memory_bytes: 74272
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;


int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	long long int  s[200][200];
	//cout << fixed << setprecision(10);
	long long int n, m, k,p,q,r;
	cin >> p>>q>>r;
	cout << p + q + r - max(p, max(q, r));
}


Measured memory_bytes: 256
S = list(input())

count = 0
record = 0
for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        count += 1
    else:
        if count > record:
            record = count
        count = 0
if count>record:
    record = count

print(record)

Measured memory_bytes: 3060