akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    # sys.stdin = open("sample.txt")
    N, M = Scanner.map_int()
    S = Scanner.string()
    T = Scanner.string()
    L = Math.lcm(N, M)
    s, t = 0, 0
    while s < N and t < M:
        if S[s] != T[t]:
            print(-1)
            return
        s += L//M
        t += L//N
    print(L)
    return


if __name__ == "__main__":
    main()


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

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

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

	int n; cin >> n;
	if(n%2) cout << n/2+1 << '\n';
	else cout << n/2 << '\n';

	return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int s , n , k;

int main()
{
    _FastIO;

    cin >> n >> k;
    int x , y;
    for(int i = 1; i <= n; i++){
        cin >> x;
    }
    n -= k;
    cout << (n + k - 2) / (k - 1) + 1 << endl;
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> d(n);
    rep(i,n)cin>>d[i];

    sort(d.begin(),d.end(),greater<int>());

    cout<<d[n/2-1]-d[n/2];
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    if(s+t > t+s) swap(s,t);
    int u = len(s),v = len(t);
    int c,d;
    rep(i,n){
        if((n-i*v) % u == 0){
            c = (n-i*v) / u,d = i;
            break;
        }
    }
    rep(i,c){
        cout << s;
    }
    rep(i,d){
        cout << t;
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 1684
n = int(input())
a = list(map(int, input().split()))

a.sort()

posi = [a[-1]]
nega = [a[0]]

for n in a[1:-1]:
  if n < 0:
    nega.append(n)
  else:
    posi.append(n)

selected = []
ans = nega[0]

for n in posi[1:]:
  (x, y) = ans, n
  ans = x - y
  selected.append((x, y))

nega.append(ans)

ans = posi[0]
for n in nega[1:]:
  (x, y) = ans, n
  ans = x - y
  selected.append((x, y))

print(ans)

for (x, y) in selected:
  print(str(x) + ' ' + str(y))




Measured memory_bytes: 64268
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(a<b){
		for(int i=0;i<b;i++){
        	cout << a;
        }
    }
    else{
    	for(int i=0;i<a;i++){
        	cout << b;
        }
    }
  cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int MAX = (int)2e5;
ll MOD = (ll)1e9+7;

ll fanmod(int a){
  int i;
  ll res=1;
  for(i=1;i<=a;i++)
    res = res*i%MOD;
  return res;
}

ll inv(ll a){
  ll ret = 1;
  ll m = MOD-2;
  while(m!=0){
    if(m&1)
      ret = ret*a%MOD;
    m /= 2;
    a = a*a%MOD;
  }
  return ret;
}

int main(){
  int n,x,y,
      min1,min2,sum=0,
      i,j;
  pair<int,int> a[MAX];
  ll ans=1;
  
  scanf("%d%d%d",&n,&x,&y);
  for(i=0;i<n;i++)
    scanf("%d%d",&a[i].first,&a[i].second);
  
  sort(a,a+n,[](pair<int,int> &x, pair<int,int> &y){
    return x.first != y.first ?
           x.first < y.first :
      	   x.second < y.second;
  });
  if(n==1){printf("1\n");return 0;}
  min1 = 0;
  for(i=1;i<n;i++)if(a[min1].second > a[i].second)min1 = i;
  min2 = min1==0 ? 1 : 0;
  for(i=1;i<n;i++)
    if(a[min1].first != a[i].first && (min2 == -1 || a[min2].second > a[i].second))min2 = i;
  if(min2==-1 || a[min1].second+a[min2].second > y){printf("1\n");return 0;}
  
  i=0;
  while(i<n){
    int t = i != min1 ? min1 : min2;
    if(a[t].second+a[i].second <= y){
      int g = max(y-a[t].second,x-a[i].second);
      j = i+1;sum++;
      while(j<n && a[j].first==a[i].first && a[j].second <= g){j++;sum++;}
      ans = ans*inv(fanmod(j-i))%MOD;
    }
    i++;
    while(i<n && a[i].first == a[i-1].first)i++;
  }
  ans = ans*fanmod(sum)%MOD;
  
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n, t, sum = 0;
    cin >> n >> t;
    vector<long> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    for(int i = 0; i < n; i++){
        if(i == n-1) sum += t;
        else if(l[i+1] - l[i] > t) sum += t;
        else sum += l[i+1] - l[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, m;
	cin >> n >> m;
	if (m == 0){
		cout << 0 << endl;
		return 0;
	}
	int a[m], b[m];
	int p[n];
	REP(i, n){
		p[i] = i+1;
	}
	REP(i, m) cin >> a[i] >> b[i];

	int ans = 0;

	do {
		int res = 0;
		for (int i = 0; i < n-1; i++){
			for (int j = 0; j < m; j++){
				if ((p[i] == a[j] and p[i+1] == b[j]) or (p[i] == b[j] and p[i+1] == a[j])){
					res++;
					break;
				}
			}
		}

		if (res+1 == n) ans++;
	} while (next_permutation(p+1, p+n));

	cout << ans << endl;
}


Measured memory_bytes: 256
A,B,C = list(map(int,input().split()))
if A >= B and B >= C:
  print(A*10 + B+C)
elif B >= C and C >=A:
  print(B*10 + C+A)
elif C >= A and A >= B:
  print(C*10 + A+B)
elif A >= B and C >= B:
  print(A*10 + B+C)
elif B >= A and A >= C:
  print(B*10 + A+C)
elif C >= A and B >= A:
  print(C*10 + A+B)

Measured memory_bytes: 3060
//	created : 16/03/15
// 	author   : Rp7rf
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF 1e9
 
int main(void){
    int q;
    string a,b;
    int dp[1010][1010];
    cin>>q;

    while(q--){
        cin>>a>>b;
        for(int j = 0 ; j < a.size() ; j ++){
            for(int i = 0 ; i < b.size() ; i ++){
                if(a[j] == b[i]){
                    dp[j+1][i+1] = dp[j][i]+ 1;
                }else{
                    dp[j+1][i+1] = max(dp[j][i+1],dp[j+1][i]);
                }
            }
        }
        cout<<dp[a.size()][b.size()]<<endl;
    }
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main() {
    int n;cin>>n;
    int k;bool ans=false;
    for(int i=1;i*(i-1)/2<=n;i++){
        if(i*(i-1)/2==n){
            ans=true;k=i;
            break;
        }
    }
    if(ans){
        cout<<"Yes"<<endl;
        vector<int>V[k];
        for(int i=0;i<k-1;i++){
            for(int j=i+1;j<k;j++){
                int x=(2*k-i-1)*i/2+j-i;
                V[i].push_back(x);
                V[j].push_back(x);
            }
        }
        cout<<k<<endl;
        rep(i,k){
            cout<<k-1<<' ';
            rep(j,k-1)cout<<V[i][j]<<' ';
            cout<<endl;
        }
    }
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3200
import sys
from bisect import bisect_left

input = sys.stdin.readline


def main():
    N = int(input())
    L = list(map(int, input().split()))

    L.sort()
    ans = 0
    for i in range(N - 2):
        a = L[i]
        for j in range(i + 1, N - 1):
            k = bisect_left(L, a + L[j])
            ans += (k - 1 - j)

    print(ans)


if __name__ == "__main__":
    main()


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

int N, K;
vector<int> A;
int solve();

int main(){
  cin >> N >> K;
  A = vector<int>(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  // kake = vector<int>(N);
  // tasu = vector<int>(N);
  long long kakeru = 0;
  long tasu = 0;
  for(int i = 0; i<N; i++){
    for(int j = 0; j<N; j++){
      if(A.at(i) > A.at(j)){
        if(i != j){
          // kake.at(i)++;
          kakeru++;
          if(j >i){
            // tasu.at(i)++;
            tasu++;
          }
        }

      }

    }
  }
  long long ss = 1000000007;
  long long ka;
  kakeru %= ss;
  // cout << kakeru << endl;
  if(K % 2 == 0){
    ka = (K/2*kakeru) %ss;
    ka = (ka * (K-1)) % ss;
  }else{
    ka = ((K-1)/2*kakeru) % ss;
    ka = (ka * K) % ss;
  }
  long long SK = (tasu * K) %ss;
  long long ans = (ka+SK) % ss;



  // long long S = (((kakeru %ss)*K) %ss) * (K-1);

  // long long S = (K*(K-1)/2) % ss;
  // long long SK = (tasu * K) %ss;
  // long long L = (S *kakeru) % ss;
  // long long ans = (L+SK) % ss;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

int main()
{
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];

    vector<int> sl(n + 1);
    for(int i = 0; i < n; ++i){
        sl[i + 1] = max(sl[i], a[i]);
    }
    vector<int> sr(n + 1);
    for(int i = n - 1; i >= 0; --i){
        sr[i] = max(sr[i + 1], a[i]);
    }

    for(int i = 0; i < n; ++i){
        int ans = max(sl[i], sr[i + 1]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include <stdlib.h> 
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
	int m[1000],f[1000],k=1000,r[1000],i;
	for( i=0;i<=k;i++)
	{
		cin>>m[i]>>f[i]>>r[i];
		if(m[i]==-1&&f[i]==-1&&r[i]==-1)
			break;
	
	
	
	
	}
	int p;
	for(int k=0;k<i;k++)
	{
		if(m[k]==-1||f[k]==-1)
			{
				cout<<"F"<<endl;
		continue;
		}
	
		p=0;
		p=m[k]+f[k];
		if(p>=80)
			cout<<"A"<<endl;
		if(p<80&&p>=65)
			cout<<"B"<<endl;
		if(p<65&&p>=50)
			cout<<"C"<<endl;
		if(p>=30&&p<50&&r[k]<50)
			cout<<"D"<<endl;
		if(p>=30&&p<50&&r[k]>=50)
			cout<<"C"<<endl;
		if(p<30)
			cout<<"F"<<endl;
	
	
	
	}












}
	

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

int main() {
    int n,count=0;
    string s,ans="No";
    cin>>n>>s;

    rep(i,n/2) {
        if (s.at(i) == s.at(n/2+i)) count++;
    }

    if (count==n/2 && n%2==0) ans="Yes";

    cout<<ans<<endl;
}


Measured memory_bytes: 256
def main():
    s = int(input())

    m = 1000000
    array = []
    array.append(s)
    count = 0
    for i in range(1,m):
        if array[i-1] == 1:
            count += 1
        if count == 2:
            break
        if array[i-1]%2 == 0:
            array.append(array[i-1]/2)
        else:
            array.append(array[i-1]*3+1)
    ans = m
    for i in range(len(array)):
        for j in range(i+1, len(array)):
            if array[i] == array [j]:
                ans = min(ans, max(i+1,j+1))
        if m == 3:
            break
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int res = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == t[i]) res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if (x>=y) cout<<x-y<<endl;
    else cout<<"0"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

int a, b;
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();
    cin >> a >> b;
    cout << (a + b - 1) / a << endl;
    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n));i>0;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 10e9 + 7;
typedef long long ll;

int main(){
	int N, K;
	cin >> N >> K;
	int ans = 1;
	rep(i, N){
		ans = min(ans * 2, ans + K);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//
// Created by bytedance on 2020/4/10.
//


#include <bits/stdc++.h>

using namespace std;
const int maxn = 200005;

struct Node {
public:
    Node() {
        for (int &i : next)
            i = -1;
        sum = 0;
    }

    int next[26];
    int sum;

} node[1000005];

vector<int> q(1000005);
const int root = 0;
int cnt = 1;


int main() {
    int n;
    cin >> n;
    vector<string> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end(), [](string &a, string &b) {
        return a.length() < b.length();
    });
    long long ans = 0;
    cnt = 1;
    for (const auto &s : vec) {
//        cout << s << endl;
        int l = s.length();
        int now = root;
        for (int j = l - 1; j >= 0; j--) {
            if (node[now].next[s[j] - 'a'] == -1) {
                node[now].next[s[j] - 'a'] = cnt++;
            }
            q[j] = now;
            now = node[now].next[s[j] - 'a'];
//            cout << now << endl;
        }
        ans += node[now].sum;
        node[now].sum++;
        int tmp = 0;
        tmp |= (1 << (s[0] - 'a'));
//        tmp |= (1 << (s[1] - 'a'));
        for (int i = 2; i <= l; i++) {
            tmp |= (1 << (s[i - 1] - 'a'));
//            cout << tmp << endl;
            for (int k = 0; k < 26; k++) {
                if (tmp & (1 << k)) {
                    ans += node[node[q[i - 1]].next[k]].sum;
                }
            }
        }

    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 118704
A = [[int(a) for a in input().split()] for _ in range(3)]
B = [[0] * 3 for _ in range(3)]
N = int(input())
for _ in range(N):
    a = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == a:
                B[i][j] = 1

for i in range(3):
    if sum([B[i][j] for j in range(3)]) == 3:
        print("Yes")
        exit()

for j in range(3):
    if sum([B[i][j] for i in range(3)]) == 3:
        print("Yes")
        exit()

if sum([B[i][i] for i in range(3)]) == 3:
    print("Yes")
    exit()

if sum([B[i][2-i] for i in range(3)]) == 3:
    print("Yes")
    exit()

print("No")

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

typedef long long ll;

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

    //freopen("input.txt", "r", stdin);

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    while(b <= a && k > 0)
    {
        b *= 2;
        k--;
    }
    while(c <= b && k > 0)
    {
        c *= 2;
        k--;
    }

    if(a < b && b < c)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 3620
import bisect

A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Measured memory_bytes: 12800
using System;
using System.Linq;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split(' ');
            decimal n = decimal.Parse(array[0]);
            decimal d = decimal.Parse(array[1]);
            var result = Math.Ceiling(n / (2 * d + 1));
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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 N,a,b,c;
int dp[100100][3];

int main(){
    cin>>N;
    rep(i,3)dp[0][i]=0;
    repi(i,1,N+1){
        cin>>a>>b>>c;
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
    }
    out(max(dp[N][0],max(dp[N][1],dp[N][2])));
    
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,l,ans=0,min_l=1000000000,pie=0,tmp;
  cin >> n >> l;
  for(int i=0;i<n;i++){
    pie+=i+l;
  }
  for(int i=0;i<n;i++){
    tmp = pie-(i+l);
    tmp = abs(pie-tmp);
    if(tmp<min_l){
      min_l = tmp;
      ans = pie-(i+l);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,k,n,m;
  cin>>n>>m;
  int a[m];
  int sum=0;
  for(i=0;i<m;i++)
  {
      cin>>a[i];
      sum+=a[i];
  }
  if(sum>=n)
  cout<<"Yes";
  else
  cout<<"No";
}

Measured memory_bytes: 640
#include <stdio.h>
#define INF 100000000
int main(void){
  int n,ac[100000][3],dp[100000][3],i,j,k,max,ans=0;
  scanf("%d",&n);
  for (i=0;i<n;i++) scanf("%d%d%d",&ac[i][0],&ac[i][1],&ac[i][2]);
  dp[0][0]=ac[0][0]; dp[0][1]=ac[0][1]; dp[0][2]=ac[0][2];
  for (i=1;i<n;i++){
    for (j=0;j<3;j++){
      max=0;
      for (k=0;k<3;k++){
        if (j!=k&&dp[i-1][k]+ac[i][j]>max) max=dp[i-1][k]+ac[i][j];
      }
      dp[i][j]=max;
    }
  }
  for (i=0;i<3;i++){
    if (dp[n-1][i]>ans) ans=dp[n-1][i];
  }
  printf("%d\n",ans);
  return 0;
}

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

int main()
{
	using vi = std::vector<int>;
	using vvi = std::vector<vi>;
	int H, W;
	scanf("%d%d", &H, &W);
	using vb = std::vector<bool>;
	using vvb = std::vector<vb>;
	vvb room(H + 2, vb(W + 2));
	for (int r{1}; r <= H; r++)
		for (int c{1}; c <= W; c++)
		{
			char S;
			scanf(" %c", &S);
			room[r][c] = S == '.';
		}

	constexpr int inf{1 << 30};
	int ans{};
	int dir[4][2]{{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
	for (int start_r{1}; start_r <= H; start_r++)
		for (int start_c{1}; start_c <= W; start_c++)
		{
			if (!room[start_r][start_c]) continue;
			vvi distance(H + 2, vi(W + 2, inf));
			std::queue<std::pair<int, int>> que;
			distance[start_r][start_c] = 0;
			que.push({start_r, start_c});
			while (!que.empty())
			{
				auto now{que.front()};
				que.pop();
				for (auto& e: dir)
				{
					std::pair<int, int> next{now.first + e[0], now.second + e[1]};
					if (!room[next.first][next.second]) continue;
					if (distance[next.first][next.second] <= distance[now.first][now.second] + 1)
						continue;
					distance[next.first][next.second] = distance[now.first][now.second] + 1;
					que.push(next);
				}
			}
			for (auto& e: distance)
				for (auto& f: e)
					if (f != inf)
						ans = std::max(ans, f);
		}
	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 256
n, a = map(int, input().split())
x = list(map(int, input().split()))
X = max(x)
y = [i - a for i in x]
dp = [[0 for t in range(2 * n * X + 10)] for j in range(n + 1)]
dp[0][n * X] = 1
for j in range(1, n + 1):
    for t in range(2 * n * X + 1):
        if 0 <= t - y[j - 1] <= 2 * n * X:
            dp[j][t] = dp[j - 1][t] + dp[j - 1][t - y[j - 1]]
        else:
            dp[j][t] = dp[j - 1][t]
print(dp[n][n * X] - 1)

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

int main() {
    long long a, b;
    int sum = 1;
    cin >> a >> b;
    if (a < 0 && b > 0) sum = 0;
    else if (a < 0 && b < 0) {
        if ((b - a) % 2 == 0) sum = -1;
        else sum = 1;
    }
    else sum = 1;

    if (sum > 0) cout << "Positive" << endl;
    else if (sum < 0) cout << "Negative" << endl;
    else cout << "Zero" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;


int main(){
  int n,cnt=0;
  cin >> n;
  vector<int> p(n,0);
  rep(i,n) cin >> p[i];
  rep(i,n) {
   if(i+1 != p[i]) cnt++;  
  }
  cout << ((cnt < 3) ? "YES":"NO") << endl;
}

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

typedef long long ll;

const ll lim = 1000000000;
const int Maxn = 505;

int N, M, n, m;
int B[Maxn][Maxn];
ll st;

int main()
{
    scanf("%d %d %d %d", &N, &M, &n, &m);
    for (int i = 0; i < N; i += n)
        for (int j = 0; j < M; j += m)
            B[i][j] = lim - 1;
    for (int i = n - 1; i < N; i += n)
        for (int j = m - 1; j < M; j += m)
            B[i][j] = -lim;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < M; j++)
            st += B[i][j];
    if (st <= 0) { printf("No\n"); return 0; }
    printf("Yes\n");
    for (int i = 0; i < N; i++)
        for (int j = 0; j < M; j++)
            printf("%d%c", B[i][j], j + 1 < M? ' ': '\n');
    return 0;
}


Measured memory_bytes: 3968
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    ng = 0
    ok = N
    print(ng, flush=True)
    ng_s = SS()
    ok_s = ng_s
    while abs(ok-ng)>1:
        m = (ng+ok)//2
        print(m, flush=True)
        s = SS()
        if s == 'Vacant':
            sys.exit()
        elif (ok - m) % 2 == 1 and ok_s != s or (ok - m) % 2 == 0 and ok_s == s:
            ok = m
            ok_s = s
        else:
            ng = m
            ng_s = s

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10068
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	int n, m;
	vector<int>list;
	vector<pair<int, int>>list2;

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	if (m == 1) {
		cout << 0 << endl;
		return 0;
	}

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


	for (int i = 1; i < m; i++) {
		list2.push_back(make_pair( abs( list[i] - list[i - 1]), i));
	}

	//sort(list2.begin(), list2.end(), greater<int>());
	sort(list2.begin(), list2.end());

	ll sum = 0;
	int index = 0;
	vector<int>list3;

	for (int i = list2.size() - 1, j = 0; j < n - 1 && j < m - 1 ; i--, j++) {
		list3.push_back(list2[i].first);
	}

	sort(list3.begin(), list3.end(), greater<int>());

	for (int i = 0; i < n - 1 && i < m - 1; i++) {
		//sum += (abs(list[list3[i]] - list[index]));
		//index = list3[i] + 1;
		sum += list3[i];
	}

	//sum += list[list3[list3.size() - 1]] - list[index];

	cout << abs( list[0] - list[list.size() - 1]) - sum << endl;


	return 0;
}

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

using namespace std;

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

    map<string , int> occ;

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


    string v[4] = {"AC" , "WA" , "TLE" , "RE"};

    for (int i = 0 ; i < 4 ; i++){
        cout << v[i] << " x " << occ[v[i]] << endl;
    }


    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge {ll s,t,d;};
struct vector<vector<Edge>> Graph;
ll c1,c2,c4;
int main(){
  ll H,W; cin>>H>>W;
  UM<char,ll> cnt;
  REP(i,H){
    string s; cin>>s;
    REP(j,W) cnt[s[j]]+=1;
  }
  vi cv;
  for(auto p:cnt) {cv.PB(p.second);}

  if(H*W%2==1) {
    c1=1;
    c2=(H/2)+(W/2);
  }else if(H%2){
    c2=(W/2);
  }else if(W%2){
    c2=(H/2);
  }

  for(ll &i:cv){
    if(i%2){
      if(c1){
        i-=1;
        c1-=1;
      }else{
        cout<<"No"<<endl;
        return 0;
      }
    }
  }

  for(ll &i:cv){
    if(i%4){
      if(c2){
        i-=2;
        c2-=1;
      }else{
        cout<<"No"<<endl;
        return 0;
      }
    }
  }

  for(ll i:cv){
    if(i%4){
      cout<<"No"<<endl;
      return 0;
    }
  }

  cout<<"Yes"<<endl;




}


Measured memory_bytes: 256
a,b,k = map(int,input().split())
ans_list = []
for i in range(a,a+k):
    ans_list.append(i)
    if ans_list[-1] == b:
        [print(i) for i in ans_list]
        exit()
for i in range(b-k+1,b+1):
    if ans_list.count(i) == 0:
        ans_list.append(i)
[print(i) for i in ans_list]

Measured memory_bytes: 3060
a,b=map(int, input().split())
c="必要な電源タップ数は"
d="個です。"
count=0
total=1
while True:
    
#    total+=a
    
#    if total<b:
#        total-=1
#        count+=1
#    else:
#        break
    if total >= b:
        break
    total += (a-1)
    count+=1
print(count)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
    int x;

    cin >> x;
    int a,b;
    a = x / 500;
    x -= (a*500);
    b = x / 5;

    cout << 1000*a + b*5;
}

Measured memory_bytes: 256
/*
Á·Ï°Ìâ£ºCheese_AOJ 0558 
*/

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

const int INF=100000000;
const int MAX=1000;

typedef pair<int, int> P;
int N, M;
int sx, sy;
int gx[10], gy[10];
char maze[MAX][MAX];
//ÉèÖÃÊý×é£¬±íÊ¾µ½ÆðµãµÄ×î½ü¾àÀë 
int d[MAX][MAX];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int bfs(int g)
{
	queue<P> que;
	for(int i=0; i<N; i++)
		for(int j=0; j<M; j++)
			d[i][j]=INF;
	//ÏÈ°ÑÆðµã·Å½øÈ¥£¬¾àÀëÉèÖÃÎªÁã 
	que.push(P(sx, sy));
	d[sx][sy]=0;
	
	//Ö±µ½¶ÓÁÐÃ»ÓÐÔªËØ£¬¾ÍÎÞÂ·¿É×ßÁË 
	while(que.size())
	{
		P p = que.front();
		que.pop();
		if(p.first==gx[g]&&p.second==gy[g])
			break;
		
		for(int i=0; i<4; i++)
		{
			int nx=p.first+dx[i];
			int ny=p.second+dy[i];
			if(nx>=0&&nx<N&&ny>=0&&ny<M&&maze[nx][ny]!='X'&&d[nx][ny]==INF)
			{
				que.push(P(nx,ny));
				d[nx][ny] = d[p.first][p.second]+1;
			}
		}	
	}
	return d[gx[g]][gy[g]];
}

int main()
{
	int gn;
	scanf("%d%d%d", &N, &M, &gn);
	getchar();
	for(int i=0; i<N; i++)
	{
		for(int j=0; j<M; j++)
			scanf("%c", &maze[i][j]);
		getchar();
	}
	for(int i=0; i<N; i++)
		for(int j=0; j<M; j++)
		{
			if(maze[i][j]=='S')
			{
				sx=i;
				sy=j;
			}
			if(maze[i][j]=='1')
			{
				gx[1]=i;
				gy[1]=j;
			}
			if(maze[i][j]=='2')
			{
				gx[2]=i;
				gy[2]=j;
			}
			if(maze[i][j]=='3')
			{
				gx[3]=i;
				gy[3]=j;
			}
			if(maze[i][j]=='4')
			{
				gx[4]=i;
				gy[4]=j;
			}
			if(maze[i][j]=='5')
			{
				gx[5]=i;
				gy[5]=j;
			}
			if(maze[i][j]=='6')
			{
				gx[6]=i;
				gy[6]=j;
			}
			if(maze[i][j]=='7')
			{
				gx[7]=i;
				gy[7]=j;
			}
			if(maze[i][j]=='8')
			{
				gx[8]=i;
				gy[8]=j;
			}
			if(maze[i][j]=='9')
			{
				gx[9]=i;
				gy[9]=j;
			}
		}
	
	int asw = bfs(1);
	for(int i=1; i<gn; i++)
	{
		sx=gx[i]; sy=gy[i];
		asw += bfs(i+1);
	}
	printf("%d\n", asw);
	
	
	return 0;
}



Measured memory_bytes: 8156
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    string S;
    string checkABC="ABC";
    cin >> N;
    cin >> S;
    int cnt=0;
    for(auto itr=S.begin();itr!=S.end()-2;itr++){
        if(equal(itr,itr+3,checkABC.begin(),checkABC.end()))cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    h <- getInt
    print $ solve h

solve :: Int -> Int
solve 1 = 1
solve x = 1 + 2 * (solve $ x `div` 2)

Measured memory_bytes: 380
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
string s;

signed main() {
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int x = 0; x < 10; x++) {
				int res = 0;
				for (int k = 0; k < n; k++) {
					if (res == 0 && s[k] == (char)(i + '0')) res++;
					else if (res == 1 && s[k] == (char)(j + '0')) res++;
					else if (res == 2 && s[k] == (char)(x + '0')) res++;
				}
				if (res == 3) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

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


using namespace std;

int main()
{
	int N;
	int a,k;
	int prime[1001];
	long long xx=1;
	int mod = 1000000007;
	cin >> N;
	for (int i = 0; i < N + 1; ++i) prime[i] = 0;


	for (int j = 2; j < N + 1; ++j) {
		k = j;
		//素因数分解
		a = 2;
		while (k >=a*a) {
			if (k % a ==0) {
				k = k/a;
				prime[a]++;
			}
			else {
				a++;
			}
		}
		prime[k]++;
	}

	for (int k = 1; k < N + 1; ++k) {
		xx = ((xx%mod) * (prime[k] + 1)%mod)%mod;
	}

	cout << xx << endl;
	return 0;

}

Measured memory_bytes: 256
# # Educational DP Contest B
N, K = map(int, input().split())
H = list(map(int, input().split()))

dp = [float("inf")] * N

dp[0] = 0
for i in range(1, N):
    cost_list = [float("inf")] * K
    for k in range(1, K+1):
        if i - k < 0:
            break
        cost_list[k-1] = dp[i-k] + abs(H[i] - H[i-k])
    dp[i] = min(cost_list)
print(dp[N-1])

Measured memory_bytes: 57848
#include <bits/stdc++.h>
using namespace std;
string s,s1;
int ans;
int main()
{
    cin >>s;
    if (s.size()==1)
    {
        cout <<s;
        return 0;
    }
    for (int i=0;i<s.size()-1;i++)
        s1+='9',ans+=9;
    if (s.substr(1,s.size()-1)==s1)
        ans+= (s[0]-'0');
    else
        ans+= (s[0]-'1');
    cout <<ans;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

n, k = list(map(int, input().split()))
h = np.array(list(map(int, input().split())))

k = min(k, n-1)
dp = np.zeros(n+1)

for i in range(2, k+1):
    dp[i] = np.min(dp[1:i] + np.abs(h[i-1] - h[0:i-1]))

for i in range(k+1, n+1):
    dp[i] = (dp[i-k:i] + np.abs(h[i-1] - h[i-k-1:i-1])).min()
    
print(int(dp[n]))

Measured memory_bytes: 22904
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
	string s;cin >> s;
	if(s[0]==s[1]&&s[1]==s[2]){
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
  return 0;
}


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

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
const long long mod =1e9+7;
int n,k;
long long d[100002];
long long sum[100002];
long long kq;
int a[100002];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<=a[1];i++)
        d[i]=1;
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
            sum[j]=(sum[j-1]+d[j])%mod;
        for(int j=0;j<=k;j++)
        {
            int l=j-a[i];
            l=max(l,0);
            int r=j;
            int s=sum[r]-sum[l-1];
            d[j]=(sum[r]-sum[l-1]+mod*mod)%mod;
        }
    }
    cout<<d[k];
    return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    ll n, k; cin >> n >> k;
    vector<ll> sum(n + 1);
    for(int i = 1; i <= n; i++) {
        int a; cin >> a;
        sum[i] = (sum[i - 1] + a - 1) % k;
        sum[i] = (sum[i] + k) % k;
    }
    map<ll, ll> mp;
    ll ans = 0;
    for(int i = 0; i <= n; i++) {
        if(i - k >= 0)mp[sum[i - k]]--;
        ans += mp[sum[i]];
        mp[sum[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] array = new long[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextLong();
            if (array[i] == 0) {
                System.out.println(0);
                return;
            }
        }
        long tmp = 1;
        for (int i = 0; i < n; i++) {
            if (tmp <= 1000000000000000000L / array[i]) {
                tmp *= array[i];
            } else {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(tmp);
    }
}


Measured memory_bytes: 61368
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(vector<T> & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(vector<T>& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(vector<T>& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(vector<T>& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>T Sum(vector<T> a, T init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define In(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn(T,name,n) vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn2(T,name,name2,n) vector<T> name(n),name2(n); rep(i,n)cin>>name[i]>>name2[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int re(string s, string t) {
	int ret = 0;
	for (char c = 'a'; c <= 'z'; c++) {
		ret += count(all(s), c) && count(all(t), c);
	}
	return ret;
}

int main() {
	in(n);
	In(string, s);
	int ans = 0;
	rep(i, sz(s) - 1) {
		ans = max(ans, re(s.substr(0, i + 1), s.substr(i + 1, sz(s) - i)));
	}
	out(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <stdio.h>
using namespace std;

int n, k;
char x;
char s[12];

int main() {

	cin >> n >> s >> k;

	x = s[k - 1];

	for (int i = 0; i < n; i++) {
		if (x != s[i]) s[i] = '*';
	}

	cout << s << endl;

	return 0;
}


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

public class Main{
	public static void main(String[] augs){

	    int a,b;

	    Scanner scan = new Scanner(System.in);
	    a = Integer.parseInt(scan.next());
	    b = Integer.parseInt(scan.next());
	    if(a >= -1000 && b <= 1000){
	    if(a > b){
	    	System.out.println("a > b");
	    }else if(a < b){
	    	System.out.println("a < b");
	    }else if(a == b){
	    	System.out.println("a == b");
	    }
	    }
	
	}


}

Measured memory_bytes: 26152
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Jul 25 21:29:15 JST 2020
 **/

signed main() {
    Int n, K;
    std::cin >> n >> K;
    std::vector<Int> a(n);
    REP(i, n) std::cin >> a[i];
    REP(i, n - K) { std::cout << (a[i + K] > a[i] ? "Yes" : "No") << "\n"; }
}


Measured memory_bytes: 4716