akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main()
{
    int a, b;
    int x, y, z;
    scanf("%d %d", &a, &b);
    x = a+b;
    y = a-b;
    z = a*b;
    if(x>y){
        if(x>z)
            printf("%d", x);
        else
            printf("%d", z);
    }
    else{
        if(y>z)
            printf("%d", y);
        else
            printf("%d", z);
    }

}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int x;
	int N;
	string S;
	int maxValue;

	x = 0;

	cin >> N;
	cin	>> S;

	maxValue = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'I') {
			x += 1;
		}
		else {
			x -= 1;
		}
		
		if (maxValue > x) {
			maxValue = maxValue;
		}
		else {
			maxValue = x;
		}
	}

	cout << maxValue << endl;

}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    ll a,b;
    cin >> a >> b;
    cout << a*b;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int main()
{
while(true) {
int n;
scanf("%d", &n);
if(n == 0)
break;
priority_queue<int> q[2];
int s[2] = {0};
int prev = -1;
for(int i = 0; i < n; ++i) {
int c, d;
scanf("%d", &c);
d = (c + 1) % 2;
if(i % 2 == 0) {
if(prev != c)
q[c].push(i);
} else {
if(prev != c) {
int l = q[d].top();
q[d].pop();
int re = i - l;
s[c] += re;
s[d] -= re;
if(l == 0)
q[c].push(0);
}
}
s[c] += 1;
prev = c;
}
printf("%d\n", s[0]);
}
return 0;
}

Measured memory_bytes: 1052
n = gets.chomp.to_f
m = n**(1/2.0)
l = []
(1..m).each do |i| 
  a,b = n.divmod(i)
  if b == 0
    l << [a.to_s.length,i.to_s.length].max()
  end
end

puts l.min()

Measured memory_bytes: 1788
using System;

namespace _079c
{
    class Program
    {
        static void Main(string[] args)
        {
            string ABCD = Console.ReadLine();
            int A = int.Parse(ABCD[0].ToString());
            int B = int.Parse(ABCD[1].ToString());
            int C = int.Parse(ABCD[2].ToString());
            int D = int.Parse(ABCD[3].ToString());
            if(A+B+C+D==7)Console.WriteLine("{0}+{1}+{2}+{3}=7",A,B,C,D);
            else if(A+B+C-D==7)Console.WriteLine("{0}+{1}+{2}-{3}=7",A,B,C,D);
            else if(A+B-C+D==7)Console.WriteLine("{0}+{1}-{2}+{3}=7",A,B,C,D);
            else if(A+B-C-D==7)Console.WriteLine("{0}+{1}-{2}-{3}=7",A,B,C,D);
            else if(A-B+C+D==7)Console.WriteLine("{0}-{1}+{2}+{3}=7",A,B,C,D);
            else if(A-B+C-D==7)Console.WriteLine("{0}-{1}+{2}-{3}=7",A,B,C,D);
            else if(A-B-C+D==7)Console.WriteLine("{0}-{1}-{2}+{3}=7",A,B,C,D);
            else if(A-B-C-D==7)Console.WriteLine("{0}-{1}-{2}-{3}=7",A,B,C,D);
        }
    }
}


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

  int N = Norg;
  const int nd = static_cast<int>(std::log10(N)) + 1;
  
  int sumd(0);
  for(int i = 0; i < nd; i++)
  {
   	int d = N % 10;
    sumd += d;
    N = (N - d) / 10;
  }

  if( 0 == Norg % sumd )
  {
    cout << "Yes" << endl;
  }
  else 
  {
   	cout << "No" << endl; 
  }
}
 

Measured memory_bytes: 512
print(list([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51])[int(input())-1])

Measured memory_bytes: 38384
N = int(input())

if N == 0:
    print(0)
    exit()
elif N == 1:
    print(1)
    exit()
DP = [(0,1)]
num = 0
start = 0
end = 1
while True:
    num += 1
    a = end - start + 1
    if num % 2 == 0:
        start_ = end + 1
        end_ = start_ + a - 1
        end = end_
    else:
        end_ = start - 1
        start_ = end_ - a + 1
        start = start_
    DP.append((start_, end_))
    if start <= N <= end:
        break

Ans = ''
DP[0] = (1, 1)
for i, (start, end) in enumerate(DP[::-1]):
    if start <= N <= end:
        Ans += '1'
        N -= (-2) ** (num-i)
    else:
        Ans += '0'

print(Ans)


Measured memory_bytes: 38384
n = int(input())
A = list(map(int, input().split()))

left = 0
right = sum(A)
ans = right

for i in range(n):
    left = left + A[i]
    right = right - A[i]

    if abs(left - right) < ans:
        ans = abs(left - right)
    else:
        break

print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	static long MIN = Long.MIN_VALUE;

	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		int N = io.nextInt();
		int M = io.nextInt();
		int[][] edge = new int[M][3];
		for(int i=0;i<M;i++){
			edge[i][0]=io.nextInt()-1;
			edge[i][1]=io.nextInt()-1;
			edge[i][2]=io.nextInt();
		}
		
		long[] cost = new long[N];
		cost[0] = 0;
		for(int i=1;i<N;i++){
			cost[i] = MIN;
		}
		
		boolean update = true;
		int count = 0;
		while(update && count<N-1){
			update = false;
			for(int i=0;i<M;i++){
				if(cost[edge[i][0]]!=MIN && 
						cost[edge[i][1]]<cost[edge[i][0]]+edge[i][2]){
					update = true;
					cost[edge[i][1]] = cost[edge[i][0]]+edge[i][2];
				}
			}
			count ++;
		}
		
		long ans = cost[N-1];
		
		while(update && count<N){
			update = false;
			for(int i=0;i<M;i++){
				if(cost[edge[i][0]]!=MIN && 
						cost[edge[i][1]]<cost[edge[i][0]]+edge[i][2]){
					update = true;
					cost[edge[i][1]] = cost[edge[i][0]]+edge[i][2];
				}
			}
			count ++;
		}
		
		
		if(ans != cost[N-1]){
			System.out.println("inf");
			return;
		}else{
			System.out.println(cost[N-1]);
		}
		
	}
}

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

#define N 110

int col[N], row[N];
char ma[N][N];

int main() {
    int m, n;
    scanf("%d%d", &m, &n);
    for (int i = 0; i < m; ++i) scanf("%s", ma[i]);
    for (int i = 0; i < m; ++i) {
        int ok = 1;
        for (int j = 0; j < n; ++j) if (ma[i][j] != '.') { ok = 0; break; }
        if (ok) row[i] = 1;
    }
    for (int j = 0; j < n; ++j) {
        int ok = 1;
        for (int i = 0; i < m; ++i) {
            if (row[i]) continue;
            if (ma[i][j] != '.') { ok = 0; break; }
        }
        if (ok) col[j] = 1;
    }
    for (int i = 0; i < m; ++i) {
        if (row[i]) continue;
        for (int j = 0; j < n; ++j) {
            if (col[j]) continue;
            putchar(ma[i][j]);
        }
        puts("");
    }
    return 0;
}


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

int main(){
	long long n;
	while (cin >> n, n){
		int ans = 0;
		for (int i = n - 1; i > 1; i--){
			n *= i;
			while (n != 0 && n % 10 == 0){
				n /= 10;
				ans++;
			}
			n %= 30000;
			//printf("%d ", n);
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1144
#include <stdio.h>

int main(){
  int h[100100], flag[100100];
  int n,m;
  scanf("%d%d",&n,&m);
  int i;
  
  for(i=0; i<n; ++i){
    scanf("%d",&h[i]);
    flag[i]=1;
  }
  
  for(i=0; i<m; ++i){
    int a,b;
    scanf("%d%d",&a,&b);
    --a;--b;
    if(h[a]>=h[b]) flag[b]=0;
    if(h[a]<=h[b]) flag[a]=0;
  }
  
  int ans=0;
  for(i=0; i<n; ++i){
    if(flag[i]) ans++;
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 2516
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #a,b,c=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    vv=list(map(int, readline().rstrip().split()))
    vv.sort()
    for i in range(1,n):
        vv[i]=(vv[i-1]+vv[i])/2
    print(vv[n-1])
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 5628
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	const int INF = 1e9+1;
	int n,m;
	std::cin >> n >> m;
	std::vector<int> d(n);
	rep(i,n) std::cin >> d[i];
	std::vector<std::pair<int,int> > edges;
	// min need to have to have a vertex<=cur
	std::vector<std::vector<std::pair<int,int> > > g(n,std::vector<std::pair<int,int> >());
	rep(i,m) {
		int u,v;
		std::cin >> u >> v;
		u--;v--;
		edges.emplace_back(u,v);
		g[u].emplace_back(v,i);
		g[v].emplace_back(u,i);
	}
	std::set<int> use;
	rep(i,n) {
		int min = INF;
		int mini = -1;
		for(auto to:g[i]) {
			if(min > d[to.first]) {
				min = d[to.first];
				mini = to.second;
			}
		}
		if(min>d[i]) {
			print(-1);
			return 0;
		}
		use.emplace(mini);
	}
	std::vector<int> ans(m,1e9);
	for(auto x:use) {
		ans[x] = std::max(d[edges[x].first],d[edges[x].second]);
	}
	std::vector<int> col(n,-1);
	std::function<void(int)> dfs = [&] (int i) {
		for(auto to:g[i]) {
			if(col[to.first]!=-1) continue;
			if(use.count(to.second)==1) col[to.first]=col[i]^1;
			else continue;
			dfs(to.first);
		}
	};
	rep(i,n) {
		if(col[i]==-1) {
			col[i]=0;
			dfs(i);
		}
	}
	rep(i,n) {
		if(col[i]==-1) col[i]=0;
	}
	for(auto i:col) {
		if(i) std::cout << 'W';
		else std::cout << 'B';
	}
	std::cout << ENDL;
	for(int i:ans) {
		print(i);
	}

	return 0;
}


Measured memory_bytes: 25324
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define all(c) (c).begin(), (c).end()
const int INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;

class modint {
 public:
  ll n;
  int mod = MOD;

  modint(const ll x = 0) noexcept : n(x) {}
  modint& operator+=(const modint a) {
    n += a.n;
    n %= mod;
    return *this;
  }
  modint operator+(const modint a) { return modint(*this) += a; }
  modint& operator-=(const modint a) {
    n += (mod - a.n);
    n %= mod;
    return *this;
  }
  modint operator-(const modint a) { return modint(*this) -= a; }
  modint& operator*=(const modint a) {
    n *= a.n;
    n %= mod;
    return *this;
  }
  modint operator*(const modint a) { return modint(*this) *= a; }
  modint pow(ll exp) {
    if (exp == 0) return 1;
    modint a = pow(exp >> 1);
    a *= a;
    if (exp & 1) a *= *this;
    return a;
  }
  modint inverse() { return pow(mod - 2); }
  modint operator/(const modint a) { return modint(*this) /= a; }
  modint& operator/=(modint a) { return (*this) *= a.inverse(); }
};
ostream& operator<<(ostream& o, const modint& m) {
  o << m.n;
  return o;
}

modint fact(int n) {
  static vector<modint> f = {1, 1};
  while (n >= (int)f.size()) f.push_back(f[f.size() - 1] * modint(f.size()));
  return f[n];
}

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

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

  modint ans = 0;
  modint mul = 0;
  for (int i = 0; i < n - 1; ++i) {
    modint d = x[i + 1] - x[i];
    mul += modint(1) / (i + 1);
    ans += d * mul;
  }
  ans *= fact(n - 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2804
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

int main()

{
    string s;
    cin >> s;
    int count;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '2')
        {
            count += 1;
        }
    }
    cout << count;
}


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

using namespace std;

typedef long long  ll;

int cnt;

void Merge(vector<int> &a, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> l(n1 + 1), r(n2 + 1);

    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] = INT_MAX;
    r[n2] = INT_MAX;

    int i = 0, j = 0;
    for (int k = left; k < right; ++k) {
        if (l[i] <= r[j])
            a[k] = l[i++];
        else
            a[k] = r[j++];
        ++cnt;
    }
}

void MergeSort(vector<int> &a, int left, int right)
{
    if (left + 1 < right) {
        int mid = (left + right) * 0.5;
        MergeSort(a, left, mid);
        MergeSort(a, mid, right);
        Merge(a, left, mid, right);
    }
}

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

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    MergeSort(a, 0, n);

    for (int i = 0; i < n; ++i)
        cout << a[i] << (i == n - 1 ? '\n' : ' ');
    cout << cnt << "\n";

    return 0;
}

Measured memory_bytes: 5064
#include<cstdio>
#include<algorithm>
#include<iostream>
typedef long long LL;
using namespace std;
LL a,b,x,ans;
int main()
{
	cin>>x;ans=x+1;
	for(LL i=2;i*i<=x;i++)
	{
		if(x%i==0)
		ans=min(i+x/i,ans);
	}
	cout<<ans-2;
}


Measured memory_bytes: 3196
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    int four = 0, two = 0, one = 0;
    for (int i = 0;i < n;i++){
        int a;
        cin >> a;
        if (a % 4 == 0) four++;
        else if (a % 2 == 0) two++;
        else one++;
    }

    if (two == 0){
        if (four >= one - 1){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        if (four == one) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 3636
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N, M = map(int, input().split())
A = [0] * N
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    A[a] += 1
    A[b] += 1

for a in A:
    if a % 2 == 1:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 9868
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}

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

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

int main(){
  int K,N;
  cin>>N>>K;
  double p[N];
  vector<double>t(N+1,0);
  for(int i=0;i<N;i++){
    cin>>p[i];
    t[i+1]=t[i]+p[i]*(0.5)+0.5;
    //cout<<i<<" "<<t[i]<<endl;
  }
  double maxp=0;
  for(int i=0;i<N-K+1;i++){
    maxp=max(maxp,t[i+K]-t[i]);
  }
  cout<<setprecision(18)<<maxp<<endl;
  return 0;
}

  

Measured memory_bytes: 6484
import java.io.*;
import java.util.StringTokenizer;



public class Main {
	
	
    public static void main(String[] args) {
       
    	try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String s1 , s2;
           
            int arrayA[] = new int[4];
            int arrayB[] = new int[4];
            
            while((s1 = br.readLine()) != null && (s2 = br.readLine()) != null)
            {
            	StringTokenizer st1 = new StringTokenizer(s1," ");
            	for(int i = 0; i<4; i++)
            	{
            		arrayA[i] = Integer.parseInt(st1.nextToken());
            	}
       
            	StringTokenizer st2 = new StringTokenizer(s2," ");
            	for(int i = 0; i<4; i++)
            	{
            		arrayB[i] = Integer.parseInt(st2.nextToken());
            	}
            	System.out.println(calHit(arrayA,arrayB)+" "+calFlow(arrayA,arrayB));
            }
    	}catch (Exception e) {
            e.printStackTrace();
        }
       
    }
    
    private static int calHit(int arrayA[],int arrayB[]) {
    	
    	 int hit = 0;
    	 
    	for(int i = 0; i<4; i++)
    	{
    		if(arrayA[i] == arrayB[i])
    		{
    			hit++;
    		}			
    	}
    	return hit;
    	
    }
    
    private static int calFlow(int arrayA[],int arrayB[]) {
    	
   	 int flow = 0;
   	 
   	for(int i = 0; i<4; i++)
   	{
   		for(int a = 0; a<4; a++)
   		{
   			if(i != a)
   			{
   				if(arrayA[i]==arrayB[a])
   				{
   					flow++;
   				}
   			}
   		}
   	
   }
   	return flow;
    }
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000000;
int PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll,ll,ll>>>;


struct UnionFind{
    vector<int> par;
    vector<int> rank;

    UnionFind(int N):par(N),rank(N){
        for(int i = 0;i < N;i++){
          par[i] = i;
          rank[i] = 0;
        }
    }

    int root(int x){
       while(x != par[x]){
        x =  par[x] = par[par[x]];
       }
       return x;
    }

    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)return;
        if(rank[x] > rank[y]){
          par[y] = rx;
        }
        if(rank[x] < rank[y]){
          par[rx] = ry;
        }else{
          par[ry] = rx;
          if(rank[x] == rank[y]){
            rank[rx]++;
          }
        }
    }

    bool same(int x,int y){
      return root(x) == root(y);
    }
};


int main(){
   ll N;cin >> N;
   vector<ll> A(N);
   UnionFind F(N);
   for(int i = 0;i < N;i++){
       cin >> A[i];
   }
   for(int i = 0;i < N-1;i++){
       if(A[i] + 1 == A[i+1]){
           F.unite(i,i+1);
       }
   }
   ll ans = 1;
   ll cnt = 0;
   ll R = 0,B = 0,G = 0;
   for(int i = 0;i < N;i++){
       if(R == B && B == G && A[i] == R){
           R++;
           ans *= 3;
           ans %= MOD;
       }else if(R == B && A[i] == R){
           R++;
           ans *= 2;
           ans %= MOD;
       }else if(B == G && A[i] == B){
           B++;
           ans *= 2;
           ans %= MOD;
       }else if(R == G && R == A[i]){
           R++;
           ans *= 2;
           ans %= MOD;
       }else if(R == A[i]){
           R++;
       }else if(B == A[i]){
           B++;
       }else if(G == A[i]){
           G++;
       }else{
           cout << 0 << endl;
           return 0;
       }
   }
   cout << ans << endl;
}



Measured memory_bytes: 1792
import java.util.Scanner;

class Main{
        int tiket[]={0,6000,4000,3000,2000};
		int t,n,uriage;
    
    public void solve(){
        Scanner sc=new Scanner(System.in);
		
        for(int i=1;i<=4;i++){
		t=sc.nextInt();
		n=sc.nextInt();
	    uriage=tiket[t]*n;
		System.out.println(uriage);
        }
    }
	public static void main(String[]args){
		Main obj=new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>
#include <cassert>
#include <iso646.h>
#include <exception>
#include <stdexcept>
#include <iterator>
#include <sstream>

using namespace std;

typedef long long i64;

int cnt[200200];

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

    int n, k;
    cin >> n >> k;
    
    int diff_classes = 0;
    for (int i = 0; i < n; i++)
    {
        int b;
        cin >> b;

        cnt[b]++;
        if (cnt[b] == 1)
            diff_classes++;
    }

    vector<int> cnts;
    for (int b = 1; b <= n; b++)
        if (cnt[b])
            cnts.push_back(cnt[b]);

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

    int ans = 0;
    for (int i = 0; i < (diff_classes - k); i++)
        ans += cnts[i];

    cout << ans;
}

Measured memory_bytes: 2168
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int m1,m2;
  m1 = max(a,c);
  m2 = min(b,d);
  int ans = m2 - m1;
  if(ans < 0) ans = 0;
  cout << ans << endl;
}


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

vector<long long> divisor(long long n){//nの約数列挙
    vector<long long> res;
    for(long long i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

typedef pair<long long, long long> P;
int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    map<long long, long long> m;
    sort(A.begin(), A.end());
    vector<int> ju(N, 0);
    for(int i = 1; i < N; i++){
        if(A[i] == A[i - 1]){
            ju[i] = -1;
            ju[i - 1] = -1;
        }
    }
    for(int i = 0; i < N; i++){
        if(m.count(A[i])) continue;
        long long t = A[i];
        long long res = 2;
        while(t*res <= A[N - 1]){
            m[t*res]++;
            res++;
        }
    }
    long long ans = 0;
    for(int i = 0; i < N; i++){
        if(m[A[i]] == 0 && ju[i] == 0) ans++;
    }
    cout << ans << endl;
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;

vector <int> presort1[51],presort2[51];
int le[51][101],ri[51][101]; // [pernah di-ambil][langkah]

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

    int n,k;
    cin >> n >> k;
    int ar[n+1],minus=0,tot=0;
    for (int i=1;i<=n;i++){
        cin >> ar[i];
        if (ar[i]<0){
            minus++;
        } else tot+=ar[i];
    }

    if (n+minus<=k){
        cout << tot << el;
        return 0;
    }
    
    for (int i=1;i<=n;i++){
        for (int j=1;j<=i;j++) presort1[i].pb(ar[j]);

        sort(presort1[i].begin(),presort1[i].end(),greater<int>());
    }

    for (int i=n;i>=1;i--){
        for (int j=i;j<=n;j++) presort2[n-i+1].pb(ar[j]);

        sort(presort2[n-i+1].begin(),presort2[n-i+1].end(),greater<int>());
    }

    for (int i=0;i<=n;i++){
        int total=0;
        for (auto x : presort1[i]) total+=x;
        
        int id=i;
        le[i][id]=total;
        for (int j=i-1;j>=0;j--){
            id++;
            total-=presort1[i][j];
            le[i][id]=total;
        }
    }    

    for (int i=0;i<=n;i++){
        int total=0;
        for (auto x : presort2[i]) total+=x;

        int id=i;
        ri[i][id]=total;
        for (int j=i-1;j>=0;j--){
            id++;
            total-=presort2[i][j];
            ri[i][id]=total;
        }
    }

    for (int i=1;i<=n;i++){
        for (int j=1;j<=k;j++){
            le[i][j]=max(le[i][j],max(le[i-1][j],le[i][j-1]));
            ri[i][j]=max(ri[i][j],max(ri[i-1][j],ri[i][j-1]));
        }
    }

    int ans=0;
    for (int i=0;i<=n;i++){
        for (int j=0;j<=k;j++){
            ans=max(ans,le[i][j]+ri[n-1][k-j]);
        }
    }

    cout << ans << el;

    return 0;
} 

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
M = max(X, Y)
V = int(1e18)
for i in range(M+1):
  v = 2 * C * i
  if i <= X:
    v += (X - i) * A
  if i <= Y:
    v += (Y - i) * B
  if v < V:
    V = v
print(V)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int ans=0;
	string a,b;
	cin>>a>>b;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]!=b[i])ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3860
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, A, B;
    cin >> N >> A >> B;

    ll space = B - A - 1;
    if(space % 2 == 0){
        p("Borys");
    }else{
        p("Alice");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
int main(void){
	int N;
 	std::cin >> N;
	std::vector<int> a(N);
	for(int i = 0; i < N; i++) std::cin >> a[i];
	std::sort(a.begin(), a.end()); // 数列aを昇順ソート
	std::cout << a[N-1] - a[0] << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll INF  = 1e18;
static const ll MAX_H = 2000;
static const ll MAX_W = 2000;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

ll H, W;
//bool M[MAX_H][MAX_W];
void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin >> H >> W;
    vector<string> S(H);
    REP(i,H){
        cin >> S[i];
    }

    short dpL[MAX_H][MAX_W] = {0}, dpR[MAX_H][MAX_W]={0}, dpT[MAX_H][MAX_W]={0}, dpU[MAX_H][MAX_W]={0};


    REP(i,H){
        REP(j,W){
            if(S[i][j] == '.'){
                if( j != 0)dpL[i][j] = dpL[i][j-1] + 1;
                else dpL[i][j] = 1;
            }
          //cout << dpL[i][j];
        }
      //cout << endl;
    }
    REP(i,H){
        REPR(j,W){
            if(S[i][j] == '.'){
                //cout << dpR[i][j] << endl;
                if(j != W - 1)dpR[i][j] = dpR[i][j+1] + 1;
                else dpR[i][j] = 1;
                //cout << dpR[i][j] << endl;
            }
            //cout << dpR[i][j];
        }
        //cout << endl;
    }


    REP(i,H){
        REP(j,W){
            if(S[i][j] == '.'){
                if(i != 0)dpT[i][j] = dpT[i-1][j] + 1;
                else dpT[i][j] = 1;
            }
            //cout << dpT[i][j];
        }
        //cout << endl;
    }

    REPR(i,H){
        REP(j,W){
            if(S[i][j] == '.'){
                if(i != H-1) dpU[i][j] = dpU[i+1][j] + 1;
             	else dpU[i][j] = 1;
            }
            //cout << dpU[i][j];
        }
        //cout << endl;
    }
    

    ll MAX = 0;
    REP(i,H){
        REP(j,W){
            if(MAX < (dpL[i][j] + dpR[i][j]  +dpT[i][j] + dpU[i][j] - 3)){
                //cout << i << j << MAX << endl;
                MAX = dpL[i][j] + dpR[i][j] + dpT[i][j] + dpU[i][j] - 3;
            }
        }
    }

    p(MAX);

}

Measured memory_bytes: 35584
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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


	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> M >> L >> R;
		if (M < abs(L) + abs(R)) {
			cout << "No\n";
			return 0;
		}
		M %= 2;
		L += R;
		L %= 2;
		if (M != L) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int comp(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int main(void) {
    int n, m, i, j;
    int d[200000], t[200000];
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", d + i);
    }
    scanf("%d", &m);
    for (i = 0; i < m; i++) {
        scanf("%d", t + i);
    }
    qsort(d, n, sizeof(int), comp);
    qsort(t, m, sizeof(int), comp);
    i = 0;
    j = 0;
    for ( ; i < n && j < m; ){
        if (d[i] < t[j]) {
            i++;
            continue;
        }
        if (d[i] > t[j]) {
            puts("NO");
            return 0;
        } else {
            i++;
            j++;
        }
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 2556
#include<iostream>
#include<cmath>
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS )
class Point{
public:
  double x, y;
  Point ( double x = 0, double y = 0): x(x), y(y){}
  Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
  Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
  Point operator * ( double a ){ return Point(x*a, y*a); }
  Point operator / ( double a ){ return Point(x/a, y/a); }
  double abs() { return sqrt(norm());}
  double norm() { return x*x + y*y; }
  bool operator < ( const Point &p ) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == ( const Point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};
class Segment{
public:
  Point p1, p2;
  Segment ( Point p1 = Point(0.0,0.0), Point p2 = Point(0.0,0.0)): p1(p1), p2(p2){}
  double abs() { return sqrt(norm());}
  double norm() { return (p2.x - p1.x)*(p2.x - p1.x) + (p2.y - p1.y)*(p2.y - p1.y); }
};
typedef Point Vector;
typedef Segment Line;
double norm( Vector a ){ return a.x*a.x + a.y*a.y; }
double abs( Vector a ){ return sqrt(norm(a)); }
double dot( Vector a, Vector b ){ return a.x*b.x + a.y*b.y; }
double cross( Vector a, Vector b ){ return a.x*b.y - a.y*b.x; }
double getDistanceLP(Line s,Point p){
  return abs(cross(s.p2-s.p1,p-s.p1)/abs(s.p2-s.p1));
}
double getDistanceSP(Segment s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
  return getDistanceLP(s,p);
}

Point project(Segment s,Point p){
  Vector base = s.p2-s.p1;
  double t = dot(p-s.p1,base)/norm(base);
  return s.p1+base*t;
}

Point p1,p2;
double r1,r2;
Segment s;

Point rotate( Point a, double si,double co){
  return Point(a.x*co-a.y*si,a.x*si+a.y*co);
}

Point getCrossPointCC(Point p1,double r1,Point p2,double r2){
  double a=r2,b=r1,c=abs(p1-p2);
  double cos_A = (b*b+c*c-a*a) / (2.0*b*c);
  double sin_A = sqrt(1.0-cos_A*cos_A);
  Vector v=p2-p1;
  v = v * r1 / c;
  return p1+rotate(v,sin_A,cos_A);
}

int main(){
  cin>>p1.x>>p1.y>>r1;
  cin>>p2.x>>p2.y>>r2;

  Point A=getCrossPointCC(p1,r1,p2,r2);
  Point B=getCrossPointCC(p2,r2,p1,r1);
  Point a=min(A,B),b=max(A,B);
  printf("%.9f %.9f %.9f %.9f\n",a.x,a.y,b.x,b.y);
  return 0;
}

Measured memory_bytes: 1240
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int h[] = new int[n];
		for(int i = 0; i < n; ++i)
		h[i] = sc.nextInt();
		sc.close();
		int ans = 0;
		for(int i = 0; i < n; ++i){
			if(h[i] >= k)++ans;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 52044
/*In the name of ALLAH, Most Gracious, Most Merciful*/
#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define setbits                 __builtin_popcount
#define zerobits                __builtin_ctzll
#define parity(n)               __builtin_parity(n)
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)               __gcd(a,b)
#define lcm(a, b)               ((a)*(b))/gcd(a,b)
#define watch(x)                cout << (#x) << " is " << (x) << endl
#define TEST_CASES()            ll t;cin>>t;while (t--)
#define PRECISION(a,x)          fixed<<setprecision(x)<<a<<endl;
#define endl                    "\n"
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define FAST_IO()               ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FILE_IO()               freopen("output.txt", "w", stdout);freopen("input.txt", "r", stdin)
using namespace std;

ll MAX_PRIME_DIV(ll n)
{
    ll maxi=INT_MIN;
    for (ll i=2;i*i<=n;i++)
    {
        if (n%i==0)maxi=max(maxi,i);
    }
    if (maxi==INT_MIN)return INT_MIN;
    return maxi;
}
void solve()
{
   string s;
   cin>>s;
   vector<string>v={"0","SUN", "MON", "TUE", "WED", "THU", "FRI","SAT"};
   for (int i=1;i<v.size();i++)
   {
       if (s==v[i])
       {
           cout<<(7-i+1)<<endl;
       }
   }
}

int32_t main()
{
    FAST_IO();
    //TEST_CASES()
        solve();
}




Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

int main()
{

  int n;
  cin >> n;
  int flag = 0;
  for (int i = 1; i <= 9; i++)
  {
    for (int j = 1; j <= 9; j++)
    {
      if (i * j == n)
      {
        cout << "Yes" << endl;
        flag = 1;
        break;
      }
    }
    if (flag == 1)
    {
      break;
    }
  }

  if (flag == 0)
  {
    cout << "No" << endl;
  }

  return 0;
}


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

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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> dp(n+1,0);
    rep(i, n+1) {
        if(i == 0) {
            continue;
        }
        int min = dp[i-1] + 1;
        int x = 6;
        while(i >= x) {
            if (min > dp[i-x] + 1)
                min = dp[i-x] + 1;
            x *= 6;
        }
        x = 9;
        while(i >= x) {
            if (min > dp[i-x] + 1)
                min = dp[i-x] + 1;
            x *= 9;
        }
        dp[i] = min;
    }
    cout << dp[n] << endl;
}



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

using namespace std;

int main() {
  int N;
  vector<long> list;
  
  cin >> N;
  
  for (int i = 1; i <= N; i++) {
    long in;
    
    cin >> in;
    
    list.push_back(in - (i + 1));
  }
  
  sort(list.begin(), list.end());
  
  int median_of_list = N % 2 == 0 ? (list.at(N / 2) + list.at(N / 2 - 1)) / 2 : list.at(N / 2); 
  long minimum_sum = 0;
  
  for (int i = 0; i < N; i++) {
    minimum_sum += abs(list.at(i) - median_of_list);
  }
  
  cout << minimum_sum << endl;
  
  return 0;
}

Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		System.out.println(swap(br.readLine()));

	}

	static String swap(String text){
		String NewText= text.replaceAll("apple", "MOMOTARO");
		NewText = NewText.replaceAll("peach", "apple");
		NewText = NewText.replaceAll("MOMOTARO", "peach");

		return NewText;
	}
}

Measured memory_bytes: 16900
Scanf.scanf "%d" (fun n ->
    let module M = Map.Make (struct type t = int let compare (a:int) (b:int) = compare a b end) in
    let rec loop i map acc =
        if i > n then acc else
            let a = Scanf.scanf " %d" (fun a -> a) in
            let acc = acc + try M.find (i - a) map with _ -> 0 in
            let key = i + a in
            let map = M.add key (1 + try M.find key map with _ -> 0) map in
            loop (i + 1) map acc
    in
    loop 1 M.empty 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 21920
#include <bits/stdc++.h>
#define MAX 102
using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  bool inlist[MAX] = {false};
  int X, N, num;
  cin >> X >> N;
  for (int i = 0; i < N; i++){
    cin >> num;
    inlist[num] = true;
  }
  for (int i = 0; i < MAX; i++){
    if (X - i >= 0 && !inlist[X - i]){
      cout << X - i << '\n';
      break;
    }
    if (X + i < MAX && !inlist[X + i]){
      cout << X + i << '\n';
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
bool isDigit(char c){return '0' <= c && c <= '9';}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    string s;
    cin >> s;
    rep(i,s.size())
    {
        if(i%2==0)
        {
            cout << s[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int K, N; cin >> K >> N;
	vector<ll>A(N);
	rep(i, 0, N)cin >> A[i];
	ll cnt = K - A[N - 1] + A[0];
	ll mx = K - A[N - 1] + A[0];
	rep(i, 0, N - 1) {
		cnt += A[i + 1] - A[i];
		chmax(mx, A[i + 1] - A[i]);
	}
	cout << cnt - mx << "\n";
	
	return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b && b == c){
    cout << 1 << endl;
  }else if(a == b && b != c || a != b && b == c || a == c && b != c){
    cout << 2 << endl;
  }else{
    cout << 3 << endl;
  }
}

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

using namespace std;

class fastio {
public:
    fastio() {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} __fastio;

int main(){
	string s;
	cin >> s;
	if (s == "AAA" || s == "BBB")
	{
		cout << "No" << "\n";
	} else {
		cout << "Yes" << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[][] c = new int[3][3];
            for (int i = 0; i < 3; i++) {
                c[i] = in.nextIntArray(3);
            }

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

            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < 3; j++) {
                    if (c[j][i + 1] - c[j][i] != dx[i]) {
                        out.println("No");
                        return;
                    }

                    if (c[i + 1][j] - c[i][j] != dy[i]) {
                        out.println("No");
                        return;
                    }
                }
            }

            out.println("Yes");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n) {
        cin >> a[i];
        a[i]-=i+1;
    }
    sort(a.begin(),a.end());
    ll mid = a[n/2];
    ll ans=0;
    rep(i,n) ans+=abs(a[i]-mid);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, K;
    cin >> A >> B >> K;
    int i = max(A, B) + 1;
    while (K > 0)
    {
        i--;
        if (A % i == 0 && B % i == 0) K--;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <array>
#include <set>

#include <cmath>

using namespace std;

typedef long long LL;

int main() {
	int n, x;
	vector<pair<int, int>> inputs;

	while (true)
	{
		cin >> n >> x;
		if (n == 0 && x == 0) break;

		inputs.emplace_back(make_pair(n, x));
	}

	for (auto&& input : inputs) {
		set<vector<int>> ans;
		vector<int> numbers(input.first);
		iota(numbers.begin(), numbers.end(), 1);
		int count = 0;

		for (auto iter_i = numbers.begin(); iter_i != numbers.end() - 2; ++iter_i) {
			for (auto iter_j = iter_i + 1; iter_j != numbers.end() - 1; ++iter_j) {
				for (auto iter_k = iter_j + 1; iter_k != numbers.end(); ++iter_k) {
					if ((*iter_i + *iter_j + *iter_k) == input.second) {
						count++;
						break;
					}
				}
			}
		}
		printf("%d\n", count);
	}
	

	return 0;
}



Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        
        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        String inputData = scanner.nextLine();
        scanner.close();

        // 文字列の編集
        int inputDataNumber = inputData.length();
        char[] displayStringLength = new char[inputDataNumber];
        for (int index = 0; index < displayStringLength.length; index++) {
            displayStringLength[index] = 'x';
        }

        // 編集した文字列の出力
        String displayData = new String(displayStringLength);
        System.out.println(displayData);

    }

}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
 
 int main(){
     string O;
     string E;
     cin >> O >> E;
     for (int i = 0; i < 50; i++){
         if(i < O.size()){
             cout << O.at(i);
         }
         if(i < E.size()){
             cout << E.at(i);
         }
     } 
 }

Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	const S = args[1][0]
	let ans = ''

	for (let i = 0; i < S.length; i++) {
		const c = S[i]
		let t1 = c.charCodeAt()
		let t2 = ((t1 - 65) + N) % 26 + 65
		ans += String.fromCharCode(t2)
	}

	console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21192