akhauriyash/Code-Regression huggingface dataset:
/*include*/
#include <bits/stdc++.h>

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

/*funcs*/

/*input*/

int a[5];
int b[5];

/*main*/
int main(){
    int ans=0;
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
    for(int i=0;i<5;i++){
        if(a[i]%10==0){
            ans=ans+a[i];
            b[i]=0;
        }else{
            ans=ans+a[i]+10-(a[i]%10);
            b[i]=a[i]%10;
        }
    }
    sort(b,b+5);
    int p=b[0];
    for(int i=0;i<5;i++){
        if(p==0){
            p=b[i];
        }else{
          if(i==4){
          	p=b[4];
          }
            break;
        }
    }
    if(p!=0){
    cout<<ans-10+p;
    }else{
        cout<<ans;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
int main()
{
  // fopen();
    int n,k;
    cin>>n>>k;
    int a[n];
    rep(i,n) {cin>>a[i];}
    sort(a,a+n,greater<int>());
    ll s=0;
    repA(k,i,n){s+=a[i];}
    cout<<s;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<min(a,b)*c+max(a-b ,0ll)*d<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    string s, t;
    cin >> s >> t;
    cout << ((t.substr(0, s.size()) == s) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3612
N = int(input())
a = [int(input()) for i in range(N)]
isFound = False
ai = 1
for i in range(1, N + 1):
    ai = a[ai - 1]
#    print(f'a{i} = {ai}')
    if (ai == 2):
        isFound = True
        print(i)
        break
if (isFound is False):
    print(-1)


Measured memory_bytes: 7084
a = [[10*[0]for _ in[0]*3]for _ in[0]*4]
n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    a[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        print('',*a[i][j])
    if i < 3:
        print('#'*20)


Measured memory_bytes: 5624
import java.io.*;
import java.util.*;
public class Main
{
	int n,bigmask;
	char s[];
	HashMap<String,Integer> map;
	long ans;
	private void solve()throws IOException
	{
		n=nextInt();
		s=(" "+nextLine()).toCharArray();
		bigmask=(1<<n)-1;
		map=new HashMap<>();
		ans=0;
		init();
		find();
		out.println(ans);
	}
	void init()
	{
		for(int mask=0;mask<=bigmask;mask++)
		{
			StringBuilder red=new StringBuilder();
			StringBuilder blue=new StringBuilder();
			for(int i=1;i<=n;i++)
				if(((mask>>(i-1))&1)==1)
					red.append(s[i]);
				else
					blue.append(s[i]);
			String str=red+"#"+blue;
			map.put(str,map.getOrDefault(str,0)+1);
		}
	}
	void find()
	{
		for(int mask=0;mask<=bigmask;mask++)
		{
			StringBuilder red=new StringBuilder();
			StringBuilder blue=new StringBuilder();
			for(int i=1;i<=n;i++)
				if(((mask>>(i-1))&1)==1)
					red.append(s[n+i]);
				else
					blue.append(s[n+i]);
			String str=blue.reverse()+"#"+red.reverse();
			ans+=map.getOrDefault(str,0);
		}
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 135224
N = int(input())
A = list(map(int, input().split()))

idx = {A[i]: i for i in range(N)}
 
ans = 0
idx_l, idx_r = list(range(N + 2)), list(range(N + 2))
for a in range(N, 0, -1):
    i = idx[a]
    l, r = idx_l[i], idx_r[i]
    ans += a * (i - l + 1) * (r - i + 1)
    idx_l[r + 1], idx_r[l - 1] = l, r
    
print(ans)

Measured memory_bytes: 47900
import math

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
A = [9] * N
B = [9] * N
Pcount = 0
Qcount = 0
Pnum = 1
Qnum = 1
Ans = 0

for i in range(N-1):
  for j in range(N):
    if P[i] > A[j]:
      Pcount = Pcount + 1
  
  for k in range(N):
    if Q[i] > B[k]:
      Qcount = Qcount + 1
    
  Pnum = Pnum + math.factorial(N - i - 1) * (P[i] - 1 - Pcount)
  Qnum = Qnum + math.factorial(N - i - 1) * (Q[i] - 1 - Qcount)
  
  A[i] = P[i]
  B[i] = Q[i]
  Pcount = 0
  Qcount = 0


Ans = abs(Pnum - Qnum)
#print(Pnum)
#print(Qnum)
print(Ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
#include <map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>
 
class DisjointSet {
    public:
    std::vector<int> par;
    DisjointSet() {}
    DisjointSet(int n){
        par.resize(n, 0);
        for(int i = 0; i < n; i++){
            par[i] = i;
        }
    }

    void simplify(int x) {
        std::vector<int> path;
        while (par[x] != x) {
            path.push_back(x);
            x = par[x];
        }
        for (int p : path) {
            par[p] = x;
        }
    }
    
    int find(int x){
        simplify(x);
        return par[x];
    }
    
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if (x != y) {
            par[y] = x;
        }
    }
};

const int MAX_N = 200050;
const int MAX_K = 100050;

int N, K, L;
int p[MAX_K], q[MAX_K], r[MAX_K], s[MAX_K];

DisjointSet ds1 = DisjointSet(MAX_N);
DisjointSet ds2 = DisjointSet(MAX_N);
 
int main(void){
    std::cin >> N >> K >> L;

    for (int i = 1; i <= K; i++) {
        std::cin >> p[i] >> q[i];
    }
    for (int i = 1; i <= L; i++) {
        std::cin >> r[i] >> s[i];
    }
    
    for(int i = 1; i <= K; i++){
        ds1.unite(p[i], q[i]);
    }
    
    for(int i = 1; i <= L; i++){
        ds2.unite(r[i], s[i]);
    }
    
    std::unordered_map<long long, int> S;
    for(int i = 1; i <= N; i++){
        long long tmp = (long long)ds1.find(i) * MAX_N + ds2.find(i);
        if (S.find(tmp) != S.end()) {
            S[tmp] += 1;
        } else {
            S[tmp] = 1;
        }
        
    }
    
    for(int i = 1; i <= N; i++){
        long long tmp = (long long)ds1.find(i) * MAX_N + ds2.find(i);
        std::cout << S[tmp] << " ";
    }
    std::cout << std::endl;
    
    return 0;
}

Measured memory_bytes: 11464
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args)throws Exception {
//
//		Scanner sc = new Scanner(System.in);
//		BigInteger n = sc.nextBigInteger();
//	      boolean flag=solve(n);
//	      if(flag==true)
//	        System.out.println("Yes");
//	      else
//	    	  System.out.println("No");
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
        StringTokenizer st = new StringTokenizer(br.readLine());
        int max=-1;
        long sum=0;
        for(int i=0; i<n; i++){
        	int k = Integer.parseInt(st.nextToken());
        	if(i==0) {
        		max=k;
        	}
        	else {
        		if(max>k) {
        			sum+=max-k;
        			k=max;
        		}
        		else {
        			max=Math.max(k, max);
        		}
        	}
        }
        System.out.println(sum);
        
	        
	}

	

}


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

signed main() {
    string n;
    cin >> n;
    cout << count_if(be(n), [](char c){ return c == '2'; }) << nl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define mod 998244353
#define maxn 200010
#define LL long long
using namespace std;
LL fact[maxn],inv[maxn],ans,t[maxn],p;
int n,m,k,nm;
LL quick_pow(LL a,LL b){//a^b
	LL ans=1;
	while(b){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans%mod;
}
void init(){
	int i;
	scanf("%d%d%d",&n,&m,&k);
	nm=n,nm=max(nm,m),fact[0]=1;
	for(i=1;i<=nm;i++)fact[i]=fact[i-1]*i%mod;
	inv[nm]=quick_pow(fact[nm],mod-2);
	for(i=nm-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
LL C(LL a,LL b){
	return fact[a]*inv[a-b]%mod*inv[b]%mod;
}
int main(){
	int i;
	init();
	ans=0,p=quick_pow(m-1,n-k-1);
	for(i=n-k;i<=n;i++){
		ans=(ans+m*p%mod*C(n-1,i-1)%mod)%mod;
		p=p*(m-1)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6188
fun main(args: Array<String>) {
  val id = readLine()!!;
  val id2 = readLine()!!;
  
  for (i in 0 .. id2.length - 2) {
    if (id[i] == id2[i]) {
      continue
    }
    println("No")
    return
  }
  print("Yes")
  return
}

Measured memory_bytes: 34416
import sys
n = int(sys.stdin.readline())

L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
L.insert(0, [0,0,0])
flag='Yes'
for i in range(1, n+1):
    tmp = L[i][0] - L[i-1][0] -abs(L[i][1] - L[i-1][1]) - abs(L[i][2] - L[i-1][2])
    if tmp<0 or tmp%2!=0:
        flag='No'
        break
print(flag)

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

bool pairCompare(const std::pair<int, int>& firstElem, const std::pair<int, int>& secondElem) {
    return firstElem.second < secondElem.second;
}

int main(){
    int n;
    while(cin >> n, n){
        vector<pair<int ,int> > v;
        rep(i,n){
            int id;
            cin >> id;
            int t = 0;
            rep(j, 4){
                int m, s;
                cin >> m >> s;
                t += m*60+s;
            }
            v.pb(mp(id, t));
        }
        sort(all(v), pairCompare);

        rep(i, 2){
            cout << v[i].first << endl;
        }
        cout << v[v.size()-2].first << endl;
    }
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,count =0;
    bool flgA = false; 
    bool flgB = false;
    cin >> a >> b >> c >> d;
    
    for(int i=0; i<101 ;i++){
        if(i>=a && i <= b){
            flgA = true;
        }
        if(i >=c && i<=d){
            flgB = true;
        }
        
        if((flgA == true )&&flgB){
            count++;
        }
        flgA = false;
        flgB = false;
    }
    
    cout << ((count<=0)?0:count-1)<< endl;
    
    return 0;
}

Measured memory_bytes: 384
n = int(input())

result = 1
max_c = 0
for i in range(1, n + 1):
    tmp = i
    count = 0
    while tmp > 0 and tmp % 2 == 0:
        tmp = int(tmp / 2)
        count += 1
    if max_c < count:
        max_c = count
        result = i

print(result)


Measured memory_bytes: 2940
#include <stdio.h>
#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;



int L[MAX/2+2],R[MAX/2+2];
llong merge(int A[] , int n , int left , int mid , int right)
{
	int i , j , k;
	llong cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for( i = 0; i < n1;i++) L[i] = A[left+i];
	for( i = 0; i < n2;i++) R[i] = A[mid+i];
	L[n1] = R[n2] = SENTINEL;
	i = j = 0;
	for( k = left; k < right; k++)
	{
		if(L[i] <= R[j])
		{
			A[k] = L[i++];
		}
		else{
			A[k] = R[j++];
			cnt += n1 -i;
		}
	}
	return cnt;
}

llong mergeSort(int A[] , int n , int left , int right)
{
	int mid;
	llong v1, v2, v3, a;
	if(left + 1 < right){
		mid =( left + right)/2;
		v1 = mergeSort(A,n,left,mid);
		v2 = mergeSort(A,n,mid,right);
		v3 = merge(A,n,left,mid,right);
		a = v1+v2+v3;
		return a;
	}
	else return 0;
}


int main(void)
{
    int A[MAX],n,i;
	scanf("%d",&n);
	//cin >> n;
    for( i = 0; i < n;i++)
    {
    	scanf("%d",&A[i]);
        //cin >> A[i];
    }
    llong ans = mergeSort(A,n,0,n);
	printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3312
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int N;
  string in;
  int ans = 0;
  int enda = 0;
  int startb = 0;
  int sb_ea = 0;
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> in;
    int ix = 0;
    while((ix = in.find("AB", ix)) >= 0) {
      ans++;
      ix++;
    }
    if(in[in.size()-1] == 'A'){
      if(in[0] == 'B')sb_ea++;
      else enda++;
    }
    else if(in[0] == 'B') startb++;
  }
  if(enda > 0 && startb > 0){
    ans += min(enda, startb);
    ans += sb_ea;
  }
  else if(enda > 0){
    ans += sb_ea;
  }
  else if(startb > 0){
    ans += sb_ea;
  }
  else if(sb_ea > 0){
    ans += (sb_ea - 1);
  }

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


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll a = in(), b = in();
	ll cnt = 0;
	for (ll i = a; i <= b; ++i) {
		if (i % 10 == i / 10000 && i / 10 % 10 == i / 1000 % 10) {
			++cnt;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
ctypedef long long LL
# cython: cdivision=True
from libc.stdio cimport scanf
from libcpp.vector cimport vector
ctypedef vector[LL] vec

cdef LL R,C,K,i,j,k

scanf("%lld %lld %lld",&R,&C,&K)

cdef vector[vector[LL]] dp = [[0 for j in range(3)] for i in range(C)]
cdef vector[vector[LL]] ndp = [[0 for j in range(3)] for i in range(C)]
cdef vector[vector[LL]] item = [[0 for j in range(C)] for i in range(R)]
cdef LL r,c,v

for i in range(K):
    scanf("%lld %lld %lld",&r,&c,&v)
    item[r-1][c-1] = v

dp[C-1][0] = item[R-1][C-1]
dp[C-1][1] = item[R-1][C-1]
dp[C-1][2] = item[R-1][C-1]

for j in range(C-2,-1,-1):
    dp[j][0]=max(dp[j+1][1]+item[R-1][j],dp[j+1][0])
    dp[j][1]=max(dp[j+1][2]+item[R-1][j],dp[j+1][1])
    dp[j][2]=max(item[R-1][j],dp[j+1][2])

for i in range(R-2,-1,-1):
    ndp = [[0 for j in range(3)] for i in range(C)]
    ndp[C-1][0]=dp[C-1][0]+item[i][C-1]
    ndp[C-1][1]=dp[C-1][0]+item[i][C-1]
    ndp[C-1][2]=dp[C-1][0]+item[i][C-1]
    for j in range(C-2,-1,-1):
        ndp[j][0]=max(max(dp[j][0],ndp[j+1][1])+item[i][j],ndp[j+1][0])
        ndp[j][1]=max(max(dp[j][0],ndp[j+1][2])+item[i][j],ndp[j+1][1])
        ndp[j][2]=max(dp[j][0]+item[i][j],ndp[j+1][2])
    dp=ndp

print(dp[0][0])

'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Measured memory_bytes: 229708
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var N, K int

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &K)

	as := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
	}

	dp := make([]bool, K+1)
	for i := 1; i < K+1; i++ {
		v := false
		for _, a := range as {
			if a <= i && dp[i-a] == false {
				v = true
				break
			}
		}
		dp[i] = v
	}

	if dp[K] {
		fmt.Println("First")
	} else {
		fmt.Println("Second")
	}
}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int a[60];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	int sum=0;
	for(int i=1;i<=k;i++) sum+=a[n-i];
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0532
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] lineA = ReadIntAr();
            int[] lineB = ReadIntAr();
            int[] lineC = ReadIntAr();
            List<int[]> employee = new List<int[]>() { lineA, lineB, lineC };

            foreach (var item in employee)
            {
                int attendanceTime = item[0] * 3600 + item[1] * 60 + item[2];
                int leavingTime = item[3] * 3600 + item[4] * 60 + item[5];
                int workingTimes = leavingTime - attendanceTime;

                int h = workingTimes / 3600;
                int m = (workingTimes % 3600) / 60;
                int s = (workingTimes % 3600) % 60;

                Console.WriteLine("{0} {1} {2}", h, m, s);
            }        
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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

void dfs(int i, string s, int n){
    if(i == n){
        cout << s << endl;
        return;
    }
    char m = 'a';
    for(int j = 0; j < i; j++) m = max(m, s[j]);
    m++;
    for(int j = 0; 'a' + j <= m; j++) dfs(i + 1, s + char('a' + j), n);
    return;
}

int main()
{
    int n;
    cin >> n;
    dfs(1, "a", n);
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}


int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    lp(0,n) cin>>a[i];
    sort(a, a+n);
    ll ans=0;
    ans += a[n-1];
    int t=n;
    n-=2;
    for(int i=t-2; n>0; i--){
        if(n>=2){
            //cout<<ans<<" "<<n<<" "<<a[i]<<endl;
            ans += (2*a[i]);
            n-=2;
        }
        else{
            ans += a[i];
            n--;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N, K; cin >> N >> K;
  vector<vector<ll>> edges(N);
  bool visited[N] = {true};
  ll prev[N] = {-1}, ptn[N] = {K};
  vector<ll> nodes(1, 0);

  rep(_, N-1){
    ll a, b;
    cin >> a >> b;
    edges[a-1].push_back(b-1);
    edges[b-1].push_back(a-1);
  }
  rep(i, N){
    ll cnt = 1 + (i > 0);
    for(ll nxt : edges[nodes[i]]){
      if(!visited[nxt]){
        visited[nxt] = true;
        nodes.push_back(nxt);
        prev[nxt] = nodes[i];
        ptn[nxt] = K - cnt;
        cnt++;
      }
    }
  }
  rrep(i, N){
    if(i > 0)
      ptn[prev[nodes[i]]] = (ptn[prev[nodes[i]]] * ptn[nodes[i]]) % MOD;
  }
  cout << ptn[0] << endl;
  return 0;
}


Measured memory_bytes: 9716
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

/*
操作を逆からみる．一度塗られた場所はもう塗られない
操作の方法は(v,d)のペアの数だけある（visitedで管理）
f(v,d,c)：vからd以内の点をcで塗る
はf(v,d-1,c)とf(u,d-1,c)に分解できる．
*/

ll n,m,visited[100010][11],color[100010]={},q,vq[100010],dq[100010],cq[100010];
vector<ll> v[100010];

void f(ll p,ll d,ll c){
	if(visited[p][d]==1)return;
	if(d==0){
		color[p]=c;
	}else{
		f(p,d-1,c);
		rep(i,v[p].size()){
			f(v[p][i],d-1,c);
		}
	}
	visited[p][d]=1;
}

int main(void){
	cin>>n>>m;
	rep(i,100010)rep(j,11)visited[i][j]=0;
	rep(i,m){
		ll a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	cin>>q;
	rep(i,q)cin>>vq[i]>>dq[i]>>cq[i];
	irep(i,q){
		f(vq[i],dq[i],cq[i]);
		// reg(i,1,n)printf("%lld ",color[i]);
		// printf("\n");
	}
	reg(i,1,n)cout<<color[i]<<endl;
	return 0;
}

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

ll Pow(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

bool cmp(const int &a, const int &b){
    return a > b;
}

int gcd(int x, int y){
    return x % y == 0 ? y : gcd(y, x % y);
}

int n, m;
int u[100005], v[100005];
int s, t;

int main(){
    char s[4];
    cin>>s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
        printf("Bad\n");
    else printf("Good\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++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)

int  main()
{
	int n, k; cin >> n >> k;
	vector<int> v(n);
	rep(i, n)
		cin >> v[i];
	sort(v.rbegin(), v.rend());
	int ans = 0;
	rep(i, k)
		ans += v[i];
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 256
def main():
    N = int(input())
    names = []
    for _ in range(N):
        names.append(input())
    d = dict()
    for s in names:
        if s[0] in "MARCH":
            d[s[0]] = d.get(s[0], 0) + 1
    ans = 0
    for c0 in d:
        for c1 in d:
            for c2 in d:
                if c0 < c1 < c2:
                    ans += d[c0]*d[c1]*d[c2]
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 9752
z = input().split()
x = int(z[0])
a = int(z[1])
b = int(z[2])
A = x - a
B = x - b
if A < 0:
  A = A*-1
if B < 0:
  B = B*-1
if A > B:
  print('B')
else:
  print('A')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, k; cin >> n >> k;
  int h[n];
  for(int i=0; i<n; i++) cin >> h[i];
  int count=0;
  for(int i=0; i<n; i++){
    if(h[i]>=k) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 640
N = int(input())
H = list(map(int,input().split()))
H = [0]+H+[0]
def trm(li):
  for i in range(len(li)-2,0,-1):
    if li[i-1]<=li[i]<=li[i+1]:
      li.pop(i)
    elif li[i-1]>=li[i]>=li[i+1]:
      li.pop(i)
  return H
H = trm(H)
cnt = 0
for i in range(max(H),0,-1):
  flg = False
  for j in range(len(H)):
    if H[j]==i:
      if not flg:
        cnt +=1
        flg = True
      H[j]=H[j]-1
    else:
      flg = False
print(cnt)

Measured memory_bytes: 3064
#!/usr/bin/env python3

S = input()[::-1]

Moji = ['maerd', 'remaerd', 'resare', 'esare']

while len(S)!=0:

    if S[:5] == Moji[0] or S[:5] == Moji[3]:
        S = S[5:]
    elif S[:6] == Moji[2]:
        S = S[6:]
    elif S[:7] == Moji[1]:
        S = S[7:]
    else:
        print('NO')
        exit()

print('YES')


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

using namespace std;

int a,b,c;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> a >> b >> c;

    cout << min(a+b,min(b+c,a+c)) << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  string S;
  int64_t N;

  cin >> S;

  N = S.size();

  for (int i = 0; i < (N + 1) / 4; i++) {
    if (S[i] != S[(N - 1) / 2 - 1 - i] |
        S[i] != S[(N + 3) / 2 - 1 + i] |
        S[i] != S[N - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int main()
{
	// freopen("CF17-QA-F.in", "r", stdin); 
	int n, ans = 0, cur = 0; 
	scanf("%d", &n); 
	while (n--)
	{
		int x; 
		scanf("%d", &x); 
		int k = 0; 
		while (1 << k <= x)
			k++;
		k--;
		bool more = (1 << k) != x;
		if (cur < k)
			ans += k - cur; 
		else if (cur > k)
			more = false;
		cur = k; 
		if (more)
		{
			cur++;
			ans++; 
		}
	}
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 256
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
vector<int> W,R;
int main(){
    int n;
    cin >> n;
    int l[n];
    string s;
    cin >> s;
    rep(i,n){
        if(s[i]=='W'){
            W.push_back(i);
            l[i]=1;
        }else{
            R.push_back(i);
            l[i]=0;
        }
    }
    int fw=0;
    int fr=R.size()-1;
    int ans=0;
    //cerr<<fw<<fr<<endl;
    if(W.size()==0){
        cout<<0<<endl;
        return 0;
    }
    rep(i,n){
        int j=n-1-i;
        if(l[j]==0){
            if(fr<0||R[fr]<W[fw]){
                continue;
            }else if(fw>=W.size()){
                l[j]=1;
                ans++;
            }else{
                l[R[fr]]=1;
                //cerr<<R[fr];
                fr--;
                l[W[fw]]=0;
                //cerr<<W[fw]<<endl;
                fw++;
                ans++;
            }
        }
        //cerr<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5408
#include <cstdio>
#define LL long long
#define Int register int
using namespace std;
int main()
{
	LL A, B, N;
	scanf("%lld %lld %lld", &A, &B, &N);
	LL x;
	if (B <= N)
		x = (N / B) * B - 1;
	else x = N;
	printf("%lld", (A * x) / B - A * (x / B));
	return 0;
}

Measured memory_bytes: 1736
n=int(input())
t,a=map(int,input().split())
s = input().rstrip().split(' ')
gap = 300
loc = 0
for i in range(n):
  temp = t-int(s[i])*0.006
  if abs(temp-a) < gap:
    gap = abs(temp-a)
    loc = i+1
print(loc)

Measured memory_bytes: 3060
W,H=map(int,input().split())
arr=[[0 for i in range(H)] for j in range(W)]


for i in range(W):
    gyou=input()
    for j in range(H):
        arr[i][j]=gyou[j:j+1]

safe=1



for i in range(W):
    for j in range(H):
        if arr[i][j]=="#":
            if i-1 >=0 and i+1 < W  and j-1>=0 and j+1<H:
                if arr[i-1][j] == "#" or arr[i+1][j] == "#" or arr[i][j-1] == "#" or arr[i][j+1] == "#":
                    safe=1
                else:
                    print("No")
                    exit()
                    
                    
print("Yes")
        

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod  10000007
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
#define mem(a,b) memset(a,b,sizeof(a));
typedef long long ll;
const ll maxn=5000006;
//priority_queue<ll,vector<ll >,greater<ll > >q;
const ll INF=0x3f3f3f3f;
//const double E=exp(1);
//const double PI=acos(-1);
using namespace std;
//__builtin_popcount
//priority_queue

int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
ll kc(ll a,ll b){ll c=1;while(b){if(b&1)c=(c*a)%mod;a=(a*a)%mod;b>>=1;}return c;}
bool cmp(double x,double y){return x>y;}
int read(){int x=0,f=1;char s=getchar();for(; s>'9'||s<'0'; s=getchar()) if(s=='-') f=-1;for(; s>='0'&&s<='9'; s=getchar()) x=x*10+s-'0';return x*f;}
int a[maxn];
int b[maxn];
int c[maxn];
int main()
{
     ios::sync_with_stdio(false);
  /*int t;
  cin>>t;
  for(int i=1;i<=t;i++)
    cin>>a[i];
    int q=0,qq=0;;
  for(int i=1;i<t;i++)
    if(a[i]>a[i+1])
  {
      if(a[i]-a[i+1]==1&&!qq){qq=1;continue;}
      else q=1;

  }
  if(!q)cout<<"Yes\n";
  else cout<<"No\n";*/
    int t;
  cin>>t;
  int sum=0;
  for(int i=1;i<=t;i++)
  {
      int j=i;
      int ans=0;
      while(j)
      {
          ans++;
          j/=10;
      }
      if(ans&1)sum++;
  }cout<<sum<<endl;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if(a < 10 && b < 10) cout << a * b << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n;cin >> n;
    vector<int> p(n);
    rep(i,n)cin >> p[i];
    int count = 0;
    for(int i=0;i<n;i++){
        auto Min = min_element(p.begin()+i,p.end());
        int md = distance(p.begin(),Min);
        if(*Min != p[i]){
            int tmp = p[i];
            p[i] = p[md];
            p[md] = tmp;
            count++;
        }
        if(count>=2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio> 
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=100010;
int a[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=='-'?o=-1:0,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n;
    long long ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
	int x=gi(),y=gi();
	ans-=y,a[i]=x+y;
    }
    sort(a+1,a+1+n);
    for(int i=n;i>0;i-=2) ans+=a[i];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll x,t;
	int ans=0;
	cin >>x>>t;
	cout<<max(0LL,x-t)<<endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a,b,x,y; cin>>a>>b;
  x=a; y=b;
  while(x%b!=0&&y%a!=0){
    if(x<y) x+=a;
    else y+=b;
  }
  if(x%b==0) cout<<x<<endl;
  else cout<<y<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
    double x1, y1, x2, y2, x, y, ans;
    
    cin >> x1 >> y1 >> x2 >> y2;
    
    x = pow(x1 - x2, 2);
    
    y = pow(y1 - y2, 2);
    
    ans = sqrt(x + y);
    
    printf("%.5lf\n", ans);
}


Measured memory_bytes: 3276
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new RemainingTime();
			Instance.Exec();
		}
	}

	public class RemainingTime
	{
		public void Exec()
		{
			var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
			int a = (int)inputLongArray[0];
			int b = (int)inputLongArray[1];

			int time = a + b;
			time = time > 23 ? time - 24 : time;
			string result = $"{time}";

			Console.WriteLine(result);

			Console.Out.Flush();

			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 11348
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - 美しい文字列 / Beautiful Strings
            var w = Console.ReadLine();
            var chars = new Dictionary<char, int>();

            foreach(var c in w)
            {
                if (!chars.ContainsKey(c))
                {
                    chars.Add(c, 1);
                }
                else
                {
                    chars[c]++;
                }
            }

            if (IsBeautifulStrings(chars))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static bool IsBeautifulStrings(Dictionary<char, int> chars)
        {
            foreach(var v in chars.Values)
            {
                if (v % 2 != 0)
                {
                    return false;
                }
            }

            return true;
        }
    }
}

Measured memory_bytes: 13152
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int32_t main()
{
	IOS;
	int T=1;
	//cin>>T;
	while(T--)
	{
		int n,m,i;
		cin>>n>>m;
		string s="";
		int tem=n;
		while(tem--)
			s.push_back('#');
		char c;
		for(i=0;i<m;i++)
		{
			cin>>tem>>c;
			tem--;
			if(s[tem]=='#')
				s[tem]=c;
			else if(s[tem]!=c)
			{
				cout<<-1;
				return 0;
			}
		}
		if(n==1)
		{
			if(s[0]=='#')
			{
				s[0]='0';
			}
			cout<<s;
			return 0;
		}
		if(s[0]=='0')
		{
			cout<<-1;
			return 0;
		}
		if(s[0]=='#')
			s[0]='1';
		for(i=1;i<n;i++)
		{
			if(s[i]=='#')
				s[i]='0';
		}
		cout<<s;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		String s = in.readString(); 
		int index = s.length();
	    while(true) {
	    	index--;
	    	if(index % 2 == 0) {
	    		if(s.substring(0,index/2).equals(s.substring(index/2,index)))
	    			break;
	    	}
	    }
	    System.out.println(index); 
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
 
int main()
  {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
    #endif

  long n, m;
  cin >> n >> m;

  int a;
  long sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> a;
    sum += a;
  }
  if (n-sum >= 0)
    cout << n-sum << endl;
  else
    cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 5e3+10;
int n,m,cnt,fa[N],sz[N],p[N],f[N][N],fac[N],pw[N],c[N];
int Find(int x) {return fa[x]?fa[x]=Find(fa[x]):x;}
void add(int x, int y) {
	x=Find(x),y=Find(y);
	if (x!=y) fa[x]=y,sz[y]+=sz[x];
	else ++cnt;
}

int main() {
	scanf("%d", &n);
	REP(i,1,n) sz[i] = 1;
	REP(i,1,n) { 
		scanf("%d", p+i);
		if (p[i]>0) add(i,p[i]);
	}
	fac[0] = pw[0] = 1;
	REP(i,1,n) fac[i]=(ll)fac[i-1]*i%P,pw[i]=(ll)pw[i-1]*(n-1)%P;
	REP(i,1,n) if (p[i]==-1) { 
		++m;
		c[m] = sz[Find(i)];
		f[1][m] = (f[1][m-1]+c[m])%P;
	}
	int ans = (ll)(f[1][m]-m)*pw[m-1]%P;
	REP(i,2,m) {
		REP(j,1,m) f[i][j]=(f[i][j-1]+(ll)c[j]*f[i-1][j-1])%P;
		ans = (ans+(ll)f[i][m]*pw[m-i]%P*fac[i-1])%P;
	}
	ans = ((ll)(n-cnt)*pw[m]-ans)%P;
	if (ans<0) ans += P;
	printf("%d\n", ans);
}


Measured memory_bytes: 101596
/*input

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main(){
	IOS;
	int n,m;
	cin>>n>>m;
	cout<<n-m+1<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i=0; i<n; i++) {a[i] = sc.nextInt();}
		long money = 1000;
		long kabu = 0;

		int min = 100;//底値。
		int max = 100;//上値。
		boolean isUpper = false; // 株価上昇中:true
		//下降から上昇に転じたら買う。上昇から下降に転じたら売る。

		for(int i=1; i<n; i++) {
			if(isUpper) {
				if(a[i-1] > a[i]) {
					//i-1の時点で売り!
					money += kabu * a[i-1];
					kabu = 0;
					isUpper = false;
					min = a[i];
				} else {
					max = a[i];
				}

			} else {
				if(a[i-1] < a[i]) {
					//i-1の時点で買い!
					kabu += money / a[i-1];
					money = money % a[i-1];
					isUpper = true;
					max = a[i];
				} else {
					min = a[i];
				}
			}
		}

		if(isUpper) {
			//上昇中なら最後に売る
			money += kabu * a[n-1];
			kabu = 0;
		} else {
			//下降中で終わるなら、max時点で売ったことにする
			money += kabu * max;
			kabu = 0;
		}
		System.out.printf("%d", money);
	}
}


Measured memory_bytes: 35832