akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main (int argc, char * argv[])
{
    char ch[1200];
    char a[1200];
    int n=0;
    while (1){
    scanf("%c",&a[n]);
        if(a[n]=='\n'){
            break;
        }
        ch[n] = a[n];
        if('A'<= a[n] && a[n]<='Z'){
            ch[n] =a[n]+32;
        }else if('a'<=a[n] && a[n]<='z'){
            ch[n] =a[n]-32;
        }
        n++;
    }
    
    for(int i=0;i<n;i++){
    printf("%c",ch[i]);
    }
    printf("\n");
    return 0;
    
}


Measured memory_bytes: 2040
#include<stdio.h>
#define N 100

int main(){
  int n,num[N],i,flag,tmp,count=0;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)scanf("%d",&num[i]);
  
  flag=1;
  while(flag){
    flag=0;
    for(i=n-1;i>0;i--){
      if(num[i]<num[i-1]){
      tmp=num[i];
      num[i]=num[i-1];
      num[i-1]=tmp;
      flag=1;
      count++;
      }
    }
  }
  
  for(i=0;i<n-1;i++)printf("%d ",num[i]);
  printf("%d\n%d\n",num[i],count);
  
  return 0;
}

Measured memory_bytes: 600
n = int(raw_input())
t,a = map(int, raw_input().split(' '))
his = map(int, raw_input().split(' '))
m = (+float('inf'),-1)
for i,hi in enumerate(his): m = min(m, (abs(t - hi * 0.006 - a),i+1))
print  m[1]

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

int main() {
    int n, k;
    cin >> n >> k;
    int x[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += 2 * min(x[i], k - x[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
 
template<typename T>
struct is_vector : false_type{};
 
template<typename T>
struct is_vector<vector<T>> : true_type{};
 
template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

void solve() {
  int h, w, k; cin >> h >> w >> k;
  vector<string> G(h);
  rep(i,h) cin >> G[i];

  Graph ans(h, vi(w));
  int idx = 1;
  vi vec_h;
  rep(i,h) {
    int prev = 0;
    rep(j,w) {
      if (G[i][j] == '#') {
        while (prev <= j) {
          ans[i][prev] = idx;
          for (auto p : vec_h) {
            ans[p][prev] = idx;
          }
          ++prev;
        }
        ++idx;
      }
    }
    if (prev == 0) {
      vec_h.push_back(i);
      continue;
    }
    while (prev < w) {
      ans[i][prev] = ans[i][prev-1];
      for (auto p : vec_h) {
        ans[p][prev] = ans[p][prev-1];
      }
      ++prev;
    }
    vec_h.clear();
  }
  rep(j,w) {
    for (auto p : vec_h) {
      ans[p][j] = ans[p-1][j];
    }
  }

  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
typedef pair<string,string> pss;
vector<int> fi;
vector<int> ope;
int b;
int p[16];
vector<int> cands[2];
//cands[0] 0 start
//cands[1] 1 start
bool canuse[2];
int ans=1e7;
int tmp=0;
int N,M,onenum=0,zeronum=0;
int main(void)
{
  memset(canuse,false,sizeof(canuse));
  cin >> N >> M;
  for(int i=0;i<N;i++)
    {
      int b;
      cin >> b;
      fi.push_back(b);
      if(fi[i]==0) zeronum++;
      else onenum++;
    }
  for(int i=0;i<M;i++)
    {
      cin >> p[i];
    }
  for(int k=0;k<2;k++)
    {
      int cnt=k;
      for(int j=0;j<M;j++)
	{
	  for(int i=0;i<p[j];i++)
	    {
	      cands[k].push_back(cnt%2);
	    }
	  cnt++;
	}
      if(count(cands[k].begin(),cands[k].end(),1)==onenum) canuse[k]=true;
    }
  for(int pat=0;pat<2;pat++)
    {
      /*cout << pat << ' ' << canuse[pat] << endl;
      for(int check=0;check<N;check++)
	{
	  cout << cands[pat][check] << ' ';
	}
	cout << endl;*/
      if(canuse[pat])
	{
	  ope=fi;
	  int now=0;
	  tmp=0;
	  for(int j=0;j<M;j++)
	    {
	      //cout << "now " << now << endl;
	      if(ope==cands[pat]) break;
	      for(int i=now;i<now+p[j];i++)
		{
		  int target=-1;
		  if(ope[i]!=(pat+j)%2)
		    {
		      target=i;
		      while(ope[target]!=(pat+j)%2)
			{
			  target++;
			}
		    }
		  //cout << target << endl;
		  if(target!=-1)
		    {
		      swap(ope[i],ope[target]);
		      tmp+=(target-i);
		    }
		  // cout << i << ' ' << target << endl;
		  /*for(int check=0;check<N;check++)
		    {
		      cout << ope[check] << ' ';
		    }
		    cout << endl;*/
		}
	      now+=p[j];
	    }
	  ans=min(ans,tmp);
	}
      else continue;
    }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <string.h>
#include <set>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b;
	c=a*b;
	if (c%2==0) cout<<"Even";
	else
	cout<<"Odd";
	return 0;
}

Measured memory_bytes: 256
from collections import*
input=open(0).readline
h,w,n=map(int,input().split())
d=defaultdict(int)
for _ in range(n):
    a,b=map(int,input().split())
    for i in(0,-1,-2):
        for j in(0,-1,-2):
            d[(a+i,b+j)]+=1
a=[0]*10
for i in d.keys():
    if 0<i[0]<h-1and 0<i[1]<w-1:
        a[d[i]]+=1
a[0]=(h-2)*(w-2)-sum(a)
print(*a,sep='\n')

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    int N, H, W;
    cin>>N>>H>>W;
    int ans=0;
    rep(i,N){
        int a, b;
        cin>>a>>b;
        if(a>=H && b>=W) ans++;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def nal(): return list(map(int, stdin.readline().split()))
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())

w, a, b = na()

if((abs(b - a) <= w)):
    print(0)
elif(a < b):
    print(b-(a+w))
else:
    print(a-(b+w))

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

using namespace std;

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

constexpr int MAXN = 100000;

int A[MAXN + 2];
int B[MAXN + 2];
int c[MAXN + 2];

int main() {
	int N;
	cin >> N;
	int readiness = 0;
	for(int i = 0; i < N; i++)
		cin >> A[i];
	for(int i = 0; i < N; i++)
		cin >> B[i];
	int ci = 0;
	for(int i = 0; i < N; i++)
		if(A[i] > B[i])
			c[ci++] = A[i] - B[i];
	sort(c, c + ci);
	int ans = 0;
	for(int i = 0; i < N; i++) {
		int needed = B[i] - A[i];
		if(needed > 0) {
			while(readiness < needed) {
				if(ci == 0)
					goto impossible;
				readiness += c[--ci];
				ans++;
			}
			readiness -= needed;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
impossible:
	cout << -1 << endl;

}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int n, k, s;
  cin >> n >> k >> s;
  int t = s == 1 ? 2 : s - 1;
  rep(i, n)
  {
    cout << (i < k ? s : t) << (i == n - 1 ? "\n" : " ");
  }
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <map>
using namespace std; 
int main(){
    int a,s; cin >> a >> s;
    if (a%s==0){
        cout << a/s << "\n";
    }
    else cout << a/s+1 << "\n";
    
}




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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<8>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<int>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1e9+7

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

int main()
{
    int n;
    int a[200001];

    int b[200001];
    int c[200001];

    ci >> n;
    rep(i, 0, n) ci >> a[i];

    int mx = 0;
    rep(i, 0, n) b[i] = mx = max(mx, a[i]);
    mx = 0;
    rrep(i, n - 1, -1) c[i] = mx = max(mx, a[i]);

    rep(i, 0, n) {
	if(i == 0) {
	    co << c[1] << en;
	} else if(i == n - 1) {
	    co << b[n - 2] << en;
	} else {
	    co << max(b[i - 1], c[i + 1]) << en;
	}
    }
  
    return 0;
}


Measured memory_bytes: 3968
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int N, a[100],A=0,B=0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	sort(a, a + N, greater<int>());
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			A += a[i];
		}
		else {
			B += a[i];
		}
	}
	printf("%d", A - B);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  map<string, int> cnt;
  int MAX = 0;
  string s;
  rep(i, N){
    cin >> s;
    cnt[s]++;
    MAX = max(MAX, cnt[s]);
  }
  for(auto itr : cnt){
    auto value = itr.second;
    if(value == MAX)
      cout << itr.first << endl;
  }
}

Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <vector>
#include <string>
#include <limits.h>
#include <set>
#define ll long 
using namespace std;


int main()
{
ios_base::sync_with_stdio(false);
    
  #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif

    ll N;
    cin>>N;
    ll i;
    long long sum = 0L;
    for(i=1; i<=N; i++)
    {
    	if((i%5==0 && i%3==0)||i%3==0||i%5==0)
    		continue;
    	else
    		sum = sum+i;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<iostream>
using namespace std;
typedef long long ll;
int n,d[55];
int main(){
	ll ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&d[i]);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++)ans+=1ll*d[i]*d[j];
	}
	printf("%lld\n",ans);
} 

Measured memory_bytes: 256
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n = int(readline())
fs = [list(map(int, readline().split())) for _ in range(n)]
ps = [list(map(int, readline().split())) for _ in range(n)]

pat = list(itertools.product([0, 1], repeat=10))

ans = -10**9
for p in pat:
    if sum(list(p)) == 0:
        continue
    money = 0
    for i in range(n):
        cnt = 0
        for j in range(10):
            if fs[i][j] == 1 and p[j] == 1:
                cnt += 1
        money += ps[i][cnt]
    if ans < money:
        ans = max(ans, money)
print(ans)

Measured memory_bytes: 9412
N = int(input())
h_list = list(map(int,input().split()))
ans = 'Yes'
for i in range(1,N):
    if h_list[i] > h_list[i-1]:
        h_list[i] -= 1
    elif h_list[i] < h_list[i-1]:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 63856
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
const int N=5e4+10;
const int M=N*10*10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,sx,sy,tx,ty;
int main()
{
    int i,j;
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    int nowx=sx,nowy=sy;
    while(nowx<tx)putchar('R'),nowx++;
    while(nowy<ty)putchar('U'),nowy++;
    while(nowx>sx)putchar('L'),nowx--;
    while(nowy>sy)putchar('D'),nowy--;
    putchar('D');nowy--;
    while(nowx<tx+1)putchar('R'),nowx++;
    while(nowy<ty)putchar('U'),nowy++;
    putchar('L');nowx--;
    putchar('U');nowy++;
    while(nowx>sx-1)nowx--,putchar('L');
    while(nowy>sy)nowy--,putchar('D');
    putchar('R');
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n,m; cin >> n>>m;
  
  vector<int> wa(n,0);
  int a;
  string s;
  
  int pen=0, ac=0;
  
  for(int i=0; i<m; i++){
    cin >> a >> s;
    if(s=="WA" && wa[a-1]!=-1){
      wa[a-1]++;
    }
    else if(s=="AC" && wa[a-1]!=-1){
      ac++;
      pen += wa[a-1];
      wa[a-1]= -1;
    }
  }
  cout << ac << " " << pen << endl;
}

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

/*int intsort(const void *a, const void *b){
	return *(int*)a - *(int*)b;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
/*}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}*/

int main(){
	int N,M;
	scanf("%d",&N);
	scanf("%d",&M);

	if(N==M){
		printf("%d",N*2);
	}else if(N>M){
		printf("%d",N*2-1);
	}else{
		printf("%d",M*2-1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using llint = long long int;
using u64 = std::uint_fast64_t;


void solve(void){

  std::string s, t;
  std::cin >> s >> t;
  int count = 0;
  for(int i=0; i<s.size(); i++){
    if(s[i] != t[i]) count++;
  }
  std::cout << count << std::endl;

}

int main(void){

  solve();

  return 0;
}


Measured memory_bytes: 3920
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
char s[5][15];
int main(){
	scanf("%s %s %s", s[1], s[2], s[3]);
	printf("%c%c%c", s[1][0] - 32, s[2][0] - 32, s[3][0] - 32);
	return 0;
}


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

#define endl '\n'
#define endt '\t'
#define ends ' '
#define die(x) return cout << x << endl, 0;
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << '[' << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7; 

////////////////////////

const int MAXN = 5e5 + 5;

typedef basic_string<int> bint;
bint N;

bint F(int x) {
	bint X;
	while (x) {
		X.push_back(x % 10);
		x /= 10;
	}
	return X;
}
bint Sum(bint A, bint B) {
	if (sz(A) < sz(B)) swap(A, B);
	while (sz(B) < sz(A)) B.push_back(0);
	bint C(sz(A) + 1, 0);
	for (int i = 0; i < sz(A); i++) {
		int c = C[i] + A[i] + B[i];
		C[i] = c % 10;
		C[i + 1] = c / 10;
	}
	if (C.back() == 0) C.pop_back();
	return C;
}
bint Mul9(bint A) {
	bint C(sz(A) + 1, 0);
	for (int i = 0; i < sz(A); i++) {
		int c = C[i] + 9 * A[i];
		C[i] = c  % 10;
		C[i + 1] = c / 10;
	}
	if (C.back() == 0) C.pop_back();
	return C;
}
void Print(bint A) { reverse(all(A)); for (int i : A) cerr << i; cerr << endl; }
bool IsVal(int k) {
	bint M = Mul9(Sum(N, F(k)));
	int s = 0;
	for (int i : M) s += i;
	return s <= 9 * k;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	#ifdef LOCAL
	ifstream cin("sample.in");
	#endif

	string S; cin >> S; reverse(all(S));
	for (char c : S) N.push_back(c - '0');

	int dw = 0, up = sz(S);
	while (up - dw > 1) {
		int md = (dw + up) >> 1;
		if (IsVal(md)) up = md;
		else dw = md;
	}
	cout << up << endl;

	return 0;
}

Measured memory_bytes: 14656
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ls(x) x<<1
#define rs(x) x<<1|1
#define ll long long
#define tree ans
#define rep(i, a, b) for(int i = a; i <= b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 200010;
int n, h[maxn], a[maxn];
ll ans[maxn << 2], dp[maxn], tag[maxn << 2];
void push_up(int p) { ans[p] = max(ans[ls(p)], ans[rs(p)]); }
void change(int p, ll x) {
    ans[p] = max(ans[p], x);
    tag[p] = max(tag[p], x);
}
void push_down(int p, int l, int r) {
    change(ls(p), tag[p]), change(rs(p), tag[p]);
    tag[p] = 0;
}
ll query(int p, int l, int r, int ql, int qr) {
    if(ql <= l && r <= qr) return ans[p];
    if(tag[p]) push_down(p, l, r);
    int mid = (l + r) >> 1;
    ll ret = 0;
    if(ql <= mid) ret = max(ret, query(ls(p), l, mid, ql, qr));
    if(qr > mid) ret = max(ret, query(rs(p), mid + 1, r, ql, qr));
    return ret;
}
void update(int p, int l, int r, int ql, int qr, ll x) {
    if(ql <= l && r <= qr) {
        change(p, x);
        return;
    }
    if(tag[p]) push_down(p, l, r);
    int mid = (l + r) >> 1;
    if(ql <= mid) update(ls(p), l, mid, ql, qr, x);
    if(qr > mid) update(rs(p), mid + 1, r, ql, qr, x);
    push_up(p);
}
int main()
{
    read(n);
    rep(i, 1, n) read(h[i]);
    rep(i, 1, n) read(a[i]);
    ll ans = 0;
    rep(i, 1, n) {
        ll tmp = h[i] == 1 ? 0 : query(1, 1, n, 1, h[i] - 1);
        dp[i] = tmp + a[i];
        ans = max(ans, dp[i]);
        update(1, 1, n, h[i], n, dp[i]);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    int dig = 0;

    while(jud != 0){
        dig += jud%10;
        jud /= 10;
    }

    if(n %dig == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e15;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int n, m;

struct edge {
    int from;
    int to;
    ll cost;
};

vector<ll> dist;
vector<edge> edges;
vector<bool> negative;

void bellman_ford(int s = 0, bool second = false) {
    if (!second) {
        dist.resize(n, INF);
        dist[s] = 0;
        negative.resize(n);
        rep (i, n - 1) {
            rep (j, m) {
                edge e = edges[j];
                if (dist[e.from] != INF && dist[e.to] > dist[e.from] + e.cost) {
                    dist[e.to] = dist[e.from] + e.cost;
                }
            }
        }
        return;
    }
    rep (i, n) {
        rep (j, m) {
            edge e = edges[j];
            if (dist[e.from] != INF && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                negative[e.to] = true;
            }
            if (negative[e.from]) negative[e.to] = true;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    cin >> n >> m;
    rep (i, m) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--, b--;
        c *= -1;
        edge e = {a, b, c};
        edges.push_back(e);
    }
    bellman_ford();
    ll res = dist[n - 1];
    bellman_ford(0, true);
    if (negative[n - 1]) cout << "inf" << endl;
    else cout << res * -1 << endl;
    
    return 0;
}



Measured memory_bytes: 384
/// hi_im_manh :D
#include <bits/stdc++.h>
#define reset(a,n) memset(a,0,(n+1)*sizeof(int))
#define endl "\n"
#define llmin LLONG_MIN
#define llmax LLONG_MAX
#define intmax INT_MAX
#define intmin INT_MIN
#define ll long long
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define duckman "TASK"

#define input freopen(duckman".inp", "r", stdin);
#define output freopen(duckman".out", "w", stdout);

#define nmax 22000
const ll INF = 1e18L + 5;
using namespace std;

void max_self(ll &a, ll b) {
    a = max(a, b);
}

void min_self(ll &a, ll b) {
    a = min(a, b);
}
int main()
{
    fast;
//    input;
//    output;

//    ll n, weight;
//    cin >> n >> weight;
//    vector<ll> dp(weight+1);
//    for (int i = 0; i < n; ++i) {
//        ll v, w;
//        cin >> w >> v;
//        for (ll weight_now = weight; weight_now - w >= 0; --weight_now) {
//            max_self(dp[weight_now], dp[weight_now - w] + v);
//        }
//    }
//    cout << dp[weight];

//    ll n, weight;
//    cin >> n >> weight;
//    vector<ll> w(n), v(n);
//    ll sum_v = 0;
//    for (ll i = 0; i < n; i++) {
//        cin >> w[i] >> v[i];
//        sum_v += v[i];
//    }
//    vector<ll> dp (sum_v + 1, INF);
//    dp[0] = 0;
//    for (ll i = 0; i < n; ++i) {
//        for (ll value_now = sum_v; value_now >= v[i]; --value_now) {
//            min_self(dp[value_now], dp[value_now - v[i]] + w[i]);
//        }
//    }
//    for (ll i = sum_v; i >= 0; --i) {
//        if (dp[i] <= weight) {
//            cout << i;
//            return 0;
//        }
//    }

//    string x, y;
//    getline(cin, x);
//    getline(cin, y);
//    ll n = x.size(), m = y.size();
//    vector<vector<ll>> dp (n+2, vector<ll>(m+2));
//    for (ll i = 0; i <= n; i++) {
//        for (ll j = 0; j <= m; j++) {
//            if (i == 0 || j == 0) {
//                dp[i][j] = 0;
//            }
//            else {
//                if (x[i-1] == y[j-1]) {
//                    dp[i][j] = dp[i-1][j-1] + 1;
//                }
//                else {
//                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
//                }
//            }
//        }
//    }
//    string ans = "";
//    ll i = n, j = m;
//    while (i && j) {
//        if (x[i-1] == y[j-1]) {
//            ans = x[i-1] + ans;
//            --i;
//            --j;
//        }
//        else {
//            if (dp[i][j] == dp[i-1][j]) {
//                --i;
//            }
//            else {
//                --j;
//            }
//        }
//    }
//    cout << ans;
    const ll M = 1e9 + 7;
    ll r, c;
    cin >> r >> c;
    char a[r][c];
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> a[i][j];
        }
    }
    ll dp[r+1][c+1];
    memset(dp, 0, sizeof(dp));
    dp[1][0] = 1;
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            if (a[i][j] == '.') {
                dp[i+1][j+1] = (dp[i+1][j] % M + dp[i][j+1] % M) % M;
            }
            else {
                dp[i+1][j+1] = 0;
            }
        }
    }
    cout << dp[r][c] % M;
}

/*

*/


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	int m,nmin,nmax;
	while(1){
		cin>>m>>nmin>>nmax;
		if(m==0) break;
		vi v(m,0);
		rep(i,m){
			cin>>v[i];
		}
		int ma=-1,pos;
		for(int i=nmin;i<=nmax;i++){
			if(ma<=v[i-1]-v[i]){
				ma=v[i-1]-v[i];
				pos=i;
			}
		}
		cout<<pos<<endl;
	}
}



Measured memory_bytes: 3076
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

constexpr uint64_t mod = 1e9 + 7;

// (x ^ n) % Mを求める．
uint64_t ModPow(uint64_t x, uint64_t n, uint64_t M) {
  if (n % 2 == 0) {
    if (n == 0) {
      return 1;
    } else {
      uint64_t tmp = ModPow(x, n / 2, M);
      return (tmp * tmp) % M;
    }
  } else {
    return (x * ModPow(x, n - 1, M)) % M;
  }
}

//
uint64_t solve(const string& str, size_t l) {
  if (l + 1 == str.size()) {
    return str[l] == '0' ? 1 : 3;
  }
  if (str[l] == '1') {
    auto N = str.size();
    // どちらかに1を割り振る
    auto tmp1 = solve(str, l + 1) * 2;
    // どちらも0なら残りは好き勝手できる
    auto tmp2 = ModPow(3, N - l - 1, mod);
    return (tmp1 + tmp2) % mod;
  } else {
    return solve(str, l + 1);
  }
}

int main() {
  string str;
  cin >> str;
  cout << solve(str, 0) << endl;
  return 0;
}


Measured memory_bytes: 3584
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	if(n>=3200){
		string s;
		cin>>s;
		cout<<s;
	} else {
		cout<<"red";
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3616
fun main(arr:Array<String>) {
    val ans = if (canComplete()) "Yes" else "No"
    println(ans)
}

data class Work(val require:Long, val limit:Long)

fun canComplete():Boolean {
    val workCount = readLine()!!.toInt()
    var works = Array<Work>(workCount, {Work(0,0)})
    (0..workCount-1).forEach{
        val (a,b) = readLine()!!.split(" ").map { it.toLong() }
        works[it] = Work(a, b)
    }
    works = works.sortedBy { it.limit }.toTypedArray()
    var now = 0.toLong()
    works.forEach {
        now = now + it.require
        if(now > it.limit) {
            return false
        }
    }
    return true
}

Measured memory_bytes: 135648
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(),a.end());

	cout << a[2] * 10 + a[1] + a[0] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
   while (true){
       int n, m; cin >> n >> m;
       if(n == 0 and m == 0) return 0;
       else{
           vector<int> price(n);
           REP(i, n) cin >> price[i];
           int ans = 0;
           REP(i, n){
               REP(j, n){
                   if(j == i) continue;
                   else{
                       int tmp = price[i] + price[j];
                       if(ans < tmp and tmp <= m) ans = tmp;
                   }
               }
           }
           if(ans == 0) cout << "NONE" << endl;
           else cout << ans << endl;
       }
       
   }

}


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


void solve() {
	int n;
	cin >> n;
	if(n % 1000) cout << 1000 - (n % 1000) << endl;
	else cout << 0 << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve(); 
	return 0;
}
 


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define pi 3.14159265

bool compare(pll a, pll b){
    return (a.first*b.second) < (a.second*b.first);
}

const int mod = 1e9 + 7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%mod,n/2);
    return (x*modexp((x*x)%mod,n/2))%mod;
}

int main(){
    fastio;
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}

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

struct edge {
    int src, dst, cost; 
    edge(int s, int t, int c): src(s), dst(t), cost(c) {}
    bool operator < (const edge &rhs) const {return cost > rhs.cost;}
};

const int INF = 1e8;

void bellman_ford(const vector<edge> &edges, vector<int> &d, const int s) {
    d.assign(d.size(), INF);
    d[s] = 0;
    for(auto &i : d) {
        for(auto &e : edges) {
            d[e.dst] = min(d[e.dst], d[e.src] + e.cost);
        }
    }
}

int main(void) {
    int n, m, s, g1, g2;
    while(cin >> n >> m >> s >> g1 >> g2 && n) {
        vector<edge> edges;
        vector<vector<int> > d(n, vector<int>(n));
        --s; --g1; --g2;
        REP(i, m) {
            int b1, b2, c;
            cin >> b1 >> b2 >> c;
            edges.push_back(edge(b1-1, b2-1, c));
        }
        REP(i, n) {
            bellman_ford(edges, d[i], i);
        }
        int cost = numeric_limits<int>::max();
        REP(i, n) {
            cost = min(cost, d[s][i] + d[i][g1] + d[i][g2]);
        }
        cout << cost << endl;
    }
}

Measured memory_bytes: 3084
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S;
  int a, b, c, d;
  while(cin >> S, S != "#"){
    cin >> a >> b >> c >> d;
    int B[9][9];
    for(int i = 0; i < 9; ++i) fill(B[i],B[i]+9,0);
    int x = 0, y = 0;
    for(int i = 0; i < (int)S.length(); ++i){
      char l = S[i];
      if(S[i] == 'b'){
	B[x][y] = 1;
	++y;
      }else if(S[i] == '/'){
	++x;
	y = 0;
      }else{
	y += l - '0';
      }
    }
    B[a-1][b-1] = 0;
    B[c-1][d-1] = 1;
    int t = 0;
    for(int i = 0; i <= x; ++i){
      for(int j = 0; j < y; ++j){
	if(B[i][j]){
	  if(t){
	    cout << t;
	    t = 0;
	  }
	  cout << "b";
	}else{
	  ++t;
	}
      }
      if(t){
	cout << t;
	t = 0;
      }
      if(i < x)
	cout << "/";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3192
import bisect
n, l, t = map(int, input().split())

plots = []
plots_after = []
for i in range(n):
    x, w = map(int, input().split())
    plots.append((x, w, i))
    if w == 1:
        plots_after.append((x+t) % l)
    else:
        plots_after.append((x-t) % l)
    
x0, w0, _ = plots[0]

if w0 == 1:
    cnt = 0
    for i in range(1, n):
        xi, wi, _ = plots[i]
        if wi == 2:
            cnt += max(0, (2 * t - (xi - x0)) // l + 1)
    cnt %= n

    plots_after.sort()

    x_after = (x0 + t) % l
    idx = bisect.bisect_right(plots_after, x_after)-1

    for i in range(n):
        print(plots_after[(i-cnt+idx) % n])

else:
    cnt = 0
    for i in range(1, n):
        xi, wi, _ = plots[i]
        if wi == 1:
            cnt -= max(0, (2 * t - (l - xi + x0)) // l + 1)
    cnt %= n
    plots_after.sort()

    x_after = (x0 - t) % l
    idx = bisect.bisect_left(plots_after, x_after)

    for i in range(n):
        print(plots_after[(i-cnt+idx) % n])

Measured memory_bytes: 95820
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int n;
    cin >> n;
    float  v[n];
    for(int i=0; i < n; i++){
        cin >> v[i];
    }

    sort(v, v + n);
    float ans = (v[0]+ v[1])/2;

    for(int i=2; i < n; i++){
        ans = (ans + v[i])/2;
    }

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

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,m,s;
	int i,j,in[10001],out[10001],max;
	scanf("%d%d",&n,&m);
	s=m;
	max=m;
	for(i=1;i<=n;i++)scanf("%d%d",&in[i],&out[i]);
	for(i=1;i<=n;i++){
		s+=in[i]-out[i];
		if(s<0){
			max=0;
			break;
		}
		else if(s>max)max=s;
	}
	printf("%d\n",max);
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int c=0;
  
  for(int i=0;i<n/2;i++){
    if(s.at(i)!=s.at(n-1-i)){
      c++;
    }
  }
       
  cout<< c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
ll v[20001], dp[2][1010];
ll a[2][1010],b[2][1010];
int main(){
	ll n,m,k;	cin>>n>>m>>k;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<m;j++){
			dp[i][j]=INF;
			a[i][j]=-INF;	b[i][j]=INF;
		}
	}
	dp[0][0]=k;	a[0][0]=b[0][0]=v[0];
	for(int i=1;i<n;i++){
		for(int j=0;j<m;j++){
			if(dp[0][j]==INF)	continue;
			//その箱に追加する場合
			if(j+1<m){
				dp[1][j+1]=dp[0][j];
				a[1][j+1]=max((ll)a[0][j],v[i]);
				b[1][j+1]=min((ll)b[0][j],v[i]);
			}
			//新しく箱を作る場合
			ll num=k+dp[0][j];
			num+=(a[0][j]-b[0][j])*(j+1);
			dp[1][0]=min(dp[1][0],num);
			a[1][0]=b[1][0]=v[i];
		}
		for(int j=0;j<m;j++){
			dp[0][j]=dp[1][j];	dp[1][j]=INF;
			a[0][j]=a[1][j];	a[1][j]=-INF;
			b[0][j]=b[1][j];	b[1][j]=INF;
		}
	}
	ll ans=INF;
	for(int i=0;i<m;i++){
		ll num=dp[0][i];
		num+=(a[0][i]-b[0][i])*(i+1);
		ans=min(ans,num);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3300
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];
        int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var l = 0;
        var r = 0;
        // 正負が切り替わるポイントを見つける
        for (int i = 0; i < x.Length; i++)
        {
            if (x[i] > 0)
            {
                if (i > k)
                {
                    r = i;
                    l = i - k;
                }
                else
                {
                    l = 0;
                    r = l + k - 1;
                }
                break;
            }
        }
        if (l == 0 && r == 0)
        {
            r = x.Length - 1;
            l = r - k + 1;
        }

        var fr = r;
        var ok = true;
        var ans = int.MaxValue;
        while (ok)
        {
            var lr = Math.Abs(x[l]) + Math.Abs(x[r] - x[l]);
            var rl = Math.Abs(x[r]) + Math.Abs(x[r] - x[l]);
            var tmp = Math.Min(lr, rl);
            ans = Math.Min(ans, tmp);
            l++;
            r++;
            if (r == x.Length || l == fr+1)
            {
                ok = false;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 21472
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//Farey Sequence
public class Main{

	int N = 1000000;
	boolean[] p;
	
	long gcd(long a, long b){
		return b==0?a:gcd(b, a%b);
	}

	long get(int x){
		int n = x;
		Set<Integer> set = new HashSet<Integer>();
		int div = 2;
		while(x>1){
			if(p[x]){
				set.add(x); break;
			}
			if(x%div==0){
				set.add(div);
				x/=div;
			}
			else div++;
		}
		int m = set.size();
		int[] a = new int[m];
		int id = 0;
		for(int i:set)a[id++]=i;
		long res = 0;
		for(int i=1;i<1<<m;i++){
			int num = 0;
			for(int j=i;j!=0;j>>=1)num+=j&1;
			long lcm = 1;
			for(int j=0;j<m;j++){
				if((i>>j&1)>0){
					lcm = lcm/gcd(lcm, a[j])*a[j];
					if(lcm>n)break;
				}
			}
			if(num%2==0)res-=n/lcm;
			else res+=n/lcm;
		}
		return res;
	}
	
	void run(){
		p = new boolean[N+1];
		Arrays.fill(p, true);
		p[0]=p[1]=false;
		for(int i=2;i<=N;i++)if(p[i])for(int j=i+i;j<=N;j+=i)p[j]=false;
		long[] res = new long[N+1];
		res[1] = 2;
		for(int i=2;i<=N;i++){
			res[i] = res[i-1];
			res[i]+=i-get(i);
		}
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0)System.out.println(res[sc.nextInt()]);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 21000
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;

    int n = s.size();

    string t;
    rep(i, n){
        if(i % 2 == 0){
            t.push_back('g');
        }
        else{
            t.push_back('p');
        }
    }

    int score = 0;
    rep(i, n){
        if(t[i] == 'p' && s[i] == 'g'){
            score++;
        }
        if(t[i] == 'g' && s[i] == 'p'){
            score--;
        }
    }

    cout << score << endl;

    return 0;
}

Measured memory_bytes: 640
//abc167

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

int main() {
  string s,t;
  int count = 0;
  cin >> s  >> t ;

  int len = s.size();

  if(len == t.size()-1){
    for(int i = 0 ; i<len ; i++){
      if(s[i] == t[i]){
        count++;
      }
    }
  }

  if(count == len){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }


}


Measured memory_bytes: 3636
Option Strict On
Module Module1

    Sub Main()
        Dim N As Integer = Convert.ToInt32(Console.ReadLine())
        Dim l() As String = Split(Console.ReadLine())
        Dim m(N - 1) As Integer
        For i As Integer = 0 To N - 1
            m(i) = Convert.ToInt32(l(i))
        Next
        Dim counter As Integer = 1
        Dim maxyama As Integer = m(0)
        For i As Integer = 1 To N - 1
            If maxyama <= m(i) Then
                counter += 1
                maxyama = m(i)
            End If
        Next
        Console.WriteLine(counter)
        Console.ReadLine()
    End Sub

End Module

Measured memory_bytes: 13652
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using namespace std;
using ll = long long;

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

    int back = 0;
    string N, ans;
    cin >> N;

    for (int i = N.size()-1; i >= 0; i--) {
        if (N[i] == 'B')
            back++;
        else {
            if (back != 0)
                back = (back-1 >= 0) ? back-1 : 0;
            else 
                ans.push_back(N[i]);
        }
    }

    reverse(ans.begin(),ans.end());
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextInt();
        long b = scanner.nextInt();
        long c = scanner.nextInt();
        long d = scanner.nextInt();
        long ans;
        ans = Math.max(a * c, b * d);
        ans = Math.max(a * d, ans);
        ans = Math.max(b * c, ans);
        if ((a <= 0 && b >= 0) || (c <= 0 && d >= 0)) ans = Math.max(0, ans);
        System.out.println(ans);
    }
}

Measured memory_bytes: 35876
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

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

    vector<int> a(1e5 + 1);

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[x - 1]++;
    }

    int cnt2 = 0;
    int cnt1 = 0;
    for (int i = 0; i <= 1e5; i++) {
        if (a[i] == 0) {
            continue;
        }
        if(a[i] % 2 == 0){
            cnt2++;
        }else{
            cnt1++;
        }
    }

    int cnt = cnt1 + cnt2 - (cnt2 % 2 == 0 ? 0 : 1);
    cout << cnt << endl;


    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)


int main()
{
	uint32_t a,b,c,d;
	cin >> a >> b >> c >> d;

	uint32_t left = a + b, right = c + d;

	if (left == right) {
		printf("Balanced\n");
		return 0;
	}
	if (left < right) {
		printf("Right\n");
		return 0;
	}
	printf("Left\n");
	return 0;
	//	std::cout << "Hello World!\n"; 
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int n,m;
	cin >> n >> m;
	if(n == m)cout << "Yes" << endl;
	else cout << "No" << endl;
}

int32_t main(){
	IO;
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    map<string, int> m;
    rep(i, n){
        string t = s[i];
        sort(ALL(t));
        m[t]++;
    }

    int ans = 0;
    for(auto p : m){
        int x = p.second;
        ans += x * (x - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10368