akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
namespace IO{
	const int maxn(1<<21|1);
	char ibuf[maxn],*iS,*iT,obuf[maxn],*oS=obuf,*oT=obuf+maxn-1,_c,st[55];
	int _f,tp;
	char Getc(){return (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,maxn,stdin),(iS==iT?EOF:*iS++)):*iS++);}
	void Flush(){fwrite(obuf,1,oS-obuf,stdout);oS=obuf;}
	void Putc(char x){*oS++=x;if(oS==oT)Flush();}
	template<class Int>void Input(Int &x){
		for(_f=0,_c=Getc();_c<'0'||_c>'9';_c=Getc())_f=_c=='-';
		for(x=0;_c<='9'&&_c>='0';_c=Getc())x=(x<<3)+(x<<1)+(_c^48);
		if(_f)x=-x;
	}
	template<class Int>void Print(Int x){
		if(!x)Putc('0');
		if(x<0)Putc('-'),x=-x;
		while(x)st[++tp]=x%10+'0',x/=10;
		while(tp)Putc(st[tp--]);
	}
}
using namespace IO;
const int _=2e5+25;
const ll inf=1ll<<60;
ll a[_],x[_],y[_],n,A[_],X[_],Y[_],L[_],R[_];
int main(){
	Input(n);
	for(int i=1;i<=n;++i){
		Input(a[i]); x[i]=~a[i]&1;
		if(a[i]<=2)y[i]=2-a[i];
		else y[i]=a[i]&1;
	}
	for(int i=1;i<=n;++i){
		X[i]=X[i-1]+x[i],Y[i]=Y[i-1]+y[i],A[i]=A[i-1]+a[i];
	}
	ll mn=L[0]=0;
	for(int i=1;i<=n;++i){
		mn=min(mn,A[i]-Y[i]);
		L[i]=mn+Y[i];
	}
	R[n]=0;	mn=A[n]-A[n]+Y[n];
	for(int i=n-1;~i;--i){
		mn=min(mn,A[n]-A[i]+Y[i]);
		R[i]=mn-Y[i];
	}
	ll ans=mn=inf;
	for(int i=0;i<=n;++i){
		mn=min(mn,L[i]-X[i]);
		ans=min(ans,mn+R[i]+X[i]);
	}
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 16896
N = int(input())
A = 0
B = 0
ans = 0
case = 0
for i in range(N):
  S = input()
  for j in range(len(S)-1):
    if S[j] == 'A' and S[j+1] == 'B':
      ans += 1
  if S[0] == 'B' and S[len(S)-1] == 'A':
    case += 1
  else:
    if S[0] == 'B':
      B += 1
    if S[len(S)-1] == 'A':
      A += 1
if case == 0:
  print(ans+min(A,B))
else:
  if A > 0 and B > 0:
    print(ans+case+1+min(A-1,B-1))
  elif A > 0 or B > 0:
    print(ans+case)
  else:
    print(ans+case-1)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;

int N, M;
int golist[100001];

struct eki {
	ll A, B, C;
};

eki e[100000];
ll ruisekiwa[100000];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++)cin >> golist[i], golist[i]--;
	for (int i = 0; i < N - 1; i++) {
		cin >> e[i].A >> e[i].B >> e[i].C;
	}

	for (int i = 0; i < M - 1; i++) {
		int from, to;
		if (golist[i] < golist[i + 1])from = golist[i], to = golist[i + 1];
		else from = golist[i + 1], to = golist[i];
		ruisekiwa[from]++, ruisekiwa[to]--;
		
	}
	for (int i = 1; i < N; i++)ruisekiwa[i] += ruisekiwa[i - 1];
	
	ll ans = 0;
	for (int i = 0; i < N - 1; i++) {
		ans += min(e[i].A * ruisekiwa[i], e[i].B * ruisekiwa[i] + e[i].C);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6612
#!/usr/bin/env python3

def main():
    S = input()
    if S == 'SUN':
        print(7)
    elif S == 'MON':
        print(6)
    elif S == 'TUE':
        print(5)
    elif S == 'WED':
        print(4)
    elif S == 'THU':
        print(3)
    elif S == 'FRI':
        print(2)
    elif S == 'SAT':
        print(1)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
		using namespace std;
		#define int long long int
		#define loop(i,a,b) for(int i=a;i<b;i++)
		#define scan(arr,n) for (int i = 0; i < n; ++i) cin >> arr[i]
		#define vi vector<int>
		#define si set<int>
		#define pii pair <int, int>
		#define sii set<pii>
		#define vii vector<pii>
		#define mii map <int, int>
		#define pb push_back
		#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
		//Constants
		const int MOD = 1000000007; /* 1e9 + 7*/
		const int MAXN = 1000005; /*1e6 +5 */
		 
		int spf[1000009]; // stores the smallest prime factor of a number
		 
		void sieve()
		{
		spf[1] = 1;
			for (int i=2; i<MAXN; i++)
				spf[i] = i;
			for (int i=4; i<MAXN; i+=2)
				spf[i] = 2;
		 
			for (int i=3; i*i<MAXN; i++)
				if (spf[i] == i)
				{
					for (int j=i*i; j<MAXN; j+=i)
						if (spf[j]==j)
							spf[j] = i;
				}
			}
		
		 
		/* Iterative Function to calculate (x^y)%p in O(log y) */
		int power(int x,  int y, int p)
		{
			int res = 1;     // Initialize result
			x = x % p; // Update x if it is more than or
						// equal to p 
			if (x == 0) return 0; // In case x is divisible by p;     
			while (y > 0)
			{
				// If y is odd, multiply x with result
				if (y & 1)
					res = (res*x) % p;     
				// y must be even now
				y = y>>1; // y = y/2
				x = (x*x) % p;
			}
			return res;
		}
		
		 
		void solve()
		{
			int s=0;
			string n;
			cin>>n;
			loop(i,0,n.length())
			{
				s=s+n[i]-'0';
			}
			if(s%9==0)
			cout<<"Yes";
			else
			cout<<"No";
		}

		 
		int32_t main()
		{
			faster;
			/*sieve();*/
		   // compute();
		  // int t;cin>>t;
		 int t=1;
		while(t--)
			solve();
		 
		 
			return 0;
		}


Measured memory_bytes: 3780
x = int(input())
for a in range(-10000, 10001):
    p = a ** 5
    l, r = -10000, 10001
    while r - l > 1:
        m = (l + r) // 2
        if m ** 5 <= p - x:
            l = m
        else:
            r = m
    if l ** 5 == p - x:
        print(a, l)
        exit(0)


Measured memory_bytes: 90296
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/

set<char> ss;
ll d[30];

int main() {
    cin >> n >> s;
    REP(i, n) {
        d[s[i] - 'a']++;
    }

    REP(i, n) {
        ss.insert(s[i]);
        d[s[i] - 'a']--;
        cnt = 0;
        for (auto x : ss) {
            if (d[x - 'a'] >= 1) {
                cnt++;
            }
        }
        chmax(ans, cnt);
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    int n,a[15],x[15][15],y[15][15],ans = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        for(int j = 0;j < a[i];j++){
            cin >> x[i][j] >> y[i][j];
        }
    }
    for(int bit = 0;bit < (1 << n);bit++){
        bool flag[15] = {false},flag_ = true;int count = 0;
        for(int i = 0;i < n;i++){
            if(bit & (1 << i)){
                flag[i] = true;
                count++;
            }
        }
        for(int i = 0;i < n && flag_;i++){
            if(flag[i]){
                for(int j = 0;j < a[i] && flag_;j++){
                    if(flag[x[i][j]-1] != y[i][j])flag_ = false;
                }
            }
        }
        if(flag_)ans = max(ans,count);
    }
    cout << ans;
    return 0;
}

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

namespace B___Roller_Coaster
{
    class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int N = input[0];
            int K = input[1];
            int[] h = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int ans = h.Count(value => value >= K);
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 19296
using System;
using System.Collections.Generic;
class Program
{
    static int x;
    static List<int> s = new List<int>();
    static string result;
    static void Main()
    {
        x = int.Parse(Console.ReadLine());
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i=0;i<x;i++) { s.Add(int.Parse(tmp[i])); }
        int y=0;
        for (int i = 0; i < x; i++) { if (i+1 == s[i]) { y++; } }
        if (y >= 3) { result = "YES"; } else { if (x == 2) { result = "YES"; } else { result = "NO"; } }

        Console.WriteLine(result);
            Console.Out.Flush();
        
    }

 


}

Measured memory_bytes: 13140
N = int(input())
ans = [-1] * (N ** 2)
X = [int(x)-1 for x in input().split()]
for i, x in enumerate(X):
    ans[x] = i+1
left, right = [], []
for i in range(N):
    l_cnt, r_cnt = i, N - (i+1)
    left.extend([(X[i], i+1)] * l_cnt)
    right.extend([(X[i], i+1)] * r_cnt)
l, r = 0, N ** 2 - 1
left.sort()
right.sort(reverse=True)
for _, x in left:
    while ans[l] != -1:
        l += 1
    ans[l] = x
for _, x in right:
    while ans[r] != -1:
        r -= 1
    ans[r] = x
counter = [[] for _ in range(N)]
for i, a in enumerate(ans):
    counter[a-1].append(i)
if all(counter[i].index(x) == i for i, x in zip(range(N), X)):
    print("Yes")
    print(*ans)
else:
    print("No")


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

int main () {
	int h,w;
	while ( cin >> h >> w ){
		if ( h == 0 && w == 0){
			break;
		}
		for ( int a = 0; a < h; a++){
			for ( int b = 0; b < w; b++){
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3136
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def f(n):
    ret = 0
    for a in range(1, n+1):
        if n % a == 0:
            ret += 1
    return ret

N = int(input())
n = 1
while True:
    if f(n) == N:
        print(n)
        break
    n += 1

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

int main()
{
    char s[1001];
    scanf("%s",s);
    char char_array[1001],str2[1001];
    char str[1001];
    strcpy(char_array,s);
    int t,i,a,b,k=0,l=0;
    char temp,p[1001];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%s",str);
        if(strcmp(str,"replace")==0)
        {
            scanf("%d%d",&a,&b);
            scanf("%s",str2);
            for(i=a; i<=b; i++)
            {
                temp=char_array[i];
                char_array[i]=str2[k];
                str2[k]=temp;
                k++;
            }
            k=0;
        }
        else if(strcmp(str,"reverse")==0)
        {
            scanf("%d%d",&a,&b);
            while(a<b)
            {
                temp=char_array[a];
                char_array[a]=char_array[b];
                char_array[b]=temp;
                a++;
                b--;
            }
        }
        else if(strcmp(str,"print")==0)
        {
            scanf("%d%d",&a,&b);
            for(i=a; i<=b; i++)
            {
                p[l]=char_array[i];
                l++;
            }
            p[l]='\0';
            printf("%s\n",p);
            l=0;
        }
    }
}



Measured memory_bytes: 2040
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

class XorShift {
  public:
    uint64_t operator()() noexcept { return next(state_); }

  private:
    static constexpr uint64_t next(uint64_t x) noexcept {
        x ^= x << 13;
        x ^= x >> 7;
        x ^= x << 17;
        return x;
    }

    uint64_t state_;
};

static array<int, 26> C;
static array<array<int, 26>, 365> S;
static array<int, 365> X;

static void solve() {
    for (auto d = 0; d < 365; ++d) {
        auto itr = max_element(S[d].begin(), S[d].end());
        X[d] = distance(S[d].begin(), itr);
    }
}

int main() {
    int d;
    cin >> d;
    // assert(d == 365);
    for (auto& Ci : C)
        cin >> Ci;
    for (auto& row : S)
        for (auto& elem : row)
            cin >> elem;

    solve();

    // convert to 1-based
    for (auto Xi : X)
        cout << (Xi + 1) << "\n";
    return 0;
}


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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    int sum_a=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        sum_a += a[i];
    }
    int ans = sum_a - n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
class Tree{
public:
    string word;
};
int main(){
    string s;
    cin >> s;
    int l = s.length(), i, j;
    int count = 0;
    int mt[l+4] = {0};
    for(i=0;i<l-3;i++){
        int mod = (s[i]-'0')*1000+(s[i+1]-'0') * 100 + (s[i+2]-'0') * 10 + (s[i+3]-'0');
        mod = mod % 2019;
        if(mod == 0){
            count+=mt[i]+1;
            mt[i+4] += mt[i]+1;
        }else{
            for(j=i+4;j<l;j++){
                mod = mod*10+(s[j]-'0');
                mod = mod % 2019;
                if(mod == 0){
                    count+=mt[i]+1;
                    if(j<l-1) mt[j+1] += mt[i]+1;
                    break;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4480
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
lr = []
lmrer = BIG  # leftmost right end
lmrel = BIG
rmlel = -BIG # rightmost left end
rmler = -BIG
mx1 = -BIG
for i in range(n):
    l,r = inm()
    lr.append((l,r))
    #if r < lmrer:
    if r < lmrer or r==lmrer and l<lmrel:
        lmrer = r
        lmrel = l
        lmrei = i
    #if l > rmlel:
    if l > rmlel or l==rmlel and r>rmlel:
        rmlel = l
        rmler = r
        rmlei = i
    if r-l>mx1:
        mx1 = r-l

if n==2:
    print(lr[0][1]-lr[0][0]+1 + lr[1][1]-lr[1][0]+1)
    exit()

# longest vs all else
mx = max(0,lmrer-rmlel+1)+mx1+1
if lmrei==rmlei:
    print(mx)
    exit()

i1 = max(lmrei,rmlei)
i2 = min(lmrei,rmlei)
del lr[i1]
del lr[i2]
lr.sort()

rminr = [0]*(n-2)
rminr[n-3] = lr[n-3][1]
for i in range(n-4,-1,-1):
    rminr[i] = min(rminr[i+1],lr[i][1])

# lmre vs all else
len1 = lmrer-lmrel+1
len2 = rminr[0]-rmlel+1
mx = max(mx, len1+len2)

for i in range(n-3):
    len1 = lmrer-max(lmrel,lr[i][0])+1
    len2 = min(rmler,rminr[i+1])-rmlel+1
    mx = max(mx,len1+len2)

# rmle vs all else
len1 = lmrer-max(lmrel,lr[n-3][0])+1
len2 = rmler-rmlel+1
mx = max(mx,len1+len2)

print(mx)


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

int N,C;
int s[100005],t[100005],c[100005];
int tt[200005];
int sm[200005];

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

  for(int i = 0; i < N; i++) {
    cin >> s[i] >> t[i] >> c[i];
  }

  for(int i = 1; i <= C; i++) {
    for(int j = 0; j < 200005; j++) tt[j] = 0;
    for(int j = 0; j < N; j++) {
      if(c[j] == i) tt[s[j] * 2 - 1]++, tt[t[j] * 2 + 1]--;
    }
    for(int j = 1; j < 200005; j++) tt[j] += tt[j-1];
    for(int j = 0; j < 200005; j++) if(tt[j] > 0) sm[j]++;
  }

  int ans = 0;

  for(int i = 0; i < 200005; i++) {
    ans = max(ans,sm[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 2944
using System;

namespace AtCoder{
    public static class AtCoder{
        public static void Main(){
            var input = Console.ReadLine().Split(' ');
            long a = long.Parse(input[0]);
            decimal b = decimal.Parse(input[1]);

            decimal ans = a * b;
            ans = Math.Truncate(ans);
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 27608
from collections import Counter

n = int(input())
D = list(map(int, input().split()))
c = Counter(D)

total = 1
count = 0
for i in range(n):
  num = c.get(i, 0)
  if num == 0:
    total = 0
    break
  count += num
  if i == 0 and (c[i] != 1 or D[0] != 0):
    total = 0
  if i > 0:
    total = (total * (c[i - 1] ** c[i])) % 998244353
  if count == n:
    break
print(total)

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

using namespace std;

const int N = 1e3 + 2;
const int mod = 1e9 + 7;

int n, m, dp[N][N];
char a[N][N];

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

    dp[1][1] = 1;

    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            cin >> a[i][j];
            if(a[i][j] == '.'){
                dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            }
        }
    }

    cout << dp[n][m] << endl;
}


Measured memory_bytes: 5120
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    L, R, d = map(int, input().split())
    
    N_R = R//d
    N_L = (L-1)//d
    print(N_R - N_L)

if __name__ == "__main__":
    main()



Measured memory_bytes: 9160
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
lucas = [0]*(N+1)
lucas[0] = 2
lucas[1] = 1

for i in range(2, N+1):
    lucas[i] = lucas[i-1]+lucas[i-2]
print(lucas[-1])


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int proceed(string s)
{
  if (s == "dreamerd") return 7;
  if (s == "dreamere") return 7;
  if (s == "dreamera") return 5;
  if (s == "dreamdre") return 5;
  if (s == "eraserdr") return 6;
  if (s == "eraserer") return 6;
  if (s == "erasedre") return 5;
  if (s == "eraseera") return 5;
  return -1;
}

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  S += "dreamer";
  
  string ans = "YES";
  for (int i = 0; i < N; )
  {
    string s = S.substr(i, 8);
    if (proceed(s) == -1)
    {
      ans = "NO";
      break;
    }
    else
    {
      i += proceed(s);
    }
  }
  
  cout << ans << endl;
}

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

int main(){
    int N, A;
    cin >> N >> A;
    N %= 500;
    if(A == 0){
        cout << (N ? "No" : "Yes") << endl;
        return 0;
    }
    cout << (N/A > 0 ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int n=s.size();
int cnt=0,cnt1=0,i;
for(i=0;i<n;i++)
{
 if(s[i]=='A')
 cnt++;
 if(s[i]=='B')
 cnt1++;
}
if(cnt1>=1&&cnt>=1)
cout<<"Yes"<<"\n";
else
cout<<"No"<<"\n";
}

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

using namespace std;

int main(){
    int a,b,c;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    if (a-b-c==-a && b==c) {
        printf("1\n");
    } else if (a==b || a==c || b==c) {
        printf("2\n");
    } else {
        printf("3\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define F first
#define s second
#define int long long		
int x[214514];
string y[214514];
char z[214514];
int sum[214514];
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	rep(0,i,c)cin>>x[i];
	rep(0,i,c)sum[x[i]-1]++;
	rep(0,i,a){
		if(c-b<sum[i]){
			c("Yes")
		}
		else{
			c("No")
		}
	}
}					

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define VS vector<string>
#define VI vector<int>
#define ll long long
#define ull unsigned long long
#define FST first
#define SEC second
int rec(ll num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
int main(){
  ll n;
  cin>>n;
  int ans=1e9;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ans=min(ans,max(rec(i),rec(n/i)));
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
//
//  abc057A.cpp
//  
//
//  Created by 楊承昊 on 2017/3/26.
//
//

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int a,b;
    cin>>a>>b;
    a+=b;
    if(a>=24) a-=24;
    cout<<a<<endl;
    return 0;
}

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

int main(){
  int N;
  string S,T;
  cin >> N >> S >> T;
  for(int i=0;i<2*N;i++){
    if(i%2==0){
      cout << S.at(i/2);
    }
    else{
      cout << T.at(i/2);
    }
  }
  cout << endl;
}
  

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

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

    // prev[i] := minimum index where the value less than a[i] appeared before i
    // next[i] := minimum index where the value less than a[i] appeared after i
    vector<int> prev(n, 0), next(n, n);
    stack<pair<int, int>> stk;
    stk.push({0, -1});  // 番兵
    rep(i, n) {
        while (stk.size() > 0 && stk.top().first >= a[i]) stk.pop();
        prev[i] = stk.top().second + 1;
        stk.push({a[i], i});
    }

    while (!stk.empty()) stk.pop();
    stk.push({0, n});
    rep(i, n) {
        while (stk.size() > 0 && stk.top().first >= a[n - i - 1]) stk.pop();
        next[n - i - 1] = stk.top().second;
        stk.push({a[n - i - 1], n - i - 1});
    }

    ll ans = 0;
    rep(i, n) {
        ans += a[i] * (next[i] - i) * (i + 1 - prev[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7216
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007
#define INF 2000000200

int main() {
  ll a, b;
  cin >> a >> b;
  vector<ll> v;
  if (a == -b) {
    v.pb(1);
  }
  if (a < b) {
    v.pb(abs(b - a));
  }
  if (-a < b) {
    v.pb(abs(b + a) + 1);
  }
  if (a < -b) {
    v.pb(abs(-b - a) + 1);
  }
  if (-a < -b) {
    v.pb(abs(-b + a) + 2);
  }
  sort(all(v));
  cout << v[0] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if((b-a)==(c-b)){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
		
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  vector<int> l(n);
  for(auto&& e:l)
  {
    cin>>e;
  }
  sort(l.begin(), l.end());
  int64_t ans = 0;
  for (int i = n-1; i >= 0; --i)
  {
    for (int j = i-1; j >= 0; --j)
    {
      auto itr = lower_bound(l.begin(), l.end(),l[i]+l[j]);
      ans += n-1-i - distance(itr,l.end());
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int N, D;
    cin >> N >> D;

    vector<vector<int>> arr;
    for (int i = 0; i < N; i++) {
        int x;
        vector<int> a;
        for (int j = 0; j < D; j++) {
            cin >> x;
            a.push_back(x);
        }
        arr.push_back(a);
    }

    int ans = 0;
    for (int k = 0; k < arr.size(); k++) {
        for (int l = 0; l < arr.size(); l++) {
            if (k != l) {
		        int f = k;
		        int t = l;
		        if (t == arr.size()) {
		            t = 0;
		        }
		        int sum = 0;
		        for (int l = 0; l < D; l++) {
		            sum += pow(arr[f][l] - arr[t][l], 2);
		        }
		        double d = sqrt(sum);
		        if (floor(d) == ceil(d)) {
		            ans++;
		        }
            }
        } 
    }
    cout << (ans / 2) << endl;
    return 0;
}


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

int main()
{
    int n,m;
    cin >> n >> m;
    int cnt[m] = {0};
    int count = 0;

    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k ; j++){
            int a;
            cin >> a; a--;
            cnt[a]++;
        }
    }

    for(int i = 0; i < m; i++){
        if(cnt[i] == n)
            count++;
    }

    cout << count;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int h,w;
    while(cin >> h >> w, h||w){
        rep(i,h){
            rep(j,w){
                if(i == 0 || j == 0 || i == h - 1 || j == w - 1) cout << "#";
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1152
#define onlycc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

typedef long long ll;

int x;

int main()
{
    onlycc;
    cin >> x;

    if(x == 0) cout << 1;
    else cout << 0;

    return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();

            var answer =Enumerable.Range(0, S.Length).All(i => S[i] == T[i]) ? "Yes" : "No";
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 26588
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

struct Edge
{
  public:
	int from, to, cost;
	bool used;
	Edge() {}
	Edge(int _from, int _to, int _cost)
	{
		from = _from;
		to = _to;
		cost = _cost;
		used = false;
	}
};

struct Data
{
	int first, second;
	int from, ind;
	Data()
	{
	}

	Data(int _first, int _second, int _from, int _ind)
	{
		first = _first;
		second = _second;
		from = _from;
		ind = _ind;
	}

	bool operator<(const Data &d) const
	{
		return first < d.first;
	}
	bool operator>(const Data &d) const
	{
		return first > d.first;
	}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

vi dijkstra(int s, Graph &G)
{ //s=>始点
	priority_queue<Data, vector<Data>, greater<Data>> que;
	vi D(SZ(G), INF);
	D[s] = 0;
	que.push(Data(0, s, -1, -1));

	while (!que.empty())
	{
		Data d = que.top();
		que.pop();
		int v = d.second;
		if (D[v] < d.first)
			continue;
		if (d.ind != -1)
		{
			G[d.from][d.ind].used = true;
		}

		REP(i, SZ(G[v]))
		{
			if (D[G[v][i].to] > D[v] + G[v][i].cost)
			{
				D[G[v][i].to] = D[v] + G[v][i].cost;
				que.push(Data(D[G[v][i].to], G[v][i].to, G[v][i].from, i));
			}
		}
	}
	return D;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	Graph G(N);
	REP(i, M)
	{
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		G[a].push_back(Edge(a, b, c));
		G[b].push_back(Edge(b, a, c));
	}

	REP(i, N)
	{
		dijkstra(i, G);
	}

	int ans = 0;
	REP(i, N)
	{
		for (Edge e : G[i])
		{
			if (!e.used)
				ans++;
		}
	}
	cout << ans / 2 << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
	int b,c;
}a[100005];
int cmp(node x,node y){
	return x.c>y.c;
}
int d[100005];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%d",&d[i]);
	sort(d,d+n);
	for(int i=0;i<m;i++)
		scanf("%d%d",&a[i].b,&a[i].c);
	sort(a,a+m,cmp);
	int id=0;
	ll ans=0;
	for(int i=0;i<n;i++){
		if(d[i]<a[id].c&&a[id].b){
			ans+=a[id].c;
			a[id].b--;
		}
		else ans+=d[i];
		if(a[id].b==0){
			if(id+1<m)
				id++;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int A, B, K;
	cin >> A >> B >> K;

	for (int i = 0; i < K; i++) {
		if (i % 2 == 0) {
			if (A % 2) A--;
			B += A / 2;
			A /= 2;
		}
		else {
			if (B % 2) B--;
			A += B / 2;
			B /= 2;
		}
	}

	cout << A << ' ' << B << endl;
}

Measured memory_bytes: 3596
s = input()
s = s[::-1]

words = ["dream", "dreamer", "erase", "eraser"]
words = [w[::-1] for w in words]
lens = [len(w) for w in words]

while True:
    for l, w in zip(lens, words):
        if s[:l] == w:
            s = s[l:]
            break
    else:
        print("NO")
        break
    if len(s) == 0:
        print("YES")
        break

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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

void solve(long long A, long long B){
  cout << (A - 1) * (B - 1) << endl;
}

int main() {
long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
  solve(A, B);
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main(){
  int X;
  cin >> X;
  if(X==3) cout << "YES" << endl;
  else if(X==5) cout << "YES" << endl;
  else if(X==7) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<vector>
using namespace std;
int main(){

    int n,x;
    int mi=1e9;
    cin>>n>>x;
    int sum=0;
    for(int i=0;i<n;i++){
        int l;
        cin>>l;
        mi=min(l,mi);
        sum+=l;
    }
    int ret=x-sum;
    int ans=ret/mi;
    ans+=n;
    cout<<ans<<endl;
    
    
    
    
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);

struct LazySegmentTree {
private:
	int n;
	vector<ll> node, lazy;
public:
	LazySegmentTree(vector<ll> v) {
		int sz = (int)v.size();
		n = 1; while(n < sz) n *= 2;
		node.resize(2*n-1,INF);
		lazy.resize(2*n-1,0);
		for(int i=0; i<sz; i++) node[i+n-1] = v[i];
		for(int i=n-2;i>=0;i--) node[i] = min(node[i*2+1] , node[i*2+2]);
	}
	void eval(int k, int l, int r) {
		if(lazy[k] != 0) {
			node[k] += lazy[k];
			if(r - l > 1) {
				if(node[2*k+1]!=INF)lazy[2*k+1] += lazy[k];
				if(node[2*k+2]!=INF)lazy[2*k+2] += lazy[k];
			}
			lazy[k] = 0;
		}
	}
	void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
		if(r < 0) r = n;
		eval(k, l, r);
		if(b <= l || r <= a) return;
		if(a <= l && r <= b) {
			lazy[k] += x;
			eval(k, l, r);
		}
		else {
			add(a, b, x, 2*k+1, l, (l+r)/2);
			add(a, b, x, 2*k+2, (l+r)/2, r);
			node[k] = min(node[2*k+1] , node[2*k+2]);
		}
	}
	ll getmin(int a, int b, int k=0, int l=0, int r=-1) {
		if(r < 0) r = n;
		if(b <= l || r <= a) return INF;
		eval(k, l, r);
		if(a <= l && r <= b) return node[k];
		ll vl = getmin(a, b, 2*k+1, l, (l+r)/2);
		ll vr = getmin(a, b, 2*k+2, (l+r)/2, r);
		return min(vl , vr);
	}
};

int main(){
	ll N,M,ans=0,l,r,a;
	cin >> N >> M;
	LazySegmentTree dp( vector<ll>(N+1,0) );
	vector< vector<P> > add(N+2),del(N+2);
	FOR(i,0,M){
		cin >> l >> r >> a;
		add[l].push_back({l,-a});
		del[r].push_back({l,-a});
	}

	FOR(i,1,N+1){
		for(auto x:add[i]){
			dp.add(0,i,x.second);
		}
		a = dp.getmin(0,i);
		ans = min(ans,a);
		dp.add(i,i+1,a);
		for(auto x:del[i]){
			dp.add(0,x.first,-x.second);
		}
	}
	cout << -ans << endl;
}



Measured memory_bytes: 30308
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから

void solve(){
  int n,k;
  cin>>n>>k;
  ll mul=1;
  rep(i,n){
    if(i==0)mul*=k;
    else mul*=(k-1);
  }
  cout<<mul;
}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int mod = 998244353;
int main() {
	int n, x;
    cin >> n >> x;
    int dp[n + 10][550];
    for(int i=0; i < n+10; i++){
        for(int j=0; j < 550; j++){
          dp[i][j] = 0;
        }
      }
    dp[0][0] = 1;
    for(int k=0; k <= x; k++){
      for(int i=0; i < n; i++){
        for(int j=0; j < 512; j++){
          dp[i+1][j^k] = (dp[i+1][j^k] + dp[i][j]) % mod;
        }
      }
    }
    cout << dp[n][x] << endl;
    return 0;
   }


Measured memory_bytes: 4204
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
using namespace std;

const int MXN = (int)3e5 + 7;

typedef long long llong;

int n, m, a[MXN], b[MXN], ans;
llong pref_a[MXN], pref_b[MXN], k;

int main(){
  ios_base::sync_with_stdio(0);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cin >> n >> m >> k;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
    pref_a[i] = a[i] + pref_a[i - 1];
  }
  for(int i = 1; i <= m; i++){
    cin >> b[i];
    pref_b[i] = b[i] + pref_b[i - 1];
  }
  for(int i = 0; i <= n; i++){
    int cnt = 0;
    llong sum = 0;
    sum += (pref_a[i] <= k ? pref_a[i] : 0);
    cnt += (pref_a[i] <= k ? i : 0);
    ///
    cnt += upper_bound(pref_b + 1, pref_b + m + 1, k - sum) - pref_b;
    cnt--;
    ans = max(ans, cnt);
  }
  cout << ans;
	return 0;
}


Measured memory_bytes: 8312
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    ll h,n;
    cin>>h>>n;
    lvec a(n);
    rep(i,n)cin>>a[i];
    ll cnt=0;
    rep(i,n)cnt+=a[i];
    cout<<(cnt>=h?"Yes":"No");
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>

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

int main(){
    int n; cin >> n;
    if (n % 2 == 0){
        cout << n / 2 << endl;
    }else{
        cout << n / 2 + 1 << endl;
    }
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(M)]
for ab_i in ab:
    min_j = -1
    min_manh = float('inf')
    for j, cd_j in enumerate(cd):
        if min_manh > abs(ab_i[0]-cd_j[0])+abs(ab_i[1]-cd_j[1]):
            min_manh = abs(ab_i[0]-cd_j[0])+abs(ab_i[1]-cd_j[1])
            min_j = j+1
    print(min_j)

Measured memory_bytes: 3064
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S, T;
    cin >> S >> T;
    
    string ans = "No";
    if (S == T.substr(0, S.size()))
        ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
N = int(input())
A = list(map(int, input().split()))
now = A[0]
ans = 0
for i in range(1, N):
    if now == A[i]:
        ans += 1
        for j in range(1, N + 1):
            if i == N - 1:
                if j != A[i - 1]:
                    A[i] = j
                    break
            else:
                if j != A[i - 1] and j != A[i + 1]:
                    A[i] = j
                    break
    now = A[i]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int a[10005];
int x[10005];

int main() {
  int b = 1;
  for (int i = 1;i > 0;b++){
    cin >> a[b];
    cin >> x[b];
    i = a[b]+x[b];
    }
    b--;
    for (int i = 1;b > 1;b--){
      if (x[i] < a[i]){
    cout << x[i] << " " << a[i] << endl;
    } else {
      cout << a[i] << " " << x[i] << endl;
      }
      i++;
  }
  return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), d = in.nextInt();
        if(Math.abs(a - c) <= d || (Math.abs(a - b) <=d && Math.abs(b - c) <= d)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (1)
  {
    if (C - B <= 0)
    {
      cout << "Yes" << endl;
      return 0;
    }
    else if (A - D <= 0)
    {
      cout << "No" << endl;
      return 0;
    }
    A = A - D;
    C = C - B;
   // printf("A:C %d:%d", A, C);
  }
  return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var answer = 0L;
            for (var i = 1; i <= N; i++)
            {
                long r = N / i;
                answer += (r * (r + 1) / 2) * i;
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 27520
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

long solve(long h, long w)
{
  if (w == 1) return 1;
  if (h == 1) return 1;
  if (w % 2 == 0) {
    return w / 2 * h;
  } else {
    if (h % 2 == 0) {
      return w * (h / 2);
    } else {
      return w * (h / 2) + w / 2 + 1;
    }
  }
}

int main()
{
  long h, w;
  std::cin >> h >> w;

  std::cout << std::setprecision(20);
  std::cout << solve(h, w) << std::endl;
}


Measured memory_bytes: 256
import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

class Main {
	static int m, n;
	static double[][] pm, pn;
	static ArrayList<Double> lis;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			m = sc.nextInt();
			n = sc.nextInt();
			if (m == 0 && n == 0)
				break;
			pm = new double[m][2];
			pn = new double[n][2];
			lis = new ArrayList<>();
			for (int i = 0; i < m; ++i) {
				pm[i][0] = sc.nextDouble();
				pm[i][1] = sc.nextDouble();
				lis.add(pm[i][0]);
			}
			for (int i = 0; i < n; ++i) {
				pn[i][0] = sc.nextDouble();
				pn[i][1] = sc.nextDouble();
				lis.add(pn[i][0]);
			}
			Collections.sort(lis);
			for (int i = 0; i < lis.size(); ++i) {
				while (i + 1 < lis.size() && Math.abs(lis.get(i) - lis.get(i + 1)) < 1e-6) {
					lis.remove(i + 1);
				}
			}

			double area = 0;
			for (int i = 0; i + 1 < lis.size(); ++i) {
				double srcX = lis.get(i);
				double dstX = lis.get(i + 1);
				double srcArea = width(srcX, pn) * width(srcX, pm);
				double middleArea = width((srcX + dstX) / 2, pn) * width((srcX + dstX) / 2, pm);
				double dstArea = width(dstX, pn) * width(dstX, pm);
				if (Math.abs(middleArea) < 1e-6)
					continue;
				area += (dstX - srcX) / 6 * (srcArea + dstArea + 4 * middleArea);
			}
			System.out.println(area);
		}
	}

	static double width(double x, double[][] arr) {
		int len = arr.length;
		double lb = Double.MAX_VALUE / 10;
		double ub = -Double.MAX_VALUE / 10;
		for (int i = 0; i < len; ++i) {
			double x1 = arr[i][0];
			double x2 = arr[(i + 1) % len][0];
			double y1 = arr[i][1];
			double y2 = arr[(i + 1) % len][1];
			if (Math.abs(x1 - x2) < 1e-6)
				continue;
			if ((x - x1) * (x - x2) <= 0) {
				double b = (Math.abs(x - x1) * y2 + Math.abs(x - x2) * y1) / (Math.abs(x - x1) + Math.abs(x - x2));
				lb = Math.min(lb, b);
				ub = Math.max(ub, b);
			}
		}
		return Math.max(0, ub - lb);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 48052
// AOJ 0583

#include <stdio.h>
#include <math.h>
#include <float.h>

int gcd(int a, int b)
{
        int c;

        while (b > 0) {
                c = a % b;
                a = b;
                b = c;
        }

        return a;
}
int upper_div[100000];
int div_cnt;
int N;
int x[3];
int print_divisors(int n)
{
        int i;

        div_cnt=0;

        for(i=1;i<=sqrt((double)n);i++)
                if((n % i)==0)
                {
                        printf("%d\n",i);
                        if(i != n/i)
                                upper_div[div_cnt++]=n/i;
                }
        for(i=div_cnt-1;i>=0;i--)
                printf("%d\n",upper_div[i]);

}

main()
{
        int i,gcd_;

        scanf("%d",&N);

        for(i=0;i<N;i++)
                scanf("%d",&x[i]);
        
        gcd_=gcd(x[0],x[1]);
        if(N==3)
                gcd_=gcd(gcd_,x[2]);
        
        print_divisors(gcd_);
        return(0);

}

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	int n; cin >> n;
	int v = 0;

	rep(i, 0, n) {
		ll t; cin >> t;
		while ((t & 1) == 0) t >>= 1, v++;
	}
	cout << v << endl;
}


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

flag=1
c=0
while flag==1:
  for i in range(0,n):
    if a[i]%2!=0:
      flag=0
      break
  if flag==1:
    c+=1
    for j in range(0,n):
      a[j]//=2
print(c)

Measured memory_bytes: 3060
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    a = sorted(LI())
    r = a[-1]
    a[-1] -= 1

    return r + max(a)


print(main())



Measured memory_bytes: 6860