akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, m;
  cin >> n >> m;

  vl a(n, -1);
  rep(i, m) {
    ll s, c;
    cin >> s >> c;

    if (a[n-s] == -1) {
      a[n-s] = c;
    } else {
      if (a[n-s] != c) {
        cout << -1 << endl;
        return 0;
      }
    }
  }

  if (n == 1 and a[0] == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (n == 1 and a[0] == -1) {
    cout << 0 << endl;
    return 0;
  }

  if (n >= 2 and a[n-1] == 0) {
    cout << -1 << endl;
    return 0;
  }

  bool f = 0;
  vl ans(n);
  for (ll i = n-1; i >= 0; i--) {
    if (a[i] == -1) {
      if (f) {
        ans[i] = 0;
      } else {
        ans[i] = 1;
        f = 1;
      }
    } else {
      ans[i] = a[i];
      f = 1;
    }
  }

  for (ll i = n-1; i >= 0; i--) {
    cout << ans[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
    int n;
    char s[256];
    scanf("%d", &n);
    scanf("%s", s);
    int ans;
    if(n % 2 == 1){
        ans = 0;
    }else{
        if(strncmp(s, s + (n / 2), n / 2) == 0){
            ans = 1;
        }else{
            ans = 0;
        }
    }
    if(ans){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
s=input()
t=input()

l=[False]*len(s)
c=0
m=0
for x in range(len(s)-len(t)+1):
     c=0
     for y in range(len(t)):
          w=s[x:x+len(t)]
          if w[y]==t[y]:c+=1
     m=max(m,c)
print(len(t)-m)

Measured memory_bytes: 9148
#include <iostream>
#include <vector>

 using namespace std;

int main()
{
 int i,n,m,all=0,p=0; //n個の内、m個を選ぶ//
 cin >> n >> m;
 vector<int> a(n);
for(i=0;i<n;i++){ 
    cin >> a[i];
    all=all+a[i];
}
for(i=0;i<n;i++){
    if((4*m)*a[i]>=all) p=p+1;
}

if(p>=m) cout << "Yes" << endl;
else cout << "No" <<endl;

return 0;
}

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

using namespace std;

struct Tag {
    int ver, hor, lr, rl;
    Tag() : ver(0), hor(0), lr(0), rl(0) {}
    Tag(int v, int h, int l, int r) : ver(v), hor(h), lr(l), rl(r) {}
};

Tag dp[2][255];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        for(int i = 0; i < N; ++i) {
            dp[0][i] = dp[1][i] = Tag(0, 0, 0, 0);
        }
        int ans = 0;
        for(int i = 0; i < N; ++i) {
            const int cur = i & 1;
            const int prev = cur ^ 1;
            string str;
            cin >> str;
            for(int c = 0; c < N; ++c) {
                dp[cur][c] = Tag(0, 0, 0, 0);
                if(str[c] == '1') {
                    if(i > 0) dp[cur][c].ver = dp[prev][c].ver;
                    if(c > 0) dp[cur][c].hor = dp[cur][c-1].hor;
                    if(i > 0 && c > 0) dp[cur][c].lr = dp[prev][c-1].lr;
                    if(i > 0 && c+1 < N) dp[cur][c].rl = dp[prev][c+1].rl;
                    ans = max(ans, ++dp[cur][c].ver);
                    ans = max(ans, ++dp[cur][c].hor);
                    ans = max(ans, ++dp[cur][c].lr);
                    ans = max(ans, ++dp[cur][c].rl);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

public class Test
{
	public static void Main()
	{
		// my code goes here
		var a = Console.ReadLine().Split().Select(nyan => int.Parse(nyan)).ToArray();
		int n = a[0];
		int m = a[1];
		Console.WriteLine(( n*(n-1) + m*(m-1) )/2);
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define MOD 1000000007
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    int N;
    cin >> N;

    ll A[N];
    ll B[N + 2] = {};
    rep(i, N) {
        cin >> A[i];
        B[i + 1] = A[i]+B[i];
    }

    ll ans=INF2;

    reps(x, 2, N-1) {

        ll low = 0;      // 一番小さい値より1つ前
        ll high = x;  // 一番でかい値より1つあと
        while (abs(high - low) > 1) {
            ll mid = (high + low) / 2;

            (B[mid]>=B[x]-B[mid] ? high : low) = mid;
        }
        ll leftma=min(B[high],B[x]-B[low]);
        ll leftmi=max(B[low],B[x]-B[high]);

        ll low1 = x;      // 一番小さい値より1つ前
        ll high1 = N;  // 一番でかい値より1つあと
        while (abs(high1 - low1) > 1) {
            ll mid = (high1 + low1) / 2;

            (B[mid]-B[x]>=B[N]-B[mid] ? high1 : low1) = mid;
        }
        ll rightma=min(B[high1]-B[x],B[N]-B[low1]);
        ll rightmi=max(B[low1]-B[x],B[N]-B[high1]);

        ll tmp=max(leftma,rightma)-min(leftmi,rightmi);
        mini(ans,tmp);
    }

    cout<< ans<<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define F(i,a,b) for(register int i=(a);i<=(b);++i)
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0;
	bool f=0;
	char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') f=1;
		ch=getchar();
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	return f?-x:x;
}
const int maxn=1e5+3;
const long long inf=1e16;
struct day
{
	int x,y,z;
}d[maxn];
bool cmp1(day a,day b)
{ return a.y-a.x<b.y-b.x; }
priority_queue< int,vector<int>,greater<int> > q;
ll pre[maxn],suf[maxn];
signed main()
{
	//freopen("b.in","r",stdin);
	//freopen("b.out","w",stdout);
	int x=read(),y=read(),z=read();
	int num=x+y+z;
	ll ans=0;
	F(i,1,num)
	{
		d[i].x=read();
		d[i].y=read();
		d[i].z=read();
		ans+=d[i].z;
	}
	sort(d+1,d+num+1,cmp1);
	ll sum=0;
	F(i,1,x)
	{
		int c=d[i].x-d[i].z;
		q.push(c);
		sum+=c;
	}
	pre[x]=sum;
	F(i,x+1,x+z)
	{
		int tp=q.top();
		int c=d[i].x-d[i].z;
		if(tp<c)
		{
			sum-=tp;
			sum+=c;
			q.pop();
			q.push(c);
		}
		pre[i]=sum;
	}
	sum=0;
	while(!q.empty()) q.pop();
	for(register int i=num;i>=num-y+1;--i)
	{
		int c=d[i].y-d[i].z;
		q.push(c);
		sum+=c;
	}
	suf[num-y+1]=sum;
	for(register int i=num-y;i>=x+1;--i)
	{
		int tp=q.top();
		int c=d[i].y-d[i].z;
		if(tp<c)
		{
			sum+=c;
			sum-=tp;
			q.pop();
			q.push(c);
		}
		suf[i]=sum;
	}
	ll tmp=-inf;
	F(i,x,num-y) tmp=max(tmp,pre[i]+suf[i+1]);
	printf("%lld\n",ans+tmp);
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const int maxn=2e5+1;
const int MX=5e6+1;
map<pair<int,int>,bool> z;
int main(){
    int n;
    int m;
    cin>>n>>m;
    for(int i=1; i<=m; ++i){
        int a,b;
        cin>>a>>b;
        z[{a,b}]=true;
        z[{b,a}]=true;
    }
    for(int i=2; i<n; ++i){
        if (z[{1,i}] && z[{i,n}]){
            cout<<"POSSIBLE\n";
            return 0;
        }
    }
    cout<<"IMPOSSIBLE\n";
}


Measured memory_bytes: 37760
encode={
" ":"101",
"'":"000000",
",":"000011",
"-":"10010001",
".":"010001",
"?":"000001",
"A":"100101",
"B":"10011010",
"C":"0101",
"D":"0001",
"E":"110",
"F":"01001",
"G":"10011011",
"H":"010000",
"I":"0111",
"J":"10011000",
"K":"0110",
"L":"00100",
"M":"10011001",
"N":"10011110",
"O":"00101",
"P":"111",
"Q":"10011111",
"R":"1000",
"S":"00110",
"T":"00111",
"U":"10011100",
"V":"10011101",
"W":"000010",
"X":"10010010",
"Y":"10010011",
"Z":"10010000"
}
decode={
"00000":"A",
"00001":"B",
"00010":"C",
"00011":"D",
"00100":"E",
"00101":"F",
"00110":"G",
"00111":"H",
"01000":"I",
"01001":"J",
"01010":"K",
"01011":"L",
"01100":"M",
"01101":"N",
"01110":"O",
"01111":"P",
"10000":"Q",
"10001":"R",
"10010":"S",
"10011":"T",
"10100":"U",
"10101":"V",
"10110":"W",
"10111":"X",
"11000":"Y",
"11001":"Z",
"11010":" ",
"11011":".",
"11100":",",
"11101":"-",
"11110":"'",
"11111":"?"
}

def coding():
    code = ""
    stri = ""
    st = raw_input()
    for s in st:
        code += encode[s]
    if len(code)%5:
        code += "0"*(5-len(code)%5)
    b = 0
    while True:
        if b == len(code):
            return stri
        stri += decode[code[b:b+5]]
        b += 5
while True:
    try:
        print coding()
    except:
        break

Measured memory_bytes: 4332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define mp make_pair
int main()
{
	ll n;
	fastio;	
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll dp[n]={0};
	for(ll i=n-2;i>=0;i--)
	{
		ll f=0,s=LONG_LONG_MAX;
		f=abs(a[i+1]-a[i])+dp[i+1];
		if(i+2<n)
		s=abs(a[i+2]-a[i])+dp[i+2];
		dp[i]=min(s,f);
	}
	cout<<dp[0];
}


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

using namespace std;

typedef long long ll;

int main()
{
	ll n,a,b,c,d,i,j,l,r;
	
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	
	for(i=0;i<n;i++){
		j = (n-1) - i;
		l = -d * i + c * j;
		r = -c * i + d * j;
		if(l <= b-a && b-a <= r){
			printf("YES\n");
			return 0;
		}
	}
	
	printf("NO\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int i = 0; i <= A; i++){
    for (int j = 0; j <= B; j++){
      int k = (X - i * 500 - j * 100) / 50;
      if (0 <= k && k <= C) res++;
    }
  }
  cout << res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

void solve(){
 int n,k;
 int o=0;
 cin >> n >>k;
 vector<int>a(n);
 for(int i=0;i<n;i++) cin >> a[i];
 for(int i=0;i<n;i++){
 if(a[i]>=k) o++;}
 cout << o;
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3648
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	b = zeros(Int,n+1)
	for i in 1:n
		b[i+1] = a[i]+b[i]
	end
	d = Dict{Int,Int}()
	ans = 0
	for i in n:-1:0
		if i+k<=n
			d[mod(b[i+1+k]-i,k)] -= 1
		end
		if haskey(d,mod(b[i+1]-i,k))
			ans += d[mod(b[i+1]-i,k)]
			d[mod(b[i+1]-i,k)] += 1
		else
			d[mod(b[i+1]-i,k)] = 1
		end
	end
	println(ans)
end

main()

Measured memory_bytes: 139768
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int r;
	cin >> r;
	if(r < 1200) cout << "ABC" << endl;
	else if(r < 2800)cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

unordered_map<string, bool> m;
string str = "";

bool func(int pos, int num){
    if(pos == num){
        if(m.find(str) == m.end()){
            cout << str << endl;
            return true;
        }
        return false;
    }
    for(int i = 0; i < 26; i++){
        str[pos] = 'a' + i;
        if(func(pos + 1, num)){
            return true;
        }
    }
    return false;
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        string S;
        cin >> S;
        for(int i = 1; i <= 4; i++){
            for(int j = 0; j < (int)S.size() - i + 1; j++){
                m[S.substr(j, i)] = true;
            }
        }
    }
    for(int i = 1; i <= 4; i++){
        str += " ";
        if(func(0, i)){
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
    int n, debt = 100000;
    cin >> n;
    for (int i = 0; i < n; i++) {
        debt *= 1.05;
        if (debt % 1000 != 0) {
            debt += 1000 - debt % 1000;
        }
    }
    cout << debt << endl;
    return 0;
}

Measured memory_bytes: 3072
N,A,B = map(int, raw_input().split())
S = raw_input()
kakutei = kaigai = 0
for Si in S:
  if Si == 'a':
    if kakutei < A+B:
      print 'Yes'
      kakutei += 1
    else:
      print 'No'
  elif Si == 'b':
    if kakutei < A+B and kaigai < B:
      print 'Yes'
      kakutei += 1
      kaigai += 1
    else:
      print 'No'
  else:
    print 'No'
 

Measured memory_bytes: 3076
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 15 2019 
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;

vi v(10000 , 0);


auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 
    ivv(s);
    int counter = 1; 
    int mx = INT_MIN;
    v[s]++;
    while(true){
        s = (s&1)?(3*s+1):(s/2);
        counter++;
        if(v[s]!=0){
            cout<<counter<<endl;
            return;
        }else{
            v[s]++;
        }
    } 
//    cout<<counter+3<<endl;
    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N, A, B, C, D;  cin >> N >> A >> B >> C >> D;
	A -= 1, B -= 1, C -= 1, D -= 1;
	string s;  cin >> s;

	bool ans = true;
	for(int i = A ; i < max(C, D) ; i++)
		if(s.substr(i, 2) == "##")  ans = false;

	if(D < C){
      	bool flag = false;
		for(int i = B ; i <= D ; i++)
			if(i>=0&&i<N&&s.substr(i-1,3)== "...")  flag = true;
      
        if(!flag)  ans = false;  
	}

	if(ans)  cout << "Yes" << endl;
	else     cout << "No"  << endl;

	return 0;
}


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

int main(){
	string s;
	while(cin >> s){
		for(int i = 0; i < 9; ++i){
			for(int j = 0; j < 9 - i; ++j){
				s[j] = ((s[j] - '0') + (s[j+1] - '0')) % 10 + '0';
			}
		}
		cout << s[0] - '0' << endl;
	}
}

Measured memory_bytes: 1180
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

const int N=2005;
const int P=998244353;
const int INF=0x3f3f3f3f;

int n,k,q;
int a[N],id[N];
int vis[N];
int cur[N],Index;
int res[N],ans=INF;

inline bool cmp(int x,int y){
	return a[x]<a[y];
}

inline bool cmp_2(int x,int y){
	return x>y;
}

void init(){
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),id[i]=i;
	sort(id+1,id+n+1,cmp);
	for(int i=0;i<n;i++){
		// > a[id[i]]
		int last=0,cnt=0;
		for(int j=1;j<=n+1;j++){
			if(a[j]<=a[id[i]]){
				//last+1 -> j-1
				Index=0;
				for(int t=last+1;t<=j-1;t++) cur[++Index]=a[t];
				last=j;
				if(Index>=k){
					nth_element(cur+1,cur+k,cur+Index+1,cmp_2);
					for(int t=k;t<=Index;t++) res[++cnt]=cur[t];
				}
			}
		}
		//for(int j=1;j<=cnt;j++) printf("%d ",res[j]); printf("\n");
		if(cnt>=q){
			nth_element(res+1,res+q,res+cnt+1);
			int tmp=res[q];
			nth_element(res+1,res+1,res+cnt+1);
			ans=min(ans,tmp-res[1]);
		}
	}
	printf("%d\n",ans);
}

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

Measured memory_bytes: 256
def solve_131b(n, l):
    sum = 0
    min = 100000
    for i in range(1, n+1):
        sum += (l + i - 1)
    
    if l >= 0:
        min = l
    elif l + n - 1 <= 0:
        min = l + n - 1
    else:
        min = 0
    
    return sum - min

n, l = map(int, input().split())
print(solve_131b(n, l))

Measured memory_bytes: 3060
// ConsoleApplication77.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b || a == c)
	{
		if (b == c)
		{
			cout << "No\n";
		}
		else
		{
			cout << "Yes\n";
		}
	}
	else if (b == c)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);
#define endl "\n"
#define MAXN 2*100123
#define ll long long
#define INF INT_MAX
#define FORE(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) FORE(i,0,n)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define ps(v) push_back(v)
#define ms(v,x) memset(v,x,sizeof(v)) 

using namespace std;

int n,v;
int freq[MAXN];

int main(){_
    cin >> n;

    FOR(i,n-1){
        cin >> v;
        freq[v]++;
    }

    FORE(i,1,n+1){
        cout << freq[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin>>s;
	bool flag = false;
	if (s.size() % 2 == 0){
	for(int i = 0; i < s.size() - 1; i+= 2) {
			if(s[i] == 'h' && s[i + 1] == 'i'){
				flag = true;
				continue;
			}
			else{
				cout << "No" << endl;
				return 0;
			}
	}
	}
	if (flag){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nk = readints;
    int n = nk[0], k = nk[1];
    auto a = readints;

    auto dp = new int[a.length];
    for (int i = 1; i < a.length; i++) {
        dp[i] = int.max;
        for (int j = max(0, i - k); j < i; j++) {
            dp[i] = min(dp[i],
                        dp[j] + abs(a[j] - a[i]));
        }
    }
    writeln(dp[$ - 1]);
}


Measured memory_bytes: 4516
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=998244353;
const ll inf=1e18;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define lb(x,a) lower_bound(all(x),a)
#define ub(x,a) upper_bound(all(x),a)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()



void solve(){
 ll n,q;
  cin >> n >> q;
 ll ans=(n-2)*(n-2);
 vll x(n,n-1),y(n,n-1);
 
  ll h=n-1,w=n-1;
  
  
  while(q--){ 
  ll t,u;
   cin >> t >> u;
   --u;
   if(t==1){
     if(u<w){
    rep(i,u,w) y[i]=h;
    w=u;
     }
    ans-=y[u]-1;
     
   }else{
     if(u<h){
    rep(i,u,h) x[i]=w;
    h=u;
     }
    ans-=x[u]-1;
     
   }
   
 }
  cout << ans << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 6352
#include<iostream>
using namespace std;
int main(void){
  long long a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  long long ans_water=100*a,ans_sugar=0;
  double ans_rate=0.000;
  for(int i=0;i*100*a<=f;i++){
    for(int j=0;i*100*a+j*200*b<=f;j++){ 
       for(int k=0;i*100*a+j*200*b+k*c<=f;k++){
          for(int l=0;i*100*a+j*200*b+c*k+d*l<=f;l++){
            if(i==0&&j==0)continue;
            if(k==0&&l==0)continue;
            double tmp_rate = (double)(c*k+d*l)/(i*100*a+j*200*b+c*k+d*l);
              if(c*k+d*l <= (i*100*a+j*200*b)*e/(double)100  &&  tmp_rate>ans_rate){
              ans_rate = tmp_rate;
              ans_water = i*100*a+j*200*b;
              ans_sugar = c*k+d*l;
            }
            
          }
       }
    }
  }
 cout << ans_water+ans_sugar <<endl;
 cout << ans_sugar ;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	ll L, R;
	cin >> L >> R;
	ll min = 2019;

	R = R - (ll)(L / 2019) * 2019;
	L = L - (ll)(L / 2019) * 2019;

	if (R >= 2019) {
		cout << 0 << endl;
	}
	else if(L==0){
		cout << 0 << endl;
	}
	else {
		range(i, L, R+1) {
			range(k, i + 1, R+1) {
				chmin(min, (i * k) % 2019);
			}
		}

		cout << min << endl;
	}



	return 0;
}



Measured memory_bytes: 256
// #define DEBUG_MODE
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(x) fprintf(stderr, "[%s = %d]\n", #x, x)
#else
	#define errp(...)
	#define dbg(x) 
#endif

const int N = 200010;
char s[N];
int a, b, c, d, n;

bool possible () {
	if (c < d) {
		for (int i = b + 1; i < d - 1; i++)
			if (s[i] == '#' && s[i + 1] == '#') return false;
		for (int i = a + 1; i < c - 1; i++)
			if (s[i] == '#' && s[i + 1] == '#') return false;
		return true;
	}
	bool emp = false;
	for (int i = b; i <= d; i++)
		if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
			emp = true;
			break;
		}
	if (!emp) return false;
	for (int i = b + 1; i < d - 1; i++)
		if (s[i] == '#' && s[i + 1] == '#') return false;
	for (int i = a + 1; i < c - 1; i++)
		if (s[i] == '#' && s[i + 1] == '#') return false;
	return true;
}

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	a--; b--; c--; d--;
	scanf("%s", s);
	if (possible()) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define maxn 1000000001
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,k,m,i,j;
vector<int> a[9],p1,p2,ans;
vector<int> inv(vector<int> A){
	vector<int> B(n);
	for(i=0;i<n;i++)
		B[A[i]]=i;
	return B;
}
vector<int> mul(vector<int> A,vector<int> B){
	vector<int> C(n);
	for(i=0;i<n;i++)
		C[i]=A[B[i]];
	return C;
}
vector<int> ksm(vector<int> A,int v){
	vector<int> B;
	for(i=0;i<n;i++)
		B.push_back(i);
	while(v){
		if(v&1)
			B=mul(B,A);
		A=mul(A,A);
		v>>=1;
	}
	return B;
}
int main(){
    n=read();k=read();
    for(i=1;i<=n;i++)
    	a[1].push_back(read()-1);
    for(i=1;i<=n;i++)
    	a[2].push_back(read()-1);
    for(j=3;j<=6;j++)
    	a[j]=mul(a[j-1],inv(a[j-2]));
    p1=mul(a[4],a[1]);
    p2=inv(p1);
    m=(k-1)/6;
    ans=mul(mul(ksm(p1,m),a[(k-1)%6+1]),ksm(p2,m));
    for(i=0;i<n;i++)
    	pus(ans[i]+1,1);
    cout<<endl;
    return 0;
}

Measured memory_bytes: 9808
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define cs const 
#define fr first 
#define se second
#define ls (now<<1)
#define rs (now<<1|1)
#define mid ((l+r)>>1)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define low(i) (i&(-i))
#define par pair<int,int>
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define sep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
 
cs int G = 3;
cs int ff = 2e6 + 1;
cs int inf = 1e18 + 1;
cs int base = 2333;
cs int mod = 1e9 + 7;

struct Node
{
	int tr[ff];
	void modi(int now, int l, int r, int ps, int va)
	{
		if(l > ps || r < ps) return;
		if(l == r && l == ps) return (void)(tr[now] = max(tr[now], va));
		modi(ls, l, mid, ps, va); modi(rs, mid + 1, r, ps, va);
		tr[now] = max(tr[ls], tr[rs]);
	}
	int qry(int now, int l, int r, int lc, int rc)
	{
		if(l > rc || r < lc) return 0;
		if(lc <= l && r <= rc) return tr[now];
		return max(qry(ls, l, mid, lc, rc), qry(rs, mid + 1, r, lc, rc));
	}
}Seg;
int n, k, a[ff], pre[ff], f[ff], Ans;
void init()
{
	cin >> n >> k;
	rep(i, 1, n) scanf("%lld", &a[i]), a[i] ++;
	rep(i, 1, n)
	{
		pre[i] = Seg.qry(1, 1, 300001, max(a[i] - k, 1LL), min(a[i] + k, 300001LL)) + 1;
		if(!pre[i]) pre[i] = 1;
		Seg.modi(1, 1, 300001, a[i], pre[i]);
		Ans = max(Ans, pre[i]);
	//	cout << i << " " << pre[i] << "\n";
	}
//	rep(i, 1, n) f[i] = f[pre[i]] + 1, Ans = max(Ans, f[i]);
//	rep(i, 1, n) cout << pre[i] <<" " <<f[i] <<"\n";
	cout << Ans;
}
signed main()
{
	int Ts = 1;
//	cin >> Ts;
	while(Ts--)
		init();
}

Measured memory_bytes: 16592
#include <bits/stdc++.h>
using namespace std;
// ==================================================
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(int64_t)(a);i<(int64_t)(b);i++)
#define repn(i,n) rep(i,0,n)
#define din(t, ...) t __VA_ARGS__;_din(__VA_ARGS__)
#define v(t,n) vector<t> n
void _din() {}
void dout() { cout << endl; }
template <typename T, typename ... Args> inline void _din(T& head, Args& ... rest) { cin >> head; _din(rest...); }
template <typename T, typename ... Args> inline void dout(T head, Args ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
template <typename T>inline void qsortv(vector<T>& v) { qsort(v.data(), v.size(), sizeof(T), [](const void*a, const void*b)->int {if ((*(T*)a) < (*(T*)b))return -1; if ((*(T*)a) == (*(T*)b))return 0; return 1; }); }
template <typename T, typename F>inline void qsortv(vector<T>& v, F func) { qsort(v.data(), v.size(), sizeof(T), func); }
template <typename T>inline void sortv(vector<T>& v) { sort(v.begin(), v.end()); }
// ==================================================

int main()
{
	din(int, n);
	dout(n%2?2*n:n);
}

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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mod 1000000007
#define INF 1e9+5
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define lp(i,a,b) for(i=a;i<b;++i)
#define lpr(i,a,b) for(i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;

int main(){

  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/

  fast;
  int i,j,tc,ip,n;
  cin>>tc;
  string s;
  set<string> st;
  while(tc--){
    cin>>s;
    st.insert(s);
  }
  cout<<st.size()<<endl;
  return 0; 
} 


Measured memory_bytes: 19244
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <set>
#include <queue>
#include <math.h>
#include <stdbool.h>

#define LL long long
#define inf 0x3f3f3f3f
using namespace std;
const int MAXN=1000005;

int D[105],L[105];

int main()
{
    //freopen("../in.txt","r",stdin);
    int N,X;
    cin >> N >> X;
    D[1] = 0;
    for (int i=1;i<=N;i++)
        cin >> L[i];
    for (int i=2;i<=N+1;i++)
    {
        D[i] = D[i-1] + L[i-1];
    }
    int cnt = 0;
    for (int i=1;i<=N+1;i++)
    {
        if (D[i]<=X)
            cnt++;
        else
            break;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
  ll n;
  cin>>n;
  ll ans=1,mod=1e9+7;
  for(ll i=1;i<=n;i++){
    ans*=i;
    ans%=mod;
  }
  cout<<ans<<endl;
}

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

int main() {
    int n;
    cin >> n;
    
    vector<pair<int, int>> r(n), b(n);
    for (auto& e : r) cin >> e.first >> e.second;
    for (auto& e : b) cin >> e.first >> e.second;
    sort(begin(r), end(r), [](auto a, auto b) { return a.second > b.second; });
    sort(begin(b), end(b));

    int ans = 0;
    for (auto& bp : b) {
        for (auto itr = begin(r); itr != end(r); itr++) {
            if (bp.first > itr->first && bp.second > itr->second) {
                ans++;
                r.erase(itr);
                r.shrink_to_fit();
                break;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())

if N < 10:
  print(N)
elif N < 100:
  print(9)
elif N < 1000:
  print(9+N-99)
elif N < 10000:
  print(909)
elif N < 100000:
  print(9+900+N-9999)
else:
  print(90909)

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

int GCD(int a, int b) {return b ? GCD(b, a % b) : a;}

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    vector<int> left(N+1, 0), right(N+1, 0);
    for (int i = 0; i < N; i++) left[i+1] = GCD(left[i], a[i]);
    for (int i = N-1; i >= 0; i--) right[i] = GCD(right[i+1], a[i]);

    int res = 0;
    for (int i = 0; i < N; i++) {
        int l = left[i];
        int r = right[i+1];
        res = max(res, GCD(l, r));
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int powten[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000};

int f(int i, int j, vector<string>& s, vector<int>& a, map<char, int>& m, vector<bool>& b) {
	if (j == 8) return 1;
	int N = s.size();
	if (i == N) {
		/*for (int i = 0; i < N; i++)
			cout << a[i] << ' ';
		cout << endl;
		string x; cin >> x;*/
		int sum = 0;
		for (int i = 0; i < N - 1; i++)
			sum += a[i];
		if ((sum - a[N - 1]) % powten[j + 1])
			return 0;
		return f(0, j + 1, s, a, m, b);
	}
	if (j >= s[i].length())
		return f(i + 1, j, s, a, m, b);
	char c = s[i][s[i].length() - j - 1];
	if (m[c] == -1) {
		int sum = 0, x = (s[i].length() >= 2 && s[i].length() - j - 1 == 0 ? 1 : 0);
		for (int k = x; k < 10; k++) {
			if (b[k]) continue;
			b[k] = true;
			m[c] = k;
			a[i] += k * powten[j];
			sum += f(i + 1, j, s, a, m, b);
			b[k] = false;
			m[c] = -1;
			a[i] -= k * powten[j];
		}
		return sum;
	}
	else {
		if (m[c] == 0 && s[i].length() >= 2 && s[i].length() - j - 1 == 0)
			return 0;
		a[i] += m[c] * powten[j];
		int res = f(i + 1, j, s, a, m, b);
		a[i] -= m[c] * powten[j];
		return res;
	}
}

int main() {
	for (;;) {
		int N; cin >> N;
		if (N == 0) break;
		vector<string> s(N);
		for (int i = 0; i < N; i++)
			cin >> s[i];
		vector<int> a(N);
		map<char, int> m;
		for (char c = 'A'; c <= 'Z'; c++)
			m[c] = -1;
		vector<bool> b(10);
		cout << f(0, 0, s, a, m, b) << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    REP(i,N){
        ll a;
        cin >> a;
        if(i%2 == 0 && a % 2 == 1)
            ans++;
    }

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


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

int main() {
  int  N,M,C,ans = 0;
  cin >> N >> M >> C;
  vector<int> A(M);
  vector<int> B(M);
  for(int i = 0;i < M;i++){
    cin >> B.at(i);
  }
  for(int i = 0;i < N;i++){
    for(int j = 0;j < M;j++){
      cin >> A.at(j);
    }
    int tmp = 0;
      for(int j = 0;j < M;j++){
        tmp += A.at(j) * B.at(j);
      }
    if(tmp + C > 0)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int H, W;
    cin >> H >> W;
    vec<string> S(H, "");
    rep(i, H) cin >> S[i];

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

    rep(i, H) rep(j, W) {
        if(S[i][j] == '#') continue;
        int num = 0;
        for (int d = 0; d < 8; ++d) {
            int ni = i + dy[d];
            int nj = j + dx[d];

            if (ni < 0 or H <= ni) continue;
            if (nj < 0 or W <= nj) continue;
            if (S[ni][nj] == '#') num++;
        }
        S[i][j] = (char)(num+'0');
    }
    rep(i,H) cout << S[i] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <iostream>
//#include <iomanip>
//#include <vector>
//#include <cmath>
//#include <algorithm>
using namespace std;


#define F first
#define PB push_back
#define MP make_pair

typedef long long ll;

ll p = pow(10, 9) + 7;
int siz = pow(10, 9);



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b,c;
    cin >> a >> b >> c;
    if(a * b * c == 5 * 5 * 7)
    {
        cout << "YES" << endl;
    }else
    {
        cout << "NO" << endl;
    }

}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> chara(26);

    for(int in=0;in<s.size();in++) {
        chara.at(s.at(in)-'a')++;
    }

    for(int in=0;in<26;in++) {
        if(chara.at(in)>1) {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}


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

int main() {
    long long int i, n, c, cal=0;
    long long int x[110000]={0}, v[110000]={0};
    long long int sum_r[110000]={0}, sum_l[110000]={0};
    long long int counter_l[110000]={0}, counter_r[110000]={0};
    
    cin >> n >> c;
    
    for(i=1; cin >> x[i] >> v[i]; i++);
    
    for(i=1; i<=n; i++) {
        sum_r[i] = sum_r[i-1] + v[i];
        sum_l[i] = sum_l[i-1] + v[n-i+1];
    }
    for(i=1; i<=n; i++) {
        sum_r[i] -= x[i];
        sum_l[i] -= c-x[n-i+1];
    }
    
    for(i=1; i<=n; i++) {
        counter_l[i] = max(counter_l[i-1], sum_l[i]);
        counter_r[i] = max(counter_r[i-1], sum_r[i]);
    }
    
    for(i=1; i<=n; i++) {
        cal = max(cal, max(sum_r[i], sum_r[i]-x[i]+counter_l[n-i]));
        cal = max(cal, max(sum_l[i], sum_l[i]-(c-x[n-i+1])+counter_r[n-i]));
    }
    
    cout << cal << endl;
}

Measured memory_bytes: 5376
N=int(input())
A=list(map(int,input().split()))
d=[[0]*N for i in range(60)]
for i,a in enumerate(A):
    for j in range(60):
        d[j][i]=a%2
        a>>=1
m=10**9+7
r=0
for i in range(60):
    s=sum(d[i])
    r=(r+(N-s)*s*pow(2,i,m))%m
print(r%m)

Measured memory_bytes: 185912
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=2e5+7;
int n,q,A,B,X[N];
typedef long long LL;
struct node{
	LL L,det;
}d[N<<2];
void modify(int l,int r,int o,const int&L,const int&R,const LL&val,const int&delta){
	if(L<=l&&r<=R){
		LL yL=d[o].L,yR=yL+(r-l)*d[o].det;
		LL nL=val+(l-L)*delta,nR=nL+(r-l)*delta;
		if(nL>=yL&&nR>=yR)return;
		if(nL<=yL&&nR<=yR){d[o]=(node){nL,delta};return;}
	}
	const int mid=l+r>>1;
	if(L<=mid)modify(l,mid,o<<1,L,R,val,delta);
	if(mid<R)modify(mid+1,r,o<<1|1,L,R,val,delta);
}
LL TAG;
LL query(int l,int r,int o,const int&pos){
	if(l==r)return d[o].L;
	LL nans=d[o].L+(pos-l)*d[o].det;
	const int mid=l+r>>1;
	if(pos<=mid)return min(nans,query(l,mid,o<<1,pos));else
	return min(nans,query(mid+1,r,o<<1|1,pos));
}
int main(){
	scanf("%d%d%d%d",&n,&q,&A,&B);
	for(int i=1;i<=n*4;++i)d[i].L=0x3f3f3f3f3f3f3f3f;
	for(int i=1;i<=q;++i)scanf("%d",X+i);
	modify(1,n,1,B,n,abs(A-X[1]),1);
	modify(1,n,1,1,B,abs(A-X[1])+B-1,-1);
	modify(1,n,1,A,n,abs(B-X[1]),1);
	modify(1,n,1,1,A,abs(B-X[1])+A-1,-1);
	for(int i=2;i<=q;++i){
		LL as=query(1,n,1,X[i]);
		modify(1,n,1,X[i-1],n,as-abs(X[i]-X[i-1]),1);
		modify(1,n,1,1,X[i-1],as+X[i-1]-1-abs(X[i]-X[i-1]),-1);
		TAG+=abs(X[i]-X[i-1]);
	}
	LL ans=0x3f3f3f3f3f3f3f3f;
	for(int i=1;i<=n;++i)
	ans=min(ans,TAG+query(1,n,1,i));
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  int a,b,c,tmp,cost;
  cin >> a >> b >> c;
  for (int i=0;i<2;i++) {
    if(a>b) {
      tmp = a;
      a = b;
      b = tmp;
    }
    if(b>c) {
      tmp = b;
      b = c;
      c = tmp;
    }
  }
  cost = b-a;
  cost = cost + c-b;
  cout << cost << endl;
  return(0);
}

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

using namespace std;

int main()
{
    int a,b;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        if(a==0&&b!=100)
            printf("%d\n",b);
        if(a==0&&b==100)
            printf("101\n");
        if(a==1&&b!=100)
            printf("%d\n",b*100);
        if(a==1&&b==100)
            printf("10100\n");
        if(a==2&&b!=100)
            printf("%d\n",b*10000);
        if(a==2&&b==100)
            printf("1010000\n");
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner; 
 public class Main {  
     public static void main(String[] args) {     
	 Scanner sc = new Scanner(System.in);   
	 int w = sc.nextInt();    
	 int n = sc.nextInt();
	 int[] values = new int[w];    
	 for (int i = 0; i < values.length; i++) {   
	     values[i] = i + 1;     
	 }     
	 for (int i = 0; i < n; i++) { 
	     String str = sc.next();   
	     String[] ab = str.split(",");   
	     int a = Integer.parseInt(ab[0]) - 1;   
	     int b = Integer.parseInt(ab[1]) - 1;
	     int c;   
	     c=values[a];
	     values[a]=values[b];
	     values[b]=c;   
	 }  
	 for(int i=0;i<values.length;i++){
	     System.out.printf("%d\n",values[i]) ;  }
	 } 
     } 

Measured memory_bytes: 26292
import sys
count = [0 for i in range(26)]

s = sys.stdin.read().lower()
# Ctrl + Dで入力終了

# 入力値sをイテレータに該当するcountにカウントアップしていく
# ord('文字列')でunicodeポイントを返す(a, b, c, … → 97, 98, 99, … )
for i in s:
    if 0 <= ord(i)-97 <= 25:
        count[ord(i)-97] += 1

# countを出力
for index, num in enumerate(count):
    print(f"{chr(index+97)} : {num}")



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

#define ll long long int

using namespace std;

int main(void) {
    ll n, p, tmp;
    ll ans = 1;
    cin>>n>>p;

    if(p==1){
        cout<<1<<endl;
        return 0;
    }else if(n==1){
        cout<<p<<endl;
        return 0;
    }

    /*
    map<ll, ll> prime_division;
    for(ll i=2; p>1; i++) {
        while((p % i) == 0) {
            prime_division[i]++;
            p /= i;
            if(prime_division[i]==n){
                ans*=i;
                prime_division[i]=0;
            }
        }
    }
    */

    for (int i=2; pow(i, n) <= p; i++) {
        tmp = (ll)pow(i, n);
        while(p % tmp == 0) {
            ans*= i;
            p /= tmp;
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys
n=int(input())
ws = set()
for _ in range(n):
    w = input()
    if w in ws:
        print('No')
        sys.exit()
    if ws and b != w[0]:
        print('No')
        sys.exit()
    ws.add(w)
    b = w[-1]
print('Yes')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const long LONG_INF = 2147483647;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a,b,k;
    cin >> a >> b >> k;
    int count = 0;
    rrrep(i, 100, 1) {
        if (a % i == 0 && b % i == 0) {
            count++;
            if (count == k) {
                cout << i << endl;
                break;
            }
        }
    }
    
    
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    string S, T;
    cin >> S >> T;
    cout << T + S << endl;
    return 0;
}

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

int main()
{
    int N, W;
    cin >> N >> W;
    int value[N], weight[N];
    for (int i = 0; i < N; i++) {
        cin >> value[i] >> weight[i];
    }
    // dp[i][w] := i 番目の品物までを見た時に重さがwを超えない時の価値の最大値
    int dp[N + 5][W + 5] = {};
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int w = 0; w < W + 1; w++) {
            // i番目の品物を入れる時
            if (w - weight[i] >= 0) {
                dp[i + 1][w] = max(dp[i][w], dp[i][w - weight[i]] + value[i]);
            }
            // 入れられない時
            dp[i + 1][w] = max(dp[i + 1][w], dp[i][w]);
        }
    }
    printf("%d\n", dp[N][W]);
}



Measured memory_bytes: 7244