akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>

using namespace std;

const double DTR = (2 * acos(-1)) / 360;

double myfmod(double x, double y) {
        return x - (int) (x / y) * y;
}
 
enum ans {
        ABC, ACD, ADB, BCD,
};

int solve() {
        string xy;
        cin >> xy;
        int d, l;
        scanf("%d%d", &d, &l);
        double base = 
                xy == "BC" ? -60 :
                xy == "CD" ? 0 :
                xy == "DB" ? 60:
                0;
        double theta = (base + d) * DTR;
        double y = l * sin(theta);
        double x = l * cos(theta);
        double z60 = x + sqrt(3) / 3.0 * y;
        double z120 = -x + sqrt(3) / 3.0 * y;
        z60 = myfmod(myfmod(z60, 2.0) + 2.0 + 1e-8, 2.0);
        z120 = myfmod(myfmod(z120, 2.0) + 2.0 + 1e-8, 2.0);
        y = (z60 + z120) * sqrt(3) / 2.0;
        if (z60 < 1.0) {
                if (z120 < 1.0) {
                        if (y < sqrt(3) / 2.0) {
                                return ADB;
                        } else {
                                return BCD;
                        }
                } else {
                        if (y < sqrt(3)) {
                                return ABC;
                        } else {
                                return ACD;
                        }
                } 
        } else {
                if (z120 < 1.0) {
                        if (y < sqrt(3)) {
                                return ACD;
                        } else {
                                return ABC;
                        }
                } else {
                        if (y < 3.0 * sqrt(3) / 2.0) {
                                return BCD;
                        } else {
                                return ADB;
                        }
                }
        }
}

int main() {
        int a = solve(), b = solve();
        puts(a == b ? "YES" : "NO");
        return 0;
}

Measured memory_bytes: 3472
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

int main(void){
  
  ll k;
  cin>>k;

  vector<ll> v;

  int start = 0;
  int end = 8;

  int count = 0;

  for(int i=0;i<9;i++){
    v.push_back(i+1);
   // cout<<v[i]<<" ";
    count++;
  }

  while(1){

    for(int i=start;i<=end;i++){
      //cout<<v[i]<<endl;
      if(v[i]%10==0){
        v.push_back(v[i]*10+v[i]%10);
        v.push_back(v[i]*10+v[i]%10+1);
      }else if(v[i]%10!=9){
        v.push_back(v[i]*10+v[i]%10 -1);
        v.push_back(v[i]*10+v[i]%10);
        v.push_back(v[i]*10+v[i]%10 +1);
      }else{
        v.push_back(v[i]*10+v[i]%10-1);
        v.push_back(v[i]*10+v[i]%10);
      }
    }
    start = end+1;
    end = v.size();
    if(start >100000) break;
  }

  //for(int i=0;i<100;i++) cout<<v[i]<<" ";
  cout<<v[k-1]<<endl;
  
  
  return 0;
}

Measured memory_bytes: 10604
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();

    for (int i = 1; i <= 9; i++) {
      if (n % i == 0) {
        int j = n / i;
        if (0 < j && j <= 9) {
          os.println("Yes");
          return;
        }
      }
    }
    os.println("No");
  }
}

Measured memory_bytes: 23124
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    if (A[i] <= B[i]):
        ans += A[i]
        B[i] -= A[i]
        if (A[i + 1] > B[i]):
            A[i + 1] -= B[i]
            ans += B[i]
        else:
            ans += A[i + 1]
            A[i + 1] = 0
    else:
        ans += B[i]
print(ans)

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

void	print_top_or_bottom(int n)
{
	for (int i = 0; i < n; i++)
		cout << '#';
	cout << endl;
}

void	print_middle(int n)
{
	cout << '#';
	for (int i = 0; i < n - 2; i++)
		cout << '.';
	cout << '#' << endl;
}

int main() {
	int H, W;
	cin >> H >> W;
	while (!(H == 0 && W == 0))
	{
		print_top_or_bottom(W);
		for (int i = 0; i < H - 2; i++)
			print_middle(W);
		print_top_or_bottom(W);
		cin >> H >> W;
		cout << endl;
	}
}




Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)
		cin >> a[i] >> b[i] >> c[i];

	int dp[3][n];
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			dp[j][i] = 0;
	dp[0][0] = a[0];
	dp[1][0] = b[0];
	dp[2][0] = c[0];
	for(int i=0;i<n-1;i++) {
		dp[0][i+1] = max(dp[0][i+1], dp[1][i] + a[i+1]);
		dp[0][i+1] = max(dp[0][i+1], dp[2][i] + a[i+1]);
		dp[1][i+1] = max(dp[1][i+1], dp[2][i] + b[i+1]);
		dp[1][i+1] = max(dp[1][i+1], dp[0][i] + b[i+1]);
		dp[2][i+1] = max(dp[2][i+1], dp[0][i] + c[i+1]);
		dp[2][i+1] = max(dp[2][i+1], dp[1][i] + c[i+1]);	
	}
	int ans = 0;
	ans = max(ans, dp[0][n-1]);
	ans = max(ans, dp[1][n-1]);
	ans = max(ans, dp[2][n-1]);
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 2560
n, x = map(int, input().split())

while n != 0 or x != 0:
	count = 0
	for i in range(1, n+1):
		for j in range(i+1, n+1):
			for k in range(j+1, n+1):
				if i+j+k == x:
					count += 1
	print(count)
	n, x = map(int, input().split())

Measured memory_bytes: 7656
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int w = Integer.parseInt(br.readLine());

		for(int i=0;i<line.length();i++){
			if(i%w==0){
				System.out.print(line.charAt(i));
			}
		}
		System.out.println();
	}
}


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

int main(){
  int n;
  int i,j=0,k;
  cin >> n;
  long long a[n],ret=0,m=1000000010;
  for(i=0;i<n;i++){
    cin >> a[i];
    ret+=abs(a[i]);
    if(a[i]<0)j++;
    m=min(m,abs(a[i]));
  }
  if(j%2==1){
    ret-=2*m;
    //cout << ret << " " << m << endl;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#define MAX 100000
#define SENTINEL 2000000000
using namespace std;

struct Card 
{
    char suit;
    int value;
};

struct Card L[MAX / 2+2],R[MAX / 2+2];

void merge(Card A[], int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++){
        L[i] = A[left+i];
    }
    for (int i = 0; i < n2; i++){
        R[i] = A[mid+i];
    }
    L[n1].value = SENTINEL;
    R[n2].value = SENTINEL;

    int i = 0;
    int j = 0;
    for (int k = left; k < right; k++){
        if (L[i].value <= R[j].value){
            A[k] = L[i];
            i += 1;
        } else {
            A[k] = R[j];
            j += 1;
        }
        
    }
    
    
    
}

void mergeSort(Card A[], int n, int left, int right)
{
    if (left + 1 < right){
        int mid = (right + left) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
        
    }
    
}

    

int partition(Card A[], int p, int r)
{
    struct Card t, x = A[r];
    int i = p - 1;
    for (int j = p; j < r; j++){
        if (A[j].value <= x.value){
            i += 1;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i+1];
    A[i+1] = A[r];
    A[r] = t;

    return i+1;
    
    
}

void quickSort(Card A[], int p, int r)
{
    if(p < r){
        int q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
        
    }
    
}

int main()
{
    int n, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;
    
    
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> S >> v;
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }
    mergeSort(B, n, 0, n);
    quickSort(A, 0, n-1);
    for (int i = 0; i < n; i++){
        if (A[i].suit != B[i].suit) {
            stable = 0;
        }
        
    }
    
    if (stable) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    
    for (int i = 0; i < n; i++){

        cout << A[i].suit << " " << A[i].value << endl;

    }
    
    return 0;
}

Measured memory_bytes: 3512
#include <fstream>
#include <iostream>
#include <vector>
#include <numeric>
#include<algorithm>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    int n,m,k,c;
    cin >> n >> m >> k;
    vector<long int> a(n+1);
    vector<long int> b(m+1);
    a[0] = b[0] =0;
    rep(i,n){
        cin >> a[i+1];
        a[i+1] +=a[i];
    }
    rep(i,m){
        cin >> b[i+1];
        b[i+1] += b[i];
    }
    int ans=0,j=0;
    rep(i,n+1){
        if(k-a[i]<0) break;
        while(b[j]<=k-a[i]){
            j++;
            if(j==m+1) break;
        }
        j--;
        // cout<< j << " i " << i << endl;
        ans = max(ans,i+j);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 6364
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 **/

int main(){
    int mod=1000000007;
    int n;
    long ans=1;
    scanf("%d",&n);
    for(int i=n;i>1;i--) {
        ans*=i;
    }
    printf("%ld\n",ans);
    return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> b(n - 1);
  int ans = 0;
  rep(i, n - 1)  cin >> b[i];
  ans += b[0];
  for(int i = 0; i < n - 2; ++i) {
    ans += min(b[i], b[i + 1]);
  }
  ans += b[n - 2];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll ans=0;
    ll arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    for(int i=1;i<n;i++)
    {
        if(arr[i]<arr[i-1])
        {
            ans=ans+arr[i-1]-arr[i];
            arr[i]=arr[i-1];
        }
    }
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 5168
#include<iostream>
#include<string>
#include<array>
#include <vector>
#include<deque>

int main() {
	std::string str;
	std::cin >> str;
	for (int i = 0; i < 3; i++) {
		if (str[i] == '1') {
			str[i] = '9';
		}
		else if (str[i] == '9') {
			str[i] = '1';
		}
	}
	std::cout << str << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template<class A> ostream& operator <<(ostream& out, const vector<A> &v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        if(i) out << ", ";
        out << v[i];
    }
    return out << "]";
}

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

    int n;
    cin >> n;
    vector<int> vec(n + 1);
    vector<int> cnt(n + 1, 0);
    for (int i = 2; i <= n; i++) {
        cin >> vec[i];
        cnt[vec[i]]++;
    }
    for (int i = 1; i <= n; i++) cout << cnt[i] << '\n';

    return 0;
}


Measured memory_bytes: 4780
import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy
  
def main():
    S = input()
    cnt=0
    ans=0
    for i,s in enumerate(S):
        if s=='R':
            cnt+=1
        if i==len(S)-1 or s=="S":
            ans=max(ans,cnt)
            cnt=0
    print(ans)
 
if __name__ == '__main__':
    main()

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

int main(){

  int A[3],K;
  cin >> A[0] >> A[1] >> A[2];
  cin >> K;
  sort(A,A+3);

  cout << A[0] + A[1] + A[2]*pow(2,K);

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int bit = 0;
        for (int i=0; i<N; i++) {
            bit |= sc.nextInt();
        }
        System.out.println(Integer.numberOfTrailingZeros(bit));
        sc.close();
    }
}

Measured memory_bytes: 36064
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << (x-z)/(y+z) << endl;

    return 0;
}


Measured memory_bytes: 256
S = input()
start = 0
is_found_a = False
ans = 0
for i in range(len(S)):
    if not is_found_a and S[i] == 'A':
        start = i
        is_found_a = True
    elif S[i] == 'Z':
        ans = i - start + 1
print(ans)

Measured memory_bytes: 3516
import math
n = int(input())
lst = [x for x in range(1, n + 1) if x % 2 != 0]
def div(x):
    lst_2 = []
    for i in range(1, int(math.sqrt(x)) + 1):
        if x % i == 0 and x // i != i:
            lst_2.append(i)
            lst_2.append(x // i)
        if x % i == 0 and x // i == i:
            lst_2.append(i)
    return lst_2

cnt = 0
for i in lst:
    div_lst = div(i)
    if len(div_lst) == 8:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
n,m = map(int,input().split())
data = dict()
for i in range(m):
    data[i+1] = 0
for i in range(n):
    temp = list(map(int,input().split()))
    for k in range(1,temp[0]+1):
        data[temp[k]] += 1
counter = 0
for i in data:
    if data[i] == n:
        counter += 1
print(counter)

Measured memory_bytes: 3064
import statistics
N = int(input())
A = list(map(int, input().split()))
tmp1 = [0] * N
tmp2 = [0] * N
tmp1[0] = A[0]
tmp2[-1] = A[-1]
for i in range(1, N):
    tmp1[i] = abs(tmp1[i - 1] + A[i])
    tmp2[-i - 1] = abs(tmp2[-i] + A[-i - 1])
ans = 10 ** 10
for i in range(N - 1):
    ans = min(ans, abs(tmp1[i] - tmp2[i + 1]))
print(ans)

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

int main(){
    int x,y,t;
    while(1){
        cin>>x>>y;
        if(x==0 && y==0)break;
        if(x>y){
            t=x;
            x=y;
            y=t;
        }
        cout<<x<<" "<<y<<endl;
    }
    return 0;
}


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



int main (){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin>>A.at(i);
    }
    sort(A.begin(), A.end());
  	//for(int i=0; i<N; i++){
    //  	cout<<A.at(i)<<' ';
    //}
  	//cout<<endl;
        
    long long Sum=0;
    for(int i=N-1; i>=2; i--){
        for(int j=i-1; j>=1; j--){
            int Long=A.at(i);
            int Middle=A.at(j);
            int Must=Long-Middle;
            auto X=upper_bound(A.begin(), A.end(), Must);
            int C=X-A.begin();
          	//cout<<i<<' '<<j<<' '<<C<<endl;
          	if(j-C>0){
          		Sum += j-C;
            }
          	
        }
    }
    cout<<Sum;
}

Measured memory_bytes: 256
s=list(input())
k=[]
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        print("NO")
        exit()
    if s[i]=="K" and s[i+1]!="I":
        print("NO")
        exit()
    if s[i]=="I" and s[i+1]!="H":
        print("NO")
        exit()

for i in range(len(s)):
    if s[i]!="A":
        k.append(s[i])
if k==["K","I","H","B","R"]:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 38384
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ab = readln.split.to!(int[]);
    auto A = ab[0];
    auto B = ab[1];
    int r;
    foreach (_; 0..2) {
        if (A > B) {
            r += A;
            --A;
        } else {
            r += B;
            --B;
        }
    }
    writeln(r);
}

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

int main() {
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  int ans = 1;
  if(M1 == M2 || D1 < D2) ans = 0;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp;
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

ll powMod(ll a, ll n, ll mod){
    if(n == 0) return 1;
    if(n%2 == 0)
        return powMod(a, n/2, mod) * powMod(a, n/2, mod) % mod;
    else
        return a * powMod(a, n-1, mod)% mod;
}

ll ncrMod(ll n, ll r, ll mod){
    ll x=1, y=1;
    for(ll i = 1; i <= r; ++i){
        x *= n-i+1;
        x %= mod;
        y *= i;
        y %= mod;
    }
    return x * powMod(y, mod-2, mod) % mod;
}

int main() {
    ll N, A, B;

    cin >> N >> A >> B;

    ll rem = N % (A+B);
    ll k = N / (A+B);
    cout << A * k + ((rem <= A) ? rem : A);


    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
  Scanner scanner = new Scanner(System.in);
  int a = scanner.nextInt();
  int b = scanner.nextInt();
  int d = a / b ;
  int r = a % b ;
  double f = (double)a / (double)b ;
  System.out.println(d);
  System.out.println(r);
  System.out.println(String.format("%.8f\n", f));
    }
  }

Measured memory_bytes: 26536
from heapq import heappush, heappop

x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
# used = [[[False] * (z + 1) for _ in range(y + 1)] for _ in range(x + 1)]
used = set()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
kouho = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]


def calc(a, b, c):
    if not (a, b, c) in used:
        used.add((a, b, c))
        heappush(kouho, ((-A[a] - B[b] - C[c]), a, b, c))


used.add((0, 0, 0))
for i in range(k):
    temp, p, q, r = heappop(kouho)
    print(-temp)
    if p + 1 < x:
        calc(p + 1, q, r)
    if q + 1 < y:
        calc(p, q + 1, r)
    if r + 1 < z:
        calc(p, q, r + 1)


Measured memory_bytes: 4852
#include <bits/stdc++.h>
#include <atcoder/modint>
#include <atcoder/lazysegtree>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

using mint = atcoder::modint998244353;
mint inv9 = mint(9).inv();

struct S{
    mint x, k;
    S(mint x=0, mint k=1): x(x), k(k) {}
};
using F = int;
S op(S a, S b){
    return S(a.x*b.k + b.x, a.k*b.k);
}
S e(){ return S(); }
S mapping(F f, S a){
    if(f == 0) return a;
    return S((a.k-1)* inv9 * f, a.k);
}
F composition(F g, F f){
    if(g == 0) return f;
    return g;
}
F id(){ return 0; }
using lazy_segtree = atcoder::lazy_segtree<S, op, e, F, mapping, composition, id>;

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n,q; cin >> n >> q;

    vector<S> v(n, S(1, 10));
    auto seg = lazy_segtree(v);
    rep(_,q){
        int l,r,d;
        cin >> l >> r >> d;
        l--;
        seg.apply(l,r,d);
        mint ans = seg.all_prod().x;
        cout << ans.val() << endl;
    }
    return 0;
}

Measured memory_bytes: 9808
#include<bits/stdc++.h>
#define rep(i,s,t) for(int i = (int)(s); i <= (int)(t); i++)
#define rev(i,t,s) for(int i = (int)(t); i >= (int)(s); i--)
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef pair<int,int> pii;
deque<pii> que;
const int maxn = 1e5+5;
bool vis[maxn];
int main()
{
    #ifdef LOCAL_FILE
    freopen("in.txt","r",stdin);
    #endif // LOCAL_FILE
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int k;
    cin>>k;
    que.push_front(make_pair(1,1));
    while(!que.empty())
    {
        pii now = que.front();
        que.pop_front();
        if(vis[now.first]) continue;
        vis[now.first] = true;
        if(now.first == 0)
        {
            cout<<now.second<<endl;
            break;
        }
        que.push_front(make_pair(now.first*10%k,now.second));
        que.push_back(make_pair((now.first+1)%k,now.second+1));
    }
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define LL long long
#define int LL
#define P pair<int,int>
#define fi first
#define se second
const LL N=1e5+10;
const LL mod=1e9+7;
const LL inf=0x3f3f3f;
const double eps=1e-9;
using namespace std;
template<typename tp> inline void read(tp &x)
{
    x=0; char c=getchar(); bool f=0;
    for(;c<'0'||c>'9';f|=(c=='-'),c = getchar());
    for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c = getchar());
    if(f) x=-x;
}
namespace first_of_all
{
    int tp,T,n,m,tot;
    int F[110];
    vector<P> vec[110];
    void dfs(int dep,int x,int y,int stop)
    {
        if(x>F[dep+2]||y>F[dep+2]) return;
        vec[dep].push_back(P(x,y));
        if(dep==stop) return;
        dfs(dep+1,y,x+y,stop);
        dfs(dep+1,y,x+2*y,stop);
    }
    void init()
    {
        F[0]=F[1]=1;
        for(tot=1;F[tot]+F[tot-1]<=4e18;tot++)
            F[tot+1]=F[tot]+F[tot-1];
        while(F[tot]>1e18) tot--;
        dfs(0,1,1,tot);
    }
}
using namespace first_of_all;
void solve1(int ret=0)
{
    int stop=-1;
    for(int i=tot;i;i--)
        if(F[i]<=n&&F[i+1]<=m)
        {
            stop=i;
            break;
        }
    if(stop<=1)
    {
        printf("1 %lld\n",n==1?m%mod:4ll);
        return ;
    }
    for(auto v:vec[stop-1])
    {
        int x=v.fi,y=v.se;
        if(y<=n&&x+y<=m) ret+=(m-x)/y;
        if(y<=m&&x+y<=n) ret+=(n-x)/y;
    }
    printf("%lld %lld\n",stop,ret%mod);
}
void solve2(int ret=0)
{
    int stop=-1;
    for(int i=tot;i;i--)
        if(F[i]<=n&&F[i+1]<=m)
        {
            stop=i;
            break;
        }
    if(stop<=1)
    {
        printf("%lld\n",n==1?m%mod:4ll);
        return ;
    }
    for(int i=2;i<=stop;i++)
    {
        int l=F[i+1],r=F[i+2];
        for(auto v:vec[i-1])
        {
            int x=v.fi,y=v.se;
            if(y<=n&&x+y<=m)
            {
                if(y<l) ret+=(m-x)/y;
                else ret+=(r-x-1)/y;
            }
            if(y<=m&&x+y<=n)
            {
                if(y<l) ret+=(n-x)/y;
                else ret+=(r-x-1)/y;
            }
            ret%=mod;
        }
    }
    ret+=n+m;
    printf("%lld\n",ret%mod);
}
signed main()
{
    init();tp=1;
    read(T);
    while(T--)
    {
        read(n),read(m);
        if(n>m) swap(n,m);
        if(tp==1) solve1();
        else solve2();
    }
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, M, X; cin >> N >> M >> X;
    vector<int> a(M);
    for(int i=0; i<M; i++) cin >> a[i];

    int ans1 = 0;
    for(int i=0; i<M; i++) if(a[i] < X) ans1++;
    
    int ans2 = 0;
    for(int i=0; i<M; i++) if(a[i] > X) ans2++;

    cout << min(ans1, ans2) << endl;
}

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

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

  vector<int> res(N, 0);
  for (int x = 1; x < sqrt(N); x++) {
    for (int y = 1; y < sqrt(N); y++) {
      for (int z = 1; z < sqrt(N); z++) {
        int n = x*x + y*y + z*z + x*y + y*z + x*z;
        if (n <= N) {
          res.at(n-1)++;
        }
      }
    }
  }

  for (int i = 0; i < N; i++) {
    cout << res.at(i) << endl;
  }
}

Measured memory_bytes: 3636
using System;

namespace ABC127_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var min = int.MinValue;
            var max = int.MaxValue;
            for (var i = 0; i < nm[1]; i++)
            {
                var num = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                if(min<num[0])
                {
                    min = num[0];
                }
                if(max>num[1])
                {
                    max = num[1];
                }
            }
            if(max<min)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(max - min + 1);
            }
            
        }
    }
}


Measured memory_bytes: 15312
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);	
		int n = sc.nextInt();
		int k = sc.nextInt();
		int h;
		int ans = 0;
		
		
		for(int i = 0; i < n; i++) {
			h = sc.nextInt();
			if(h >= k) ans++;
		}
		
		System.out.println(ans);

	}
}


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

const int maxn = 1e5+100;

vector<int> G[maxn];

int n,k;
int A[maxn];
int res;

int d[maxn];

void dfs(int u)
{
    d[u] = 0;
    for(int i = 0;i < G[u].size();++i)
    {
        int v = G[u][i];
        dfs(v);
        if(u != 1 && d[v] == k-1)
        {
            res++;
        }
        else
        {
            d[u] = max(d[v]+1,d[u]);
        }
    }

}

int main()
{
   // freopen("./test.txt","r",stdin);
    scanf("%d %d",&n,&k);
    for(int i = 1;i <= n;++i)
        scanf("%d",&A[i]);
    res = 0;
    if(A[1] != 1)
        res++;

    for(int i = 2;i <= n;++i)
        G[A[i]].push_back(i);

    dfs(1);
    printf("%d\n",res);

    return 0;
}


Measured memory_bytes: 12800
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.LongStream;
import java.io.IOException;
import java.util.Deque;
import java.util.stream.Collectors;
import java.io.InputStreamReader;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int K = in.nextInt();

            Deque<Long> que = new ArrayDeque<>(LongStream.rangeClosed(1, 9).boxed().collect(Collectors.toSet()));
            while (--K > 0) {
                long q = que.removeFirst();
                long l = q % 10;
                if (l > 0) que.add(q * 10 + l - 1);
                que.add(q * 10 + l);
                if (l < 9) que.add(q * 10 + l + 1);
            }
            out.println(que.removeFirst());
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 34388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    int alen = a.size();
    int blen = b.size();
    cout << (a[alen-1]==b[0] && b[blen-1]==c[0] ? "YES":"NO");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<char,char> pcc;
ll v[100005],h[100005];
int main()
{
//	cout<<pow(501,5)-pow(500,5)<<endl;
//	return 0;
	ll x;
	cin>>x;
	for(int i=0;i<=500;i++)
	v[i]=pow(i,5);
	int f=0;
	for(ll i=0;i<=500;i++)
	{
		for(ll j=0;j<=500;j++)
		{
			ll y=v[i],z=v[j];
			if(y+z==x)
			{
				cout<<i<<' '<<-j<<endl;
				f=1;
				break;
			}
			else if(y-z==x)
			{
				cout<<i<<' '<<j<<endl;
				f=1;
				break;
			}
		}
		if(f==1)
		break;
	}
} 

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

typedef long long ll;
using namespace std;

ll N;
set<ll> s;

bool f(ll m) {
    if (N % (m + 1) != 0)return 0;
    ll p = N / (m + 1);
    if (!(p < m))return 0;
    return 1;
}

int main() {
    cin >> N;
    ll ans = 0;
    for (ll i = 1, l = sqrt(N); i <= l; i++) {
        if (N % i == 0) {
            if (f(i - 1)) s.insert(i - 1);
            if (f(N / i - 1))s.insert(N / i - 1);
        }
    }
    for (auto i = s.begin(); i != s.end(); i++) {
        ans += *i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long L = scan.nextLong();
        long R = scan.nextLong();
        
        long result = 2018;

        for (long i = L; i < R; i++){
            for (long j = i + 1; j <= R; j++){
                long mod = (i * j) % 2019;
                if(result > mod) result = mod;
                if(result == 0) break;
            }
            if(result == 0) break;
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 23764
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        a: i32,
        b: i32,
        c: i32,
        k: i32,
    }

    let mut ans = 0;
    if k<=a {
        ans = k;
    } else if a<k && k<=a+b {
        ans = a;
    } else if a+b<k && k<=a+b+c {
        ans = a - (k-(a+b));
    } else if a+b+c<k {
        ans = a - c;
    }

    println!("{}", ans);

}

Measured memory_bytes: 2168
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include <iomanip>

using namespace std;


int main(){
  int n;
  cin >> n;
  vector<int> x(n), y(n), p(n);
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i];
    p[i]=i;
  }
  
  double dis, sum=0;
  do{
    for(int i=0;i<n-1;i++){
      dis = pow(x[p[i]]-x[p[i+1]],2)+pow(y[p[i]]-y[p[i+1]],2);
      dis = pow(dis,0.5);
      sum+=dis;
    }
  }while(next_permutation(p.begin(), p.end()));
  
  int num=1;
  for(int i=n;i>=2;i--)
    num*=i;
  
  std::cout << std::fixed;
  cout << setprecision(10) << sum/num;
  
  return 0;
}

Measured memory_bytes: 256
//=======================//
// coder: Andy - Tohrumi //
//=======================//

#include <bits/stdc++.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)
#define int long long

typedef vector<int> vi;		typedef vector<ll> vl;
typedef pair<int, int> ii; 	typedef vector<ii> vii;

// code start here //

vector<vii> graph;

const int N = 100005;

int ans[N];
bool flag = 1;
vi check;

void dfs(int u) {
	if(check[u] == -1) check[u] = 1;
	rep(i, 0, (int)graph[u].size()) {
		ii t = graph[u][i];
		if(check[t.first] == -1) {
			ans[t.first] = ans[u] - t.second;
			dfs(t.first);
		}
		else {
			if(ans[u] - t.second != ans[t.first]) flag = 0;
		}
	}
}

signed main() {
	fastio;
	int n, m; cin >> n >> m;
	graph.assign(n, vii());
	check.assign(n, -1);
	int l, r, d;
	rep(i, 0, n) ans[i] = LLONG_MAX;
	rep(i, 0, m) {
		cin >> l >> r >> d;
		l--; r--;
		graph[r].pb(mp(l, d));
		graph[l].pb(mp(r, -d));
	}
	rep(i, 0, n) {
		if(check[i] == -1) {
			ans[i] = 0;
			dfs(i);
		}
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 19980
#include <stdio.h>
int main(void){
  int i,j,n,data[1000][1000],sum_h[1000],sum_w[1000],sum;
  
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	scanf("%d ",&data[i][j]);
      }
    }
    for(i=0;i<n;i++){
      sum_w[i]=0;
      for(j=0;j<n;j++){
	sum_w[i]+=data[i][j];
      }
    }
    for(i=0;i<n;i++){
      sum_h[i]=0;
      for(j=0;j<n;j++){
	sum_h[i]+=data[j][i];
      }
    }
    sum=0;
    for(i=0;i<n;i++){
      sum+=sum_w[i];
    }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	printf("%5d",data[i][j]);
      }
      printf("%5d\n",sum_w[i]);
    }
    for(i=0;i<n;i++){
      printf("%5d",sum_h[i]);
    }
    printf("%5d\n",sum);
  }
  return(0);
}
  

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n) {
    if (s[i] == 'R') a[i] = 0;
    if (s[i] == 'G') a[i] = 1;
    if (s[i] == 'B') a[i] = 2;
  }
  vector<ll> cnt(3);
  rep(i,n) cnt[a[i]]++;
  ll ans = 1;
  rep(i,3) ans *= cnt[i];
  rep(j,n)rep(i,j) {
    int k = j + (j-i);
    if (k < n) {
      if (a[i] == a[j]) continue;
      if (a[i] == a[k]) continue;
      if (a[k] == a[j]) continue;
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		sc.close();
		int ans = a + b;
		ans = Math.max(2 * a - 1, ans);
		ans = Math.max(2 * b - 1, ans);
		System.out.println(ans);
	}

}


Measured memory_bytes: 22484
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int X, A, B, C;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;
    int count = 0;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if (500 * i + 100 * j + 50 * k == X){
                    count++;
                }
            }
        }
    }
    if (count){
        cout << count;
    }else{
        cout << 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int n; cin >> n;
    vector<ll> a(n); 
    rep(i,n) cin >> a.at(i);

    vector<ll> b(n, 0);
    if(n==1) {
        cout << a.at(0) << endl;
        return 0;
    }

    if(n%2==0){
        for(int i=0; i<n; i++){
            int tmp = n/2;
            int tmp2 = (i+1)/2;
            if(i%2==0){
                b.at(tmp+tmp2) = a.at(i);
            }
            else{
                b.at(tmp-tmp2) = a.at(i);
            }
        }
    }
    else{
        for(int i=0; i<n; i++){
            int tmp = n/2;
            int tmp2 = (i+1)/2;
            if(i%2){
                b.at(tmp+tmp2) = a.at(i);
            }
            else{
                b.at(tmp-tmp2) = a.at(i);
            }
        }
    }

    rep(i, b.size()) cout << b.at(i) << " ";
    cout << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    string A,B;
    cin >> A >> B;
    int sum = stoi(A+B);
    int ans = sqrt(sum);
    if (ans*ans == sum) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using namespace std;

const int N = 1e5 + 10;
const long long inf = 1e18;

int A, B;
int n;
int h[N];

long long add(long long x, long long y) {
  if (x > inf || y > inf) return inf;
  return x + y;
}

long long mul(long long x, int A) {
  long double ret = (long double) x * A;
  if (ret > inf) return inf;
  return x * A;
}

long long need_a(int health, long long x) {
  if ((health + A - 1) / A > x) return inf;
  long long l = -1, r = x;
  while (l + 1 < r) {
    long long mid = (l + r) >> 1;
    if (add(mul(mid, A), mul(x - mid, B)) < health) {
      l = mid;
    } else {
      r = mid;
    }
  }
  return r;
}

bool check(long long x) {
  long long cnt_a = 0;
  for (int i = 0; i < n; ++i) {
    cnt_a = add(cnt_a, need_a(h[i], x));
  }
  return cnt_a <= x;
}

int main() {
  scanf("%d", &n);
  scanf("%d%d", &A, &B);
  for (int i = 0; i < n; ++i) {
    scanf("%d", h + i);
  }
  sort(h, h + n);
  reverse(h, h + n);
  long long l = 0, r = inf;
  while (l + 1 < r) {
    long long mid = (l + r) >> 1;
    if (check(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  printf("%lld\n", r);
  return 0;
}


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

int main(){
  string A,B,C;
  cin>>A>>B>>C;
  
  if(A.at(A.size()-1)==B.at(0)&&B.at(B.size()-1)==C.at(0)){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <map>
#include <algorithm>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 100000;
int v[1 + nmax];

std::map<int,int> mp;

void normalize(int n) {
  std::vector<int> aux;
  for(int i = 1;i <= n; i++)
    aux.push_back(v[i]);
  std::sort(aux.begin(), aux.end());
  for(int i = 0; i < n; i++)
    mp[aux[i]] = 1 + i;
  for(int i = 1; i <= n; i++)
    v[i] = mp[v[i]];
}

int main() {
  int n;
  std::cin >> n;
  int result = 0;
  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  normalize(n);
  for(int i = 1;i <= n; i += 2)
    if(v[i] % 2 == 0)
      result++;
  std::cout << result;
  return 0;
}


Measured memory_bytes: 8712
fun main(args: Array<String>) = println(run {
    val n = readLine()!!.toInt()
    val w = (1..n).map { readLine()!! }

    val words = mutableSetOf<String>()
    words.add(w.first())
    w.reduce {a, b ->
        if(b in words || a.last() != b.first()) return@run "No"
        words.add(b)
        b
    }
    "Yes"

})


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

using namespace std;
int main(){
  string s;
   cin >>s;
  
  long r=0,l=0;
  vector<long> c(s.length(),0);
  long index;
  for(int i=0;i<s.length()-1;i++){
    
    if(s[i]=='R'&&s[i+1]=='R') {r++;
                               }
   else if(s[i]=='R'&&s[i+1]=='L') {r++;
                                   index=i;
                                  }
    else if(s[i]=='L'&&s[i+1]=='L'){ l++;
                                  }
    else if(s[i]=='L'&&s[i+1]=='R'){l++;
     if(r%2==1) {c[index]=(r+l-1)/2+1;
                c[index+1]=(r+l)/2;
               }
     else {c[index]=(r+l)/2;
                c[index+1]=(r+l-1)/2+1;
    
     }
     r=0;
     l=0;
    }
  }
    l++;
    if(r%2==1) {c[index]=(r+l-1)/2+1;
                c[index+1]=(r+l)/2;      
               }
    else { c[index]=(r+l)/2;
                c[index+1]=(r+l-1)/2+1;
    
    
    }
                
    for(int i=0;i<s.length()-1;i++) cout << c[i] << " "; 
    
    cout << c[s.length()-1] << endl;
    
  }

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

int n, k;
int a[200055];
int b[200055];

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

    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    while (k--) {
        for (int i = 0; i < n; i++) b[i] = 0;

        for (int i = 0; i < n; i++) {
            b[min(n, i + a[i] + 1)]--;
            b[max(0, i - a[i])]++;
        }

        for (int i = 1; i < n; i++) {
            b[i] += b[i - 1];
        }

        swap(a, b);

        bool cool = true;

        for (int i = 0; i < n; i++) {
            if (a[i] != n) {
                cool = false;
                break;
            }
        }

        if (cool) break;
    }

    for (int i = 0; i < n; i++) {
        if (i) printf(" ");
        printf("%d", a[i]);
    }

    puts("");

    return 0;
}


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

int main(){
	int l;
	cin >> l;
	
	double len = l/3.0;
	double ans = len * len * len;
	printf("%.12lf\n",ans);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define DIFF ('A'-'a')

int main(void){
    int n=0;
    char str[1200];
    fgets(str,1200,stdin);
    while(str[n] != NULL){
        if (str[n] > 'Z' && str[n] <= 'z') printf("%c",str[n]+DIFF);
        else if (str[n] >= 'A' && str[n] <= 'Z') printf("%c",str[n]-DIFF);
        else printf("%c",str[n]);
        n++;
    }
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  string ans = "Yes";
  for (int i = 0; i < S.size(); i++) {
    if (i == 0) {
      if (S.at(i) == 'L') {
        ans = "No";
      }
    }
    else if (i % 2 == 0 && S.at(i) == 'L') {
      ans = "No";
    }
    else if (i % 2 != 0 && S.at(i) == 'R') {
      ans = "No";
    }
  }
  cout << ans << endl;
}


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

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

	int min = 1000000001, max = 0, a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a < min)
			min = a;
		if (a > max)
			max = a;
	}
	cout << max - min;

}

Measured memory_bytes: 256
N = int(input())
S = input()

cnt = 0
for i in range(N):
    for j in range(1,N):
        l = i - j
        r = i + j
        if (l < 0) or (N-1 < r): break
        if (S[l] != S[i]) and (S[i] != S[r]) and (S[l] != S[r]): cnt += 1

from collections import Counter
c = Counter(S)
if len(c) < 3:
    print(0)
else:
    ans = 1
    for v in c.values(): ans *= v
    print(ans-cnt)

Measured memory_bytes: 9464
#include<iostream>
#include<string>
using namespace std;
int main(){
  string in;
  while(cin>>in!='\0'){
    char han;
    //cout<<in[0]<<endl;
    if(
       (in[0]==in[1]&&in[1]==in[2])||
       (in[0]==in[4]&&in[4]==in[8])||
       (in[0]==in[3]&&in[3]==in[6])
       ){
      if(in[0]!='s')
	han=in[0];}
    
    else if((in[2]==in[4]&&in[4]==in[6])||(in[2]==in[5]&&in[5]==in[8]))
      {if(in[2]!='s')han=in[2];}
    else if(in[1]==in[4]&&in[4]==in[7]){if(in[1]!='s')han=in[1];}
    else if(in[3]==in[4]&&in[4]==in[5]){if(in[3]!='s')han=in[3];}
    else if(in[6]==in[7]&&in[7]==in[8]){if(in[6]!='s')han=in[6];}
    else han='d';
    cout <<han<<endl;
  }

}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
int n, k, g, maxi, a;
int main() {
	cin >> n >> k >> g;
	maxi = g;
	n--;
	while (n--) {
		cin >> a;
		g = gcd(g, a);
		maxi = max(maxi, a);
	}
	cout << ((k % g == 0 && k <= maxi) ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
	return 0;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        sc.close();

        if(c <= a+b+1){
            System.out.println(c+b);
        }else{
            System.out.println(a+b*2+1);
        }
    }
}

Measured memory_bytes: 22228