akhauriyash/Code-Regression huggingface dataset:
//Create Time: 2018-04-27 16:24:16
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <functional>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#include <complex>
#include <cassert>
#include <climits>
#include <iterator>
#include <tuple>
using namespace std;
#define snuke(i,x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
// #define OUT(x) std::cout<<(#x)<<":"<<(x)<<std::endl
// #define TST(x) std::cout<<(#x)<<":"<<(x)<<" "
#define OUT(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("\n",_it,args);}
#define TST(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("",_it,args);}
#define SZ(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define unq(x) sort(all(x)),(x).erase(unique(all(x)),(x).end())
#define mem(f,x) memset((f), (x), sizeof(f))
#define clr(f) mem(f,0)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define DEBUG
void OUT_TST(string s,istream_iterator<string> it) {cerr<<s;}
template<typename T, typename... Args> void OUT_TST(string s,istream_iterator<string> it,T a,Args... args){cerr<<*it<<"="<<a<<" ";OUT_TST(s,++it,args...);}
template<class T> void rd(T&ret){ret=0;bool ok=0,u=0;for(;;){int c=getchar();if(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',ok=1;else if(c=='-')u=1;else if(ok){if(u)ret*=-1;return;}}}
long long powmod(long long p,long long n,long long mod){long long ret=1;for(;n;n>>=1){if(n&1)ret=ret*p%mod;p=p*p%mod;}return ret;}
template <class T> bool chmin(T& a, const T &b) {return b < a? a = b, 1: 0;}
template <class T> bool chmax(T& a, const T &b) {return b > a? a = b, 1: 0;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef tuple<int,int,int> tp;
/****head****/
const int N=200009;
vi v;
int an[N],bn[N];
ll find(int x,int y){
    return lower_bound(all(v),y) - lower_bound(all(v),x);
}
int main(){
    int n;cin>>n;
    rep(i,0,n)scanf("%d",an+i);
    rep(i,0,n)scanf("%d",bn+i);
    int ans=0;
    for(int s=2;s<=(1<<29);s<<=1){
        v.clear();
        rep(i,0,n)v.pb(bn[i]%s);
        sort(all(v));
        ll cnt=0;
        rep(i,0,n){
            int t=an[i]%s;
            if(s/2>t) cnt+=find(s/2-t,s-t);
            else cnt+=find(0,s-t) + find(s/2*3-t,s);
        }
        // OUT(s,cnt);
        if(cnt&1)ans|=s/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2936
#include<stdio.h>


typedef struct{
	int v;
	int l,r;
}node;

int check(int a[],int n){
	int i;
	for(i=0;i<n;i++){
		if(a[i]==0)return 0;
	}
	return 1;
} 

void searchRoot(int v[],int id,node t[]){
	if(id==-1)return;
	v[id]=1;
	searchRoot(v,t[id].l,t);
	searchRoot(v,t[id].r,t);
}

void search(int key,int id,node t[],int p,int s,int d){
	if(id==-1)return;
	if(key==id){
		int count=0;
		if(t[key].l!=-1)count++;
		if(t[key].r!=-1)count++;
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, ",key,p,s,count,d);
		return;
	}
	search(key,t[id].l,t,id,t[id].r,d+1);
	search(key,t[id].r,t,id,t[id].l,d+1);
}

int max(int a,int b){
	if(a>b)return a;
	return b;
}

int searchH(int key,node t[]){
	if(key==-1)return -1;
	return max(searchH(t[key].l,t),searchH(t[key].r,t))+1;
}


int main(void){
	node tree[26];
	int visit[26];
	int n,id,l,r;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&id,&l,&r);
		tree[id].l=l;
		tree[id].r=r;
		visit[id]=0;
	}
	int root;
	for(i=0;i<n;i++){
		searchRoot(visit,i,tree);
		if(check(visit,n)==1){
			root=i;
			break;
		}
	}
	int maxH;
	for(i=0;i<n;i++){
		search(i,root,tree,-1,-1,0);
		printf("height = %d, ",searchH(i,tree));
		if(root==i)printf("root");
		else if(tree[i].r==-1&&tree[i].l==-1)printf("leaf");
		else printf("internal node");
		printf("\n");
	}
	
	return 0;
}


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

using namespace std;

int main() {
  int i, N;
  int count=0;
  cin >> N;
  int arr[N], T[N];
  for(i=0;i<N;i++){
    cin >> arr[i];
    T[i] = arr[i];
  }
  sort(arr, arr+N);
  for(i=0;i<N;i++){
    if(arr[i]!=T[i]){
      count++;
    }
  }
  if(count>2){
    cout << "NO";
  } else cout << "YES";

}

Measured memory_bytes: 256
// Shift-JIS（シフトジス）

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

int main()
{
    int A, B;
    cin >> A >> B;
    if (6 <= A && A <= 12) {
        cout << B / 2 << endl;
    } else if (A < 6) {
        cout << 0 << endl;
    } else {
        cout << B << endl;
    }
}

Measured memory_bytes: 256
T=0
H=0
n=int(input())
for i in range(n):
    s=input()
    s=s.rstrip().split()
    if s[0]==s[1]:
        T+=1
        H+=1
    else:
        t=[s[0],"t"]
        h=[s[1],"h"]
        S=[t,h]
        S.sort()
        if S[1][1]=="t":
            T+=3
        elif S[1][1]=="h":
            H+=3
print(T,H)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main(){

    string s;
    cin>>s;

    lli maxLength=0;

    for(lli i=0;i<s.size();i++){
        for(lli j=i;j<s.size();j++){
            bool ok=true;
            for(lli k=i;k<=j;k++){
                if(s[k]!='A' && s[k] != 'G' && s[k] != 'C' && s[k] != 'T'){
                    ok= false;
                    break;
                }
            }
            if(ok){
                chmax(maxLength,j-i+1);
            }
        }
    }
    cout<<maxLength<<endl;


 
    return 0;
}

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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //int TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, t;
    cin >> n >> t;
    int a[n + 1];
    rep(i, 0, n)
        cin >> a[i];
    a[n] = inf * 2;
    ll ans = 0;
    rep(i, 0, n)
        ans += min(t, a[i + 1] - a[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(n)    for(int i = 0; i < (n); ++i)
#define RREP(n)   for(int i = (n); i >= 0; --i)
#define FOR(m, n) for(int i = (m); i < (n); ++i)
#define SZ(x)       ( (int)(x).size() )
#define BIT(n)      ( 1LL << (n) )
#define EXIST(x)    ( (x).find()		!= (x).end() )
#define DEBUG(n)    cerr << #n << " : " << n << '\n';
#define PB  push_back
#define MP  make_pair
#define UB  upper_bound			//k <
#define LB  lower_bound			//k	<= 
#define F   first
#define S   second
#define INF 1.0e9


using namespace std;

typedef long long			ll;
typedef pair<int, int>		pii;
typedef pair<long long, long long>   pll;
typedef vector<int>			vi;
typedef vector<double>		vd;
typedef vector<long long>   vll
;

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

int r_up(const int a, const int b){ return (a + b - 1) / b; }

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

struct UFT{
  vi	p;
  UFT(){}
  UFT(int N)       { p.resize( N, -1 ); }
  int	par(int a)   { if( p[a] >= 0 ){ p[a]  = par( p[a] ); return p[a]; } return a;  }
  int size(int a)  { return -p[par(a)]; }
  bool	same(int a, int b) { return par(a)	 == par(b); }
  void unite(int	a, int b){
	a													  = par(a);  b = par(b);
	if( a == b ) return;
	if( size(a) < size(b) ) swap(a,b);
	p[a]												 -= size(b);
	p[b]												  = a;
  }
};

int n,k;


int main(){
  cin>>n>>k;
  vector<pll> vp;
  REP(n){
	ll x,y;cin>>x>>y;
	vp.PB(MP(y,x));
  }
  sort(vp.rbegin(),vp.rend());

  vll ans(n+1,0);
  vi typ(n+1,0);
  ll cnt=0;
  
  ll tmp=0;

  REP(k){
	tmp+=vp[i].F;
	if(typ[vp[i].S]==0)cnt++;
	typ[vp[i].S]++;
  }
  ans[cnt]=tmp+cnt*cnt;

  
  while(1){
	int org=-1,tar=-1;
	FOR(k,n)
	  if(typ[vp[i].S]==0){tar=i;break;}
	RREP(k-1)
	  if(typ[vp[i].S]>1){org=i;break;}

	if(org>-1&&tar>-1){
	  typ[vp[org].S]--; typ[vp[tar].S]++;
	  tmp-=vp[org].F;
	  tmp+=vp[tar].F;
	  swap(vp[org],vp[tar]);
	  vp.erase(vp.begin()+k,vp.begin()+tar);
	  cnt++;
	  ans[cnt]=tmp+cnt*cnt;
	}
	else break;
  }

  sort(ans.rbegin(),ans.rend());
  cout<<ans[0]<<endl;

  
  return 0;
}


Measured memory_bytes: 2928
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  int N, M;
  int A[10000];

  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++)
  {
    scanf("%d", A + i);
  }

  int sum = 0;
  for (int i = 0; i < M; i++)
  {
    sum += A[i];
  }

  if (sum > N)
  {
    printf("-1");
  }
  else
  {
    printf("%d", N - sum);
  }

  return 0;
}


Measured memory_bytes: 1772
import java.io.*;
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //String[] buf = reader.readLine().split(" ");
        String s = sc.next();
        int i = 0, len = s.length();
        StringBuilder sb = new StringBuilder();
        String temp = "BC";
        while(i<len){
            if(i<len-1&&s.substring(i,i+2).equals(temp)){
                sb.append("D");
                i += 2;
            } else{
                sb.append(s.charAt(i));
                i++;
            }
        }
        long ans = help(sb.toString().toCharArray());
        System.out.println(ans);
    }
    static long help(char[] sb){
        int i=0,len = sb.length;
        long ans = 0;
        while(i<len){
            if(sb[i]=='B'||sb[i]=='C') i++;
            else{
                int j = i+1;
                while(j<len&&(sb[j]=='A'||sb[j]=='D')) j++;
                long temp = 0, A = 0;
                for(int idx=i;idx<j;idx++){
                    if(sb[idx]=='A') A++;
                    else temp += A;
                }
                ans += temp;
                i = j;
            }
        }
        return ans;
    }
}



Measured memory_bytes: 37008
def lcs(x, y):
    a = len(x)
    b = len(y)
    c1 = [0] * (b + 1)
    for i in range(a):
        e1 = x[i]
        c2 = c1[:]#スライス
        for j in range(b):
            if e1 == y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
    
n = int(input().rstrip())#rstripで余計な空白削除
ret = []
for i in range(n):
    s1 = input().rstrip()
    s2 = input().rstrip()
    ret.append(lcs(s1, s2))
print(*ret, sep="\n")



Measured memory_bytes: 5632
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    // buy a and b => buy ab;
    if(2*c-a-b >= 0){
        cout << a*x + b*y << endl;;
    }else{
        int64_t cprice = c*2*min(x,y);
        int64_t remain = max(x,y) - min(x,y);
        if((x>y?a:b)<=c*2){
            cout << cprice + remain * (x>y?a:b) << endl;
        }else{
            cout << cprice + remain * c*2 << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int a=0;
    string s;
    cin>>s;
    for(int i=0;i<4;i++){
        if(s[i]=='+')a++;
        if(s[i]=='-')a--;
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
  
if a <= b <= c:
    print(a, b, c)
  
elif a <= c <= b:
    print(a, c, b)
  
elif b <= a <= c:
    print(b, a, c)
  
elif b <= c <= a:
    print(b, c, a)
  
elif c <= a <= b:
    print(c, a, b)
  
else:
    print(c, b, a)

Measured memory_bytes: 6724
/* Manish Pant - insider_pants */

#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.h"
#endif

#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main()
{
    fast();
    int n; cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++)
    {
        int a; cin >> a;
        v.pb(a);
    }
    
    if(n == 2)
    {
        cout << v[1] << ' ' << v[0] << endl;
        return 0;
    }

    int x = 0;
    for(int i = 1; i < n; i++)
        x ^= v[i];

    vector<int> ans(n);
    ans[0] = x;

    int temp = v[0] ^ x;
    for(int i = 1; i < n; i++)
    {
        ans[i] = v[i] ^ temp;
    }

    for(int i = 0; i < n; i++)
        cout << ans[i] << ' ';
    cout << endl;

}

Measured memory_bytes: 4920
import sys
import numpy as np



class grid:
  def __init__(self, debug=False):
    # admit stdin
    hw = input().split()
    self.H = int(hw[0])
    self.W = int(hw[1])

    self.circuit = [[1,0],[1,-1],[0,-1],[-1,-1],[-1,0],[-1,1],[0,1],[1,1]]
    
    # char decomp, loop accessed as g[row][col]
    self.g = [[self.__rep2int(c) for c in input()] for j in range(self.H)]
    if debug:
      print(self.g)

  def __rep2int(self, c):
    return 0 if c=='.' else 1

  def __onBomb(self, i, j):
    return self.g[i][j]==1

  def __circuitSum(self, i, j, array):
    val = 0
    for delta in self.circuit:
      I = i+delta[0]
      J = j+delta[1]
      # if the circuit contains the coordinate out of the grid, do nothing
      if any([I<0, I>=self.H]) or any([J<0, J>=self.W]):
        continue
      else:
        val += array[I][J]
    return val

  def CountBombs(self):
    # tempg = ['' for j in range(self.H)]
    out_text = ''
    # sum
    for i in range(self.H):
      for j in range(self.W):
        # tempg[i] += '#' if self.__onBomb(i,j) else str(self.__circuitSum(i,j,self.g))
    # return tempg
        out_text += '#' if self.__onBomb(i,j) else str(self.__circuitSum(i,j,self.g))
      out_text += '\n'
    return out_text

g=grid()
print(g.CountBombs())


Measured memory_bytes: 11976
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int N, arr[100005], Left[100005], Right[100005], result;

int gcd(int a, int b)
{
    if(b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d", &arr[i]);
    }
    Left[0] = arr[0];
    for(int i = 1; i < N; i++)
    {
        Left[i] = gcd(Left[i - 1], arr[i]);
    }
    Right[N - 1] = arr[N - 1];
    for(int i = N - 2; i >= 0; i--)
    {
        Right[i] = gcd(Right[i + 1], arr[i]);
    }
    result = max(Left[N - 2], Right[1]);
    for(int i = 1; i < N - 1; i++)
    {
        result = max(result, gcd(Left[i - 1], Right[i + 1]));
    }
    printf("%d", result);
}

Measured memory_bytes: 1408
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	int x, y, z;
	int s, ans;
	scanf("%d %d", &x, &y);


	if(x<y)printf("0\n");
	else printf("10\n");


	return 0;
}


Measured memory_bytes: 128
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//
 
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
 
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer return cout << 0, 0;
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)
 
const long long MXN = 1e6 + 200;
const long long MNN = 1e4 + 520;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;
 
typedef long long llong;
typedef unsigned long long ullong;
 
using namespace std;

int n;
llong dp[3100][3100];
string s;

int main (){
    ios;
    cin >> n;
    cin >> s;
    s = "##" + s;
    dp[1][1] = 1;
    for(int pr = 2; pr <= n; pr++){
        vector<int> v(pr + 1, 0);
        for(int j = 1; j <= pr - 1; j++){
            v[j] = (v[j - 1] + dp[pr - 1][j]) % MOD;
        }
        for(int b = 1; b <= pr; b++){
            int l, r;
            if(s[pr] == '<'){
                l = b, r = pr - 1;
            }else{
                l = 1, r = b - 1;
            }
            dp[pr][b] = (dp[pr][b] + v[r] - v[l - 1] + MOD) % MOD;
        }
    }
    llong ans = 0;
    for(int i = 1; i <= n; i++) ans = (ans + dp[n][i]) % MOD;
    cout << ans;
}


Measured memory_bytes: 72320
#77c
from bisect import bisect_left, bisect_right

N = int(input())

A_list = list((int(e) for e in input().split()))
B_list = list((int(e) for e in input().split()))
C_list = list((int(e) for e in input().split()))

A_list.sort(reverse=False)
B_list.sort(reverse=False)
C_list.sort(reverse=False)

ans = 0

#上から考える場合
#for i in range(N):
#    #print(A_list[i])
#    index_right = bisect_right(B_list, A_list[i])
#    for j in range(index_right,N):
#        index_right = bisect_right(C_list, B_list[j])
#        #print(":",B_list[j],N - index_right)
#        ans += N - index_right

#中段から考える場合
for i in range(N):
    middle_size = B_list[i]
    top_count = bisect_left(A_list, middle_size)
    lower_count = N - bisect_right(C_list, middle_size)
    
    #print(B_list[i],top_count,lower_count)
    
    ans += top_count * lower_count

print(ans)

Measured memory_bytes: 23360
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int n,a,cnt[N],maxd,ans;
int main(){
	int t;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a),cnt[a]++,maxd=max(maxd,a);
	}
	for(int i=0;i<=maxd;i++){
		t=cnt[i]+cnt[i+1];
		if(i>0) t+=cnt[i-1];
		ans=max(ans,t);
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/

int main(){
    string s, t; cin >> s >> t;
    int n = t.size();
    string u = t.substr(0, n - 1);
    if(s == u) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 3628
import java.util.*

fun main(args: Array<String>) {
  val (N, M) = readInts()
  val A = readInts()

  val queue: Queue<Int> = PriorityQueue<Int>(N) { a, b -> b - a }
  queue.addAll(A)
  for (i in 0 until M) {
    val e = queue.poll()
    queue.add(e / 2)
  }
  var sum = 0L
  queue.forEach { sum += it }
  println(sum)
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 69984
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>

#define ll long long int
#define loop(v,n) for(ll v=0;v<n;v++)

using namespace std;

constexpr ll mod = 998244353;

int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll sum[200001][2];//#:0
    sum[0][0] = 0;
    sum[0][1] = 0;
    loop(i,n) {
        if(s[i] == '#') {
            sum[i+1][0] = sum[i][0] + 1;
            sum[i+1][1] = sum[i][1];
        }
        if(s[i] == '.') {
            sum[i+1][0] = sum[i][0];
            sum[i+1][1] = sum[i][1] + 1;
        }
    }
    ll res = 200000;
    loop(i,n+1) {
        res = min(res,(sum[i][0]+(sum[n][1] - sum[i][1])));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		while (true) {
			int n = Integer.parseInt(reader.readLine());
			if (n == 0) {
				break;
			}
			int[] nums = new int[n];
			for (int i = 0; i < n; i++) {
				nums[i] = Integer.parseInt(reader.readLine());
			}
			int max = Integer.MIN_VALUE;
			int sum = 0;
			for (int i = 0; i < n; i++) {
				sum = nums[i];
				for (int j = i; j < n; j++) {
					if (j != i)
						sum += nums[j];
					max = Math.max(max, sum);
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 21900
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    if(b/a >= c){
        printf("%d", c);
    } else {
        if(b/a < c){
            printf("%d", b/a);
        } else {
            printf("0");
        }
    return 0;
    }
}


Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }


const INF: i64 = 1 << 50;

fn solve() {
    loop {
        let w: usize = get();
        let h: usize = get();
        if w == 0 && h == 0 { break; }
        let mut g = vec![Vec::new(); w * h];
        for i in 0 .. h {
            for j in 0 .. w - 1 {
                let a: i32 = get();
                if a == 0 {
                    g[i * w + j].push(i * w + j + 1);
                    g[i * w + j + 1].push(i * w + j);
                }
            }
            if i + 1 < h {
                for j in 0 .. w {
                    let a: i32 = get();
                    if a == 0 {
                        g[i * w + j].push(i * w + j + w);
                        g[i * w + j + w].push(i * w + j);
                    }
                }
            }
        }
        let mut dist = vec![INF; w * h];
        let mut que = VecDeque::new();
        que.push_back((0, 0));
        while let Some((v, d)) = que.pop_front() {
            if dist[v] <= d { continue; }
            dist[v] = d;
            for &w in &g[v] {
                que.push_back((w, d + 1));
            }
        }
        println!("{}", if dist[w * h - 1] >= INF { 0 } else { dist[w * h - 1] + 1 });
    }
}
    
fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 9080
s= list(input())

abc = "abcdefghijklmnopqrstuvwxyz"

ans = len(s)

for a in abc:
    if a in s:
        t = s.index(a)
        anst = t
        for i in range(t+1, len(s)):
            if s[i] == a:
                anst = max(anst, i - t - 1)
                t = i

        anst = max(anst, len(s) - t - 1)

        ans = min(ans, anst)

print(ans)

Measured memory_bytes: 9100
from bisect import bisect

def ctoi(c):
    return ord(c) - ord('a')

def solve():
    S = input()
    T = input()
    N = len(S)
    idx = [[] for i in range(26)]
    for i in range(2 * N):
        idx[ctoi(S[i % N])].append(i)
    ans = -1
    for c in T:
        if not idx[ctoi(c)]:
            return -1
        ans += idx[ctoi(c)][bisect(idx[ctoi(c)], ans % N)] - ans % N
    return ans + 1
print(solve())


Measured memory_bytes: 17896
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int x,y,z,k;;
	int a[1111],b[1111],c[1111];
	cin>>x>>y>>z>>k;
	//vector<int> a,b,c;
	rep(i,x){
		cin>>a[i];
	}
	rep(i,y){
		cin>>b[i];
	}
	rep(i,z){
		cin>>c[i];
	}
	vector<int> v,v2,v3;
	for(int i=0;i<x;i++){
		for(int j=0;j<y;j++){
			v.push_back(a[i]+b[j]);
		}
	}
	sort(v.begin(),v.end(),greater<int>());
	for(int i=0;i<min(k,(int)v.size());i++)v2.push_back(v[i]);
	for(int i=0;i<min(k,(int)v.size());i++){
		for(int j=0;j<z;j++){
			v3.push_back(v2[i]+c[j]);
		}
	}
	sort(v3.begin(),v3.end(),greater<int>());
	for(int i=0;i<k;i++)cout<<v3[i]<<endl;

}

Measured memory_bytes: 43268
#include<stdio.h>
int main()
{
	long long int x, k, d;
	scanf("%lld %lld %lld", &x, &k, &d);
	if (x < 0)
		x *= -1;
	if (x / d > k)
	{
		printf("%lld\n", x - k * d);
		return 0;
	}
	k -= x / d;
	x %= d;
	if (k % 2 > 0)
		printf("%lld\n", d - x);
	else
		printf("%lld\n", x);
	return 0;
}

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

int main(){
    int L,R,d;
    cin>>L>>R>>d;
    cout<<(R/d-(L-1)/d)<<endl;
}


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

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

Measured memory_bytes: 38488
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n)
    Cins(int, n, a);
    Sort(a);
    Cout(a[n-1] - a[0]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define M 2010
#define N 1010
#define pb emplace_back
#define mo 1000000007
#define mr make_pair
using namespace std;
struct Info{int x,y,z;}a[M],b[M];
int m,n,f[N],nb,fa[N];
vector<pair<int,int> > e[N];
ll S,su,d[N],ans;
bool c1(const Info &x,const Info &y){return x.z<y.z;}
int que(int x){if (f[x]!=x)f[x]=que(f[x]);return f[x];}
ll po(ll x,ll y){ll z=1;while (y){if (y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
void jb(int x,int y,int z){e[x].pb(mr(y,z));e[y].pb(mr(x,z));}
void dfs(int x,int f){
	fa[x]=f;
	for (auto y:e[x])if(y.first!=f){d[y.first]=d[x]+y.second;dfs(y.first,x);}
}
int que(int x,int y){
	ll ma=0;
	while (x!=y){
		if (d[x]<d[y]) swap(x,y);
		ma=max(ma,d[x]-d[fa[x]]);
		x=fa[x];
	}
	return ma;
}
int main(){
	cin>>n>>m>>S;
	for (int i=1;i<=m;i++){cin>>a[i].x>>a[i].y>>a[i].z;}
	sort(a+1,a+m+1,c1);
	for (int i=1;i<=n;i++)f[i]=i;
	for (int i=1;i<=m;i++){
		int nx=que(a[i].x),ny=que(a[i].y);
		if (nx!=ny)f[nx]=ny,su+=a[i].z,jb(a[i].x,a[i].y,a[i].z);
		else b[++nb]=a[i];
	}
	dfs(1,0);
	if (su==S)ans=(po(2,n-1)+mo-2)*po(2,m-n+1)%mo;
	for (int i=1;i<=nb;i++)b[i].z-=que(b[i].x,b[i].y);
	sort(b+1,b+nb+1,c1);
	for (int i=1;i<=nb;i++)if (su+b[i].z==S)ans=(ans+po(2,nb-i+1))%mo;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
  int N,i;
    scanf("%d\n",&N);
  
  double sum=0,x[N];
  char u[N][N];
  
  for(i=0;i<N;i++){
    scanf("%lf %s\n",&x[i],u[i]);
  }
  for(i=0;i<N;i++){
    if(u[i][0]=='B'){
      sum=sum+x[i]*380000.0;
    }
    else{
      sum=sum+x[i];
    }
  }
  
    printf("%lf\n",sum);
  return 0;
}
  

Measured memory_bytes: 128
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);

typedef vector<vvi> vvvi;
int main(){
	int n,K;
	cin>>n>>K;
	vi x,y,d;
	vi x1(n),y1(n),d1(n);
	vi x2(n),y2(n),d2(n);
	REP(i,n){
		cin>>x1[i]>>y1[i]>>d1[i];
		cin>>x2[i]>>y2[i]>>d2[i];
		x.push_back(x1[i]);
		x.push_back(x2[i]);
		y.push_back(y1[i]);
		y.push_back(y2[i]);
		d.push_back(d1[i]);
		d.push_back(d2[i]);
	}
	sort(ALL(x));
	sort(ALL(y));
	sort(ALL(d));
	x.erase(unique(ALL(x)),x.end());
	y.erase(unique(ALL(y)),y.end());
	d.erase(unique(ALL(d)),d.end());
	
	vvvi f(x.size(),vvi(y.size(),vi(d.size())));
	REP(i,n){
		REP(j,x.size()-1){
		REP(k,y.size()-1){
		REP(l,d.size()-1){
			if(x1[i]<=x[j]&&x[j+1]<=x2[i]&&
			y1[i]<=y[k]&&y[k+1]<=y2[i]&&
			d1[i]<=d[l]&&d[l+1]<=d2[i]){
				f[j][k][l]++;
			}
		}
		}
		}
	}
	ll ans=0;
	REP(j,x.size()-1){
	REP(k,y.size()-1){
	REP(l,d.size()-1){
		if(f[j][k][l]>=K){
			ans+=(ll)(x[j+1]-x[j])*(y[k+1]-y[k])*(d[l+1]-d[l]);
			//cerr<<"x"<<x[j]<<"-"<<x[j+1]<<endl;
			//cerr<<"y"<<y[k]<<"-"<<y[k+1]<<endl;
			//cerr<<"d"<<d[l]<<"-"<<d[l+1]<<endl;
		}
	}
	}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5492
<?php

$stdin = fopen('php://stdin', 'r');

$buf = fgets($stdin);
$buf = trim($buf);

if (strtolower($buf) == 'a' ||
    strtolower($buf) == 'i' ||
    strtolower($buf) == 'u' ||
    strtolower($buf) == 'e' ||
    strtolower($buf) == 'o') {
    echo 'vowel';
} else {
    echo 'consonant';
}




Measured memory_bytes: 3576
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var mod = 2019;
            var counts = new long[mod];
            var sum = 0;
            var digit = 1;
            var count = 0L;
            counts[sum]++;
            for (var i = 0; i < s.Length; i++)
            {
                sum = (sum + (s[s.Length - 1 - i] - '0') * digit) % mod;
                counts[sum]++;
                digit = (digit * 10) % mod;
            }
            for (var i = 0; i < counts.Length; i++)
            {
                count += (counts[i] * (counts[i] - 1)) / 2;
            }
            Console.WriteLine(count);
        }
    }
}


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

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int N = 2e5 + 10;
const int mod = 1e9 + 7;

// LL a[N], b[N];
// LL sa[N], sb[N];
// int n, m, k;

// int func(int v)
//{
// if (v >= sb[m]) return m;
// if (v < sb[1]) return 0;

// int lo = 1, hi = m;
// while (lo + 1 < hi)
//{
// int mid = (lo + hi) / 2;
// if (v >= sb[mid])
// lo = mid;
// else
// hi = mid;
//}

// if (v >= sb[hi]) return hi;
// return lo;
//}

//最小素因子
const int MAX = 1E7;
bool isprm[MAX + 10];
int prm[MAX + 10], fac[MAX + 10];

int n;

int minfac(int n)
{
    fac[1] = 1;
    clr(isprm, true);
    int cnt = 0;
    for (int i = 2; i <= n; i++)
    {
        if (isprm[i]) prm[++cnt] = fac[i] = i;
        for (int j = 1; j <= cnt && (LL)i * prm[j] <= n; j++)
        {
            isprm[i * prm[j]] = false;
            fac[i * prm[j]] = prm[j];
            if (i % prm[j] == 0) break;
        }
    }
    return cnt;
}

LL fun(int v)
{
    LL ret = 1;
    while (v != 1)
    {
        int c = 0;
        int p = fac[v];
        while (v % p == 0)
        {
            v /= p;
            c++;
        }
        ret = ret * (c + 1);
    }
    return ret;
}

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    minfac(MAX);
    while (~scanf("%d", &n))
    {
        LL ans = 1;
        for (int i = 2; i <= n; i++)
        {
            LL v = fun(i);
            LL vv = 1ll * i * v;
            ans += vv;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 55120
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]

ans = []
ans.append(sum(a[0]) + a[1][n - 1])
for i in range(n - 2, -1, -1):
    ans.append(ans[n - 2 - i] - a[0][i + 1] + a[1][i])

print(max(ans))

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

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
//#define int long long
#define ll long long
#define endl "\n"
#define inf ULLONG_MAX
#define gcd __gcd
#define deb(x) cout << #x << " " << x << endl;
#define pr(x) cout << x << endl;

#define sz(a) ((ll)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())
#define cpres(c, val) (find(all(c), val) != (c).end())
#define dec greater<ll>()
#define sortv(x) sort(all(x))
#define revsortv(x) sort(all(x), dec)
#define com(x) ((x) * (x + 1) / 2)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define ed end()
#define bs binary_search // to find if an element is present or not in Ologn time, return a boolean
#define ub upper_bound   // to find an element strictly greater than the given no.
#define lb lower_bound   // lb(v,begin(), v.end(), n) gives the iterator

#define fo(n) for (ll i = 0; i < n; i++)
#define fo1(n) for (ll i = 1; i < n; i++)
#define fo2(i, n) for (ll i = 0; i < n; i++)
#define fo3(i, a, b) for (ll i = a; i < b; i++)
#define fors(a) cin >> a[i]
#define forp(a) cout << a[i] << " "
#define prv(a, n)  \
    fo(n) forp(a); \
    cout << endl;
#define fob(i, a, b) for (ll i = (b); i >= (a); i--)

typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef unordered_map<string, ll> umsl;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;

#define scan(v, n)   \
    vl v;            \
    fo(n)            \
    {                \
        ll item;     \
        cin >> item; \
        v.pb(item);  \
    }

const ll INF = 0xFFFFFFFFFFFFFFFL;;
const ll N = 1e9 + 7;
void swap1(ll a,ll b){
    ll temp;
    temp=a;
    a=b;
    b=temp;
}
void solve()
{
string s;
cin>>s;
if(s=="ABC")cout<<"ARC";
else cout<<"ABC";

}

int32_t main(int32_t argc, char **argv)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif*/

    ll t;
   // cin >> t;
    t=1;
   while (t--)
        solve();

    cerr << endl
         << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

    return 0;
}

Measured memory_bytes: 3792
h,w = map(int,input().split())
masu = []
for _ in range(h):
    masu.append(list(str(input())))

ans = 0
dp = [[0]*w for i in range(h)]
if masu[0][0] == "#":
    dp[0][0] = 1

for i in range(1,h):
    if masu[i][0] != masu[i-1][0] and masu[i][0]=="#":
        dp[i][0] = dp[i-1][0]+1
    else:
        dp[i][0] = dp[i-1][0]

for j in range(1,w):
    if masu[0][j] != masu[0][j-1] and masu[0][j]=="#":
        dp[0][j] = dp[0][j-1]+1
    else:
        dp[0][j] = dp[0][j-1]


for i in range(1,h):
    for j in range(1,w):
        if masu[i][j] != masu[i-1][j] and masu[i][j]=="#":
            tate = dp[i-1][j]+1
        else:
            tate = dp[i-1][j]

        if masu[i][j] != masu[i][j-1] and masu[i][j]=="#":
            yoko = dp[i][j-1]+1
        else:
            yoko = dp[i][j-1]

        dp[i][j] = min(tate,yoko)


# print(*dp,sep="\n")
print(dp[-1][-1])

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

using namespace std;

typedef long long LL;
int MOD = 1000000007;

int N,A,B,C,D;
LL F[1010][1010];
int up = 1000;
LL fac[1010];
LL inv[1010];

typedef long long LL;

LL po(LL x,int a)
{
	LL res = 1;
	while(a)
	{
		if (a&1) 
			res = res * x % MOD;
		x = x * x % MOD;
		a>>=1;
	}
	return res;
}

LL Co(LL N,LL M)
{
	return ((fac[N]*inv[M])%MOD)*inv[N-M]%MOD;
}

LL calc(int S,int x)//x the sizeof leftmost group
{
	if (S == 0) return 1;
	if (x > B) return 0;
	if (F[S][x] != -1) return F[S][x];
	LL res = calc(S,x+1);
	for (int i=C;i<=D;i++)
	{
		if (i * x > S) break;
		LL tmp = calc(S-i*x, x+1); 
		//printf("%d %d %d %I64d\n",S,x,i,tmp);
		tmp = tmp * inv[i] % MOD;
		tmp = tmp * po(inv[x], i) % MOD;
		res = (res + tmp) % MOD;
	}
	return F[S][x] = res;
}

int main()
{
	fac[0] = 1;
	for (int i=1;i<=up;i++)fac[i] = fac[i-1] * i % MOD;
	inv[up] = po(fac[up],MOD-2);
	for (int i=up-1;i>=1;i--) inv[i] = inv[i+1] * (i+1) % MOD;
	//for (int i=1;i<=100;i++)printf("%I64d %I64d \n",fac[i],inv[i]);
	scanf("%d%d%d%d%d",&N,&A,&B,&C,&D);
	for (int i=0;i<=N;i++)
		for (int j=0;j<=N;j++)F[i][j] = -1;
	LL ans = 0;
	ans = calc(N,A)*fac[N]%MOD;
	//for (int i=1;i<=N;i++)
	//	for (int j=1;j<=N;j++)
	//	if (F[i][j]!=-1)printf("[%d][%d] = %d\n",i,j,F[i][j]);
	cout<<ans<<endl;
}

Measured memory_bytes: 8192
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
const int INF = numeric_limits<int>::max()/2;

template <typename T>
class FenwickTree {
  const int n;
  vector<T> data;
public:
  FenwickTree(int count) : n(count), data(count, 0) {;}

  void add(int pos, const T& value) {
    assert (0 <= pos && pos < n);
    for (int i = pos; i < n; i |= i + 1) data[i] += value;
  }

  T sum(int pos) const {
    assert (0 <= pos && pos <= n);
    T res = 0;
    for (int i = pos - 1; i >= 0; i = (i & (i + 1)) - 1) {
      res += data[i];
    }
    return res;
  }

  T sum(int l, int r) const {
    assert (0 <= l && l <= r && r <= n);
    return sum(r) + (-sum(l));
  }
  using value_type = T;
  using update_type = T;
};

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

    ll n,k;cin>>n>>k;
    vector<ll> v(n+1);
    for(int i=1;i<=n;i++){
        cin>>v[i];
        v[i] += v[i-1];
    }
    vector<ll> b(n+1);
    b[0]=-k;
    for(ll i=1;i<=n;i++) b[i]=v[i]-(i+1)*k;
    sort(b.begin(),b.end());
    map<ll,ll> mp;
    for(int i=0;i<=n;i++) mp[b[i]]=i;
    FenwickTree<ll> ft(222222);
    int idx=mp[-k];
    ft.add(idx,1);
    ll res=0;
    for(int i=1;i<=n;i++){
        ll num=v[i]-(i+1)*k;
        idx=mp[num];
        res += ft.sum(0,idx+1);
        ft.add(idx,1);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 17664
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int X, Y, A, B, C, p[222222], q[222222], r[222222];

  long long ap[222222], aq[222222], ar[222222], a[222222];

  std::cin >> X >> Y >> A >> B >> C;

  for (int i = 0; i < A; i ++)
    std::cin >> p[i];
  
  for (int i = 0; i < B; i ++)
    std::cin >> q[i];
  
  for (int i = 0; i < C; i ++)
    std::cin >> r[i];

  std::sort(p, p + A, std::greater<int>());
  std::sort(q, q + B, std::greater<int>());
  std::sort(r, r + C, std::greater<int>());

  ap[0] = aq[0] = ar[0] = 0;

  for (int i = 0; i < A; i ++)
    ap[i + 1] = p[i] + ap[i];
  
  for (int i = 0; i < B; i ++)
    aq[i + 1] = q[i] + aq[i];
  
  for (int i = 0; i < C; i ++)
    ar[i + 1] = r[i] + ar[i];

  a[0] = 0;

  int ind = 1;
  
  for (int i = 0, j = 0; i < X || j < Y; ind ++)
    if (i < X && j < Y) {
      if (p[i] >= q[j]) {
        a[ind] = p[i] + a[ind - 1];
        i ++;
      }
      else {
        a[ind] = q[j] + a[ind - 1];
        j ++;
      }
    }
    else if (i < X) {
      a[ind] = p[i] + a[ind - 1];
      i ++;
    }
    else if (j < Y) {
      a[ind] = q[j] + a[ind - 1];
      j ++;
    }
    else {
      assert(false);
    }

  assert(ind == X + Y + 1);

  long long sp = -1;

  for (int i = 0; i <= C; i ++) {
    int c = X + Y - i;

    if (0 <= c && c <= X + Y) {
      long long s = ar[i] + a[c];

      sp = std::max(s, sp);
    }
  }

  std::cout << sp << std::endl;
  
  return 0;
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int N;
vector<int> g[size];
int depth[size];
void dfs(int v){
    if(g[v].size() == 0){
        depth[v] = 0;
        return;
    }
	vector<int> vec;
	for(int u:g[v]){
		dfs(u);
		vec.push_back(depth[u]);
	}
	sort(vec.begin(), vec.end(), greater<int>());
	int res = 0;
	rep(i,0,vec.size()) res = max(res, vec[i] + i);
	depth[v] = res + 1;
}
int main(){
	cin>>N;
	int a;
	rep(i,1,N){
		cin>>a; a--;
		g[a].push_back(i);
	}dfs(0);
	cout<<depth[0]<<endl;
}

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


int top,S[1000];


void push(int x)
{
	top++;
	S[top]=x;
}

int pop()
{
	top--;
	return S[top+1];
}

int main()
{
	char s[100];
	top=0;
	int a,b;
	while(scanf("%s",s)!=EOF)
	{
		if(s[0]=='+')
		{
			a=pop();
			b=pop();
			push(a+b);
		}
		else if(s[0]=='-')
		{
			a=pop();
			b=pop();
			push(b-a);
		}
		else if(s[0]=='*')
		{
			a=pop();
			b=pop();
			push(b*a);
		}
		else
		{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
 } 



Measured memory_bytes: 2740
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N, M = mi()
yakusu = make_divisors(M)
lim = M // N
ind = bisect.bisect_right(yakusu, lim)
ans = 1

for i in reversed(range(1, ind)):
    amari = M % yakusu[i]
    if not amari:
        ans = yakusu[i]
        break

print(ans)

Measured memory_bytes: 3188
import sys
import math
import bisect

def main():
    s = input()
    n = len(s)
    min_val = 10 ** 18
    for i in range(n):
        if i + 3 <= n:
            tmp = int(s[i:i+3])
            val = abs(tmp - 753)
            min_val = min(min_val, val)
    print(min_val)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060