akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(a[i] > i){
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = 0;
    int pre = 0;
    for(int i = n - 1; i >= 0; --i){
        if(a[i] > pre){
            ans += a[i];
            pre = a[i];
        }
        else{
            if(pre - a[i] >= 2){
                cout << -1 << endl;
                return 0;
            }
            if(pre == a[i]) ans += a[i];
            pre = a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main (void) {
  
  int N,A[100];
  float B[100];  //逆数の配列//
  
  //入力//
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  
  //逆数の総和をaとする//
  float a = 0;
  for (int i = 0; i < N; i++) {
    B[i] = 1 / (float)A[i];
    a += B[i];
  }
  
  //逆数の総和の逆数をbとする//
  float b = 1 / a;
  
  //出力//
  printf("%f", b);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define first fst
#define second scd

#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  int a,b;
  cin>>a>>b;
  if(b%a==0) cout<<a+b<<endl;
  else cout<<b-a<<endl;

  return 0;
}









Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int arr[3];
	int n= 3;
	arr[0] = a;
	arr[1] = b;
	arr[2] = c;
	int cc, d, t;
 
	  for (cc = 0 ; cc < ( n - 1 ); cc++)
	  {
		for (d = 0 ; d < n - cc - 1; d++)
		{
		  if (arr[d] > arr[d+1])
		  {
		    t         = arr[d];
		    arr[d]   = arr[d+1];
		    arr[d+1] = t;
		  }
		}
	  }
	a = arr[0];
	b = arr[1];
	c = arr[2];
	if(a==5 && b==5 && c==7){
		printf("YES");
	}else{
		printf("NO");
	}
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    int a[n],sum = 0;
    for(itn i = 0;i < n;i++)cin >> a[i];
    sum += abs(a[0]) + abs(a[n-1]);
    for(itn i = 1;i < n;i++)sum += abs(a[i]-a[i-1]);
    for(int i = 0;i < n;i++){
        int sum2 = 0,sum3 = 0;
        if(i == 0){
            sum2 = abs(a[i]) + abs(a[i+1]-a[i]);
            sum3 = abs(a[i+1]);
        } else if(i == n-1){
            sum2 = abs(a[i]) + abs(a[i]-a[i-1]);
            sum3 = abs(a[i-1]);
        } else {
            sum2 = abs(a[i]-a[i-1])+abs(a[i+1]-a[i]);
            sum3 = abs(a[i+1]-a[i-1]);
        }
        cout << sum-sum2+sum3 << endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    int ans = 1e9;
   
    for(int i=1;i<=n/2+1;i++){
        int a=i,b=n-i;
         int aketa=0;
        int bketa =0;
        while(a>0){
            aketa += a%10;
            a /=10; 
        }
        while(b>0){
            bketa += b%10;
            b /=10; 
        }
        ans = min(ans,aketa+bketa);
    }    
    cout << ans << endl;
 }

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    vector<int> b(N+1);
    for(int i = 1; i < N+1; i++){
        cin >> a.at(i);
    }

    for(int i = N; i > 0; i--){
        int n = i;
        int count = 0;
        while(n <= N){
            count += b.at(n);
            n += i;
        }
        if(count%2 != a.at(i)){
            b.at(i) = 1;
        }else{
            b.at(i) = 0;
        }
    }

    int m = 0;
    for(int i = 0; i < N+1; i++){
        m += b.at(i);
    }

    cout << m << endl;

    for(int i = 1; i < N+1; i++){
        if(b.at(i) == 1) cout << i << " ";
    }
    cout << endl;


}

Measured memory_bytes: 2432
import numpy as np
N, M = map(int,input().split())
H = list(map(int, input().split())) 
check = [1 for _ in range(N)]
for i in range(M):
    A, B = map(int,input().split())
    A -= 1
    B -= 1
    if H[A] == H[B]:
        check[B] = 0
        check[A] = 0
    elif H[A] > H[B]:
        check[B] = 0
    else:
        check[A] = 0
print(sum(check))

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

int main() {
	int n, t; scanf("%d%d", &n, &t);
	int tim;
	vector<pair<string, int>>ans;
	rep(i, n) {
		int h1, m1, h2, m2; string s1, s2;
		scanf("%d:%d", &h1, &m1); cin >> s1;
		scanf("%d:%d", &h2, &m2); cin >> s2;
		int tim1 = h1 * 60 + m1;
		if (i&&tim1 - tim >= t)ans.push_back({ s1, tim1 - tim });
		tim = h2 * 60 + m2;
	}
	printf("%d\n", ans.size());
	for (auto p : ans)cout << p.first << ' ' << p.second << endl;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    int M, D;
    cin >> M >> D;

    int cnt = 0;
    for(int i = 4; i <=M; i++){
        for(int j = 20; j <=D; j++){
            int d1 = (j%10);
            int d10 = (j/10);
            int mul = d1 * d10;
            if(mul == i && d1 >=2 && d10 >= 2) cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    char s[11],t[12];
    int n1,n2;
	cin>>s>>t;
	n1=strlen(s);
	n2=strlen(t);
	
	if(n1==n2-1&&strncmp(s,t,n1)==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
		
	


}


Measured memory_bytes: 3120
import sys
input = sys.stdin.readline


def main():
    k = int(input())
    num = 7
    d = 1
    for i in range(10**6):
        if num % k == 0:
            print(d)
            return
        num = (num*10 + 7) % k
        d += 1
    print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t n, k, q;
  cin >> n >> k >> q;
  
  vector<int64_t> a(q);
  for(int i=0; i<q; i++){
    cin >> a[i];
  }
  
  map<int64_t, int64_t> score;
  for(int j=0; j<q; j++){
    score[a[j]]++;
  }
  
  for(int m=1; m<n+1; m++){
    if(score[m]>q-k){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }

  
}

Measured memory_bytes: 10352
n = int(input())
ab = []
for i in range(n):
    ab.append(list(map(int,input().split())))
cd = []
for i in range(n):
    cd.append(list(map(int,input().split())))
cd.sort(key=lambda x:x[0])
ab.sort(key=lambda x:x[1],reverse=True)
ab.sort(key=lambda x:x[0])
tmp = -1
ans = 0
for i in range(n):
    ma = -1
    for j in range(n):
        if cd[i][0] > ab[j][0]:
            if ab[j][1] > ma and cd[i][1] > ab[j][1]:
                ma = ab[j][1]
                tmp = j
    if tmp != -1:
        ans+=1
        ab[tmp][1] = 201
    tmp = -1
    ma = -1
print(ans)

Measured memory_bytes: 39024
#include<stdio.h>

int check(char, char[]);

int main() {
  char S[100000];

  scanf("%s", S);

  if(check('0', S) > check('1', S)) printf("%d\n", check('1', S));
  else                              printf("%d\n", check('0', S));

  return 0;
}

int check(char color, char str[]) {
  int count = 0;
  int i = 0;

  while(str[i] != '\0') {
    if(i % 2 == 0) {
      if(str[i] != color) count++;
    } else {
      if(str[i] == color) count++;
    }
    i++;
  }

  return count;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MOD 1000000007
int n;
int m;
int a[1000000];
long long dp[1000000];
int main(){
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> a[i];
    }
    a[m] = 1000000;
    dp[0] = 1;
    int j = 0;
    for(int i=1;i<=n+1;i++){
        dp[i] = 0;
    }
    for(int i=0;i<n;i++){
        //cout << "dp[" << i << "]=" << dp[i] << endl;
        if(i == a[j]){
            j++;continue;
        }
        dp[i+1] = (dp[i+1]+dp[i])%MOD;
        dp[i+2] = (dp[i+2]+dp[i])%MOD;
        
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    string s; cin >> s;
    int len = s.length();
    vector<int> m(len+1);
    m[len] = 0;
    int ten = 1;
    REPD(i, len)
    {
        //cout << "s[i]=" << s[i] << '\n';
        m[i] = (m[i+1] + (((lol)s[i]-(lol)'0')*ten))%2019;
        ten = (ten*10)%2019;
        //cout << m[i] << endl;
    }
    sort(ALL(m));
    int save = 2020;
    int save2{1};
    FOR(i, 0, len)
    {
        if(save != m[i])
        {
            result += (save2*(save2-1))/2;
            save = m[i];
            save2 = 1;
        }
        else
        {
            save2++;
        }
        
    }
    if(m[len] == m[len-1])
    {
        result += (save2*(save2-1))/2;
    }
    

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 4376
k = gets.to_i

h = {1 => ('0'..'9').to_a }
luns = [*h[1]]

i = 2

while true do
  nums = h[i-1]
  
  h[i] = nums.flat_map do |n|
    a = n[0].to_i
    [a-1, a, a+1].select {|b| b >= 0 && b < 10}.map{|b| b.to_s + n }
  end.uniq
  
  luns = [*luns, *h[i]]
  new = luns.map(&:to_i).uniq
  if new.size > k
    puts new.sort[k]
    exit 0
  end

  i += 1
end


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

template <typename T>
void print(const T &v);

int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i, n)
    {
        cin >> p[i];
    }
    int mini = INF;
    int num = 0;
    for (int i = -100; i <= 200; i++)
    {
        bool flag = true;
        for (int j = 0; j < n; j++)
        {
            if (i == p[j])
            {
                flag = false;
                break;
            }
        }
        if (flag && mini > abs(i - x))
        {
            mini = abs(i - x);
            num = i;
        }
    }
    cout << num << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL A,B;
int k;
int main()
{
    cin>>A>>B>>k;
    int flag=1;
    while(k--){
        if(flag%2){
            if(A%2){
                A-=1;
            }
            B+=A/2;
            A/=2;
        }else{
            if(B%2){
                B-=1;
            }
            A+=B/2;
            B/=2;
        }
        flag+=1;
    }
    cout<<A<<" "<<B<<endl;
}


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

int main()
{
    long long n,b,r;
    cin>>n>>b>>r;
    if(b==0)
        cout<<0;
    else
    {
        long long t;
        t=n/(b+r);
        long long k=n%(b+r);
        if(k<=b)
            cout<<t*b+k;
        else
            cout<<t*b+b;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

/////////////         modの計算

int mod = 1000000007;

long long mod_adjust(long long a) {//	余りをとる(0～mod-1に調整する)
	if (a > mod) {
		return a % mod;
	}
	if (a < 0) {
		a *= -1;
		a %= mod;
		return mod - a;
	}
	return a;
}
int mod_adjust(int a) {//	余りをとる(0～mod-1に調整する)
	return (int)mod_adjust((long long)a);
}
int mod_add(int a, int b) {//	足し算
	a = mod_adjust(a), b = mod_adjust(b);
	long long k = a % mod; k += b % mod; k %= mod;
	return (int)k;
}
int mod_sub(int a, int b) {//	引き算
	long long k = mod_adjust((long long)a); k += mod_adjust((long long)b); k %= mod;
	return (int)k;
}
int mod_multi(int a, int b) {//	掛け算
	long long k = mod_adjust((long long)a); k *= mod_adjust((long long)b); k %= mod;
	return (int)k;
}
int mod_inv(int a) {//	逆元
	a = mod_adjust(a);
	if (a == 1) { return 1; }
	long long p = mod, q = a, m = 0, n = 1, r, c;

	while (q > 1) {
		r = p % q;
		c = p / q;
		c = mod_adjust(m - n * c);
		p = q, m = n, q = r, n = c;
	}
	return n;
}
int mod_div(int a, int b) {//	割り算
	return mod_multi(a, mod_inv(b));
}
int mod_pow(int x, int n) {//	累乗(logNオーダーなので速い)
	if (n < 0) {
		return mod_pow(mod_div(1, x), -n);
	}
	if (n == 0) {
		return 1;
	}
	if (n == 1) {
		return x;
	}
	if (n % 2 == 0) {
		int k = mod_pow(x, n / 2);
		return mod_multi(k, k);
	}
	else {
		int k = mod_pow(x, n / 2);
		return mod_multi(mod_multi(k, k), x);
	}
}

int* factorial = NULL;			//	階乗
int* factorial_inv = NULL;		//	階乗の逆元

//	階乗を事前に計算しておく関数。
//	Nはmod_combination(n, r)で呼び出されうる最大の数。
void calc_factorial(int N) {////////////////////////// 初めに必ず呼び出すこと！！！
	factorial = new int[N + 1];
	factorial_inv = new int[N + 1];

	factorial[0] = 1;
	factorial_inv[0] = 1;
	for (int i = 1; i <= N; i++) {
		factorial[i] = mod_multi(factorial[i - 1], i);
		factorial_inv[i] = mod_inv(factorial[i]);
	}
}
int mod_combination(int n, int r) {//	nCr	を計算する
	if (n < 0 || r < 0 || r > n) { return 0; }
	return mod_multi(factorial[n], mod_multi(factorial_inv[n - r], factorial_inv[r]));
}

int main() {
	int N, A, B, C; cin >> N >> A >> B >> C;

	calc_factorial(N * 2 + 3);

	int Pa = mod_div(A, A + B);
	int Pb = mod_div(B, A + B);

	int p = mod_div(100, A + B);

	long sum = 0;
	{
		int buf = mod_pow(Pa, N);

		for (int i = 0; i < N; i++) {
			sum = mod_add(sum, mod_multi(mod_multi(buf, (N+i)), mod_combination(N - 1 + i, i)));
			buf = mod_multi(buf, Pb);
		}
	}
	{
		int buf = mod_pow(Pb, N);

		for (int i = 0; i < N; i++) {
			sum = mod_add(sum, mod_multi(mod_multi(buf, (N + i)), mod_combination(N - 1 + i, i)));
			buf = mod_multi(buf, Pa);
		}
	}

	sum = mod_multi(sum, p);

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1920
/*
                    !!!!!!
                    !!!!!!!!!!
                     !!!!!!!!!!!!!!!
                       !!!!!!!!!!!!!!
                     !!!!!!!!!!!!!!!
                      !!!!!!!!!!!!
                      !!!!!!!!!!!!
                        !!!!!!!!!!!!
                        !!!!!!!!
                        !!!!!!!!!!
                       !!!!!!!!!!!!!!
                     !!!!!!!!!!!!!!!!
                    !!!!!!!!!!!!!!!!                                  !!!!!
                  !!!!!!!!!!!!!!!!!!!                               !!!!!!!!!!
                 !!!!!!!!!!!!!!!!!!!!!!!                 !         !!!!!!!!!!
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!              !!     !!!!!!!!!!!!
           !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        !!      !!!!!!!!
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!
              !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  !!!!!!!!!!!!
       !!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        !!!!!!
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!      !!!!!
          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        !!!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        !
          !!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
           !!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                  !!!!!!!!!!!!!!!!!!!!!!!!!!!!
                  !!!!!!!!!!!!!!!!!!!!!!!!!!
                  !!!!!!!!!!!!!!!!!!!!!!!!!
                   !!!!!!!!!!!!!!!!!!!!!!!!
                    !!!!!!!!!!!!!!!!!!!!
                    !!!!!!!!!!!!!!!!!!!
                     !!!!!!!!!!!!!!!!
                      !!!!!!!!!!!!!!!!
                      !!!!!!!!!!!!!!!
                       !!!!!!!!!!!!!!
                        !!!!!!!!!!!!
                        !!!!!!!!!!!!
                        !!!!!!!!!!!!
                          !!!!!!!!
                          !!!!!!
                           !!!!
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
lli a[3001];
lli INF=1e18;
lli dp[3001][3001][2];
lli f(lli i, lli j, lli c){
    //cout<<i<<" "<<j<<endl;
    if(i==j){
        if(c==1)return (-a[i]);
        else return a[i];
    }
    if(dp[i][j][c]!=INF)return dp[i][j][c];
    if(c==0)return dp[i][j][c]=(max(a[i]+f(i+1,j,1),a[j]+f(i,j-1,1)));
    else return dp[i][j][c]=(min(-a[i]+f(i+1,j,0),-a[j]+f(i,j-1,0))); 
}

int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
        lli n;
        cin>>n;
        for(lli i=0;i<=n;i++)for(lli j=0;j<=n;j++)dp[i][j][0]=INF,dp[i][j][1]=INF;
        for(lli i=0;i<n;i++)cin>>a[i];
        cout<<f(0,n-1,0);
        

  

 }

Measured memory_bytes: 141184
import sys, math, heapq
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
H, W = read_int()


# nomal
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]
res = [[0 for _ in range(W)] for _ in range(H)]
grid = []

for i in range(H):
    row = list(" ".join(input()).split())
    grid.append(row)

def solve():
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == ".":
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)
 
            if grid[H - i - 1][W - j - 1] == ".":
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 346760
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left

import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17

def check(books, x, i, m, n):
    ab = [0 for i in range(m)]
    ret = 0
    for k in range(n):
        if i % 2 == 1:
            book = books[k]
            for tab, b in enumerate(book[1:]):
                ab[tab] += b
            ret += book[0]
        i //= 2
    # print(bin(i), ab)
    for cab in ab:
        if cab < x:
            return INF

    return ret

def main():
    s = input().strip()
    t = input().strip()

    if t == s + t[-1]:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()



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

int main() {
    int K, X;
    cin >> K >> X;
    for (int i = X - K + 1; i < X + K; i++) {
        cout << i;
        if (i == X + K - 1) cout << endl;
        else cout << " ";
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.time.LocalTime;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;


public class Main {

    public static void main(String[] args) {
    
    	FastScanner scan = new FastScanner();
    	
    	int n = scan.nextInt();
    	System.out.println((-n%1000 + 1000) % 1000);
    	}   
    
    
    static class FastScanner{
    	
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer("");
    	String next() {
    		while(!st.hasMoreTokens())
    			try {
    				st = new StringTokenizer(br.readLine());
    			} catch (IOException e){
    				e.printStackTrace();
    			}
    		return st.nextToken();
    	}
    	
    	int nextInt() {
    		return Integer.parseInt(next());
    	}
    	
    	int [] readArray(int n) {
    		int [] a = new int[n];
    		for(int i=0; i<n ; i++) a[i] = nextInt();
    		return a;
    	}
    	
    	long nextLong() {
    		return Long.parseLong(next());
    	}
    	
    	
    }
    
   
}



Measured memory_bytes: 32696
import sys


def solve(A: int, B: int):
    return max(A + B, A - B, A * B)


# -----------------------------------------------------------------------------
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()

    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int

    ans = solve(A, B)
    if ans is not None:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
const long double eps = 1e-12;
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 10000000013LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
int n;
string s;
long long gogo[20000];
int solve(int len) {
	long long dying = 1;
	int itr = 0;
	long long now = 0;
	for (int q = 0; q < s.length(); ++q) {
		now *= 26LL;
		now += s[q] - 'a';
		now %= MAX_MOD;
		if (q >= len) {
			now += (MAX_MOD - ((dying * (s[q - len] - 'a') % MAX_MOD))) % MAX_MOD;
			now %= MAX_MOD;
		}
		else {
			dying *= 26LL;
			dying %= MAX_MOD;
		}
		if (q >= len - 1) {
			gogo[itr] = now;
			itr++;
		}
	}
	set<long long> nya;
	for (int i = itr - len - 1; i >= 0; --i) {
		nya.insert(gogo[i + len]);
		if (nya.find(gogo[i]) != nya.end()) return true;
	}
	return false;
}
int main() {
	cin >> n >> s;
	int bot = 0;
	int top = s.length();
	while (top - bot > 1) {
		int mid = (top + bot) / 2;
		if (solve(mid) == true) {
			bot = mid;
		}
		else top = mid;
	}
	cout << bot << endl;
}


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

s = []
k = 0
while N > 0:
	l = N % 26 #一番下のけた
	if l == 0:
		l = 26
	s.insert(0,chr(ord('a')+l-1))
	N = N-1
	N = N // 26
	k +=1


print(''.join(s))


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    for (int i = 0; i < N - 2; i++) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int n, k;
	cin >> k >> n;
	int arr[n];
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int distances[n];
	int maxi = 0;
	for(int i = 1; i < n; i++)
	{
		distances[i] = arr[i] - arr[i - 1];
		maxi = max(maxi, distances[i]);
	}
	distances[0] = arr[0] + k - arr[n - 1];
	maxi = max(distances[0], maxi);
	cout << k - maxi << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <cmath>

int main() {
	int N, x[100], y[100], v[100];
	std::scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		std::scanf("%d %d", x + i, y + i);
		v[i] = i;
	}
	std::sort(v, v + N, [&](int a, int b) {
		return std::atan2((double) y[a], (double) x[a]) < std::atan2((double) y[b], (double) x[b]);
	});
	long long x_sums[200], y_sums[200];
	x_sums[0] = 0;
	y_sums[0] = 0;
	for (int i = 1; i <= N * 2 - 1; ++i) {
		x_sums[i] = x_sums[i - 1] + x[v[(i - 1) % N]];
		y_sums[i] = y_sums[i - 1] + y[v[(i - 1) % N]];
	}
	long long max = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j <= i + N; ++j) {
			long long x_sum = x_sums[j] - x_sums[i], y_sum = y_sums[j] - y_sums[i];
			long long value = x_sum * x_sum + y_sum * y_sum;
			if (value > max) {
				max = value;
			}
		}
	}
	std::printf("%.16lf", std::sqrt(max));
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

bool isPrime[300000];
int primeCnt[300000];

int main(){
	memset(isPrime,1,sizeof(isPrime));
	memset(primeCnt,0,sizeof(primeCnt));
	isPrime[0]=isPrime[1]=0;
	for(int i=2;i<300000;i++){
		primeCnt[i]=primeCnt[i-1];
		if(isPrime[i]){
			primeCnt[i]++;
			for(int j=i*2;j<300000;j+=i){
				isPrime[j]=0;
			}
		}
	}

	int n;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		printf("%d\n",primeCnt[2*n]-primeCnt[n]);
	}

	return 0;
}

Measured memory_bytes: 2660
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
void No(){
    cout << "No" << endl;
    exit(0);
}
int main(){
    int n;
    int a[3] = {};
    cin >> n;
    rep(i,3)cin >> a[i];
    string s;
    vector<string> c(n);
    rep(i,n)cin >> c[i];
    rep(hoge,n){
        int i, j;
        i = c[hoge][0]-'A';
        j = c[hoge][1]-'A';
        if(a[i]==0 and a[j]==0)No();
        if(a[i]==0 or a[j]==0){
            if(a[i]>a[j]){
                a[i]--;
                a[j]++;
                s += 'A'+j;
            }else{
                a[i]++;
                a[j]--;
                s += 'A'+i;
            }
        }else{
            if(a[i]==1 and a[j]==1){
                if(hoge==n-1){
                    s += 'A'+i;
                }else{
                    if(c[hoge]==c[hoge+1]){
                        s += 'A'+i;
                        a[i]++;
                        a[j]--;
                    }else{
                        int ii = c[hoge+1][0]-'A';
                        int jj = c[hoge+1][1]-'A';
                        if(i==ii or i==jj){
                            s += 'A'+i;
                            a[i]++;
                            a[j]--;
                        }else{
                            s += 'A'+j;
                            a[j]++;
                            a[i]--;
                        }
                    }
                }
            }else{
                if(a[i]>a[j]){
                    a[i]--;
                    a[j]++;
                    s+='A'+j;
                }else{
                    a[i]++;
                    a[j]--;
                    s+='A'+i;
                }
            }
        }
    }
    cout << "Yes" << "\n";
    for(auto x : s){
        cout << x << "\n";
    }
}


Measured memory_bytes: 6768
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main(){
	int a, b;
	cin >> a >> b;

	if ((a - b) % 2 == 0) {
		cout << (a + b) / 2;
	} else {
		cout << "IMPOSSIBLE";
	}

	return 0;
}
  

Measured memory_bytes: 888
from collections import deque
import numpy as np
import math
import copy
import bisect  # index = bisect.bisect_left(list,num)

N, M = map(int, input().split())
E = [[] for i in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    E[a - 1].append(b - 1)
    E[b - 1].append(a - 1)


q = deque()
ans = 0
visited = [False for i in range(N)]
visited[0] = True
q.append((0, visited))
while(len(q) > 0):
    #print("q:", q)
    tmp, visited = q.popleft()
    if not(False in visited):
        ans += 1
    for e in E[tmp]:
        if not visited[e]:
            tmp_visited = copy.deepcopy(visited)
            tmp_visited[e] = True
            #print(e, tmp_visited)
            q.append((e, copy.deepcopy(tmp_visited)))

print(ans)

Measured memory_bytes: 13004
n, m = map(int, input().split())
p = 1000000007
aaa = [0] * (n + 1)
f = [0] * (n + 1)
for _ in range(m):
    x = int(input())
    aaa[x] = 1
f[0] = 1
if aaa[1] == 1:
    f[1] = 0
else:
    f[1] = 1
for i in range(2, n + 1):
    f[i] = (f[i - 1] + f[i - 2]) % p
    if aaa[i] == 1:
        f[i] = 0
print(f[n])


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

using namespace std;

int main() {

    int a[3];
    for (int i = 0; i < 3; i++)
        cin >> a[i];
    
    sort(a, a+3);
    int ans = 0;
    ans += abs(a[0] - a[1]);
    ans += abs(a[1] - a[2]);
    
    cout << ans << endl;
    
    
    
    
    return 0;
}




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


Measured memory_bytes: 3588
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int INF = 2147483647;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll sum=1;
    ll before_sum;
    bool can = true;
    rep(i,n){
        before_sum=sum;
        sum*=a[i];
        if(before_sum>sum){
            can = false;
        }

    }   

    if(sum>1000000000000000000){
        can = false;
    }
    if(can){
        cout << sum << endl;
    }
    else cout << -1 << endl;
    return 0;
 }

Measured memory_bytes: 4048
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for (int i=0; i<n; i++) cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int m,d,i=22,count=0;
	cin>>m>>d;
	while(i<=d&&d>=i){
        if((i%10)*((i/10)%10)<=m){
            if((i%10)*((i/10)%10)!=0){
                    if((i%10)>=2&&((i/10)%10)>=2)
                        count++;
            }

        }
            i++;
	}
	cout<<count<<endl;
	return 0;
}


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

#define int long long

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

int N, M;
int L[200000], R[200000], D[200000];
int x[100001];
int par[100001];
int rnk[100001];
int diff[100001];

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        rnk[i] = 0;
    }
}

int depth(int x) {
    if (par[x] == x) {
        return 0;
    } else {
        return depth(par[x]) + diff[x];
    }
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return find(par[x]);
    }
}

void unite(int x, int y, int D) {
    int dep_x = depth(x);
    int dep_y = depth(y);
    x = find(x);
    y = find(y);
    if (x == y) {
        return;
    }
    if (rnk[x] < rnk[y]) {
        par[x] = y;
        diff[x] = dep_y - D - dep_x;
    } else {
        par[y] = x;
        diff[y] = dep_x + D - dep_y;
        if (rnk[x] == rnk[y]) {
            rnk[x]++;
        }
    }
}

signed main() {
    cin >> N >> M;
    init(N+1);
    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i] >> D[i];
        unite(L[i], R[i], D[i]);
    }
    for (int i = 0; i < M; i++) {
        if (depth(R[i]) - depth(L[i]) != D[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    int a[5];
    for(int i=0; i<5; i++){
        cin >> a[i];
    }
    
    sort(a,a+5);
    
    for(int i=4; i>=0; i--){
        cout<<a[i];
        if(i==0){
            cout<<endl;
        }else{
            cout<<" ";
        }
    }
    return 0;
}



Measured memory_bytes: 3116
import bisect

n = int(input())
a = list(map(int,input().split()))

a.sort()
m = 0
ans = []

for i in a:
    R = i / 2
    p = bisect.bisect_left(a,R)
    if p == 0:
        r = a[p]
    else:
        r = a[p] if abs(a[p] - R) < abs(a[p - 1] - R) else a[p - 1]
    if m < i + min(r,i - r):
        m = i + min(r,i - r)
        ans = [i,r]
print(*ans)

Measured memory_bytes: 62704
// Dont be lazy. Dont look for simple and quick implementations. Be ready to do case-work and implement. Make sure the method is fully correct. 
// Read question properly, ques can be tricky


#include <bits/stdc++.h>
#include <chrono>
using namespace std;
 
#define int long long
 
#define pb push_back
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define f first 
#define s second
#define tup pair<pii,int>
#define ordk order_of_key
// const int M= 998244353;
const int M = 1e9+7;
const int MXN=2e5+10; 
 
int power(int a,int b) {int res=1;a%=M;while(b){if((b&1))res=(res*a)%M;a=(a*a)%M;b>>=1;}return res;}
inline void print(int a,int b){ cout << a << ' ' << b << endl;}
inline void print(int a,int b,int c){ cout << a << ' ' << b <<' '<< c << ' ' << endl;}
 
int n;

int32_t main(){
    fast;
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>= 22){
        cout << "bust\n";
    }
    else cout << "win\n";
    return 0;
}

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

int main() {
  
  int n;
  int m;
  cin >> n ;
  vector<int> a(n);
  
  for (int i = 1;i<n;i++){
    cin >> m;
    a.at(m-1) += 1;
  }
  for (int i = 0;i<n;i++){
    cout << a.at(i) << endl;
  }
}


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

int main(){
    long long n;
    std::cin >> n;
    
    std::vector<long long> vec(5);
    for(int i = 0; i < 5; ++i){
        std::cin >> vec.at(i);
    }

    long long min = *std::min_element(vec.begin(), vec.end()), ans = 5;
    if(1 <= n / min){
        if(0 == n % min){
            ans += n / min - 1;
        }else{
            ans += n / min;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll P, Q, R;
  IN(P,Q,R);

  //OUT(min(min(P+Q, Q+R), R+P));
  OUT(min({P+Q, Q+R, R+P}));

  return 0;
}

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


def solve(T: int, X: int):
    print(T/X)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    T = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(T, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.io.*;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {
  int n;
  int[][] f;
  int[][] p;
  int[] table;
  int res;
  public static void main(String[] args) {
    new Main().solve();
  }

  private void solve() {
    try(InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {

      n = in.nextInt();
      f = new int[n][10];
      for (int i = 0; i < n; i++) {
        f[i] = in.mapInt(10);
      }
      p = new int[n][11];
      for (int i = 0; i < n; i++) {
        p[i] = in.mapInt(11);
      }

      table = new int[10];
      res = Integer.MIN_VALUE;
      dfs(0);

      final int ans = res;
      out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  void evalute(){
    int sum = 0;
    boolean isAllZero = true;
    for (int i : table) {
      if(i == 0) continue;
      isAllZero = false;
    }
    if(isAllZero) return;

    for (int i = 0; i < n; i++) {
      int s = 0;
      for (int j = 0; j < 10; j++) {
        if(table[j] == 0) continue;
        s += f[i][j];
      }
      sum += p[i][s];
    }

    if(res < sum) {
      res = sum;
    }
  }

  void dfs(int cnt) {
    if(cnt == 10) evalute();
    else {
      table[cnt] = 0; dfs(cnt+1);
      table[cnt] = 1; dfs(cnt+1);
    }
  }

  int atoi(String s) { return Integer.parseInt(s); }
  long atol(String s) { return Long.parseLong(s); }

  static class InputReader implements AutoCloseable {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream), 32768);
      st = null;
    }
    public String next() {
      if (st == null || !st.hasMoreTokens()) {
        try { st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          throw new UncheckedIOException(e);
        }
      }
      return st.nextToken();
    }
    public int nextInt() { return Integer.parseInt(next()); }
    public long nextLong() { return Long.parseLong(next()); }
    int[] mapInt(int len) {
      int[] ret = new int[len];
      for (int i = 0; i < len; i++) ret[i] = Integer.parseInt(next());
      return ret;
    }
    long[] mapLong(int len) {
      long[] ret = new long[len];
      for (int i = 0; i < len; i++) ret[i] = Long.parseLong(next());
      return ret;
    }
    @Override public void close() throws IOException { br.close(); }
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <set>
#include <iterator>
#include <algorithm>

using namespace std;

int calc(string x, string y)
{
	string z;
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	set_intersection(x.begin(), x.end(), y.begin(), y.end(), back_inserter(z));
	z.erase(unique(z.begin(), z.end()), z.end());
	return z.size();
}

int main()
{
	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	for (int i = 1; i + 1 < N; ++i) {
		int ret = calc(S.substr(0, i), S.substr(i));
		ans = max(ans, ret);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
def nod(n) :
    i = 1
    while n > 26 ** i :
        n = n - 26 ** i
        i += 1
    return i
 
n = int(input())
i = nod(n)
##print(i)
demo = [26 ** j for j in range(12)]
demo1 = []
k = 0
for j in demo :
    k += j
    demo1.append(k)
##print(demo)
##print(demo1)
n = n - demo1[i - 1] + 1
##print(n)
##print(n / 26)
if n / 26 != n // 26 :
    i -= 1
    ans = []
    while i >= 0 :
        k = n // (26 ** i)
        n -= (26 ** i) * k
        if i > 0 :
            ans.append(chr(96 + k + 1))
        else :
            ans.append(chr(96 + k))
        i -= 1
    print(''.join(map(str,ans)))
else :
    i -= 1
    ans = []
    while i >= 0 :
        k = n // (26 ** i)
        n -= (26 ** i)*k
        if n > 0 :
            if i > 1 :
    ##            print(k,chr(96+k+1))
                ans.append(chr(96+k+1))
            elif i == 1 :
    ##            print(k,chr(96+k))
                ans.append(chr(96 + k))
            else :
                ans.append('z')
        else :
                ans.append(chr(96 + k))
                
                while i > 0 :
                    ans.append('z')
                    i -= 1
                break
        i -= 1
    print(''.join(map(str,ans)))


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
using ll = long long;
char o[N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k, r, s, p;
	cin >> n >> k >> r >> s >> p;
	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		char x;
		cin >> x;
		char y = x == 'r' ? 'p' : x == 'p' ? 's' : 'r';
		if (y == (i - k > 0 ? o[i - k] : 0))
			o[i] = 0;
		else
		{
			o[i] = y;
			ans += y == 'r' ? r : y == 'p' ? p : s;
		}
	}
	cout << ans;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,max1=-1,k,sum=0;
    for(int i=0;i<3;i++)
    {
        cin>>a;
        if(a>max1)
            max1=a;
        sum+=a;
    }
    cin>>k;
    sum-=max1;
    for(int i=0;i<k;i++)
        max1=max1*2;
    sum+=max1;
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int N, a[100000] = {}, odd = 0, two = 0, four = 0;
bool ok = false;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];

		if (a[i] % 4 == 0) {
			four++;
		}
		else if (a[i] % 2 == 0) {
			two++;
		}
		else {
			odd++;
		}
	}

	if (two < 2) {
		if (four + 1 >= odd + two) {
			ok = true;
		}
	}
	else {
		if (four >= odd) {
			ok = true;
		}
	}

	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
// Last Change: 07/20/2019 21:08:12.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (auto &&e : A) {
    cin >> e;
  }
  vector<ll> B = A;
  sort(B.begin(), B.end());

  for (auto &&e : A) {
    if (e == B[N - 1]) {
      cout << B[N - 2];
    } else {
      cout << B[N - 1];
    }
    cout << endl;
  }
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;scanf("%d",&n);
    vector<int> a(n+1);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    vector<int> na(n+1);
    for(int i=n;i>=1;i--){
        int cnt=0;
        for(int j=i;j<=n;j+=i){
            cnt+=na[j];
        }
        if(cnt%2!=a[i])na[i]=1;
    }
    int ans=accumulate(na.begin(),na.end(),0);
    if(ans){
        printf("%d\n",ans);
        for(int i=1;i<=n;i++){
            if(na[i]){
                if(ans==1)printf("%d\n",i);
                else printf("%d ",i);
                ans--;
            }
        }
    }
    else puts("0");
}

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

int main() {
  //input
  int N, K;
  string S;
  cin >> N >> K >> S;
  //calc
  int score = 0;
  if ( S.at(0) == 'R' && N > 1 ) {
    if ( S.at(1) == 'R' ) {
      score++;
    }
  }
  int RLcount = 0;
  for(int i=1; i<N;i++) {
    if ( S.at(i) == 'L' ) {
      if ( S.at(i-1) == 'L' ) {
        score++;
      }
      else {
	    RLcount++;
      }
    }
    else if ( i < N-1 ) {
      if ( S.at(i+1) == 'R' ) {
        score++;
      }
    }
  }
  int s_first, s_last;
  int X, Y;
  s_first = S.at(0);
  s_last = S.at(N-1);
  if ( s_first == s_last ) {
    X = RLcount;
    Y = 0;
  }
  else if ( s_first == 'L' ) {
      X = RLcount;
      Y = 1;
  }
  else {
    X = RLcount - 1;
    Y = 1;
  }
//  cout << "(" << X << "," << Y << ")" << endl;
  if ( K >= X + Y ) {
    score += 2 * X + Y;
  }
  else if ( K >= X ) {
    score += 2 * X;
  }
  else {
    score += 2 * K;
  }
  //output
  cout << score << endl;
}

Measured memory_bytes: 512