akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

int main(void)
{
  int i[26],flag = 0;
  char n[110];
  scanf("%s",n);
  
  for(int m = 0;m <= 26;m++)
  {
    i[m] = 0;
  }
  
  for(int m = 0;m < strlen(n);m++)
  {
    i[n[m] - 97] += 1;
  }
  
  for(int j = 0;j <= 25; j++)
  {
    if(i[j] % 2 != 0){printf("No"); return 0;}
  }
  
  printf("Yes");
  
  return 0;
}

Measured memory_bytes: 128
n=int(input())
A=[[0]*10 for i in range(10)]
for i in range(1,n+1):
  a=str(i)
  b=int(a[0])
  c=int(a[-1])
  A[b][c]=A[b][c]+1
ans=0
for i in range(1,10):
  for j in range(1,10):
    ans=ans+A[i][j]*A[j][i]
print(ans)

Measured memory_bytes: 3064
#m-solutions2020 a
import sys
input = sys.stdin.readline

X=int(input())

if 400<=X<=599:
    print(8)
elif 600 <=X<= 799:
    print(7)
elif 800<=X<=999:
    print(6)
elif 1000<=X<=1199:
    print(5)
elif 1200<=X<=1399:
    print(4)
elif 1400<=X<=1599:
    print(3)
elif 1600<=X<=1799:
    print(2)
elif 1800<=X<=1999:
    print(1)
    


Measured memory_bytes: 9208
import java.util.*;
import java.io.*;

public class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	
	public static void main(String[] args) throws Exception {
		int N = Integer.parseInt(br.readLine());
		
		int[] yarra = new int[N];
		String[] split = br.readLine().split(" ");
		long max = -1;
		long min = 1000000001;
		for(int i = 0; i < yarra.length; i++) {
			long x = Long.parseLong(split[i]);
			max = Math.max(max, x);
			min = Math.min(min, x);
		}
		pw.println(max - min);
		
		pw.close();
	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int n, x, t; cin >> n >> x >> t;
  cout << ((n+x-1) / x) * t << endl;

  return 0;
}

// EOF

Measured memory_bytes: 3636
#include<cstdio>
#define ll long long 
using namespace std;
ll n,k,ans;
int main()
{
	scanf("%lld%lld",&n,&k);
	ans+=(n/k)*(n/k)*(n/k);
	if (k%2==0)
	{
		ll t=0;
		if (n>=(k/2))  t=(n-(k/2))/k+1;
		ans+=t*t*t;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())

    def rec(x):
        if x < 4:
            ans = 0
            for i in range(1, x + 1):
                ans ^= i
            return ans

        p = 0
        y = 1
        while y << 1 <= x:
            y <<= 1
            p += 1

        return (1 << p) * ((x - y + 1) % 2) + rec(x & ~(1 << p))

    if A == 0:
        print(rec(B))
    else:
        print(rec(B) ^ rec(A - 1))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9208
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			long mod = 1000000000 + 7;

			int n = int.Parse(Console.ReadLine());
			Dictionary<int, List<KeyValuePair<int, int>>> map = new Dictionary<int, List<KeyValuePair<int, int>>>();
			for (int i = 0; i < n - 1; i++) {
				int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
				int u = vs[0] - 1;
				int v = vs[1] - 1;
				int w = vs[2];
				if (!map.ContainsKey(u)) {
					map.Add(u, new List<KeyValuePair<int, int>>());
				}
				map[u].Add(new KeyValuePair<int, int>(v, w));
				if (!map.ContainsKey(v)) {
					map.Add(v, new List<KeyValuePair<int, int>>());
				}
				map[v].Add(new KeyValuePair<int, int>(u, w));
			}
			int[] ans = new int[n];
			Queue<int> queue = new Queue<int>();
			ans[0] = 1;
			queue.Enqueue(0);
			while (queue.Count > 0) {
				int node = queue.Dequeue();
				foreach (var item in map[node]) {
					if (ans[item.Key] == 0) {
						queue.Enqueue(item.Key);
						if (item.Value % 2 == 0) {
							ans[item.Key] = ans[node];
						} else {
							ans[item.Key] = ans[node] + 1;
						}
					}
				}
			}
			foreach (var i in ans) {
				Console.WriteLine(i % 2);
			}


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 34756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            Console.WriteLine(N < 1000 ? "ABC" : "ABD");
        }
    }
}

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

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

    int l, r;
    cin >> l >> r;

    int modL = l % 2019;
    int divL = l / 2019;
    int modR = r % 2019;
    int divR = r / 2019;

    if (divL == divR) {
        int mini = 2019;
        for (int i = modL; i < modR; i++) {
            for (int j = modL + 1; j <= modR; j++) {
                int tmp = (i * j) % 2019;
                mini = min(mini, tmp);
            }
        }
        cout << mini << '\n';
    }
    else cout << 0 << '\n';
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <complex>
#include <stdio.h>
#include <unordered_set>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 2e9 + 1;
const LL LINF = 1e12;
const LL MAXN = 5e3 + 1;
const LD EPS = 1e-6;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	string s;
	cin >> s;
	if (SZ(s) < 4)
		cout << "No";
	else
	{
		bool ok = 1;
		if (s[0] != 'Y')
			ok = 0;
		if (s[1] != 'A')
			ok = 0;

		if (s[2] != 'K')
			ok = 0;

		if (s[3] != 'I')
			ok = 0;

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

	return 0;
}

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //good luck kittu!
    ll n; cin>>n;
    map<ll, ll> m;
    for(ll i = 2; i*i<=n; i++){
        if(n%i==0){
            while(n%i==0){
                m[i]++;
                n /= i;
            }
        }
    }
    if(n>1) m[n]++;

    ll ans = 0;
    for(auto x : m){
        if(x.second==1) ans++;
        else{
            ll a = 1, count = 0;
            while(x.second>=a){
                count++;
                x.second -= a;
                a++;
            }
            ans += count;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		int[] s = new int[n];
		for(int i = 0 ; i < n ; i++) {
			s[i] = -1;


		}

		int ans = 0;
		for(int i = 0 ; i < m ; i++) {
			int temp1 = Integer.parseInt(sc.next()) -1;
			int temp2 = Integer.parseInt(sc.next());

			if(s[temp1] == -1) {
				s[temp1] = temp2;
			}else if(s[temp1] != temp2) {
				ans = -1;
				break;
			}

		}


		for(int i = 0 ; i < n ; i++) {
			if(s[i] == -1) {
				if(i == 0 && n != 1) {
					s[i] = 1;
				}else {
					s[i] = 0;
				}
			}
		}

		if(n != 1 && s[0] == 0) {
			ans = -1;
		}

		if(ans != -1) {
			String tmp = "";
			for(int i = 0 ; i < n ; i++ ) {
				tmp += "" + s[i];
			}
			
			ans = Integer.parseInt(tmp);
		}	

		System.out.println(ans);
	}
}

Measured memory_bytes: 23124
n, a = map(int, input().split())
x=list(map(lambda x: int(x)-a, input().split()))
k=[[0]*3000 for i in range(60)]
for i in range(3000):
    k[0][i]=0
k[0][x[0]+1500]+=1
k[0][1500]+=1
for i in range(1, n):
    for j in range(3000):
        if 3000>j-x[i]>=0:
            k[i][j]=k[i-1][j-x[i]]+k[i-1][j]
        else:
            k[i][j]=k[i-1][j]
print(k[n-1][1500]-1)

Measured memory_bytes: 4980
n,m,x,y = map(int, input().split())
n = int(n)
m = int(m)
x = int(x)
y = int(y)
s = []
for i in range(2):
    a = input().split()
    s.append([int(m) for m in a])

s[0].append(x)
s[1].append(y)
p = max(s[0])
q = min(s[1])

if p >= q:
    print("War")
else:
    print("No War")

Measured memory_bytes: 3064
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let xab :Vec<i32> = read_vec();
    let a = xab[0] - xab[1];
    let b = xab[0] - xab[2];
    let ans = if a.abs() > b.abs() {
        "B".to_string()
    } else {
        "A".to_string()
    };
    println!("{}",ans);
}

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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int const N = 1e5 + 7;
int ds[N];

int frep(int x)
{
	return x == ds[x] ? x : ds[x] = frep(ds[x]);
}

void join(int a, int b)
{
	a = frep(a); b = frep(b);
	ds[b] = a;
}

int main()
{
	fastio;

	for (int i = 1; i < N; ++i)
		ds[i] = i;

	int n, m;
	cin >> n >> m;

	int u, v;
	for (int i = 0; i < m; ++i)
	{
		cin >> u >> v;
		join(u, v);
	}

	int res = 0;
	for (int i = 2; i <= n; ++i)
	{
		if (frep(1) != frep(i))
			join(1, i), res++;
	}
	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 4044
def resolve():
    N = int(input())
    ans = [0,0,0,0]
    for i in range(N):
        S = input()
        if S == 'AC':
            ans[0] += 1
        if S == 'WA':
            ans[1] += 1
        if S == 'TLE':
            ans[2] += 1
        if S == 'RE':
            ans[3] += 1
    print( 'AC x ' + str(ans[0]) )
    print( 'WA x ' + str(ans[1]) )
    print( 'TLE x ' + str(ans[2]) )
    print( 'RE x ' + str(ans[3]) )
resolve()

Measured memory_bytes: 9216
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[7]={1,2,4,8,16,32,64};
int main()
{
	cin>>n;
	for(int i=6; i>=0; i--)
	{
		if(n>=a[i])
		{
			cout<<a[i];
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}
#ifdef LOCAL
	#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
	#define debug(...) 3
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using ull = uint64_t; using ld = long double;
using pii = pair<int, int>; using pll = pair<ll, ll>;

// -----------------------------------------------------------------------------

void func() {
	char a, b; cin >> a >> b;
	if (a == b) {
		cout << 'H' << endl;
	} else {
		cout << 'D' << endl;
	}
}

int main() {
	fast_io; cout_precision;
	int t = 1; // cin >> t;
	for (int i = 1; i <= t; ++i) {
		func();
	}
}

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

int MOD=1e9+7;

int main() {
  int n; cin>>n;
  string s1,s2;
  cin>>s1>>s2;
  
  long long int ans = 0, s=0;
  if (n==1) {
    cout << 3 << endl;
    return 0;
  }
  if (s1[0]==s1[1]) {
    s = 2;
    ans = 6;
  } else {
    s = 1;
    ans = 3;
  }
  for(int i=s;i<n;++i){
    if (s1[i]!=s2[i]) {
      // よこ
      if (s1[i-1]==s2[i-1]){
        // たて->よこ
        (ans *= 2) %= MOD;
      } else {
        // よこ->よこ
        (ans *= 3) %= MOD;
      }
      ++i;
    } else {
      // たて
      if (s1[i-1]==s2[i-1]){
        // たて->たて
        (ans *= 2) %= MOD;
      }
    }
  }
  
  cout << (ans+MOD)%MOD << endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readlines = sys.stdin.buffer.readlines
input = sys.stdin.buffer.readline
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in [0]*10]
A = map(int, read().split())

for i in range(10):
    for j in range(10):
        for k in range(10):
            dist = C[j][i] + C[i][k]
            if C[j][k] > dist:
                C[j][k] = dist

cnt = [0]*10
for a in A:
    if a != -1:
        cnt[a] += 1
ans = 0
for i, c in enumerate(cnt):
    ans += C[i][1] * c
print(ans)


Measured memory_bytes: 73104
#include <atcoder/dsu>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

int main() {
  int N,Q;
  cin>>N>>Q;
  dsu d(N);
  int t,u,v;
  for(int i=0;i<Q;i++){
    cin>>t>>u>>v;
    if(t==0){
      d.merge(u,v);
    }
    if(t==1){
      if(d.same(u,v)){
        cout<<1<<endl;
      }
      else {
        cout<<0<<endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 4008
#include <iostream>
#include <math.h>
#include <string>
#include <string.h> 
#include <stdio.h>
using namespace std;
#define MAX 200000
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define OUT(n, m) printf("%lf %lf\n",n,m);
typedef struct Grid{
    double x,y;
}grid;
int koch(int d,grid r,grid l);
int main(){
    int n;
    
    grid p1={0,0},p2={100,0};
    scanf("%d",&n);
    OUT(p1.x,p1.y);
    koch(n,p1,p2);
    OUT(p2.x,p2.y);
}
int koch(int d,grid l,grid r){
    if(d==0)return 0;
    static const double pi = 3.141592653589793;
    grid s,t,u;
    s.x=(2*l.x + r.x)/3, s.y=(2*l.y + r.y)/3;
    t.x=(l.x + 2*r.x)/3, t.y=(l.y + 2*r.y)/3;
    u.x=(t.x-s.x)*cos(pi/3) - (t.y-s.y)*sin(pi/3)+s.x;
    u.y=(t.x-s.x)*sin(pi/3) + (t.y-s.y)*cos(pi/3)+s.y;
    koch(d-1,l,s);
    OUT(s.x,s.y);
    koch(d-1,s,u);
    OUT(u.x,u.y);    
    koch(d-1,u,t);
    OUT(t.x,t.y);
    koch(d-1,t,r);
    return 0;
}

Measured memory_bytes: 3164
N = int(input())
if N % 2 == 1:
    M = int(((N - 1) ** 2 // 2))
    print(M)
    for i in range(1, N):
        print(i, N)
    for i in range(1, int((N - 1) / 2) + 1):
        for j in range(i + 1, N):
            if i + j < N:
                print(i, j)
                print(j, N - i)

else:
    M = int(N * (N - 2) // 2)
    print(M)
    for i in range(N - 2):
        print(1, i + 2)
        print(i + 2, N)
    for i in range(2, int(N / 2) + 1):
        for j in range(i + 1, N):
            if i + j < N + 1:
                print(i, j)
                print(j, N + 1 - i)

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
inline void rd(int &x)
{
	x=0;register char k=getchar();int s=1;
	while(k>'9'|k<'0'){if(k=='-')s=-1;k=getchar();}
	while(k>='0'&&k<='9')x=x*10+k-48,k=getchar();x*=s;
}
int a1,b1,a2,b2,bb,aa;
char k[100];
int main()
{
	int r,g,n,ans=0;
	rd(n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",k);int len=strlen(k),opa=0,opb=0;
		for(int j=0;j<len;j++)
		{
			if(k[j]=='A'&&k[j+1]=='B')ans++;
		}int fir=k[0],la=k[len-1];
		if(fir!='B'&&la!='A')continue;
		if(fir=='B'&&la=='A'){aa++;continue;}
		if(k[0]=='B')
		{
			b1++;
		}else a1++;
		
	}ans+=aa+min(b1,a1);
	if(b1==a1&&a1==0&&aa)ans--;cout<<ans;
}

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

using namespace std;

int levenshtein_distance(const string& s1, const string& s2) {
    auto m = s1.size();
    auto n = s2.size();

    int dp[m+1][n+1];
    for (auto i = 0; i <= m; ++i)
        dp[i][0] = i;
    for (auto j = 0; j <= n; ++j)
        dp[0][j] = j;

    for (auto i = 1; i <= m; ++i) {
        for (auto j = 1; j <= n; ++j) {
            auto cost = s1[i-1] == s2[j-1] ? 0 : 1;
            dp[i][j] = min({
                dp[i-1][j] + 1,     // insert: LD("apple", "play") = LD("appl", "play") + 1
                dp[i][j-1] + 1,     // delete: LD("apple", "play") = LD("apple", "pla") + 1
                dp[i-1][j-1] + cost // replace: LD("apple", "play") = LD("appl", "pla") + 1 or LD("apple", "plane") = LD("appl", "plan") + 0
            });
        }
    }
    return dp[m][n];
}

int main() {
    string s1, s2;
    cin >> s1 >> s2;

    cout << levenshtein_distance(s1, s2) << endl;

    return 0;
}

Measured memory_bytes: 7096
n=int(input())
al=[chr(ord('a') + i) for i in range(26)]
sakai=[]
k=0
for i in range(10):
  k+=26**(i+1)
  sakai.append(k)

if n<=26:
  n-=1
  u=1
elif n>sakai[9]:
  n-=sakai[9]+1
  u=11
for i in range(9):
  if (sakai[i]<n<=sakai[i+1]):
    n-=sakai[i]+1
    u=i+2

def base(n):
  ans=[]
  while(n>=26):
    r=n%26
    n=(n-r)//26
    ans.append(r)
  ans.append(n)
  return ans


p=base(n)

if u-len(p)>0:
  ans_3='a'
  if u-len(p)>1:
    for j in range(u-len(p)-1):
      ans_3+='a'
    
for i in range(len(p)):
  if i==0:
    ans_2=al[p[len(p)-i-1]]
  else:
    ans_2=ans_2+al[p[len(p)-i-1]]
if u-len(p)>0:
  print(ans_3+ans_2)
else:
  print(ans_2)

Measured memory_bytes: 9148
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let ab = input::<i64>();
    let bc = input::<i64>();
    let _ca = input::<i64>();

    let ans = ab * bc / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys, math

if(__name__ == "__main__"):
    N = int( input().strip() )
    Alist = list( map(int, input().strip().split() ) )

    i = 0
    bills = 0
    money = 1000
    while(i<N-1):
        while(i<N-1 and Alist[i] >= Alist[i+1]):
            i += 1
        if(i>=N-1):
            break

        bills = money //Alist[i]
        money -= bills * Alist[i]
        while(i<N-1 and Alist[i] < Alist[i+1]):
            i += 1
        money += bills * Alist[i]
        bills = 0
    print(money)


Measured memory_bytes: 9200
#include "bits/stdc++.h"
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------
-----問題ここまで----- */
/* -----解説等-----
----解説ここまで---- */

LL N;

LL ans = 0LL;

//[L,R]のいい感じの分割
PLL f(VL& csum, int L, int R) {
	int LLL = L, RRR = R;
	FOR(i, 0, 10) { // check [L,mid][mid+1,R]
		int mid1 = (2*L + R) / 3;
		int mid2 = (L + 2*R) / 3;
		LL dif1 = LINF, dif2 = LINF;
		{
			LL A = csum[mid1] - csum[LLL - 1];
			LL B = csum[RRR] - csum[mid1];
			dif1 = abs(A - B);
		}
		{
			LL A = csum[mid2] - csum[LLL - 1];
			LL B = csum[RRR] - csum[mid2];
			dif2 = abs(A - B);
		}
		if (dif2 < dif1) {
			L = mid1;
		}
		else {
			R = mid2;
		}
	}
	LL dd = LINF;
	LL M = 0;
	FOR(i, 0, R-L+1) {
		int mid2 = L + i;
		LL A = csum[mid2] - csum[LLL - 1];
		LL B = csum[RRR] - csum[mid2];
		if (abs(A - B) < dd) {
			dd = abs(A - B);
			M = mid2;
		}
	}
	LL A = csum[M] - csum[LLL - 1];
	LL B = csum[RRR] - csum[M];
	return PLL(A, B);
}

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

	cin >> N;
	VL a(N);
	FOR(i, 0, N)cin >> a[i];
	VL csum(N + 1, 0);
	FOR(i, 0, N)csum[i + 1] = csum[i] + a[i]; 
	// iを決める(a,b||c,d)
	// この中の最適分割は
	// なかをいい感じに分割することである
	ans = LINF;
	FOR(c, 2, N - 1) { // cの位置
		// [A,B]:[1:c]
		PLL ab = f(csum, 1, c);
		// [C,D]:[c+1,N]
		PLL cd = f(csum, c + 1, N);
		LL Max = max({ ab.first,ab.second,cd.first,cd.second });
		LL Min = min({ ab.first,ab.second,cd.first,cd.second });
		ans = min(ans, Max - Min);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3328
n = int(input())
a1 = [int(i) for i in input().split()]
a2 = [int(i) for i in input().split()]

num = a1[0] + a2[n-1]

def f(i):
    if n == 1:
        return 0

    elif i < n-2:
        return max(sum(a2[i:n - 1]), a1[i + 1] + f(i + 1))

    else:
        return max(a1[n-1], a2[n-2])

print(f(0) + num)


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll n, val = 1000, i = 1000, ans ;
    cin >> n ;
    while (val < n) {
        val += i ;
    }
    ans = val - n ;
    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <bitset>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
#define double long double
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch-'0'), ch=getchar();
    return s*w;
}
void print(int x) { if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
signed main()
{
    int n; n=read();
    int res=0;
    for(ri int i=1;i<=n;i++) res+=i*(n-i+1);
    for(ri int i=1;i<n;i++)
    {
        int u,v;
        u=read(), v=read();
        if(u>v) swap(u,v);
        res-=u*(n-v+1);
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
	int N = inputValue();
	vector<int> v;
	inputVector(&v, N);
	sort(v.begin(),v.end());
	double ans = v[0];
	REP(i, N-1){
		ans = (ans + v[i+1]) / 2.0;
	}
	cout << fixed;
	cout << setprecision(8) << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>

using namespace std;

char s[100005];
int f[100005];

int main()
{
   // string s;
    int N,Q,cnt=0;
    cin >> N >> Q;
    cin >> s;
    for(int i=0;i<N;i++){
        if(i!=N-1&&s[i]=='A'&&s[i+1]=='C'){
            f[i]=++cnt;
            i++;
        }
    }
  //  for(int i=0;i<N;i++)
  //      printf("%d,",f[i]);
  //  cout << "\n";
    while(Q--){
        int l,r;
        cin >> l >> r;
        while(f[l-1]==0&&l-1<r-2){
            l++;
        }
        while(f[r-2]==0&&r-2>l-1)
            r--;
        if(f[r-2]==0&&f[l-1]==0)
            cout << "0\n";
        else
            cout << f[r-2]-f[l-1]+1 <<endl;

    }


    return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define int long long

using namespace std;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (i % k == 0) {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	int t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		ll k[n],l[n],r[n];
		
		vector<ip> vl,vr;

		ll ans = 0;
		for(int i=0;i<n;i++){
			cin>>k[i]>>l[i]>>r[i];
			--k[i];
			ans += l[i];
			if(k[i] == n-1)
				continue;
			if(l[i]<r[i])
				vr.pb({r[i]-l[i],k[i]});
			else if(l[i]>r[i]){
				vl.pb({l[i]-r[i],k[i]});
				ans += r[i]-l[i];
			}
		}

		sort(vl.begin(),vl.end());

		set<int>::iterator it;

		set<int> s;
		for(int i=0;i<n;i++)
			s.insert(i);
		for(int i=vl.size()-1;i>=0;i--){
			it = s.upper_bound(vl[i].ss);
			if(it == s.begin())
				continue;
			--it;
			s.erase(it);
			ans += vl[i].ff;
		}

		sort(vr.begin(),vr.end());

		s.clear();
		for(int i=0;i<n;i++)
			s.insert(i);
		for(int i=vr.size()-1;i>=0;i--){
			it = s.lower_bound(vr[i].ss+1);
			if(it == s.end())
				continue;
			s.erase(it);
			ans += vr[i].ff;
		}

		cout<<ans<<endl;
	}				
}


Measured memory_bytes: 20332
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n , k; cin >> n >> k;
    int A[n+2] , dp[n+1];
    for(int i = 1 ;i <= n; i++){
        cin >> A[i];
        dp[i] = Mod;
    }
    dp[1]  = 0;
    for(int i = 1;i <= n; i++){
        for(int j = i+1 ;j <= min(n , i+k) ; j++)
            dp[j] = min(dp[j] , dp[i] + abs(A[j] - A[i]));
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
x, n = map(int, input().split())
p = list(map(int, input().strip().split()))

if n <= 0:
    print(x)
    sys.exit()

else:
    if not x in p:
        print(x)
        sys.exit()
    else:
        a1 = x - 1
        a2 = x + 1
        c = 0
        while True:
            if c % 2 == 0:
                if not a1 in p:
                    print(a1)
                    break
                else:
                    a1 -= 1
            else:
                if not a2 in p:
                    print(a2)
                    break
                else:
                    a2 += 1
            c += 1

sys.exit()



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

string	sort1(string str)
{
	int i = 0, j;
	while (i < str.size() - 1)
	{
		j = i + 1;
		while (j < str.size())
		{
			if (str[i] > str[j])
			{
				char temp;
				temp = str[i];
				str[i] = str[j];
				str[j] = temp;
			}
			j++;
		}
		i++;
	}
	return str;
}

string	sort2(string str)
{
	int i = 0, j;
	while (i < str.size() - 1)
	{
		j = i + 1;
		while (j < str.size())
		{
			if (str[i] < str[j])
			{
				char temp;
				temp = str[i];
				str[i] = str[j];
				str[j] = temp;
			}
			j++;
		}
		i++;
	}
	return str;
}

int		main()
{
	string str1, str2;
	cin >> str1 >> str2;
	str1 = sort1(str1);
	str2 = sort2 (str2);
	if (str1 < str2) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n, k;
    while(cin>>n>>k, n){
        vector<int> a(n);
        for(int i=0; i<n; i++) cin>>a[i];

        vector<ll> sum(n+10, 0);
        for(int i=1; i<=n; i++) sum[i]=sum[i-1]+a[i-1];

        ll ans=-INF;
        for(int i=1; i+k-1<=n; i++){
            chmax(ans, sum[i+k-1]-sum[i-1]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
const int N=20;
char s[N];
int main(){
	scanf("%s",&s);
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') puts("Yes\n");
	else puts("No\n");
	return 0;
} 

Measured memory_bytes: 256
s = []
t = []

n = int(input())
for i in range(n):
    s.append(input()) 
m = int(input())
for i in range(m):
    t.append(input())
    
#print(s)
#print(t)
    
s_set = set(s)
money = 0
for word in s_set:
    cur = s.count(word)-t.count(word)
    if cur > money:
        money = cur
if money < 0:
    money = 0
print(money)
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int a,b,c;
  cin>>a>>b>>c;
  if((a==5&&b==7&&c==7)||(a==7&&b==7&&c==5)||(a==7&&b==5&&c==7))
    cout<<"NO"<<endl;
  else
    cout<<"YES\n";
}

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

int main(){
  string N;
  int K;
  cin >> N >> K;
  vector<bool> flag(10,true);
  int D;
  for(int i=0;i<K;i++){
    cin >> D;
    flag.at(D)=false;
  }
  bool carry=false;
  string ans="";
  int x,j,mi;
  for(int i=0;i<=9;i++){
    if(flag.at(i)){
      mi=i;
      break;
    }
  }
  for(int i=N.size()-1;i>=0;i--){
    x=N.at(i)-'0';
    if(carry){
      x++;
      if(x==10){
        x=0;
      }else{
        carry=false;
      }
    }
    if(flag.at(x)){
      ans.push_back(x+'0');
    }else{
      for(j=x+1;j<=9;j++){
        if(flag.at(j)){
          for(auto & c:ans){
            c=mi+'0';
          }
          ans.push_back(j+'0');
          break;
        }
      }
      if(j==10){
        carry=true;
        for(j=0;j<x;j++){
          if(flag.at(j)){
            for(auto & c:ans){
              c=mi+'0';
            }
            ans.push_back(j+'0');
            break;
          }
        }
      }
    }
  }
  if(carry){
    if(flag.at(1)){
      ans.push_back('1');
    }else{
      for(int i=2;i<=9;i++){
        if(flag.at(i)){
          for(auto & c:ans){
            c=mi+'0';
          }
          ans.push_back(i+'0');
          break;
        }
      }
    }
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
/***************************************** START OF TEMPLATE *********************************************/
#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  newl           cout<<"\n";
#define  f              first
#define  s              second
#define  pb             push_back
#define  mp             make_pair
#define  sym(s)         s="#"+s+"#";
#define  sqr(v)         v*v;
#define  all(x)         (x).begin(),(x).end()
#define  alll(x, n)     x+1, x+n+1
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  mset1d(a,n,v)  foo(i,0,n+5)a[i]=v;
#define  mset2d(a,n,m,v)foo(i,0,n+5)foo(j,0,m+5)a[i][j]=v;
#define  INP(a,n)       foo(i,1,n) cin>>a[i];
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  debm(a)        for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  debp(a,n)      foo(i,1,n)cout<<"{"<<a[i].f<<","<<a[i].s<<"}, ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b;newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c;newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ld   PI    =  3.14159265358979323846; 
const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll n, a[N];

/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    int a, b, c, k;
    cin>>a>>b>>c>>k;    
    while(b<=a){
        b*=2;
        k--;
    }
    while(c<=b){
        c*=2;
        k--;
    }
    k>=0?cout<<"Yes":cout<<"No";
}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
    MAIN(i);
    }
}

Measured memory_bytes: 8348
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int T[128][128], ex[128];
	vector<string> S;
	string s;

	while(cin >> s)
	{
		S.push_back(s);
	}
	
	for(int i = 0; i < S.size(); i++)
	{
		int n = i;
		if(i > S.size()/2)
		{
			n = S.size() - n-1;
		}
 		ex[i] = n;
	}

	for(int i = 0; i < S.size(); i++)
	{
		int m;
		stringstream ss;
		while(S[i].find(",") != string::npos)
		{
			m = S[i].find(",");
			S[i].replace(m, 1, " ");
		}
		ss.str(S[i]);
		
		int n = ex[i];
		for(int j = 0; j <= n; j++)
		{
			ss >> T[i][j];
		}
	}


	int dp[128][128] = {{ 0 }};
	dp[0][0] = T[0][0];
	for(int i = 0; i < S.size()/2; i++)
	{
		for(int j = 0; j <= i; j++)
		{
			for(int k = 0; k <= 1; k++)
			{
				dp[i+1][j+k] = max(dp[i+1][j+k], dp[i][j] + T[i+1][j+k]);
			}
		}
	}

	for(int i = S.size()/2; i < S.size()-1; i++)
	{
		int n = ex[i];
		for(int j = 0; j <= i + 1; j++)
		{
			for(int k = 0; k <= 1; k++)
			{
				if(j-k >= 0 && j+k <= i + 1)
				{
					dp[i+1][j-k] = max(dp[i+1][j-k], dp[i][j] + T[i+1][j-k]);
				}
			}
		}
	}
	/*
	for(int i = 0; i < S.size(); i++)
	{
		for(int j = 0; j <= i; j++)
		{
			printf("%d ",dp[i][j]);
		}
		puts("");
	}
	*/
	cout << dp[S.size()-1][0] << endl;
}

Measured memory_bytes: 1368
import math
n = int(input())
best = math.inf
cmb = None
for i in range(int(math.sqrt(n))):
    i+=1
    if n%i==0:
        if best>n//i-i:
            best=n//i-i
            cmb=i

print(int(math.log10(n//cmb))+1)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll y,m,d;char a,b;
	cin>>y>>a>>m>>b>>d;
	//puta(y,m,d);
	if(y<=2018 or (y==2019 and m<=4))puta("Heisei");
	else puta("TBD");
	return 0;
}

Measured memory_bytes: 892
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int p[200001];
	int res[200001] = {};
	int maxRes = 0;
	for(int i = 0; i < n; i++){
		int p;
		cin >> p;
		p--;
		res[p] = 1;
		if(p > 0) res[p] += res[p - 1];
		maxRes = max(maxRes, res[p]);
	}
	cout << n - maxRes << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

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

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

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(){
   int n;
   cin >> n;
   vector<int> p(n);
   for(int i = 0; i < n; i++){
      cin >> p[i];
   }

   int cnt = 0;
   for(int i = 2; i < n; i++){
      int a = p[i-2];
      int b = p[i-1];
      int c = p[i];
      if((a > b and b > c) or (a < b and b < c)){
         cnt++;
      }
   }

   cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
tmp = 0
ans = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 14252
import fractions

a, b, c, d = map(int, input().split())
cdiv = b//c - (a-1)//c
ddiv = b//d - (a-1)//d
e =  c*d // fractions.gcd(c, d)
ediv = b//e - (a-1)//e
count = b-a+1 - (cdiv + ddiv - ediv)
print(count)

Measured memory_bytes: 5048
#include<iostream>
#include<complex>
#include<vector>
#include<iomanip>

using namespace std;

typedef complex<double> P;

#define EPS 1e-9
#define shosu(x) fixed<<setprecision(x)

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
struct C{
  P c;double r;
  C(const P &c,double r):c(c),r(r){}
};

namespace std{//演算子の定義
  bool operator < (const P& a,const P& b){
    return real(a)!= real(b) ? real(a) < real(b) : imag(a) < imag(b);
    //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b)
  }
  bool operator == (const P& a,const P& b){
    return a.real()==b.real() && a.imag()==b.imag();
  }
}

double dot(P a,P b){
  return real(conj(a)*b);
}

double cross(P a,P b){
  return imag(conj(a)*b);
}

int ccw(P a, P b, P c) {//3点の関係性
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;                               // a--c--b on line
}

P projection(L l, P p){//pの直線l上の射影の点
  double t=dot(p-l[0],l[0]-l[1])/norm(l[0]-l[1]);
  return l[0]+t*(l[0]-l[1]);
}

P reflection(L l, P p){//点pの直線lに関して対称な点
  return p+2.0*(projection(l,p)-p);
}

bool isOrthogonal(L l1, L l2){//2直線の直交判定
  return fabs(dot(l1[1]-l1[0],l2[1]-l2[0])) < EPS;
}

bool isParallel(L l1, L l2){//2直線の平行判定
  return fabs(cross(l1[1]-l1[0],l2[1]-l2[0])) < EPS;
}

int main(){
  double xp1,yp1,xp2,yp2;
  cin>>xp1>>yp1>>xp2>>yp2;
  P p1(xp1,yp1), p2(xp2,yp2);
  L l(p1,p2);

  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    double x,y;
    cin>>x>>y;
    P p(x,y);
    P ans=reflection(l,p);
    cout<<shosu(10)<<ans.real()<<"  "<<ans.imag()<<endl;

  }

}



Measured memory_bytes: 3268
#include<cctype>
#include<string>
#include<iostream>
#include<algorithm>

using namespace std;

int rotx(string &dice){
	char t=dice[0];
	dice[0]=dice[1];
	dice[1]=dice[5];
	dice[5]=dice[4];
	dice[4]=t;
}

int roty(string &dice){
	char t=dice[0];
	dice[0]=dice[3];
	dice[3]=dice[5];
	dice[5]=dice[2];
	dice[2]=t;
}

int rotz(string &dice){
	char t=dice[1];
	dice[1]=dice[3];
	dice[3]=dice[4];
	dice[4]=dice[2];
	dice[2]=t;
}

void next(string &dice,int i){
	if(i%4==0){
		if(i%8==0)	rotx(dice);
		else		roty(dice);
	}
	rotz(dice);
}

int main(){
	string dice[8];
	while(1){
		for(int i=0;i<8;i++)	cin>>dice[i];
		if(dice[0]=="0")	break;

		char co[128];
		for(int c='A';c<='Z';c++)	co[c]=tolower(c);
		for(int c='a';c<='z';c++)	co[c]=toupper(c);

		bool exist[8][128]={};
		for(int i=0;i<8;i++)for(int j=0;j<6;j++)	exist[i][dice[i][j]]=true;

		bool ok=false;
		int i[]={0,1,2,3,4,5,6,7};
		int a,b,c,d,e,f,g,h;
		string diceA,diceB,diceC,diceD,diceE,diceF,diceG,diceH;
		do{	// fix the order of 8 dices
			a=i[0];	b=i[1];	c=i[2];	d=i[3];
			e=i[4];	f=i[5];	g=i[6];	h=i[7];
			diceA=dice[a];	diceB=dice[b];	diceC=dice[c];	diceD=dice[d];
			diceE=dice[e];	diceF=dice[f];	diceG=dice[g];	diceH=dice[h];

			for(int ia=0;ia<24;ia++,next(diceA,ia)){
if(!exist[b][co[diceA[2]]])	continue;
if(!exist[e][co[diceA[5]]])	continue;
				for(int ib=0;ib<24;ib++,next(diceB,ib)){
					if(co[diceA[2]]!=diceB[3])	continue;
if(!exist[c][co[diceB[4]]])	continue;
if(!exist[f][co[diceB[5]]])	continue;
					for(int ic=0;ic<24;ic++,next(diceC,ic)){
						if(co[diceB[4]]!=diceC[1])	continue;
if(!exist[d][co[diceA[4]]] || !exist[d][co[diceC[3]]])	continue;
if(!exist[g][co[diceC[5]]])	continue;
						for(int id=0;id<24;id++,next(diceD,id)){
							if(co[diceA[4]]!=diceD[1] || co[diceC[3]]!=diceD[2])	continue;
if(!exist[h][co[diceD[5]]])	continue;
							for(int ie=0;ie<24;ie++,next(diceE,ie)){
								if(co[diceA[5]]!=diceE[0])	continue;
								for(int iF=0;iF<24;iF++,next(diceF,iF)){
									if(co[diceB[5]]!=diceF[0] || co[diceE[2]]!=diceF[3])	continue;
									for(int ig=0;ig<24;ig++,next(diceG,ig)){
										if(co[diceC[5]]!=diceG[0] || co[diceF[4]]!=diceG[1])	continue;
										for(int ih=0;ih<24;ih++,next(diceH,ih)){
											if(co[diceD[5]]!=diceH[0] || co[diceE[4]]!=diceH[1] || co[diceG[3]]!=diceH[2])	continue;
											ok=true;
											goto FOUND;
										}
									}
								}
							}
						}
					}
				}
			}
		}while(next_permutation(i+1,i+8));

		FOUND:
		cout<<(ok?"YES":"NO")<<endl;
	}

	return 0;
}

Measured memory_bytes: 908
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000000

int main(){

    int n; cin >> n;
    vector<int> c(n);
    vector<int> s(n);
    vector<int> f(n);
    vector<int> ans(n + 1, 0);
    for(int i = 1; i <= n - 1; i++){
        cin >> c[i] >> s[i] >> f[i];
    }

    
    for(int i = 1; i <= n - 1; i++){
        int t = 0;
        for(int j = i; j <= n - 1; j++){
            while(1){
                if(s[j] <= t && t % f[j] == 0){
                t += c[j];
                break;
                }
                t++;
            }
        }
        ans[i] = t;
    }

    for(int i = 1; i <= n; i++){
        cout << ans[i] << endl;
    }    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
        #define ll long long int
        using namespace std;
        #define mod 1000000007
        #define pb push_back
        #define fi first
        #define si second
        #define mp make_pair
        #define f(n) for(ll i=0;i<n;i++)
        #define ff(m) for(ll j=0;j<m;j++)
        #define fr(i,p,n) for(ll i=p;i<n;i++)
        #define in insert
        ll exp(ll a,ll b,ll m);
        #define vl vector<ll> 
        #define pll pair <ll,ll>

    
        void solve(){

        	int n;
        	cin>>n;
        	if(n%10==3)
        		cout<<"bon"<<endl;
        	else if(n%10==0 || n%10 == 1 || n%10==6 || n%10==8 )
        		cout<<"pon"<<endl;
        	else
        		cout<<"hon"<<endl;



        }
 
       int main(){
 
            int t=1;
 			//cin>>t;
            while(t--)
               solve();
    
    		return 0;
		}
 
		ll exp(ll a,ll b,ll m)
		{
			if(b==0)
			{
				return 1;
			}
			ll temp =exp(a,b/2,m);
			temp=(temp*temp)%m;
			if(b&1)
			{
				return (temp*(a%m))%m;
			}
			return temp;
		}

Measured memory_bytes: 3620
#include <stdio.h>
#include<ctype.h>

int main(int argc, char const *argv[]) {
  int N,K;
  char S[50];

  scanf("%d %d\n",&N,&K );
  scanf("%s",&S);

  S[K-1] = tolower(S[K-1]);
  printf(S);
  
  return 0;
}


Measured memory_bytes: 128