akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int a[55],b[55],c[55];
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    for(int i=1;i<=n;i++)
        cin >> b[i];
    for(int i=1;i<n;i++)
        cin >> c[i];

    int num=0;
    for(int i=1;i<=n;i++)
    {
        num+=b[i];
        if(i!=1 && a[i]-a[i-1]==1)
            num+=c[a[i-1]];
    }
    cout << num;
    return 0;
}


Measured memory_bytes: 256
INF = float('inf')


def tc():
    n, m = map(int, input().split())
    g = [[] for _ in range(n + 1)]
    for _ in range(m):
        x, y = map(int, input().split())
        g[x].append(y)

    vis = [False] * (n + 1)
    done = [False] * (n + 1)

    stack = list(range(1, n + 1))
    topsort = []
    while stack:
        u = stack[-1]
        if done[u]:
            stack.pop()
            continue
        vis[u] = True

        leaf = True
        for v in g[u]:
            if not vis[v]:
                leaf = False
                stack.append(v)

        if leaf:
            topsort.append(u)
            done[u] = True
            stack.pop()  # if no vs, pop u

    # topsort.reverse() # topsort more useful backwards here
    dp = [0] * (n + 1)
    for u in topsort:
        if g[u]:
            dp[u] = max(dp[v] for v in g[u]) + 1

    print(max(dp))


tc()


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

int main()
{
    int card[11];

    int c1, c2, c3;
    while( cin >> c1 >> c2 >> c3 )
    {
        for( int i = 1; i <= 10; i++ )
        card[i] = 1;

        card[c1] = 0;
        card[c2] = 0;
        card[c3] = 0;

        int limit = 20 - c1 - c2;
        double p = 0, sum = 0;
        for( int i = 1; i <= 10; i++ )
        {
            if( card[i] == 1 )
            {
                sum++;
                if( i <= limit )
                    p++;
            }
        }
        if( 100 * p / sum > 50 )        //相手の裏のカードが自分が引きたいカードだった場合の確率で考える。
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 3016
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
ll l=1000000007;
string alphabet="abcdefghijklmnopqrstuvwxyz";

int main() {
  ll n; cin>>n;
  string s; cin>>s;
  vector<ll> v(26,0);
  rep(i,n){
    rep(j,26){
      if(s[i]==alphabet[j]){v[j]++;}
    }
  }
  ll ans=1;
  /*for (ll tmp = 1; tmp < (1 << 5); tmp++) {
    bitset<5> b(tmp);//cout<<b<<endl;
    ll x=1;
    rep(i,5){ if(b.test(i)){x*=v[i]; x%=l;} }//cout<<x;
    ans+=x; ans%= l;
  }*/
  rep(i,26){
    ans*=v[i]+1; ans%=l;
  }
  ans--;
  cout<<ans;
}

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

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    if (k > a)
    {
        if (b < k - a)
            b = 0;
        else
            b -= k - a;
        a = 0;
    }
    else
    {
        a -= k;
    }

    cout << a << " " << b << endl;
    return 0;
}


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

#define MAX 100

int init(int, int, int, const vector<int>&, const vector<int>&, const vector<int>&);

int main(){
    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);
    for (int i = 0; i < N; ++i){
        cin >> x[i] >> y[i] >> h[i];
    }

    for (int cy = 0; cy <= MAX; ++cy){
        for (int cx = 0; cx <= MAX; ++cx){
            bool flag = true;
            int H = init(N, cx, cy, x, y, h);

            for (int i = 0; i < N; ++i){
                if (h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0)){
                    flag = false;
                    break;
                }
            }

            if (flag){
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }
    return -1;
}


int init(int N, int cx, int cy, const vector<int>& x, const vector<int>& y, const vector<int>& h){
    for (int i = 0; i < N; ++i){
        if (h[i] > 0){
            return h[i] + abs(x[i] - cx) + abs(y[i] - cy);
        }
    }
    return -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    ll N, A, B; cin >> N >> A >> B;
    cout << A * (N / (A + B)) + min(N % (A + B), A) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int a, n, min {1000000}, max {-1000000};
	long sum {};
	std::cin >> n;
	for (int i=0; i!=n; ++i) {
		std::cin >> a;
		min = a < min ? a : min;
		max = a > max ? a : max;
		sum += a;
	}
	std::cout << min << ' ' << max << ' ' << sum << '\n';
}

Measured memory_bytes: 3092
#include <iostream>
using namespace std;
#define ll long long
ll N, K, i, t, a, b;
ll arr[100001] = {0};
int main() {
    cin >> N >> K;
    for(i = 0; i < N; i++) {
        cin >> a >> b;
        arr[a] += b;
    }
    for(i = 1, t = 0; i <= 100001; i++) {
        t += arr[i];
        if(t >= K) {cout << i; break;}
    }
}

Measured memory_bytes: 1024
N = int(input())
restran = [list(input().split()) for i in range(N)]

for i, j in enumerate(restran):
    restran[i][1] = int(restran[i][1])
    restran[i].append(i+1)

restran = sorted(restran, reverse=True, key=lambda restran: restran[1])
restran = sorted(restran, key=lambda restran: restran[0])

for i in range(len(restran)):
    print(restran[i][2])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    char a;  cin >> a;
    if('A' <= a && a <= 'Z')  cout << "A" << endl;
    else                      cout << "a" << endl;
    
	return 0;
}

Measured memory_bytes: 3568
def gcd(x, y)
  return x if y < 1
  return gcd(y, x % y)
end

while line = gets
  a, b = line.split.map(&:to_i)
  a, b = b, a if a < b
  c = gcd(a, b)
  puts "#{c} #{a*b/c}"
end

Measured memory_bytes: 8564
#include <stdio.h>

int main(void){
  int A, B, C, D, N;
  int op1, op2, op3;
  scanf("%d", &N);
  A = N / 1000;
  B = (N - A * 1000) / 100;
  C = (N - A * 1000 - B * 100) / 10;
  D = N - A * 1000 - B * 100 - C * 10;
  if (A + B + C + D == 7) {
    op1 = '+'; op2 = '+'; op3 = '+';
  } else if (A + B + C - D == 7) {
    op1 = '+'; op2 = '+'; op3 = '-';
  } else if (A + B - C + D == 7) {
    op1 = '+'; op2 = '-'; op3 = '+';
  } else if (A + B - C - D == 7) {
    op1 = '+'; op2 = '-'; op3 = '-';
  } else if (A - B + C + D == 7) {
    op1 = '-'; op2 = '+'; op3 = '+';
  } else if (A - B + C - D == 7) {
    op1 = '-'; op2 = '+'; op3 = '-';
  } else if (A - B - C + D == 7) {
    op1 = '-'; op2 = '-'; op3 = '+';
  } else if (A - B - C - D == 7) {
    op1 = '-'; op2 = '-'; op3 = '-';
  }
  printf("%d%c%d%c%d%c%d=7\n", A, op1, B, op2, C, op3, D);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define MAX 25
struct Node{
  int parent;
  int right;
  int left;
  int degree;
};
int n;
struct Node U[MAX];
int sib(int);
int dep(int);
int hei(int);
 
int sib(int x){
  if(U[x].right!=-1) return U[x].right;
  else if(U[U[x].parent].left!=x) return U[U[x].parent].left;
  else return -1;
}
int hei(int x) {
  int i,a=0,y;
   
  for(i=0;i<n;i++) {
    if(U[i].parent==x) {
      y=hei(i)+1;
      if(y>a) a=y;
    }
  }
  return a;
}  
int dep(int x){
  int d=0,p;
  p=U[x].parent;
  
  while(p!=-1){
    p=U[p].parent;
    d++;
  }
  
  return d;
}

 
int main(){
  int i,id,r,l;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    U[i].parent=-1;
    U[i].right=-1;
    U[i].left=-1;
    U[i].degree=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&l,&r);
    U[id].left=l;
    U[U[id].left].right=r;
    if(U[id].left!=-1){
      U[U[id].left].parent=id;
      U[id].degree++;
    }
    if(U[U[id].left].right!=-1){
      U[U[U[id].left].right].parent=id;
      U[id].degree++;
    }
  }
  
  for(i=0;i<n;i++){
    if(U[i].parent==-1)
      printf("node %d: parent = -1, sibling = -1, degree = %d, depth = 0, height = %d, root\n",i,U[i].degree,hei(i));
  
    else if(U[i].degree==0)
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n",i,U[i].parent,sib(i),U[i].degree,dep(i),hei(i));
  
    else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n",i,U[i].parent,sib(i),U[i].degree,dep(i),hei(i));
  }
  
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int a,b; cin>>a>>b;
    string s; cin>>s;
  	
  	for (int i=0;i<a;i++){
    	if(s.at(i)=='-'){
        	cout<<"No"<<endl;
          	return 0;
        }
    }
  	
  	if(s.at(a)!='-'){
		cout<<"No"<<endl;
      	return 0;
	}
  
  	for (int i=a+1;i<s.size();i++){
    	if(s.at(i)=='-'){
        	cout<<"No"<<endl;
          	return 0;
        }
    }
         cout<<"Yes"<<endl;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b;
  cin >> a >> b;
  if(a+b < 10) cout << a+b << endl;
  else cout << "error" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);



void solve(int T){
    int a,b;
    cin>>a>>b;
    int x=a+b;
    cout<<6-x<<"\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





Measured memory_bytes: 3588
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N,an=1,nan=1;
	cin >> N;
	rep(i, N) {
		ll A;
		cin >> A;
		an *= 3;
		if (A % 2 == 0) {
			nan *= 2;
		}

	}
	cout << an - nan << endl;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(void){
	int pasta, juice, minP = 2000, minJ = 2000, sum;
	int i;
	
	for (i = 0; i < 3; i++){
		scanf("%d", &pasta);
		if (pasta < minP) minP = pasta;
	}
	
	for (i = 0; i < 2; i++){
		scanf("%d", &juice);
		if (juice < minJ) minJ = juice;
	}
	
	sum = minP + minJ - 50;
	
	printf("%d\n", sum);
		
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#include<vector>

struct Card{
  char patt;
  int num;
};

void display( std::vector<Card> A ){
    for( int i = 0; i < A.size(); i++ ){
      std::cout << A[i].patt << A[i].num;
      if( i < A.size()-1 ) std::cout << " ";
      else std::cout << std::endl;
  }
}

int bubbleSort( std::vector<Card>& A, int N ){
  int cnt = 0;
  for( int i = 1; i < N; i++ ){
    for( int j = i; j > 0; j-- ){
      if( A[j-1].num > A[j].num ){
        std::swap( A[j], A[j-1] );
        cnt++;
      } else  break;
    }
  }
  return cnt;
}

int selectionSort( std::vector<Card>& A, int N ){
  int cnt = 0;
  for( int i = 0; i < N-1; i++ ){
    int minj = i;
    for( int j = i+1; j < N; j++ ){
      if( A[minj].num > A[j].num ){
        minj = j;
      }
    }
    if( i != minj ){
      std::swap( A[minj], A[i] );
      cnt++;
    }
  }
  return cnt;
}

bool isSafe( const std::vector<Card> target, const std::vector<Card> base ){
  std::vector<char> patt(0);
  for( int i = 1; i <= 9; i++ ){
    for( int j = 0; j < base.size(); j++ ){
      if( base[j].num == i ){
        patt.push_back( base[j].patt );
      }
    }
  }

  for( int i = 0; i < target.size(); i++ ){
    if( target[i].patt != patt[i] )
      return false;
  }
  return true;
}

int main()
{
  int N;
  std::cin >> N;
  std::vector<Card> A(N);
  for( Card &a : A ){
    char c;
    int i;
    std::cin >> c;
    std::cin >> i;
    a.patt = c;
    a.num = i;
  }

  std::vector<Card> bubble( A );
  bubbleSort( bubble, N );
  display( bubble );
  std::cout << ((isSafe( bubble, A )) ? "Stable":"Not stable" ) << std::endl; 

  std::vector<Card> selection( A );
  selectionSort( selection, N );
  display( selection );
  std::cout << ((isSafe( selection, A )) ? "Stable":"Not stable" ) << std::endl;
}



Measured memory_bytes: 3152
#include <stdio.h>
#include <math.h>

#define N 10000
int isprime(int);

int main(){
  int i,n,sum=0;
  int A[N];
 

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

  for(i=0; i<n; i++){
    if(isprime(A[i])==1)
      sum++;
  }
  printf("%d\n",sum);

  return 0;
}

int isprime(int x){
  int i;

  if(x == 2)
    return 1;

  if(x < 2 || x%2==0)
    return 0; 

  i = 3;
  while(i <= sqrt(x)){
    if(x%i==0)
      return 0;
    i = i + 2;

  }
  return 1;
}

Measured memory_bytes: 628
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
mn = []
mx = []
for i in range(n):
    a,b = na()
    mn.append(a)
    mx.append(b)

mn.sort()
mx.sort()

if n%2 == 0:
    p = mn[n//2-1]+mn[n//2]
    q = mx[n//2-1]+mx[n//2]
    print(q-p+1)
else:
    p = mn[n//2]
    q = mx[n//2]
    print(q-p+1)



Measured memory_bytes: 25428
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NMC= Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long[] B = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            int cnt = 0;
            //ソースコード取得と比較
            for (int j = 0; j < NMC[0]; j++)
            {
                //結果を初期化
                long result = 0;
                //取得
                long[] A = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
                //
                for (int z = 0; z < NMC[1]; z++)
                {
                    result += A[z] * B[z];
                }
                result += (NMC[2]);
                if (0<result)
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


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

int main(){
  string s;
  int k;
  cin>>k;
  rep(i,k){
    s+="ACL";
  }
  cout<<s<<endl;
}

Measured memory_bytes: 3628
using System;

namespace ABC057_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());

            var min = int.MaxValue;
            for (long i = 1; i * i <= N; i++)
            {
                if (N % i != 0) continue;

                var B = N / i;
                var F = Math.Max(i.ToString().Length, B.ToString().Length);

                min = Math.Min(min, F);
            }

            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(i + k > n) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.BitSet;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N, ans;
	static int[] X = new int[24];
	static int[] Y = new int[24];
	static int[] R = new int[24];
	static int[] C = new int[24];
	static int[] mask = new int[24];
	static BitSet visited;

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			for (int i = 0; i < N; ++i) {
				X[i] = sc.nextInt();
				Y[i] = sc.nextInt();
				R[i] = sc.nextInt();
				C[i] = sc.nextInt();
			}
			visited = new BitSet(1 << N);
			System.out.println(solve());
		}
	}

	static int solve() {
		ans = 0;
		for (int i = 0; i < N; ++i) {
			mask[i] = 0;
			for (int j = 0; j < i; ++j) {
				if (cover(i, j)) mask[i] |= (1 << j);
			}
		}
		dfs((1 << N) - 1);
		return ans;
	}

	static void dfs(int rest) {
		if (visited.get(rest)) return;
		ans = Math.max(ans, N - Integer.bitCount(rest));
		for (int i = 0; i < N; ++i) {
			if ((rest & (1 << i)) == 0) continue;
			if ((rest & mask[i]) != 0) continue;
			for (int j = i + 1; j < N; ++j) {
				if (C[i] != C[j]) continue;
				if ((rest & (1 << j)) == 0) continue;
				if ((rest & mask[j]) != 0) continue;
				dfs(rest - (1 << i) - (1 << j));
			}
		}
		visited.set(rest);
	}

	static boolean cover(int i, int j) {
		return (X[j] - X[i]) * (X[j] - X[i]) + (Y[j] - Y[i]) * (Y[j] - Y[i]) < (R[i] + R[j]) * (R[i] + R[j]);
	}

}

Measured memory_bytes: 49148
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  N = S.length();
  int point=0;
  int optimal = N-1;
  REP(i,0,N-1){
    if(S[i]==S[i+1])point++;
  }
  int plus=2*K;
  cout<<min(optimal, point+plus)<<endl;
  // VEC<int> C;
  // int cnt = 1;
  // C.push_back(0);
  // REP(i, 0, N - 1) {
  //   if (S[i] != S[i + 1]) {
  //     C.push_back(cnt);
  //     cnt = 1;
  //   } else {
  //     cnt++;
  //   }
  // }
  // C.push_back(cnt);
  // DUMP(C);
  // int m = C.size();
  // int mid = m / 2;
  // LL sum = 0;
  // REP(i, 0, K) {
  //   if (mid - 1 >= 0) sum += C[mid - 1];
  //   if (mid + 1 < C.size()) sum += C[mid + 1];
  // }

  return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := newInputScanner(true, 64)
	N := sc.nextInt()
	combinations := standardCombinations(N)
	for _, combination := range combinations {
		fmt.Println(combination.str)
	}
}

func standardCombinations(n int) []*combination {
	if n == 1 {
		return []*combination{&combination{
			usedLetters: 1,
			str:         "a",
		}}
	}
	subCombinations := standardCombinations(n - 1)
	combinations := make([]*combination, 0)
	var newUsedLetters int
	for _, subCombination := range subCombinations {
		for i := 0; i <= subCombination.usedLetters; i++ {
			newUsedLetters = subCombination.usedLetters
			if i == subCombination.usedLetters {
				newUsedLetters++
			}
			combinations = append(combinations, &combination{
				usedLetters: newUsedLetters,
				str:         subCombination.str + string('a'+i),
			})
		}
	}
	return combinations
}

type combination struct {
	usedLetters int
	str         string
}

type inputScanner struct {
	*bufio.Scanner
}

func newInputScanner(enabledScanWords bool, sizeInKB int) *inputScanner {
	scanner := bufio.NewScanner(os.Stdin)
	if enabledScanWords {
		scanner.Split(bufio.ScanWords)
	}
	capacity := sizeInKB * 1024
	buf := make([]byte, capacity)
	scanner.Buffer(buf, capacity)
	return &inputScanner{
		Scanner: scanner,
	}
}

func (inputSc *inputScanner) nextInt() int {
	i, e := strconv.Atoi(inputSc.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (inputSc *inputScanner) nextUInt64() uint64 {
	i, e := strconv.ParseUint(inputSc.nextStr(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func (inputSc *inputScanner) nextStr() string {
	inputSc.Scan()
	return inputSc.Text()
}


Measured memory_bytes: 12928
S = input()
N = len(S)
res = "No"

if S == S[::-1]:
    if S[:int((N-1)/2)] == S[:int((N-1)/2)][::-1]:
        if S[int((N+3)/2)-1:] == S[int((N+3)/2)-1:][::-1]:
            res = "Yes"

print(res)


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int N;
    string S;
    cin >> N >> S;
    int size = S.size();
    for(int i = 0; i < size; i++){
        if(S[i] + N > 'Z') S[i] = S[i] + N - 26;
        else S[i] = S[i] + N;
    }
    cout << S << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    string s;
    cin>>s;
    int n=sz(s);
    rep(i,(n-1)/2) {
        if(n-2-i<i) break;
        if(s[i]!=s[n-2-i]) {
            cout<<-1<<endl;
            return 0;
        }
    }
    if(s[n-1]=='1' || s[0]=='0' || s[n-2]=='0') {
        cout<<-1<<endl;
        return 0;
    }
    
    int now=1;
    rep(i,n) {
        if(i==0) continue;
        cout<<now<<" "<<i+1<<endl;
        if(i<=n/2 && s[i-1]=='1') now=i+1;
    }
}


Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(void) {
    int list[3] = {0},count = 0;
    for(int i = 0; i < 3; i ++)
        cin >> list[i];
    for(int i = 0; i < 3 - 1; i++)
        for(int j = i + 1; j <3; j ++)
            if(list[j] < list[i]) {
                int temp;
                temp = list[i];
                list[i] = list[j];
                list[j] = temp;
            }
    for(int i = 0; i < 3; i++) {
        if(count)
            cout << " ";
        cout << list[i];
        count ++;
    }
    cout << endl;
    return 0 ;
}


Measured memory_bytes: 3056
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main(){
  int N;
  std::cin >> N;
  if (N==3) {
    printf("2 5 63\n");
  } else if (N==4) {
    printf("2 5 20 63\n");
  } else if (N==5) {
    printf("2 5 20 63 90\n");
  } else {
    long long sum = 0;
    int i = 0;
    int offset[4]={2, 3, 4, 6};
    int offset_counter = 0;
    int cnt = 0;
    std::set<int> st;
    while(cnt<N) {
      st.insert(6*i+offset[offset_counter]);
      sum += 6*i+offset[offset_counter];
      cnt++;
      offset_counter++;
      if (offset_counter==4) {
        i++;
        offset_counter = 0;
      }
    }
    switch(sum%6){
    case 2:
      st.erase(2);
      st.insert(30000);
      break;
    case 3:
      st.erase(3);
      st.insert(30000);
      break;
    case 5:
      st.erase(3);
      st.insert(29998);
      break;
    }
    for (int p : st){
      printf("%d ",p);
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 4136
s = input()
yymm = 1 <= int(s[2:]) <= 12
mmyy = 1 <= int(s[:2]) <= 12
if yymm and mmyy:
    print('AMBIGUOUS')
elif yymm:
    print('YYMM')
elif mmyy:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 8884
def calcGCD(a, b)
  m = [a, b].max
  n = [a, b].min

  while n > 0
    if (n == 0)
      break
    else
      nn = n
      n = m % n
      m = nn
    end
  end
  return m
end

inputs = []
while (line = gets) != nil
  inputs.push(line.split())
end

for i, j in inputs
  a = i.to_i
  b = j.to_i
  g = calcGCD(a, b)
  l = a * b / g
  puts printf("%d %d", g, l)
end

Measured memory_bytes: 6112
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string s,t;
  cin >> s >> t;

  bool ans = false;

  rep(i,sz(s))
  {
    if(s == t)
    {
      ans = true;
      break;
    }
    s = s.back() + s.substr(0,sz(s) - 1);
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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


map<int , int> ma;
int main(){
  int N;
  cin >> N;
  bool check = false;
  int buf;
  for(int i = 0; i< N; i++){
    cin >> buf;
    // if(ma.at(buf) != 0){
    if(ma.find(buf) == ma.end()){
      // ma.at(buf) = 1;
      ma.insert(make_pair(buf, 1));
    }else{
      check = true;
    }
  }

  if(check == true){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }


}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp ": "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(__typeof(a)i=(a);i<=(b);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define db(something)   cerr<<#something<<" - "<<something<<"\n";         
int main()
{
  
   Ezio
   /*Variables*/
   /*Code*/
   ll n,s(0);
   cin>>n;
   fn(i,n){
     if(i%3 and i%5) s+=i;
   }
   cout<<s<<endl;
   return 0;
}
    

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
ll r, d, x;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> r >> d >> x;
  FOR(i, 0, 10){
    x = x * r - d;
    cout << x << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int a,b;
	cin>>a>>b;
	cout<<a*b;
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


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

int main(){
  ll a, b, x;
  cin >> a >> b >> x;
  
  ll ans_a = (a-1)/x + 1;
  ll ans_b = b/x + 1;
  if (a == 0) ans_a = 0;
  if (b == 0) ans_b = 1;
  cout << ans_b - ans_a << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

void b(std::istream& in)
{
    int N;
    in >> N;

    std::vector<unsigned long long> Ai(N + 1, 1);
    for (int i = 1; i <= N; ++i)
    {
        in >> Ai[i];
        if (Ai[i] == 0)
        {
            std::cout << "0";
            return;
        }
    }

    unsigned long long mul = 1;
    for (const auto& a : Ai)
    {
        unsigned long long tmp = mul * a;
        if ((tmp / mul) != a)
        {
            std::cout << "-1";
            return;
        }
        if (tmp > 1000000000000000000L)
        {
            std::cout << "-1";
            return;
        }

        mul = tmp;
    }

    std::cout << mul;
}

int main(int, char* [])
{
    b(std::cin);
    return 0;
}



Measured memory_bytes: 3556
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x): #親を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y): #和集合の生成
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x): #所属する集合の大きさ
        return -self.parents[self.find(x)]

    def same(self, x, y): #同じ集合に属しているか判定
        return self.find(x) == self.find(y)

    def members(self, x): #同じ集合に属する要素全列挙
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self): #集合のリーダー全列挙
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self): #集合の数
        return len(self.roots())

    def all_group_members(self): #辞書型,{(リーダーの番号):(その集合の要素全列挙)}
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
l=[]
for i in range(m):
    l.append(list(map(int,input().split())))
ans=0
for i in range(m):
    a=UnionFind(n)
    for j in range(m):
        if i==j:
            continue
        a.union(l[j][0]-1,l[j][1]-1)
    if a.group_count()==2:
        ans+=1
print(ans)

Measured memory_bytes: 9248
fun main(args: Array<String>) {
    abc068c()
}

fun abc068c() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val abList = (1..m).map { readLine()!!.split(' ').map { it.toInt() } }
        .map { Pair(it[0], it[1]) }

    val from1 = abList.filter { it.first == 1 }.map { it.second }.toSet()
    val toN = abList.filter { it.second == n }.map { it.first }.toSet()

    val answer = if (from1.any { it in toN }) "POSSIBLE" else "IMPOSSIBLE"

    println(answer)
}


Measured memory_bytes: 94328
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, T;
    cin >> N >> T;

    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> mx(N);
    mx[N - 1] = A[N - 1];
    for (ll i = N - 2; i >= 0; --i) mx[i] = max(A[i], mx[i + 1]);

    ll p = 0;
    rep(i, N) p = max(p, mx[i] - A[i]);

    ll ans = 0;
    rep(i, N) if(p == mx[i] - A[i]) ++ans;

    print(ans);

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int N = 1e5 + 1;

int32_t main(){
 	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
 	int n ;
 	cin >> n;
 	cout << pow(n , 3) << endl;
 return 0;
}

Measured memory_bytes: 4304
#include <iostream>

using namespace std;
#define NUMBER 200000

int main(){

	int ary[NUMBER];
	int min_register[NUMBER];


	int n;
	cin >> n;	//????´???°?????????

	cin >> ary[0];	//1?????????????´??????????
	int min=ary[0];
	min_register[0] = min;

	int max = -1000000001;
	for(int i = 1; i < n; i++){
		cin >> ary[i];
		min = (min > ary[i])?ary[i]:min;
		min_register[i] = min;
		max = (max > ary[i] - min_register[i-1])?max:ary[i] - min_register[i-1];

	}
	cout << max << endl;
}

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

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

  for (int i = a; i < b+1; i++) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;

}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define INF 1e18
using namespace std;

typedef long long ll;
int n,K;
vector<pair<ll,ll>> v;

ll MIN(ll a,ll b,ll c,ll d){
    ll res=min(a,b);
    res=min(res,c);
    res=min(res,d);
    return res;
}
ll MAX(ll a,ll b,ll c,ll d){
    ll res=max(a,b);
    res=max(res,c);
    res=max(res,d);
    return res;
}
ll area(int a,int b,int c,int d){
    ll len1,len2;//len1:縦 len2:横
    len1=v[d].first-v[a].first;
    ll A=v[a].second,B=v[b].second,C=v[c].second,D=v[d].second;
    len2=MAX(A,B,C,D)-MIN(A,B,C,D);
    return len1*len2;
}
bool in_area(int a,int b,int c,int d,int p){
    ll UNDER=MIN(v[a].second,v[b].second,v[c].second,v[d].second);
    ll TOP=MAX(v[a].second,v[b].second,v[c].second,v[d].second);
    ll LEFT=v[a].first,RIGHT=v[d].first;
    return (LEFT<=v[p].first && v[p].first<=RIGHT && UNDER<=v[p].second && v[p].second<=TOP);
}
int score(int a,int b,int c,int d){
    int res=4;
    if(a==b)res--;
    if(b==c)res--;
    if(c==d)res--;
    for(int i=0;i<n;i++){
        if(i==a || i==b || i==c || i==d)continue;
        if(in_area(a,b,c,d,i))res++;
    }
    return res;
}

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

    cin>>n>>K;
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        v.push_back(pair<ll,ll>{a,b});
    }
    sort(v.begin(),v.end());

    ll ans=4*INF;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            for(int k=j;k<n;k++){
                for(int l=k;l<n;l++){
                    //cout<<score(i,j,k,l)<<endl;
                    if(score(i,j,k,l)>=K){
                        //cout<<score(i,j,k,l)<<" "<<area(i,j,k,l)<<endl;
                        ans=min(ans,area(i,j,k,l));
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<=111)
        cout<<"111\n";
    else if(n>111 && n<=222)
        cout<<"222\n";
    else if(n>222 && n<=333)
        cout<<"333\n";
    else if(n>333 && n<=444)
        cout<<"444\n";
    else if(n>444 && n<=555)
        cout<<"555\n";
    else if(n>555 && n<=666)
        cout<<"666\n";
    else if(n>666 && n<=777)
        cout<<"777\n";
    else if(n>777 && n<=888)
        cout<<"888\n";
    else if(n>888 && n<=999)
        cout<<"999\n";
    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ans(N);
  int a, b;
  rep(i, M){
    cin >> a >> b;
    ans.at(a-1)++;
    ans.at(b-1)++;
  }
  rep(i,N){
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int a;
  cin >> a;
  string ok = "Three";
  for(int i = 0; a > i; i++){
    char s;
    cin >> s;
    if(s == 'Y'){
      ok = "Four";
      break;
    }
  }
  cout << ok << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String input = reader.readLine();
        int length = input.length();
        int latter = (length + 3) / 2 ;
        int i = 0;
        for (i = 0; i < length / 2;i++) {
            if (input.charAt(i) != input.charAt(input.length() - 1 - i)) {
                break;
 
            }
            if (i < (length) / 2) {
                if (input.charAt(i) != input.charAt((length) / 2 - 1 -  i)) {
 
                    break;
                }
            }
            if (i < (length - latter) / 2) {
                if (input.charAt(length - i - 1) != input.charAt(latter + i - 1)) {
                    break;
                }
            }
        }
        if (i == length / 2) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23252
def solve():
    from sys import stdin
    f_i = stdin
    
    # function to update distance between switch and computer
    def dfs(sw_id, prev, dist):
        switch[sw_id].append(dist)
        for next_sw in adj[sw_id]:
            if next_sw != prev:
                dfs(next_sw, sw_id, dist + 1)
    
    while True:
        N = int(f_i.readline())
        if N == 0:
            break
        
        # distance table of computers
        dist_tbl = [list(map(int, f_i.readline().split())) for i in range(N)]
        
        switch = [[1]] # switch[sw][com]: distance between sw and com
        degree = [1]
        adj = [[]] # adjacency list of switches
        
        for dt_i in dist_tbl[1:]:
            # try to connect a computer to an existing switch
            for m, sw_m in enumerate(switch):
                for dist_j, dt_ij in zip(sw_m, dt_i):
                    if dist_j != dt_ij - 1:
                        break
                else: # found a switch to connect a computer
                    degree[m] += 1
                    dfs(m, m, 1)
                    break
                continue
            else: # no switch to connect
                # find an existing switch to connect additional switch to
                for m, sw_m in enumerate(switch):
                    g = (x - y for x, y in zip(dt_i, sw_m))
                    diff = next(g)
                    for d in g:
                        if d != diff:
                            break
                    else:
                        break
                
                # first additional switch
                sw = len(switch)
                switch.append([dist + 1 for dist in switch[m]])
                adj[m].append(sw)
                adj.append([m])
                degree[m] += 1
                degree.append(1)
                
                # second and subsequent additional switches
                for i in range(2, diff):
                    switch.append([dist + i for dist in switch[m]])
                    adj[sw].append(sw + 1)
                    adj.append([sw])
                    degree[sw] += 1
                    degree.append(1)
                    sw += 1
                
                # connect a computer to the last added switch
                degree[sw] += 1
                dfs(sw, sw, 1)
                
        degree.sort()
        print(' '.join(map(str, degree)))

solve()


Measured memory_bytes: 6140
n = int(input())
a = [int(input()) for _ in range(n)]
cnt = 0
for i in range(n):
    if i != n-1 and a[i] % 2 == 1:
        if a[i+1] != 0:
            a[i+1] -= 1
            cnt += 1
    cnt += a[i]//2
print(cnt)

Measured memory_bytes: 7072
#include<stdio.h>

int main(void) {
  int n, r;
  scanf("%d %d", &n, &r);
  
  if(n >= 10) {
    printf("%d\n", r);
  }
  else {
    printf("%d\n", r + 100 * (10 - n));
  }
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    cin >> n;
	if(n == 1){
        cout << "Hello World" << '\n';
    }else{
        int a, b;
        cin >> a >> b;
        cout << a + b << '\n';
    }
	
	return 0;
}

Measured memory_bytes: 256