akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
#include <assert.h>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    string S;
    cin >> S;

    ll ans = 0;
    if(S[0] == 'R'){
        if(S[1] == 'R'){
            ans = 2 + (S[2] == 'R');
        }else{
            ans = 1;
        }
    }else{
        if(S[1] == 'R'){
            ans = 1 + (S[2] == 'R');
        }else{
            ans = (S[2] == 'R');
        }
    }

    cout << ans <<endl;

}

int main(){
    Main();
}

Measured memory_bytes: 3192
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	int a,ab,a0, max=0, N, K, c,cost=0;
	cin >> K >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a;
		if (i == 0)
		{
			a0 = a;
			ab = a;
			continue;
		}
		cost += (a - ab);
		if (max < (a - ab))
			max = (a - ab);
		ab = a;
	}
	cost += K-a+a0;
	if (max < (K - a + a0))
		max = (K - a + a0);
	cost -= max;
	cout << cost << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int> > key;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		int s = 0;
		for (int j = 0; j < b; ++j) {
			int c;
			cin >> c;
			--c;
			s |= 1 << c;
		}
		key.push_back({ s, a });
	}
	vector<int> dp(1 << n, 1e9);
	dp[0] = 0;
	for (int s = 0; s < 1 << n; ++s) {
		for (int i = 0; i < m; ++i) {
			int t = s | key[i].first;
			int cost = dp[s] + key[i].second;
			dp[t] = min(dp[t], cost);
		}
	}
	int ans = dp.back();
	if (ans == 1e9) ans = -1;
	cout << ans << endl;
	return 0;
}

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

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

    int N, M;
    cin >> N >> M;
    priority_queue<int> que;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        que.push(a);
    }
    for (int i = 0; i < M; i++) {
        int n = que.top();
        que.pop();
        que.push(n >> 1);
    }
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1020
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x, y;
	cin >> x >> y;
	if(y <= x && x%y == 0) cout << -1 << endl;
	else cout << x << endl;
	return 0;
}

Measured memory_bytes: 3588
//Link : https://atcoder.jp/contests/agc019/tasks/agc019_d

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 2005

char A[N+N],B[N+N];


int l[N+N],r[N+N];

int dist(int x,int n) {
  return min(x, abs(n-x));
}
int getIndex(int x,int n) {
  if(x>=n) {
    return x%n;
  } else if(x<0) {
    return (x%n+n)%n;
  }
  return x;
}

int getMini(int ml,int mr,int k,int n) {
  int ad = mr + ml;
  return ad + min(ml+ dist(getIndex(k+mr,n),n), mr+ dist(getIndex(k-ml,n),n));
}

int solveWhenIndexK(int k,int n) {
  int diff = 0 , ret = 1e9;
  for(int i=0;i<n;++i) {
    if(A[i+k]!=B[i]) {
      ++diff;
    }
  }
  int minLeft;
  for(int i=0;i<n;++i) {
    int index = getIndex(k-i+n,n);
    if(B[index]=='1') {
      minLeft = i;
      break;
    }
  }
  for(int i=0;i<n;++i) {
    int index = getIndex(i+k,n);
    if(B[index]=='1') {
      minLeft = 0;
    }
    l[index] = minLeft;
    ++minLeft;
  }
  int minRight;
  for(int i=0;i<n;++i) {
    int index = getIndex(k+i+ n-1,n);
    if(B[index]=='1') {
      minRight = i;
      break;
    }
  }
  for(int i=0;i<n;++i) {
    int index = getIndex(k+n-1-i,n);;
    if(B[index]=='1') {
      minRight = 0;
    }
    r[index] = minRight;
    ++minRight;
  }
  for(int i=0;i<n;++i) {
    int index = getIndex(i+k,n);
    if(A[index]==B[i]) {
      l[index] = r[index] = 0;
    }
  }
  multiset<int> ss;
  vector<pair<int,int> >pre;
  for(int i=0;i<n;++i) {
    pre.push_back(make_pair(l[i],r[i]));
    ss.insert(r[i]);
  }
  sort(pre.begin(),pre.end());
  int pos = 0;
  for(int ml = 0;ml<=n;++ml) {
    while(pos<pre.size()) {
      if(pre[pos].first<=ml) {
        ss.erase(ss.find(pre[pos].second));
        ++pos;
      } else {
        break;
      }
    }
    int mr = 0;
    if(ss.size()>0) {
      mr = *prev(ss.end());
    }
    if(k-ml>0) {
      mr = max(mr, n-k);
    }
    ret = min(ret, getMini(ml,mr,k,n));
  }

  pre.clear();
  ss.clear();
  for(int i=0;i<n;++i) {
    pre.push_back(make_pair(r[i],l[i]));
    ss.insert(l[i]);
  }
  sort(pre.begin(),pre.end());
  for(int mr = 0;mr<=n;++mr) {
    while(pos<pre.size()) {
      if(pre[pos].first<=mr) {
        ss.erase(ss.find(pre[pos].second));
        ++pos;
      } else {
        break;
      }
    }
    int ml = 0;
    if(ss.size()>0) {
      ml = *prev(ss.end());
    }
    if(k+mr<n) {
      ml = max(ml, k);
    }
    ret = min(ret, getMini(ml,mr,k,n));
  }
  return ret + diff;
}
void solve() {
  scanf(" %s ", A);
  scanf(" %s ", B);

  int n = strlen(A);
  for(int i=0;i<n;++i) {
    B[i+n] = B[i];
    A[i+n] = A[i];
  }
  bool isSame = true;
  for(int i=0;i<n;++i) {
    if(A[i]!=B[i]) {
      isSame = false;
      break;
    }
  }
  if(isSame) {
    printf("0\n");
    return;
  }
  bool isAllZero = true;
  for(int i=0;i<n;++i) {
    if(B[i]!='0') {
      isAllZero = false;
      break;
    }
  }
  if(isAllZero) {
    printf("-1\n");
    return;
  }
  int ret = 1e9;
  for(int k=0;k<n;++k) {
    ret = min(ret, solveWhenIndexK(k,n));
  }
  printf("%d\n", ret);
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> x(6);
    for (int i = 0; i < 6;i++){
        cin >> x.at(i);
    }
    if(x[4]-x[0] > x[5]){
        cout << ":(" << endl;
        return 0;
    }
    cout << "Yay!" << endl;
}

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

int main(){
  string a;
  int b=0;
  cin >> a;
  
  for(int i=0; i<3; i++){
    if(a[i] == a[i+1])b++;
    }
  if(b>0) cout << "Bad" << endl;
  else if(b==0) cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int A;
    int B;
    int C;
    int D = 0;
     cin >> A;

     for(int i;i<A;i++){
         cin >> B;
         cin >> C;
         D += C-B+1;
     }
     cout << D;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
using namespace std;
int main(void){
  int H,W;
   while(1){
       cin>>H>>W;
       if(H==0&&W==0)break;
      
   for(int i=1;i<=H;i++){
     for(int i=1;i<=W;i++){
      cout<<"#";
     }
     cout<<"\n";
    }
  cout<<"\n";
   }
}
   



Measured memory_bytes: 3036
#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

int H,W,N,sr,sc;
string S,T;

int main(){
  cin >>H>>W>>N>>sr>>sc;
  sr--;
  sc--;
  cin>>S;
  cin>>T;
  int startW=0;
  int endW=W;
  REPR(i,N){
    //青木のターン
    if (T[i]=='L'){
      endW=min(endW+1,W);
    }
    if (T[i]=='R'){
      startW=max(startW-1,0);
    }
  	//ちょくだいのターン
    if (S[i]=='L'){
      startW++;
    }
    if (S[i]=='R'){
      endW--;
    }
    if (startW>=endW){//ここで外に絶対出せることが証明された
      cout << "NO" <<endl;return 0;
    }
  }
  
  
  if ((sc<startW)|(sc>=endW)){//ここで外に絶対出せることが証明された
    cout << "NO" << endl;return 0;
  }
  






  int startH=0;
  int endH=H;
  REPR(i,N){
    //青木のターン
    if (T[i]=='U'){
      endH=min(endH+1,H);
    }
    if (T[i]=='D'){
      startH=max(startH-1,0);
    }
  	//ちょくだいのターン
    if (S[i]=='U'){
      startH++;
    }
    if (S[i]=='D'){
      endH--;
    }
    if (startH>=endH){//ここで外に絶対出せることが証明された
      cout << "NO" << endl;return 0;
    }
  }
  
  
  if ((sr<startH)|(sr>=endH)){//ここで外に絶対出せることが証明された
    cout << "NO" << endl;return 0;
  }
  


  cout<<"YES"<<endl;

  return 0;
}

Measured memory_bytes: 776
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	fmt.Print(string(Scanner()[0]))
	fmt.Print(string(Scanner()[0]))
	fmt.Println(string(Scanner()[0]))
}


Measured memory_bytes: 1776
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int k = cin.Int();

			int[] v = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
			Console.WriteLine(v[k - 1]);
		}
	}

	public static class Helper
	{
		public static void UpdateMin32<T>(T array, int index, int value) where T : IList<int>
			=> array[index] = Math.Min(array[index], value);
		public static void UpdateMax32<T>(T array, int index, int value) where T : IList<int>
			=> array[index] = Math.Max(array[index], value);
		public static void UpdateMin64<T>(T array, int index, long value) where T : IList<long>
			=> array[index] = Math.Min(array[index], value);
		public static void UpdateMax64<T>(T array, int index, long value) where T : IList<long>
			=> array[index] = Math.Max(array[index], value);

		public static T[] Array<T>(int n, Func<int, T> init)
			=> Enumerable.Range(0, n).Select(x => init(x)).ToArray();
		public static List<T> List<T>(int n, Func<int, T> init)
			=> Enumerable.Range(0, n).Select(x => init(x)).ToList();
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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


 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int x = (c + b -1) / b;
  int y = (a + d -1) / d;
  
  if (y >= x) cout << "Yes";
  else cout << "No";
  
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll h,w;
    cin>>h>>w;
    if(h==1 or w==1)
        cout<<1<<endl;
    else
    {
        h = h*w;
        h++;
        h = h/2;
        cout<<h<<endl;
    }
    return 0;
}


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

map<string, string> weather = {{"Sunny", "Cloudy"},
                               {"Cloudy", "Rainy"},
                               {"Rainy", "Sunny"}};

int main()
{
  string S;
  cin >> S;
  cout << weather[S];
  return 0;
}

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


int solve(int i, int m, int *a, int n) {
  //solve( 0, 探したい数, 配列のポインタ, 配列の長さ);


  if( m == 0 ) {
    return 1;
  }
  if( i >= n ) {
    return 0;
  }
  return ( solve( i+1, m, a, n) || solve( i+1, m-a[i], a, n) );
}


int *inputIntArray(int n) { 

  int *a;
  int i;

  a = (int *)malloc(sizeof(int) *n);

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

  return a; //配列ポインタ

}


int main() {

  int n,q;
  int *a, *m;

  int i;

  scanf("%d", &n);
  a = inputIntArray( n );

  scanf("%d", &q);
  m = inputIntArray( q );

  for( i=0; i<q; i++) {

    if( solve( 0, m[i], a, n) ) {
      printf("yes\n");
    }
    else {
      printf("no\n");
    }

  }

    return 0;

}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
const int INF = 1e9;
bool check(vector<int> t) {
	int dif = t[1]-t[0];
	rep2(i,2,t.size()) {
		if(t[i]-t[i-1]!=dif) return true;
	}
	return false;
}
int main() {
	int n;
	while(cin >> n, n) {
		int x[110] = {};
		rep(i,n+1) {
			cin >> x[i];
		}
		rep(i,n+1) {
			vector<int> v;
			rep(j,n+1) {
				if(i==j) continue;
				v.push_back(x[j]);
			}
			if(!check(v)) {
				cout << x[i] << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1216
N = int(input())
H = list(map(int, input().split()))
ans = 0
temp = 0
now = H[0]
for i in range(1, N):
    if now >= H[i]:
        temp += 1
    else:
        ans = max(ans, temp)
        temp = 0
    now = H[i]
print(max(ans, temp))

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, k;
string s, t;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> s;
	ll i=0;
	vll ASH(n,0),DOT(n,0);
	for(ll i=0;i<n;i++) ASH[i] = (s[i]=='#'), DOT[i] = (s[i]=='.');
	for(ll i=1;i<n;i++) ASH[i] += ASH[i-1], DOT[i] += DOT[i-1];

	ll mini = min(ASH[n-1], DOT[n-1]);
	//DISP(ASH);
	//DISP(DOT);

	for(ll i=1;i<n;i++) { // i rep no of '.'s at start ..followed by n-i #
		ll dots = ASH[i-1];
		ll ash =  DOT[n-1] - DOT[i-1];

		mini = min(mini, dots + ash);
		///cout<<n<<" "<<dots<<" "<<ash;newl;
	}
	cout<<mini;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 6812
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define inf             LLONG_MAX
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
bool sortbysec(const pair<pair<string,int>,int> &a, 
              const pair<pair<string,int>,int> &b) 
{ 
	if(a.first.first==b.first.first)
		return a.first.second > b.first.second;
    return (a.first.first < b.first.first); 
} 
bool checkValidity(ll a, ll b, ll c) 
{ 
    // check condition 
    if (a + b > c && a + c > b && b + c > a) 
        return false; 
    else
        return true; 
} 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll x,k,d;
        cin>>x>>k>>d;
        x=abs(x);
        ll m=x/d;
        //cout<<m<<" ";
        if(m>k)
        {
            cout<<x-k*d;
            exit(0);
        }
        if(m==k)
        {
            cout<<x-k*d;
            exit(0);
        }
        if(m<k)
        {
            ll l=k-m;
            ll ps=x-m*d;
            //cout<<l<<" "<<ps<<" ";
            if(ps<d-ps || ps>d-ps)
            {
                if(l%2==0)
                {
                    cout<<ps;
                    exit(0);
                }
                else
                {
                    cout<<d-ps;
                    exit(0);
                }
            }
            /*else if(ps>d-ps)
            {
                if(l%2==0)
                {
                    cout<<m;
                    exit(0);
                }
                else
                {
                    cout<<d-ps;
                    exit(0);
                }
            }*/
            else
            {
                cout<<ps;
                exit(0);
            }
        }
         
    } 
    return 0;
}


Measured memory_bytes: 3640
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) {
        par = vector<int>(N,-1);
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x]<0) return x;
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y) { // xとyの木を併合
        x = root(x); //xの根をrx
        y = root(y); //yの根をry
        if (x == y) return false; //xとyの根が同じ(=同じ木にある)時はそのま
        if(par[x]>par[y]) swap(x,y);
        par[x]+=par[y];
        par[y] = x;
        return true; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x){
        return -par[root(x)];
    }
};

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

    ll n,m;
    cin>>n>>m;
    UnionFind uf(n);
    ll res=0;
    rep(i,m){
        int a,b;cin>>a>>b;
        --a;--b;
        uf.unite(a,b);
    }

    rep(i,n) if(uf.root(i)==i)res++;
    cout<<res-1<<endl;

}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n)
    {
        vector<int>a(n);
        for(int i=0;i<n;i++)cin>>a[i];
        sort(a.begin(),a.end());
        int sum=0;
        for(int i=1;i<=n-2;i++)sum+=a[i];
        cout<<sum/(n-2)<<endl;
    }
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    while(cin>>n>>m){
        int arr[n];
        int sum=0;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            sum+=arr[i];
        }
        sort(arr,arr+n,greater<int>());
        int req=(sum)/(4*m);
        if(req*(4*m)!=sum) req++;
        bool ok=1;
        for(int i=0;i<m;i++){
            if(arr[i]<req){
                ok=0;
                break;
            }
        }
        if(ok)cout << "Yes\n";
        else cout << "No\n";
    }
}


Measured memory_bytes: 3620
# coding: utf-8
n,m = map(int, input().split())
l=[]
r=[]
for i in range(m):
    l1,r1=map(int, input().split())
    l.append(l1)
    r.append(r1)
maxl = max(l)
minr = min(r)
if minr-maxl+1 > 0:
    print(minr-maxl+1)
else:
    print(0)

Measured memory_bytes: 10996
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a,b,d,r;
    double f;
    cin>>a>>b;
    d = a/b;
    r = a - d*b;
    f = double(a)/double(b);
    printf("%d %d %.5lf\n",d,r,f);
    return 0;
}


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

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define INF 100000000000ULL

using namespace std;

namespace Kyopro {

    using ll = long long;

    const double PI = acos(-1);

    const ll MOD = 998244353LL;

    const int MAX = 210000;

    long long fac[MAX], finv[MAX], inv[MAX];

    // テーブルを作る前処理
    void COMinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    // 二項係数計算
    long long COM(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    long long modpow(long long a, long long n, long long mod) {
        long long res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    ll f(size_t m, size_t n) {
        ll ret = (m * modpow(m - 1, n - 1, MOD)) % MOD;
        return ret;
    }

    long long modinv(long long a, long long m) {
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    ll combinations2(size_t n, size_t k) {
        ll r = 1;
        for (ll d = 1; d <= k; ++d) {
            r *= n--;
            r = r % MOD;
            r = r * modinv(d, MOD);
            r = r % MOD;
        }
        if (r > MOD / 2) {
            r -= MOD;
        }
        return r;
    }
}

using namespace Kyopro;

void solve() {
    ll x, y;
    cin >> x >> y;
    if (((4 * x - y) % 2 == 0) && ((y - 2 * x) % 2 == 0) && (4 * x - y >= 0) && ((y - 2 * x) >= 0)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

    COMinit();

    solve();

    return 0;
}

Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(x) scanf("%d", &x)
#define sc(x) scanf("%c", &x)
#define sl(x) scanf("%lld", &x)
#define pl(x) printf("%lld\n", x)
#define pi(x) printf("%d\n", x)
#define pii pair <int, int>
#define pll pair <long long, long long>
#define gu getchar_unlocked
#define pu putchar_unlocked
#define setbits __builtin_popcountll
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define speed ios::sync_with_stdio(false)

const int N = 100005;

int B[105];

int main(){
    int n;
    si(n);
    for(int i = 1; i < n; i++){
    	si(B[i]);
    }
    int sum = B[1] + B[n - 1];
    for(int i = 2; i < n; i++){
    	int temp = min(B[i - 1], B[i]);
    	sum += temp;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
import bisect
n=int(input())
a=[int(input()) for _ in range(n)][::-1]
lis=[a[0]]
for i in a[1:]:
  if i>=lis[-1]:
    lis.append(i)
  else:
    lis[bisect.bisect_right(lis,i)]=i
print(len(lis))

Measured memory_bytes: 8480
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
using ll = long long;
using ld = long double;
using Vi = V<int>;  using VVi = V<Vi>;
using Vl = V<ll>;   using VVl = V<Vl>;
using Vd = V<ld>;   using VVd = V<Vd>;
using Vb = V<bool>; using VVb = V<Vb>;
using Pi = P<int>;
using Pl = P<ll>;
using Pd = P<ld>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline ll cDiv(const ll x, const ll y) { return (x+y-1) / y; } // ceil(x/y)
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); } // floor(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); } // ceil(log2(x))
inline int popcount(const ll x) { return __builtin_popcountll(x); }
inline void fail() { cout << -1 << '\n'; exit(0); }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
// const int INF  = 1<<30;
// const ll INFll = 1ll<<60;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


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

  int n = sz(s);

  if (s[n-1] == 's') s += "es";
  else s += "s";

  cout << s << '\n';
}


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

#define int long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define endl "\n"

unordered_map<char, int>m;

int32_t main()
{
	IOS;
	string w;
	cin >> w;
	for (auto x : w)
		m[x]++;
	int flag = 0;
	for (char c = 'a'; c <= 'z'; c++)
	{
		if (m[c] & 1)
		{
			flag = 1;
			break;
		}
	}
	if (flag)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n; cin >> n;

    for(int i = 0;i < n * 2;i ++){
        if((int)(i * 1.08) == n){
            cout << i << endl;
            break;
        }
        if(i == n*2-1) cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n,t,x,y;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(x+y>t)
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==0&&t%2==1)
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==1&&t%2==0)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
 int T;
 int h,m,s;
 int temp1;
 scanf("%d",&T);
 h=T/3600;
 temp1=T%3600;
 m=temp1/60;
 s=temp1%60;

 printf("%d:%d:%d\n",h,m,s);

 return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)

#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;

int dp[100010][26];
signed main() {
	
	fastio();
	//#define LOCAL_DEFINE
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int a,b;
	cin>>a>>b;
	cout<<max(2*a-1,max(2*b-1,a+b));
	return  0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const int N = 18, M = (1 << N) + 5,
  P = 998244353, I2 = (P + 1) / 2;
 
inline int fpow(int x, int y) {
  int ret = 1;
  for ( ; y; y >>= 1, x = 1ll * x * x % P)
    if (y & 1) ret = 1ll * ret * x % P;
  return ret;
}
 
int n, f[M], p[M], s;
 
inline void FWT(int A[], int o) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += i << 1)
      for (int k = 0; k < i; ++k) {
        int nx = A[j + k], ny = A[i + j + k];
        A[j + k] = (nx + ny) % P;
        A[i + j + k] = (nx - ny + P) % P;
        if (o == -1) {
          A[j + k] = 1ll * A[j + k] * I2 % P;
          A[i + j + k] = 1ll * A[i + j + k] * I2 % P;
        }
      }
}
 
int main() {
  scanf("%d", &n); n = 1 << n;
  for (int i = 0; i < n; ++i)
    scanf("%d", p + i), s += p[i];
  s = fpow(s, P - 2);
  for (int i = 0; i < n; ++i)
    p[i] = 1ll * p[i] * s % P;
  p[0] = (p[0] - 1 + P) % P;
  for (int i = 0; i < n; ++i)
    f[i] = P - 1;
  f[0] += n;
  FWT(p, 1), FWT(f, 1);
  for (int i = 0; i < n; ++i)
    f[i] = 1ll * f[i] * fpow(p[i], P - 2) % P;
  FWT(f, -1);
  for (int i = 0; i < n; ++i)
    printf("%d\n", (f[i] - f[0] + P) % P);
  return 0;
}

Measured memory_bytes: 5836
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int S = scan.nextInt();
		int W = scan.nextInt();
		String result = "unsafe";
		if(S>W) {
			result="safe";
		}
		scan.close();
		System.out.println(result);
	}
}

Measured memory_bytes: 35780
# -*- coding: utf-8 -*-
n = int(input())
s = input()

x = [0 for _ in range(n + 1)]
for i in range(n):
    if s[i] == 'I':
        x[i + 1] = x[i] + 1 
    else:
        x[i + 1] = x[i] - 1
print(max(x))


Measured memory_bytes: 2940
#include <iostream>

int main(int argc, const char * argv[]) {
    
    int a, b, c ;
    
    std::cin >> a >> b >> c ;
    
    if (a < b && b < c) {
        std::cout << "Yes" << std::endl ;
    } else {
        std::cout << "No" << std::endl ;
    }
    
    return 0;
}


Measured memory_bytes: 3104
N, M, R = map(int, input().split())
R_LIST = list(map(int, input().split()))
ABC = []
for _ in range(M):
    a,b,c = map(int, input().split())
    ABC.append((a,b,c))
    
    

    
edges = ABC[:]


def warshall_floyd(d, n):
    # d: グラフ二次元リスト
    # n: 頂点数 (0始まり)
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

# グラフ無効グラフ化
graph = [[float("inf") for i in range(N+1)] for i in range(N+1)] 
for x,y,z in edges:
    graph[x][y] = z
    graph[y][x] = z
for i in range(N+1):
    graph[i][i] = 0 #自身のところに行くコストは０

#最短経路
shortest =  warshall_floyd(graph, N+1)
    
# 順列全探索
import sys
INT_MAX = sys.maxsize # 9223372036854775807
ans = INT_MAX

import queue

rest = set(R_LIST[:])

import copy  
def dfs(cost,pre,rest):
    if len(rest) == 0:
        return cost
    
    ret = INT_MAX
    for r in rest:
        if pre == None:
            next_cost = 0
        else:
            next_cost = cost + shortest[pre][r]
        next_rest = copy.copy(rest)
        next_rest.remove(r)
        
        tmp_ret = dfs(next_cost, r, next_rest)
        ret = min(ret, tmp_ret)
        
    return ret
        
    

print(dfs(0, None, rest))
            
      
        
        



Measured memory_bytes: 75092
#include <stdio.h>
int main(){
    int N;
    int A[200010];
    scanf("%d",&N);
    int i;
    int a;
    int j;
    a=0;
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
        if(a<A[i]){
            a=A[i];
            j=i;
        }
    }
    int k;
    int b;
    b=0;
    for(i=0;i<N;i++){
        if(i!=j){
            if(b<A[i]){
                b=A[i];
                k=i;
            }
        }
    }
    for(i=0;i<N;i++){
        if(i!=j){
            printf("%d\n",a);
        }else{
            printf("%d\n",b);
        }
    }
}

Measured memory_bytes: 2304
#include <iostream>
using namespace std;
int main() {
    long n,cnt=1,index,i,min,flag=0,j;
    cin>>n;
    min=n;
    long a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
        if(i==0)
        min=a[i];
        else{
            if(a[i]<min)
            {
                min=a[i];
                cnt++;
            }
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define IOSF ios::sync_with_stdio(false)
typedef long long LL;
using namespace std;
const int INF=0x3f3f3f3f;
const int MAX=10e5+5;
const int MOD=10e9+7;

int a,b,n,flag=1;
LL math[MAX];
LL com[MAX];

int main() {
    IOSF;
    LL temp,mid;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>math[i];
        com[i]=math[i];
    }
    sort(math,math+n+1);
    mid=math[n/2];
    for(int i=1;i<=n;i++){
        temp=com[i];
        if(temp<=mid)
            cout<<math[n/2+1]<<endl;
        else
            cout<<mid<<endl;
    }
    return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n,k;
  const int max_n = 2 * 1e5;
  int a[max_n + 1];
  cin >> n >> k;
  int max_a = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    max_a = max(max_a, a[i]);
  }
  int left = 0;
  int right = max_a;
  int x;
  int sum = 0;
  while(right - left > 1){
    sum = 0;
    x = (right + left) / 2;
    for(int i = 0; i < n; i++){
      if(a[i] == x) sum += a[i] / x - 1;
      else sum += a[i] / x;
    }
    // cout << "x= " << x << ", sum = " << sum << endl;
    if(sum <= k) right = x;
    else left = x;
    // if(right - left <= 1) break;
  }

  cout << right << endl;

  return 0;
}

Measured memory_bytes: 4312
/*Lower_Rating*/
/*dianfenzhi*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<bitset>
#include<map>
using namespace std;

#define LL long long
#define DB double
#define Pr pair<int,int>
#define X first
#define Y second
#define MAXN 100
#define MAXK 10000000
#define eps 1e-10
#define INF 2147483647
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}

int n,m;
char s[MAXN+5][MAXN+5];
int dp[MAXN+5][MAXN+5];
int main(){
    n=read(),m=read();
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    mem(dp,0x3f);
    dp[1][1]=(s[1][1]=='#');
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(s[i][j]=='#'){
                if(i>1)dp[i][j]=min(dp[i][j],dp[i-1][j]+(s[i-1][j]!='#'));
                if(j>1)dp[i][j]=min(dp[i][j],dp[i][j-1]+(s[i][j-1]!='#'));
            }else{
                if(i>1)dp[i][j]=min(dp[i][j],dp[i-1][j]);
                if(j>1)dp[i][j]=min(dp[i][j],dp[i][j-1]);
            }
    printf("%d",dp[n][m]);
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%s", $o);
fscanf(STDIN, "%s", $e);

$str = '';
for($i=0;$i<strlen($o);$i++){

$str .=    substr($o, $i,1);    
if(strlen($e)>$i){
$str .=    substr($e, $i,1);
}
}


echo $str;        


Measured memory_bytes: 3576
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

C = [[0,0,0,0]]
for i in range(3):
    C.append([0] + LI())

"""
yxの順
a1 + b1 = c11
a2 + b1 = c21
a3 + b1 = c31
a1 + b2 = c12
a2 + b2 = c22

b1 = b2 + c11 - c12
b2 = -a2 + c22
b1 = -a2 + c22 + c11 - c12
a2 - a2 + c22 + c11 - c12 = c21
c22+c11 = c21 + c12

"""
#  print(C)
if (C[2][2] + C[1][1] - C[1][2] == C[2][1]) and (C[1][1] + C[3][3] == C[1][3] + C[3][1]) and (C[2][2] + C[3][3] == C[2][3] + C[3][2]):
    print("Yes")
else:
    print("No")


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

public class Hello{
    public static void Main(){
        string[]array=Console.ReadLine().Split(' ');
        int N=int.Parse(array[0]);
        int K=int.Parse(array[1]);
        if(K==1)Console.WriteLine(0);
        else Console.WriteLine(N-K);
    }
}

Measured memory_bytes: 13140
import math

A,B,H,M = map(int,input().split())

H = (H*360/12)+(M*30/60)
M = M*360/60

a = abs(H-M)
# print(a)
ans = math.sqrt((A**2)+(B**2)-2*A*B*math.cos(math.radians(a)))
print(ans)



Measured memory_bytes: 62380
import java.util.Scanner

import scala.annotation.tailrec

// [(a,b,c) | abc<=k]をソート (リファクタリング)
object Main {
  def read(): (Int, Int, Int, Int, IndexedSeq[Long], IndexedSeq[Long], IndexedSeq[Long]) = {
    val sc = new Scanner(System.in)
    val n1, n2, n3, k = sc.nextInt()
    val l1 = for (_ <- 0 until n1) yield sc.nextLong()
    val l2 = for (_ <- 0 until n2) yield sc.nextLong()
    val l3 = for (_ <- 0 until n3) yield sc.nextLong()
    (n1, n2, n3, k, l1, l2, l3)
  }


  def solve(n1: Int, n2: Int, n3: Int, k: Int, l1: IndexedSeq[Long], l2: IndexedSeq[Long], l3: IndexedSeq[Long]): IndexedSeq[Long] = {

    // breakを使わない実装
    // (i1, i2) => [(i1,i2,i3) | i3<- l3.indices, (i1+1)*(i2+1)*(i3+1)<=k]を求める。
    // 愚直にfilterすると遅いので、i3 => (i1+1)*(i2+1)*(i3+1)の単調性を利用する
    def i3List(i1: Int, i2: Int): List[Int] = {
      @tailrec // 末尾再帰でなくてもどうにかなる(たかだか1000回再帰なので)
      def sub(i3: Int, acc: List[Int]): List[Int] = {
        if (!l3.isDefinedAt(i3)) acc
        else if ((i1 + 1) * (i2 + 1) * (i3 + 1) > k) acc
        else sub(i3 + 1, i3 :: acc)
      }

      sub(i3 = 0, Nil)
    }

    val indexListRequirementOfTopk: IndexedSeq[(Int, Int, Int)] =
      for (i1 <- l1.indices;
           i2 <- l2.indices;
           i3 <- i3List(i1, i2)
      ) yield (i1, i2, i3)

    val sortedL1 = l1.sorted.reverse
    val sortedL2 = l2.sorted.reverse
    val sortedL3 = l3.sorted.reverse
    indexListRequirementOfTopk.map { case (i1, i2, i3) => sortedL1(i1) + sortedL2(i2) + sortedL3(i3) }.sorted.reverse.take(k)
  }

  def printResult(result: IndexedSeq[Long]) = {
    result.foreach(println)
  }


  def main(args: Array[String]): Unit = {
    val (n1, n2, n3, k, l1, l2, l3) = read()
    printResult(solve(n1, n2, n3, k, l1, l2, l3))
  }
}

Measured memory_bytes: 61764
public class Main {

  private static void solve() {
    long x = nl();

    long now = 100;
    for (int i = 1;; i++) {
      now = now + now / 100;
      if (now >= x) {
        System.out.println(i);
        return;
      }
    }


  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 36772
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1]; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1]; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define pb(x) push_back(x)
#define vi vector <int>
#define pi pair <int, int>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	READ(n);
	READARR(a, n);
	
	bool b[n + 1] = {};
	int c = 0;
	FORD (i, n, 1)
	{
		int cnt = 0;
		for (int j = 2*i; j <= n; j += i)
			if (b[j]) cnt++;
		cnt %= 2;
		if (cnt != a[i]) {b[i] = 1; c++;}
	}
	
	cout << c << endl;
	FOR (i, 1, n) 
		if (b[i]) cout << i << " ";
}

Measured memory_bytes: 2688