akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		final int[] days = {
			31, 28, 31, 30, 31, 30,
			31, 31, 30, 31, 30, 31
		};
		Scanner input = new Scanner(System.in);
		Leap leap = new Leap();
		
		while (true){
			Day[] day = new Day[2];
			
			for (int i = 0; i < 2; i++){
				int year = input.nextInt();
				int month = input.nextInt();
				int date = input.nextInt();
				if (year < 0 || month < 0 || date < 0) return;
				day[i] = new Day(year, month, date);
			}
			
			int res = 0;
			while (true){
				if (day[0].equal(day[1])){
					System.out.println(res);
					break;
				}
				
				int year = day[0].getYear();
				int month = day[0].getMonth();
				int date = day[0].getDate();
				int tmp = days[month - 1];
				if (leap.isLeap(day[0]) && month == 2) tmp++;
				
				date++;
				if (date > tmp){
					date = 1;
					month++;
				}
				if (month > 12){
					month = 1;
					year++;
				}
				res++;
				
				day[0].setYear(year);
				day[0].setMonth(month);
				day[0].setDate(date);
			}
		}
	}
}

class Day {
	private int year;
	private int month;
	private int date;
	
	public Day(){}
	public Day(int year, int month, int date){
		this.year = year;
		this.month = month;
		this.date = date;
	}
	public void printDay(){
		System.out.println("year = " + this.year);
		System.out.println("day = " + this.month);
		System.out.println("date = " + this.date);
	}
	
	public void setYear(int year){
		this.year = year;
	}
	public void setMonth(int month){
		this.month = month;
	}
	public void setDate(int date){
		this.date = date;
	}
	public int getYear(){
		return this.year;
	}
	public int getMonth(){
		return this.month;
	}
	public int getDate(){
		return this.date;
	}
	public boolean equal(Day day){
		int year = day.getYear();
		int month = day.getMonth();
		int date = day.getDate();
		return this.year == year &&
		       this.month == month &&
			   this.date == date;
	}
}

class Leap {
	Leap(){}
	boolean isLeap(Day day){
		int year = day.getYear();
		return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
	}
}

Measured memory_bytes: 20708
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int n;
double v[1011];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> v[i];
  sort(v + 1, v + 1 + n);
  double ans = v[1];
  for (int i = 2; i <= n; ++i) {
    ans += v[i];
    ans /= 2.;
  }
  cout << setprecision(10) << fixed << ans << endl;
}





Measured memory_bytes: 256
import sys
input=sys.stdin.readline
import math

N,M=(int(x) for x in input().rstrip('\n').split())
As=[int(x) for x in input().rstrip('\n').split()]
n = 1
use2 = 0
check = 0
for i in range(N):
  x = As[i]
  if i==0:
    while x % 2==0:
      use2+=1 
      x = x//2
    lcm=x
  else:
    use=0
    while x%2==0:
      x = x//2
      use += 1
    if use2 != use:
      check += 1
      break
    lcm=lcm*x//(math.gcd(lcm,x))
if check > 0:
  print(0)
else:
  LCM=2**(use2-1)
  LCM=LCM*lcm
  print(((M//LCM)+1)//2)

Measured memory_bytes: 20212
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
int main()
{
    ll m,n,k,s,i,H,W,ans=0;
    scanf("%lld%lld%lld",&n,&k,&s);
    if(s!=1000000000)
    {
        for(i=1; i<=k; i++)
            printf("%lld ",s);
        for(i=1; i<=n-k; i++)
        {
            printf("1000000000");
            if(i!=n-k)
                printf(" ");
        }
    }
    else
    {
         for(i=1; i<=k; i++)
            printf("%lld ",s);
        for(i=1; i<=n-k; i++)
        {
            printf("1");
            if(i!=n-k)
                printf(" ");
        }
    }


}


Measured memory_bytes: 1280
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

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

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

    if(a > 0){
        cout << "Positive" << endl;
        return 0;
    }

    if(a <= 0 && b >= 0){
        cout << "Zero" << endl;
        return 0;
    }

    if((b - a) % 2 == 0){
        cout << "Negative" << endl;
        return 0;
    }
    cout << "Positive" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve()
{
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	deque<int> p(a),q(b),r(c);
	for(auto &i:p)
		cin>>i;
	for(auto &i:q)
		cin>>i;
	for(auto &i:r)
		cin>>i;
	sort(p.rbegin(),p.rend());
	sort(q.rbegin(),q.rend());
	sort(r.rbegin(),r.rend());
	while(p.size()!=x)
		p.pop_back();
	while(q.size()!=y)
		q.pop_back();
	for(auto &i:p)
		r.push_back(i);
	for(auto &i:q)
		r.push_back(i);
	sort(r.rbegin(),r.rend());
	int i=0,ans=0;
	while(i!=x+y)
	{
		ans+=r.front();
		r.pop_front();
		i++;
	}
	cout<<ans;
}
int32_t main()
{
	// vector<int> l={0,0,2,2,2,2,3};
	// auto it=lower_bound(l.begin(),l.end(),1);
	// l.insert(it,1);
	// for(auto i:l)
	// 	cout<<i<<" ";
	// cout<<"\n";
	// return 0;
    //_READ
	_FAST
    int t;
    t=1;
    while(t--)
        solve();
    return 0;
}
/*
===FOR N-Dimensional Vector===
https://codeforces.com/blog/entry/76149
g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined a.cpp -o a -D_GLIBCXX_DEBUG
*/


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

int main() {
  int H, W;
  cin >> H >> W;
  
  for(int i = 0; i < H + 2; i++) {
    if(i == 0 || i == H + 1) { 
      for(int j = 0; j < W + 2; j++) {
        cout << '#';
      }
      cout << endl;
    }
    else {
      string a;
      cin >> a;
      cout << '#' << a << '#' << endl;
    }
  }
}

Measured memory_bytes: 256
def insertionSort(A,n,g):
  global count
  for i in range(g,n,1):
    v=A[i]
    j=i-g
    while (j >= 0) & (A[j] > v):
      A[j+g] = A[j]
      j = j - g
      count +=1
    A[j+g] = v

n = int(input())
A = [int(input()) for i in range(n)] 

count = 0
G = [1]
while n > 1 + 3*G[-1]:
  G.append(1 + 3*G[-1])
m = len(G)
G.reverse()
for i in range(m):
    insertionSort(A, n, G[i])
    
print(m)
print(*G)
print(count)
print(*A, sep='\n')


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

int abs(int n) {
  if (n > 0) return n;
  else return -n;
}

int dist(int x1,int y1,int x2,int y2) {
  return (abs(x1-x2) + abs(y1-y2));
}

bool check(int t1,int t2,int dist) {
  if (t2-t1 < dist) return false;   //遠い
  else if ((t2-t1)%2 != dist%2) return false;  //偶奇が一致しない
  else return true;
}
  

int main() {
  int N;
  cin >> N;
  bool ok = true;
  
  vector<int> T(N);
  vector<int> X(N);
  vector<int> Y(N);
  for (int i = 0;i<N;i++) {
    cin >> T.at(i);
    cin >> X.at(i);
    cin >> Y.at(i);
  }
  ok = check(0,T.at(0),dist(0,0,X.at(0),Y.at(0)));
  for (int i = 0;i<N-1;i++) {
    ok = check(T.at(i),T.at(i+1),dist(X.at(i),Y.at(i),X.at(i+1),Y.at(i+1)));
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;  
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <string>

using namespace std;

using i32 = int;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;

using pii = pair<i32, i32>;

#define rep(i, n) for (i32 i = 0; i < (n); ++i)
#define repr(i, n) for (i32 i = ((n)-1); i >= 0; --i)
#define urep(i, n) for (u32 i = 0; i < (n); ++i)
#define urepr(i, n) for (u32 i = ((n)-1); i >= 0 && i < (n); --i)
#define all(v) v.begin(), v.end()

int A[200000];
int A2[200000];

int main()
{
	int N;
	cin >> N;
	rep(i, N) {
		int x;
		cin >> x;
		A[i] = A2[i] = x;
	}
	sort(A2, A2 + N);
	if (N >= 2) {
		int max1 = A2[N - 1];
		int max2 = A2[N - 2];
		rep(i, N) {
			printf("%d\n", (max1 == A[i]) ? max2 : max1);
		}
	}
	return 0;
}


Measured memory_bytes: 3200
import kotlin.math.abs
import kotlin.math.min
import kotlin.math.max

fun main() {
    val (n, k) = readLongList()
    val tmp = n % k
    println(min(tmp, abs(tmp - k)))
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}


Measured memory_bytes: 36420
def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(4, n + 1, 2):
        sieve[i] = 2
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i * 2):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


def prime_factorize(n):
    result = []
    while n != 1:
        p = prime_table[n]
        e = 0
        while n % p == 0:
            n //= p
            e += 1
        result.append((p, e))
    return result


N = int(input())

m = 1000000007

prime_table = make_prime_table(N)

t = [0] * (N + 1)
for i in range(2, N + 1):
    for p, e in prime_factorize(i):
        t[p] += e

result = 1
for i in range(2, N + 1):
    if t[i] == 0:
        continue
    result = result * (t[i] + 1) % m
print(result)


Measured memory_bytes: 9472
import sys
f = sys.stdin
import math, cmath

direction = 1j
location = 0 + 0j
while True:
    step, degrees = map(int, f.readline().split(','))
    location += direction * step
    direction *= cmath.rect(1, math.radians(-degrees))
    if step == 0:
        break
print(int(location.real))
print(int(location.imag))

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

int main(){ 
    int b;
    int n;
    cin>>n;
    vector<int> a(n);
for (int i = 0; i < n; i++) {
  cin >> a.at(i);
}
sort(a.begin(), a.end());
b=a.at(n/2)-a.at((n/2)-1);
cout <<b;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, check = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A % 2 == 0) {
      if (A % 3 != 0 && A % 5 != 0) {
        check = 1;
        break;
      }
    }
  }
  if (check == 1) {
    cout << "DENIED" << endl;
  }
  else {
    cout << "APPROVED" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int n;
	cin>>n;
	int k=7;
		for(int i=1; i<=n; i++){
			k%=n;
			if(k==0){cout<<i; return 0;}
			k=10*k+7;
		}
		
	cout<<-1<<endl;
}

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

int a,b,c,d,e,k;
cin >> a >> b >> c >> d >> e ;
cin >> k ;
if( e - a > k){
  cout << ":(" << endl;
}
else {
  cout << "Yay!" << endl;
}
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr

using namespace std;

using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;

#define _LIBCPP_DEBUG 0
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
    bool deck[4][13];
    int n, num;
    char s;
    
    for (auto i=0; i<4; i++) for (auto j=0; j<13; j++) deck[i][j] = false;
    
    cin >> n;
    for (auto i=0; i<n; i++) {
        cin >> s >> num;
        if (s == 'S') deck[0][num-1] = true;
        else if (s == 'H') deck[1][num-1] = true;
        else if (s == 'C') deck[2][num-1] = true;
        else if (s == 'D') deck[3][num-1] = true;
    }
    
    for (auto i=0; i<4; i++) {
        if (i == 0) s = 'S';
        else if (i == 1) s = 'H';
        else if (i == 2) s = 'C';
        else if (i == 3) s = 'D';
        
        for (auto j=0; j<13; j++) {
            if (!deck[i][j]) {
                cout << s << " " << j+1 << endl;
            }
        }
    }
}


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

int main() {
    int N ,T;
    cin >> N >> T;

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

    int ans = (1 << 16);

    for(int i = 0; i < N; i++)
    {
        if (t[i] <= T && c[i] < ans) {
            ans = c[i];
        }
        
    }

    if (ans != (1 << 16)) {
        cout << ans << endl;
    }
    else {
        cout << "TLE" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int N,M,X,A[101],i,x,R[101]={0},res1=0,res2=0;
  scanf("%d %d %d",&N,&M,&X);
  for(i=0;i<M;i++)
    scanf("%d",&A[i]);
  for(i=0;i<M;i++)
    R[A[i]] = 1;
  x=X;
  for(i=X;i<N;i++)
    res1 += R[i];
  for(i=X;i>0;i--)
    res2 += R[i];
  printf("%d\n",min(res1,res2));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int x;
  cin >> x;

  bool f=false;
  rep1(i,1000){
    int y=100*i;
    int d=x-y;
    if(d<0) break;
    if(d<=5*i){
      f=true;
      break;
    } 
  }

  if(f) cout << 1 << "\n";
  else cout << 0 << "\n";
  return 0;
}


Measured memory_bytes: 256
N = int(input())
for i in range(N) :
    r, t = map(int, input().split())
    
    chair = int(r / 100) + int(t / 30) * 5
    ans = str(chair)
    
    if r % 100 != 0 :
        ans = ans + " " + str(chair + 1)
    
    if t % 30 != 0 :
        ans = ans + " " + str(chair + 5)
        if r % 100 != 0 :
            ans = ans + " " + str(chair + 6)
    print(ans)


Measured memory_bytes: 5596
#include <stdio.h>
int main(void){
    double x;
    
    while(scanf("%lf",&x)==1){
        if(x<=48)printf("light fly\n");
        else if(x<=51)printf("fly\n");
        else if(x<=54)printf("bantam\n");
        else if(x<=57)printf("feather\n");
        else if(x<=60)printf("light\n");
        else if(x<=64)printf("light welter\n");
        else if(x<=69)printf("welter\n");
        else if(x<=75)printf("light middle\n");
        else if(x<=81)printf("middle\n");
        else if(x<=91)printf("light heavy\n");
        else printf("heavy\n");
    }
    

    return 0;
}



Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.StringTokenizer;


public class Main {
	
	static class Scanner{
		BufferedReader br=null;
		StringTokenizer tk=null;
		public Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		public String next() throws IOException{
			while(tk==null || !tk.hasMoreTokens()) {
				String cad = br.readLine();
				if (cad == null)
					return null;
				tk=new StringTokenizer(cad);
			}
			return tk.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException{
			return Integer.valueOf(next());
		}
		public long nextLong() throws NumberFormatException, IOException{
			return Long.valueOf(next());
		}
		public double nextDouble() throws NumberFormatException, IOException{
			return Double.valueOf(next());
		}
	}
	
	
	static class State {
		int mask;
		int tam;
		public State(int[] count) {
			mask = 0;
			tam = count.length;
			for(int i = 0; i < tam; i++)
				if (count[i] % 2 == 1)
					mask = mask | (1<<i);
		}
		public State(int m, int t) {
			mask = m;
			tam = t;
		}
		LinkedList<Integer> generateNextStates() {
			LinkedList<Integer> ret = new LinkedList<Integer>();
			ret.add(mask);
			for(int i = 0; i < tam; i++) {
				int nmask = mask ^ (1<<i);
				ret.add(nmask);
			}
			return ret;
		}
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + mask;
			return result;
		}
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			State other = (State) obj;
			if (mask != other.mask)
				return false;
			return true;
		}
	}
	
	static char[] s;
	
	public static void main(String args[]) throws IOException {
		Scanner sc = new Scanner();
		s = sc.next().toCharArray();
		int[] ans = new int[s.length];
		int[] count = new int[27];
		Arrays.fill(count, 0);
		HashMap<State, Integer> map = new HashMap<State, Integer>();
		State cstate = new State(count);
		map.put(cstate, 0);
		int idx = 0;
		for(char c: s) {
			count[c - 'a']++;
			State cs = new State(count);
			LinkedList<Integer> ns = cs.generateNextStates();
			int current_value = Integer.MAX_VALUE;
			for(int m: ns) {
				State tmp = new State(m, count.length);
				if (map.containsKey(tmp))
					current_value = Math.min(current_value, map.get(tmp) + 1);
			}
			ans[idx] = current_value;
			if (!map.containsKey(cs) || map.get(cs) > current_value)
				map.put(cs, current_value);
			idx++;
		}
		System.out.println(ans[s.length - 1]);
	}

}


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

int main(){
	int K,A,B;
	cin >> K >> A >> B;
	for(int i=A;i<=B;i++){
		if(i%K==0){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
     
    int main() {
    	int N;
    	vector<int> F;
    	
    	cin>>N;
    	for(int i=0;i<N+1;i++){
    		F.push_back(0);
    	}
     
    	for(int i=0;i<N;i++){
    		int x,y;
    		cin>>x>>y;
     		
     		int xn=max(0,x-1);
     		if(xn<=N){
    			F[xn]++;
     		}
    		if(y<=N){
    			F[y]--;
    		}
    	}
     
    	for(int i=0;i<N;i++){
    		F[i+1]+=F[i];
    	}
     
    	int ans;
    	for(int i=0;i<N+1;i++){
    		if(F[i]>=i){
    			ans=i;
    		}
    	}
     
    	cout<<ans<<endl;
     
    	return 0;
    }

Measured memory_bytes: 3552
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k-1] = s[k-1] - 'A' + 'a';
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
typedef pair<double, double> point;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	//file();
	fast();
	int a, b; cin >> a >> b;
	for (int i = 1; i <= 1e7; i++) {
		int f = i * 0.08 + EPS;
		int s = i * 0.1 + EPS;
		if (f == a && s == b)
			RT(i << endl);
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


def solve(N, Ss):
    c = collections.Counter(Ss)
    c.update(["AC", "WA", "TLE", "RE"])
    return "\n".join(["AC x " + str(c["AC"]-1),
                      "WA x " + str(c["WA"] - 1),
                      "TLE x " + str(c["TLE"] - 1),
                      "RE x " + str(c["RE"] - 1)])


if __name__ == "__main__":
    N = int(input())
    Ss = [input() for _ in range(N)]
    print(solve(N, Ss))


Measured memory_bytes: 16632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <functional>
#include <list>

#define MOD (1000000000 + 7)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 3000000;

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
} 

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

vector<bool> Eratosthenes(ll N) {
    vector<bool> primes(N, true);
    vector<ll> ret;
    primes[0] = false;
    primes[1] = false;
    for (ll i=2; pow(i,2)<=N; i++) {
        if (primes[i]) {
            for(int j=2; i*j<=N; j++) primes[i*j] = false;
            ret.push_back(primes[i]);
        }
    }
    return primes;//ret;
}

vector<ll> A;

bool can_divide(ll K, ll maxv) {
    ll sum = 0;
    for(ll i = 0; i < A.size(); i++) {
        sum += (A[i] + maxv-1) / maxv - 1;
    }

    // cout << maxv << ":" << (sum <= K) << endl;

    return sum <= K;
}

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

    ll maxv = 0;
    A.assign(N, 0);
    for(ll i = 0; i < N; i++) {
        cin >> A[i];
        maxv = max(A[i], maxv);
    }

    ll left = 1;
    ll right = maxv;

    ll ret = 0;

    while(true) {
        ll target = (left + right) / 2;
        // cout << left << "," << right << endl;
        if(left == right) {
            cout << left << endl;
            return 0;
        }
        if (can_divide(K, target) == true) {
            right = target;
        } else {
            left = target+1;
        }
    }

    
}




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

char group(int n) {
  if (n==2) return 'c';
  if (n==4 || n==6 || n==9 || n==11) return 'b';
  return 'a';
}

int main() {
  int x,y; cin >> x >> y;
  cout << (group(x) == group(y) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=0;i<3;i++){
    if(s.at(i) == s.at(i+1)) {cout<< "Bad" << endl; return 0;}
  }
  cout << "Good" << endl;
 
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
map<long long,int> mp;
int main()
{
	int n;
	cin>>n;
	long long ret = 0,sum = 0;
	mp[0] = 1;
	for(int i = 0;i < n; ++i)
	{
		long long a;
		cin>>a;
		sum += a;
		ret += mp[sum];
		mp[sum]++;
	}
	printf("%lld\n",ret);
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"
const int N=100005;
const int inf=1e18;
const double eps=1e-9;

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

int power(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
            res=res*a;
            res%=mod;
        }
        a=a*a;
        a%=mod;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	string s;
    cin>>s;
    int r=0;
    for(int x=0;x<s.size();x++){
        r+=s[x]-'0';
        r=r%9;
    }
    if(r==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }








	
return 0;
}


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

int main() {
    int N,M;
    map<string, int> mp;
    cin>>N;
    for(int i=0; i<N; i++) {
        string s;
        cin>>s;
        mp[s]++;
    }
    cin>>M;
    for(int i=0; i<M; i++) {
        string t;
        cin>>t;
        mp[t]--;
    }
    int max=0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
        if(max<itr->second) max=itr->second;
    }
    cout<<max<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;
	while ((scanf("%d%d", &a, &b) != -1) && (a + b != 0)){
		if (a <= b){
			printf("%d %d\n", a, b);
		}
		else{
			printf("%d %d\n", b, a);
		}
	}
	return 0;
}

Measured memory_bytes: 600
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

Aminus = [a - i - 1 for i, a in enumerate(A)]

from collections import defaultdict
Aplus = defaultdict(int)
for i, a in enumerate(A):
    Aplus[i + 1 + a] += 1


ans = 0
for i in range(len(A)):
    ans += Aplus[-(Aminus[i])]
    if -(A[i] + i + 1) == A[i] - i - 1:
        ans -= 1
print(ans)


    

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



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


    ll n,m; cin >> n >> m;
    string arr[1001];
    ll sol[1001][1001];
    bool row=1,col=1;
    for(ll i=0; i<n; i++) {
        cin >> arr[i];
        for (ll ii = 0; ii < m; ii++) {
            if(i == 0){
                if(col){
                    if (arr[i][ii] == '.') sol[i][ii] = 1;
                    else {
                        sol[i][ii] = 0;
                        col = 0;
                    }
                }else{
                    sol[i][ii] = 0;
                }
                continue;
            }

            if(ii == 0){
                if(row){
                    if (arr[i][ii] == '.') sol[i][ii] = 1;
                    else {
                        sol[i][ii] = 0;
                        row = 0;
                    }
                }else{
                    sol[i][ii] = 0;
                }
                continue;
            }

            if (arr[i][ii] == '.') sol[i][ii] = 1;
            else sol[i][ii] = 0;
        }
    }
    for(ll i=1; i<n; i++){
        for(ll y=1; y<m; y++) {
            if (arr[i][y] == '.') {
                if (sol[i - 1][y] == 0 || sol[i][y - 1] == 0) {
                    sol[i][y] = max(sol[i - 1][y], sol[i][y - 1]);
                } else {
                    sol[i][y] = (sol[i - 1][y] + sol[i][y - 1])%mod;
                }
            }
        }
    }

    cout << sol[n-1][m-1];




    return 0;
}

Measured memory_bytes: 9088
import sys

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

town = [0] * n
town[0] = 1
track = [1]
now = 1
cnt = 0
while True:
    now = a[now-1]
    town[now-1] += 1
    cnt += 1
    if town[now-1] > 1:
        loop = now
        break
    track.append(now)
    if cnt == k:
        print(now)
        sys.exit()

idx = track.index(loop)
ans = (k - idx) % (cnt - idx)
print(track[idx:][ans])

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

int main () {
  int N , M ; 
  cin >> N >> M ; 
  vector<int> s(M) , c(M) ; 
  bool ans = false ; 
  map<int , int> MAP ; 
  
  for(int i = 0 ; i < M ; i++ ){
    cin >> s.at(i) ;
    cin >> c.at(i) ; 
    MAP[s.at(i)] = c.at(i) ; 
    if(s.at(0) == 1 && c.at(0) == 0 && N != 1 ) {
      cout << "-1" << endl ;
      ans = true ; 
      if(ans) return 0 ;   
    }
  }


  for(int i = 0 ; i < M ; i++){
    for(int j = 0 ; j < M ; j++){
        if(s.at(i) == s.at(j) && c.at(i) != c.at(j)) {
          cout << "-1" << endl ;
          return 0 ; 
        }
    }
  }
  
  for(int i =1 ; i <= N ; i++){
    int A = MAP[i] ;
    if(i == 1 && A == 0 && N > 1){
      A = 1 ; 
    }    
    cout << A ;
  }
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
int main()
{
    char S[10];
    gets(S);
    int i,kamla = 0,len;
    len = strlen(S);
    for(i=0;i<len;i++)
    {
        if(S[5]=='0')
        {
            if(S[6]>='1' && S[6]<='4')
            {
                if(S[8]>='0' && S[8]<='2')
                {
                    if(S[9]>='0' && S[9]<='9')
                    {
                        kamla = 1;
                    }
                }
                else if(S[8]=='3')
                {
                    if(S[9]=='0')
                    {
                        kamla = 1;
                    }
                }
            }
        }
    }
    if(kamla==1)
    {
        printf("Heisei\n");
    }
    else
    {
        printf("TBD\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void C();

int main()
{
	C();
	fflush(stdout);
	return 0;
}

static void C()
{
	int N;
	get(N);

	std::vector<LLONG> ai(N);
	for (int i = 0; i < N; i++) {
		get(ai[i]);
	}

	LLONG max = 0;
	LLONG sum = 0;
	for (int i = 1; i < N; i++) {
		if (ai[i - 1] > ai[i]) {
			sum += ai[i - 1] - ai[i];
			ai[i] = ai[i - 1];
		}
	}
	printf("%lld\n", sum);
}


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

int top, S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main() {
    int a, b;
    top = 0;
    char s[100];
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }
        else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        }
        else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }
        else{
            push(atoi(s));
        }
    }
    cout << pop() << endl;
    return 0;
}



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

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


void solve(){
     
    return ;
}

int main(){
    int l, r, d;
    cin>>l>>r>>d;
    int count =0;
    for(int i = l;i<=r;i+=1){
        if(i%d==0)count++;
    }
    cout<<count<<endl;
}

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

int main(){
  string s,t;
  int sum=0;
  
  cin >> s >> t;
  
  if(s[0]==t[0]){
    sum += 1;
  }
  
  if(s[1]==t[1]){
    sum += 1;
  }
  
  if(s[2]==t[2]){
    sum += 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
#print(N)

ans = 0
if N > 9:
  ans = 9
  if N > 1000:
    ans = ans + 999 - 99
    if N >= 100000:
      ans = ans + 99999 - 9999
    elif N >= 10000:
      ans = ans + N - 9999
  elif N >= 100:
    ans = ans + N - 99
else:
  ans = N
print(ans)




Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

//#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

signed main()
{
	int N;
	cin >> N;
	while (true)
	{
		if (N == 0) break;
		if (N % 10 == 9)
		{
			cout << "Yes" << endl;
			return 0;
		}
		N /= 10;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main(void){
  int n=0;
  scanf("%d",&n);
  while(n!=0){
    int stm[100000][2]={0};
    int stp=0;
    /*int clm[100000]={0};
      int clp=0;*/
    int i=0;
    scanf("%d",&(stm[0][1]));
    stm[0][0]=1;
    int yomi=0;
    for(i=1;i<n;i++){
      scanf("%d",&yomi);
      if(yomi==stm[stp][1]){
	stm[stp][0]++;
      }
      else{
	if(i%2==0){
	  //printf("%da%d%d\n",i,stp,yomi);
	  stp++;
	  stm[stp][1]=yomi;
	  stm[stp][0]=1;
	}
	else{
	  if(stp!=0){
	    //printf("%db\n",i);
	    stp--;
	    stm[stp][0]+=stm[stp+1][0]+1;
	    stm[stp+1][0]=0;
	    stm[stp+1][1]=yomi;
	  }
	  else{
	    //printf("%dc\n",i);
	    stm[stp][0]++;
	    stm[stp][1]=yomi;
	  }
	}
      }
    }
    int ans=0;
    for(i=0;i<=stp;i++){
      if(stm[i][1]==0){
	ans+=stm[i][0];
      }
      //printf("%d%d\n",stm[i][0],stm[i][1]);
    }
    printf("%d\n",ans);
    scanf("%d",&n);
  }
  return 0;
}



    

Measured memory_bytes: 1812
fun main(args: Array<String>) = yorukatsu22b()

fun yorukatsu22b() {
    val (a, b, c) = readLine()!!.split(' ').map { it.toInt() }

    val remains = mutableSetOf<Int>()
    var i = 1

    while (remains.add(a * i++ % b)) Unit

    val answer = if (c in remains) "YES" else "NO"

    println(answer)
}


Measured memory_bytes: 38080
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  long long n,a[200005]={},ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  if(a[0]!=0) {
    cout << -1 << endl;
    return 0;
  }
  for(int i=0; i<n-1; i++) {
    if(a[i+1]>a[i]) {
      if(a[i+1]!=a[i]+1) {
        cout << -1 << endl;
        return 0;
      }
    }
    else if(a[i+1]==a[i]) {
      ans+=a[i+1];
    }
    else {
      ans+=a[i];
    }
  }
  ans+=a[n-1];
  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.LinkedList;
import java.util.Scanner;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		//complete the following
		for(int i = 0; i < totalVertex;i++) {
			for(int j =0; j<totalVertex;j++) {
			LinkedList<Integer> list = adjList.get(i);
			if(list.contains(j)&&!(j==totalVertex-1)) {
				System.out.print(1+" ");
			}
			else if(list.contains(j)&&(j==totalVertex-1)) {
				System.out.println(1);
			}
			else if(!(list.contains(j))&&(j==totalVertex-1)) {
				System.out.println(0);
			}
			else {
				System.out.print(0+" ");
			}
			}
		
		}
	}
}


public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 32952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a,b,c;
int main(void){
	cin>>a>>b>>c;
	if(a+b==c||b+c==a||c+a==b){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int x, y, z, k;
	cin >> x >> y >> z >> k;
	V<ll> a(x), b(y), c(z);
	rep(i, x)cin >> a[i];
	rep(i, y)cin >> b[i];
	rep(i, z)cin >> c[i];
	sort(all(a));
	sort(all(b));
	sort(all(c));

	ll l = 2, r = 30000000001;
	while (r - l > 1) {
		
		ll m = (l + r) / 2;
		ll cnt = 0;
		rep(i, x)rep(j, y) {
			ll res = m - a[i] - b[j];
			cnt += c.end() - lower_bound(all(c), res);
		}
		if (cnt >= k)l = m;
		else r = m;
	}

	V<ll> ans;
	rep(i, x)rep(j, y) {
		ll res = l - a[i] - b[j];
		int cnt = c.end() - upper_bound(all(c), res);
		rep(s, cnt)ans.push_back(a[i] + b[j] + c[z - 1 - s]);
	}

	sort(all(ans), greater<ll>());
	for (auto x : ans)cout << x << endl;
	rep(j, k - ans.size())cout << l << endl;

}

Measured memory_bytes: 3656
#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;
  cin>>n;
  int ans=0;
  vector<string>s(n);
  int a=0,b=0,sub=0;
  rep(i,n)cin>>s[i];
  rep(i,n){
    int m=s[i].size();
    rep(j,m-1){
      if(s[i][j]=='A'&&s[i][j+1]=='B')++ans;
    }
    if(s[i][0]=='B')++b;
    if(s[i].back()=='A')++a;
    if(s[i][0]=='B'&&s[i].back()=='A')++sub;
  }
  ans+=min(a,b);
  if(a==b&&a==sub&&sub!=0)ans=max(0,ans-1);
  cout<<ans;
}

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


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int _=305,yl=998244353;
int g[_],cnt,n,m;
bitset<_>a[_],f[_];
ll POW(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1)res=res*x%yl;
		x=x*x%yl;y>>=1;
	}
	return res;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			int x;cin>>x;
			if(x)a[i].set(j);
		}
		for(int j=1;j<=m;++j){
			if(a[i][j]){
				if(g[j])a[i]^=f[j];
				else {f[j]=a[i];g[j]=1;++cnt;break;}
			}
		}
	}
	cout<<(POW(2,m)-POW(2,m-cnt)+yl)*POW(2,n-1)%yl<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int,input().split())) + [0]
dis = 0
for i in range(1, N+2):
  dis += abs(A[i]-A[i-1])
for i in range(1, N+1):
  print(dis - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1]-A[i-1]))


Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> V(N);
    vector<P> V1(100001), V2(100001);

    rep(i, 100001) {
        V1[i] = P(0, i);
        V2[i] = P(0, i);
    }

    rep(i, N) {
        cin >> V[i];
        if (i % 2) {
            P p = V1[V[i]];
            p.first++;
            V1[V[i]] = p;
        }
        else {
            P p = V2[V[i]];
            p.first++;
            V2[V[i]] = p;
        }
    }

    sort(all(V1));
    sort(all(V2));
    reverse(all(V1));
    reverse(all(V2));

    int ans = 1e9;
    if (V1[0].second == V2[0].second) {
        ans = N - max((V1[0].first + V2[1].first), (V1[1].first + V2[0].first));

    }
    else {
        ans = N - (V1[0].first + V2[0].first);
    }

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

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int P[N];
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    int v = P[0];
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (P[i] <= v) {
            ans++;
        }
        v = min(v, P[i]);
    }
    cout << ans << "\n";
    return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

#ifdef DEBUG
#define debug(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


int main() {
    int N,A,B; cin >> N >> A >> B;
    printf("%d %d\n", min(A,B), max(0, A+B-N));
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <climits>
using namespace std;
 
const int SIZE = 1 << 17; // 2^17 = 131072
template<typename T>
struct segtree {
    // ?????????????????????
    T node[2*SIZE], I;
 
    // ????????¬????????§??? (update, query ??? 2 ???????????????)
    T (*upd_f)(T, T), (*qry_f)(T, T);
 
    // ???????????¨?????????????????????????????¨?????? node ??????????????§?????????
    segtree(T (*op1)(T, T), T (*op2)(T, T), T X) {
        upd_f = op1;
        qry_f = op2;
        I = X;
        fill(node, node+2*SIZE, I);
    }
 
    // ??´??? idx ?????? val ????????? (upd_f ?????¨?????? update)
    void update(int idx, T val) {
        idx += SIZE - 1;
        node[idx] = upd_f(node[idx], val);
        while(idx > 0) {
            // ????????¨?????? qry_f ??????????????¨?????¨????????????
            idx = (idx - 1) / 2;
            node[idx] = qry_f(node[2*idx+1], node[2*idx+2]);
        }
    }
 
    // ???????????? [a, b) ?????????????????¨???????????????
    // (qry_f ?????¨????????????)
    T query(int a, int b, int l=0, int r=SIZE, int k=0) {
        if(b <= l || r <= a) return I;
        if(a <= l && r <= b) return node[k];
        int mid = (l + r) / 2;
        T vl = query(a, b, l, mid, 2*k+1);
        T vr = query(a, b, mid, r, 2*k+2);
        return qry_f(vl, vr);
    }
};
 
int upd(int a, int b) {return b;}
int fnd(int a, int b) {return min(a, b);}
int main() {
    segtree<int> seg(upd, fnd, INT_MAX);
    int N, Q; scanf("%d%d", &N, &Q);
    for(int i=0; i<Q; i++) {
        int c, x, y; scanf("%d%d%d", &c, &x, &y);
        if(c == 0) seg.update(x, y);
        else printf("%d\n", seg.query(x, y+1));
    }
    return 0;
}


Measured memory_bytes: 3760