akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

A,B,C,X,Y = IL()

P(min(A*X+B*Y,C*2*max(X,Y),C*X*2+B*max(0,Y-X),C*Y*2+A*max(0,X-Y)))

Measured memory_bytes: 38384
#include <iostream>

using namespace std;
int main (){
    int n,m;
    cin >> n >> m;
    int ap[n]={};
    int tmp1,tmp2;
    for (int i = 0; i < m; i++){
        cin >> tmp1 >> tmp2;
        ap[tmp1-1]++;
        ap[tmp2-1]++;
    }
    for (int i = 0; i < n; i++){
        cout << ap[i] << "\n";
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main()
{
    int n, k;
    std::cin >> n >> k;

    std::string s;
    std::cin >> s;

    std::vector<int> pos;
    pos.push_back(0);

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

    pos.push_back(n);

    int ans = 0;
    for (int i = 0; i < pos.size(); i++) {
        int end_pos_idx;
        if (s[pos[i]] == '1') {
            end_pos_idx = i + 2 * k + 1;
        } else {
            end_pos_idx = i + 2 * k;
        }

        if (end_pos_idx >= pos.size()) {
            end_pos_idx = pos.size() - 1;
        }

        ans = std::max(ans, pos[end_pos_idx] - pos[i]);
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 1020
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int a, b, C;
    scanf("%d %d %d", &a, &b, &C);
    double rad = M_PI * C / 180;
    double h = sin(rad) * b;
    double S = a * h / 2;
    double c = sqrt(a * a + b * b - cos(rad) * a * b * 2);
    printf("%lf\n%lf\n%lf", S, c + a + b, h);
    return 0;
}



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

using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s[0] != 'A') {
        cout << "WA\n";
        return 0;
    }
    if (s[1] == 'C' || isupper(s[1])) {
            cout << "WA\n";
            return 0;
    }
    int k = 0;
    for (int i = 2, j; i < s.length() -1; i++) {
        if (s[i] == 'C')
            k++;
        else if (isupper(s[i])) {
            cout <<"WA\n";
            return 0;
        }
        if (k > 1) {
            cout << "WA\n";
            return 0;
        }
    }

    if (isupper(s[s.length()-1]) || k == 0) {
        cout << "WA\n";
        return 0;
    }

    cout << "AC\n";

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long

ll x[100009], y[100009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m;
	ll s = 0, ts = 0;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	for (int i = 0; i < m; i++)
		cin >> y[i];
	for (int i = 0; i < n; i++) {
		s = (s + 1LL * x[i] * i - ts + 1000000007LL * 5) % 1000000007LL;
		ts = (ts + x[i]) % 1000000007LL;
	}
	ll ans = s; s = ts = 0;
	for (int i = 0; i < m; i++) {
		s = (s + 1LL * y[i] * i - ts + 1000000007LL * 5) % 1000000007LL;
		ts = (ts + y[i]) % 1000000007LL;
	}
	ans = (ans * s) % 1000000007LL;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1792
ABC = [int(i) for i in input().split(" ")]
K = int(input())

maximun = max(ABC)
index = 0
for i in range(3):
    if ABC[i] - maximun == 0:
        index = i

for k in range(K):
    ABC[index] = 2 * ABC[index]

print(sum(ABC))


Measured memory_bytes: 3060
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    n, a, b = (int(x) for x in sys.stdin.read().split())
    total = 0
    for i in range(1, n+1):
        s = sum(list(int(x) for x in str(i)))
        if a <= s <= b: total += i
    print(total)

if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long 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++)
const int MOD = 1000000007;

int main() {
  int Ans = 0;  // 回答：
  int A,B,C,K;
  cin >> A >> B >> C >> K;

  // Ｋ≧Ａ→Ｋ
  // Ｋ≧Ａ＋Ｂ→Ａ
  // else Ａ－（Ｋ－Ａ－Ｂ）

  if (K<=A){
    Ans = K;
  } else if (K<=A+B){
    Ans = A;
  } else {
    Ans = A - ( K - A - B );
  }

  cout << Ans << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cassert>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  int a, b, c; cin >> a >> b >> c;
  if ((a<c && c<b) || (b<c && c<a)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    char a = s[0];
    char b = s[1];
    char c = s[2];
    char d = s[3];
    
    if((a==b && c==d && a!=d) || (a==c && b==d && a!=d) || (a==d && b==c && a!=c)){
        cout << "Yes" << endl;
    } else {
        cout << "No"<< endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <set>

using namespace std;

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

	int N;
	cin >> N;

	set<string> check_set;

	string prev = "";

	bool check = true;
	for (int i = 0; i < N; i++)
	{
		string W;
		cin >> W;

		if (check_set.find(W) != check_set.end())
		{
			check = false;
			break;
		}

		if (prev != "")
		{
			if (prev.back() != W.front())
			{
				check = false;
				break;
			}
		}

		check_set.insert(W);
		prev = W;
	}

	if (check)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}

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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define int long long 

using namespace std;

int32_t main()
{
	fio;
	int a,b,n;
  cin>>a>>b>>n;
  cout<<floor((a*min(b-1,n))/b)<<endl;
	return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5;
int N;
ll a[MAX_N*3];
int main(){
	cin>>N;
	REP(i,N*3){
		cin>>a[i];
	}
	sort(a,a+N*3);
	ll ans=0;
	REP(i,N){
		ans+=a[N*3-2-i*2];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
//using fs = unordered_set;
//#define fs set//unordered_set
vector<ll> S(0);

ll FFi(ll i){
    if(S[i]==i)return i;
    return S[i]=FFi(S[i]);
    
}

void marge(ll a,ll b){
    ll aa=FFi(a),bb=FFi(b);
    if(aa==bb)return;
    S[aa]=bb;
    S[bb]=bb;
}


int main() {
    ll N,M;
    cin >> N >> M;
    vector<vector<ll>> A(N);
    for(ll i=0;i<N;i++)S.push_back(i);
    for(ll i=0;i<M;i++){
        ll sub1,sub2;
        cin >> sub1 >> sub2;
        marge(sub1-1, sub2-1);
     
        
    }
   
    vector<ll> CO(N,0);
    for(ll i:S){
        CO[FFi(i)]++;
    }
    sort(CO.begin(), CO.end(), [](ll a,ll b){return a>b;});
    
    cout << CO[0] << endl;
    
    
}



Measured memory_bytes: 14200
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N, M;
    cin >> N >> M;
    vector<long> A(M);
    long total=0;
    for(size_t i=0;i<M; i++)
    {
        cin >> A[i];
        total += A[i];
    }
    if(N - total < 0) cout << "-1" << endl;
    else cout << N - total << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

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

    unordered_set<int> set;
    set.insert(s);
    
    int ans;
    for (int i = 1; i <= 1000000; i++)
    {
        if (s % 2 == 0)
        {
            s = s / 2;
        }

        else
        {
            s = 3 * s + 1;
        }

        if (set.find(s) == set.end())
        {
            set.insert(s);
        }

        else
        {
            ans = i + 1;
            break;
        }
    }

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

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

const int MOD = 1e9 + 7;
int D[101][8];
vector<int> bit;

bool valid(int b)
{
	for (; b; b >>= 1) {
		if ((b & 3) == 3) return false;
	}
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int H, W, K;
	cin >> H >> W >> K; K--;
	D[0][0] = 1;
	for (int i = (1 << (W - 1)) - 1; i >= 0; i--) {
		if (valid(i)) bit.push_back(i);
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 0; j < W; j++) {
			for (auto b : bit) {
				if (b&(1 << j)) {
					D[i][j] = (D[i][j] + D[i - 1][j + 1]) % MOD;
				}
				else if (j && b&(1 << (j - 1))) {
					D[i][j] = (D[i][j] + D[i - 1][j - 1]) % MOD;
				}
				else {
					D[i][j] = (D[i][j] + D[i - 1][j]) % MOD;
				}
			}
		}
	}
	cout << D[H][K] << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Ls(n)  (n<<1)
#define Rs(n)  (Ls(n)|1)
using namespace std;

typedef long long  LL;
const int N=200010;
int n,q,A,B,x[N];
LL t1[4*N],t2[4*N],tag[4*N],_,ans;

void addtag(int x,LL k){t1[x]+=k,t2[x]+=k,tag[x]+=k;}
void pushdown(int n){addtag(Ls(n),tag[n]),addtag(Rs(n),tag[n]),tag[n]=0;}
void update(int n){t1[n]=min(t1[Ls(n)],t1[Rs(n)]),t2[n]=min(t2[Ls(n)],t2[Rs(n)]);}

void build(int n,int l,int r)
{
	if (l==r)
		{
			if (l==B)  t1[n]=l,t2[n]=-l;  else  t1[n]=t2[n]=1LL<<60;
			return;
		}else
		{
			int mid=(l+r)>>1;
			build(Ls(n),l,mid),build(Rs(n),mid+1,r);
			update(n);
		}
}

LL ask1(int n,int l,int r,int L)
{
	if (L<=l)  return t1[n];
	else
		{
			int mid=(l+r)>>1;
			pushdown(n);
			if (L>mid)  return ask1(Rs(n),mid+1,r,L);
			else  return min(ask1(Ls(n),l,mid,L),ask1(Rs(n),mid+1,r,L));
		}
}

LL ask2(int n,int l,int r,int R)
{
	if (r<=R)  return t2[n];
	else
		{
			int mid=(l+r)>>1;
			pushdown(n);
			if (mid>=R)  return ask2(Ls(n),l,mid,R);
			else  return min(ask2(Ls(n),l,mid,R),ask2(Rs(n),mid+1,r,R));
		}
}

void modify(int n,int l,int r,int x,LL k)
{
	if (l==r)  t1[n]=k+l,t2[n]=k-l,tag[n]=0;
	else
		{
			int mid=(l+r)>>1;
			pushdown(n);
			x<=mid?modify(Ls(n),l,mid,x,k):modify(Rs(n),mid+1,r,x,k);
			update(n);
		}
}

void dfs(int n,int l,int r)
{
	if (l==r)  ans=min(ans,t1[n]-l);
	else
		{
			int mid=(l+r)>>1;
			pushdown(n);
			dfs(Ls(n),l,mid),dfs(Rs(n),mid+1,r);
		}
}

void work()
{
	scanf("%d %d %d %d",&n,&q,&A,&B);
	build(1,1,n);
	for (int i=1; i<=q; i++)
		{
			scanf("%d",&B);
			_=min(ask1(1,1,n,B)-B,B==1?1LL<<60:ask2(1,1,n,B-1)+B);
			addtag(1,fabs(A-B)),modify(1,1,n,A,_),A=B;
		}
	ans=1LL<<60,dfs(1,1,n);
	printf("%lld",ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

int main(void) {
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	int ans = 987654321;
	for(int i=0;i<=n-m;i++) {
		int cnt = 0;
		for(int j=0;j<m;j++) {
			if(s[i+j] != t[j]) cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}



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

bool kaibun(string s){
  string t(s.rbegin(), s.rend());
  return s == t;
}

int main(){
  string s;
  cin >> s;
  int n = s.size();
  cout << (kaibun(s) && kaibun(s.substr(0,(n-1)/2)) && kaibun(s.substr((n+1)/2))?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <algorithm>

bool inputCheck(const int& var)
{
    if( var < -(std::pow(10, 9)) 
    ||  std::pow(10, 9) < var )
    {
        return false;
    }

    return true;
}

int main()
{
    // 入力
    long a,b,c,d;
    std::cin >> a >> b >> c >> d;

    // 入力チェック
    // -10^9 <= a =< b <= 10^9
    if(inputCheck(a) 
    && inputCheck(b) 
    && inputCheck(c) 
    && inputCheck(d) 
    )
    {
        if(b < a || d < c)
        {
            // input ng
            return -1;
        }
        else
        {    
            // input ok            
        }
    }
    else
    {
        // input ng 
        return -1;
    }
    
    // ac, ad, bc, bdの積を4通り計算し、
    // 最大値をmaxとして出力する。
    long result = std::max({a*c, a*d, b*c, b*d});
    std::cout << result << std::endl;

    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		
		int max = 0;
		for(int i = 1; i < n; i++) {
			int count = 0;
			for(char c = 'a'; c <= 'z'; c++)
				if(s.substring(0, i).contains(String.valueOf(c)) && s.substring(i).contains(String.valueOf(c)))
					count++;
			if(max < count)
				max = count;
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 23380
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>      // sqrt
#include <cstdlib>    // exit
#include <algorithm>  // min,max
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define R 1000000007
#define DBG 0
typedef pair<int,int> pii;

#define MAXN 300
int d[MAXN][MAXN];
int e[MAXN][MAXN];

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  forr(i,0,n-1)
    cin >> s[i];
  forr(i,0,n-1)
  forr(j,0,n-1) d[i][j] = e[i][j] = 0;

  int m = (n-1)/2;
  forr(i,0,n-1)
  forr(j,0,n-1) {
    int dend = m;
    int eend = (n%2 == 1 ? m-1 : m);
    int dd = 0;
    forr(k,1,dend)
      if (s[(i+k)%n][(j-k+n)%n]==s[(i-k+n)%n][(j+k)%n])
        dd = k;
      else break;
    d[i][j] = dd;
    int ee = -1;
    forr(k,0,eend)
      if (s[(i-k+n)%n][(j+k)%n]==s[(i+1+k)%n][(j-1-k+n)%n])
        ee = k;
      else break;
    e[i][j] = ee;
  }

  if (DBG) {
    cout << "d" << endl;
    forr(i,0,n-1) {
      forr(j,0,n-1) cout << d[i][j] << ' ';
      cout << endl;
    }
    cout << "e" << endl;
    forr(i,0,n-1) {
      forr(j,0,n-1) cout << e[i][j] << ' ';
      cout << endl;
    }
  }

  int cnt = 0;
  forr(i,0,n-1)
  forr(j,0,n-1) {
    bool ok = true;
    forr(k,0,n-1)
      if (d[(i+k)%n][(j+k)%n] < min(k,n-1-k)) {
        if (DBG) cout << "setfd k " << k << endl;
        ok = false;
        break;
      }
    forr(k,0,n-2)
        if (e[(i+k)%n][(j+1+k)%n] < min(k,n-2-k)) {
          if (DBG) cout << "setfe k " << k << endl;
          ok = false;
          break;
        }
    if (DBG) cout << "i " << i << " j " << j << " ok " << ok << endl;
    if (ok) cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 1152
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        String s=sc.next();
        System.out.println(s.substring(0,k-1)+s.substring(k-1,k).toLowerCase()+s.substring(k));
 
    }

}

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

long long gcd(long long a, long long b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
long long lcm(long long a, long long b)
{
	return a / gcd(a, b) * b;
}
int main()
{
	int n;
	cin >> n;
	long long ans = 1;
	for (int i = 0; i < n; i++) {
		long long t;
		cin >> t;
		ans = lcm(ans, t);
	}
	cout << ans << endl;
	
	return 0;
}



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

struct block{
	long long ab,wei,solid,val;
	bool operator <(block b){
		return ab < b.ab;
	}
};

long long n,ans,dp[1001][10001];

int main(){
	cin >> n;
	vector<block> vals;
	for(int i = 0 ; i < n ; i += 1){
		int a,b,c;
		cin >> a >> b >> c;
		vals.push_back({a+b,a,b,c});
	}
	sort(vals.rbegin(),vals.rend());
	for(int i = 0 ; i < n ; i += 1){
		dp[i+1][vals[i].solid] = max(dp[i+1][vals[i].solid],vals[i].val);
		for(int j = 0 ; j <= 10000 ; j += 1){
			int currsolid = min(j-vals[i].wei,vals[i].solid);
			dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
			if(currsolid >= 0){
				dp[i+1][currsolid] = max(dp[i+1][currsolid],dp[i][j]+vals[i].val);
				ans = max(ans,dp[i+1][currsolid]);
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int const N = 5e3 + 5;
int const MOD = 1e9 + 7;

long long dp[N][N][2], g[N], cnt[N], tmp[N][N][2];
int n;

vector < int > a[N];

void plus_mod(long long &x, long long y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

void dfs(int u, int pre) {
    dp[u][1][0] = 1;
    cnt[u] = 1;
    for (int v : a[u]) {
        if (v == pre)   continue;
        dfs(v, u);


        for (int x = 1; x <= cnt[u]; x++) {
            for (int p = 0; p <= 1; p++) {
                for (int y = 1; y <= cnt[v]; y++) {
                    for (int k = 0; k <= 1; k++) {
                        plus_mod(tmp[u][x][p^k^1], (dp[v][y][k] * dp[u][x][p] % MOD * g[y]) % MOD);
                        plus_mod(tmp[u][x+y][p^k], dp[v][y][k] * dp[u][x][p] % MOD);
                    }
                }
            }
        }

        cnt[u] += cnt[v];
        for (int x = 1; x <= cnt[u]; x++) {
            for (int p = 0; p <= 1; p++) {
                dp[u][x][p] = tmp[u][x][p];
                tmp[u][x][p] = 0;
            }
        }
    }


}

int main()
{
   // freopen("inp.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }

    g[0] = 1;
    for (int i = 2; i <= n; i++) {
        g[i] = g[i-2] * (i - 1) % MOD;
    }

    dfs(1, 0);

    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        plus_mod(ans, (dp[1][i][0] - dp[1][i][1] + MOD) * g[i] % MOD);
    }

    cout << ans << endl;
}


Measured memory_bytes: 781824
fun main(args:Array<String>):Unit {
    while (true) {
        val (n, r) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && r == 0) return
        var first = 0
        Array(r){
            val (p, c) = readLine()!!.trim().split(' ').map(String::toInt)
            Pair(p, c)
        }.reversed().forEach{(p, c) ->
            when{
                first < c -> first += p - 1
                first < c + p - 1 -> first -= c
                else -> Unit
            }
        }
        println(n - first)
    }
}


Measured memory_bytes: 37968
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
using namespace std;
#define MOD 1000000007
#define REP(m,n) for(int i=m;i<n;++i)
#define REPj(m,n) for(int j=m;j<n;++j)
#define INF 10000000000000000
#define ll long long
#define mp make_pair

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	if (abs(n - a) < abs(n - b)) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}
	return 0;
}

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

using namespace std;

int main ()
{
  string s;
  int count = 0;
  cin >> s;

  for (int i = 0;i < s.length();i++) {
    if (s[i] == '7') {
      count++;
    }
  }

  if (count == 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }

  return 0;

}


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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
int n;
int res = 0;
struct node {
    int id;
    int parent;
};

node v[100];
vector<tuple<int, int, int>> cost;
vector<int> path;

int find(node x){
    if(x.parent == -1){
        REP(i, path.size())
            v[path[i]].parent = x.id;
        path.clear();
        return x.id;
    }
    else{
        path.push_back(x.id);
        return find(v[x.parent]);
    }
}

void marge(node x, node y){
    int x_id = find(x);
    int y_id = find(y);
    if(x_id == y_id)
        return;
    else
        v[y_id].parent = x_id;
    return;
}

bool judge(node x, node y){
    vector<int> xpath, ypath;
    return find(x) == find(y);
}

int main() {
    cin >> n;
    REP(i, n) REP(j, n) {
        int tmp;
        cin >> tmp;
        if(tmp != -1)
            cost.push_back(make_tuple(tmp, i, j));
    }
    REP(i, n){
        v[i].id = i;
        v[i].parent = -1;
    }
    sort(ALL(cost));
    REP(i, cost.size()){
        node from = v[get<1>(cost[i])];
        node to = v[get<2>(cost[i])];
        if(judge(from, to)){
            continue;
        }
        res += get<0>(cost[i]);
        marge(from, to);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1344
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
 
int main(){
    long int k; cin>>k;
    long int n=50;
    long int q=k/n, r=k%n;
    cout<<n<<endl;
    FOR(i,0,r){
        cout<<2*n+q-r<<" ";
    }
    FOR(i,0,50-r){
        cout<<n+q-r-1<<" ";
    }
    return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  string[] s; readC(3, s);

  auto t = 0, i = new int[](3);
  for (;;) {
    if (i[t] >= s[t].length) {
      writeln(cast(char)('A'+t));
      return;
    }
    t = cast(int)(s[t][i[t]++]-'a');
  }
}


Measured memory_bytes: 256
/*  ex3_3 Digits
    pandacodeb*/

#include <stdio.h>

int main(void){
    int n, k;
    scanf("%d %d", &n, &k);
    int digits = 0;
    while (n > 0){
        n = n / k;
        digits++;
    }
    printf("%d\n", digits);
    return 0;
}

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

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

int main(void){

    int N,i,j,k,L[2001],s,ans=0;

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

    qsort(L,N,sizeof(int),compare_int);

    for(i = 0;i < N;i++){
        for(j = i + 1;j < N;j++){
            for(k = j + 1;k < N;k++){
                if(L[i] + L[j] > L[k]){
                    ans++;
                }else{
                    break;
                }
            }
        }
    }

    printf("%d\n",ans);
    return 0;
}

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

const int MAX_N = int(1e5) + 10;
const int INF = 0x3f3f3f3f;

int n, tot;
int a[MAX_N], cnt[5], val[5];

int main() {
	scanf("%d", &n);
	bool flag = false;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		flag |= (a[i] != 0);
	}
	if (!flag) {
		puts("Yes");
		return 0;
	}

	std::sort(a + 1, a + n + 1);
	a[0] = INF;
	for (int i = 1; i <= n; ++i) {
		if (a[i] != a[i - 1]) {
			++tot;
			cnt[tot] = 1;
			val[tot] = a[i];
		} else ++cnt[tot];
		if (tot > 3) {
			puts("No");
			return 0;
		}
	}

	if (n % 3 == 0) {
		if (tot == 3) {
			if ((val[1] ^ val[2] ^ val[3]) == 0 && cnt[1] == n / 3 && cnt[2] == n / 3)
				puts("Yes");
			else
				puts("No");
		} else if (tot == 2) {
			if (val[1] == 0 && cnt[1] == n / 3) {
				puts("Yes");
			} else {
				puts("No");
			}
		} else puts("No");
	} else {
		puts("No");
	}
}

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	double L;
	cin >> L;
	double x, y, z;
	x = y = z = L / 3.0;
	cout << fixed << setprecision(12) << x * y * z << '\n';
	return 0;
}

Measured memory_bytes: 384
n =  int(input())
arr = input().split()
arr = [int(x) for x in arr]
counts = []
temp = 0
for i in range(n-1):
    if arr[i] >= arr[i+1]:
        temp += 1
        #print(temp)
        counts.append(temp)
    else:
        #counts.append(temp)
        temp = 0
if not counts:
    print(0)
else:
    print(max(counts))

Measured memory_bytes: 14224
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
double rs[10];

int main() {
  while (scanf("%d", &n) > 0) {
    REP(i, n) { scanf("%lf", &rs[i]); }
    sort(rs, rs + n);
    double ans = 0.0;
    do {
      for (int last = 3; last <= n; last++) {
        double left = 0.0;
        double right = PI;
        REP(iter, 50) {
          double mid = (left + right) / 2.0;
          double lans = rs[0] * rs[1] * sin(mid) / 2.0;
          double sum = mid;
          for (int i = 1; i < last; i++) {
            double v = rs[0] * rs[1] / rs[i] / rs[(i + 1) % last] * cos(mid);
            if (v > 1) { v = 1; }
            if (v < -1) { v = -1; }
            double theta = acos(v);
            sum += theta;
            lans += rs[i] * rs[(i + 1) % last] * sin(theta) / 2.0;
          }
          if (sum > 2 * PI) {
            right = mid;
          } else {
            left = mid;
          }
          if (fabs(sum - 2 * PI) < EPS) { ans = max(ans, lans); }
        }
      }
    } while (next_permutation(rs, rs + n));
    printf("%.8f\n", ans);
  }
}

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

using namespace std;

string s,t;

int n,m;

int main()
{
    string x;
    cin >> s >> t >> n >> m >> x;
    if(x==s)n--;
    else if (x==t) m--;
    cout << n << " " << m << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
 
#define MAX 10000
 
int par[MAX],rank[MAX];
 
void init(int n){
  int i;
  for(i = 0 ; i < n ; i++){
    par[i] = i;
    rank[i] = 0;
  }
}
 
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}
 
void unite(int x,int y){
  x = find(x);
  y = find(y);
 
  if(x == y) return;
 
  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]){
      rank[x]++;
    }
  }
}
 
int same(int x,int y){
  return find(x) == find(y);
}
 
int main(){
  int n,q,i,com,x,y;
 
  scanf("%d%d" ,&n ,&q);
  init(n);
  for(i = 0 ; i < q ; i++){
    scanf("%d%d%d" ,&com ,&x ,&y);
 
    if(com == 0){
      unite(x,y);
    }else{
      if(same(x,y)){
    puts("1");
      }else{
    puts("0");
      }
    }
  }
 
  return 0;
}


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

const int N = 1E5 + 10;

int n, a[N];

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  int len = unique(a + 1, a + 1 + n) - (a + 1);
  if((n - len) % 2) cout << len - 1 << endl;
  else cout << len << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long 
#define MAXN 1000010

using namespace std;

int n, m, d, x;
int f;
int a[MAXN];
int t;
string s;

int main() {
	scanf("%d", &n);
	scanf("%d", &m);
//	for (int i = 1; i <= n; i++) {
//		scanf("%d", &a[i]);
//	}
	t = 1;
	while (t < m) {
		t += n - 1;
		f++;
	}
	cout << f << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;

int main(void){
	int n,k;
	cin>>n>>k;
	int cnt=0;
	while(n>0){
		n/=k;
		cnt++;
	}
	cout<<cnt;
	return 0;
}

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

#define st first
#define nd second
const int N = 1e5+5, INF = -1e4-5;
int n, a[N], pos = 0;
bool checkNeg = 0, checkPos = 0;
vector<pair<int,int>> ans;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] < 0) checkNeg = 1;
        else if (a[i] > 0) checkPos = 1;
    }
    sort(a,a+n);
    if (checkPos && checkNeg)
    {
        for (int i = 0; i < n; i++)
        {
            if (a[i] < 0 && a[i+1] >= 0)
            {
                pos = i;
                break;
            }
        }
        for (int i = pos+2; i < n; i++)
        {
            ans.push_back({a[pos],a[i]});
            a[pos] -= a[i];
        }
        for (int i = pos-1; i >= 0; i--)
        {
            ans.push_back({a[pos+1],a[i]});
            a[pos+1] -= a[i];
        }
        cout << a[pos+1] - a[pos] << endl;
            ans.push_back({a[pos+1],a[pos]});
        for (auto x: ans)
        {
            cout << x.st << ' ' << x.nd << endl;
        }
    }
    else if (checkPos && !checkNeg)
    {
        for (int i = 2; i < n; i++)
        {
            ans.push_back({a[0],a[i]});
            a[0] -= a[i];
        }
        ans.push_back({a[1],a[0]});
        cout << a[1] - a[0] << endl;
        for (auto x: ans)
        {
            cout << x.st << ' ' << x.nd << endl;
        }
    }
    else
    {
        for (int i = n-2; i >= 0; i--)
        {
            ans.push_back({a[n-1],a[i]});
            a[n-1] -= a[i];
        }
        cout << a[n-1] << endl;
        for (auto x: ans)
        {
            cout << x.st << ' ' << x.nd << endl;
        }
    }
}
/*
3
-2 -3 -4
*/


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;



int main()
{
    fastInp;

    ll n;
    cin >> n;
    vector<ll> vec(n);
    for (auto &cur : vec) cin >> cur;

    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                ll mx = max(max(vec[i], vec[j]), vec[k]);
                if (vec[i] != vec[j] && vec[j] != vec[k] && vec[k] != vec[i] &&  i != j && j != k && k != i && mx < (vec[i] + vec[j] + vec[k] - mx)) {
                    cnt++;
                }
            }
        }
    }
    
    cout << cnt / 6;

    return 0;
}

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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

long long p = 1e9+7.5;

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

    cin>>n;
    vector<int> s(n+4);
    s[0]=s[1]=s[2]=0, s[3]=1;
    forn(i,4,n+1){
    	s[i]++;
    	forn(j,0,i-2)
    		s[i]+=s[j], s[i]%=p;
    }
    cout<<s[n]<<'\n';
    
    return 0;
}

Measured memory_bytes: 3652
/*D - String Formation*/

#include <bits/stdc++.h>
using namespace std;

int main(){

	string izq = "";
	string der = "";
	int operations;
	int rev = 0;
	string cad;
	int op;
	int w;

	cin >> cad >> operations;
	int pal = 0; // 1 reversa

	while(operations--){

		cin >> op;

		if(op == 1){
			rev++;
			pal = 1 - pal;
		}
		else{
			char letra;
			cin >> w >> letra;

			if(rev % 2 == 0){
				if(w == 1)
					izq += letra;
				else
					der += letra;
			}
			else{
				if(w == 1)
					der += letra;
				else
					izq += letra; 
			}
			
		}
	}

	if(rev % 2 == 0){

		for (int i = izq.size() - 1; i >= 0 ; --i)
			cout << izq[i];

		cout << cad;

		for (int i = 0; i < der.size(); ++i)
			cout << der[i];
		
	}
	else{
		for (int i = der.size() - 1; i >= 0 ; --i)
			cout << der[i];

		reverse(cad.begin(), cad.end());
		cout << cad;

		for (int i = 0; i < izq.size(); ++i)
			cout << izq[i];
	}



	return 0;
}

Measured memory_bytes: 1088
// Problem : C - Triangular Relationship
// Contest : AtCoder Regular Contest 102
// URL : https://atcoder.jp/contests/arc102/tasks/arc102_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

int n, k;

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n >> k;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		if ((i * 2) % k == 0) {
			int x = n - i % k;
			int p = i % k == 0 ? x / k : x / k + 1;
			ans += 1ll * p * p;
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#define max(a,b) ((a)>(b)?(a):(b))
r;main(i,N,X,Y,x,y){
	scanf("%d%d%d%d%d",&N,&N,&N,&X,&Y);
	for(;i<N;i++){
		scanf("%d%d",&x,&y);
		if((x-X)*(y-Y)>0)r+=max(abs(x-X),abs(y-Y));
		else r+=abs(x-X)+abs(y-Y);
		X=x,Y=y;
	}
	r=!printf("%d\n",r);
}

Measured memory_bytes: 596
=begin
N = gets.to_i               # 単一整数
a = gets.split.map(&:to_i)  # スペースで区切られた複数の整数
a = N.times.map{gets.to_i}  # 縦に並んだ複数の整数。たまにある
s = gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
=end
N = gets.to_i
puts N ** 2

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define vl          vector<ll>
#define ld          long double
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pi          3.14159265358979323


void solve()
{
       map<ll,ll>cnt;
       ll n; cin>>n;
       ll mx=0;
       ll a[n],b[n];
       rep(i,0,n) { cin>>a[i]; cnt[a[i]]++; mx=max(mx,a[i]); b[i]=a[i]; }
       sort(b,b+n);
       rep(i,0,n)
       {
              if(a[i]!=mx) { cout<<mx<<endl; }
              else if(a[i]==mx)
              {
                     if(cnt[mx]==1) { cout<<b[n-2]<<endl; }
                     else { cout<<mx<<endl; }
              }
       }
}

int main(){
	int T = 1;
       //pre();
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


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


int main() {

    int n;
    cin >> n;
    vector<int> w(n);
    int ans = 10000;
    rep(i,n) cin >> w[i];
    for (int t = 1; t < n; ++t) {
        int s_1 = 0, s_2 = 0;
        for (int i = 1; i <= n; ++i) {
            if (i <= t) s_1 += w[i-1];
            else s_2 += w[i-1];
        }
        ans = min(ans, abs(s_1 - s_2));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N, K;

int main () {
  cin >> N >> K;
  int ans = 0;
  rep(i,N) {
    int x;
    cin >> x;
    ans += min(x, K-x);
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}


int main() {
	ll A, B, K, t, a; cin >> A >> B >> K;
	t = A, a = B;
	REP(i,K){
		if(i%2==0){
			t -= (t % 2);
			a += t / 2;
			t /= 2;
		}
		else{
			a -= (a % 2);
			t += a / 2;
			a /= 2;
		}
	}
	cout << t << " " << a << endl;
	
	return 0;
}



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

std::vector<int> color;
std::vector<std::vector<int>> M;
std::vector<int> d;
std::vector<int> p;
int INF = 1001001001;
int sum = 0;

void dijkstra(int n){
    for(int i = 0; i < n; i++){
        color[i] = 0;
        d[i] = INF;
    }

    d[0] = 0;
    p[0] = -1;

    while(true){
        int u;
        int mincost = INF;
        for(int i = 0; i < n; i++){
            if(color[i] != 1 && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }

        if(mincost == INF){
            break;
        }

        color[u] = 1;

        for(int i = 0; i < n; i++){
            if(color[i] != 1 && M[u][i] != -1){
                if(d[u] + M[u][i] < d[i]){
                    d[i] = d[u] + M[u][i];
                }
            }
        }

    }
    
    for(int i = 0; i < d.size(); i++){
        sum += d[i];
    }

}

int main(void){
    int n;
    std::cin >> n;

    color.resize(n);

    M.resize(n, std::vector<int>(n));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            M[i][j] = INF;
        }
    }

    d.resize(n);
    p.resize(n);

    int u, k, v;

    for(int i = 0; i < n; i++){
        std::cin >> u >> k;
        for(int i = 0; i < k; i++){
            std::cin >> v;
            std::cin >> M[u][v];
        }
    }
    
    
    dijkstra(n);
    
    for(int i = 0; i < n; i++){
        std::cout << i << " " << d[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3200
package main

import "fmt"

func main() {
	var N, x int
	fmt.Scan(&N, &x)
	a := make([]int, N)
	for i := range a {
		fmt.Scan(&a[i])
	}
	var i, ans int
	for i+1 < N {
		if a[i]+a[i+1] < x {
		} else {
			// a[i+1]の箱からできるだけ多く食べ、足りなければa[i]からも食べる
			d := (a[i] + a[i+1]) - x // 全体の差分
			ans += d
			a[i+1] -= min(a[i+1], d)
		}
		i++
	}
	fmt.Println(ans)
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  string a,b; cin>>a>>b;
  ll n=a.size(), m=b.size();
  string less="LESS", greater="GREATER", eq="EQUAL";
  string ans;
  if(n==m){
    if(a<b) ans=less;
    if(a>b) ans=greater;
    if(a==b) ans=eq;
  }else{
    if(n>m) ans=greater;
    else ans=less;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

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

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        a--;
    }
    cout << a;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3636