akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

L = defaultdict(int)
R = defaultdict(int)
for i in range(len(A)):
    L[A[i] + i] += 1
    R[i - A[i]] += 1

# print(L, R)
# print(L.keys(), R.keys())
ans = 0
for r in R.keys():
    if r in L.keys():
        ans += L[r] * R[r]
print(ans)


Measured memory_bytes: 53808
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

  ll ans = LINF;
  auto div = divisor(N);
  for (auto i : div) {
    ll j = N / i;
    ll move = i + j - 2;
    chmin(ans, move);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

#define test4(x,y,z,a) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cerr<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cerr<<"x is "<<x<<endl;

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

int main()
{
    IOS;
    ll n;
    cin>>n;
    ll a[n+1];
    ll mx=0;
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>=mx) ans++;
        mx=max(a[i],mx);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int j,i,n,q,C=0,mid=0,right=0,left=0,k=0;
  int S[100000],T[50000],c[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    left=0;
    right=n;
    while(left<right){
      mid=(left+right)/2;
      if(S[mid]==T[i]){
    C++;
        c[k]=S[mid];
        k++;
    break;
      }
      if(T[i]>S[mid]){
    left=mid+1;
      }
      else if(T[i]<S[mid]){
    right=mid;
      }
    }
  }
  printf("%d\n",C);
  return 0;
}



Measured memory_bytes: 2280
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 3e7 + 10;
const int  maxm = 300;
const int turn[4][2] = {{1, 0}, { -1, 0}, {0, 1}, {0, -1}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll mod = 1e9 + 7;
int num[5][105];
int dp[5][105];
int main()
{
        //ios_base::sync_with_stdio(0);
        //cin.tie(0);
        //freopen("chess.in", "r", stdin);
        //freopen("out1.txt", "w", stdout);
        int n;
        cin >> n;
        for (int i = 1; i <= 2; i++)
        {
                for (int j = 1; j <= n; j++)
                {
                        scanf("%d", &num[i][j]);
                }
        }
        for (int i = 1; i <= 2; i++)
        {
                for (int j = 1; j <= n; j++)
                {
                        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + num[i][j];
                }
        }
        cout << dp[2][n] << endl;
}


Measured memory_bytes: 256
use proconio::input;


fn main() {

let mut n : i128 ;
let mut x : i128 ;
let mut t : i128 ;


    input! {

   n : i128 , 
   x : i128 ,
   t : i128 ,
  
  
    }

 //let mut time = 

 println!("{}", ((n+(x-1))/x)*t );
 
}


Measured memory_bytes: 2096
let rec gcd n m =
  if m = 0 then n
  else gcd m (n mod m)

let lcm n m = n / gcd n m * m

let () = Scanf.scanf "%d %d\n%s\n%s" @@ fun n m s t ->
  Printf.printf "%d\n" @@
  let l = lcm n m in
  if
    List.fold_left (Array.fold_left ( && )) true
    [ Array.init n (fun i ->
        0 < i * l / n mod (l / m) ||
        s.[i] = t.[i * l / n / (l / m)]);
      Array.init m (fun i ->
        0 < i * l / m mod (l / n) ||
        t.[i] = s.[i * l / m / (l / n)]) ]
  then l
  else -1


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

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

int n , y;

int main()
{
    _FastIO;
    cin >> n >> y;
    if(y % 1000){
        cout << "-1 -1 -1" << endl;
        return 0;
    }
    y /= 1000;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            int x = y;
            x -= i * 10;
            x -= j * 5;
            if(x < 0)
                break;
            int s = i + j + x;
            if(s == n){
                cout << i << " " << j << " " << x << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


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

  string n;
  cin >> n;

  bool res = true;
  rep(i, n.length()) {
    if (i%2==0 && n[i] == 'L') res = false;
    if (i%2==1 && n[i] == 'R') res = false;
  }
  
  cout << (res?"Yes":"No")<<endl;
}


Measured memory_bytes: 760
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String a = scan.next();
        String b = scan.next();
        String c = scan.next();
        if(a.charAt(a.length() - 1) == b.charAt(0) && b.charAt(b.length() - 1) == c.charAt(0)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 22612
#include <stdio.h>

int main()
{
  int a,b,r;

  scanf("%d%d",&a,&b);
  r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  printf("%d\n",b);
  return 0;
}

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

int main(){
	int N;
	cin >> N;
	int P[N];
	rep(i,N) cin >> P[i];

	int Q[N];
	int minl = P[0];
	rep(i,N){
		minl = min(minl,P[i]);
		Q[i] = minl;
	}
	int ans = 0;
	rep(i,N){
		if (Q[i]>=P[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5148
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <limits>
#include <stdio.h>

template <typename T>
void vc(T t) {
    std::cout << t << " ";
}

template<typename T, typename... Args>
void vc(T t, Args... args) {
// recursive variadic function
    std::cout << t << " ";
    vc(args...) ;
}

const int N = 100000;

long long dp[3002][3002];
long long dpx(const std::vector<long long> vi, int l, int r) {
  // vc("x", l, r, "\n");
  if (l > r) {
    return 0;
  }
  if (dp[l][r] != 123456789012345LL) {
    return dp[l][r];
  }
  if (l == r) {
    dp[l][r] = vi[l];
    return vi[l];
  }
  // vc("-", l, r, dp[l][r], vll[0], vll[1], vll[2], vll[3], "\n");
  // vc("+", l, r, dp[l][r], "\n");
  return dp[l][r];
}

void once() {
  int n;
  std::cin >> n;
  std::vector<long long> vi(n + 1);
  for (int i = 1; i <= n; ++i) {
    std::cin >> vi[i];
  }

  for (int i = 0; i < 3002; ++i)
    for (int j = 0; j < 3002; ++j)
      dp[i][j] = 0LL;

  for (int len = 0; len < n; ++len) {
    for (int l = 1; l + len <= n; ++l) {
      int r = l + len;
      if (l == r) {
        dp[l][r] = vi[l];
        continue;
      }
      long long vll_0 = vi[l] - vi[l + 1] + dp[l + 2][r]; // ll
      long long vll_1 = vi[l] - vi[r] + dp[l + 1][r - 1]; // lr
      long long vll_2 = vi[r] - vi[l] + dp[l + 1][r - 1]; // rl
      long long vll_3 = vi[r] - vi[r - 1] + dp[l][r - 2]; // rr
      dp[l][r] = std::max(std::min(vll_0, vll_1), std::min(vll_2, vll_3));
    }
  }

  std::cout << dp[1][n] << std::endl;
}

int
main() {
  int n = 1;
  std::ios::sync_with_stdio(false);
  // std::cin >> n;
  while (n--) {
    once();
  }
}

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

int check(int n,int x,set<int> s){
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int xi=x-i-j;
            if(xi>i && xi>j){
                if(s.count(xi)) cnt++;
            }
        }
    }

    return cnt;
}

int main(){
    int n; cin>>n;
    int result=0;
    for(int i=1;i<=n;i++){
        if(i%2==0) continue;
        int cnt=0;
        for(int j=1;j<=i;j++){
            if(i%j==0) cnt++;
        }
        if(cnt==8) result++;
    }

    cout<<result<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
 
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
 
typedef vector<string> vs;
typedef vector<vs> vvs;
 
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
 
typedef map<string, int> msi;
 
typedef pair<int, int> pii;
typedef pair <ll, ll> pll; // note 'single' ls
 
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++)
 
#define pb \
push_back
 
#define ff \
first
 
#define ss \
second

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

  int out_of_order = 0;

  vi P;
  vi P_inv(n+1);

  REP(i, 1, n)
  {
    int p;
    cin >> p;

    P.pb(p);
    P_inv[p]=i;
  }

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

  // if (n==2)
  // {
  //   if (P[0] == 1) cout << 0 << endl;
  //   else cout << 1 << endl;

  //   return 0;
  // }

  // find longest contiguous section of non-flips ...

  vb not_flips;

  REP(i, 1, n-1)
  {
    not_flips.pb(P_inv[i]<P_inv[i+1]);
  }

  // for (auto f:not_flips)
  // {
  //   cout << f << endl;
  // }
  // cout << endl;

  vi flip_lengths;
  flip_lengths.pb(int(not_flips[0]));
  
  REP(i, 1, n-2)
  {
    if (not_flips[i]) flip_lengths.pb(flip_lengths.back()+1);
    else flip_lengths.pb(0);
  }

  // for (auto f:flip_lengths)
  // {
  //   cout << f << endl;
  // }
  // cout << endl;

  int max_f_length = 0;

  for (auto l:flip_lengths)
  {
    if (l > max_f_length)
    {
      max_f_length = l;
    }
  }

  cout << n - 1 - max_f_length << endl;

  return 0;
}

Measured memory_bytes: 4076
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int a, b, c;
	cin >> a >> b;
	if (a % 2 == 0 || b % 2 == 0) {
		PRIN;
	}
	else {
		PRIY;
	}
	return 0;
}

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

typedef long long ll;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //  --------------------------------------
    
    int N, M; cin >> N >> M;
    vector<pair<ll, int>> shop_list;
    
    for (int i = 0; i < N; i++) {
        ll A;
        int B;
        cin >> A >> B;
        pair<ll, int> shop = make_pair(A, B);
        shop_list.push_back(shop);
    }
    
    sort(shop_list.begin(), shop_list.end());
    
    ll ans = 0;
    int shop_counter = 0;
    int juice_counter = 0;
    while (juice_counter <= M) {
        ans += shop_list[shop_counter].first * shop_list[shop_counter].second;
        juice_counter += shop_list[shop_counter].second;
        shop_counter += 1;
    }
    
//    cout << juice_counter << " " << shop_counter << "\n";
    
    if (juice_counter > M) {
        ans -= shop_list[shop_counter-1].first * (juice_counter - M);
    }
    
    cout << ans << "\n";
    
//    for (int i = 0; i < N; i++) {
//        cout << shop_list[i].first << " " << shop_list[i].second << "\n";
//    }
    
    
}



Measured memory_bytes: 2420
#include <stdio.h>
int main(){
  int A[2000]={1},a,n,q,m,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    for(j=2000-a;j>=0;j--){
      if(A[j]) A[j+a]=1;
    }
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(A[m]) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

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

int main() {
    int A[2][100];
    int N;
    cin >> N;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }
    int B[100] = {0};
    int total = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            total = total + A[0][j];
        }
        for (int j = i; j < N; j++) {
            total = total + A[1][j];
        }
        B[i] = total;
        total = 0;
    }
    sort(B, B + N);
    cout << B[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S, T;
	cin >> S;
	cin >> T;
	int N = S.size();
	map<char, char> mp;
	string res = "Yes";
	for (int i = 0; i < S.size(); i++) {
		if (mp.count(S[i]) == 0) {
			mp[S[i]] = T[i];
		}
		else {
			if (mp[S[i]] != T[i])res = "No";
		}
	}
	swap(S, T);
	mp.clear();
	for (int i = 0; i < S.size(); i++) {
		if (mp.count(S[i]) == 0) {
			mp[S[i]] = T[i];
		}
		else {
			if (mp[S[i]] != T[i])res = "No";
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define zzz ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
bool check[5000]; ll ans;
int main()
{
    zzz;
    int n; cin>>n; vector<string> a(n);
    for(int i=0;i<n;++i) {cin>>a[i]; sort(a[i].begin(),a[i].end());}
    sort(a.begin(),a.end());map<string,int> x; for(auto l : a) x[l]++;
    for(auto l : x) ans+= (1ll*l.second*(1ll*l.second-1))/2;
    cout<<ans;
}


Measured memory_bytes: 12032
#if defined(__GNUC__)
#include <bits/stdc++.h>
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))
#define ACM(x, y) std::accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	std::ios::sync_with_stdio(false);

	int n, k;

	cin >> n >> k;

	vector<int> h(n);

	REP(i, n) {
		cin >> h[i];
	}

	SORT(h);

	REP(i, k) {
		if (!h.size()) {
			break;
		}
		h.pop_back();
	}

	int res = ACM(h, 0ll);

	cout << res;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;

	cin>>n>>k;

	int a[n],i;

	for(i=0;i<n;i++)
		cin>>a[i];

	int dp[n];

	for(i=0;i<n;i++)
		dp[i] = INT_MAX;

	dp[n-1] = 0;

	for(i = n-2;i>=0;i--)
	{
		for(int j=1;j<=k && i+j<n ;j++)
		{
			dp[i] = min(dp[i],dp[i+j]+abs(a[i+j] - a[i]));
		}
	}
	cout<<dp[0];


	return 0;
}

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


int main() {
  string s;
	cin >> s;
	int win = 0;
	int lose = 0;
	for(char c : s) {
	  if(c == 'o') win++;
	  if(c == 'x') lose++;
  }
  if(lose <= 7) cout << "YES";
  else cout << "NO";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> G(H);
    for(int i = 0; i < H; i++) cin >> G[i];

    vector<vector<int>> R(H, vector<int>(W));
    vector<vector<int>> L(H, vector<int>(W));
    vector<vector<int>> U(H, vector<int>(W));
    vector<vector<int>> D(H, vector<int>(W));

    for(int i = 0; i < H; i++){
        int cnt_l = 0;
        for(int j = 0; j < W; j++){
            if(G[i][j] == '#') cnt_l = 0;
            else cnt_l++;
            L[i][j] = cnt_l;
        }
        int cnt_r = 0;
        for(int j = W - 1; j >= 0; j--){
            if(G[i][j] == '#') cnt_r = 0;
            else cnt_r++;
            R[i][j] = cnt_r;
        }
    }
    for(int i = 0; i < W; i++){
        int cnt_u = 0;
        for(int j = 0; j < H; j++){
            if(G[j][i] == '#') cnt_u = 0;
            else cnt_u++;
            D[j][i] = cnt_u;
        }
        int cnt_d = 0;
        for(int j = H - 1; j >= 0; j--){
            if(G[j][i] == '#') cnt_d = 0;
            else cnt_d++;
            U[j][i] = cnt_d;
        }
    }
    int max_n = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) max_n = max(max_n , R[i][j] + L[i][j] + U[i][j] + D[i][j] - 3);
    }
    cout << max_n << endl;
}

Measured memory_bytes: 67328
import java.awt.geom.*;
import java.io.*;
import java.util.*;


public class Main {
	Scanner sc = new Scanner(System.in);
	LinkedList<String> stack;
	HashMap<String,HashSet<String> > map;
	String [] keys;
	HashSet<String>map0;
	
	private void doit(){
		
		keys = sc.nextLine().split("\\.");
		map0 = new HashSet<String>();
		stack = new LinkedList<String>();
		map = new HashMap<String, HashSet<String>>();
		mapping(0);
		check();
//		
//		//debug
//		for(int i = 0; i < keys.length; i++){
//			System.out.println("i=" + i + ":" + keys[i] + ".");
//		}
//		System.out.println(keys.length);
//		
//		//debug
//		for(String key: map.keySet()){
//			System.out.println("key=" + key +" "+ "valu="+map.get(key));
//		}
//		System.out.println();
		
	}
	
	

	private void check() {
		if(! map0.contains(keys[1])){
			System.out.println("no such property");
			return;
		}
		for(int i = 1; i < keys.length; i++){
			if(map.containsKey(keys[i])){
				if(i == 1) continue;
				HashSet<String> temp = map.get(keys[i-1]);
				if(temp.contains(keys[i])){
					
				}
				else{
					System.out.println("no such property");
					return;
				}
			}
			else{
				System.out.println("no such property");
				return;
			}
		}
		String now = keys[keys.length-1];
		HashSet<String> hs = map.get(now);
		if(hs.size() > 1){
			System.out.println("object");
		}
		else {
			String value = "";
			for(String s: hs){
				value = s;
			}
			if(map.containsKey(value) && ! value.equals(now)){
				System.out.println("object");
			}
			else{
				System.out.println("string \"" + value +"\"");
			}
		}
	}



	private HashSet<String> mapping(int n) {
		HashSet<String> res = new HashSet<String>();
		while(true){
			String line = gettoken();
			if(line == null) return res;
			int count = ci(line);
			if(count == n){
				String [] arr = line.split(":");
				String key = arr[0].trim();
				res.add(key);
				if(n == 0){
					map0.add(key);
				}
				mappingItem(n, line);
			}
			else{
				stack.add(line);
				return res;
			}
		}
	}



	private void mappingItem(int n, String line) {
		String [] arr = line.split(":");
		String key = arr[0].trim();
		if(arr.length == 1){
			String nline = gettoken();
			if(nline == null) return;
			int m = ci(nline);
			stack.add(nline);
			HashSet<String> value = mapping(m);
			map.put(key, value);
		}
		else{
			HashSet<String> value = new HashSet<String>();
			value.add(arr[1].substring(1));
			map.put(key, value);
		}
		
	}

	private String gettoken() {
		if(! stack.isEmpty()){
			return stack.removeLast();
		}
		if(sc.hasNext()){
			return sc.nextLine();
		}
		return null;
	}

	private int ci(String line) {
		int count = 0;
		for(int i = 0; i < line.length(); i++){
			if(line.charAt(i) != ' '){
				return count;
			}
			count++;
		}
		return -1;
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

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

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }
};


int main() {
    int N; cin >> N;
    vector<pair<int, int>> balls(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> balls[i].first;
        cin >> balls[i].second;
    }
    set<pair<int, int>> pq;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; i <= N; i++) pq.insert({balls[i].first - balls[j].first, balls[i].second - balls[j].second});
    }
    int ans = 100000;
    for (auto k : pq) {
        UnionFind uf = UnionFind(N+1);
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                if ((k.first == balls[i].first - balls[j].first && k.second == balls[i].second - balls[j].second)
                 || (k.first == balls[j].first - balls[i].first && k.second == balls[j].second - balls[i].second)) {
                     uf.unite(i, j);
                 }
            }
        }
        set<int> roots;
        for (int i = 1; i <= N; i++) {
            roots.insert(uf.find(i));
        }
        ans = min(ans, (int)roots.size());
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
b, c = map(int, input().split())
s = input()
c =c-1
if(c != 0 and c != b-1):
    print(s[0:c] + s[c].lower() + s[c+1:])
elif(c==0):
    print(s[0].lower() + s[1:])
else:
    print(s[0:c] + s[c].lower())

Measured memory_bytes: 3060
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;

template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a,T  b) { return a<b?(a=b,true):false; }
#define forn(i,x,y) for(int i=(x);i<(int)(y);i++)
#define rep(i,y) for(int i=0;i<(int)(y);i++)
#define repb(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)

int N;
int a[1000100];
bool inv[1000100];
bool note[1000100];
int main() {
    bool glb_non_pairwise = false;
    cin >> N;
    rep(i,N) {
        cin >> a[i];
        if (inv[a[i]]&&a[i]!=1) glb_non_pairwise=true;
        inv[a[i]] = true;
    }
    int p = gcd(a[0],a[1]);
    rep(i,N) {
        p=gcd(p,a[i]);
    }
    bool setwise = false;
    if (p==1) setwise = true;
    bool non_pairwise = false;
    for(int i=2;i<1000100;i++) {
        if (note[i]) continue;
        ll mul=1;
        int cnt=0;
        while(i*mul<1000100) {
            note[i*mul] = true;
            if (inv[i*mul]) cnt++;
            mul++;
        }
        if (cnt > 1) {
            non_pairwise = true;
            break;
        }
    }
    if (!non_pairwise&&!glb_non_pairwise) {
        cout << "pairwise coprime" << endl;
        return 0;
    } else if (setwise) {
        cout << "setwise coprime" << endl;
        return 0;
    } else {
        cout << "not coprime" << endl;
    }
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template <typename T> T read() {T t; cin >> t; return t;}

void Main() {
  int n = read<int>();
  vector<int> A(n), B(n);
  rep(i, n) {
    A[i] = read<int>();
    B[i] = read<int>();
  }

  vl dp(n);
  dp[0] = 1;
  rep(i, 1, n) {
    if (A[i-1] * B[i] > B[i-1] * A[i]) {
      dp[i] = (A[i-1] * dp[i-1] + A[i] - 1) / A[i];
    }
    else {
      dp[i] = (B[i-1] * dp[i-1] + B[i] - 1) / B[i];
    }
    //dp[i] = ceil(max(1.0*A[i-1]/A[i], 1.0*B[i-1]/B[i]) * dp[i-1]);
  }
  cout << (A[n-1]+B[n-1])*dp[n-1] << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

struct BiMatch{
  int n;
  vector<vector<int> > G;
  vector<int> match,used;
  
  BiMatch(){}
  BiMatch(int sz):n(sz),G(sz),match(sz),used(sz){}
  
  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  bool dfs(int v){
    used[v]=true;
    for(int i=0;i<(int)G[v].size();i++){
      int u=G[v][i],w=match[u];
      if(w<0||(!used[w]&&dfs(w))){
	match[v]=u;
	match[u]=v;
	return true;
      }
    }
    return false;
  }

  int build(){
    int res=0;
    fill(match.begin(),match.end(),-1);
    for(int v=0;v<n;v++){
      if(match[v]<0){
	fill(used.begin(),used.end(),0);
	if(dfs(v)){
	  res++;
	}
      }
    }
    return res;
  }
};
int64 gcd(int64 a, int64 b){
	if(b == 0) return a;
	return gcd(b, a%b);
}

int32 H, W;
int32 toInt(int32 y, int32 x){
	return W*y+x;
}

int32 dx[4] = {-1, 0, 0, 1};
int32 dy[4] = {0, -1, 1, 0};
using PP = pair<PII, PII>;

int main(void){
	cin >> H >> W;
	vector<vector<int64>> a(H, vector<int64>(W));
	vector<PP> res;
	REP(i, H){
		REP(j, W){
			cin >> a[i][j];
		}
	}
	REP(i, H){
		REP(j, W){
			if(a[i][j] % 2 == 0) continue;
			if(j != W-1){
				res.push_back(PP(PII(i+1, j+1), PII(i+1, j+2)));
				a[i][j+1]++;
			}else if(i != H-1){
				res.push_back(PP(PII(i+1, j+1), PII(i+2, j+1)));
				a[i+1][j]++;
			}
		}
	}
	cout << res.size() << endl;
	REP(i, res.size()){
		cout << res[i].fs.fs << " " << res[i].fs.sc << " " << res[i].sc.fs << " " << res[i].sc.sc << endl;
	}
}


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

using namespace std;

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

    int N, K;
    cin >> N >> K;

    vector<int> V(N);
    rep(i, N) { cin >> V[i]; }

    ll res = 0;
    rep(a, min(N, K) + 1)
    {
        rep(b, min(N - a, K - a) + 1)
        {
            vector<ll> tmp;
            rep(i, a) { tmp.push_back(V[i]); }
            rep(i, b) { tmp.push_back(V[N - i - 1]); }

            sort(tmp.begin(), tmp.end());
            ll cur_sum = std::accumulate(tmp.begin(), tmp.end(), 0);

            int r = min(K - (a + b), int(tmp.size()));
            rep(i, r)
            {
                if (tmp[i] < 0)
                {
                    cur_sum -= tmp[i];
                }
            }

            res = max(res, cur_sum);
        }
    }

    cout << res << endl;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll n;
  cin >> n;
  //ll a, b, c;
  //cin >> a >> b;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;
  if(n<=9){
      cout << n << endl;
  }
  else {
    ll buf = n;
    for(i=0;buf!=0;){
        buf /= 10;
        i++;
    }
    ll buf2 = 9;
    buf = 0;
    for(j=0;j<i-1;j++){
        buf += buf2;
        buf2 *= 10;
        result += 9;
    }
    result += (n-buf) / (buf+1);
    cout << result << endl;
  }

  
  /*
  vector<ll> a(n);
  for(i = 0; i < n; i++)
    cin >> a[i];
  //for(i = 0; i < n; i++)
  */
  
  /*
  if(judge)
    //cout << "Yes" << endl;
    //cout << "YES" << endl;
    //cout << "Yay!" << endl;
  else
    //cout << "No" << endl;
    //cout << "NO" << endl;
    //cout << ":(" << endl;
  */
  
  //cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll X,K,D; cin >> X >> K >> D;
    ll z=X/abs(X); X=abs(X);
    ll n=X/D;
    if(K<=n){
        cout << abs(X-K*D) << endl;
    }else{
        ll a=X-n*D;
        if((K-n)%2==1){
            cout << abs(a-D) << endl;
        }else{
            cout << abs(a) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3640
N, M = map(int, input().split())

# N分の配列を用意
lst = ['0'] * N

# ２桁以上の場合、左から一桁目は最小値１
if len(lst) > 1:
    lst[0] = '1'

# リストに対し、フラグ用リストを作成
lst_flg = [False] * N

for _ in range(M):
    s, c = input().split()
    i = int(s) - 1

    if lst_flg[i]:
        if lst[i] != c:
            print('-1')
            exit()
    else:
        lst[i] = c
        lst_flg[i] = True

if len(lst) > 1 and lst[0] == '0':
    print('-1')
    exit()
print(''.join(lst))

Measured memory_bytes: 3064
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
LL x[SIZE],y[SIZE];
int p[SIZE];
bool u[SIZE];
int main(){
    int N;
    R(N);
    FOR(i,1,N)R(x[i]);
    for(int i=N;i>1;i--)x[i]-=x[i-1];
    int M;
    LL K;
    R(M,K);
    FOR(i,2,N)p[i]=i;
    REP(i,M){
        int x;
        R(x);
        swap(p[x],p[x+1]);
    }
    FOR(i,2,N){
        if(!u[i]){
            int now=i;
            VI d;
            while(!u[now]){
                d.PB(now);
                u[now]=1;
                now=p[now];
            }
            REP(j,SZ(d)){
                y[d[j]]=x[d[(j+K)%SZ(d)]];
            }
        }
    }
    FOR(i,2,N)x[i]=x[i-1]+y[i];
    FOR(i,1,N)W(x[i]);
    return 0;
}


Measured memory_bytes: 6000
import bisect
import io
import math
import string

data = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort()
C.sort()
counter = 0

for b in B:
    a_index = bisect.bisect_left(A,b)
    c_index = bisect.bisect_right(C,b)
    counter += a_index*(len(C)-c_index)

print(counter)

Measured memory_bytes: 24288
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

typedef long long ll;

int main()
{
    double a,b;
    cin >> a >> b;
    cout << static_cast<int>(ceil((a+b)/2)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int k; cin >> k;
  char *n = new char[11*100010]; memset(n,0,11*100010);
  for(int i=0;i<9;i++) n[i*11]='1'+i;
  int ps=0; int pe=9; int cr=1;
  do {
    int pc=pe;
    for(int p=ps;p<pe;p++){
      if( n[p*11+cr-1] == '0' ){
        for(int r=0;r<cr;r++){ n[pc*11+r]=n[p*11+r]; } n[pc*11+cr] = '0'; pc++;
        for(int r=0;r<cr;r++){ n[pc*11+r]=n[p*11+r]; } n[pc*11+cr] = '1'; pc++;
      }else if( n[p*11+cr-1] == '9' ){
        for(int r=0;r<cr;r++){ n[pc*11+r]=n[p*11+r]; } n[pc*11+cr] = '8'; pc++; 
        for(int r=0;r<cr;r++){ n[pc*11+r]=n[p*11+r]; } n[pc*11+cr] = '9'; pc++; 
      }else{
        for(int r=0;r<cr;r++){ n[pc*11+r]=n[p*11+r]; } n[pc*11+cr] = n[p*11+cr-1]-1; pc++; 
        for(int r=0;r<cr;r++){ n[pc*11+r]=n[p*11+r]; } n[pc*11+cr] = n[p*11+cr-1]; pc++; 
        for(int r=0;r<cr;r++){ n[pc*11+r]=n[p*11+r]; } n[pc*11+cr] = n[p*11+cr-1]+1; pc++; 
      }
      if( pc >= 100000 ) goto finish;
    }
    cr++;
    ps=pe;
    pe=pc;
  } while( true );
  finish:
  printf("%s\n",&n[(k-1)*11]);
  return 0; 
}
  


Measured memory_bytes: 1912
package main

import (
	"bufio"
	"fmt"
	basicIO "io"
	"os"
	"strconv"
)

func main() {
	protagonist(os.Stdin, os.Stdout)
}

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	A, _ := io.nextInt()
	P, _ := io.nextInt()

	sol := int((A*3 + P) / 2)
	io.PutInt(sol)
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() (int, error) {
	io.Scanner.Scan()
	i, err := strconv.Atoi(io.Scanner.Text())
	return i, err
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


Measured memory_bytes: 640
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  char a;
  cin >> a;
  if('A'<=a&&a<='Z'){
    cout <<"A"<<endl;
  }else{
    cout <<"a"<<endl;
  }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h> 
  using namespace std;
 
long long int max(long long int a,long long int b) 
{ 
    return (a > b) ? a : b; 
} 
 
long long int knapSack(long long int W, long long int wt[], long long int val[], long long int n) 
{ 
    long long int i, w; 
    long long int K[n + 1][W + 1]; 
  
   
    for (i = 0; i <= n; i++) { 
        for (w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max( 
                    val[i - 1] + K[i - 1][w - wt[i - 1]], 
                    K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
  
    return K[n][W]; 
} 
  
int main() 
{ 
    long long int n,W;
    cin>>n>>W;
    long long int wt[n],val[n];
    for(long long int i=0;i<n;i++)
    cin>>wt[i]>>val[i];
    for(long long int i=0;i<n;i++)
    {
        for(long long int j=i+1;j<n;j++)
        {
            if(wt[i]>wt[j])
            {
                long long int temp,camp;
                temp=wt[j];camp=val[j];
                wt[j]=wt[i];val[j]=val[i];
                wt[i]=temp;val[i]=camp;
            }
            if(wt[i]==wt[j])
            {
                if(val[i]<val[j]){
                long long int temp,camp;
                temp=wt[j];camp=val[j];
                wt[j]=wt[i];val[j]=val[i];
                wt[i]=temp;val[i]=camp;}
            }
        }
    }

    printf("%lld", knapSack(W, wt, val, n)); 
    return 0; 
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
//#include <map>
//#include <set>
//#include <list>
//#include <cmath>
//#include <ctime>
//#include <deque>
//#include <queue>
//#include <stack>
//#include <string>
//#include <bitset>
//#include <cstdio>
//#include <limits>
//#include <vector>
//#include <climits>
//#include <cstring>
//#include <cstdlib>
//#include <fstream>
//#include <numeric>
//#include <sstream>
//#include <iomanip>
//#include <iostream>
//#include <algorithm>
//#include <unordered_map>

using namespace std;

#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.141592653589793238462643383279502884
#define MAX 1000100
#define mod 1000000007
#define EPS 1E-9
#define int long long
#define endl "\n"

int fix(int cur, int m)
{
    return ((cur%m) + m) % m;
}

int fast_power(int x, int y,int m)
{
    if (y == 0)
        return 1;
    int temp = fast_power(x, y / 2, m) ;
    temp = (temp*temp)% m;
    if (y % 2 != 0)
        temp = (temp*x)% m;
    return temp;

}


int32_t main()
{
    //freopen("C:/Users/Joe/Desktop/tests/in11.txt", "r", stdin);
    //freopen("C:/Users/Joe/Desktop/tests/out11.txt", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.tie(0);

    int t=1;
    //cin >> t;
    while(t--)
    {
        string str;
        cin >> str;
        string ans="";
        for(int i=0;i<str.size();i++)
        {
            if(str[i]=='B')
            {
                if(ans.size())
                    ans.pop_back();
            }
            else
                ans+=str[i];
        }
        cout << ans << endl;

    }
    return 0;
}


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

int nextInt();

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

int n, q, i;
int A[100005];
int vt[100005];
void pro(int x) {
	for(int i=1;i<=n;i++) vt[i] = 0;
	for(int i=1;i<=n/2;i++) {
		for(int j=n;j>=1;j--) {
			if(vt[j] == 0) {
				vt[j] = 1;
				cout<<A[j]<<' ';
				break;
			}
		}
		int jidx = -1;
		for(int j=1;j<=n;j++) {
			if(vt[j] == 0) {
				if(jidx == -1) jidx = j;
				else {
					if(abs(x - A[jidx]) > abs(x - A[j])) jidx = j;
				}
			}
		}
		vt[jidx] = 1;
	}
	for(int i=1;i<=n;i++) if(vt[i] == 0) cout<<A[i];
	cout<<'\n';
}
int dp[100005];
ll X[100005];
int main() {
	n = nextInt();
	q = nextInt();
	for(i=1; i<=n;i++){
		A[i] = nextInt();
	}
	sort(A+1,A+n+1);

	int r = n/2 + 1;
	int l = 2;
	if(n%2) l--;
	int cnt=0;
	ll sum = 0;
	for(int i=r;i<=n;i++) sum += (ll)A[i];
	while(l<r) {
		dp[cnt++] = (A[l]+A[r])/2;
		X[cnt-1] = sum;

		sum -= (ll)A[r];
		sum += (ll)A[l];
		l+=2;
		r++;
	}
	X[cnt] = sum;
	while(q--){
		int a = nextInt();
		int idx = lower_bound(dp,dp+cnt,a) - dp;
		cout<<X[idx]<<'\n';
	}
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main(){
  double W,H,x,y;cin>>W>>H>>x>>y;
  double ans1;
  int ans2=0;
  ans1=W*H/2;
  if(x*2==W && y*2==H)ans2=1;
  
  cout<<ans1<<" "<<ans2<<endl;
}

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

int main() {
    string a;

    cin >> a;

    int ans = 0;

    for (int i = 0; i < a.size()/2; i++){
        if (a[i] != a[a.size()-1-i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int a,b,c,d=0;
  cin>>N;
  string S;
  for(int i=0;i<N;i++){
    cin>>S;
    if(S=="P"){
      a=1;
    }
    else if(S=="w"){
      b=1;
    }
    else if(S=="G"){
      c=1;
    }
    else if(S=="Y"){
      d=1;
    }  
  }  
  if((a+b+c+d)==3){
    cout<<"Three"<<endl;
  }
  else if((a+b+c+d)==4){
    cout<<"Four"<<endl;
  }  
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,p[1001],k,i,j,x,b;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
	scanf("%d",&p[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(p[i]>p[j]){
				x=p[i];
				p[i]=p[j];
				p[j]=x;
			}
		}
	}
	b=0;
	for(i=0;i<k;i++){
		b+=p[i];
	}
	printf("%d\n",b);
	return 0;
}

				

Measured memory_bytes: 1716
N = int(input())
A = 0
x = 1

if len(str(N))%2 == 0:
    for i in range(len(str(N))//2):
        A += 9*x
        x *= 100
    
    print(A)
else:
    A = N - 10**(len(str(N))-1) + 1
    
    for i in range((len(str(N))-1)//2):
        A += 9*x
        x *= 100
    
    print(A)
        

Measured memory_bytes: 3060