akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 
 
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({a, ex});
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}


int main(int argc, const char * argv[]) {

    string S; cin >> S;
    
    if(S[0]=='R' && S[1]=='R' && S[2] == 'R'){
        cout << 3 << endl;
        return 0;
    }

    if(S[0]=='R' && S[1]=='R'){
        cout << 2 << endl;
        return 0;
    }

    if(S[1]=='R' && S[2] == 'R'){
        cout << 2 << endl;
        return 0;
    }

    if(S[0]=='S' && S[1]=='S' && S[2] == 'S'){
        cout << 0 << endl;
        return 0;
    }
    cout << 1 << endl;
    return 0;

}


Measured memory_bytes: 6232
#include <stdio.h>
int main(){
  int h,w,i,j;
  
  for(;;){
    
    scanf("%d %d",&h,&w);
    
    for(i = 0;i < h;i++ ){
      
      for(j = 0;j < w;j++){
	printf("#");
      }
      printf("\n");
    }
    if(h == 0 && w ==0){
      break;
    }
    printf("\n");
    
  }
  return 0;
  
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int N, W; cin >> N >> W;
  vector<int> w;
  vector<ll> v;
  for(int i=0; i<N; i++){
    int wi; ll vi;
    cin >> wi >> vi;
    w.push_back(wi);
    v.push_back(vi);
  }
  vector<vector<ll>> dp(102, vector<ll>(100002, 0));
  for(int i=1; i<=N; i++){
    for(int j=0; j<=W; j++){
      if(dp[i][j]<dp[i-1][j]) dp[i][j]=dp[i-1][j];
      if(j+w[i-1]<=W) dp[i][j+w[i-1]]=dp[i-1][j]+v[i-1];
    }
  }
  cout << dp[N][W];
  return 0;
}

Measured memory_bytes: 81024
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

int dp[1010][1010];

signed main() {
  INIT;
	VAR(int,h,w);
	VEC(string,s,h);

	dp[0][0] = 1;
	REP(hi,h){
		REP(wi,w){
			if(s[hi][wi]=='#') continue;
			dp[hi][wi] = max(dp[hi][wi],
											 ((0<=hi-1&&hi-1<h?dp[hi-1][wi]:0) +
												(0<=wi-1&&wi-1<w?dp[hi][wi-1]:0)) % MOD);
		}
	}
	int ans = dp[h-1][w-1];
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 9216
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.Collections;
import java.math.BigDecimal;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        StringBuilder sb = new StringBuilder();
        while (sc.hasNext()) {
            String s = sc.next();
            BigDecimal b = new BigDecimal(s);
            
            if (b.compareTo(new BigDecimal(0)) == 0) break;
            
            int sum = 0;
            for (int i = 0; i < s.length(); i++) {
                sum += Character.getNumericValue(s.charAt(i));
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 26944
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  int i,result;
  double v;
  while(cin >> v){
    for( i = 1; i < 1000; i++ ){
      if( v < 9.8*sqrt( ( 5.0*i-5.0)/4.9 ) ){
	  result = i;
	  break;
	}
	
    }
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end(), greater<ll>());

  ll sum = v[0], p = v[0];
  int c = 1;
  for (int i = 1; i < a; i++) {
    sum += v[i];
    if (v[i] == p) c++;
    else {
      p = v[i];
      c = 1;
    }
  }
  double average = (double)(sum) / a;


  int d = 0;
  for (int i = a; i < n; i++) {
    if (v[i] == p) d++;
    else break;
  }

  ll comb[51][51];
  for (int i = 0; i < 51; i++) {
    comb[i][0] = 1;
    for (int j = 1; j < i; j++) {
      comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
    }
    comb[i][i] = 1;
  }

  ll ans = 0;
  if (c == a) {
    for (int i = a; i <= min(c+d, b); i++) {
      ans += comb[c+d][i];
    }
  }
  else ans = comb[c+d][c];

  cout << fixed << setprecision(10) << average << endl;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << (N + 1) / 2 << endl;

    return 0;
}


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

int main(){

  int N;
  string S, T;
  cin >> N >> S >> T;
  string A = "";
  for(int i=0; i<N; i++){
    	A = A + S.at(i) + T.at(i);
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <cstdio>
using namespace std;

int main(void)
{
	map <int, int> mf, ms;
	string str;
	int cn, a, b;
	while (getline(cin, str), str.size() != 0){
		stringstream ss;
		for (int i = 0; i < str.size(); i++){
			if (str[i] == '.') str[i] = ' ';
		}
		ss << str;
		ss >> a;
		mf[a]++;
		ss.str("");
	}
	while (scanf("%d,%d", &a, &b) != EOF){
		if (mf[a] != 0){
			if (ms[a] == 0) ms[a] += mf[a];
			ms[a]++;
		}
	}
	
	map <int, int> ::iterator it = ms.begin();
	while (it != ms.end()){
		cout << it->first << " " << it->second << endl;
		it++;
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
	int T;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main tr = new Main();
		tr.test(sc);
		sc.close();
	}
	
	void test(Scanner sc){
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int max = A>B?A:B;
		max = max>C?max:C;
		int ans=0;
		if(max == A){
			ans = A * 10 + B + C;
		}else if(max == B){
			ans = B * 10 + A + C;
		}else{
			ans = C * 10 + B + A;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22868
#include<stdio.h>
#include<stdlib.h>
#define N 1000000000
#define RANGE 500000

void merge(int *,int ,int,int);
void mergesort(int *,int,int);
int *L,*R,cnt=0;

int main(void){
  int n,S[RANGE],i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  mergesort(S,0,n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i < n-1) printf(" ");

  }
  printf("\n%d\n",cnt);
  
  return 0;
}

void merge(int *S,int left,int mid, int right){
  int n1,n2,i,k,j;
  n1=mid-left;
  n2=right-mid;
  L=(int *)malloc((n1+1)*sizeof(int));
  R=(int *)malloc((n2+1)*sizeof(int));

  for(i=0;i<n1;i++) L[i]=S[left + i];
  for(i=0;i<n2;i++) R[i]=S[mid + i];
  L[n1]=N;
  R[n2]=N;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j] ){
      S[k]=L[i];
      i++;
    }else{
      S[k]=R[j];
      j++;
    }
  }
}


void mergesort(int *S,int left,int right){
  int mid;
  if(left+1<right){
    mid = (left + right)/2;
    mergesort(S,left,mid);
    mergesort(S,mid,right);
    merge(S,left,mid,right);

  }


}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  i64 a, b;
  cin >> a >> b;
  auto func = [](i64 x) -> i64 {
    if (x % 4 == 0) return x;
    if (x % 4 == 1) return 1;
    if (x % 4 == 2) return x | 1;
    return 0;
  };
  if (a == 0) {
    cout << func(b) << endl;
  } else {
    cout << (func(b) ^ func(a - 1)) << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

struct UnionFind {
    vector<int> rank, parent, size;

    // +1 for 1-indexed nodes
    UnionFind(int n) : rank(n + 1, 0), parent(n + 1), size(n + 1, 1) {
        iota(parent.begin(), parent.end(), 0); // parent is itself
    }
    int root(int x) {
        if (x != parent[x]) {
            parent[x] = root(parent[x]);
        }
        return parent[x];
    }
    bool isSame(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y) { return link(root(x), root(y)); }
    bool link(int x, int y) {
        if (x == y)
            return false;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            size[x] += size[y];
        } else {
            parent[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
        return true;
    }
    int getSize(int x) { return size[root(x)]; }
};

int main() {
    ll n, m;
    cin >> n >> m;
    vl a(m), b(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
    }
    vl ret(m, 0);
    UnionFind uf(n);
    ret[m - 1] = n * (n - 1) / 2;
    for (int i = m - 1; i >= 1; --i) {
        ll x = 0, y = 0;
        if (!uf.isSame(a[i], b[i])) {
            x = uf.getSize(a[i]);
            y = uf.getSize(b[i]);
            uf.unite(a[i], b[i]);
        }
        ret[i-1] = ret[i] - x * y;
    }
    for (int i = 0; i < m; ++i) {
        cout << ret[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 4864
# coding: utf-8

# In[1]:


SUNNY, CLOUDY, RAINY = 'Sunny', 'Cloudy', 'Rainy' 


# In[2]:


weather = input()


# In[4]:


if weather == SUNNY:
    print(CLOUDY)
elif weather == CLOUDY:
    print(RAINY)
elif weather == RAINY:
    print(SUNNY)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(n == i * j){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3556
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    rep(i, N) cin >> m.at(i);

    int sum = 0;
    rep(i, N) {
        sum += m.at(i);
    }

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

    int left = X - sum;
    int count = left / m.at(0);
    int ans = m.size() + count;

    cout << ans << endl;

    return 0;
}


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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int r, D, x;
  cin >> r >> D >> x;

  int ans=x;
  REP(i, 10){
    ans = r*ans - D;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(n: str):
    n = n[::-1]
    ret = 0
    carry = 0
    for i, c in enumerate(n):
        t = int(c)
        t += carry
        if t == 5:
            if i < len(n) - 1 and int(n[i + 1]) >= 5:
                ret += 10 - t
                carry = 1
            else:
                ret += t
                carry = 0
        elif t < 5:
            ret += t
            carry = 0
        else:
            ret += 10 - t
            carry = 1
    if carry:
        ret += 1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = str(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

typedef long long ll;

const int MAX_N = 100;
const int MAX_W = 10000;

int dp[MAX_N+1][MAX_W+1];

int n, W;
int w[MAX_N], v[MAX_N];

int main() {
    cin >> n >> W;
    for(int i=0; i<n; i++) cin >> v[i] >> w[i];
    
    for(int i=n-1; i>=0; i--){
        for(int j=0; j<=W; j++){
            if(j<w[i]){
                dp[i][j] = dp[i+1][j];
            }
            else {
                dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]]+v[i]);
            }
        }
    }
    
    cout << dp[0][W] << endl;
    
}



Measured memory_bytes: 7008
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int sum=0,maxv=0;
    string s;
    cin>>s;

    rep(i,s.size()){
	if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
	    sum++;
	}
	else{
	    maxv=max(maxv,sum);
	    sum=0;
	}
    }

    cout<<max(maxv,sum)<<'\n';
    return 0;
}


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

const int MAX_N=1010101*2;
ll inv[MAX_N+1], fact[MAX_N+1], ifact[MAX_N+1];

ll comb(int n, int k){
  if(n<k) return 0;
  return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD;
}

void prepare(){
  inv[1]=fact[0]=fact[1]=ifact[0]=ifact[1]=1LL;
  for(int i=2;i<=MAX_N;i++){
    inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    fact[i]=fact[i-1]*i%MOD;
    ifact[i]=ifact[i-1]*inv[i]%MOD;
  }
}

ll f(int r,int c){
  ll ret=0;
  for(int i=1;i<=r+1;i++){
    ll tmp=fact[i+c]*ifact[i]%MOD*ifact[c]%MOD;
    ret=(ret+tmp)%MOD;
  }
  return ret;
}


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

  int R[2],C[2]; cin>>R[0]>>C[0]>>R[1]>>C[1];

  ll ans=f(R[1],C[1]);
  ans=(ans-f(R[0]-1,C[1])+MOD)%MOD;
  ans=(ans-f(R[1],C[0]-1)+MOD)%MOD;
  ans=(ans+f(R[0]-1,C[0]-1))%MOD;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 47616
#include <bits/stdc++.h>
    #define fastcin ios_base::sync_with_stdio(0);cin.tie(0)
    #define ll long long
    #define pb push_back
    #define F first
    #define S second
    #define pii pair<int,int>
    #define pli pair<long long , int>
    #define pil pair<int,long long>
    #define pll pair<long long,long long>
    #define vi vector<int>
    #define vl vector<long long>
    #define vb vector<bool>
    #define all(c) c.begin(),c.end()
    #define i(a,b) for( int i = a ; i < b ; ++i)
    #define j(a,b) for( int j = a ; j < b ; ++j)
	#define k(a,b) for( int k = a ; k < b ; ++k)			
    #define ri(a,b) for( int i = a ; i >= b ; --i)
    #define rj(a,b) for( int j = a ; j >= b ; --j)
    #define prod(a,b) (((ll)a)*((ll)b))
	#define ar cout << arr[i] << endl

using namespace std;

int solve(){
	int n;
	cin >> n;
	vector<double>arr(n);
	i(0,n) cin >> arr[i];
	sort(all(arr));
	double ans = arr[0];
	i(1,n) ans = (ans+arr[i])/2;
	cout << fixed;
	cout << setprecision(14) << ans << endl;
	return 0 ;
}

int main(){
	fastcin;
	int q=1;
	//cin >> q;
	while(q--){
		solve();
	}		
	return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int k = input();
    string s;
    cin >> s;

    if (s.size() <= k) {
        cout << s << endl;
    } else {
        s = s.substr(0, k) + "...";
        cout << s << endl;
    }
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
const int M=2e5+10;
int n;
int a[M];
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    sort(a,a+n);
    ll ans=0;
    for(int i=2;i<n;i++)
        for(int j=i-1;j>0 && a[i]<a[j]+a[j-1];j--)
            ans+=j-(upper_bound(a,a+n,a[i]-a[j])-a);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
sunuke=[0]*N
for i in range(K):
  d=int(input())
  A=list(map(int,input().split()))
  for j in range(d):
    sunuke[A[j]-1]+=1
result=0
for i in range(N):
  if sunuke[i]==0:
    result+=1
print(result)

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

typedef long long int LL;

int sum[11];
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    sum[a]++;
    sum[b]++;
    sum[c]++;
    if(sum[5] == 2 && sum[7] == 1)printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
cur = 0
ans1, ans2 = 0,0
for i, x in enumerate(a):
    cur += x
    if i%2 == 0:
        if cur >= 1:
            continue
        else:
            ans1 += abs(1-cur)
            cur = 1
    else:
        if cur <= -1:
            continue
        else:
            ans1 += abs(-1-cur)
            cur = -1
cur = 0
for i, x in enumerate(a):
    cur += x
    if i%2 != 0:
        if cur >= 1:
            continue
        else:
            ans2 += abs(1-cur)
            cur = 1
    else:
        if cur <= -1:
            continue
        else:
            ans2 += abs(-1-cur)
            cur = -1
print(min(ans1, ans2))

Measured memory_bytes: 14464
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

template <typename T>
constexpr bool chmin(
    T a, T b, function<bool(T, T)> f = [](T a, T b) { return a > b; }) {
  // when f is true, b is more 'smaller'
  if (f(a, b)) {
    swap(a, b);
    return true;
  }
  return false;
}
template <typename T> constexpr bool chmax(T a, T b) {
  return chmin(a, b, [](T a, T b) { return a < b; });
}
template <typename ite> void print_ite(ite start, ite end, char c = ' ') {
  for (auto i = start; i != end; i++)
    cout << i << c;
  cout << endl;
}
template <typename ite> void scan_ite(ite start, ite end) {
  for (auto i = start; i != end; i++)
    cin >> (*i);
}
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  ll n, k;
  cin >> n >> k;
  ll m = n % k;
  cout << min(m, k - m) << endl;
}


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

string S; int N, cnt;

int main() {
	cin >> N >> S;
	for (int i = 0; i < 1000; i++) {
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int f = 0;
		for (int j = 0; j < N; j++) {
			if (S[j] == ('0' + c[f])) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <iomanip>
 int main() {
  int a, b;
  std::cin >> a >> b; 
  std::cout << a/b <<std::endl;
  std::cout << a%b <<std::endl;
  double f;
  f = 1.0 * a/b;
  std::cout << std::fixed;
  std::cout << std::setprecision(5) << f <<std::endl;




 return 0;


}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N,K,Q; cin >> N >> K >> Q;
    vector<int> A(N,0);
    rep(i,Q){
        int a; cin >> a; a--;
        A[a]++;
    }
    rep(i,N){
        if(A[i]+K>Q) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	while (true) {
		int n; cin >> n;

		if (n == 0)return 0;

		if (n == 1) {
			cout << 1 << " " << 1 << endl;
		}

		map<int,pair<int,int>> m;

		m[0].first = 0;
		m[0].second = 0;

		for (int i = 1; i < n; i++) {
			
			int target;
			int direct;

			cin >> target >> direct;

			int y,x;

			y = m[target].first;
			x = m[target].second;

			if (direct == 0) {
				x--;
			}

			if (direct == 1) {
				y++;
			}

			if (direct == 2) {
				x++;
			}

			if (direct == 3) {
				y--;
			}

			m[i].first = y;
			m[i].second = x;

		}

		int minx = INF;
		int miny = INF;

		int maxx = -1000;
		int maxy = -1000;

		for (auto p : m) {
			if (p.second.first < miny) {
				miny = p.second.first;
			}

			if (p.second.second < minx) {
				minx = p.second.second;
			}

			if (p.second.first > maxy) {
				maxy = p.second.first;
			}

			if (p.second.second > maxx) {
				maxx = p.second.second;
			}
		}

		int width = maxx - minx+1;
		int height = maxy - miny+1;

		cout << width << " " << height << endl;
	}

	return 0;
}



Measured memory_bytes: 3036
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
# from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a = input()
if a.isupper():
    print("A")
else:
    print("a")


Measured memory_bytes: 9904
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
using namespace std;

bool compare(vector<int> former, vector<int> latter){
    if(former[0] == latter[0]){
        return abs(former[1]) > abs(latter[1]);
    }else return former[0] < latter[0];
}

int main(void){
    int N, Q;
    cin >> N >> Q;

    vector<vector<int>> Events;
    int Sbuf, Tbuf, Xbuf, Dbuf;

    for(int i=0; i<N; i++){
        scanf("%d %d %d", &Sbuf, &Tbuf, &Xbuf);
        Events.push_back({Sbuf-Xbuf, 1, Xbuf}); //1:insert
        Events.push_back({Tbuf-Xbuf, -1, Xbuf}); //-1:delete
    }
    for(int i=0; i<Q; i++){
        scanf("%d", &Dbuf);
        Events.push_back({Dbuf, 0, i}); //0:query
    }

    sort(Events.begin(), Events.end(), compare);

    vector<int> dist(Q);
    multiset<int> roadwork;

    for(auto event: Events){
        if(event[1] == 1)roadwork.insert(event[2]);
        else if(event[1] == -1)roadwork.erase(roadwork.lower_bound(event[2]));
        else{
            dist[event[2]] = (roadwork.empty() ? -1 : *(roadwork.begin()));
            if(event[2] == Q-1)break;
        }
    }

    for(int d: dist)cout << d << "\n";

    return 0;
}


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

using namespace std;

int a[200000][2];
int b[200000][2];

int main() {
    int n, i;
    long long ans = 1e18;
    vector <pair<int, int> > v;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        if (x > y) swap(x, y);
        
        v.push_back(make_pair(x, y));
    }
    
    sort(v.begin(), v.end());
    
    a[0][0] = a[0][1] = v[0].second;
    
    for (i = 1; i < n; i++) {
        a[i][0] = min(a[i - 1][0], v[i].second);
        a[i][1] = max(a[i - 1][1], v[i].second);
    }
    
    b[n - 1][0] = b[n - 1][1] = v[n - 1].second;
    
    for (i = n - 1; i >= 0; i--) {
        b[i][0] = min(b[i + 1][0], v[i].second);
        b[i][1] = max(b[i + 1][1], v[i].second);
    }
    
    for (i = 0; i < n; i++) {
        long long m1, m2, m3, m4;
        
        if (i == n - 1) {
            m1 = v[0].first;
            m2 = v[n - 1].first;
            m3 = a[n - 1][0];
            m4 = a[n - 1][1];
        } else {
            m1 = v[0].first;
            m2 = b[i + 1][1];
            m3 = min(a[i][0], v[i + 1].first);
            m4 = max(a[i][1], v[n - 1].first);
        }
        
        ans = min(ans, (m2 - m1) * (m4 - m3));
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 5104
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int K,S;
  cin>>K>>S;
  int ANS = 0;
  for (int i = 0; i < K+1; i++)
  {
    for (int j = 0; j < K+1; j++)
    {
      if(S - i- j >= 0 && S -i -j <= K)ANS++;
    }
    
  }
  cout<<ANS<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(15);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
	int grid[3][3];
	int naname = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			std::cin >> grid[i][j];
		}
	}

	naname = grid[0][0] + grid[1][1] + grid[2][2];

	if(naname == grid[2][0] + grid[1][1] + grid[0][2]){
		if (naname - (grid[1][2] + grid[2][0]) == grid[0][1]) {
			if (naname - (grid[0][1] + grid[2][0]) == grid[1][2]) {
				if (naname - (grid[1][0] + grid[0][2]) == grid[2][1]) {
					if (naname - (grid[0][2] + grid[2][1]) == grid[1][0]) {
						std::cout << "Yes" << std::endl;
						return 0;
					}
				}
			}
		}
	}
	std::cout << "No" << std::endl;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp

#include <iostream>
#include <vector>
using namespace std;

int main(){	
	while(1){
		int n;
		cin >> n;
		if(n == 0)break;
		string array;
		for(int i=0;i<n;i++){
			char input;
//			scanf("%c\n",&input);
			cin >> input;
			array += input;
		}

		int answer = 10000000;
		vector<int> points;
		for(int i=1;i<array.size()-1;i++){
			if(array[i-1] != array[i] || array[i+1] != array[i]){
				points.push_back(i);
			}
		}
		for(int i=0;i<points.size();i++){
			string memo = array;
			vector<char> list;
			if(memo[points[i]] == '1'){
				list.push_back('2');
				list.push_back('3');
			}else if(memo[points[i]] == '2'){
				list.push_back('1');
				list.push_back('3');
			}else{
				list.push_back('1');
				list.push_back('2');
			}
			
			for(int k=0;k<2;k++){
				memo[points[i]] = list[k];
				bool isChanged = true;
				int continuity[10001];
				continuity[0] = 1;
				while(isChanged){
					int Max = 1;
					int where = 0;
					for(int j=1;j<memo.size();j++){
						if(memo[j-1] == memo[j]){
							continuity[j] = continuity[j-1] + 1;
						}else{
							continuity[j] = 1;
						}
						if(Max != max(Max,continuity[j])){
							where = j;
							Max = max(Max,continuity[j]);
						}
					}
					if(Max >= 4){
						memo.erase(memo.begin() + where - Max + 1,memo.begin() + where + 1);
					}else{
						isChanged = false;
					}
					if(memo.size() == 0){
						isChanged = false;
					}
					
				}
				answer = min(answer,int(memo.size()));
			}
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 3264
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int ans;
  int sum = 0;
  for(int i=1;i<=N;++i) {
    sum += i;
    if(i*(i+1)>=2*N) {
      ans = i;
      break;
    }
  }
  for(int i=1;i<=ans;++i) {
    if(i==sum-N) continue;
    cout<<i<<endl;
  }
}


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

int n, a[200005], total_xor;

int main(){
    scanf("%d", &n);
    for (int i=0; i<n; ++i){
        scanf("%d", &a[i]);
        total_xor ^= a[i];
    }
    for (int i=0; i<n; ++i){
        printf("%d ", total_xor ^ a[i]);
    }
}


Measured memory_bytes: 4500
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  cout<<N*(N+1)/2<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n; cin >>n;
  ll a[n],sum=0,t=1;
  for(int i=0; i<n; i++){
    cin >>a[i];
    sum+=t*a[i]; t*=-1;
  }
  for(int i=0; i<n; i++){
    cout <<sum<<' ';
    if(i-n+1) sum=sum*-1+2*a[i];
  }
}

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

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

int main(){
	string s,t;
	int sl,tl;
	int max = 0,count,i,j;

	cin >> s;
	cin >> t;
	sl = (int)s.size();
	tl = (int)t.size();
	for(i = 0; i <= sl-tl; i++){
		count = 0;
		for(j = 0; j < tl; j++){
			if(s[i+j] == t[j]){
				count++;
			}
		}
		if(count > max){
			max = count;
		}
		if(max == tl){
			break;
		}
	}

	cout << tl - max;

	return 0;

}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int N, A, B, C,D;
	cin >> N >> A >> B >> C >> D;
	string S;
	cin >> S;
	int t;
	bool check=true;
	bool check2 = false;
	for (t = A-1; t < max(C,D); t++) {
		if (S[t] == '#') {
			if (S[t + 1] == '#')
				check = false;
		}
	}
	if (C > D) {
		for (t = B - 1; t < D ; t++) {
			if (S[t-1] == '.'&&S[t] == '.'&&S[t + 1] == '.')
				check2 = true;
		}
		if (check2 != true)
			check = false;
	}

	if (check)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 640
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-06-05 15:25
# @url:https://atcoder.jp/contests/abc169/tasks/abc169_d
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    n=int(input())
    #判断n是否为素数
    def isprime(n):
        if n <= 1:
            return 0
        for x in range(2,int(math.sqrt(n))+1):
            if n%x == 0:
                return 0
        return 1
    #利用递归分解n并打印质因数
    ans=[]
    def bprime(n):
        if isprime(n):
            ans.append(n)
        else:
            x = 2
            while x <= int(n/2):
                if n%x == 0:
                    ans.append(x)
                    return bprime(n//x)
                x = x + 1
    bprime(n)
    # print (ans)
    d=collections.Counter(ans)
    mx=0
    for k in d.keys():
        i=1
        v=d[k]
        cnt=0
        while v>0:
            v=v-i
            i=i+1
            cnt+=1
        if v==0:
            mx+=cnt
        else:
            mx+=(cnt-1)
    print (mx)
if __name__ == "__main__":
    main()

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

using ll = long long;

template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}

int main()
{
    ll N, W; cin >> N >> W;
    vector<ll> w(N), v(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    ll ans = 0;
    vector<map<ll, ll>> dp(N+1); // key:w, value:v
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        dp[i+1] = dp[i];
        for (auto it = dp[i].rbegin(); it != dp[i].rend(); it++) {
            ll sum_w = it->first + w[i];
            if (sum_w <= W) {
                ll sum_v = it->second + v[i];
                if (chmax(dp[i+1][sum_w], sum_v)) {
                    chmax(ans, sum_v);
                }
            }
        }
    }

    cout << ans << endl;    
}


Measured memory_bytes: 6400
while True:
    n = int(raw_input())
    if n==0:
        break
    lsum = sum(map(int, raw_input().split()))
    j = map(int, raw_input().split())
    lsum += sum(j)
    j.sort()
    ans = lsum
    for i in xrange(0,n-1):
        lsum -= j[i]
        ans = max(ans, lsum*(i+2))
    print ans

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

#define MAXX 100005
int dp[MAXX];

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

    int i, cnt = 0, x, z, n, minn = 10000000, maxx = 0;
    cin>>n;
    int arr[n];
    for(i = 0; i < n; i++)
    {
        cin>>arr[i];
        dp[arr[i]]++;
        minn = min(minn, arr[i]);
        maxx = max(maxx, arr[i]);
    }
    for(i = 1; i < min(MAXX, maxx+5); i++)
    {
        dp[i] = dp[i] + dp[i-1];
    }
    for(i = minn; i < maxx; i++)
    {
        x = dp[i];
        z = n - x;
        if(x == z)
        {
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 1024
import re
sd = input()
ts =  input()

def f():
    for i in range(len(sd) - len(ts) + 1):
        p = sd[len(sd) - i - len(ts):len(sd) - i]
        pat = re.compile(p.replace('?', '.'))
        if re.match(pat, ts):
            lsd = list(sd)
            lsd[len(sd) - i - len(ts):len(sd) - i] = list(ts)
            print(''.join(lsd).replace('?', 'a'))
            return
    print('UNRESTORABLE')
f()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
int main()
{
	int n,k;
	cin>>n>>k;
	vl a;
	for(int i=0;i<n;i++)
	{
		int k;
		cin>>k;
		a.push_back(k);
	}
	sort(a.begin(),a.end());
	ll ans = 1e15;
	for(int i=0;i<n;i++)
	{
		if(i+k-1<n)
		{
			ans = min(ans,(a[i+k-1]-a[i]));
		}
	} 
	cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

vector<vector<int>> child(100001);

int depth(int n) {
	if (child[n].empty()) return 0;
	map<int, int> dcnt;
	for (auto itr = child[n].begin(); itr != child[n].end(); itr++) {
		dcnt[depth(*itr)]++;
	}
	int ret = 0, sum = 0;
	for (auto itr = dcnt.rbegin(); itr != dcnt.rend(); itr++) {
		sum += itr->second;
		ret = max(ret, itr->first + sum);
	}
	return ret;
}

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

	for (int i = 2; i <= N; i++) {
		int a;
		cin >> a;
		child[a].push_back(i);
	}

	cout << depth(1) << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 18424